Socket
Socket
Sign inDemoInstall

ensure-array

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ensure-array - npm Package Compare versions

Comparing version 0.0.5 to 1.0.0

.travis.yml

36

ensure-array.js

@@ -1,30 +0,8 @@

(function (root, factory) {
/*global define:true */
if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else {
// Browser globals
root.ensureArray = factory();
}
}(this, function () {
'use strict';
function ensureArray(a, b, n) {
if (arguments.length === 0) return []; //no args, ret []
if (arguments.length === 1) { //single argument
if (a === undefined || a === null) return []; // undefined or null, ret []
if (Array.isArray(a)) return a; // isArray, return it
}
return Array.prototype.slice.call(arguments); //return array with copy of all arguments
module.exports = function ensureArray(a, b, n) {
if (arguments.length === 0) return []; // no args, ret []
if (arguments.length === 1) { // single argument
if (a === undefined || a === null) return []; // undefined or null, ret []
if (Array.isArray(a)) return a; // isArray, return it
}
return ensureArray;
}));
return Array.prototype.slice.call(arguments); // return array with copy of all arguments
}

@@ -5,17 +5,19 @@ {

"description": "Ensure that an object is an array. Moves error checking out of your code.",
"version": "0.0.5",
"repository": { "type": "git", "url": "http://github.com/jeffbski/ensure-array.git" },
"bugs" : { "url": "http://github.com/jeffbski/ensure-array/issues" },
"version": "1.0.0",
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/jeffbski/ensure-array.git"
},
"bugs": {
"url": "http://github.com/jeffbski/ensure-array/issues"
},
"main": "ensure-array.js",
"engines": {
"node": "*"
},
"dependencies": {},
"devDependencies": {
"mocha": "~0.14.1",
"chai": "~0.5.2"
"mocha": "~4.0.0",
"chai": "~4.1.0"
},
"scripts": {
"test": "./node_modules/mocha/bin/mocha ./test/*.mocha.js"
"test": "./node_modules/mocha/bin/mocha ./test/*.mocha.js --reporter spec --ui qunit"
}
}
# ensure-array
Simple convenience function which ensures that you are dealing with an array and you can
Simple convenience function which ensures that you are dealing with an array and you can
eliminate noise from your code.
[![Build Status](https://secure.travis-ci.org/jeffbski/ensure-array.png?branch=master)](http://travis-ci.org/jeffbski/ensure-array)
For Example:

@@ -10,3 +12,3 @@

var array = require('ensure-array');
function foo(bar) {

@@ -34,3 +36,3 @@ array(bar).forEach(function (x) {

It gets rid of the noise and coerces what is provided into an array, so you do not have to
It gets rid of the noise and coerces what is provided into an array, so you do not have to
litter your code with a bunch of extraneous checks.

@@ -44,3 +46,3 @@

4. otherwise return array containing all of the arguments
Here is the actual code which makes it happen

@@ -76,6 +78,7 @@

- 2017-11-02 - 1.0.0 - Modernized by @Zertz
- 2011-12-08 - 0.0.4 - Update tapr / tap versions
- 2011-12-01 - 0.0.3 - Updated to support any version of Node.js
## License

@@ -88,2 +91,3 @@

- Author: Jeff Barczewski (@jeffbski)
- Modernized on 2017-11-02 by Pier-Luc Gendreau (@Zertz)

@@ -95,3 +99,1 @@ ## Contributing

- You may contact me at @jeffbski or through github at http://github.com/jeffbski
'use strict';
/*global ensureArray:true */
if (typeof(chai) === 'undefined') {
var chai = require('chai');
}
var chai = require('chai');
var ensureArray = require('../ensure-array.js');
if (typeof(react) === 'undefined') {
var react = require('../'); //require('react');
}
if (typeof(ensureArray) === 'undefined') {
var ensureArray = require('../ensure-array.js');
}
(function () {

@@ -17,0 +7,0 @@

Sorry, the diff of this file is not supported yet

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