utiller 1.0.331 → 1.0.332

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3767,6 +3767,28 @@ var Utiller = /*#__PURE__*/function () {
3767
3767
  }).keys().compact() // 過濾掉 null, undefined, '' 等 falsy 值
3768
3768
  .value();
3769
3769
  }
3770
+ }, {
3771
+ key: "generateGenericCombinations",
3772
+ value:
3773
+ /**
3774
+ * const array1 = ['黑色', '綠色', '金色']
3775
+ * const array2 = ['S', 'M', 'L']
3776
+ * const array3 = ['短袖', '長袖']
3777
+ * const result = generateGenericCombinations([array1, array2, array3])
3778
+ * console.log(result)
3779
+ * ['黑色 | S | 短袖', '黑色 | S | 長袖', '黑色 | M | 短袖', '黑色 | M | 長袖', '黑色 | L | 短袖',
3780
+ '綠色 | S | 短袖', '綠色 | S | 長袖', '金色 | L | 長袖' '黑色 | L | 長袖' ]
3781
+ * */
3782
+ function generateGenericCombinations(arrays) {
3783
+ var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : " | ";
3784
+ return arrays.reduce(function (acc, curr) {
3785
+ return _lodash["default"].flatMap(acc, function (a) {
3786
+ return curr.map(function (b) {
3787
+ return (Array.isArray(a) ? a.join(separator) : a) + separator + b;
3788
+ });
3789
+ });
3790
+ }, arrays[0]);
3791
+ }
3770
3792
  }]);
3771
3793
  }();
3772
3794
  var _default = exports["default"] = Utiller;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utiller",
3
- "version": "1.0.331",
3
+ "version": "1.0.332",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "configerer": "^1.0.11",
14
- "utiller": "^1.0.330",
14
+ "utiller": "^1.0.331",
15
15
  "linepayer": "^1.0.4",
16
16
  "databazer": "^1.0.12",
17
17
  "lodash": "^4.17.20",