Skip to content

Commit

Permalink
Tweak retro<T>() for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Aug 13, 2022
1 parent 2219592 commit 0b3f023
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/algorithm/src/retro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export function retro<T>(
if (typeof (object as any).retro === 'function') {
return (object as IRetroable<T>).retro();
}
return (function* () {
for (let index = (object as ArrayLike<T>).length - 1; ~index; index--) {
yield (object as ArrayLike<T>)[index];
return (function* (object) {
for (let index = object.length - 1; ~index; index--) {
yield object[index];
}
})();
})(object as ArrayLike<T>);
}

0 comments on commit 0b3f023

Please sign in to comment.