Comparing version 1.1.1 to 2.0.0
@@ -0,3 +1,4 @@ | ||
declare function arrayWrap<T>(): never[]; | ||
declare function arrayWrap<T>(value: T | T[]): T[]; | ||
export = arrayWrap; |
@@ -1,21 +0,12 @@ | ||
(function () { | ||
var isArray = | ||
Array.isArray || | ||
function (value) { | ||
return Object.prototype.toString.call(value) === "[object Array]"; | ||
}; | ||
var isArray = | ||
Array.isArray || | ||
function (value) { | ||
return Object.prototype.toString.call(value) === "[object Array]"; | ||
}; | ||
function arrayWrap(value) { | ||
if (arguments.length) { | ||
return isArray(value) ? value : [value]; | ||
} else { | ||
return []; | ||
} | ||
module.exports = function arrayWrap(value) { | ||
if (arguments.length) { | ||
return isArray(value) ? value : [value]; | ||
} | ||
if (typeof module !== "undefined") { | ||
module.exports = arrayWrap; | ||
} else { | ||
this.arrayWrap = arrayWrap; | ||
} | ||
})(); | ||
return []; | ||
}; |
{ | ||
"name": "arraywrap", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "if it's not an array, wrap it in an array. if it's already an array, do nothing.", | ||
@@ -23,3 +23,3 @@ "main": "arraywrap.js", | ||
"type": "git", | ||
"url": "https://github.com/EvanHahn/arraywrap.js.git" | ||
"url": "https://git.sr.ht/~evanhahn/arraywrap.js" | ||
}, | ||
@@ -34,9 +34,9 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/EvanHahn/arraywrap.js/issues" | ||
"email": "me@evanhahn.com" | ||
}, | ||
"homepage": "https://github.com/EvanHahn/arraywrap.js", | ||
"homepage": "https://git.sr.ht/~evanhahn/arraywrap.js", | ||
"devDependencies": { | ||
"eslint": "^8.2.0", | ||
"prettier": "^2.4.1" | ||
"eslint": "^8.21.0", | ||
"prettier": "^2.7.1" | ||
} | ||
} |
@@ -1,13 +0,13 @@ | ||
# array wrap dot js | ||
# arraywrap.js | ||
[](http://badge.fury.io/js/arraywrap) | ||
If it's not an array, make it one: | ||
```js | ||
arrayWrap(123); // => [123] | ||
arrayWrap("yo"); // => ['yo'] | ||
arrayWrap(null); // => [null] | ||
arrayWrap(undefined); // => [undefined] | ||
arrayWrap(); // => [] | ||
const arraywrap = require("arraywrap"); | ||
arraywrap(123); // => [123] | ||
arraywrap("yo"); // => ['yo'] | ||
arraywrap(null); // => [null] | ||
arraywrap(undefined); // => [undefined] | ||
arraywrap(); // => [] | ||
``` | ||
@@ -18,25 +18,9 @@ | ||
```js | ||
arrayWrap([1, 2, 3]); // => [1, 2, 3] | ||
arrayWrap([]); // => [] | ||
arraywrap([1, 2, 3]); // => [1, 2, 3] | ||
arraywrap([]); // => [] | ||
var arr = [1, 2]; | ||
const arr = [1, 2]; | ||
arrayWrap(arr) === arr; // true | ||
``` | ||
To use it in Node/Browserify/Webpack: | ||
```js | ||
var arrayWrap = require("arraywrap"); | ||
arrayWrap(47); | ||
``` | ||
To use it in the browser: | ||
```html | ||
<script src="arraywrap.js"></script> | ||
<script> | ||
arrayWrap(47); | ||
</script> | ||
``` | ||
This should support environments that don't have `Array.isArray` (like IE8 and below). | ||
This supports environments that don't have `Array.isArray` (like IE8 and below). |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
2943
14
1
26