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

js-pointer

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-pointer

Tiny, spec compliant JSON Pointer RFC 6901 implementation.

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
32
increased by45.45%
Maintainers
1
Weekly downloads
 
Created
Source

js-pointer

Greenkeeper badge Build Status Coverage Status Dependencies npm version

Tiny, spec compliant implementation of the JSON Pointer spec RFC 6901 with 100% test coverage and no dependencies.

Getting started

Install via NPM

  npm i js-pointer --save

Point to object properties

const jsPointer = require('js-pointer');

const object = { one: { two: 3 } }
jsPointer.get(object, '/one/two')
// → 3

Pointing to array elements

const object = { one: { two: [3] } }
jsPointer.get(object, '/one/two/0')
// → 3

Pointing through array elements

const object = { one: { two: [{ three: 4 }] } }
jsPointer.get(object, '/one/two/0/three')
// → 4

Please see the spec and tests for further detail of the JSON pointer format.

API

jsPointer.get(object, pointer)

Returns sub-object or value in object referred to by pointer. If pointer does not refer to an object or value then undefined will be returned.

object

Plain object targeted by the pointer

pointer

string JSON pointer. A pointer beginning with # indicates a URI fragment, which will be URI decoded before processing.

Keywords

FAQs

Package last updated on 07 Jan 2018

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