js-pointer
Advanced tools
Comparing version 0.0.3 to 1.0.0
@@ -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 @@ |
{ | ||
"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 |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
33
4253
11
4
23