Skip to content

Commit 9d539dd

Browse files
committed
Update to latest jsonld.js.
1 parent 23bd098 commit 9d539dd

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

playground/jsonld.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ jsonld.contextLoaders['node'] = function(options) {
939939

940940
/**
941941
* Assigns the default context loader for external @context URLs to a built-in
942-
* default. Supported types currently include: 'jquery'.
942+
* default. Supported types currently include: 'jquery' and 'node'.
943943
*
944944
* To use the jquery context loader, the 'data' parameter must be a reference
945945
* to the main jquery object.
@@ -1182,8 +1182,7 @@ jsonld.removeValue = function(subject, property, value, options) {
11821182
* 1. They are both primitives of the same type and value.
11831183
* 2. They are both @values with the same @value, @type, @language,
11841184
* and @index, OR
1185-
* 3. They are both @lists with the same @list and @index, OR
1186-
* 4. They both have @ids they are the same.
1185+
* 3. They both have @ids they are the same.
11871186
*
11881187
* @param v1 the first value.
11891188
* @param v2 the second value.
@@ -1205,25 +1204,7 @@ jsonld.compareValues = function(v1, v2) {
12051204
return true;
12061205
}
12071206

1208-
// 3. equal @lists
1209-
if(_isList(v1) && _isList(v2)) {
1210-
if(v1['@index'] !== v2['@index']) {
1211-
return false;
1212-
}
1213-
var list1 = v1['@list'];
1214-
var list2 = v2['@list'];
1215-
if(list1.length !== list2.length) {
1216-
return false;
1217-
}
1218-
for(var i = 0; i < list1.length; ++i) {
1219-
if(!jsonld.compareValues(list1[i], list2[i])) {
1220-
return false;
1221-
}
1222-
}
1223-
return true;
1224-
}
1225-
1226-
// 4. equal @ids
1207+
// 3. equal @ids
12271208
if(_isObject(v1) && ('@id' in v1) && _isObject(v2) && ('@id' in v2)) {
12281209
return v1['@id'] === v2['@id'];
12291210
}
@@ -6170,6 +6151,21 @@ if(_nodejs) {
61706151
jsonld.useContextLoader('node');
61716152
}
61726153

6154+
if(_nodejs) {
6155+
jsonld.use = function(extension) {
6156+
switch(extension) {
6157+
case 'request':
6158+
// use node JSON-LD request extension
6159+
jsonld.request = require('./request');
6160+
break;
6161+
default:
6162+
throw new JsonLdError(
6163+
'Unknown extension.',
6164+
'jsonld.UnknownExtension', {extension: extension});
6165+
}
6166+
}
6167+
}
6168+
61736169
// end of jsonld API factory
61746170
return jsonld;
61756171
};

0 commit comments

Comments
 (0)