New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonld

Package Overview
Dependencies
Maintainers
4
Versions
215
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonld - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

31

CHANGELOG.md
# jsonld ChangeLog
## 1.2.0 - 2018-12-11
### Notes
- The updated [rdf-canonize][] extracted out native support into
[rdf-canonize-native][] and now has an *optional* dependency on this new
module. If you have build tools available it will still build and use native
support otherwise it will fallback to less performant JS code.
- If you wish to *require* the native `rdf-canonize` bindings, add a dependency
in your code to `rdf-canonize-native` to insure it is installed.
- Some systems such as [Travis CI](https://travis-ci.org) currently only have
ancient compilers installed by default. Users of `rdf-canonize`, and hence
`jsonld.js`, previously required special setup so the `rdf-canonize` native
bindings would be installable. If CI testing is not performance critical you
can now simplify your CI config, let those bindings fail to install, and use
the JS fallback code.
### Changed
- Update `rdf-canonize` dependency to 0.3.
### Added
- Initial support for benchmarking.
- Basic callback interface tests.
### Removed
- Callback version of every test.
- Callback interface tests added to catch callback API errors.
- Avoids duplication of running every test for promises and callbacks.
- Simplifies testing code and makes async/await conversion easier.
## 1.1.0 - 2018-09-05

@@ -355,1 +384,3 @@

[jsonld-request]: https://github.com/digitalbazaar/jsonld-request
[rdf-canonize]: https://github.com/digitalbazaar/rdf-canonize
[rdf-canonize-native]: https://github.com/digitalbazaar/rdf-canonize-native

5

package.json
{
"name": "jsonld",
"version": "1.1.0",
"version": "1.2.0",
"description": "A JSON-LD Processor and API implementation in JavaScript.",

@@ -34,3 +34,3 @@ "homepage": "https://github.com/digitalbazaar/jsonld.js",

"dependencies": {
"rdf-canonize": "^0.2.1",
"rdf-canonize": "^0.3.0",
"request": "^2.83.0",

@@ -46,2 +46,3 @@ "semver": "^5.5.0",

"babel-preset-node6-es6": "^11.2.5",
"benchmark": "^2.1.4",
"browserify": "^15.2.0",

@@ -48,0 +49,0 @@ "chai": "^4.1.2",

99

README.md

@@ -127,4 +127,5 @@ jsonld.js

Example data and context used throughout examples below:
```js
var doc = {
const doc = {
"http://schema.org/name": "Manu Sporny",

@@ -134,3 +135,3 @@ "http://schema.org/url": {"@id": "http://manu.sporny.org/"},

};
var context = {
const context = {
"name": "http://schema.org/name",

@@ -140,5 +141,8 @@ "homepage": {"@id": "http://schema.org/url", "@type": "@id"},

};
```
### [compact](http://json-ld.org/spec/latest/json-ld/#compacted-document-form)
```js
// compact a document according to a particular context
// see: http://json-ld.org/spec/latest/json-ld/#compacted-document-form
jsonld.compact(doc, context, function(err, compacted) {

@@ -159,4 +163,10 @@ console.log(JSON.stringify(compacted, null, 2));

// or using promises
const compacted = await jsonld.compact(doc, context);
```
### [expand](http://json-ld.org/spec/latest/json-ld/#expanded-document-form)
```js
// expand a document, removing its context
// see: http://json-ld.org/spec/latest/json-ld/#expanded-document-form
jsonld.expand(compacted, function(err, expanded) {

@@ -175,4 +185,10 @@ /* Output:

// or using promises
const expanded = await jsonld.expand(doc);
```
### [flatten](http://json-ld.org/spec/latest/json-ld/#flattened-document-form)
```js
// flatten a document
// see: http://json-ld.org/spec/latest/json-ld/#flattened-document-form
jsonld.flatten(doc, (err, flattened) => {

@@ -182,4 +198,10 @@ // all deep-level trees flattened to the top-level

// or using promises
const flattened = await jsonld.flatten(doc);
```
### [frame](http://json-ld.org/spec/latest/json-ld-framing/#introduction)
```js
// frame a document
// see: http://json-ld.org/spec/latest/json-ld-framing/#introduction
jsonld.frame(doc, frame, (err, framed) => {

@@ -189,4 +211,11 @@ // document transformed into a particular tree structure per the given frame

// or using promises
const framed = await jsonld.frame(doc, frame);
```
### <a name="canonize"></a>[canonize](http://json-ld.github.io/normalization/spec/) (normalize)
```js
// canonize (normalize) a document using the RDF Dataset Normalization Algorithm
// (URDNA2015), see: http://json-ld.github.io/normalization/spec/
// (URDNA2015), see:
jsonld.canonize(doc, {

@@ -200,2 +229,9 @@ algorithm: 'URDNA2015',

// or using promises
const canonized = await jsonld.canonize(doc, {format: 'application/n-quads'});
```
### <a name="tordf"></a>toRDF (N-Quads)
```js
// serialize a document to N-Quads (RDF)

@@ -206,2 +242,9 @@ jsonld.toRDF(doc, {format: 'application/n-quads'}, (err, nquads) => {

// or using promises
const rdf = await jsonld.toRDF(doc, {format: 'application/n-quads'});
```
### <a name="fromrdf"></a>fromRDF (N-Quads)
```js
// deserialize N-Quads (RDF) to JSON-LD

@@ -212,2 +255,9 @@ jsonld.fromRDF(nquads, {format: 'application/n-quads'}, (err, doc) => {

// or using promises
const doc = await jsonld.fromRDF(nquads, {format: 'application/n-quads'});
```
### Custom RDF Parser
```js
// register a custom async-callback-based RDF parser

@@ -225,25 +275,2 @@ jsonld.registerRDFParser(contentType, (input, callback) => {

// use the promises API:
// compaction
const compacted = await jsonld.compact(doc, context);
// expansion
const expanded = await jsonld.expand(doc);
// flattening
const flattened = await jsonld.flatten(doc);
// framing
const framed = await jsonld.frame(doc, frame);
// canonicalization (normalization)
const canonized = await jsonld.canonize(doc, {format: 'application/n-quads'});
// serialize to RDF
const rdf = await jsonld.toRDF(doc, {format: 'application/n-quads'});
// deserialize from RDF
const doc = await jsonld.fromRDF(nquads, {format: 'application/n-quads'});
// register a custom promise-based RDF parser

@@ -254,3 +281,7 @@ jsonld.registerRDFParser(contentType, async input => {

});
```
### Custom Document Loader
```js
// how to override the default document loader with a custom one -- for

@@ -378,2 +409,10 @@ // example, one that uses pre-loaded contexts:

Benchmarks
----------
Benchmarks can be created from any manifest that the test system supports.
Use a command line with a test suite and a benchmark flag:
JSONLD_TESTS=/tmp/benchmark-manifest.jsonld JSONLD_BENCHMARK=1 npm test
[Digital Bazaar]: http://digitalbazaar.com/

@@ -380,0 +419,0 @@ [JSON-LD]: http://json-ld.org/

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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