Socket
Socket
Sign inDemoInstall

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 - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

34

index.js

@@ -26,16 +26,9 @@ 'use strict';

host || (host = []);
if (
subject.length == null
|| Object(subject) !== subject
// `window` also has 'length' property
|| 'setInterval' in subject
) {
host.push(subject);
} else {
if (isArrayLikeObject(subject)) {
// IE fails on collections and <select>.options (refers to <select>)
// use subject clone instead of Array.prototype.slice
clonePureArray(subject, host);
} else {
host.push(subject);
}

@@ -47,2 +40,21 @@

// altered from jQuery
function isArrayLikeObject (subject) {
var length = subject.length;
if (
typeof subject === 'function'
|| Object(subject) !== subject
|| typeof length !== 'number'
// `window` already has a property `length`
|| 'setInterval' in subject
) {
return false;
}
return length === 0
|| length > 0 && (length - 1) in subject;
}
/**

@@ -49,0 +61,0 @@ * clone an object as a pure subject, and ignore non-number properties

{
"name": "make-array",
"version": "0.1.1",
"version": "0.1.2",
"description": "Creates a real Array from almost anything.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,2 +6,7 @@ 'use strict';

var regex = /abc/;
var func = function(){};
var long_func = function(a, b, c, d, e, f){};
var date = new Date;
var obj = {};

@@ -15,2 +20,9 @@ var cases = [

['string', '1', ['1']],
['regex', regex, [regex]],
['function', func, [func]],
['function with many arguments', long_func, [long_func]],
['boolean', true, [true]],
['false', false, [false]],
['date', date, [date]],
['object', obj, [obj]],
['arguments 1, 2, 3', getArguments(1, 2, 3), [1, 2, 3]],

@@ -17,0 +29,0 @@ ['array-like object', {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc