immutable-ops
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93716
1515