Comparing version 1.1.1 to 1.1.2
@@ -1,2 +0,2 @@ | ||
function r(r){var t=r&&r.pop?[]:{};for(var n in r)t[n]=r[n];return t}export default function(t,n,l){n.split&&(n=n.split("."));for(var o=r(t),a=o,e=0,f=n.length;e<f;e++)a=a[n[e]]=e===f-1?l.call?l(a[n[e]]):l:r(a[n[e]]);return o} | ||
function r(r){var t=r&&r.pop?[]:{};for(var n in r)t[n]=r[n];return t}export default function(t,n,l){n.split&&(n=n.split("."));for(var o=r(t),a=o,e=0,f=n.length;e<f;e++)a=a[n[e]]=e===f-1?l&&l.call?l(a[n[e]]):l:r(a[n[e]]);return o} | ||
//# sourceMappingURL=clean-set.es.js.map |
@@ -1,2 +0,2 @@ | ||
function r(r){var n=r&&r.pop?[]:{};for(var t in r)n[t]=r[t];return n}module.exports=function(n,t,o){t.split&&(t=t.split("."));for(var l=r(n),e=l,i=0,p=t.length;i<p;i++)e=e[t[i]]=i===p-1?o.call?o(e[t[i]]):o:r(e[t[i]]);return l}; | ||
function r(r){var n=r&&r.pop?[]:{};for(var t in r)n[t]=r[t];return n}module.exports=function(n,t,o){t.split&&(t=t.split("."));for(var l=r(n),e=l,i=0,p=t.length;i<p;i++)e=e[t[i]]=i===p-1?o&&o.call?o(e[t[i]]):o:r(e[t[i]]);return l}; | ||
//# sourceMappingURL=clean-set.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.cleanSet=n()}(this,function(){function e(e){var n=e&&e.pop?[]:{};for(var t in e)n[t]=e[t];return n}return function(n,t,o){t.split&&(t=t.split("."));for(var f=e(n),i=f,r=0,u=t.length;r<u;r++)i=i[t[r]]=r===u-1?o.call?o(i[t[r]]):o:e(i[t[r]]);return f}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).cleanSet=n()}(this,function(){function e(e){var n=e&&e.pop?[]:{};for(var t in e)n[t]=e[t];return n}return function(n,t,o){t.split&&(t=t.split("."));for(var f=e(n),i=f,r=0,u=t.length;r<u;r++)i=i[t[r]]=r===u-1?o&&o.call?o(i[t[r]]):o:e(i[t[r]]);return f}}); | ||
//# sourceMappingURL=clean-set.min.js.map |
declare module 'clean-set' { | ||
function cleanSet<A>( | ||
source: A, | ||
keys: string | string[], | ||
update: <B>(value: B) => B | ||
): A; | ||
function cleanSet<A>(source: A, keys: string | string[], update: any): A; | ||
/** | ||
@@ -9,7 +15,3 @@ * Update a value in a deeply nested object and clone each node touched | ||
*/ | ||
export default function<A>( | ||
source: A, | ||
keys: string | string[], | ||
update: <B>(value: B) => B | any | ||
): A; | ||
export default cleanSet; | ||
} |
@@ -12,3 +12,3 @@ export default function(source, keys, update) { | ||
i === l - 1 | ||
? !!update.call | ||
? update && !!update.call | ||
? update(last[keys[i]]) | ||
@@ -15,0 +15,0 @@ : update |
{ | ||
"name": "clean-set", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "A fast deep assignment alternative to the object spread operator and Object.assign", | ||
@@ -30,4 +30,4 @@ "umd:main": "dist/clean-set.min.js", | ||
"esm": "^3.2.18", | ||
"microbundle": "^0.11.0", | ||
"nyc": "^13.3.0", | ||
"microbundle": "^0.12.0", | ||
"nyc": "^15.0.1", | ||
"prettier": "^1.16.4", | ||
@@ -34,0 +34,0 @@ "tap-difflet": "^0.7.1", |
@@ -0,0 +0,0 @@ # clean-set |
@@ -172,2 +172,14 @@ import test from 'tape'; | ||
test('clean-set: allows setting to null', tap => { | ||
let next = cleanSet(data, 'q.r', null); | ||
tap.assert(next != null, 'next has a value'); | ||
tap.assert(next !== data, 'next has a new reference'); | ||
tap.same(next.q, { r: null } , 'object was created and value set to null'); | ||
tap.end(); | ||
}); | ||
test('clean-set: performance benchmark', tap => { | ||
@@ -174,0 +186,0 @@ let cData = data, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34085
17
232