Ver código fonte

added ensureArray method

mightyplow 7 anos atrás
pai
commit
548b345371
2 arquivos alterados com 3 adições e 1 exclusões
  1. 2 0
      lib/array.js
  2. 1 1
      package.json

+ 2 - 0
lib/array.js

@@ -3,6 +3,8 @@
 module.exports = {
     toArray: arraylike => [...arraylike],
 
+    ensureArray: val => Array.isArray(val) ? val : [val],
+
     flatten: function flatten (ar) {
         return ar.reduce((acc, item) => {
             if (Array.isArray(item)) {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@mightyplow/jslib",
-  "version": "0.2.5",
+  "version": "0.3.0",
   "description": "js, helpers library",
   "main": "jslib.js",
   "devDependencies": {