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

jsonref

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonref - npm Package Compare versions

Comparing version 5.3.0 to 6.0.0

4

dist/index.js

@@ -10,6 +10,6 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.scope = void 0;
exports.parse = exports.scope = exports.pointer = exports.normalizeUri = exports.normalize = exports.isRef = exports.isAnnotated = exports.getMeta = void 0;
const errors_1 = require("./errors");

@@ -16,0 +16,0 @@ const meta = require("./meta");

@@ -18,5 +18,1 @@ export interface JSONPatchOther {

export declare function patch(obj: any, patch: JSONPatch): any;
export declare function toMongoUpdate(patch: JSONPatch): {
query?: any;
doc?: any;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toMongoUpdate = exports.patch = exports.diff = void 0;
exports.patch = exports.diff = void 0;
const meta = require("./meta");

@@ -170,91 +170,2 @@ const pointer = require("./pointer");

exports.patch = patch;
function toMongoUpdate(patch) {
const out = {};
for (let p of patch) {
const path = (p.path || '').split('/').slice(1);
if (!path.length) {
throw new Error('path cannot be empty');
}
switch (p.op) {
case 'add':
if (!out.doc)
out.doc = {};
if (path.length && path[path.length - 1] == '-') {
if (path.length === 1) {
throw new Error("cannot use '-' index at root of path");
}
path.pop();
if (!out.doc.$push)
out.doc.$push = {};
out.doc.$push[path.join('.')] = p.value;
}
else {
if (!out.doc.$set)
out.doc.$set = {};
out.doc.$set[path.join('.')] = p.value;
}
break;
case 'replace':
if (path.length && path[path.length - 1] == '-') {
throw new Error("cannot use '-' index in path of replace");
}
else {
if (!out.doc)
out.doc = {};
if (!out.doc.$set)
out.doc.$set = {};
out.doc.$set[path.join('.')] = p.value;
if (!out.query)
out.query = {};
out.query[path.join('.')] = { $exists: true };
}
break;
case 'move':
const from = (p.from || '').split('/').slice(1);
if (!from.length) {
throw new Error('from path cannot be empty');
}
if (from.length && from[from.length - 1] == '-') {
throw new Error("cannot use '-' index in from path of move");
}
else if (path.length && path[path.length - 1] == '-') {
throw new Error("cannot use '-' index in path of move");
}
else {
if (!out.doc)
out.doc = {};
if (!out.doc.$rename)
out.doc.$rename = {};
out.doc.$rename[from.join('.')] = path.join('.');
}
break;
case 'remove':
if (path.length && path[path.length - 1] == '-') {
throw new Error("cannot use '-' index in path of remove");
}
else {
if (!out.doc)
out.doc = {};
if (!out.doc.$unset)
out.doc.$unset = {};
out.doc.$unset[path.join('.')] = 1;
}
break;
case 'copy':
throw new Error('copy not supported');
case 'test':
if (path.length && path[path.length - 1] == '-') {
throw new Error("cannot use '-' index in path of test");
}
else {
if (!out.query)
out.query = {};
out.query[path.join('.')] = p.value;
}
break;
}
}
return out;
}
exports.toMongoUpdate = toMongoUpdate;
//# sourceMappingURL=patch.js.map
{
"name": "jsonref",
"version": "5.3.0",
"version": "6.0.0",
"description": "Javascript References ($ref) and Pointers library",

@@ -52,22 +52,22 @@ "main": "dist/index.js",

"devDependencies": {
"@commitlint/config-conventional": "^8.1.0",
"@types/chai": "^4.1.7",
"@types/chai-as-promised": "^7.1.0",
"@types/chai-spies": "^1.0.0",
"@types/mocha": "^5.2.7",
"@types/node": "^10.14.1",
"chai": "^4.2.0",
"@commitlint/config-conventional": "^11.0.0",
"@types/chai": "^4.2.14",
"@types/chai-as-promised": "^7.1.3",
"@types/chai-spies": "^1.0.3",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.25",
"chai": "^4.3.0",
"chai-as-promised": "^7.1.1",
"chai-spies": "^1.0.0",
"commitizen": "^4.0.3",
"commitlint": "^8.1.0",
"coveralls": "^3.0.5",
"cz-conventional-changelog": "^3.0.2",
"husky": "^3.0.1",
"mocha": "^6.2.0",
"mochawesome": "^4.0.1",
"nyc": "^14.1.1",
"rimraf": "^2.6.3",
"semantic-release": "^15.13.18",
"typescript": "^3.5.3"
"commitizen": "^4.2.3",
"commitlint": "^11.0.0",
"coveralls": "^3.1.0",
"cz-conventional-changelog": "^3.3.0",
"husky": "^5.0.9",
"mocha": "^8.2.1",
"mochawesome": "^6.2.1",
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"semantic-release": "^17.3.8",
"typescript": "^4.1.3"
},

@@ -74,0 +74,0 @@ "config": {

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