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 @@ } |
{ | ||
"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 @@ |
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
14993
255
148