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

@hyperjump/json-reference

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperjump/json-reference - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

dist/json-reference.js

@@ -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 @@

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