Skip to content

Commit 6aa92e1

Browse files
gkelloggdavidlehn
authored andcommitted
Use the &= style, instead of single-line if, as it is more concise.
1 parent 6e10d86 commit 6aa92e1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/context.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ api.process = ({activeCtx, localCtx, options}) => {
108108
}
109109

110110
// If not set explicitly, set processingMode to "json-ld-1.0"
111-
rval.processingMode = rval.processingMode || activeCtx.processingMode || 'json-ld-1.0';
111+
rval.processingMode |= activeCtx.processingMode || 'json-ld-1.0';
112112

113113
// handle @base
114114
if('@base' in ctx) {
@@ -391,20 +391,20 @@ api.createTermDefinition = (activeCtx, localCtx, term, defined) => {
391391
validContainers.push('@graph');
392392

393393
// check container length
394-
if(container.length > (hasSet ? 2 : 1)) isValid = false;
394+
isValid &= container.length <= (hasSet ? 2 : 1);
395395
} else {
396396
// container must be a string which is one of the validContainers
397-
if(_isArray(value['@container'])) isValid = false;
397+
isValid &= !_isArray(value['@container']);
398398

399399
// check container length
400-
if(container.length > 1) isValid = false;
400+
isValid &= container.length <= 1;
401401
}
402402

403403
// Check against valid containers
404-
if(!container.every(c => validContainers.includes(c))) isValid = false;
404+
isValid &= container.every(c => validContainers.includes(c));
405405

406406
// @set not allowed with @list
407-
if(hasSet && container.includes('@list')) isValid = false;
407+
isValid &= !(hasSet && container.includes('@list'));
408408

409409
if(!isValid) {
410410
throw new JsonLdError(

0 commit comments

Comments
 (0)