|Sven Slootweg 320f842e94||5 years ago|
|src||5 years ago|
|.gitignore||5 years ago|
|.npmignore||5 years ago|
|CHANGELOG.md||5 years ago|
|README.md||5 years ago|
|gulpfile.js||5 years ago|
|index.js||5 years ago|
|package.json||5 years ago|
Wraps a value in an array if it isn't already one. Returns an empty array for
A typical usecase for this: when you have an option that accepts multiple values as an array, but you want to make the use of an array literal optional when there's only a single value to specify.
Maintaining open-source projects takes a lot of time, and the more donations I receive, the more time I can dedicate to open-source. If this module is useful to you, consider making a donation!
You can donate using Bitcoin, PayPal, Flattr, cash-in-mail, SEPA transfers, and pretty much anything else. Thank you!
Pull requests welcome. Please make sure your modifications are in line with the overall code style, and ensure that you're editing the files in
src/, not those in
Build tool of choice is
gulp; simply run
gulp while developing, and it will watch for changes.
Be aware that by making a pull request, you agree to release your modifications under the licenses stated above.
var assureArray = require("assure-array"); assureArray("hello world"); // ["hello world!"] assureArray(["hello", "world"]); // ["hello", "world"] assureArray(null); //  assureArray([true]); // [true]
Ensures that the provided
value is returned as an array.
valueis an array already, this returns the array unchanged.
undefined, this returns an empty array.
valueis any other kind of value, this returns a new array containing just that one value.