Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/jsonata.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ var jsonata = (function() {
// count in from end of array
index = input.length + index;
}
var item = input[index];
var item = await input[index];
if(typeof item !== 'undefined') {
if(Array.isArray(item)) {
results = item;
Expand Down
10 changes: 10 additions & 0 deletions test/async-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,13 @@ describe('Handle chained functions that end in promises', function() {
});

});

describe('Array with Promise items', function() {
it('should await each item', async function() {
var data = {
list: [Promise.resolve({name: 'hello'})]
};
var expr = jsonata('list[0].name');
return expect(expr.evaluate(data)).to.eventually.equal('hello');
});
});