Comparing version 0.6.7-rc1 to 0.6.7-rc2
@@ -40,2 +40,5 @@ "use strict"; | ||
}; | ||
_.$diff = function (_object) { | ||
return (0, _utils.$diff)(_object); | ||
}; | ||
_.$use(_object); | ||
@@ -42,0 +45,0 @@ return _; |
@@ -88,3 +88,3 @@ "use strict"; | ||
var newDepth = depth ? depth + ("." + _key) : _key; | ||
var out = onAny && onAny({ | ||
onAny && onAny({ | ||
hook: "onAny", | ||
@@ -98,4 +98,4 @@ object: object, | ||
if (_val) { | ||
if (typeof _val === "function") { | ||
onFunction && onFunction({ | ||
if (onFunction && typeof _val === "function") { | ||
onFunction({ | ||
hook: "onFunction", | ||
@@ -108,5 +108,5 @@ object: object, | ||
}); | ||
} else if ((typeof _val === "undefined" ? "undefined" : (0, _typeof3.default)(_val)) === "object") { | ||
} else if ((onArray || onObject) && (typeof _val === "undefined" ? "undefined" : (0, _typeof3.default)(_val)) === "object") { | ||
if (Array.isArray(_val)) { | ||
onArray && onArray({ | ||
onArray({ | ||
hook: "onArray", | ||
@@ -120,3 +120,3 @@ object: object, | ||
} else { | ||
onObject && onObject({ | ||
onObject({ | ||
hook: "onObject", | ||
@@ -123,0 +123,0 @@ object: object[_key], |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports._get = exports.$get = exports.$merge = exports._set = exports.$set = exports.$use = undefined; | ||
exports._diff = exports.$diff = exports._get = exports.$get = exports.$merge = exports._set = exports.$set = exports.$use = undefined; | ||
@@ -102,2 +102,3 @@ var _typeof2 = require("babel-runtime/helpers/typeof"); | ||
(0, _lodash4.default)(cache, depth, _val); | ||
return; | ||
}; | ||
@@ -114,2 +115,3 @@ var onFunction = function onFunction(_ref3) { | ||
(0, _lodash4.default)(cache, depth, result); | ||
return; | ||
}; | ||
@@ -123,2 +125,7 @@ | ||
if (Object.keys(object).length === 0) { | ||
(0, _lodash4.default)(_, depth, _val); | ||
(0, _lodash4.default)(cache, depth, _val); | ||
return; | ||
} | ||
(0, _utils.scanObject)({ | ||
@@ -171,2 +178,3 @@ object: object, | ||
!result && (0, _lodash4.default)(cache, depth, _val); | ||
return; | ||
}; | ||
@@ -184,2 +192,3 @@ | ||
!result && (0, _lodash4.default)(cache, depth, _val); | ||
return; | ||
}; | ||
@@ -193,2 +202,9 @@ | ||
if (Object.keys(object).length === 0) { | ||
var result = (0, _lodash2.default)(_, depth); | ||
result && (0, _lodash4.default)(cache, depth, result); | ||
!result && (0, _lodash4.default)(cache, depth, _val); | ||
return; | ||
} | ||
(0, _utils.scanObject)({ | ||
@@ -206,2 +222,48 @@ object: object, | ||
return cache; | ||
}; | ||
var $diff = exports.$diff = function $diff(_, _object) { | ||
if (Array.isArray(_object)) { | ||
var cache = []; | ||
(0, _utils.$)(_object, function (key, val) { | ||
cache[key] = _diff(_, val); | ||
}); | ||
return cache; | ||
} | ||
if ((typeof _object === "undefined" ? "undefined" : (0, _typeof3.default)(_object)) === "object") { | ||
return _diff(_, _object); | ||
} | ||
}; | ||
var _diff = exports._diff = function _diff(_, _object) { | ||
var cache = {}; | ||
var onObject = function onObject(_ref8) { | ||
var object = _ref8.object, | ||
depth = _ref8.depth, | ||
_key = _ref8._key, | ||
_val = _ref8._val; | ||
var target = (0, _lodash2.default)(_, depth, {}); | ||
(0, _utils.$)(object, function (key, val) { | ||
if ((typeof val === "undefined" ? "undefined" : (0, _typeof3.default)(val)) === "object") { | ||
return; | ||
} | ||
var result = target[key]; | ||
if (result !== val) { | ||
var newDepth = depth + "." + key; | ||
(0, _lodash4.default)(cache, newDepth, val); | ||
} | ||
return; | ||
}); | ||
(0, _utils.scanObject)({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ object: _object, depth: "" }); | ||
return cache; | ||
}; |
{ | ||
"name": "menhera", | ||
"version": "0.6.7-rc1", | ||
"version": "0.6.7-rc2", | ||
"main": "dist", | ||
@@ -5,0 +5,0 @@ "files": [ |
24037
658