Socket
Socket
Sign inDemoInstall

json-refs

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-refs - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

14

index.js

@@ -76,2 +76,14 @@ /* exported findRefs, isRemotePointer, pathFromPointer, pathToPointer, resolveRefs */

/**
* Returns whether or not the object represents a JSON Reference.
*
* @param {*} [obj] - The object to check
*
* @returns true if the argument is an object and its $ref property is a string and false otherwise
*/
var isJsonReference = module.exports.isJsonReference = function isJsonReference (obj) {
// TODO: Add check that the value is a valid JSON Pointer
return _.isPlainObject(obj) && _.isString(obj.$ref);
};
/**
* Takes an array of path segments and creates a JSON Pointer from it.

@@ -126,3 +138,3 @@ *

if (this.key === '$ref' && _.isString(val)) {
if (this.key === '$ref' && isJsonReference(this.parent.node)) {
acc[pathToPointer(this.path)] = val;

@@ -129,0 +141,0 @@ }

2

package.json
{
"name": "json-refs",
"version": "0.1.2",
"version": "0.1.3",
"description": "Various utilities for JSON References (http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03).",

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

@@ -65,2 +65,22 @@ # json-refs

## `isJsonReference (obj)`
**Arguments**
* `[obj] {*}` - The object to check
**Response**
`true` if the argument is an `object` and its `$ref` property is a JSON Pointer and `false` otherwise.
## `isRemotePointer (ptr)`
**Arguments**
* `ptr {*}` - The JSON Pointer to check
**Response**
`true` if the argument is an is a JSON Pointer to a remote document and `false` otherwise.
## `pathFromPointer (ptr)`

@@ -67,0 +87,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