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

Extended operations a.k.a. user-defined operations #284

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

superguineapig
Copy link

Hello there! I've been using this library in a number of projects and have found it very useful.

Recently, at my company I needed the ability to perform simple mutations of JSON documents beyond those defined in the RFC-6902 specification. I really love the way the RFC defined its patch operation objects and wondered if there would be a way to extend that schema into user-defined operations. ("smart patches", if you will...)

I wound up implementing the specific changes I needed in our product, but quickly realized that it could be generalized to "reasonably arbitrary" operations and also work along side of the standard patch operations, and that we would have need to utilize such functionality immediately.

Using the JSON-Patch library as a starting point, I added "hooks" to allow processing of user-defined operation logic. It worked very well with almost no impact to the existing behavior and API.

I wasn't really planning on publishing this fork myself, (though I am using this code in production), but It seems like this functionality could be helpful to others, so I did some refactoring and added a full suite of tests and documentation and am submitting this pull request in case you'd like to incorporate this functionality into the public library as a major version release.

Please check out the docs in 'EXTENDED.md' for a much better overview of what this branch is all about.

The tests are at 'test/spec/extendedSpec.mjs'

I tried my best to not disturb any existing core functionality (core API is the same, all core tests pass w/o modifications) and match existing coding style.

Thanks for the hard work so far. JSON-Patch has been very helpful in several of my projects.

I hope you'll find this pull useful as well.

Cheers!

@Starcounter-Jack
Copy link
Owner

I will have a look at this. A plugin system that does not add size or lower performance for users without a plugin could work.

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

Successfully merging this pull request may close these issues.

None yet

2 participants