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

deref

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

deref - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

10

lib/index.js

@@ -9,4 +9,5 @@ 'use strict';

var instance = module.exports = function() {
function $ref(fakeroot, schema, refs) {
function $ref(fakeroot, schema, refs, ex) {
if (typeof fakeroot === 'object') {
ex = refs;
refs = schema;

@@ -17,2 +18,7 @@ schema = fakeroot;

if (typeof refs !== 'object') {
ex = !!refs;
refs = [];
}
function pushReference(from) {

@@ -38,3 +44,3 @@ $.normalizeSchema(fakeroot, from);

return $.cloneSchema(schema, $ref.refs);
return $.cloneSchema(schema, $ref.refs, ex);
}

@@ -41,0 +47,0 @@

34

lib/util/clone-schema.js

@@ -6,3 +6,3 @@ 'use strict';

var clone = module.exports = function(obj, refs, parent) {
var clone = module.exports = function(obj, refs, combine) {
var copy = {};

@@ -14,2 +14,12 @@

if (Array.isArray(obj)) {
if (!combine) {
return obj.slice();
}
return obj.map(function(schema) {
return clone(schema, refs, true);
});
}
if ($.isURL(obj.$ref)) {

@@ -32,3 +42,5 @@ var uri = $.getDocumentURI(obj.$ref) || obj.$ref;

fixed.id = obj.$ref;
if (combine) {
return clone(fixed, refs, true);
}

@@ -41,21 +53,9 @@ return fixed;

if (Array.isArray(obj)) {
return obj.map(function(value) {
var fixed = clone(value, refs, parent);
if ($.getDocumentURI(fixed.id) !== parent) {
return fixed;
}
return value;
});
}
for (var key in obj) {
var value = obj[key];
if (typeof value === 'object' && key !== 'enum') {
copy[key] = clone(value, refs, obj.id || obj.$schema || parent);
if (typeof value === 'object' && !(key === 'enum' || key === 'required')) {
copy[key] = clone(value, refs, combine);
} else {
copy[key] = Array.isArray(value) ? value.slice() : value;
copy[key] = value;
}

@@ -62,0 +62,0 @@ }

@@ -36,3 +36,3 @@ 'use strict';

if (typeof value === 'object' && key !== 'enum') {
if (typeof value === 'object' && !(key === 'enum' || key === 'required')) {
expand(value, obj.id || parent);

@@ -39,0 +39,0 @@ }

{
"name": "deref",
"version": "0.1.1",
"version": "0.1.2",
"description": "JSON-Schema $ref resolution",

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

@@ -37,3 +37,3 @@ Do you have $ref's ?

The resulting function of calling `deref()` can accept three arguments:
The resulting function of calling `deref()` can accept four arguments:

@@ -59,2 +59,15 @@ - **fakeroot** (string)

- **ex** (boolean)
Whether do full dereferencing or not, `false` by default.
Examples
--------
```javascript
$('http://example.com', schema, true);
$(schema, refs, true);
$(schema, true);
```
Utilities

@@ -61,0 +74,0 @@ ---------

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