Comparing version 3.4.0 to 3.5.0
"use strict"; | ||
const url = require('url'); | ||
var __scope = Symbol(); | ||
const __scope = Symbol(); | ||
function isRef(obj) { | ||
@@ -8,5 +8,5 @@ return typeof obj === 'object' && typeof obj.$ref === 'string' && Object.keys(obj).length === 1; | ||
function resolveUri(path, scope) { | ||
var resolvedPath = url.resolve(scope || '', path || ''); | ||
var parsedPath = url.parse(resolvedPath); | ||
var hash = parsedPath.hash || ''; | ||
let resolvedPath = url.resolve(scope || '', path || ''); | ||
let parsedPath = url.parse(resolvedPath); | ||
let hash = parsedPath.hash || ''; | ||
delete parsedPath.hash; | ||
@@ -25,4 +25,4 @@ if (hash) { | ||
function normalizeUri(path, scope, omitEmptyFragment = false) { | ||
var uri = resolveUri(path, scope); | ||
var hash = uri.hash.join('/'); | ||
let uri = resolveUri(path, scope); | ||
let hash = uri.hash.join('/'); | ||
return uri.url + (!omitEmptyFragment || hash !== '#' ? hash : ''); | ||
@@ -35,8 +35,8 @@ } | ||
} | ||
var _data = data; | ||
var _path = typeof path === 'string' ? (path === '/' ? [] : path.split('/')) : path; | ||
let _data = data; | ||
let _path = typeof path === 'string' ? (path === '/' ? [] : path.split('/')) : path; | ||
if (arguments.length > 2) { | ||
for (var i = 0, max = _path.length - 1, p = null; p = _path[i], i < max; i++) { | ||
let p; | ||
for (let i = 0, max = _path.length - 1; p = _path[i], i < max; i++) { | ||
if ((p === '#' || p === '') && i === 0) { | ||
continue; | ||
} | ||
@@ -60,5 +60,4 @@ else { | ||
else { | ||
for (var i = 0, _data = data; typeof _data !== 'undefined' && _path && i < _path.length; i++) { | ||
for (let i = 0; typeof _data !== 'undefined' && _path && i < _path.length; i++) { | ||
if ((_path[i] === '#' || _path[i] === '') && i === 0) { | ||
continue; | ||
} | ||
@@ -78,10 +77,10 @@ else { | ||
function parse(dataOrUri, opts = {}) { | ||
var _opts = opts; | ||
var _store = _opts.store || {}; | ||
var _retriever = _opts.retriever || function (url) { | ||
let _opts = opts; | ||
let _store = _opts.store || {}; | ||
let _retriever = _opts.retriever || function (url) { | ||
return Promise.reject(new Error('no_retriever')); | ||
}; | ||
var _root; | ||
let _root; | ||
function _register(path, scope, data) { | ||
var resolved = normalizeUri(path, scope); | ||
let resolved = normalizeUri(path, scope); | ||
_store[resolved] = data; | ||
@@ -91,5 +90,5 @@ return resolved; | ||
function _getPointer(path, scope) { | ||
var uri = resolveUri(path, scope); | ||
var data; | ||
for (var i = uri.hash.length, k; !data && i > 0; i--) { | ||
let uri = resolveUri(path, scope); | ||
let data, i, k; | ||
for (i = uri.hash.length; !data && i > 0; i--) { | ||
k = uri.url + uri.hash.slice(0, i).join('/'); | ||
@@ -127,3 +126,3 @@ if (k === '#') { | ||
function _parsePassOne(data, scope) { | ||
var _scope, i, o; | ||
let _scope, i, o; | ||
if (typeof data.id === 'string') { | ||
@@ -144,4 +143,4 @@ _scope = _register(data.id, scope, data); | ||
function _parsePassTwo(data) { | ||
var p = Promise.resolve(true); | ||
var _scope = data[__scope]; | ||
let p = Promise.resolve(true); | ||
let _scope = data[__scope]; | ||
function _deref(key, ref) { | ||
@@ -169,3 +168,3 @@ return p.then(function () { | ||
} | ||
var i, o; | ||
let i, o; | ||
for (i in data) { | ||
@@ -212,3 +211,3 @@ o = data[i]; | ||
if (typeof data === 'object') { | ||
var _scope, i, o; | ||
let _scope, i, o; | ||
if (typeof data.id === 'string') { | ||
@@ -215,0 +214,0 @@ _scope = normalizeUri(data.id, scope); |
{ | ||
"name": "jsonref", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "Javascript References ($ref) and Pointers library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24217
241