Skip to content

Commit 10221b5

Browse files
committed
updated json-ptr to 3.1.1
1 parent 3966e01 commit 10221b5

6 files changed

+125
-27
lines changed

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const fs = require('fs');
44
const jsonPatch = require('rfc6902');
55
const RefParser = require('./patched-json-schema-ref-parser');
66
const jps = require('./json-pointer-selectors');
7-
const jsonPtr = require('json-ptr');
7+
const { JsonPointer } = require('json-ptr');
88
const clone = require('./clone');
99

1010
/**
@@ -53,7 +53,7 @@ const applyInherit = function (doc, options, rootDoc, inWith) {
5353
// pointer to whole document under key 'source'
5454
if (inWith || !re[2]) {
5555
//console.error('cloning document', doc.$ref, re, re_source)
56-
return clone(jsonPtr.get(rootDoc, doc.$ref));
56+
return clone(JsonPointer.get(rootDoc, doc.$ref));
5757
} else {
5858
//console.error('replacing $ref', doc.$ref, re, re_source)
5959
doc.$ref = doc.$ref.replace(re_inherit, '');
@@ -66,7 +66,7 @@ const applyInherit = function (doc, options, rootDoc, inWith) {
6666
//console.error('found with ref', doc)
6767
// pointer to whole document under key 'source'
6868
//console.error('cloning document', doc.$ref, re, re_with)
69-
return clone(jsonPtr.get(rootDoc, doc.$ref));
69+
return clone(JsonPointer.get(rootDoc, doc.$ref));
7070
}
7171
}
7272
}

json-pointer-selectors.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const jsonPtr = require('json-ptr');
3+
const { JsonPointer } = require('json-ptr');
44

55
//
66
// Some json pointer additions (path with object selectors)
@@ -205,7 +205,7 @@ const compileOperation = (source, op) => {
205205
const re = parseJsonPointer(op.path);
206206

207207
if (re.selector) {
208-
const arr = jsonPtr.get(source, re.prefix);
208+
const arr = JsonPointer.get(source, re.prefix);
209209

210210
// if object is not array check deeper
211211
if (!Array.isArray(arr)) {
@@ -245,9 +245,9 @@ const compileOperation = (source, op) => {
245245
}
246246

247247
// all path exists or "op" is adding a new leaf
248-
if (jsonPtr.get(source, op.path)
248+
if (JsonPointer.get(source, op.path)
249249
|| (op.op == 'add' || op.op == 'move')
250-
&& jsonPtr.get(source, op.path.match(/(^.*)\/[^\/]*/)[1])
250+
&& JsonPointer.get(source, op.path.match(/(^.*)\/[^\/]*/)[1])
251251
) {
252252
return op;
253253
}

package-lock.json

+101-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
"test": "test"
88
},
99
"dependencies": {
10-
"json-ptr": "^1.2.0",
10+
"json-ptr": "^3.1.1",
1111
"json-schema-ref-parser": "^6.1.0",
1212
"rfc6902": "^3.0.4"
1313
},
14-
"devDependencies": {},
1514
"scripts": {
16-
"test": "mocha test"
15+
"test": "mocha test -b"
1716
},
1817
"repository": {
1918
"type": "git",

test/test_bundle.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
const assert = require('assert');
44
const bundle = require('../index').bundle;
55

6-
const date = new Date();
7-
86
const casesBundle = {
97
'bundle': {
108
prepare: {
@@ -47,6 +45,14 @@ const casesBundle = {
4745

4846
describe('Jybid bundle file', function () {
4947
const fs = require('fs');
48+
49+
before(() => {
50+
if (!fs.existsSync('.tmp')) fs.mkdirSync('.tmp')
51+
})
52+
after(() => {
53+
fs.rmdirSync('.tmp')
54+
})
55+
5056
for (const name in casesBundle) {
5157
it(name, (done) => {
5258
let error;

test/test_bundle_with_inherit_with_json_patch.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
const assert = require('assert');
44
const jybid = require('../index');
55

6-
const date = new Date();
7-
86
const cases = {
97
'patch without $ref\'s': {
108
op: 'bundle',
@@ -144,6 +142,13 @@ const cases = {
144142

145143
describe('Jybid bundle and dereference file with JSON Patch inheritance', function () {
146144
const fs = require('fs');
145+
146+
before(() => {
147+
if (!fs.existsSync('.tmp')) fs.mkdirSync('.tmp')
148+
})
149+
after(() => {
150+
fs.rmdirSync('.tmp')
151+
})
147152

148153
for (const name in cases) {
149154
const test = cases[name];

0 commit comments

Comments
 (0)