Skip to content

Commit

Permalink
fixes #10: update sample code in README
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Sep 18, 2024
1 parent 69e14d2 commit 7a54312
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ It can be useful to consume a stream by more than one value at a time. For examp
A common solution for this is a `chunks` method that works like the following:

```js
let digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].values();
let digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];

let chunksOf2 = Array.from(digits.chunks(2));
let chunksOf2 = Array.from(digits.values().chunks(2));
// [ [0, 1], [2, 3], [4, 5], [6, 7], [8, 9] ]

let chunksOf3 = Array.from(digits.chunks(3));
let chunksOf3 = Array.from(digits.values().chunks(3));
// [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [9] ]

let chunksOf4 = Array.from(digits.chunks(4));
let chunksOf4 = Array.from(digits.values().chunks(4));
// [ [0, 1, 2, 3], [4, 5, 6, 7], [8, 9] ]
```

Expand Down

0 comments on commit 7a54312

Please sign in to comment.