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.
- package/lib/utiller/index.js +46 -14
- package/package.json +1 -1
- package/template/sample.package.json +1 -1
package/lib/utiller/index.js
CHANGED
|
@@ -763,9 +763,26 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
763
763
|
}, {
|
|
764
764
|
key: "getFolderPathOfSpecificPath",
|
|
765
765
|
value: function getFolderPathOfSpecificPath(path) {
|
|
766
|
-
var
|
|
767
|
-
|
|
768
|
-
return
|
|
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(
|
|
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
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
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