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

Missing remove() #3

Closed
geraintluff opened this issue Oct 24, 2013 · 3 comments
Closed

Missing remove() #3

geraintluff opened this issue Oct 24, 2013 · 3 comments

Comments

@geraintluff
Copy link

Hi - I just started using your library for something, and I realised I can get(), and I can set(), but I'd like to be able to remove().

Any chance of putting that in?

@geraintluff
Copy link
Author

In case it's useful, this is my current polyfill:

jsonPointer.remove = jsonPointer.remove || function (obj, path) {
    var parts = this.parse(path);
    var finalProperty = parts.pop();
    var parent = parts.length ? this.get(obj, this.compile(parts)) : obj;
    delete parent[finalProperty];
    return this;
};

@geraintluff
Copy link
Author

FYI - the parts.length check is because of issue #4.

@manuelstofer
Copy link
Owner

Good point! A delete method is definitely useful.

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