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 1.3.2-master.62c7b4d to 1.4.0-0

3

CHANGELOG.md

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

## [Unreleased]
### Changed
- Bump to `@babel/core@7.1.2` and `jest@23.6.0`
- Add default exports for CommonJS

@@ -10,0 +13,0 @@ ## [1.3.1] - 2018-10-05

45

lib/index.js

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

'use strict';
"use strict";

@@ -6,13 +6,18 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = setIn;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
exports.default = setIn;
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function setIn(obj, path, updater) {

@@ -28,3 +33,2 @@ if (!Array.isArray(path)) {

path = path.slice();
var accessor = path.shift();

@@ -51,6 +55,5 @@

var value = typeof obj !== 'undefined' && obj[accessor];
var nextObj = obj;
if (typeof accessor === 'string' && ((typeof nextObj === 'undefined' ? 'undefined' : _typeof(nextObj)) !== 'object' || Array.isArray(nextObj))) {
if (typeof accessor === 'string' && (_typeof(nextObj) !== 'object' || Array.isArray(nextObj))) {
nextObj = {};

@@ -64,3 +67,3 @@ } else if (typeof accessor === 'number' && !Array.isArray(nextObj)) {

if (accessor === -1) {
return [].concat(_toConsumableArray(nextObj), [setIn([], path, updater)]);
return _toConsumableArray(nextObj).concat([setIn([], path, updater)]);
}

@@ -74,13 +77,12 @@

} else {
nextObj = [].concat(_toConsumableArray(nextObj));
nextObj = _toConsumableArray(nextObj);
nextObj[accessor] = nextValue;
return nextObj;
}
}
}
} // If updater returned undefined or no updater at all, delete the item
// If updater returned undefined or no updater at all, delete the item
if (accessor in nextObj) {
nextObj = [].concat(_toConsumableArray(nextObj));
nextObj = _toConsumableArray(nextObj);
nextObj.splice(accessor, 1);

@@ -98,10 +100,10 @@ }

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

@@ -112,2 +114,5 @@ }

}
}
}
module.exports = exports.default;
module.exports.default = exports.default;
{
"name": "simple-update-in",
"version": "1.3.2-master.62c7b4d",
"version": "1.4.0-0",
"description": "",

@@ -34,8 +34,11 @@ "main": "lib/index.js",

"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-3": "^6.24.1",
"jest": "^22.4.3"
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"babel-plugin-add-module-exports": "^1.0.0",
"jest": "^23.6.0"
}
}
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