|
Last change
on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
307 bytes
|
| Line | |
|---|
| 1 | export default function pairs(values, pairof = pair) {
|
|---|
| 2 | const pairs = [];
|
|---|
| 3 | let previous;
|
|---|
| 4 | let first = false;
|
|---|
| 5 | for (const value of values) {
|
|---|
| 6 | if (first) pairs.push(pairof(previous, value));
|
|---|
| 7 | previous = value;
|
|---|
| 8 | first = true;
|
|---|
| 9 | }
|
|---|
| 10 | return pairs;
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | export function pair(a, b) {
|
|---|
| 14 | return [a, b];
|
|---|
| 15 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.