Socket
Socket
Sign inDemoInstall

repeat-element

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

repeat-element

Create an array by repeating the given value n times.

    1.1.4latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
13,740,088
increased by6.08%

Weekly downloads

Package description

What is repeat-element?

The repeat-element npm package is a simple utility that allows you to create an array of repeated values. It is useful when you need to generate a list with the same value multiple times without manually writing out each element.

What are repeat-element's main functionalities?

Repeat a single value

This feature allows you to repeat a single value a specified number of times to create an array. The first argument is the value to repeat, and the second argument is the number of times to repeat it.

var repeat = require('repeat-element');
var repeatedArray = repeat('a', 5);
// repeatedArray is ['a', 'a', 'a', 'a', 'a']

Other packages similar to repeat-element

Readme

Source

repeat-element NPM version NPM monthly downloads NPM total downloads Linux Build Status

Create an array by repeating the given value n times.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.

Install

Install with npm:

$ npm install --save repeat-element

Usage

const repeat = require('repeat-element');

repeat('a', 5);
//=> ['a', 'a', 'a', 'a', 'a']

repeat('a', 1);
//=> ['a']

repeat('a', 0);
//=> []

repeat(null, 5)
//» [ null, null, null, null, null ]

repeat({some: 'object'}, 5)
//» [ { some: 'object' },
//    { some: 'object' },
//    { some: 'object' },
//    { some: 'object' },
//    { some: 'object' } ]

repeat(5, 5)
//» [ 5, 5, 5, 5, 5 ]

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running Tests

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:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Contributors

CommitsContributor
17jonschlinkert
3LinusU
1architectcodes

Author

Jon Schlinkert

License

Copyright © 2018, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on August 19, 2018.

Keywords

FAQs

Last updated on 07 Apr 2021

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc