Skip to content

Commit f6c48db

Browse files
committed
Better array detection. Fixes #44
1 parent d4a4bff commit f6c48db

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ function levelgraphJSONLD(db, jsonldOpts) {
337337
}
338338
acc[triple.subject][triple.predicate].push(expanded[triple.object]);
339339
} else {
340-
if (acc[triple.subject][triple.predicate]){
340+
if (Array.isArray(acc[triple.subject][triple.predicate])){
341341
acc[triple.subject][triple.predicate].push(object);
342342
} else {
343343
acc[triple.subject][triple.predicate] = [object];
@@ -346,7 +346,7 @@ function levelgraphJSONLD(db, jsonldOpts) {
346346
cb(err, acc);
347347
});
348348
}
349-
else if (acc[triple.subject][triple.predicate]){
349+
else if (Array.isArray(acc[triple.subject][triple.predicate])){
350350
acc[triple.subject][triple.predicate].push(object);
351351
cb(err, acc);
352352
} else {
@@ -358,7 +358,7 @@ function levelgraphJSONLD(db, jsonldOpts) {
358358
if (expanded !== null && !acc[triple.subject][triple.predicate]) {
359359
acc[triple.subject][triple.predicate] = expanded[triple.object];
360360
} else if (expanded !== null) {
361-
if (!acc[triple.subject][triple.predicate].push) {
361+
if (!Array.isArray(acc[triple.subject][triple.predicate])) {
362362
acc[triple.subject][triple.predicate] = [acc[triple.subject][triple.predicate]];
363363
}
364364
acc[triple.subject][triple.predicate].push(expanded[triple.object]);

0 commit comments

Comments
 (0)