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

@hyperjump/browser

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperjump/browser - npm Package Compare versions

Comparing version 0.9.2 to 0.10.0

12

json-reference/index.js

@@ -12,3 +12,3 @@ const JsonPointer = require("@hyperjump/json-pointer");

const docValue = value(jrefDoc);
return isRef(docValue) ? await get(docValue["$ref"], jrefDoc, options) : jrefDoc;
return isRef(docValue) ? await get(docValue["$href"], jrefDoc, options) : jrefDoc;
};

@@ -20,6 +20,6 @@

if (isId(value)) {
const id = uriReference(value["$id"]);
delete value["$id"];
const id = uriReference(value["$embedded"]);
delete value["$embedded"];
embedded[id] = JSON.stringify(value);
return { "$ref": id };
return { "$href": id };
} else {

@@ -77,4 +77,4 @@ return value;

const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null;
const isRef = (value) => isObject(value) && "$ref" in value;
const isId = (value) => isObject(value) && "$id" in value;
const isRef = (value) => isObject(value) && "$href" in value;
const isId = (value) => isObject(value) && "$embedded" in value;
const append = (key, doc) => "#" + encodeURI(JsonPointer.append(key, pointer(doc))).replace(/#/g, "%23");

@@ -81,0 +81,0 @@ const identity = (a) => a;

{
"name": "@hyperjump/browser",
"version": "0.9.2",
"version": "0.10.0",
"description": "A generic hypermedia client for JSON Reference",

@@ -5,0 +5,0 @@ "scripts": {

@@ -57,11 +57,11 @@ Hyperjump Browser

"foo": "bar",
"aaa": { "$ref": "#/foo" },
"ccc": { "$ref": "#/aaa" },
"aaa": { "$href": "#/foo" },
"ccc": { "$href": "#/aaa" },
"ddd": {
"111": 111,
"222": { "$ref": "#/aaa/bbb" }
"222": { "$href": "#/aaa/bbb" }
},
"eee": [333, { "$ref": "#/ddd/111" }],
"eee": [333, { "$href": "#/ddd/111" }],
"fff": {
"$id": "http://json-reference.hyperjump.io/example2",
"$embedded": "http://json-reference.hyperjump.io/example2",
"abc": 123

@@ -123,4 +123,4 @@ }

from the original authors as a starting point and evolve the concept from there.
Therefore, _the `$ref` and `$id` in this implementation IS NOT the same `$ref`
and `$id` used in recent drafts of JSON Schema_.
Therefore, _the `$href` and `$embedded` in this implementation ARE NOT a simple
renaming of `$ref` and `$id` in recent drafts of JSON Schema_.

@@ -164,10 +164,10 @@ Documentation

### $ref
### $href
In a JSON Reference document, the `$ref` property defines a reference to another
document or a different part of the current document. The value of the `$ref`
property is a string that defines a relative or absolute URL as specified by
[RFC-3986](https://tools.ietf.org/html/rfc3986).
In a JSON Reference document, the `$href` property defines a reference to
another document or a different part of the current document. The value of the
`$href` property is a string that defines a relative or absolute URL as
specified by [RFC-3986](https://tools.ietf.org/html/rfc3986).
When the "value" is an object with a `$ref` property, it should follow the
When the "value" is an object with a `$href` property, it should follow the
reference like following a link. In the following example the fragment points

@@ -190,16 +190,16 @@ `/aaa`, which is a reference that points to `/foo`, and thus the "value" is

"foo": "bar",
"aaa": { "$ref": "#/foo" }
"aaa": { "$href": "#/foo" }
}
```
A `$ref` is a document boundary that JSON Pointers should not cross. `$ref`s
A `$href` is a document boundary that JSON Pointers should not cross. `$nref`s
should not be followed in order to resolve the fragment's JSON Pointer.
### $id
### $embedded
In a JSON Reference document, the `$id` property is a string that defines an
absolute URL that identifies a document within the parent document. It's the
inlined version of a `$ref`. This is a little like the HTTP/2 server push
feature. It's sending additional documents with the request because we know the
client is just going to request those documents next.
In a JSON Reference document, the `$embedded` property is a string that defines
an absolute URL that indicates a document embedded within the parent document.
It's the inlined version of a `$href`. This is a little like the HTTP/2 server
push feature. It's sending additional documents with the request because we know
the client is just going to request those documents next.

@@ -221,3 +221,3 @@ In the example below, the "value" of the document is `111`.

"foo": {
"$id": "http://json-reference.hyperjump.io/example2#/aaa",
"$embedded": "http://json-reference.hyperjump.io/example2#/aaa",
"aaa": 111

@@ -228,10 +228,10 @@ }

An `$id` is a document boundary that JSON Pointers should not cross. A JSON
Reference's fragment JSON Pointer should not point to a separate document
inlined with `$id`.
An `$embedded` is a document boundary that JSON Pointers should not cross. A
JSON Reference's fragment JSON Pointer should not point to a separate document
inlined with `$embedded`.
#### Limitations
The problem with inlining `$ref`s with `$id` is that we don't get the HTTP
headers that describe important things like caching. An optional `$headers`
The problem with inlining `$href`s with `$embedded` is that we don't get the
HTTP headers that describe important things like caching. An optional `$headers`
keyword is being considered.
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