{"name":"@swagger-api/apidom-json-pointer","version":"1.0.0-beta.0","author":"Vladimír Gorej","license":"Apache-2.0","_id":"@swagger-api/apidom-json-pointer@1.0.0-beta.0","dist":{"shasum":"3c203165a8b02b8e1fc7822d7fe845f5cabf3a71","tarball":"http://registry-npm.ywwl.com/@swagger-api/apidom-json-pointer/download/@swagger-api/apidom-json-pointer-1.0.0-beta.0.tgz","fileCount":9,"integrity":"sha512-Pw++46q+V4/uvOqWGDhh98hm4N3oC/JPnfnLlm+dDpfBKJGHRjUG4/G8BaALt8v3SNz96NE4LAAKZYx/feHAIw==","signatures":[{"sig":"MEQCIAxe96O6+UVASEefkQGA0EYUWySrtEskP44hO7QSr9aXAiAX1d1ZpEwrugGWA8zY7fNRc7F8P/FjqHH1RlFX0iSCMQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":539729,"size":106808,"noattachment":false,"key":"/@swagger-api/apidom-json-pointer/-/@swagger-api/apidom-json-pointer-1.0.0-beta.0.tgz"},"main":"./src/index.cjs","type":"module","types":"./types/apidom-json-pointer.d.ts","unpkg":"./dist/apidom-json-pointer.browser.min.js","exports":{"types":"./types/apidom-json-pointer.d.ts","import":"./src/index.mjs","require":"./src/index.cjs"},"gitHead":"ed1426743ba9d9d581146e617ec1762df670320c","scripts":{"lint":"eslint ./","test":"npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test mocha","build":"npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser","clean":"rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types","prepack":"copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .","build:es":"cross-env BABEL_ENV=es babel src --out-dir src --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward'","lint:fix":"eslint ./ --fix","postpack":"rimraf NOTICE LICENSES","build:cjs":"cross-env BABEL_ENV=cjs babel src --out-dir src --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'","build:umd:browser":"cross-env BABEL_ENV=browser webpack --config config/webpack/browser.config.js --progress","typescript:check-types":"tsc --noEmit","typescript:declaration":"tsc -p tsconfig.declaration.json && api-extractor run -l -c ./config/api-extractor/api-extractor.json"},"_npmUser":{"name":"swagger-api","email":"apiteam@swagger.io"},"repository":{"url":"git+https://github.com/swagger-api/apidom.git","type":"git"},"_npmVersion":"lerna/8.1.9/node@v22.11.0+x64 (linux)","description":"Evaluate JSON Pointer expressions against ApiDOM.","directories":{},"sideEffects":false,"_nodeVersion":"22.11.0","dependencies":{"ramda":"~0.30.0","@types/ramda":"~0.30.0","ramda-adjunct":"^5.0.0","@babel/runtime-corejs3":"^7.20.7","@swagger-api/apidom-core":"^1.0.0-beta.0","@swagger-api/apidom-error":"^1.0.0-beta.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/apidom-json-pointer_1.0.0-beta.0_1732189997061_0.8542399226807107","host":"s3://npm-registry-packages"},"readme":"# @swagger-api/apidom-json-pointer\n\n`apidom-json-pointer` is a package that evaluates [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901) against ApiDOM.\n\n## Installation\n\nYou can install this package via [npm CLI](https://docs.npmjs.com/cli) by running the following command:\n\n```sh\n $ npm install @swagger-api/apidom-json-pointer\n```\n\n## Modern API\n\nThis is the recommended API for use in new projects. It is fully compliant with [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901) and supports all aspects of JSON Pointer.\nUses [@swaggerexpert/json-pointer](https://www.npmjs.com/package/@swaggerexpert/json-pointer) under the hood and fully reflects its API. For additional options and details, refer to the `@swaggerexpert/json-pointer` [documentation](https://www.npmjs.com/package/@swaggerexpert/json-pointer#usage).\n\nEvaluation is contextual to [ApiDOM realm](https://github.com/swaggerexpert/json-pointer?tab=readme-ov-file#apidom-evaluation-realm) - meaning `evaluate` function\nexpects only ApiDOM as the first argument.\n\n```js\nimport { evaluate } from '@swagger-api/apidom-json-pointer/modern';\n```\n\n### Evaluating\n\n```js\nimport { ObjectElement } from '@swagger-api/apidom-core';\nimport { evaluate } from '@swagger-api/apidom-json-pointer/modern';\n\nconst apidom = new ObjectElement({ a: { b: 'c' } });\nconst result =  evaluate(apidom, '/a/b');\n// => StringElement('c')\n```\n\n### Parsing\n\nParses JSON Pointer into a list of tokens, which can be accessed through the `tree` property of the parse result.\n\n```js\nimport { parse } from '@swagger-api/apidom-json-pointer/modern';\n\nconst parseResult = parse('/a/b');\n// =>\n// {\n//   result: {\n//     success: true,\n//     state: 101,\n//     stateName: 'MATCH',\n//     length: 4,\n//     matched: 4,\n//     maxMatched: 4,\n//     maxTreeDepth: 8,\n//     nodeHits: 31\n//   },\n//   tree: [ 'a', 'b' ],\n//   stats: undefined,\n//   trace: undefined\n// }\n```\n\n### Compiling\n\nCompiles a list of tokens into JSON Pointer.\n\n```js\nimport { compile } from '@swagger-api/apidom-json-pointer/modern';\n\nconst jsonPointer = compile(['a', 'b']); // => '/a/b'\n```\n\n### Escaping\n\nEscapes/unescapes tokens of JSON Pointer.\n\n```js\nimport { escape, unescape } from '@swagger-api/apidom-json-pointer/modern';\n\nescape('~a/'); // => '~0a~1'\nunescape('~0a~1'); // => '~a/'\n```\n\n### Transforming URI to JSON Pointer\n\nHandles case of [URI Fragment Identifier Representation](https://datatracker.ietf.org/doc/html/rfc6901#section-6).\n\n```js\nimport { URIFragmentIdentifier } from '@swagger-api/apidom-json-pointer/modern';\n\nURIFragmentIdentifier.fromURIReference('https://example.com/path/#/a/b'); // => '/a/b'\n```\n\n### Validating\n\nValidates a JSON Pointer and its tokens.\n\n```js\nimport {\n  testJSONPointer,\n  testReferenceToken,\n  testArrayLocation,\n  testArrayIndex,\n  testArrayDash,\n} from '@swagger-api/apidom-json-pointer/modern';\n\ntestJSONPointer('/a/b'); // => true\ntestReferenceToken('a'); // => true\ntestArrayLocation('0'); // => true\ntestArrayLocation('-'); // => true\ntestArrayIndex('0'); // => true\ntestArrayDash('-'); // => true\n```\n\n### Invalid JSON Pointers\n\n`JSONPointerError` is the base class for all JSON Pointer errors.\n\n```js\nimport { JSONPointerError } from '@swagger-api/apidom-json-pointer/modern';\n```\n\nIf an invalid list of tokens is supplied to `compile` function, `JSONPointerCompileError` is thrown.\n\n```js\nimport { JSONPointerCompileError } from '@swagger-api/apidom-json-pointer/modern';\n```\n\nIf an invalid JSON Pointer is supplied to `evaluate` function, `JSONPointerEvaluateError` is thrown.\n\n```js\nimport { JSONPointerEvaluateError } from '@swagger-api/apidom-json-pointer/modern';\n```\n\nIf a valid JSON Pointer is supplied to `evaluate` function and the pointer cannot be evaluated against ApiDOM fragment because it is not an object or an array, `JSONPointerTypeError` is thrown.\n\n```js\nimport { JSONPointerTypeError } from '@swagger-api/apidom-json-pointer/modern';\n```\n\nIf a valid JSON Pointer is supplied to `evaluate` function and the pointer cannot be evaluated against ApiDOM fragment because the key does not exist in the object, `JSONPointerKeyError` is thrown.\n\n```js\nimport { JSONPointerKeyError } from '@swagger-api/apidom-json-pointer/modern';\n```\n\nIf a valid JSON Pointer is supplied to `evaluate` function and the pointer cannot be evaluated against ApiDOM fragment because the index does not exist in the array, `JSONPointerIndexError` is thrown. \n\n```js\nimport { JSONPointerIndexError } from '@swagger-api/apidom-json-pointer/modern';\n```\n\nIf an error occurs in `parse` function, `JSONPointerParseError` is thrown.\n\n```js\nimport { JSONPointerParseError } from '@swagger-api/apidom-json-pointer/modern';\n```\n\n## Legacy API\n\nThis is a legacy API not recommended for use in new projects. It is provided for backward compatibility only.\nThe legacy API implementation is not RFC 6901 compliant, nor does it support all features of JSON Pointer.\n\nImporting legacy API from `@swagger-api/apidom-json-pointer` is equivalent to importing from `@swagger-api/apidom-json-pointer/legacy`.\n\n```js\nimport { evaluate } from '@swagger-api/apidom-json-pointer';\n```\nor\n```js\nimport { evaluate } from '@swagger-api/apidom-json-pointer/legacy';\n```\n\n### Evaluating\n\n```js\nimport { ObjectElement } from '@swagger-api/apidom-core';\nimport { evaluate } from '@swagger-api/apidom-json-pointer';\n\nconst apidom = new ObjectElement({ a: { b: 'c' } });\nconst result =  evaluate('/a/b', apidom);\n// => StringElement('c')\n```\n\n### Parsing\n\nParses JSON Pointer into a list of tokens.\n\n```js\nimport { parse } from '@swagger-api/apidom-json-pointer';\n\nconst tokens = parse('/a/b'); // => ['a', 'b']\n```\n\n### Compiling\n\nCompiles a list of tokens into JSON Pointer.\n\n```js\nimport { compile } from '@swagger-api/apidom-json-pointer';\n\nconst jsonPointer = compile(['a', 'b']); // => '/a/b'\n```\n\n### Escaping\n\nEscapes/unescapes tokens of JSON Pointer.\n\n```js\nimport { escape, unescape } from '@swagger-api/apidom-json-pointer';\n\nescape('~a/'); // => '~0a~1'\nunescape('~0a~1'); // => '~a/'\n```\n\n### Transforming URI to JSON Pointer\n\nHandles case of [URI Fragment Identifier Representation](https://datatracker.ietf.org/doc/html/rfc6901#section-6).\n\n```js\nimport { uriToPointer } from '@swagger-api/apidom-json-pointer';\n\nuriToPointer('https://example.com/path/#/a/b'); // => '/a/b'\n```\n\n### Invalid JSON Pointers\n\nIf an invalid JSON Pointer is supplied to `parse` or `evaluate` functions, `InvalidJsonPointerError`\nis thrown.\n\n```js\nimport { InvalidJsonPointerError } from '@swagger-api/apidom-json-pointer';\n```\n\nIf a valid JSON Pointer is supplied to `evaluate` function and the pointer cannot be evaluated against\nApiDOM fragment, `EvaluationJsonPointerError` is thrown.\n\n```js\nimport { EvaluationJsonPointerError } from '@swagger-api/apidom-json-pointer';\n```\n\n","publish_time":1732189997234,"maintainers":[{"name":"swagger-api","email":"apiteam@swagger.io"}],"_cnpm_publish_time":1732189997234,"dist-tags":{"latest":"1.14.0","v1.11-maintenance":"1.11.6"}}