Skip to content

Commit

Permalink
Fix Result.map when Array contains zero elements (#4036, #4048).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed May 15, 2023
1 parent 6db7458 commit 2e5935b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src.ts/abi/coders/abstract-coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,23 @@ export class Result extends Array<any> {
return new Result(_guard, result, names);
}

/**
* @_ignore
*/
map<T extends any = any>(callback: (el: any, index: number, array: Result) => T, thisArg?: any): Array<T> {
const result: Array<T> = [ ];
for (let i = 0; i < this.length; i++) {
const item = this[i];
if (item instanceof Error) {
throwError(`index ${ i }`, item);
}

result.push(callback.call(thisArg, item, i, this));
}

return result;
}


/**
* Returns the value for %%name%%.
Expand Down

0 comments on commit 2e5935b

Please sign in to comment.