Socket
Socket
Sign inDemoInstall

immutable-ops

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

immutable-ops - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

40

lib/index.js

@@ -122,25 +122,29 @@ 'use strict';

var pathLen = originalPathArg.length;
originalPathArg.reduce(function (acc, curr, idx) {
var done = false;
var idx = 0;
var acc = obj;
var curr = originalPathArg[idx];
while (!done) {
if (idx === pathLen - 1) {
acc[curr] = value;
return value;
}
done = true;
} else {
var currType = (0, _typeof3.default)(acc[curr]);
var currType = (0, _typeof3.default)(acc[curr]);
if (currType === 'undefined') {
var newObj = {};
prepareNewObject(newObj, null);
acc[curr] = newObj;
return newObj;
if (currType === 'undefined') {
var newObj = {};
prepareNewObject(newObj, null);
acc[curr] = newObj;
} else if (currType !== 'object') {
var pathRepr = originalPathArg[idx - 1] + '.' + curr;
throw new Error('A non-object value was encountered when traversing setIn path at ' + pathRepr + '.');
}
acc = acc[curr];
idx++;
curr = originalPathArg[idx];
}
}
if (currType === 'object') {
return acc[curr];
}
var pathRepr = originalPathArg[idx - 1] + '.' + curr;
throw new Error('A non-object value was encountered when traversing setIn path at ' + pathRepr + '.');
});
return obj;

@@ -147,0 +151,0 @@ }

{
"name": "immutable-ops",
"version": "0.5.1",
"version": "0.5.2",
"description": "A collection of functions to perform immutable operations on plain JavaScript objects",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -87,25 +87,31 @@ import curry from 'ramda/src/curry';

const pathLen = originalPathArg.length;
originalPathArg.reduce((acc, curr, idx) => {
let done = false;
let idx = 0;
let acc = obj;
let curr = originalPathArg[idx];
while (!done) {
if (idx === pathLen - 1) {
acc[curr] = value;
return value;
}
done = true;
} else {
const currType = typeof acc[curr];
const currType = typeof acc[curr];
if (currType === 'undefined') {
const newObj = {};
prepareNewObject(newObj, null);
acc[curr] = newObj;
return newObj;
if (currType === 'undefined') {
const newObj = {};
prepareNewObject(newObj, null);
acc[curr] = newObj;
} else if (currType !== 'object') {
const pathRepr = `${originalPathArg[idx - 1]}.${curr}`;
throw new Error(
`A non-object value was encountered when traversing setIn path at ${pathRepr}.`,
);
}
acc = acc[curr];
idx++;
curr = originalPathArg[idx];
}
}
if (currType === 'object') {
return acc[curr];
}
const pathRepr = `${originalPathArg[idx - 1]}.${curr}`;
throw new Error(`A non-object value was encountered when traversing setIn path at ${pathRepr}.`);
});
return obj;

@@ -112,0 +118,0 @@ }

Sorry, the diff of this file is not supported yet

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