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

json-ptr

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-ptr - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1-ts.64a7978.0

.mocharc.json

16

examples/readme/module.create.js

@@ -1,14 +0,10 @@

'use strict';
import { JsonPointer } from '../../src';
import { data } from './data';
var ptr = require('../../'); // json-ptr
var data = require('./data');
var format = require('util').format;
var pointer = ptr.create('/legumes/2');
const pointer = JsonPointer.create('/legumes/2');
// const pointer = new JsonPointer('/legumes/2');
// fragmentId: #/legumes/2
var value = pointer.get(data);
const value = pointer.get(data);
console.log(
format('There are %d %s of %s in stock.',
value.instock, value.unit, value.name));
console.log(`There are ${value.instock} ${value.unit} of ${value.name} in stock.`);
{
"name": "json-ptr",
"version": "1.2.0",
"version": "1.2.1-ts.64a7978.0",
"author": "Phillip Clark <phillip@flitbit.com>",

@@ -12,3 +12,4 @@ "description": "A complete implementation of JSON Pointer (RFC 6901) for nodejs and modern browsers.",

],
"main": "index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",

@@ -20,26 +21,55 @@ "repository": {

"scripts": {
"prerelease": "npm run clean && npm run test",
"release": "uglifyjs -c -m -o dist/json-ptr.min.js -r '$,require,exports,self,module,define' index.js",
"clean": "rimraf dist && mkdir dist",
"preversion": "npm run release",
"postversion": "git push && git push --tags",
"pretest": "npm run lint",
"test": "mocha test/**/*.js --reporter tap",
"test:watch": "nodemon --ext js,json --ignore dist/ --exec 'npm test'",
"preci": "npm run lint",
"ci": "mocha --reporter mocha-junit-reporter test/**/*.js",
"lint": "eslint index.js test"
"build": "tsc --build tsconfig.json",
"clean": "rimraf dist .nyc_output coverage",
"lint": "eslint src --ext .js,.ts,.json",
"preversion": "npm run build",
"prebuild": "npm run lint",
"pretest": "npm run build",
"test": "nyc mocha src/**/*.spec.ts",
"ci": "npm run test",
"docs": "typedoc"
},
"devDependencies": {
"bluebird": "^3.5.5",
"eslint": "^6.4.0",
"eslint-plugin-mocha": "^6.1.1",
"expect.js": "^0.3.1",
"json": "^9.0.6",
"mocha": "^6.2.0",
"mocha-junit-reporter": "^1.23.1",
"nodemon": "^1.19.2",
"rimraf": "^3.0.0",
"uglify-js": "^3.6.0"
"@types/assert-plus": "^1.0.4",
"@types/bent": "^7.0.1",
"@types/chai": "^4.2.9",
"@types/mocha": "^7.0.1",
"@typescript-eslint/eslint-plugin": "^2.19.2",
"@typescript-eslint/parser": "^2.19.2",
"bent": "^7.0.6",
"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-json": "^2.0.1",
"eslint-plugin-mocha": "^6.2.2",
"eslint-plugin-prettier": "^3.1.2",
"lodash": "^4.17.15",
"mocha": "^7.0.1",
"nyc": "^15.0.0",
"prettier": "^1.19.1",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.16",
"ts-node": "^8.6.2",
"typedoc": "^0.16.10",
"typescript": "^3.7.5"
},
"nyc": {
"include": [
"src/**/*.ts"
],
"extension": [
".ts",
".tsx"
],
"require": [
"ts-node/register"
],
"reporter": [
"text-summary",
"html"
],
"sourceMap": true,
"instrument": true
}
}

@@ -19,3 +19,3 @@ # json-ptr

## Use/Import
## Use

@@ -25,14 +25,5 @@ ### [nodejs](https://nodejs.org/en/)

```javascript
// npm install json-ptr
var ptr = require('json-ptr')
import { JsonPointer, create } from 'json-ptr';
```
### browser
```html
<script src="https://cdn.jsdelivr.net/npm/json-ptr@1/dist/json-ptr.min.js"></script>
<!-- exports an object named JsonPointer -->
<script>var ptr = JsonPointer.noConflict()</script>
```
### Module API

@@ -58,3 +49,3 @@

```javascript
var data = {
const data = {
legumes: [{

@@ -80,3 +71,3 @@ name: 'pinto beans',

#### .create(pointer)
#### .create(pointer: string | string[]): JsonPointer

@@ -95,8 +86,8 @@ Creates an instance of the `JsonPointer` class.

```javascript
var pointer = ptr.create('/legumes/0');
```ts
const pointer = JsonPointer.create('/legumes/0');
// fragmentId: #/legumes/0
```
#### .has(target,pointer)
#### .has&lt;T>(target: T, pointer: string | string[] | JsonPointer): boolean

@@ -130,3 +121,3 @@ Determins whether the specified `target` has a value at the `pointer`'s path.

```javascript
var value = ptr.get(data, '/legumes/1');
let value = JsonPointer.get(data, '/legumes/1');
// fragmentId: #/legumes/1

@@ -153,3 +144,3 @@ ```

```javascript
var prior = ptr.set(data, '#/legumes/1/instock', 50);
let prior = JsonPointer.set(data, '#/legumes/1/instock', 50);
```

@@ -160,7 +151,7 @@

```javascript
var data = {};
let data = {};
ptr.set(data, '#/peter/piper', 'man', true);
ptr.set(data, '#/peter/pan', 'boy', true);
ptr.set(data, '#/peter/pickle', 'dunno', true);
JsonPointer.set(data, '#/peter/piper', 'man', true);
JsonPointer.set(data, '#/peter/pan', 'boy', true);
JsonPointer.set(data, '#/peter/pickle', 'dunno', true);

@@ -198,3 +189,3 @@ console.log(JSON.stringify(data, null, ' '));

```javascript
var list = ptr.list(data);
let list = JsonPointer.list(data);
```

@@ -230,3 +221,3 @@

```javascript
var list = ptr.list(data, true);
let list = JsonPointer.list(data, true);
```

@@ -275,3 +266,3 @@

```javascript
var obj = ptr.flatten(data, true);
let obj = JsonPointer.flatten(data, true);
```

@@ -309,3 +300,3 @@

```javascript
var map = ptr.map(data, true);
let map = JsonPointer.map(data, true);

@@ -348,3 +339,3 @@ for (let it of map) {

```javascript
var path = ptr.decode('#/legumes/1/instock');
let path = JsonPointer.decode('#/legumes/1/instock');
```

@@ -356,3 +347,3 @@

#### .decodePointer(pointer)
#### decodePointer(pointer)

@@ -372,3 +363,3 @@ Decodes the specified `pointer`.

```javascript
var path = ptr.decodePointer('/people/wilbur dongleworth/age');
let path = decodePointer('/people/wilbur dongleworth/age');
```

@@ -380,3 +371,3 @@

#### .encodePointer(path)
#### encodePointer(path)

@@ -396,3 +387,3 @@ Encodes the specified `path` as a JSON pointer in [JSON string representation](https://tools.ietf.org/html/rfc6901#section-5).

```javascript
var path = ptr.encodePointer(['people', 'wilbur dongleworth', 'age']);
let path = encodePointer(['people', 'wilbur dongleworth', 'age']);
```

@@ -404,3 +395,3 @@

#### .decodeUriFragmentIdentifier(pointer)
#### decodeUriFragmentIdentifier(pointer)

@@ -420,3 +411,3 @@ Decodes the specified `pointer`.

```javascript
var path = ptr.decodePointer('#/people/wilbur%20dongleworth/age');
let path = decodePointer('#/people/wilbur%20dongleworth/age');
```

@@ -428,3 +419,3 @@

#### .encodeUriFragmentIdentifier(path)
#### encodeUriFragmentIdentifier(path)

@@ -444,3 +435,3 @@ Encodes the specified `path` as a JSON pointer in [URI fragment identifier representation](https://tools.ietf.org/html/rfc6901#section-6).

```javascript
var path = ptr.encodePointer(['people', 'wilbur dongleworth', 'age']);
let path = ptr.encodePointer(['people', 'wilbur dongleworth', 'age']);
```

@@ -452,18 +443,2 @@

#### .noConflict()
Restores a conflicting `JsonPointer` variable in the global/root namespace (not necessary in node, but useful in browsers).
_example:_
```html
<!-- ur codez -->
<script src="/json-ptr-0.3.0.min.js"></script>
<script>
// At this point, JsonPointer is the json-ptr module
var ptr = JsonPointer.noConflict();
// and now it is restored to whatever it was before the json-ptr import.
</script>
```
### `JsonPointer` Class

@@ -570,3 +545,3 @@

var ptr = require('..'),
let ptr = require('..'),
http = require('http'),

@@ -576,11 +551,11 @@ util = require('util');

// A flickr feed, tags surf,pipeline
var feed = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=surf,pipeline&tagmode=all&format=json&jsoncallback=processResponse';
let feed = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=surf,pipeline&tagmode=all&format=json&jsoncallback=processResponse';
// Compile/prepare the pointers...
var items = ptr.create('#/items');
var author = ptr.create('#/author');
var media = ptr.create('#/media/m');
let items = ptr.create('#/items');
let author = ptr.create('#/author');
let media = ptr.create('#/media/m');
function processResponse(json) {
var data = items.get(json);
let data = items.get(json);

@@ -601,3 +576,3 @@ if (data && Array.isArray(data)) {

http.get(feed, function(res) {
var data = '';
let data = '';

@@ -636,2 +611,5 @@ res.on('data', function(chunk) {

* 2019-09-14 &mdash; __1.2.0__
* Merged new `.concat` function contributed by @vuwuv, updated dependencies.
* 2019-03-10 &mdash; __1.1.2__

@@ -638,0 +616,0 @@ * Updated packages to remove critical security concern among dev dependencies'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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