Socket
Socket
Sign inDemoInstall

simple-update-in

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-update-in - npm Package Compare versions

Comparing version 2.0.2-master.004542e to 2.0.2-master.0861f0c

2

CHANGELOG.md

@@ -8,2 +8,4 @@ # Changelog

## [Unreleased]
### Fixed
- Fix [#16](https://github.com/compulim/simple-update-in/issues/16), parents should not be removed when `updater` is or returned `undefined`, in PR [#17](https://github.com/compulim/simple-update-in/issues/17)

@@ -10,0 +12,0 @@ ## [2.0.1] - 2018-12-03

56

dist/simple-update-in.development.js

@@ -444,2 +444,6 @@ (function (global, factory) {

function setValue(obj, path, target) {
if (!path.length) {
return target;
}
var _path3 = _toArray(path),

@@ -449,6 +453,2 @@ accessor = _path3[0],

if (!path.length) {
return target;
}
var value = typeof obj !== 'undefined' && obj[accessor];

@@ -464,5 +464,17 @@ var nextObj = obj;

if (typeof accessor === 'number') {
if (typeof target !== 'undefined') {
var nextValue = setValue(value, nextPath, target);
var nextValue = setValue(value, nextPath, target);
if (typeof nextValue === 'undefined') {
if (typeof obj === 'undefined') {
return obj;
} else {
// If updater returned undefined or no updater at all, delete the item
if (accessor in nextObj) {
nextObj = _toConsumableArray(nextObj);
nextObj.splice(accessor, 1);
}
return nextObj;
}
} else {
if (nextValue === value) {

@@ -475,15 +487,19 @@ return obj;

}
} // If updater returned undefined or no updater at all, delete the item
if (accessor in nextObj) {
nextObj = _toConsumableArray(nextObj);
nextObj.splice(accessor, 1);
}
return nextObj;
} else {
if (typeof target !== 'undefined') {
var _nextValue = setValue(value, nextPath, target);
var _nextValue = setValue(value, nextPath, target);
if (typeof _nextValue === 'undefined') {
if (typeof obj === 'undefined') {
return obj;
} else {
// If updater returned undefined or no updater at all, delete the key
if (accessor in nextObj) {
nextObj = _objectSpread({}, nextObj);
delete nextObj[accessor];
}
return nextObj;
}
} else {
if (_nextValue === value) {

@@ -494,11 +510,3 @@ return obj;

}
} // If updater returned undefined or no updater at all, delete the key
if (accessor in nextObj) {
nextObj = _objectSpread({}, nextObj);
delete nextObj[accessor];
}
return nextObj;
}

@@ -505,0 +513,0 @@ }

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.simpleUpdateIn=e()}(this,function(){"use strict";function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function c(t,e,r,n,a,o,i){try{var u=t[o](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,a)}function t(u){return function(){var t=this,i=arguments;return new Promise(function(e,r){var n=u.apply(t,i);function a(t){c(n,e,r,a,o,"next",t)}function o(t){c(n,e,r,a,o,"throw",t)}a(void 0)})}}function l(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(t){l(e,t,r[t])})}return e}function y(t){return function(t){if(Array.isArray(t))return t}(t)||e(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function b(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(t)||e(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function e(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function r(t,e,r){v(e);var n=function t(e,r){if(!r.length)return;var n=y(r),a=n[0],o=n.slice(1);if("function"==typeof a){var i=[];if(Array.isArray(e))for(var u=0,c=e.length;u<c;u++)a.call(e,e[u],u)&&i.push.apply(i,b(t(e,[u].concat(b(o)))));else for(var f in e||{})a.call(e,e[f],f)&&i.push.apply(i,b(t(e,[f].concat(b(o)))));return i}var s=t(void 0!==e&&e[a],o);return s?s.map(function(t){return[a].concat(b(t))}):[[a]]}(t,e),a=!0,o=!1,i=void 0;try{for(var u,c=n[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var f=u.value;t=d(t,f,r?r(m(t,f)):void 0)}}catch(t){o=!0,i=t}finally{try{a||null==c.return||c.return()}finally{if(o)throw i}}return t}function n(){return(n=t(regeneratorRuntime.mark(function t(e,r,n){var a,o,i,u,c,f,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return v(r),t.next=3,h(e,r);case 3:a=t.sent,i=!(o=!0),u=void 0,t.prev=7,c=a[Symbol.iterator]();case 9:if(o=(f=c.next()).done){t.next=26;break}if(s=f.value,t.t0=d,t.t1=e,t.t2=s,n)return t.next=17,n(m(e,s));t.next=20;break;case 17:t.t3=t.sent,t.next=21;break;case 20:t.t3=void 0;case 21:t.t4=t.t3,e=(0,t.t0)(t.t1,t.t2,t.t4);case 23:o=!0,t.next=9;break;case 26:t.next=32;break;case 28:t.prev=28,t.t5=t.catch(7),i=!0,u=t.t5;case 32:t.prev=32,t.prev=33,o||null==c.return||c.return();case 35:if(t.prev=35,i)throw u;t.next=38;break;case 38:return t.finish(35);case 39:return t.finish(32);case 40:return t.abrupt("return",e);case 41:case"end":return t.stop()}},t,this,[[7,28,32,40],[33,,35,39]])}))).apply(this,arguments)}function v(t){if(!Array.isArray(t))throw new Error("path must be an array")}function h(t,e){return a.apply(this,arguments)}function a(){return(a=t(regeneratorRuntime.mark(function t(e,r){var n,a,o,i,u,c,f,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r.length){t.next=2;break}return t.abrupt("return");case 2:if(n=y(r),a=n[0],o=n.slice(1),"function"!=typeof a){t.next=43;break}if(i=[],!Array.isArray(e)){t.next=25;break}u=0,c=e.length;case 7:if(u<c)return t.next=10,a.call(e,e[u],u);t.next=23;break;case 10:if(t.t0=t.sent,t.t0)return t.t1=i.push,t.t2=i,t.t3=b,t.next=17,h(e,[u].concat(b(o)));t.next=20;break;case 17:t.t4=t.sent,t.t5=(0,t.t3)(t.t4),t.t1.apply.call(t.t1,t.t2,t.t5);case 20:u++,t.next=7;break;case 23:t.next=42;break;case 25:t.t6=regeneratorRuntime.keys(e||{});case 26:if((t.t7=t.t6()).done){t.next=42;break}return f=t.t7.value,t.next=30,a.call(e,e[f],f);case 30:if(t.t8=t.sent,t.t8)return t.t9=i.push,t.t10=i,t.t11=b,t.next=37,h(e,[f].concat(b(o)));t.next=40;break;case 37:t.t12=t.sent,t.t13=(0,t.t11)(t.t12),t.t9.apply.call(t.t9,t.t10,t.t13);case 40:t.next=26;break;case 42:return t.abrupt("return",i);case 43:return t.next=45,h(void 0!==e&&e[a],o);case 45:return s=t.sent,t.abrupt("return",s?s.map(function(t){return[a].concat(b(t))}):[[a]]);case 47:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function m(t,e){return e.reduce(function(t,e){return t&&t[e]},t)}function d(t,e,r){var n=y(e),a=n[0],o=n.slice(1);if(!e.length)return r;var i=void 0!==t&&t[a],u=t;if("string"!=typeof a||"object"===s(u)&&!Array.isArray(u)?"number"!=typeof a||Array.isArray(u)||(u=[]):u={},"number"==typeof a){if(void 0===r)return a in u&&(u=b(u)).splice(a,1),u;var c=d(i,o,r);return c===i?t:((u=b(u))[a]=c,u)}if(void 0===r)return a in u&&delete(u=p({},u))[a],u;var f=d(i,o,r);return f===i?t:p({},u,l({},a,f))}return r.updateInAsync=function(t,e,r){return n.apply(this,arguments)},r});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.simpleUpdateIn=e()}(this,function(){"use strict";function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function c(t,e,r,n,a,o,i){try{var u=t[o](i),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,a)}function t(u){return function(){var t=this,i=arguments;return new Promise(function(e,r){var n=u.apply(t,i);function a(t){c(n,e,r,a,o,"next",t)}function o(t){c(n,e,r,a,o,"throw",t)}a(void 0)})}}function l(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(t){l(e,t,r[t])})}return e}function y(t){return function(t){if(Array.isArray(t))return t}(t)||e(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function b(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(t)||e(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function e(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function r(t,e,r){v(e);var n=function t(e,r){if(!r.length)return;var n=y(r),a=n[0],o=n.slice(1);if("function"==typeof a){var i=[];if(Array.isArray(e))for(var u=0,c=e.length;u<c;u++)a.call(e,e[u],u)&&i.push.apply(i,b(t(e,[u].concat(b(o)))));else for(var f in e||{})a.call(e,e[f],f)&&i.push.apply(i,b(t(e,[f].concat(b(o)))));return i}var s=t(void 0!==e&&e[a],o);return s?s.map(function(t){return[a].concat(b(t))}):[[a]]}(t,e),a=!0,o=!1,i=void 0;try{for(var u,c=n[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var f=u.value;t=m(t,f,r?r(h(t,f)):void 0)}}catch(t){o=!0,i=t}finally{try{a||null==c.return||c.return()}finally{if(o)throw i}}return t}function n(){return(n=t(regeneratorRuntime.mark(function t(e,r,n){var a,o,i,u,c,f,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return v(r),t.next=3,d(e,r);case 3:a=t.sent,i=!(o=!0),u=void 0,t.prev=7,c=a[Symbol.iterator]();case 9:if(o=(f=c.next()).done){t.next=26;break}if(s=f.value,t.t0=m,t.t1=e,t.t2=s,n)return t.next=17,n(h(e,s));t.next=20;break;case 17:t.t3=t.sent,t.next=21;break;case 20:t.t3=void 0;case 21:t.t4=t.t3,e=(0,t.t0)(t.t1,t.t2,t.t4);case 23:o=!0,t.next=9;break;case 26:t.next=32;break;case 28:t.prev=28,t.t5=t.catch(7),i=!0,u=t.t5;case 32:t.prev=32,t.prev=33,o||null==c.return||c.return();case 35:if(t.prev=35,i)throw u;t.next=38;break;case 38:return t.finish(35);case 39:return t.finish(32);case 40:return t.abrupt("return",e);case 41:case"end":return t.stop()}},t,this,[[7,28,32,40],[33,,35,39]])}))).apply(this,arguments)}function v(t){if(!Array.isArray(t))throw new Error("path must be an array")}function d(t,e){return a.apply(this,arguments)}function a(){return(a=t(regeneratorRuntime.mark(function t(e,r){var n,a,o,i,u,c,f,s;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r.length){t.next=2;break}return t.abrupt("return");case 2:if(n=y(r),a=n[0],o=n.slice(1),"function"!=typeof a){t.next=43;break}if(i=[],!Array.isArray(e)){t.next=25;break}u=0,c=e.length;case 7:if(u<c)return t.next=10,a.call(e,e[u],u);t.next=23;break;case 10:if(t.t0=t.sent,t.t0)return t.t1=i.push,t.t2=i,t.t3=b,t.next=17,d(e,[u].concat(b(o)));t.next=20;break;case 17:t.t4=t.sent,t.t5=(0,t.t3)(t.t4),t.t1.apply.call(t.t1,t.t2,t.t5);case 20:u++,t.next=7;break;case 23:t.next=42;break;case 25:t.t6=regeneratorRuntime.keys(e||{});case 26:if((t.t7=t.t6()).done){t.next=42;break}return f=t.t7.value,t.next=30,a.call(e,e[f],f);case 30:if(t.t8=t.sent,t.t8)return t.t9=i.push,t.t10=i,t.t11=b,t.next=37,d(e,[f].concat(b(o)));t.next=40;break;case 37:t.t12=t.sent,t.t13=(0,t.t11)(t.t12),t.t9.apply.call(t.t9,t.t10,t.t13);case 40:t.next=26;break;case 42:return t.abrupt("return",i);case 43:return t.next=45,d(void 0!==e&&e[a],o);case 45:return s=t.sent,t.abrupt("return",s?s.map(function(t){return[a].concat(b(t))}):[[a]]);case 47:case"end":return t.stop()}},t,this)}))).apply(this,arguments)}function h(t,e){return e.reduce(function(t,e){return t&&t[e]},t)}function m(t,e,r){if(!e.length)return r;var n=y(e),a=n[0],o=n.slice(1),i=void 0!==t&&t[a],u=t;if("string"!=typeof a||"object"===s(u)&&!Array.isArray(u)?"number"!=typeof a||Array.isArray(u)||(u=[]):u={},"number"==typeof a){var c=m(i,o,r);return void 0===c?void 0===t?t:(a in u&&(u=b(u)).splice(a,1),u):c===i?t:((u=b(u))[a]=c,u)}var f=m(i,o,r);return void 0===f?void 0===t?t:(a in u&&delete(u=p({},u))[a],u):f===i?t:p({},u,l({},a,f))}return r.updateInAsync=function(t,e,r){return n.apply(this,arguments)},r});

@@ -353,2 +353,6 @@ "use strict";

function setValue(obj, path, target) {
if (!path.length) {
return target;
}
var _path3 = _toArray(path),

@@ -358,6 +362,2 @@ accessor = _path3[0],

if (!path.length) {
return target;
}
var value = typeof obj !== 'undefined' && obj[accessor];

@@ -373,5 +373,17 @@ var nextObj = obj;

if (typeof accessor === 'number') {
if (typeof target !== 'undefined') {
var nextValue = setValue(value, nextPath, target);
var nextValue = setValue(value, nextPath, target);
if (typeof nextValue === 'undefined') {
if (typeof obj === 'undefined') {
return obj;
} else {
// If updater returned undefined or no updater at all, delete the item
if (accessor in nextObj) {
nextObj = _toConsumableArray(nextObj);
nextObj.splice(accessor, 1);
}
return nextObj;
}
} else {
if (nextValue === value) {

@@ -384,15 +396,19 @@ return obj;

}
} // If updater returned undefined or no updater at all, delete the item
if (accessor in nextObj) {
nextObj = _toConsumableArray(nextObj);
nextObj.splice(accessor, 1);
}
return nextObj;
} else {
if (typeof target !== 'undefined') {
var _nextValue = setValue(value, nextPath, target);
var _nextValue = setValue(value, nextPath, target);
if (typeof _nextValue === 'undefined') {
if (typeof obj === 'undefined') {
return obj;
} else {
// If updater returned undefined or no updater at all, delete the key
if (accessor in nextObj) {
nextObj = _objectSpread({}, nextObj);
delete nextObj[accessor];
}
return nextObj;
}
} else {
if (_nextValue === value) {

@@ -403,11 +419,3 @@ return obj;

}
} // If updater returned undefined or no updater at all, delete the key
if (accessor in nextObj) {
nextObj = _objectSpread({}, nextObj);
delete nextObj[accessor];
}
return nextObj;
}

@@ -414,0 +422,0 @@ }

{
"name": "simple-update-in",
"version": "2.0.2-master.004542e",
"version": "2.0.2-master.0861f0c",
"description": "",

@@ -5,0 +5,0 @@ "browser": "dist/simple-update-in.production.min.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc