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 2.0.2 to 3.0.0

28

lib/index.js

@@ -39,5 +39,6 @@ 'use strict';

}
function parse(dataOrUri, store, retriever) {
var _store = store || {};
var _retriever = retriever || function () {
function parse(dataOrUri, opts) {
var _opts = opts || {};
var _store = _opts.store || {};
var _retriever = _opts.retriever || function () {
return Promise.reject(new Error('no_retriever'));

@@ -93,14 +94,3 @@ };

}
function _getSync(path, scope) {
var uri = _resolve(path, scope);
var data;
for (var i = uri.hash.length; i > 0; i--) {
data = _store[uri.url + _url2.default.hash.slice(0, i).join('/')];
if (data) {
return pointer(data, uri.hash.slice(i));
}
}
return undefined;
}
function _parse(path, scope, data) {
function _parse(data, scope) {
_root = data;

@@ -163,4 +153,4 @@ function _parsePassOne(data, scope) {

}
_parsePassOne(data);
return _parsePassTwo(data).then(function () {
_parsePassOne(data, scope);
return _parsePassTwo(data, scope).then(function () {
return data;

@@ -171,7 +161,7 @@ });

if (typeof dataOrUri === 'string') {
return _get(dataOrUri);
return _get(dataOrUri, _opts.scope);
} else {
return _parse(null, null, dataOrUri);
return _parse(dataOrUri, _opts.scope);
}
}
//# sourceMappingURL=index.js.map
{
"name": "jsonref",
"version": "2.0.2",
"version": "3.0.0",
"description": "Javascript References ($ref) and Pointers library",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -17,9 +17,11 @@ # jsonref

## parse(dataOrUri, store, retriever)
## parse(dataOrUri _[, options]_)
* `dataOrUri`, the data to parse or a fully qualified URI to pass to `retriever` to download the data
* `store` (optional), an object to use to cache resolved `id` and `$ref` values. If no store is passed,
* `options` (optional), parsing options, the following optional properties are supported:
* `scope`, the current resolution scope (base href) of URLs and paths.
* `store`, an object to use to cache resolved `id` and `$ref` values. If no store is passed,
one is automatically created. Pass a `store` if you are going to parse several objects or URIs referencing
the same `id` and `$ref` values.
* `retriever` (optional), a function accepting a URL in input and returning a promise resolved to an object
* `retriever`, a function accepting a URL in input and returning a promise resolved to an object
representing the data downloaded for the URI. Whenever a `$ref` to a new URI is found, if the URI is not

@@ -135,3 +137,5 @@ already cached in the store in use, it'll be fetched using this `retriever`. If not `retriever` is passed

]
}, null, retriever).then(function(data) {
}, null, {
retriever: retriever
}).then(function(data) {
console.log(JSON.stringify(data, null, 2));

@@ -162,3 +166,5 @@ });

}
}, store).then(function(data) {
}, null, {
store: store
}).then(function(data) {
console.log(JSON.stringify(store, null, 2));

@@ -165,0 +171,0 @@ });

@@ -24,5 +24,6 @@ import url from 'url';

}
export function parse(dataOrUri, store, retriever) {
var _store = store || {};
var _retriever = retriever || function () {
export function parse(dataOrUri, opts) {
var _opts = opts || {};
var _store = _opts.store || {};
var _retriever = _opts.retriever || function () {
return Promise.reject(new Error('no_retriever'));

@@ -78,14 +79,3 @@ };

}
function _getSync(path, scope) {
var uri = _resolve(path, scope);
var data;
for (var i = uri.hash.length ; i > 0 ; i--) {
data = _store[uri.url + url.hash.slice(0, i).join('/')];
if (data) {
return pointer(data, uri.hash.slice(i));
}
}
return undefined;
}
function _parse(path, scope, data) {
function _parse(data, scope) {
_root = data;

@@ -145,4 +135,4 @@ function _parsePassOne(data, scope) {

}
_parsePassOne(data);
return _parsePassTwo(data).then(function() {
_parsePassOne(data, scope);
return _parsePassTwo(data, scope).then(function() {
return data;

@@ -153,6 +143,6 @@ });

if (typeof dataOrUri === 'string') {
return _get(dataOrUri);
return _get(dataOrUri, _opts.scope);
} else {
return _parse(null, null, dataOrUri);
return _parse(dataOrUri, _opts.scope);
}
}

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