@hyperjump/json-reference
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -34,3 +34,3 @@ "use strict"; | ||
var nil = exports.nil = construct("", ""); | ||
var nil = exports.nil = construct("", undefined); | ||
@@ -37,0 +37,0 @@ var value = exports.value = function value(doc) { |
{ | ||
"name": "@hyperjump/json-reference", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "An implementation of JSON Reference", | ||
@@ -5,0 +5,0 @@ "main": "./dist/json-reference.js", |
@@ -34,5 +34,8 @@ JSON Reference | ||
}, | ||
"ccc": { | ||
"$ref": "#/aaa" | ||
} | ||
"ccc": { "$ref": "#/aaa" }, | ||
"ddd": { | ||
"111": 111, | ||
"222": { "$ref": "#/aaa/bbb" } | ||
}, | ||
"eee": ["a", { "$ref": "#/ddd/111" }] | ||
} | ||
@@ -42,9 +45,29 @@ ``` | ||
```javascript | ||
import * as JsonReference from "@hyperjump/json-reference"; | ||
import * as JRef from "@hyperjump/json-reference"; | ||
const doc = JsonReference.get("http://json-reference.hyperjump.com/example1"); | ||
(async () => { | ||
// Get a document by absolute URL | ||
const doc = await JRef.get("http://json-reference.hyperjump.com/example1"); | ||
const aaa = JsonReference.get("/aaa", doc); | ||
JsonReference.value(aaa); // => "bar" | ||
JsonReference.pointer(aaa); // => "/aaa" | ||
// Get a document with a relative URL using another document as the context | ||
const aaa = await JRef.get("/aaa", doc); | ||
// Get the value of a document | ||
JRef.value(aaa); // => "bar" | ||
// Get the JSON Pointer for the document | ||
JRef.pointer(aaa); // => "/aaa" | ||
// Map over a document whose value is an array | ||
const eee = JRef.get("#/eee"); | ||
const getType = (item) => typeof JRef.value(item); | ||
const types = await JRef.map(getType, eee); // => ["string", "number"]; | ||
// Get the key/value pairs of a document whose value is an object | ||
const ddd = JRef.get("#/ddd"); | ||
await JRef.entries(ddd); // => [ | ||
// ["111", await JRef.get("#/ddd/111", doc)], | ||
// ["222", await JRef.get("#/ddd/222", doc)] | ||
// ] | ||
}()); | ||
``` | ||
@@ -51,0 +74,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
10993
164