Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not support named or array index correctly. #42

Open
trajano opened this issue Nov 11, 2021 · 0 comments
Open

Does not support named or array index correctly. #42

trajano opened this issue Nov 11, 2021 · 0 comments

Comments

@trajano
Copy link

trajano commented Nov 11, 2021

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant