Skip to content

Commit

Permalink
Fix Result.map when Array contains zero elements (ethers-io#4036, eth…
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo authored and Woodpile37 committed Jan 14, 2024
1 parent 7e0f768 commit ab92aba
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 ab92aba

Please sign in to comment.