JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 137651
  • Score
    100M100P100Q158538F
  • License MIT

Creates a real Array from almost anything.

Package Exports

  • make-array

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (make-array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NPM version Build Status

make-array

Creates a real Array from almost anything.

Install

$ npm i 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

Changelog

1.0.0: bump version to mark it as stable.

License

MIT