Socket
Socket
Sign inDemoInstall

repeat-element

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    repeat-element

Create an array by repeating the given value n times.


Version published
Weekly downloads
11M
decreased by-10.85%
Maintainers
1
Install size
4.42 kB
Created
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

Create an array by repeating the given value n times.

Install

Install with npm

npm i repeat-element --save

Usage

var 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 ]

repeat-string: Repeat the given string n times. Fastest implementation for repeating a string.

Running tests

Install dev dependencies:

npm i -d && npm test

Contributing

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

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on May 06, 2015.

Keywords

FAQs

Last updated on 07 May 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your 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