New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

array-of

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-of - npm Package Compare versions

Comparing version
1.1.0
to
1.2.0
+62
test/shim.js
require('../shim');
var test = require('tape');
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesTest = functionsHaveNames ? test : test.skip;
if (!Object.prototype.hasOwnProperty.call(Array, 'of')) {
return it('exists', function (t) {
t.same(!!Array.of, true);
});
}
ifFunctionsHaveNamesTest('has the correct name', function (t) {
t.plan(1);
t.same(Array.of.name, 'of');
});
test('has the right arity', function (t) {
t.plan(1);
t.same(Array.of.length, 0);
});
test('is not enumerable', function (t) {
t.plan(1);
var descriptor = Object.getOwnPropertyDescriptor(Array, 'of');
t.same(descriptor.enumerable, false);
});
test('should create correct array from arguments', function (t) {
t.plan(1);
t.true(Array.of(1, null, undefined), [1, null, undefined]);
});
test('should work with other constructors', function (t) {
t.plan(2);
var Foo = function FooBar(length) {
this.args = Array.prototype.slice.call(arguments, 1);
this.length = length;
};
var args = ['a', 'b', 'c'];
var expected = new Foo(args.length);
args.forEach(function (arg, index) {
expected[index] = arg;
});
t.true(Array.of.apply(Foo, args) instanceof Foo);
t.same(Array.of.apply(Foo, args), expected);
});
test('still works without Array.from', function (t) {
t.plan(1);
var originalFrom = Array.from;
Array.from = 42;
t.same(Array.of(1, 2, 3), [1, 2, 3]);
Array.from = originalFrom;
});
+2
-2
language: node_js
node_js:
- "stable"
- "0.12"
- "0.10"
- "0.12"
- "iojs"
notifications:
email: false
+11
-14

@@ -1,19 +0,16 @@

(function(root, arrayOf) {
module.exports = function () {
if (!Array.isArray(this) && typeof this === 'function') {
var Class = this;
var instance = new Class();
var length = arguments.length;
if (typeof module !== 'undefined' && module.exports) {
for (var i = 0; i < length; i++) {
instance[i] = arguments[i];
}
instance.length = length;
module.exports = arrayOf;
} else if (typeof define === 'function' && define.amd) {
define([], function() {
return arrayOf;
});
return instance;
}
})(this, function () {
return Array.prototype.slice.call(arguments);
});
};
{
"name": "array-of",
"version": "1.1.0",
"version": "1.2.0",
"description": "Polyfill for Array.of",

@@ -17,3 +17,4 @@ "main": "index.js",

"keywords": [
"array"
"array",
"polyfill"
],

@@ -20,0 +21,0 @@ "author": {

@@ -7,2 +7,8 @@ # array-of [![Build Status](https://travis-ci.org/1000ch/array-of.svg?branch=master)](https://travis-ci.org/1000ch/array-of)

## Install
```bash
$ npm install --save-dev array-of
```
## Usage

@@ -30,2 +36,2 @@

MIT: http://1000ch.mit-license.org
[MIT](https://1000ch.mit-license.org) © [Shogo Sensui](https://github.com/1000ch)

@@ -1,23 +0,36 @@

var of = require('../');
var of = require('../');
var test = require('tape');
var functionsHaveNames = (function foo() {}).name === 'foo';
var ifFunctionsHaveNamesTest = functionsHaveNames ? test : test.skip;
test('return [1]', function (t) {
test('should create correct array from arguments', function (t) {
t.plan(1);
t.deepEqual(of(1), [1]);
t.same(of(1, null, undefined), [1, null, undefined]);
});
test('return [1, 2, 3]', function (t) {
test('should work with other constructors', function (t) {
t.plan(2);
t.plan(1);
t.deepEqual(of(1, 2, 3), [1, 2, 3]);
var Foo = function FooBar(length) {
this.args = Array.prototype.slice.call(arguments, 1);
this.length = length;
};
var args = ['a', 'b', 'c'];
var expected = new Foo(args.length);
args.forEach(function (arg, index) {
expected[index] = arg;
});
t.true(of.apply(Foo, args) instanceof Foo);
t.same(of.apply(Foo, args), expected);
});
test('return [undefined]', function (t) {
test('still works without Array.from', function (t) {
t.plan(1);
t.deepEqual(of(undefined), [undefined]);
});
var originalFrom = Array.from;
Array.from = 42;
t.same(of(1, 2, 3), [1, 2, 3]);
Array.from = originalFrom;
});