* 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)
| 17844 | * @return {array} |
| 17845 | */ |
| 17846 | function createArrayFromMixed(obj) { |
| 17847 | if (!hasArrayNature(obj)) { |
| 17848 | return [obj]; |
| 17849 | } else if (Array.isArray(obj)) { |
| 17850 | return obj.slice(); |
| 17851 | } else { |
| 17852 | return toArray(obj); |
| 17853 | } |
| 17854 | } |
| 17855 | |
| 17856 | module.exports = createArrayFromMixed; |
| 17857 | },{"153":153}],134:[function(_dereq_,module,exports){ |
no test coverage detected