@twin.org/data-json-ld 0.0.1-next.6 → 0.0.1-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.cjs
CHANGED
|
@@ -1594,6 +1594,45 @@ class JsonLdProcessor {
|
|
|
1594
1594
|
}
|
|
1595
1595
|
return combinedContexts;
|
|
1596
1596
|
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Remove all the contexts that match the pattern.
|
|
1599
|
+
* @param context The context to remove the entries from.
|
|
1600
|
+
* @param match The element to try and match.
|
|
1601
|
+
* @returns The updated contexts.
|
|
1602
|
+
*/
|
|
1603
|
+
static removeContexts(context, match) {
|
|
1604
|
+
if (!core.Is.arrayValue(match)) {
|
|
1605
|
+
return context;
|
|
1606
|
+
}
|
|
1607
|
+
let finalContext;
|
|
1608
|
+
if (core.Is.string(context)) {
|
|
1609
|
+
for (const m of match) {
|
|
1610
|
+
if (context === m) {
|
|
1611
|
+
break;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
else if (core.Is.array(context)) {
|
|
1616
|
+
for (const item of context) {
|
|
1617
|
+
const hasMatch = match.some(m => core.ObjectHelper.equal(m, item));
|
|
1618
|
+
if (!hasMatch) {
|
|
1619
|
+
finalContext ??= [];
|
|
1620
|
+
if (core.Is.array(finalContext)) {
|
|
1621
|
+
finalContext.push(item);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
else if (core.Is.object(context)) {
|
|
1627
|
+
const hasMatch = match.some(m => core.ObjectHelper.equal(m, context));
|
|
1628
|
+
if (!hasMatch) {
|
|
1629
|
+
finalContext = context;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
return core.Is.arrayValue(finalContext) && finalContext.length === 1
|
|
1633
|
+
? finalContext[0]
|
|
1634
|
+
: finalContext;
|
|
1635
|
+
}
|
|
1597
1636
|
/**
|
|
1598
1637
|
* Document loader which uses a caching mechanism.
|
|
1599
1638
|
* @param url The document url to load.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1592,6 +1592,45 @@ class JsonLdProcessor {
|
|
|
1592
1592
|
}
|
|
1593
1593
|
return combinedContexts;
|
|
1594
1594
|
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Remove all the contexts that match the pattern.
|
|
1597
|
+
* @param context The context to remove the entries from.
|
|
1598
|
+
* @param match The element to try and match.
|
|
1599
|
+
* @returns The updated contexts.
|
|
1600
|
+
*/
|
|
1601
|
+
static removeContexts(context, match) {
|
|
1602
|
+
if (!Is.arrayValue(match)) {
|
|
1603
|
+
return context;
|
|
1604
|
+
}
|
|
1605
|
+
let finalContext;
|
|
1606
|
+
if (Is.string(context)) {
|
|
1607
|
+
for (const m of match) {
|
|
1608
|
+
if (context === m) {
|
|
1609
|
+
break;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
else if (Is.array(context)) {
|
|
1614
|
+
for (const item of context) {
|
|
1615
|
+
const hasMatch = match.some(m => ObjectHelper.equal(m, item));
|
|
1616
|
+
if (!hasMatch) {
|
|
1617
|
+
finalContext ??= [];
|
|
1618
|
+
if (Is.array(finalContext)) {
|
|
1619
|
+
finalContext.push(item);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
else if (Is.object(context)) {
|
|
1625
|
+
const hasMatch = match.some(m => ObjectHelper.equal(m, context));
|
|
1626
|
+
if (!hasMatch) {
|
|
1627
|
+
finalContext = context;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
return Is.arrayValue(finalContext) && finalContext.length === 1
|
|
1631
|
+
? finalContext[0]
|
|
1632
|
+
: finalContext;
|
|
1633
|
+
}
|
|
1595
1634
|
/**
|
|
1596
1635
|
* Document loader which uses a caching mechanism.
|
|
1597
1636
|
* @param url The document url to load.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RemoteDocument, Url } from "jsonld/jsonld-spec";
|
|
2
|
-
import type { IJsonLdContextDefinitionRoot, IJsonLdDocument, IJsonLdNodeObject } from "../models/IJsonLdDocument";
|
|
2
|
+
import type { IJsonLdContextDefinitionElement, IJsonLdContextDefinitionRoot, IJsonLdDocument, IJsonLdNodeObject } from "../models/IJsonLdDocument";
|
|
3
3
|
/**
|
|
4
4
|
* JSON-LD Processor.
|
|
5
5
|
*/
|
|
@@ -55,4 +55,11 @@ export declare class JsonLdProcessor {
|
|
|
55
55
|
static gatherContexts(element: {
|
|
56
56
|
[id: string]: unknown;
|
|
57
57
|
}, initial?: IJsonLdContextDefinitionRoot): IJsonLdContextDefinitionRoot | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Remove all the contexts that match the pattern.
|
|
60
|
+
* @param context The context to remove the entries from.
|
|
61
|
+
* @param match The element to try and match.
|
|
62
|
+
* @returns The updated contexts.
|
|
63
|
+
*/
|
|
64
|
+
static removeContexts(context: IJsonLdContextDefinitionRoot | undefined, match?: IJsonLdContextDefinitionElement[]): IJsonLdContextDefinitionRoot | undefined;
|
|
58
65
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -173,3 +173,27 @@ The initial context.
|
|
|
173
173
|
`undefined` \| [`IJsonLdContextDefinitionRoot`](../type-aliases/IJsonLdContextDefinitionRoot.md)
|
|
174
174
|
|
|
175
175
|
The combined contexts.
|
|
176
|
+
|
|
177
|
+
***
|
|
178
|
+
|
|
179
|
+
### removeContexts()
|
|
180
|
+
|
|
181
|
+
> `static` **removeContexts**(`context`, `match`?): `undefined` \| [`IJsonLdContextDefinitionRoot`](../type-aliases/IJsonLdContextDefinitionRoot.md)
|
|
182
|
+
|
|
183
|
+
Remove all the contexts that match the pattern.
|
|
184
|
+
|
|
185
|
+
#### Parameters
|
|
186
|
+
|
|
187
|
+
• **context**: `undefined` \| [`IJsonLdContextDefinitionRoot`](../type-aliases/IJsonLdContextDefinitionRoot.md)
|
|
188
|
+
|
|
189
|
+
The context to remove the entries from.
|
|
190
|
+
|
|
191
|
+
• **match?**: [`IJsonLdContextDefinitionElement`](../type-aliases/IJsonLdContextDefinitionElement.md)[]
|
|
192
|
+
|
|
193
|
+
The element to try and match.
|
|
194
|
+
|
|
195
|
+
#### Returns
|
|
196
|
+
|
|
197
|
+
`undefined` \| [`IJsonLdContextDefinitionRoot`](../type-aliases/IJsonLdContextDefinitionRoot.md)
|
|
198
|
+
|
|
199
|
+
The updated contexts.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/data-json-ld",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.7",
|
|
4
4
|
"description": "Models which define the structure of JSON LD",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
|
-
"@twin.org/data-core": "0.0.1-next.
|
|
18
|
+
"@twin.org/data-core": "0.0.1-next.7",
|
|
19
19
|
"@twin.org/entity": "next",
|
|
20
20
|
"@twin.org/nameof": "next",
|
|
21
21
|
"@twin.org/web": "next",
|