From 20201756d3bc744d058bb2e41559ad929fae88e5 Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Tue, 29 Mar 2016 17:14:52 -0700 Subject: [PATCH 1/3] Remove lodash dependency --- package.json | 2 +- src/IterableSchema.js | 2 +- src/UnionSchema.js | 2 +- src/index.js | 10 ++++++---- src/utils.js | 4 ++++ 5 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 src/utils.js diff --git a/package.json b/package.json index a265c16d..288eb6b8 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,6 @@ "webpack": "^1.10.5" }, "dependencies": { - "lodash": "^4.0.0" + "lodash.isequal": "^4.1.1" } } diff --git a/src/IterableSchema.js b/src/IterableSchema.js index 739ae069..7950acdb 100644 --- a/src/IterableSchema.js +++ b/src/IterableSchema.js @@ -1,4 +1,4 @@ -import isObject from 'lodash/isObject'; +import { isObject } from './utils'; import UnionSchema from './UnionSchema'; export default class ArraySchema { diff --git a/src/UnionSchema.js b/src/UnionSchema.js index 6b7d1c58..2b7e777f 100644 --- a/src/UnionSchema.js +++ b/src/UnionSchema.js @@ -1,4 +1,4 @@ -import isObject from 'lodash/isObject'; +import { isObject } from './utils'; export default class UnionSchema { constructor(itemSchema, options) { diff --git a/src/index.js b/src/index.js index 58ed6129..16939bc7 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,8 @@ import EntitySchema from './EntitySchema'; import IterableSchema from './IterableSchema'; import UnionSchema from './UnionSchema'; -import isObject from 'lodash/isObject'; -import isEqual from 'lodash/isEqual'; -import mapValues from 'lodash/mapValues'; +import isEqual from 'lodash.isequal'; +import { isObject } from './utils'; function defaultAssignEntity(normalized, key, entity) { normalized[key] = entity; @@ -41,7 +40,10 @@ function visitIterable(obj, iterableSchema, bag, options) { if (Array.isArray(obj)) { return obj.map(curriedItemMapper); } else { - return mapValues(obj, curriedItemMapper); + return Object.keys(obj).reduce(function (objMap, key) { + objMap[key] = curriedItemMapper(obj[key]); + return objMap; + }, {}); } } diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 00000000..b39ae761 --- /dev/null +++ b/src/utils.js @@ -0,0 +1,4 @@ +export function isObject(value) { + var type = typeof value; + return !!value && (type === 'object' || type === 'function'); +} From f667f2de1ce80e27dce242d0dffdbd8a2c36498b Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Wed, 30 Mar 2016 08:34:02 -0700 Subject: [PATCH 2/3] include lodash for dev/test --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 288eb6b8..ea2ca0ed 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "babel-core": "^5.8.3", "babel-loader": "^5.3.2", "chai": "^3.2.0", + "lodash": "^4.6.1", "mocha": "^2.2.5", "rimraf": "^2.4.2", "webpack": "^1.10.5" From 4374528fa9944f1173e2cb8e94bd34cb06bfe97d Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Wed, 30 Mar 2016 09:47:55 -0700 Subject: [PATCH 3/3] revert removing all of lodash --- package.json | 3 +-- src/IterableSchema.js | 2 +- src/UnionSchema.js | 2 +- src/index.js | 4 ++-- src/utils.js | 4 ---- 5 files changed, 5 insertions(+), 10 deletions(-) delete mode 100644 src/utils.js diff --git a/package.json b/package.json index ea2ca0ed..a265c16d 100644 --- a/package.json +++ b/package.json @@ -36,12 +36,11 @@ "babel-core": "^5.8.3", "babel-loader": "^5.3.2", "chai": "^3.2.0", - "lodash": "^4.6.1", "mocha": "^2.2.5", "rimraf": "^2.4.2", "webpack": "^1.10.5" }, "dependencies": { - "lodash.isequal": "^4.1.1" + "lodash": "^4.0.0" } } diff --git a/src/IterableSchema.js b/src/IterableSchema.js index 7950acdb..739ae069 100644 --- a/src/IterableSchema.js +++ b/src/IterableSchema.js @@ -1,4 +1,4 @@ -import { isObject } from './utils'; +import isObject from 'lodash/isObject'; import UnionSchema from './UnionSchema'; export default class ArraySchema { diff --git a/src/UnionSchema.js b/src/UnionSchema.js index 2b7e777f..6b7d1c58 100644 --- a/src/UnionSchema.js +++ b/src/UnionSchema.js @@ -1,4 +1,4 @@ -import { isObject } from './utils'; +import isObject from 'lodash/isObject'; export default class UnionSchema { constructor(itemSchema, options) { diff --git a/src/index.js b/src/index.js index 16939bc7..6ca61400 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,8 @@ import EntitySchema from './EntitySchema'; import IterableSchema from './IterableSchema'; import UnionSchema from './UnionSchema'; -import isEqual from 'lodash.isequal'; -import { isObject } from './utils'; +import isEqual from 'lodash/isEqual'; +import isObject from 'lodash/isObject'; function defaultAssignEntity(normalized, key, entity) { normalized[key] = entity; diff --git a/src/utils.js b/src/utils.js deleted file mode 100644 index b39ae761..00000000 --- a/src/utils.js +++ /dev/null @@ -1,4 +0,0 @@ -export function isObject(value) { - var type = typeof value; - return !!value && (type === 'object' || type === 'function'); -}