Non-integers treated as valid indices for created arrays
Closed this issue · 3 comments
Andarist commented
var obj = {}
dset(obj, ['foo', '10.2', 'baz'], 'bar')
Produces an array with 10.2
property.
lukeed commented
What would you expect it to be? This is the same result as 1.x
branch. If you pass an array of keys (instead of dot-notation), it accepts each item as is, which is ideal for pre-formatting keys instead of risking hello.world
to be split up for whatever reason.
Andarist commented
Array.isArray(obj.foo)
// dset@2 - true
// dset@1 - false
// _.set - false
// R.assocPath - false
I didn't expect the key to be split, but rather that non-integer (non-positive) would not create an array.
lukeed commented
I see it now 😄 Bug with tape.js
actually, I think
foo = {};
fn(foo, ['x', '10.2', 'z'], 123);
t.same(foo, { x:{ '10.2':{ z:123 } } });
^ Passed, despite the result being an array as you've pointed out.