* Ensure that the argument is an array by wrapping it in an array if it is not. * Creates a copy of the argument if it is already an array. * * This is mostly useful idiomatically: * * var createArrayFromMixed = require('createArrayFromMixed'); * * function takesOneOrMoreThings(things) {
(obj)
| 18432 | * @return {array} |
| 18433 | */ |
| 18434 | function createArrayFromMixed(obj) { |
| 18435 | if (!hasArrayNature(obj)) { |
| 18436 | return [obj]; |
| 18437 | } else if (Array.isArray(obj)) { |
| 18438 | return obj.slice(); |
| 18439 | } else { |
| 18440 | return toArray(obj); |
| 18441 | } |
| 18442 | } |
| 18443 | |
| 18444 | module.exports = createArrayFromMixed; |
| 18445 | },{"156":156}],147:[function(_dereq_,module,exports){ |
no test coverage detected
searching dependent graphs…