Skip to content

Commit bf9ff8a

Browse files
committed
Use Set instead of Array for validContainers. (reverted from commit 04f939f)
1 parent 97b8050 commit bf9ff8a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/context.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,14 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => {
382382
if('@container' in value) {
383383
// normalize container to an array form
384384
const container = _isString(value['@container']) ? [value['@container']] : (value['@container'] || []);
385-
const validContainers = new Set(['@list', '@set', '@index', '@language']);
385+
const validContainers = ['@list', '@set', '@index', '@language'];
386386
let isValid = true;
387387
let hasSet = container.includes('@set');
388388

389389
// JSON-LD 1.1 support
390390
if(activeCtx.processingMode && activeCtx.processingMode.indexOf('json-ld-1.1') === 0) {
391391
// TODO: @id and @type
392-
validContainers.add('@graph');
392+
validContainers.push('@graph');
393393

394394
// check container length
395395
isValid &= container.length <= (hasSet ? 2 : 1);
@@ -402,15 +402,15 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => {
402402
}
403403

404404
// check against valid containers
405-
isValid &= container.every(c => validContainers.has(c));
405+
isValid &= container.every(c => validContainers.includes(c));
406406

407407
// @set not allowed with @list
408408
isValid &= !(hasSet && container.includes('@list'));
409409

410410
if(!isValid) {
411411
throw new JsonLdError(
412412
'Invalid JSON-LD syntax; @context @container value must be ' +
413-
'one of the following: ' + Array.from(validContainers).join(', '),
413+
'one of the following: ' + validContainers.join(', '),
414414
'jsonld.SyntaxError',
415415
{code: 'invalid container mapping', context: localCtx});
416416
}

0 commit comments

Comments
 (0)