Comparing version 1.0.0 to 1.1.0
@@ -1,19 +0,21 @@ | ||
;(function () { | ||
var isArray = Array.isArray || function (value) { | ||
return Object.prototype.toString.call(value) === '[object Array]' | ||
} | ||
(function () { | ||
var isArray = | ||
Array.isArray || | ||
function (value) { | ||
return Object.prototype.toString.call(value) === "[object Array]"; | ||
}; | ||
function arrayWrap (value) { | ||
function arrayWrap(value) { | ||
if (arguments.length) { | ||
return isArray(value) ? value : [value] | ||
return isArray(value) ? value : [value]; | ||
} else { | ||
return [] | ||
return []; | ||
} | ||
} | ||
if (typeof module !== 'undefined') { | ||
module.exports = arrayWrap | ||
if (typeof module !== "undefined") { | ||
module.exports = arrayWrap; | ||
} else { | ||
this.arrayWrap = arrayWrap | ||
this.arrayWrap = arrayWrap; | ||
} | ||
})() | ||
})(); |
The MIT License (MIT) | ||
Copyright (c) 2014-2016 Evan Hahn | ||
Copyright (c) 2014-2021 Evan Hahn | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "arraywrap", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "if it's not an array, wrap it in an array. if it's already an array, do nothing.", | ||
"main": "arraywrap.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"types": "arraywrap.d.ts", | ||
"files": [ | ||
"LICENSE.txt", | ||
"README.md", | ||
"arraywrap.js" | ||
], | ||
"scripts": { | ||
"pretest": "standard", | ||
"test": "mocha" | ||
"pretest": "npm run lint", | ||
"lint": "npm run lint:eslint && npm run lint:prettier", | ||
"lint:eslint": "eslint \"**/*.js\"", | ||
"lint:prettier": "prettier --check .", | ||
"format": "prettier --write .", | ||
"test": "node test" | ||
}, | ||
@@ -22,3 +29,3 @@ "repository": { | ||
], | ||
"author": "Evan Hahn <me@evanhahn.com> (http://evanhahn.com)", | ||
"author": "Evan Hahn <me@evanhahn.com> (https://evanhahn.com)", | ||
"license": "MIT", | ||
@@ -30,11 +37,5 @@ "bugs": { | ||
"devDependencies": { | ||
"mocha": "^3.1.2", | ||
"standard": "^8.5.0" | ||
}, | ||
"standard": { | ||
"globals": [ | ||
"describe", | ||
"it" | ||
] | ||
"eslint": "^8.2.0", | ||
"prettier": "^2.4.1" | ||
} | ||
} |
@@ -1,6 +0,4 @@ | ||
array wrap dot js | ||
================= | ||
[](https://travis-ci.org/EvanHahn/arraywrap.js) | ||
# array wrap dot js | ||
[](http://badge.fury.io/js/arraywrap) | ||
[](http://standardjs.com/) | ||
@@ -10,7 +8,7 @@ If it's not an array, make it one: | ||
```js | ||
arrayWrap(123) // => [123] | ||
arrayWrap('yo') // => ['yo'] | ||
arrayWrap(null) // => [null] | ||
arrayWrap(undefined) // => [undefined] | ||
arrayWrap() // => [] | ||
arrayWrap(123); // => [123] | ||
arrayWrap("yo"); // => ['yo'] | ||
arrayWrap(null); // => [null] | ||
arrayWrap(undefined); // => [undefined] | ||
arrayWrap(); // => [] | ||
``` | ||
@@ -21,7 +19,7 @@ | ||
```js | ||
arrayWrap([1, 2, 3]) // => [1, 2, 3] | ||
arrayWrap([]) // => [] | ||
arrayWrap([1, 2, 3]); // => [1, 2, 3] | ||
arrayWrap([]); // => [] | ||
var arr = [1, 2] | ||
arrayWrap(arr) === arr // true | ||
var arr = [1, 2]; | ||
arrayWrap(arr) === arr; // true | ||
``` | ||
@@ -32,4 +30,4 @@ | ||
```js | ||
var arrayWrap = require('arraywrap') | ||
arrayWrap(47) | ||
var arrayWrap = require("arraywrap"); | ||
arrayWrap(47); | ||
``` | ||
@@ -41,5 +39,7 @@ | ||
<script src="arraywrap.js"></script> | ||
<script>arrayWrap(47)</script> | ||
<script> | ||
arrayWrap(47); | ||
</script> | ||
``` | ||
This should support environments that don't have `Array.isArray` (like IE8 and below). |
19
3275
4