Comparing version 1.2.1-ts.c739a2e.0 to 1.2.1-ts.eec9b2a.0
{ | ||
"name": "json-ptr", | ||
"version": "1.2.1-ts.c739a2e.0", | ||
"version": "1.2.1-ts.eec9b2a.0", | ||
"author": "Phillip Clark <phillip@flitbit.com>", | ||
@@ -14,2 +14,6 @@ "description": "A complete implementation of JSON Pointer (RFC 6901) for nodejs and modern browsers.", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"dist.browser" | ||
], | ||
"license": "MIT", | ||
@@ -21,10 +25,13 @@ "repository": { | ||
"scripts": { | ||
"build": "tsc --build tsconfig.json", | ||
"clean": "rimraf dist .nyc_output coverage", | ||
"lint": "eslint src --ext .js,.ts,.json", | ||
"preversion": "npm run build", | ||
"clean": "rimraf coverage dist dist.browser tmp docs", | ||
"prebuild": "npm run lint", | ||
"pretest": "npm run build", | ||
"test": "nyc mocha src/**/*.spec.ts", | ||
"ci": "npm run test", | ||
"build:browser": "webpack", | ||
"build:browser-tests": "webpack --config webpack.tests.config.js", | ||
"build": "tsc -p tsconfig.release.json && npm run build:browser && npm run build:browser-tests && npm run docs", | ||
"build:watch": "tsc -w -p tsconfig.release.json", | ||
"lint": "eslint . --ext .ts,.tsx", | ||
"pretest": "npm run lint", | ||
"test": "nyc mocha __tests__/**/*.spec.ts", | ||
"test:watch": "chokidar \"*.js\" \"*.json\" \"src/**/*.ts\" \"__tests__/**/*.ts\" --command \"npm run test\" --initial", | ||
"ci": "npm run test && npm run test", | ||
"docs": "typedoc" | ||
@@ -34,24 +41,25 @@ }, | ||
"@types/assert-plus": "^1.0.4", | ||
"@types/bent": "^7.0.1", | ||
"@types/bent": "^7.0.2", | ||
"@types/chai": "^4.2.11", | ||
"@types/debug": "^4.1.5", | ||
"@types/mocha": "^7.0.2", | ||
"@typescript-eslint/eslint-plugin": "^2.25.0", | ||
"@typescript-eslint/parser": "^2.25.0", | ||
"bent": "^7.1.2", | ||
"@types/node": "~14.0.19", | ||
"@typescript-eslint/eslint-plugin": "~3.6.0", | ||
"@typescript-eslint/parser": "~3.6.0", | ||
"bent": "^7.3.7", | ||
"chai": "^4.2.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.10.1", | ||
"eslint-plugin-import": "^2.20.1", | ||
"eslint-plugin-json": "^2.1.1", | ||
"eslint-plugin-mocha": "^6.3.0", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"lodash": "^4.17.15", | ||
"mocha": "^7.1.1", | ||
"nyc": "^15.0.0", | ||
"prettier": "^2.0.2", | ||
"rimraf": "^3.0.2", | ||
"source-map-support": "^0.5.16", | ||
"ts-node": "^8.8.1", | ||
"typedoc": "^0.17.3", | ||
"typescript": "^3.8.3" | ||
"chokidar-cli": "^2.1.0", | ||
"eslint": "^7.4.0", | ||
"eslint-config-prettier": "~6.11.0", | ||
"eslint-plugin-mocha": "^7.0.1", | ||
"mocha": "^8.0.1", | ||
"nyc": "^15.1.0", | ||
"prettier": "~2.0.5", | ||
"rimraf": "~3.0.2", | ||
"ts-loader": "^7.0.5", | ||
"ts-node": "^8.10.2", | ||
"typedoc": "^0.17.8", | ||
"typescript": "~3.9.6", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.12" | ||
}, | ||
@@ -58,0 +66,0 @@ "nyc": { |
179
README.md
@@ -31,14 +31,15 @@ # json-ptr | ||
* [`JsonPointer`](#user-content-jsonpointer-class) : _class_ – a convenience class for working with JSON pointers. | ||
* [`JsonReference`](#user-content-jsonreference-class) : _class_ – a convenience class for working with JSON references. | ||
- [`JsonPointer`](#user-content-jsonpointer-class) : _class_ – a convenience class for working with JSON pointers. | ||
- [`JsonReference`](#user-content-jsonreference-class) : _class_ – a convenience class for working with JSON references. | ||
#### Functions | ||
* [`.create(pointer)`](#user-content-createpointer) | ||
* [`.has(target,pointer)`](#user-content-hastargetpointer) | ||
* [`.get(target,pointer)`](#user-content-gettargetpointer) | ||
* [`.set(target,pointer,value,force)`](#user-content-settarget-pointer-value-force) | ||
* [`.flatten(target,fragmentId)`](#user-content-flattentarget-fragmentid) | ||
* [`.list(target,fragmentId)`](#user-content-listtarget-fragmentid) | ||
* [`.map(target,fragmentId)`](#user-content-maptarget-fragmentid) | ||
- [`.create(pointer)`](#user-content-createpointer) | ||
- [`.has(target,pointer)`](#user-content-hastargetpointer) | ||
- [`.get(target,pointer)`](#user-content-gettargetpointer) | ||
- [`.set(target,pointer,value,force)`](#user-content-settarget-pointer-value-force) | ||
- [`.unset(target,pointer,value,force)`](#user-content-settarget-pointer-value-force) | ||
- [`.flatten(target,fragmentId)`](#user-content-flattentarget-fragmentid) | ||
- [`.list(target,fragmentId)`](#user-content-listtarget-fragmentid) | ||
- [`.map(target,fragmentId)`](#user-content-maptarget-fragmentid) | ||
@@ -62,3 +63,3 @@ All example code assumes data has this structure: | ||
}, { | ||
name: 'plit peas', | ||
name: 'split peas', | ||
unit: 'lbs', | ||
@@ -70,3 +71,3 @@ instock: 8 | ||
#### .create(pointer: string | string[]): JsonPointer | ||
#### .create(pointer: string | string\[]): JsonPointer | ||
@@ -77,7 +78,7 @@ Creates an instance of the `JsonPointer` class. | ||
* `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
- `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
_returns:_ | ||
* a new [`JsonPointer` instance](#user-content-jsonpointer-class) | ||
- a new [`JsonPointer` instance](#user-content-jsonpointer-class) | ||
@@ -91,14 +92,14 @@ _example:_ | ||
#### .has<T>(target: T, pointer: string | string[] | JsonPointer): boolean | ||
#### .has(target: unknown, pointer: string | string\[] | JsonPointer): boolean | ||
Determins whether the specified `target` has a value at the `pointer`'s path. | ||
Determines whether the specified `target` has a value at the `pointer`'s path. | ||
_arguments:_ | ||
* `target` : _object, required_ – the target object | ||
* `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
- `target` : _object, required_ – the target object | ||
- `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
_returns:_ | ||
* the dereferenced value or _undefined_ if nonexistent | ||
- the dereferenced value or _undefined_ if nonexistent | ||
@@ -111,8 +112,8 @@ #### .get(target,pointer) | ||
* `target` : _object, required_ – the target object | ||
* `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
- `target` : _object, required_ – the target object | ||
- `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
_returns:_ | ||
* the dereferenced value or _undefined_ if nonexistent | ||
- the dereferenced value or _undefined_ if nonexistent | ||
@@ -132,10 +133,10 @@ _example:_ | ||
* `target` : _object, required_ – the target object | ||
* `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
* `value` : _any_ – the value to be set at the specified `pointer`'s path | ||
* `force` : _boolean, optional_ – indicates [whether nonexistent paths are created during the call](https://tools.ietf.org/html/rfc6901#section-7) | ||
- `target` : _object, required_ – the target object | ||
- `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
- `value` : _any_ – the value to be set at the specified `pointer`'s path | ||
- `force` : _boolean, optional_ – indicates [whether nonexistent paths are created during the call](https://tools.ietf.org/html/rfc6901#section-7) | ||
_returns:_ | ||
* The prior value at the pointer's path — therefore, _undefined_ means the pointer's path was nonexistent. | ||
- The prior value at the pointer's path — therefore, _undefined_ means the pointer's path was nonexistent. | ||
@@ -170,2 +171,40 @@ _example:_ | ||
#### .unset(target, pointer) | ||
Unsets the `value` at the specified `pointer` on the `target` and returns the value. The default behavior is to do nothing if `pointer` is nonexistent. | ||
_arguments:_ | ||
- `target` : _object, required_ – the target object | ||
- `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
_returns:_ | ||
- The dereferenced value or _undefined_ if nonexistent | ||
_example:_ | ||
```javascript | ||
var prior = ptr.unset(data, '#/legumes/1/instock'); | ||
``` | ||
example force: | ||
```javascript | ||
var data = {}; | ||
ptr.unset(data, '#/peter/piper'); | ||
ptr.unset(data, '#/peter/pan'); | ||
console.log(JSON.stringify(data, null, ' ')); | ||
``` | ||
```json | ||
{ | ||
"peter": { | ||
"pickle": "dunno" | ||
} | ||
} | ||
``` | ||
#### .list(target, fragmentId) | ||
@@ -179,8 +218,8 @@ | ||
* `target` : _object, required_ – the target object | ||
* `fragmentId` : _boolean, optional_ – indicates whether fragment identifiers should be listed instead of pointers | ||
- `target` : _object, required_ – the target object | ||
- `fragmentId` : _boolean, optional_ – indicates whether fragment identifiers should be listed instead of pointers | ||
_returns:_ | ||
* an array of `pointer-value` pairs | ||
- an array of `pointer-value` pairs | ||
@@ -255,8 +294,8 @@ _example:_ | ||
* `target` : _object, required_ – the target object | ||
* `fragmentId` : _boolean, optional_ – indicates whether fragment identifiers should be listed instead of pointers | ||
- `target` : _object, required_ – the target object | ||
- `fragmentId` : _boolean, optional_ – indicates whether fragment identifiers should be listed instead of pointers | ||
_returns:_ | ||
* a flattened object of `property-value` pairs as properties. | ||
- a flattened object of `property-value` pairs as properties. | ||
@@ -289,8 +328,8 @@ _example:_ | ||
* `target` : _object, required_ – the target object | ||
* `fragmentId` : _boolean, optional_ – indicates whether fragment identifiers should be listed instead of pointers | ||
- `target` : _object, required_ – the target object | ||
- `fragmentId` : _boolean, optional_ – indicates whether fragment identifiers should be listed instead of pointers | ||
_returns:_ | ||
* a Map object containing key-value pairs where keys are pointers. | ||
- a Map object containing key-value pairs where keys are pointers. | ||
@@ -329,7 +368,7 @@ _example:_ | ||
* `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6). | ||
- `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) or [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6). | ||
_returns:_ | ||
* An array of path segments used as indexers to descend from a root/`target` object to a referenced value. | ||
- An array of path segments used as indexers to descend from a root/`target` object to a referenced value. | ||
@@ -352,7 +391,7 @@ _example:_ | ||
* `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5). | ||
- `pointer` : _string, required_ – a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5). | ||
_returns:_ | ||
* An array of path segments used as indexers to descend from a root/`target` object to a referenced value. | ||
- An array of path segments used as indexers to descend from a root/`target` object to a referenced value. | ||
@@ -375,7 +414,7 @@ _example:_ | ||
* `path` : _Array, required_ – an array of path segments | ||
- `path` : _Array, required_ – an array of path segments | ||
_returns:_ | ||
* A JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5). | ||
- A JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5). | ||
@@ -398,7 +437,7 @@ _example:_ | ||
* `pointer` : _string, required_ – a JSON pointer in [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6). | ||
- `pointer` : _string, required_ – a JSON pointer in [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6). | ||
_returns:_ | ||
* An array of path segments used as indexers to descend from a root/`target` object to a referenced value. | ||
- An array of path segments used as indexers to descend from a root/`target` object to a referenced value. | ||
@@ -421,7 +460,7 @@ _example:_ | ||
* `path` : _Array, required_ - an array of path segments | ||
- `path` : _Array, required_ - an array of path segments | ||
_returns:_ | ||
* A JSON pointer in [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6). | ||
- A JSON pointer in [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6). | ||
@@ -444,5 +483,5 @@ _example:_ | ||
* `.path` : _array_ – contains the pointer's path segements. | ||
* `.pointer` : _string_ – the pointer's [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) | ||
* `.uriFragmentIdentifier` : _string_ – the pointer's [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
- `.path` : _array_ – contains the pointer's path segements. | ||
- `.pointer` : _string_ – the pointer's [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5) | ||
- `.uriFragmentIdentifier` : _string_ – the pointer's [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6) | ||
@@ -465,9 +504,9 @@ _methods:_ | ||
* `target` : _object, required_ – the target object | ||
* `value` : _any_ – the value to be set at the specified `pointer`'s path | ||
* `force` : _boolean, optional_ – indicates [whether nonexistent paths are created during the call](https://tools.ietf.org/html/rfc6901#section-7) | ||
- `target` : _object, required_ – the target object | ||
- `value` : _any_ – the value to be set at the specified `pointer`'s path | ||
- `force` : _boolean, optional_ – indicates [whether nonexistent paths are created during the call](https://tools.ietf.org/html/rfc6901#section-7) | ||
_result:_ | ||
* The prior value at the pointer's path — therefore, _undefined_ means the pointer's path was nonexistent. | ||
- The prior value at the pointer's path — therefore, _undefined_ means the pointer's path was nonexistent. | ||
@@ -480,3 +519,3 @@ #### .concat(target) | ||
* `target` : _JsonPointer, array or string, required_ – the path to be appended to the current path | ||
- `target` : _JsonPointer, array or string, required_ – the path to be appended to the current path | ||
@@ -605,24 +644,24 @@ ## Performance | ||
* 2019-09-14 — __1.2.0__ | ||
* Merged new `.concat` function contributed by @vuwuv, updated dependencies. | ||
- 2019-09-14 — **1.2.0** | ||
- Merged new `.concat` function contributed by @vuwuv, updated dependencies. | ||
* 2019-03-10 — __1.1.2__ | ||
* Updated packages to remove critical security concern among dev dependencies' | ||
- 2019-03-10 — **1.1.2** | ||
- Updated packages to remove critical security concern among dev dependencies' | ||
* 2016-07-26 — __1.0.1__ | ||
* Fixed a problem with the Babel configuration | ||
- 2016-07-26 — **1.0.1** | ||
- Fixed a problem with the Babel configuration | ||
* 2016-01-12 — __1.0.0__ | ||
* Rolled major version to 1 to reflect breaking change in `.list(obj, fragmentId)`. | ||
- 2016-01-12 — **1.0.0** | ||
- Rolled major version to 1 to reflect breaking change in `.list(obj, fragmentId)`. | ||
* 2016-01-02 — __0.3.0__ | ||
* Retooled for node 4+ | ||
* Better compiled pointers | ||
* Unrolled recursive `.list` function | ||
* Added `.map` function | ||
* Fully linted | ||
* Lots more tests and examples. | ||
* Documented many previously undocumented features. | ||
- 2016-01-02 — **0.3.0** | ||
- Retooled for node 4+ | ||
- Better compiled pointers | ||
- Unrolled recursive `.list` function | ||
- Added `.map` function | ||
- Fully linted | ||
- Lots more tests and examples. | ||
- Documented many previously undocumented features. | ||
* 2014-10-21 — __0.2.0__ Added #list function to enumerate all properties in a graph, producing fragmentId/value pairs. | ||
- 2014-10-21 — **0.2.0** Added #list function to enumerate all properties in a graph, producing fragmentId/value pairs. | ||
@@ -629,0 +668,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
651
21112
24
3
0
2