1 | Repeats an array given times.
|
2 | [:package:](https://www.npmjs.com/package/@extra-array/repeat)
|
3 | [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array)
|
4 | [:running:](https://npm.runkit.com/@extra-array/repeat)
|
5 | [:vhs:](https://asciinema.org/a/332116)
|
6 | [:moon:](https://www.npmjs.com/package/@extra-array/repeat.min)
|
7 | [:scroll:](https://unpkg.com/@extra-array/repeat/)
|
8 | [:newspaper:](https://nodef.github.io/extra-array/)
|
9 | [:blue_book:](https://github.com/nodef/extra-array/wiki/)
|
10 |
|
11 | > Similar: [repeat], [cycle], [rotate], [reverse].
|
12 |
|
13 | > This is part of package [extra-array].
|
14 |
|
15 | [extra-array]: https://www.npmjs.com/package/extra-array
|
16 |
|
17 | <br>
|
18 |
|
19 | ```javascript
|
20 | array.repeat(x, [n]);
|
21 | // x: an array
|
22 | // n: times (1)
|
23 | ```
|
24 |
|
25 | ```javascript
|
26 | const array = require("extra-array");
|
27 |
|
28 | var x = [1, 2];
|
29 | array.repeat(x, 2);
|
30 | // [ 1, 2, 1, 2 ]
|
31 |
|
32 | array.repeat(x, 3);
|
33 | // [ 1, 2, 1, 2, 1, 2 ]
|
34 | ```
|
35 |
|
36 | <br>
|
37 | <br>
|
38 |
|
39 |
|
40 | ## References
|
41 |
|
42 | - [String.prototype.repeat: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)
|
43 | - [Collections.nCopies: Java](https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#nCopies(int,%20T))
|
44 |
|
45 | [repeat]: https://github.com/nodef/extra-array/wiki/repeat
|
46 | [cycle]: https://github.com/nodef/extra-array/wiki/cycle
|
47 | [rotate]: https://github.com/nodef/extra-array/wiki/rotate
|
48 | [reverse]: https://github.com/nodef/extra-array/wiki/reverse
|