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

make-array

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-array

Creates a real Array from almost anything.

1.0.5
latest
Source
npm
Version published
Weekly downloads
220K
16.52%
Maintainers
1
Weekly downloads
 
Created

What is make-array?

The make-array package is a utility that helps in converting different types of values into arrays. It is particularly useful when you want to ensure that a value is always treated as an array, regardless of its original type.

What are make-array's main functionalities?

Convert single value to array

This feature allows you to convert a single non-array value into an array containing that value. It ensures that the input is always returned as an array.

const makeArray = require('make-array');
const singleValue = 'hello';
const array = makeArray(singleValue); // ['hello']

Convert array-like objects to array

This feature converts array-like objects (such as arguments objects or objects with a length property) into proper arrays.

const makeArray = require('make-array');
const arrayLike = {0: 'a', 1: 'b', length: 2};
const array = makeArray(arrayLike); // ['a', 'b']

Handle null or undefined

This feature ensures that null or undefined values are converted into empty arrays, providing a consistent array output.

const makeArray = require('make-array');
const result = makeArray(null); // []
const result2 = makeArray(undefined); // []

Other packages similar to make-array

Keywords

make-array

FAQs

Package last updated on 02 Aug 2018

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