Socket
Socket
Sign inDemoInstall

js-pointer

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.3 to 1.0.0

20

dist/index.js

@@ -11,19 +11,7 @@ 'use strict';

function traverse(_x, _x2) {
var _again = true;
function traverse(doc, tokens) {
if (!tokens.length) return doc;
_function: while (_again) {
var doc = _x,
tokens = _x2;
next = undefined;
_again = false;
if (!tokens.length) return doc;
var next = tokens.shift();
_x = doc[next];
_x2 = tokens;
_again = true;
continue _function;
}
var next = tokens.shift();
return traverse(doc[next], tokens);
}

@@ -30,0 +18,0 @@

39

package.json
{
"name": "js-pointer",
"version": "0.0.3",
"version": "1.0.0",
"description": "Tiny, spec compliant JSON Pointer RFC 6901 implementation.",
"main": "dist/index.js",
"scripts": {
"lint": "standard",
"precompile": "rm -f dist/*",
"compile": "babel lib --out-dir dist",
"test": "mocha --compilers js:babel/register test",
"coverage": "mocha --compilers js:babel/register --require blanket -R travis-cov test",
"watch": "watch 'npm run lint && npm test' lib test",
"coverage": "nyc --require babel-core/register --reporter=lcov mocha ./test && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"lint": "standard",
"test": "nyc --check-coverage --require babel-core/register mocha ./test",
"watch": "chokidar 'lib/*.js' 'test/*.js' -c 'npm run lint && npm test'",
"ci": "npm run lint && npm test && npm run coverage",

@@ -33,9 +33,13 @@ "prepublish": "npm run compile"

"devDependencies": {
"babel": "^5.8.21",
"blanket": "^1.1.7",
"chai": "^3.0.0",
"mocha": "^2.2.5",
"standard": "^5.2.2",
"travis-cov": "^0.2.5",
"watch": "^0.16.0"
"babel-cli": "^6.7.7",
"babel-core": "^6.7.7",
"babel-preset-es2015": "^6.6.0",
"babel-register": "^6.7.2",
"chai": "^3.5.0",
"chokidar-cli": "^1.2.0",
"coveralls": "^2.11.9",
"lodash": "^4.8.2",
"mocha": "^2.4.5",
"nyc": "^6.4.0",
"standard": "^6.0.8"
},

@@ -47,14 +51,3 @@ "standard": {

]
},
"config": {
"blanket": {
"pattern": "lib",
"data-cover-never": [
"node_modules"
]
},
"travis-cov": {
"threshold": 100
}
}
}
# js-pointer
[![Build Status](https://travis-ci.org/toboid/js-pointer.svg?branch=master)](https://travis-ci.org/toboid/js-pointer)
[![Coverage Status](https://coveralls.io/repos/github/toboid/js-pointer/badge.svg?branch=master)](https://coveralls.io/github/toboid/js-pointer?branch=master)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
Tiny, spec compliant implementation of the JSON Pointer spec [RFC 6901](https://tools.ietf.org/html/rfc6901) with 100% test coverage.
## Getting started
Install via NPM
```
npm i js-pointer --save
```
``` javascript
var jsPointer = require('js-pointer');
var object = { one: { two: { three: [{ four: 4 }] } } }
jsonPointer.get(object, '/one/two/three/0/four') // returns 4
```
Please see the [spec](https://tools.ietf.org/html/rfc6901) and [tests](https://github.com/toboid/js-pointer/blob/master/test/dereferencing-tests.js) for further detail of the json pointer format.
## API
`jsPointer.get(object, pointer)`
returns sub-object or value in `object` referred to by `pointer`
### object
Plain object targeted by the pointer
### pointer
**string** JSON pointer
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc