0.99.2 • Published 6 days ago

@swagger-api/apidom-json-pointer-relative v0.99.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
6 days ago

@swagger-api/apidom-json-pointer-relative

apidom-json-pointer-relative is a package that evaluates Relative JSON Pointer against ApiDOM.

Installation

You can install this package via npm CLI by running the following command:

 $ npm install @swagger-api/apidom-json-pointer-relative

Evaluating

import { ObjectElement } from '@swagger-api/apidom-core';
import { evaluate } from '@swagger-api/apidom-json-pointer-relative';

const root = new ObjectElement({ a: { b: 'c' } });
const current = root.get('a').get('b');
const result =  evaluate('0#', current, root);
// => StringElement('b')

Parsing

Parses Relative JSON Pointer into AST (Abstract Syntax Tree).

import { parse } from '@swagger-api/apidom-json-pointer-relative';

const tokens = parse('2/foo/0');
// => { nonNegativeIntegerPrefix: 2, indexManipulation: undefined, jsonPointerTokens: ['foo', '0'], hashCharacter: false }

Compiling

Compiles AST into Relative JSON Pointer.

import { compile } from '@swagger-api/apidom-json-pointer-relative';

const relativeJsonPointer = compile({
  nonNegativeIntegerPrefix: 2,
  indexManipulation: undefined,
  jsonPointerTokens: ['highly', 'nested', 'objects'],
  hashCharacter: false,
}); // => '2/highly/nested/objects'

Invalid Relative JSON Pointers

If invalid Relative JSON Pointer is supplied to parse or evaluate functions, InvalidRelativeJsonPointerError is thrown.

import { InvalidRelativeJsonPointerError } from '@swagger-api/apidom-json-pointer-relative';

If valid JSON Pointer is supplied to evaluate function and the relative pointer cannot be evaluated against ApiDOM fragment, EvaluationRelativeJsonPointerError is thrown.

import { EvaluationRelativeJsonPointerError } from '@swagger-api/apidom-json-pointer-relative';
0.99.2

6 days ago

0.99.1

1 month ago

0.99.0

1 month ago

0.98.0

2 months ago

0.97.0

2 months ago

0.96.0

2 months ago

0.95.0

3 months ago

0.94.0

3 months ago

0.93.0

3 months ago

0.92.0

4 months ago

0.91.0

4 months ago

0.90.0

4 months ago

0.89.0

5 months ago

0.88.0

5 months ago

0.87.0

5 months ago

0.86.0

5 months ago

0.84.0

5 months ago

0.85.0

5 months ago

0.83.0

6 months ago

0.82.2

6 months ago

0.82.1

6 months ago

0.82.0

6 months ago

0.81.0

6 months ago

0.80.0

6 months ago

0.79.0

6 months ago

0.78.0

7 months ago

0.77.0

7 months ago

0.76.2

8 months ago

0.76.1

8 months ago

0.76.0

8 months ago

0.75.0

9 months ago