utiller 1.0.161 → 1.0.165

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.
@@ -763,9 +763,26 @@ var Utiller = /*#__PURE__*/function () {
763
763
  }, {
764
764
  key: "getFolderPathOfSpecificPath",
765
765
  value: function getFolderPathOfSpecificPath(path) {
766
- var splited = path.split("/");
767
- splited.pop();
768
- return splited.join("/");
766
+ var split = path.split("/");
767
+ split.pop();
768
+ return split.join("/");
769
+ }
770
+ /**
771
+ * 取得folderName
772
+ *
773
+ * console.log(utiller.getFolderNameOfFilePath(`das/asdiasjiosd/jif/d.js`)); // jif
774
+ *
775
+ * */
776
+
777
+ }, {
778
+ key: "getFolderNameOfFilePath",
779
+ value: function getFolderNameOfFilePath(path) {
780
+ if (this.isValidFilePath(path)) {
781
+ var splits = path.split("/");
782
+ return _lodash["default"].nth(splits, -2);
783
+ } else {
784
+ throw new _exceptioner["default"](9999, "64255615 path is not valid '".concat(path, "'"));
785
+ }
769
786
  }
770
787
  /** absolute=> /acc/bbv/{target}/index.js 檢查有沒有在他下面 */
771
788
 
@@ -847,15 +864,28 @@ var Utiller = /*#__PURE__*/function () {
847
864
 
848
865
  }, {
849
866
  key: "getMergedArrayBy",
850
- value: function getMergedArrayBy(array1, array2, predicate) {
867
+ value: function getMergedArrayBy() {
868
+ var array1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
869
+ var array2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
870
+ var predicate = arguments.length > 2 ? arguments[2] : undefined;
871
+
851
872
  /** predicate可以只帶入屬性質 */
852
- predicate = _lodash["default"].isString(predicate) ? function (a, b) {
853
- return _lodash["default"].isEqual(a[predicate], b[predicate]);
854
- } : predicate;
855
- return array1.map(function (itm) {
856
- return _objectSpread(_objectSpread({}, array2.find(function (item) {
857
- return predicate(itm, item) && item;
858
- })), itm);
873
+ if (_lodash["default"].isString(predicate)) {
874
+ var attribute = predicate;
875
+
876
+ predicate = function predicate(item1, item2) {
877
+ return _lodash["default"].isEqual(item1[attribute], item2[attribute]);
878
+ };
879
+ } else {
880
+ predicate = _lodash["default"].isFunction(predicate) ? predicate : function () {
881
+ return true;
882
+ };
883
+ }
884
+
885
+ return array1.map(function (item1) {
886
+ return _objectSpread(_objectSpread({}, _lodash["default"].find(array2, function (item2) {
887
+ return predicate(item1, item2);
888
+ })), item1);
859
889
  });
860
890
  }
861
891
  }, {
@@ -1487,17 +1517,17 @@ var Utiller = /*#__PURE__*/function () {
1487
1517
  }, {
1488
1518
  key: "getMinuteFormatOfDuration",
1489
1519
  value: function getMinuteFormatOfDuration(ds) {
1490
- _moment["default"].duration(ds).asMinutes();
1520
+ return _moment["default"].duration(ds).asMinutes();
1491
1521
  }
1492
1522
  }, {
1493
1523
  key: "getSecondFormatOfDuration",
1494
1524
  value: function getSecondFormatOfDuration(ds) {
1495
- _moment["default"].duration(ds).asSeconds();
1525
+ return _moment["default"].duration(ds).asSeconds();
1496
1526
  }
1497
1527
  }, {
1498
1528
  key: "getDayFormatOfDuration",
1499
1529
  value: function getDayFormatOfDuration(ds) {
1500
- _moment["default"].duration(ds).asDays();
1530
+ return _moment["default"].duration(ds).asDays();
1501
1531
  }
1502
1532
  /** param可以是timeStamp,也可是date,或是string
1503
1533
  * timestamp : 1231231279
@@ -2454,6 +2484,8 @@ var Utiller = /*#__PURE__*/function () {
2454
2484
  return true;
2455
2485
  }
2456
2486
  /**
2487
+ * 做個總和
2488
+ *
2457
2489
  const result = utiller.getArrayOfSummarizeBy([{name:'david',count:5},{name:'nina',count:3},{name:'david',count:3},{name:'joe',count:3},{name:'joe',count:4}]
2458
2490
  ,'name','count');
2459
2491
  console.log(result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utiller",
3
- "version": "1.0.161",
3
+ "version": "1.0.165",
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.160",
14
+ "utiller": "^1.0.164",
15
15
  "linepayer": "^1.0.4",
16
16
  "databazer": "^1.0.11",
17
17
  "lodash": "^4.17.20",