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

Comparing version 1.0.3 to 1.0.5

43

index.js

@@ -6,3 +6,3 @@ // @param {all} subject

// @param {Array=} host
export default function makeArray (subject, host){
module.exports = function (subject, host) {
// false -> [false]

@@ -12,28 +12,33 @@ // null -> []

if (subject === undefined || subject === null) {
return host || [];
return host || []
}
// if is already an array
if(Object.prototype.toString.call(subject) === '[object Array]'){
if (isArray(subject)) {
return host
? host.concat(subject)
: subject;
: subject
}
host || (host = []);
host || (host = [])
if (isArrayLikeObject(subject)) {
// IE fails on collections and <select>.options (refers to <select>)
// use subject clone instead of Array.prototype.slice
clonePureArray(subject, host);
clonePureArray(subject, host)
} else {
host.push(subject);
host.push(subject)
}
return host;
};
return host
}
var toString = Object.prototype.toString
function isArray (subject) {
return toString.call(subject) === '[object Array]'
}
// altered from jQuery
function isArrayLikeObject (subject) {
var length = subject.length;
var length = subject.length

@@ -47,7 +52,7 @@ if (

) {
return false;
return false
}
return length === 0
|| length > 0 && (length - 1) in subject;
|| length > 0 && (length - 1) in subject
}

@@ -60,11 +65,11 @@

*/
function clonePureArray(subject, host){
var i = subject.length;
var start = host.length;
function clonePureArray (subject, host) {
var i = subject.length
var start = host.length
while(i --){
host[start + i] = subject[i];
while (i --) {
host[start + i] = subject[i]
}
return host;
};
return host
}
{
"name": "make-array",
"version": "1.0.3",
"version": "1.0.5",
"description": "Creates a real Array from almost anything.",
"main": "make-array.js",
"module": "index.js",
"main": "index.js",
"scripts": {
"build": "babel index.js -o make-array.js",
"test": "npm run build && sh test.sh"
"test": "sh test.sh"
},
"files": [
"index.js",
"make-array.js"
"index.js"
],

@@ -36,4 +33,2 @@ "repository": {

"devDependencies": {
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"chai": "*",

@@ -40,0 +35,0 @@ "mocha": "*"

[![NPM version](https://badge.fury.io/js/make-array.svg)](http://badge.fury.io/js/make-array)
[![Build Status](https://travis-ci.org/kaelzhang/make-array.svg?branch=master)](https://travis-ci.org/kaelzhang/make-array)
[![Dependency Status](https://gemnasium.com/kaelzhang/make-array.svg)](https://gemnasium.com/kaelzhang/make-array)

@@ -12,3 +11,3 @@ # make-array

```bash
$ npm install make-array --save
$ npm i make-array --save
```

@@ -63,2 +62,2 @@

MIT
<!-- do not want to make nodeinit to complicated, you can edit this whenever you want. -->
<!-- do not want to make nodeinit to complicated, you can edit this whenever you want. -->
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