Skip to content

Commit

Permalink
Simplify array handling of type keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Mar 16, 2020
1 parent 5ba9654 commit ba018c7
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/entryhandler/keyword/EntryHandlerKeywordType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,9 @@ export class EntryHandlerKeywordType extends EntryHandlerKeyword {
const reverse = Util.isPropertyReverse(context, keyOriginal, await util.unaliasKeywordParent(keys, depth));

// Handle multiple values if the value is an array
if (Array.isArray(value)) {
for (const element of value) {
const type = util.createVocabOrBaseTerm(context, element);
if (type) {
await EntryHandlerPredicate.handlePredicateObject(parsingContext, util, keys, depth,
predicate, type, reverse);
}
}
} else {
const type = util.createVocabOrBaseTerm(context, value);
const elements = Array.isArray(value) ? value : [ value ];
for (const element of elements) {
const type = util.createVocabOrBaseTerm(context, element);
if (type) {
await EntryHandlerPredicate.handlePredicateObject(parsingContext, util, keys, depth,
predicate, type, reverse);
Expand Down

0 comments on commit ba018c7

Please sign in to comment.