Skip to content

Commit 74332fa

Browse files
dmitrizagidulindavidlehn
authored andcommitted
Add missing await to createNodeMap() and merge().
1 parent 86e7678 commit 74332fa

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/jsonld.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ jsonld.createNodeMap = util.callbackify(async function(input, options) {
705705
});
706706

707707
// expand input
708-
const expanded = jsonld.expand(input, options);
708+
const expanded = await jsonld.expand(input, options);
709709

710710
return _createMergedNodeMap(expanded, options);
711711
});
@@ -812,7 +812,7 @@ jsonld.merge = util.callbackify(async function(docs, ctx, options) {
812812
// compact result (force @graph option to true, skip expansion)
813813
options.graph = true;
814814
options.skipExpansion = true;
815-
const compacted = jsonld.compact(flattened, ctx, options);
815+
const compacted = await jsonld.compact(flattened, ctx, options);
816816

817817
return compacted;
818818
});

tests/misc.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ describe('merge tests', () => {
3838
});
3939
});
4040

41+
describe('createNodeMap', () => {
42+
const doc = {'@id': 'ex:1', 'a:property': [{'@id': 'ex:2'}]};
43+
it('should create a flattened node hashmap', async () => {
44+
const expected = {
45+
"ex:1": {
46+
"@id": "ex:1",
47+
"a:property": [ {"@id": "ex:2"} ]
48+
},
49+
"ex:2": {"@id": "ex:2"}
50+
};
51+
52+
const map = await jsonld.createNodeMap(doc);
53+
assert.deepEqual(map, expected);
54+
});
55+
});
56+
4157
describe('other toRDF tests', () => {
4258
const emptyRdf = [];
4359

0 commit comments

Comments
 (0)