Socket
Socket
Sign inDemoInstall

make-array

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    make-array

Creates a real Array from almost anything.


Version published
Maintainers
1
Created

Readme

Source

make-array NPM version Build Status Dependency Status

Creates a real Array from almost anything.

Install

$ npm install make-array --save

Usage

var makeArray = require('make-array');
makeArray();              // []
makeArray(undefined);     // []
makeArray(null);          // []
makeArray(1);             // [1]
makeArray([1, 2]);        // [1, 2]
makeArray({
  '0': 1,
  '1': 2,
  length: 2
});                       // [1, 2]

function foo (){
  return makeArray(arguments);
}

foo(1, 2, 3);             // [1, 2, 3]

makeArray(subject, [host])

  • subject mixed things you want to make it an array
  • host Array= if host is specified, the newly-created array will append to the end of the host

Returns Array. If host is specified, it will return the host itself.

var host = [1, 2];
function foo(){
  return arguments;
}

var result = makeArray(foo({}, []), host);
result;           // [1, 2, {}, []];
result === host;  // true

License

MIT

Keywords

FAQs

Last updated on 18 Dec 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