chimpanzee
Advanced tools
Comparing version 0.0.54 to 0.0.55
@@ -68,3 +68,4 @@ "use strict"; | ||
const result = (0, _parse2.default)(schema)(obj, key, parents, parentKeys)(context); | ||
return result instanceof _results.Match || result instanceof _results.Empty ? rest.length ? run(rest, result instanceof _results.Match ? (0, _merge2.default)(state, result.value) : state) : new _results.Match(result instanceof _results.Match ? (0, _merge2.default)(state, result.value) : state, env, meta) : result; | ||
const mergeArray = schema.params && schema.params.mergeArray; | ||
return result instanceof _results.Match || result instanceof _results.Empty ? rest.length ? run(rest, result instanceof _results.Match ? (0, _merge2.default)(state, result.value, { mergeArray }) : state) : new _results.Match(result instanceof _results.Match ? (0, _merge2.default)(state, result.value, { mergeArray }) : state, env, meta) : result; | ||
}(schemas, {}) : new _results.Empty(env, meta); | ||
@@ -71,0 +72,0 @@ }; |
@@ -14,6 +14,11 @@ "use strict"; | ||
function merge(target, source) { | ||
function merge(target, source, options) { | ||
return isObject(target) && isObject(source) ? Object.keys(target).concat(Object.keys(source)).reduce(function (acc, key) { | ||
return target[key] && source[key] ? _extends({}, acc, { [key]: merge(target[key], source[key]) }) : source[key] ? _extends({}, acc, { [key]: source[key] }) : acc; | ||
}, _extends({}, target)) : Array.isArray(target) && Array.isArray(source) ? [...target, ...source.filter(function (i) { | ||
return target[key] && source[key] ? _extends({}, acc, { [key]: merge(target[key], source[key], options) }) : source[key] ? _extends({}, acc, { [key]: source[key] }) : acc; | ||
}, _extends({}, target)) : Array.isArray(target) && Array.isArray(source) ? options.mergeArray ? function () { | ||
const [longer, shorter] = target.length > source.length ? [target, source] : [source, target]; | ||
return longer.reduce(function (acc, item, i) { | ||
return acc.concat(i < shorter.length ? isObject(item) && isObject(shorter[i]) ? [merge(item, shorter[i])] : [item, shorter[i]] : [i]); | ||
}, []); | ||
}() : [...target, ...source.filter(function (i) { | ||
return !target.includes(i); | ||
@@ -20,0 +25,0 @@ })] : target; |
{ | ||
"name": "chimpanzee", | ||
"version": "0.0.54", | ||
"version": "0.0.55", | ||
"author": "Isotropy Team<isotropy@agilehead.com>", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
208849
1222