Skip to content

Commit 677a678

Browse files
author
cerebralkungfu
authored
verified and fixed examples
1 parent 02aa710 commit 677a678

17 files changed

+184
-158
lines changed

examples/issues/issue-11.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var ptr = require('../../dist');
1+
var ptr = require('../../');
22
var util = require('util');
33

44
var a = {

examples/issues/issue-13.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const assert = require('assert');
2-
const jsonpointer = require('../../dist');
2+
const jsonpointer = require('../../');
33
const thing = Object.assign([1, 2, 3], { foo: 'bar' });
44

55
assert.equal('bar', jsonpointer.get(thing, '/foo'));

examples/issues/issue-28-PoF.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { JsonPointer } = require('../../dist');
1+
const { JsonPointer } = require('../../');
22
const util = require('util');
33

44
var p = new JsonPointer("/I'm/bad");

examples/issues/issue-30-PoF.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const { JsonPointer } = require('../../dist');
1+
const { JsonPointer } = require('../../');
22
JsonPointer.get({},
33
'/aaa\'\]\)\) !== \'undefined\') \{return it;\}; console.log(\'HACKED\'); if((([\'a'); // HACKED

examples/issues/issue-36-PoF.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const { JsonPointer } = require('../../dist');
1+
const { JsonPointer } = require('../../');
22
const util = require('util');
33

44
const o = {
55
id: 1234,
66
employee: null,
7-
created_on: '2021-05-11'
7+
created_on: '2021-05-11',
88
};
99

10-
console.log(JsonPointer.get(o, '/employee/st_price'));
10+
console.log(JsonPointer.get(o, '/employee/st_price'));

examples/list-example.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
const util = require('util');
2-
const { JsonPointer } = require('../dist');
2+
const { JsonPointer } = require('../');
33
var data = {
44
a: 1,
55
b: {
6-
c: 2
6+
c: 2,
77
},
88
d: {
9-
e: [{
10-
a: 3
11-
}, {
12-
b: 4
13-
}, {
14-
c: 5
15-
}]
9+
e: [
10+
{
11+
a: 3,
12+
},
13+
{
14+
b: 4,
15+
},
16+
{
17+
c: 5,
18+
},
19+
],
1620
},
17-
f: null
21+
f: null,
1822
};
1923

2024
var items = JsonPointer.listPointers(data);
2125

2226
console.log(util.inspect(items, false, 99));
2327

2428
items = [];
25-
JsonPointer.listFragmentIds(data, function(item) {
29+
JsonPointer.listFragmentIds(data, function (item) {
2630
var type = typeof item.value;
2731
if (type === 'object') {
2832
if (Array.isArray(item.value)) {

examples/readme/module.create.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
const { JsonPointer } = require( '../../dist');
2-
const { data } = require( './data');
1+
const { JsonPointer } = require('../../');
2+
const { data } = require('./data');
33

44
const pointer = JsonPointer.create('/legumes/2');
55
// const pointer = new JsonPointer('/legumes/2');
66
// fragmentId: #/legumes/2
77

88
const value = pointer.get(data);
99

10-
console.log(`There are ${value.instock} ${value.unit} of ${value.name} in stock.`);
10+
console.log(
11+
`There are ${value.instock} ${value.unit} of ${value.name} in stock.`,
12+
);

examples/readme/module.flatten.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { JsonPointer: ptr } = require('../../dist'); // json-ptr
3+
const { JsonPointer: ptr } = require('../../'); // json-ptr
44
const data = require('./data');
55

66
// var obj = ptr.flatten(data);

examples/readme/module.get.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
'use strict';
22

3-
const { JsonPointer: ptr } = require('../../dist'); // json-ptr
3+
const { JsonPointer: ptr } = require('../../'); // json-ptr
44
const { data } = require('./data');
55
const { format } = require('util');
66

77
const value = ptr.get(data, '/legumes/1');
88
// fragmentId: #/legumes/1
99

1010
console.log(
11-
format('There are %d %s of %s in stock.',
12-
value.instock, value.unit, value.name));
11+
format(
12+
'There are %d %s of %s in stock.',
13+
value.instock,
14+
value.unit,
15+
value.name,
16+
),
17+
);

examples/readme/module.round-trip-encode.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
'use strict';
22

33
const assert = require('assert');
4-
const { JsonPointer: ptr, encodePointer, encodeUriFragmentIdentifier } = require('../../dist'); // json-ptr
4+
const {
5+
JsonPointer: ptr,
6+
encodePointer,
7+
encodeUriFragmentIdentifier,
8+
} = require('../../'); // json-ptr
59

610
const pointer = '/people/wilbur dongleworth/age';
711
const fragmentId = '#/people/wilbur%20dongleworth/age';
@@ -22,6 +26,14 @@ path.forEach((segment, i) => {
2226
assert.equal(segment, fragmentPath[i]);
2327
});
2428

25-
console.log(JSON.stringify({
26-
path, pointer, fragmentId
27-
}, null, ' '));
29+
console.log(
30+
JSON.stringify(
31+
{
32+
path,
33+
pointer,
34+
fragmentId,
35+
},
36+
null,
37+
' ',
38+
),
39+
);

0 commit comments

Comments
 (0)