You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.8 KiB

4 years ago
  1. # repeat-element [![NPM version](https://img.shields.io/npm/v/repeat-element.svg?style=flat)](https://www.npmjs.com/package/repeat-element) [![NPM monthly downloads](https://img.shields.io/npm/dm/repeat-element.svg?style=flat)](https://npmjs.org/package/repeat-element) [![NPM total downloads](https://img.shields.io/npm/dt/repeat-element.svg?style=flat)](https://npmjs.org/package/repeat-element) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/repeat-element.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/repeat-element)
  2. > Create an array by repeating the given value n times.
  3. Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
  4. ## Install
  5. Install with [npm](https://www.npmjs.com/):
  6. ```sh
  7. $ npm install --save repeat-element
  8. ```
  9. ## Usage
  10. ```js
  11. const repeat = require('repeat-element');
  12. repeat('a', 5);
  13. //=> ['a', 'a', 'a', 'a', 'a']
  14. repeat('a', 1);
  15. //=> ['a']
  16. repeat('a', 0);
  17. //=> []
  18. repeat(null, 5)
  19. //» [ null, null, null, null, null ]
  20. repeat({some: 'object'}, 5)
  21. //» [ { some: 'object' },
  22. // { some: 'object' },
  23. // { some: 'object' },
  24. // { some: 'object' },
  25. // { some: 'object' } ]
  26. repeat(5, 5)
  27. //» [ 5, 5, 5, 5, 5 ]
  28. ```
  29. ## About
  30. <details>
  31. <summary><strong>Contributing</strong></summary>
  32. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  33. </details>
  34. <details>
  35. <summary><strong>Running Tests</strong></summary>
  36. Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
  37. ```sh
  38. $ npm install && npm test
  39. ```
  40. </details>
  41. <details>
  42. <summary><strong>Building docs</strong></summary>
  43. _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
  44. To generate the readme, run the following command:
  45. ```sh
  46. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  47. ```
  48. </details>
  49. ### Contributors
  50. | **Commits** | **Contributor** |
  51. | --- | --- |
  52. | 17 | [jonschlinkert](https://github.com/jonschlinkert) |
  53. | 3 | [LinusU](https://github.com/LinusU) |
  54. | 1 | [architectcodes](https://github.com/architectcodes) |
  55. ### Author
  56. **Jon Schlinkert**
  57. * [GitHub Profile](https://github.com/jonschlinkert)
  58. * [Twitter Profile](https://twitter.com/jonschlinkert)
  59. * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
  60. ### License
  61. Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
  62. Released under the [MIT License](LICENSE).
  63. ***
  64. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 19, 2018._