Skip to content

Does not support named or array index correctly. #42

Open
@trajano

Description

@trajano

Some test cases you may want to add.

https://replit.com/@trajano/lodash#index.js

const _ = require('lodash');
const set = require('set-value');

const spec = {
  a: "foo",
  b: { x: 12, y: 11 },
  c: [
    { x: 11, y: 11 },
    { x: 22, y: 22 },
    // for keys that are strings which are 
    // reserved so simple splits can't be used
    { "foo[0].1": 22, "e.y": 22 }, 
  ],
};

console.log(spec)

const c = _.cloneDeep(spec)
_.set(c, 'b.x', 99);
_.set(c, 'c[1].y', 99);
_.set(c, "c[2]['foo[0].1']", 199);
console.log(c)

const d = _.cloneDeep(spec)
set(d, 'b.x', 99);
set(d, 'c[1].y', 99);
set(d, "c[2]['foo[0].1']", 199);
console.log(d)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions