<commit_before>jsonpatch.js
============
Library to apply JSON Patches in JavaScript
http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-03

For convenience, ``jsonpatch.apply`` can take a patch as an object
or an array of objects. The spec states the latter as being the official
patch syntax.

Note: all operations are applied in-place.

Add
---
Patch syntax: ``{add: <path>, value: <value>}``

```javascript
// Add property, result: {foo: 'bar'}
jsonpatch.apply({}, [{add: '/foo', value: 'bar'}]);

// Add array element, result: {foo: [1, 2, 3]}
jsonpatch.apply({foo: [1, 3]}, [{add: '/foo/1', value: 2}]);

// Complex, result: {foo: [{bar: 'baz'}]}
jsonpatch.apply({foo: [{}]}, [{add: '/foo/0/bar', value: 'baz'}]);
```

Remove
------
Patch syntax: ``{remove: <path>}``

```javascript
// Remove property, result: {}
jsonpatch.apply({foo: 'bar'}, [{remove: '/foo'}]);

// Remove array element, result: {foo: [1, 3]}
jsonpatch.apply({foo: [1, 2, 3]}, [{remove: '/foo/1'}]);

// Complex, result: {foo: [{}]}
jsonpatch.apply({foo: [{bar: 'baz'}]}, [{remove: '/foo/0/bar'}]);
```

Replace
-------
Patch syntax: ``{replace: <path>, value: <value>}``

```javascript
// Replace property, result: {foo: 1}
jsonpatch.apply({foo: 'bar'}, [{replace: '/foo', value: 1}]);

// Repalce array element, result: {foo: [1, 4, 3]}
jsonpatch.apply({foo: [1, 2, 3]}, [{replace: '/foo/1', value: 4}]);

// Complex, result: {foo: [{bar: 1}]}
jsonpatch.apply({foo: [{bar: 'baz'}]}, [{replace: '/foo/0/bar', value: 1}]);
```

Move
----
Patch syntax: ``{move: <path>, to: <path>}``

```javascript
// Move property, result {bar: [1, 2, 3]}
jsonpatch.apply({foo: [1, 2, 3]}, [{move: '/foo', to: '/bar'}]);
```

Test<commit_msg>Update README to include copy operation<commit_after>jsonpatch.js
============
Library to apply JSON Patches in JavaScript
http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-03

For convenience, ``jsonpatch.apply`` can take a patch as an object
or an array of objects. The spec states the latter as being the official
patch syntax.

Note: all operations are applied in-place.

Add
---
Patch syntax: ``{add: <path>, value: <value>}``

```javascript
// Add property, result: {foo: 'bar'}
jsonpatch.apply({}, [{add: '/foo', value: 'bar'}]);

// Add array element, result: {foo: [1, 2, 3]}
jsonpatch.apply({foo: [1, 3]}, [{add: '/foo/1', value: 2}]);

// Complex, result: {foo: [{bar: 'baz'}]}
jsonpatch.apply({foo: [{}]}, [{add: '/foo/0/bar', value: 'baz'}]);
```

Remove
------
Patch syntax: ``{remove: <path>}``

```javascript
// Remove property, result: {}
jsonpatch.apply({foo: 'bar'}, [{remove: '/foo'}]);

// Remove array element, result: {foo: [1, 3]}
jsonpatch.apply({foo: [1, 2, 3]}, [{remove: '/foo/1'}]);

// Complex, result: {foo: [{}]}
jsonpatch.apply({foo: [{bar: 'baz'}]}, [{remove: '/foo/0/bar'}]);
```

Replace
-------
Patch syntax: ``{replace: <path>, value: <value>}``

```javascript
// Replace property, result: {foo: 1}
jsonpatch.apply({foo: 'bar'}, [{replace: '/foo', value: 1}]);

// Repalce array element, result: {foo: [1, 4, 3]}
jsonpatch.apply({foo: [1, 2, 3]}, [{replace: '/foo/1', value: 4}]);

// Complex, result: {foo: [{bar: 1}]}
jsonpatch.apply({foo: [{bar: 'baz'}]}, [{replace: '/foo/0/bar', value: 1}]);
```

Move
----
Patch syntax: ``{move: <path>, to: <path>}``

```javascript
// Move property, result {bar: [1, 2, 3]}
jsonpatch.apply({foo: [1, 2, 3]}, [{move: '/foo', to: '/bar'}]);
```

Copy
----
Patch syntax: ``{copy: <path>, to: <path>}``

```javascript
// Move property, result {foo: [1, 2, 3], bar: 2}
jsonpatch.apply({foo: [1, 2, 3]}, [{copy: '/foo/1', to: '/bar'}]);
```

Test
{'fraction_non_alphanumeric': 0.2714757709251101, 'fraction_numerical': 0.022026431718061675, 'mean_word_length': 4.390207715133531, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6355702', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1323, 'n_words': 407}