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

@hyperjump/json-pointer

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperjump/json-pointer - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

32

dist/json-pointer.js

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

});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var nil = exports.nil = "";
var get = exports.get = function get(pointer) {
if (pointer.length > 0 && pointer[0] !== "/") {
throw Error("Invalid JSON Pointer");
}
var ptr = pointer.split("/").slice(1).map(unescape);
return function (value) {
return ptr.reduce(function (acc, segment) {
return acc[segment];
}, value);
return ptr.reduce(function (_ref, segment) {
var _ref2 = _slicedToArray(_ref, 2),
value = _ref2[0],
pointer = _ref2[1];
return [applySegment(value, segment, pointer), append(pointer, segment)];
}, [value, ""])[0];
};

@@ -27,2 +41,14 @@ };

return segment.toString().replace("~0", "~").replace("~1", "/");
};
var applySegment = function applySegment(value, segment) {
var pointer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
if (value === null || (typeof value === "undefined" ? "undefined" : _typeof(value)) !== "object") {
throw Error("Value at '" + pointer + "' is a scalar and can't be indexed");
} else if (!(segment in value)) {
throw Error("Value at '" + pointer + "' does not have index '" + segment + "'");
}
return value[segment];
};

2

package.json
{
"name": "@hyperjump/json-pointer",
"version": "0.2.0",
"version": "0.2.1",
"description": "An RFC-6901 JSON Pointer implementation",

@@ -5,0 +5,0 @@ "main": "./dist/json-pointer.js",

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