🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

filled-array

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filled-array

Returns an array filled with the specified input

2.2.0
latest
Source
npm
Version published
Weekly downloads
142K
84.91%
Maintainers
1
Weekly downloads
 
Created

What is filled-array?

The filled-array npm package is a utility that allows you to create an array filled with a specified value. It is useful for initializing arrays with default values or for creating arrays of a specific length with repeated elements.

What are filled-array's main functionalities?

Create an array filled with a specific value

This feature allows you to create an array of a specified length, filled with a given value. In the code sample, an array of length 5 is created, with each element being the string 'x'.

const filledArray = require('filled-array');
const result = filledArray('x', 5);
console.log(result); // ['x', 'x', 'x', 'x', 'x']

Create an array using a function to generate values

This feature allows you to create an array where each element is generated by a function. The function receives the index of the element as an argument. In the code sample, an array of length 4 is created, with each element being twice its index.

const filledArray = require('filled-array');
const result = filledArray((index) => index * 2, 4);
console.log(result); // [0, 2, 4, 6]

Other packages similar to filled-array

Keywords

array

FAQs

Package last updated on 02 Feb 2022

Did you know?

Socket

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