Socket
Socket
Sign inDemoInstall

jsonld-document-loader

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonld-document-loader - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

26

lib/JsonLdDocumentLoader.js

@@ -16,5 +16,4 @@ /*!

*
* @param {string} url - The URL of a document,
* etc.
* @param {object} document -The document.
* @param {string} url - The URL of a document.
* @param {object} document - The document.
*/

@@ -32,2 +31,21 @@ addStatic(url, document) {

/**
* Adds many URL to document mappings to the loader.
*
* The documents will be cloned.
*
* @param {object} options - The options to use.
* @param {object} options.documents - An object that implements the iterable
* protocol returning [url, document] pairs.
*/
addDocuments({documents} = {}) {
if(documents === null || documents === undefined ||
typeof documents[Symbol.iterator] !== 'function') {
throw new TypeError('"documents" must be iterable.');
}
for(const [url, document] of documents) {
this.addStatic(url, document);
}
}
/**
* Adds a custom protocol handler to the loader.

@@ -39,3 +57,3 @@ *

*
* @param {object} options -The options to use.
* @param {object} options - The options to use.
* @param {string} options.protocol - Protocol id, such as 'did', 'https',

@@ -42,0 +60,0 @@ * etc.

16

package.json
{
"name": "jsonld-document-loader",
"version": "2.1.0",
"version": "2.2.0",
"description": "A document loader API for jsonld.js.",

@@ -36,10 +36,10 @@ "type": "module",

"@digitalbazaar/did-io": "^2.0.0",
"c8": "^9.1.0",
"chai": "^4.4.1",
"c8": "^10.1.2",
"chai": "^4.5.0",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint-config-digitalbazaar": "^5.2.0",
"eslint-plugin-jsdoc": "^48.2.6",
"eslint-plugin-unicorn": "^53.0.0",
"karma": "^6.4.3",
"eslint-plugin-jsdoc": "^48.10.2",
"eslint-plugin-unicorn": "^55.0.0",
"karma": "^6.4.4",
"karma-chai": "^0.1.0",

@@ -51,4 +51,4 @@ "karma-chrome-launcher": "^3.2.0",

"karma-webpack": "^5.0.1",
"mocha": "^10.4.0",
"webpack": "^5.91.0"
"mocha": "^10.7.0",
"webpack": "^5.93.0"
},

@@ -55,0 +55,0 @@ "engines": {

@@ -56,3 +56,3 @@ # JSON-LD Document Loader _(jsonld-document-loader)_

### `addStatic()`
### `addStatic(url, document)`

@@ -92,2 +92,16 @@ The `addStatic()` method allows developers to load fixed static contexts and

### `addDocuments({documents})`
Uses `addStatic()` to add many documents from an iterable object that returns
values of the form `[url, document]`. Can be used directly with a Map
associating URLs to documents.
```js
import {contexts as credContexts} from '@digitalbazaar/credentials-context';
const jdl = new JsonLdDocumentLoader();
jdl.addDocuments({documents: credContexts});
```
### `setDidResolver()`

@@ -94,0 +108,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