Skip to content

Commit

Permalink
comment for Array.p.values
Browse files Browse the repository at this point in the history
  • Loading branch information
hax authored Sep 17, 2020
1 parent 120888c commit 1ebbaab
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ To implement double-ended iterator in userland, we could use a generator with th

```js
Array.prototype.values = function *values() {
// only for demo, for real upgrading of Array.prototype.values
// to double-ended iterator, it need to deal with the edge cases
// of mutating the array while iterating
for (let start = 0, end = this.length; start < end;) {
if (function.sent === 'back') yield this[--end]
else yield this[start++]
Expand Down

0 comments on commit 1ebbaab

Please sign in to comment.