Socket
Socket
Sign inDemoInstall

json-pointer

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-pointer - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

13

index.js

@@ -107,3 +107,14 @@ 'use strict';

}
delete api.get(obj, refTokens.slice(0, -1))[finalToken];
var parent = api.get(obj, refTokens.slice(0, -1));
if (Array.isArray(parent)) {
var index = +finalToken;
if (finalToken === '' && isNaN(index)) {
throw new Error('Invalid array index: "' + finalToken + '"');
}
Array.prototype.splice.call(parent, index, 1);
} else {
delete parent[finalToken];
}
};

@@ -110,0 +121,0 @@

2

package.json
{
"name": "json-pointer",
"description": "Some utilities for JSON pointers described by RFC 6901",
"version": "0.5.0",
"version": "0.6.0",
"author": "Manuel Stofer <manuel@takimata.ch>",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -18,9 +18,3 @@ # json-pointer

[component](https://github.com/component/component)
```bash
$ component install manuelstofer/json-pointer
```
## API

@@ -27,0 +21,0 @@

@@ -180,20 +180,45 @@ /*global describe, it, beforeEach*/

each(Object.keys(rfcValues), function (p) {
if (p !== '') {
it('should work for "' + p + '"', function () {
pointer.remove(rfcExample, p);
expect(pointer.get.bind(pointer, rfcExample, p)).to.throw(Error);
});
}
if (p === '' || p === '/foo/0') return;
it('should work for "' + p + '"', function () {
pointer.remove(rfcExample, p);
expect(pointer.get.bind(pointer, rfcExample, p)).to.throw(Error);
});
});
it('should work for "/foo/0"', function () {
var p = '/foo/0';
pointer.remove(rfcExample, p);
expect(pointer.get(rfcExample, p)).to.equal('baz');
});
it('should work for "/foo/1"', function () {
var p = '/foo/1';
pointer.remove(rfcExample, p);
expect(pointer.get.bind(pointer, rfcExample, p)).to.throw(Error);
});
each(Object.keys(rfcParsed), function (p) {
if (p !== '') {
it('should work for ' + JSON.stringify(rfcParsed[p].tokens), function () {
pointer.remove(rfcExample, immutable(rfcParsed[p].tokens));
expect(function() {
pointer.get(pointer, rfcExample, immutable(rfcParsed[p].tokens));
}).to.throw(Error);
});
}
if (p === '' || p === '/foo/0') return;
it('should work for ' + JSON.stringify(rfcParsed[p].tokens), function () {
pointer.remove(rfcExample, immutable(rfcParsed[p].tokens));
expect(function() {
pointer.get(rfcExample, immutable(rfcParsed[p].tokens));
}).to.throw(Error);
});
});
it('should work for ["foo","0"]', function () {
var p = immutable(['foo', '0']);
pointer.remove(rfcExample, p);
expect(pointer.get(rfcExample, p)).to.equal('baz');
});
it('should work for ["foo","1"]', function () {
var p = immutable(['foo', '1']);
pointer.remove(rfcExample, p);
expect(pointer.get.bind(pointer, rfcExample, p)).to.throw(Error);
});
});

@@ -200,0 +225,0 @@

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