Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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

Package Overview
Dependencies
Maintainers
0
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Evaluate Relative JSON Pointer expressions against ApiDOM.

  • 1.0.0-beta.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
Maintainers
0
Weekly downloads
 
Created
Source

@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';

FAQs

Package last updated on 16 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc