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

Set value (object) to null (force) #97

Open
DenniLa2 opened this issue Nov 20, 2018 · 1 comment
Open

Set value (object) to null (force) #97

DenniLa2 opened this issue Nov 20, 2018 · 1 comment

Comments

@DenniLa2
Copy link

Hello!
Thanks for You work and 'object-path'!

My object = {a: null};
If I run objectPath.set(object, 'a.b', 'c') fire the error "Cannot set property 'b' of null".
Pls, add fourth parameter to .set(), isForce. If true - replace null (primitive value) to object path.

@silverwind
Copy link

silverwind commented Dec 1, 2018

Noticed this null issue too. I'd say null should be treated the same as undefined in regards to creating intermediate objects and arrays.

// this works
require("object-path").set({a: undefined}, "a.b", "c")

// this throws "Cannot set property 'b' of null"
require("object-path").set({a: null}, "a.b", "c")

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

2 participants