utiller 1.0.360 → 1.0.364
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/pooller/index.js +12 -12
- package/lib/utiller/index.js +239 -239
- package/lib/utiller/nodeutiller.js +74 -68
- package/package.json +1 -1
- package/template/sample.package.json +4 -4
package/lib/pooller/index.js
CHANGED
|
@@ -24,16 +24,16 @@ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("C
|
|
|
24
24
|
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
25
25
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
Pooller 有以下特點:
|
|
29
|
-
1.task可以設定timeout
|
|
30
|
-
2.queue滿了的可以設定task interval
|
|
31
|
-
3.如果是runByEachTask length, queue裡面沒有task時,可以設定sleeptime, 以及Sleepcounts
|
|
32
|
-
4.task 可以cancelled by hash
|
|
33
|
-
5.runByParams,runByTimes,runInInfinite,runByEachTask
|
|
34
|
-
6.可以設定taskFailHandler, 這樣遇到錯誤就不會停掉poollers
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
27
|
+
*
|
|
28
|
+
Pooller 有以下特點:
|
|
29
|
+
1.task可以設定timeout
|
|
30
|
+
2.queue滿了的可以設定task interval
|
|
31
|
+
3.如果是runByEachTask length, queue裡面沒有task時,可以設定sleeptime, 以及Sleepcounts
|
|
32
|
+
4.task 可以cancelled by hash
|
|
33
|
+
5.runByParams,runByTimes,runInInfinite,runByEachTask
|
|
34
|
+
6.可以設定taskFailHandler, 這樣遇到錯誤就不會停掉poollers
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
37
|
var SPECIFICITY_DEBUG = false;
|
|
38
38
|
var _run = /*#__PURE__*/new WeakMap();
|
|
39
39
|
var InfinitePool = /*#__PURE__*/function () {
|
|
@@ -251,8 +251,8 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
251
251
|
(0, _defineProperty2["default"])(this, "beforeRun", function () {
|
|
252
252
|
_this.isQueuePolling = true;
|
|
253
253
|
/** 有點多餘的設計, 本來是想要當沒有task時, 有個house-keeping的設計, 但發現只要在任務加入時, 觸發runByEachTask即可
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
this.currentSleepCounts = 0;
|
|
255
|
+
*/
|
|
256
256
|
});
|
|
257
257
|
(0, _defineProperty2["default"])(this, "afterRun", function () {
|
|
258
258
|
_this.clearCache();
|
package/lib/utiller/index.js
CHANGED
|
@@ -127,8 +127,8 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
127
127
|
}));
|
|
128
128
|
});
|
|
129
129
|
/** const items = [{ price: 10 }, { price: 120 }, { price: 230 }];
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
console.log(findLowestPrice(items)); // 輸出: 10
|
|
131
|
+
*/
|
|
132
132
|
(0, _defineProperty2["default"])(this, "findLowestValue", function (items) {
|
|
133
133
|
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "price";
|
|
134
134
|
// 提取價格並找出最小值
|
|
@@ -137,8 +137,8 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
137
137
|
return Math.floor(minPrice);
|
|
138
138
|
});
|
|
139
139
|
/** const items = [{ price: 10 }, { price: 120 }, { price: 230 }];
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
console.log(findLowestPrice(items)); // 輸出: 120
|
|
141
|
+
*/
|
|
142
142
|
(0, _defineProperty2["default"])(this, "findHighestValue", function (items) {
|
|
143
143
|
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "price";
|
|
144
144
|
// 提取價格並找出最小值
|
|
@@ -225,14 +225,14 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
225
225
|
return (0, _momentTimezone["default"])(date).valueOf(); // valueOf() returns the timestamp in milliseconds
|
|
226
226
|
});
|
|
227
227
|
/** // 示例函數來測試運行時間
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
228
|
+
async function exampleFunction() {
|
|
229
|
+
return new Promise((resolve) => setTimeout(resolve, 3210)); // 模擬3.21秒延遲
|
|
230
|
+
}
|
|
231
|
+
// 測試 measureExecutionTime 函數
|
|
232
|
+
measureExecutionTime(exampleFunction).then(result => {
|
|
233
|
+
console.log(result); // 輸出:0小時 0分 3.210秒 (合計 3.210 秒)
|
|
234
|
+
});
|
|
235
|
+
*/
|
|
236
236
|
(0, _defineProperty2["default"])(this, "measureExecutionTime", /*#__PURE__*/function () {
|
|
237
237
|
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(fn) {
|
|
238
238
|
var startTime,
|
|
@@ -1369,25 +1369,25 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
1369
1369
|
}
|
|
1370
1370
|
|
|
1371
1371
|
/**
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1372
|
+
* 優化版本:針對基於唯一 Key 的合併
|
|
1373
|
+
* @param {Array} major - 主要陣列
|
|
1374
|
+
* @param {Array} sub - 次要陣列
|
|
1375
|
+
* @param {string} key - 用於匹配的唯一鍵名 (e.g., 'id')
|
|
1376
|
+
* @returns {Array} - 合併後的新陣列
|
|
1377
|
+
*
|
|
1378
|
+
*
|
|
1379
|
+
* util.getMergedArrayBy(
|
|
1380
|
+
[{id: 123, name: 'david'}, {id: 321, name: 'Joe'}],
|
|
1381
|
+
[{id: 321, age: 13}, {id: 123, age: 30}],
|
|
1382
|
+
'id')
|
|
1383
|
+
*
|
|
1384
|
+
* result:
|
|
1385
|
+
[
|
|
1386
|
+
{ id: 123, age: 30, name: 'david' },
|
|
1387
|
+
{ id: 321, age: 13, name: 'Joe' }
|
|
1388
|
+
]
|
|
1389
|
+
*
|
|
1390
|
+
*/
|
|
1391
1391
|
}, {
|
|
1392
1392
|
key: "getMergedArrayBy",
|
|
1393
1393
|
value: function getMergedArrayBy() {
|
|
@@ -1771,66 +1771,66 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
1771
1771
|
}
|
|
1772
1772
|
|
|
1773
1773
|
/**
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1774
|
+
console.log(generate());
|
|
1775
|
+
//output: 'army'
|
|
1776
|
+
console.log(generate(5));
|
|
1777
|
+
//output: ['army', 'beautiful', 'became', 'if', 'actually']
|
|
1778
|
+
console.log(generate({ minLength: 2 }));
|
|
1779
|
+
//output: 'hello'
|
|
1780
|
+
console.log(generate({ maxLength: 6 }));
|
|
1781
|
+
//output: 'blue'
|
|
1782
|
+
console.log(generate({ minLength: 5, maxLength: 5 }));
|
|
1783
|
+
//output : 'world'
|
|
1784
|
+
console.log(generate({ minLength: 11, maxLength: 10000 })); //maxLength limited to the longest possible word
|
|
1785
|
+
//output: 'environment'
|
|
1786
|
+
console.log(generate({ minLength: 10000, maxLength: 5 })); //minLength limited to the maxLength
|
|
1787
|
+
//output: 'short'
|
|
1788
|
+
console.log(generate({ min: 3, max: 10 }));
|
|
1789
|
+
//output: ['became', 'arrow', 'article', 'therefore']
|
|
1790
|
+
console.log(generate({ exactly: 2 }));
|
|
1791
|
+
//output: ['beside', 'between']
|
|
1792
|
+
console.log(generate({ min: 2, max: 3, seed: "my-seed" }));
|
|
1793
|
+
//output: ['plenty', 'pure']
|
|
1794
|
+
// this call will yield exactly the same results as the last since the same `seed` was used and the other inputs are identical
|
|
1795
|
+
console.log(generate({ min: 2, max: 3, seed: "my-seed" }));
|
|
1796
|
+
//output: ['plenty', 'pure']
|
|
1797
|
+
console.log(generate({ exactly: 5, join: " " }));
|
|
1798
|
+
//output: 'army beautiful became if exactly'
|
|
1799
|
+
console.log(generate({ exactly: 5, join: "" }));
|
|
1800
|
+
//output: 'armybeautifulbecameifexactly'
|
|
1801
|
+
console.log(generate({ exactly: 2, minLength: 4 }));
|
|
1802
|
+
//output: ['atom', 'window']
|
|
1803
|
+
console.log(generate({ exactly: 5, maxLength: 4 }));
|
|
1804
|
+
//output: ['army', 'come', 'eye', 'five', 'fur']
|
|
1805
|
+
console.log(generate({ exactly: 2, minLength: 3, maxLength: 3 }));
|
|
1806
|
+
//output: ['you, 'are']
|
|
1807
|
+
console.log(generate({ exactly: 3, minLength: 5, maxLength: 100000 }));
|
|
1808
|
+
//output: ['understanding', 'should', 'yourself']
|
|
1809
|
+
console.log(generate({ exactly: 5, wordsPerString: 2 }));
|
|
1810
|
+
//output: [ 'salt practical', 'also brief', 'country muscle', 'neighborhood beyond', 'grew pig' ]
|
|
1811
|
+
console.log(generate({ exactly: 5, wordsPerString: 2, separator: "-" }));
|
|
1812
|
+
//output: [ 'equator-variety', 'salt-usually', 'importance-becoming', 'stream-several', 'goes-fight' ]
|
|
1813
|
+
console.log(
|
|
1814
|
+
generate({
|
|
1815
|
+
exactly: 5,
|
|
1816
|
+
wordsPerString: 2,
|
|
1817
|
+
formatter: (word) => word.toUpperCase(),
|
|
1818
|
+
})
|
|
1819
|
+
);
|
|
1820
|
+
//output: [ 'HAVING LOAD', 'LOST PINE', 'GAME SLOPE', 'SECRET GIANT', 'INDEED LOCATION' ]
|
|
1821
|
+
console.log(
|
|
1822
|
+
generate({
|
|
1823
|
+
exactly: 5,
|
|
1824
|
+
wordsPerString: 2,
|
|
1825
|
+
formatter: (word, index) => {
|
|
1826
|
+
return index === 0
|
|
1827
|
+
? word.slice(0, 1).toUpperCase().concat(word.slice(1))
|
|
1828
|
+
: word;
|
|
1829
|
+
},
|
|
1830
|
+
})
|
|
1831
|
+
);
|
|
1832
|
+
//output: [ 'Until smoke', 'Year strength', 'Pay knew', 'Fallen must', 'Chief arrow' ]
|
|
1833
|
+
*/
|
|
1834
1834
|
}, {
|
|
1835
1835
|
key: "getSliceArrayOfSpecificIndexes",
|
|
1836
1836
|
value:
|
|
@@ -2107,9 +2107,9 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2107
2107
|
}
|
|
2108
2108
|
|
|
2109
2109
|
/** 獲得 幾天後的timestamp 的概念 {months: 2,days:3} =>
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2110
|
+
* ts => 1643434497341
|
|
2111
|
+
再利用 getCurrentTimeStamp(ts) => 2022-01-29
|
|
2112
|
+
*/
|
|
2113
2113
|
}, {
|
|
2114
2114
|
key: "getTimeStampWithConditions",
|
|
2115
2115
|
value: function getTimeStampWithConditions() {
|
|
@@ -2383,11 +2383,11 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2383
2383
|
}
|
|
2384
2384
|
|
|
2385
2385
|
/**
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2386
|
+
* mutated;
|
|
2387
|
+
const arr = [0,1,2,3,4,5,6,7,8];
|
|
2388
|
+
dropItemsByIndex(arr,1,3);
|
|
2389
|
+
this.appendInfo(arr); [ 0, 4, 5, 6, 7, 8 ]
|
|
2390
|
+
*/
|
|
2391
2391
|
}, {
|
|
2392
2392
|
key: "dropItemsByIndex",
|
|
2393
2393
|
value: function dropItemsByIndex(array, from, end) {
|
|
@@ -2676,14 +2676,14 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2676
2676
|
}
|
|
2677
2677
|
|
|
2678
2678
|
/**
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2679
|
+
* sample:
|
|
2680
|
+
const array = [{aa: '1'},{ aa: '2'}, {aa: '3'}];
|
|
2681
|
+
const object = {aa: '1', bb: '2', cc: '3'};
|
|
2682
|
+
util.exeAll(object,(each) => each + 1)
|
|
2683
|
+
util.exeAll(array,(each) => {each.aa = each.aa + 1});
|
|
2684
|
+
console.log(object); // { aa: '11', bb: '21', cc: '31' }
|
|
2685
|
+
console.log(array); // [ { aa: '11' }, { aa: '21' }, { aa: '31' } ]
|
|
2686
|
+
* 把collection 裏面的物件執行一下,會mutate本身*/
|
|
2687
2687
|
}, {
|
|
2688
2688
|
key: "exeAll",
|
|
2689
2689
|
value: function exeAll(collection) {
|
|
@@ -2752,11 +2752,11 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2752
2752
|
}
|
|
2753
2753
|
|
|
2754
2754
|
/** 找出兩個object,相同的屬性
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2755
|
+
sample:
|
|
2756
|
+
const obj1 = {a:1,b:4,c:3};
|
|
2757
|
+
const obj2 = {b:3};
|
|
2758
|
+
console.log(util.getIntersectionObject(obj1,obj2)) => { b: 4 }
|
|
2759
|
+
*/
|
|
2760
2760
|
}, {
|
|
2761
2761
|
key: "getIntersectionObject",
|
|
2762
2762
|
value: function getIntersectionObject(objOfMajor, objOfMinor) {
|
|
@@ -2766,11 +2766,11 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2766
2766
|
}
|
|
2767
2767
|
|
|
2768
2768
|
/** 找出兩個object,相同的屬性
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2769
|
+
sample:
|
|
2770
|
+
const obj1 = {a:1,b:4,c:3};
|
|
2771
|
+
const obj2 = {b:3};
|
|
2772
|
+
console.log(util.getIntersectionObject(obj1,obj2)) => { a: 1, c: 3 }
|
|
2773
|
+
*/
|
|
2774
2774
|
}, {
|
|
2775
2775
|
key: "getDifferenceObject",
|
|
2776
2776
|
value: function getDifferenceObject(objOfMajor, objOfMinor) {
|
|
@@ -2780,14 +2780,14 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2780
2780
|
}
|
|
2781
2781
|
|
|
2782
2782
|
/**
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2783
|
+
*
|
|
2784
|
+
const obj1 = {b:4,c:2};
|
|
2785
|
+
const obj2 = {b:4,c:3};
|
|
2786
|
+
const obj3 = {a:1,b:4,c:3};
|
|
2787
|
+
console.log(util.isObjectContainAndEqual(obj1,obj3)) false
|
|
2788
|
+
console.log(util.isObjectContainAndEqual(obj1,obj3)) true
|
|
2789
|
+
targetObject 是數量比較小那個
|
|
2790
|
+
*/
|
|
2791
2791
|
}, {
|
|
2792
2792
|
key: "isObjectContainAndEqual",
|
|
2793
2793
|
value: function isObjectContainAndEqual(targetObject, mainObject) {
|
|
@@ -2925,11 +2925,11 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2925
2925
|
}
|
|
2926
2926
|
|
|
2927
2927
|
/**
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2928
|
+
const array = _.range(0, 50).map((each) => `index Of each`);
|
|
2929
|
+
console.log('origin: ==> ', array.length) //origin: ==> 50
|
|
2930
|
+
const result = util.getSliceArrayWithMutate(array, 10);
|
|
2931
|
+
console.log('after: ==> ', result.length, ' | ', array.length) //after: ==> 10 | 40
|
|
2932
|
+
*/
|
|
2933
2933
|
}, {
|
|
2934
2934
|
key: "getSliceArrayWithMutate",
|
|
2935
2935
|
value: function getSliceArrayWithMutate(array, n) {
|
|
@@ -2953,18 +2953,18 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2953
2953
|
}
|
|
2954
2954
|
|
|
2955
2955
|
/**
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2956
|
+
*
|
|
2957
|
+
* 把array裏面的'指定index' 移動到 '特定index'
|
|
2958
|
+
*
|
|
2959
|
+
const array = [0,1,2,3,4,5,6,7];
|
|
2960
|
+
console.log(util.getArrayOfMoveToSpecificIndex(array,1,0));const array = [0,1,2,3,4,5,6,7];
|
|
2961
|
+
console.log(util.getArrayOfMoveToSpecificIndex(array,1,0));
|
|
2962
|
+
[
|
|
2963
|
+
1, 0, 2, 3,
|
|
2964
|
+
4, 5, 6, 7
|
|
2965
|
+
]
|
|
2966
|
+
|-------如果有paginate, 有可能讓功能錯亂-------|
|
|
2967
|
+
*/
|
|
2968
2968
|
}, {
|
|
2969
2969
|
key: "getArrayOfMoveToSpecificIndex",
|
|
2970
2970
|
value: function getArrayOfMoveToSpecificIndex(array, from, to) {
|
|
@@ -2991,11 +2991,11 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
2991
2991
|
}
|
|
2992
2992
|
|
|
2993
2993
|
/** 把array裏面的項目移動到指定的index
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2994
|
+
*
|
|
2995
|
+
* const array = ['a','b','c','d'];
|
|
2996
|
+
console.log(util.getArrayOfMoveItemToSpecificIndex(array,array[1],0));
|
|
2997
|
+
//[ 'b', 'a', 'c', 'd' ]
|
|
2998
|
+
* */
|
|
2999
2999
|
}, {
|
|
3000
3000
|
key: "getArrayOfMoveItemToSpecificIndex",
|
|
3001
3001
|
value: function getArrayOfMoveItemToSpecificIndex(array, item, indexOfDestination) {
|
|
@@ -3018,10 +3018,10 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
3018
3018
|
}
|
|
3019
3019
|
|
|
3020
3020
|
/** 把指定的index放到頭尾
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3021
|
+
* const array = ['a','b','c','d'];
|
|
3022
|
+
console.log(util.getArrayOfMoveSpecificIndexToAside(array,3,false));
|
|
3023
|
+
[ 'd', 'a', 'b', 'c' ]
|
|
3024
|
+
**/
|
|
3025
3025
|
}, {
|
|
3026
3026
|
key: "getArrayOfMoveSpecificIndexToAside",
|
|
3027
3027
|
value: function getArrayOfMoveSpecificIndexToAside(array, index) {
|
|
@@ -3063,15 +3063,15 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
3063
3063
|
}
|
|
3064
3064
|
|
|
3065
3065
|
/** 把一段html文字轉換成類似document的結構 處理後再回傳文字
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3066
|
+
const result = utiller.getStringOfHandleHtml(
|
|
3067
|
+
'<form id="_form_aiochk" action="https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5" method="post"><input type="hidden" name="MerchantTradeNo" id="MerchantTradeNo" value="sO6E2IilSGYpCChDqrI2" /><input type="hidden" name="MerchantTradeDate" id="MerchantTradeDate" value="2022/07/02 05:16:32" />' +
|
|
3068
|
+
'<input type="hidden" name="TotalAmount" id="TotalAmount" value="350" /><input type="hidden" name="TradeDesc" id="TradeDesc" value="綠界第三方支付(明悅科技-線上支付)" /><input type="hidden" name="ItemName" id="ItemName" value="iphone13 pro x 2 = 200 元#iphone11 x 3 = 150 元#總價 350 元##※備註: 無備註內容" /><input type="hidden" name="ReturnURL" id="ReturnURL" value="https://us-central1-davidtu-dev.cloudfunctions.net/confirmedByByECPay" /><input type="hidden" name="ClientBackURL" id="ClientBackURL" value="https://www.google.com/" /><input type="hidden" name="ExpireDate" id="ExpireDate" value="1" /><input type="hidden" name="PaymentInfoURL" id="PaymentInfoURL" value="https://us-central1-davidtu-dev.cloudfunctions.net/paymentInfoByECPay" /><input type="hidden" name="ChoosePayment" id="ChoosePayment" value="ALL" /><input type="hidden" name="PlatformID" id="PlatformID" value="" /><input type="hidden" name="MerchantID" id="MerchantID" value="2000132" /><input type="hidden" name="InvoiceMark" id="InvoiceMark" value="N" /><input type="hidden" name="IgnorePayment" id="IgnorePayment" value="BARCODE#AndroidPay#ApplePay" /><input type="hidden" name="DeviceSource" id="DeviceSource" value="" /><input type="hidden" name="EncryptType" id="EncryptType" value="1" /><input type="hidden" name="PaymentType" id="PaymentType" value="aio" />' +
|
|
3069
|
+
'<input type="hidden" name="CheckMacValue" id="CheckMacValue" value="D55E9E48C6AB83C063E0E13AD1B8C2EE8FA6547A7D7FCB33860B532E97D808BC" /><script type="text/javascript">document.getElementById("_form_aiochk").submit();</script></form>'
|
|
3070
|
+
,(document) => {
|
|
3071
|
+
const element = document.getElementById('CheckMacValue');
|
|
3072
|
+
element.setAttribute('value', '123456');
|
|
3073
|
+
})
|
|
3074
|
+
*/
|
|
3075
3075
|
}, {
|
|
3076
3076
|
key: "getStringOfHandledHtml",
|
|
3077
3077
|
value: function getStringOfHandledHtml(htmlString) {
|
|
@@ -3155,18 +3155,18 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
3155
3155
|
}
|
|
3156
3156
|
|
|
3157
3157
|
/**
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3158
|
+
* 做個總和
|
|
3159
|
+
*
|
|
3160
|
+
const result = utiller.getArrayOfSummarizeBy([{name:'david',count:5},{name:'nina',count:3},{name:'david',count:3},{name:'joe',count:3},{name:'joe',count:4}]
|
|
3161
|
+
,'name','count');
|
|
3162
|
+
console.log(result);
|
|
3163
|
+
[
|
|
3164
|
+
{ name: 'david', count: 8 },
|
|
3165
|
+
{ name: 'nina', count: 3 },
|
|
3166
|
+
{ name: 'joe', count: 7 }
|
|
3167
|
+
]
|
|
3168
|
+
*
|
|
3169
|
+
*/
|
|
3170
3170
|
}, {
|
|
3171
3171
|
key: "getArrayOfSummarizeBy",
|
|
3172
3172
|
value: function getArrayOfSummarizeBy(array, keyOfId, keyOfSum) {
|
|
@@ -3236,14 +3236,14 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
3236
3236
|
}
|
|
3237
3237
|
|
|
3238
3238
|
/**
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3239
|
+
console.log(count());
|
|
3240
|
+
//output: 1952
|
|
3241
|
+
console.log(count({ minLength: 5 }));
|
|
3242
|
+
//output: 1318
|
|
3243
|
+
console.log(count({ maxLength: 7 }));
|
|
3244
|
+
//output: 1649
|
|
3245
|
+
console.log(count({ minLength: 5, maxLength: 7 }));
|
|
3246
|
+
*/
|
|
3247
3247
|
}, {
|
|
3248
3248
|
key: "getRandomCount",
|
|
3249
3249
|
value: function getRandomCount() {
|
|
@@ -3252,10 +3252,10 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
3252
3252
|
}
|
|
3253
3253
|
|
|
3254
3254
|
/**
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3255
|
+
// 使用範例
|
|
3256
|
+
const birthDate = '2005-01-01';
|
|
3257
|
+
console.log(isOver18(birthDate)); // 會返回 true 或 false
|
|
3258
|
+
*/
|
|
3259
3259
|
}, {
|
|
3260
3260
|
key: "isOverSpecificAge",
|
|
3261
3261
|
value: function isOverSpecificAge(birthDate) {
|
|
@@ -3427,11 +3427,11 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
3427
3427
|
}
|
|
3428
3428
|
|
|
3429
3429
|
/** // 測試範例
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3430
|
+
const startTimestamp = 1683004800000; // 2023-05-01 00:00
|
|
3431
|
+
const endTimestamp = 1683040800000; // 2023-05-01 10:00
|
|
3432
|
+
const totalMinutes = getNumberOfPeriodMinute(startTimestamp, endTimestamp);
|
|
3433
|
+
console.log(totalMinutes); // 輸出:600(相當於10個小時,600分鐘)
|
|
3434
|
+
*/
|
|
3435
3435
|
}, {
|
|
3436
3436
|
key: "getNumberOfPeriodMinute",
|
|
3437
3437
|
value: function getNumberOfPeriodMinute(startTimestamp, endTimestamp) {
|
|
@@ -3692,14 +3692,14 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
3692
3692
|
}
|
|
3693
3693
|
|
|
3694
3694
|
/**
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3695
|
+
* Extract unique values of a specific key from an array of objects.
|
|
3696
|
+
* array = [ { valueOfType: 1 }, { valueOfType: 7, valueOfSubType: 6 }, { valueOfType: 1 } ];
|
|
3697
|
+
console.log(getUniqueValuesBy(array, 'valueOfType')); //[1, 7]
|
|
3698
|
+
*
|
|
3699
|
+
* @param {Array<Object>} array - The array of objects to process.
|
|
3700
|
+
* @param {string} key - The key to extract values from. Default is 'valueOfType'.
|
|
3701
|
+
* @returns {Array<any>} A deduplicated array of the extracted values.
|
|
3702
|
+
*/
|
|
3703
3703
|
}, {
|
|
3704
3704
|
key: "getUniqueValuesBy",
|
|
3705
3705
|
value: function getUniqueValuesBy(array) {
|
|
@@ -3710,23 +3710,23 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
3710
3710
|
}
|
|
3711
3711
|
|
|
3712
3712
|
/**
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3713
|
+
* ({key: 'color', label: '顏色', options: [ { value: 0, label: '紅' }, { value: 1, label: '白' }, { value: 2, label: '黑'}]},
|
|
3714
|
+
* {key: 'size', label: '尺寸', options: [ { value: 0, label: 'S號' }, { value: 1, label: 'M號' }, { value: 2, label: 'L號' }]})
|
|
3715
|
+
*
|
|
3716
|
+
* [
|
|
3717
|
+
* { trait: {color: 0, size: 0}, id: 'color_0_size_0', content: '紅|S號' },
|
|
3718
|
+
* { trait: {color: 0, size: 1}, id: 'color_0_size_1', content: '紅|M號' },
|
|
3719
|
+
* { trait: {color: 0, size: 2}, id: 'color_0_size_2', content: '紅|L號' },
|
|
3720
|
+
* { trait: {color: 1, size: 0}, id: 'color_1_size_0', content: '白|S號' },
|
|
3721
|
+
* { trait: {color: 1, size: 1}, id: 'color_1_size_1', content: '白|M號' },
|
|
3722
|
+
* { trait: {color: 1, size: 2}, id: 'color_1_size_2', content: '白|L號' },
|
|
3723
|
+
* ]
|
|
3724
|
+
*
|
|
3725
|
+
/**
|
|
3726
|
+
* 生成所有組合並依照 value 遞增排序,並回傳指定格式
|
|
3727
|
+
* @param {Array} attributes - 屬性陣列
|
|
3728
|
+
* @returns {Array} - 格式化組合
|
|
3729
|
+
*/
|
|
3730
3730
|
}, {
|
|
3731
3731
|
key: "generateCombinations",
|
|
3732
3732
|
value: function generateCombinations() {
|
|
@@ -3939,30 +3939,30 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
3939
3939
|
}
|
|
3940
3940
|
|
|
3941
3941
|
/**
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3942
|
+
*
|
|
3943
|
+
const array = [
|
|
3944
|
+
{ serial: 'A023' },
|
|
3945
|
+
{ serial: 'Z001' },
|
|
3946
|
+
{ serial: 'C002' },
|
|
3947
|
+
{ serial: 'G123' },
|
|
3948
|
+
{ serial: 'A001' },
|
|
3949
|
+
{ serial: 'A999' }
|
|
3950
|
+
];
|
|
3951
|
+
mutateBy(array, (item) => {
|
|
3952
|
+
const serial = item.serial;
|
|
3953
|
+
const match = serial.match(/^([A-Z]+)(\d+)$/i);
|
|
3954
|
+
const [letter, number] = match ? [match[1], parseInt(match[2], 10)] : [serial, 0];
|
|
3955
|
+
return [letter, number]; // 多層排序:先字母,再數字
|
|
3956
|
+
});
|
|
3957
|
+
*
|
|
3958
|
+
* [ { serial: 'A001' }, { serial: 'A023' }, { serial: 'A999' }, { serial: 'C002' }, { serial: 'G123' }, { serial: 'Z001' } ]
|
|
3959
|
+
*
|
|
3960
|
+
*
|
|
3961
|
+
* 通用的排序變異工具:依照 predict 提供的排序 key 對 array 進行原地排序(mutated)
|
|
3962
|
+
*
|
|
3963
|
+
* @param {Array} array - 要排序的陣列(會就地變異)
|
|
3964
|
+
* @param {Function} predict - 回傳排序 key(可以是陣列以支援多層排序)
|
|
3965
|
+
*/
|
|
3966
3966
|
}, {
|
|
3967
3967
|
key: "mutateBy",
|
|
3968
3968
|
value: function mutateBy(array) {
|
|
@@ -4100,7 +4100,7 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
4100
4100
|
key: "getStringOfConvertTimeRange",
|
|
4101
4101
|
value:
|
|
4102
4102
|
/** const result = convertTimeRange('2025/08/18(一)|16:00-17:00');
|
|
4103
|
-
|
|
4103
|
+
console.log(result); // '202508181600-202508181700'*/
|
|
4104
4104
|
function getStringOfConvertTimeRange(input) {
|
|
4105
4105
|
var _input$split = input.split("|"),
|
|
4106
4106
|
_input$split2 = (0, _slicedToArray2["default"])(_input$split, 2),
|
|
@@ -159,19 +159,19 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
* 遞回的去找出folder每一個child file, 預設是全部檔案, 可以透過predicate做filter, 可以exclude 指定的 'folder name'
|
|
163
|
+
*
|
|
164
|
+
* predicate: predicate(pathInfo); predicate帶的參數是 pathInfo object
|
|
165
|
+
*
|
|
166
|
+
* excludes 忽略掉的資料夾名稱
|
|
167
|
+
*
|
|
168
|
+
* return [...{
|
|
169
|
+
path: 'database/index.js',
|
|
170
|
+
fileName: 'index',
|
|
171
|
+
extension: 'js',
|
|
172
|
+
dirName: database
|
|
173
|
+
absolute: '/Users/davidtu/cross-achieve/mimi19up/mimi19up-scrapy/database/index.js'}
|
|
174
|
+
] */
|
|
175
175
|
}, {
|
|
176
176
|
key: "findFilePathBy",
|
|
177
177
|
value: function findFilePathBy(path) {
|
|
@@ -719,9 +719,9 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
719
719
|
value: function cleanFileContent(path) {
|
|
720
720
|
this.syncDeleteFile(path);
|
|
721
721
|
/** 太浪費時間了
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
722
|
+
* fs.truncateSync(path, 0);
|
|
723
|
+
this.appendInfo(`${path} 內容被清除!`);
|
|
724
|
+
* */
|
|
725
725
|
}
|
|
726
726
|
}, {
|
|
727
727
|
key: "syncWithExistPackage",
|
|
@@ -812,7 +812,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
812
812
|
indexOfRunManager = _lodash["default"].findIndex(splited, function (line) {
|
|
813
813
|
return _this5.has(line, 'name="RunManager');
|
|
814
814
|
});
|
|
815
|
-
this.insertToArray(splited, indexOfRunManager, "<configuration name=\"".concat(packageName, "\"\
|
|
815
|
+
this.insertToArray(splited, indexOfRunManager, "<configuration name=\"".concat(packageName, "\" \n type=\"NodeJSConfigurationType\" \n path-to-node=\"$USER_HOME$/.nvm/versions/node/v18.19.1/bin/node\" \n node-parameters=\"--require @babel/register\" \n path-to-js-file=\"").concat(_path4["default"].resolve(dirPath), "/src/index.js\" \n working-dir=\"").concat(_path4["default"].resolve(dirPath), "\" >"), " <envs>", " <env name=\"self_debug\" value=\"true\" />", " <env name=\"is_node\" value=\"true\" />", " </envs>", " <method v=\"2\" />", "</configuration>");
|
|
816
816
|
indexOfList = _lodash["default"].findIndex(splited, function (line) {
|
|
817
817
|
return _lodash["default"].isEqual(_lodash["default"].trim(line), "<list>");
|
|
818
818
|
}, indexOfRunManager);
|
|
@@ -988,7 +988,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
988
988
|
if (_lodash["default"].isEmpty(content)) {
|
|
989
989
|
this.appendInfo(file.fileName, file.absolute);
|
|
990
990
|
var className = _lodash["default"].isEqual(file.fileName, "index") ? file.dirName : file.fileName;
|
|
991
|
-
_fs["default"].writeFileSync(file.absolute, String.format(this.getFileContextInRaw(".\n/template/s\
|
|
991
|
+
_fs["default"].writeFileSync(file.absolute, String.format(this.getFileContextInRaw(".\n /template/s\n ample.src.index.js"), className, "明悅", new Date()));
|
|
992
992
|
}
|
|
993
993
|
}
|
|
994
994
|
} catch (err) {
|
|
@@ -1113,7 +1113,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1113
1113
|
return !_this7.has(path, projectName);
|
|
1114
1114
|
};
|
|
1115
1115
|
})))) {
|
|
1116
|
-
_context13.next =
|
|
1116
|
+
_context13.next = 49;
|
|
1117
1117
|
break;
|
|
1118
1118
|
}
|
|
1119
1119
|
_context13.next = 4;
|
|
@@ -1142,64 +1142,69 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1142
1142
|
return _this7.copyFromFolderToDestFolder(templatePath, _this7.persistByPath(_path4["default"].join(release, "template")));
|
|
1143
1143
|
case 16:
|
|
1144
1144
|
if (!deployToNPMServer) {
|
|
1145
|
-
_context13.next =
|
|
1145
|
+
_context13.next = 26;
|
|
1146
1146
|
break;
|
|
1147
1147
|
}
|
|
1148
|
-
|
|
1148
|
+
/** 升級package.json的版號 */
|
|
1149
|
+
console.log("\u8D70\u5230\u9019\uFF1F1");
|
|
1150
|
+
_context13.next = 20;
|
|
1149
1151
|
return _this7.upgradePackageJsonVersion(pathOfPackageJson);
|
|
1150
|
-
case
|
|
1152
|
+
case 20:
|
|
1151
1153
|
_yield$_this7$upgrade = _context13.sent;
|
|
1152
1154
|
moduleName = _yield$_this7$upgrade.moduleName;
|
|
1153
1155
|
version = _yield$_this7$upgrade.version;
|
|
1154
|
-
|
|
1156
|
+
console.log("\u8D70\u5230\u9019\uFF1F2");
|
|
1157
|
+
/** 把所有樣板的版號都提升 */
|
|
1158
|
+
_context13.next = 26;
|
|
1155
1159
|
return _this7.updateVersionOfTemplate(moduleName, version);
|
|
1156
|
-
case
|
|
1160
|
+
case 26:
|
|
1157
1161
|
/** 把package.json release放進去 */
|
|
1162
|
+
console.log("\u8D70\u5230\u9019\uFF1F3");
|
|
1158
1163
|
_this7.copySingleFile(pathOfPackageJson, _path4["default"].join(release, "package.json"), undefined, true);
|
|
1159
1164
|
|
|
1160
1165
|
/** 安裝一個沒有devDependency 的node_module */
|
|
1161
1166
|
if (!(forceInstallNodeModule || !_this7.isPathExist(_path4["default"].join(release, "node_module")))) {
|
|
1162
|
-
_context13.next =
|
|
1167
|
+
_context13.next = 33;
|
|
1163
1168
|
break;
|
|
1164
1169
|
}
|
|
1165
|
-
_context13.next = 28;
|
|
1166
|
-
return _this7.executeCommandLine("cd ".concat(release, " && yarn install --production"));
|
|
1167
|
-
case 28:
|
|
1168
1170
|
_context13.next = 31;
|
|
1171
|
+
return _this7.executeCommandLine("cd ".concat(release, " && yarn install --production"));
|
|
1172
|
+
case 31:
|
|
1173
|
+
_context13.next = 34;
|
|
1169
1174
|
break;
|
|
1170
|
-
case
|
|
1175
|
+
case 33:
|
|
1171
1176
|
_this7.appendInfo("ignore node-module install behavior");
|
|
1172
|
-
case
|
|
1177
|
+
case 34:
|
|
1173
1178
|
_this7.appendInfo("build ".concat(path, " succeed"));
|
|
1174
1179
|
|
|
1175
1180
|
/** 部署到 local server*/
|
|
1176
1181
|
if (!deployToNPMServer) {
|
|
1177
|
-
_context13.next =
|
|
1182
|
+
_context13.next = 38;
|
|
1178
1183
|
break;
|
|
1179
1184
|
}
|
|
1180
|
-
_context13.next =
|
|
1185
|
+
_context13.next = 38;
|
|
1181
1186
|
return _this7.executeCommandLine("cd ".concat(release, " && npm publish"));
|
|
1182
|
-
case
|
|
1183
|
-
_context13.next =
|
|
1187
|
+
case 38:
|
|
1188
|
+
_context13.next = 45;
|
|
1184
1189
|
break;
|
|
1185
|
-
case
|
|
1186
|
-
_context13.prev =
|
|
1190
|
+
case 40:
|
|
1191
|
+
_context13.prev = 40;
|
|
1187
1192
|
_context13.t0 = _context13["catch"](9);
|
|
1188
|
-
_context13.next =
|
|
1193
|
+
_context13.next = 44;
|
|
1189
1194
|
return _this7.deleteSelfByPath(release, true);
|
|
1190
|
-
case
|
|
1195
|
+
case 44:
|
|
1191
1196
|
throw new _index2["default"](9999, "generatePackage \u5831\u932F, ".concat(_context13.t0.message));
|
|
1192
|
-
case 42:
|
|
1193
|
-
_context13.prev = 42;
|
|
1194
|
-
_context13.next = 45;
|
|
1195
|
-
return _this7.deleteSelfByPath(tempFolderPath, true);
|
|
1196
1197
|
case 45:
|
|
1197
|
-
|
|
1198
|
-
|
|
1198
|
+
_context13.prev = 45;
|
|
1199
|
+
_context13.next = 48;
|
|
1200
|
+
return _this7.deleteSelfByPath(tempFolderPath, true);
|
|
1201
|
+
case 48:
|
|
1202
|
+
return _context13.finish(45);
|
|
1203
|
+
case 49:
|
|
1199
1204
|
case "end":
|
|
1200
1205
|
return _context13.stop();
|
|
1201
1206
|
}
|
|
1202
|
-
}, _loop, null, [[9,
|
|
1207
|
+
}, _loop, null, [[9, 40, 45, 49]]);
|
|
1203
1208
|
});
|
|
1204
1209
|
_iterator7.s();
|
|
1205
1210
|
case 11:
|
|
@@ -1245,55 +1250,56 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1245
1250
|
_i = 0, _paths = paths;
|
|
1246
1251
|
case 2:
|
|
1247
1252
|
if (!(_i < _paths.length)) {
|
|
1248
|
-
_context15.next =
|
|
1253
|
+
_context15.next = 25;
|
|
1249
1254
|
break;
|
|
1250
1255
|
}
|
|
1251
1256
|
path = _paths[_i];
|
|
1252
1257
|
if (!this.isPathExist(path)) {
|
|
1253
|
-
_context15.next =
|
|
1258
|
+
_context15.next = 22;
|
|
1254
1259
|
break;
|
|
1255
1260
|
}
|
|
1256
1261
|
succeedOfPersistFile = false;
|
|
1262
|
+
console.log("\u554F\u984C\u662F\u4F60\uFF1D> path\uFF1A", path);
|
|
1257
1263
|
json = this.getJsonObjByFilePath(path);
|
|
1258
1264
|
if (!(json && json.dependencies && json.dependencies[dependency])) {
|
|
1259
|
-
_context15.next =
|
|
1265
|
+
_context15.next = 19;
|
|
1260
1266
|
break;
|
|
1261
1267
|
}
|
|
1262
1268
|
json.dependencies[dependency] = "^".concat(newVersion);
|
|
1263
|
-
_context15.prev =
|
|
1264
|
-
_context15.next =
|
|
1269
|
+
_context15.prev = 10;
|
|
1270
|
+
_context15.next = 13;
|
|
1265
1271
|
return this.writeJsonThanPrettier(path, json);
|
|
1266
|
-
case
|
|
1272
|
+
case 13:
|
|
1267
1273
|
succeedOfPersistFile = true;
|
|
1268
|
-
_context15.next =
|
|
1274
|
+
_context15.next = 19;
|
|
1269
1275
|
break;
|
|
1270
|
-
case
|
|
1271
|
-
_context15.prev =
|
|
1272
|
-
_context15.t0 = _context15["catch"](
|
|
1276
|
+
case 16:
|
|
1277
|
+
_context15.prev = 16;
|
|
1278
|
+
_context15.t0 = _context15["catch"](10);
|
|
1273
1279
|
succeedOfPersistFile = true;
|
|
1274
|
-
case
|
|
1280
|
+
case 19:
|
|
1275
1281
|
if (succeedOfPersistFile) {
|
|
1276
|
-
_context15.next =
|
|
1282
|
+
_context15.next = 22;
|
|
1277
1283
|
break;
|
|
1278
1284
|
}
|
|
1279
|
-
_context15.next =
|
|
1285
|
+
_context15.next = 22;
|
|
1280
1286
|
return this.updateFileOfSpecificLine(path, function (line) {
|
|
1281
1287
|
return " \"".concat(dependency, "\":\"^").concat(newVersion, "\"").concat(_lodash["default"].endsWith(_lodash["default"].trim(line), "," ? "," : ""));
|
|
1282
1288
|
}, function (each) {
|
|
1283
1289
|
return _lodash["default"].startsWith(_lodash["default"].trim(each), "\"".concat(dependency, "\""));
|
|
1284
1290
|
});
|
|
1285
|
-
case
|
|
1291
|
+
case 22:
|
|
1286
1292
|
_i++;
|
|
1287
1293
|
_context15.next = 2;
|
|
1288
1294
|
break;
|
|
1289
|
-
case
|
|
1290
|
-
_context15.next =
|
|
1295
|
+
case 25:
|
|
1296
|
+
_context15.next = 27;
|
|
1291
1297
|
return this.copyFromFolderToDestFolder("/Users/davidtu/cross-achieve/high/idea-inventer/utiller/template/", "/Users/davidtu/cross-achieve/high/idea-inventer/newp/template/", true, true);
|
|
1292
|
-
case
|
|
1298
|
+
case 27:
|
|
1293
1299
|
case "end":
|
|
1294
1300
|
return _context15.stop();
|
|
1295
1301
|
}
|
|
1296
|
-
}, _callee14, this, [[
|
|
1302
|
+
}, _callee14, this, [[10, 16]]);
|
|
1297
1303
|
}));
|
|
1298
1304
|
function updateVersionOfTemplate(_x16, _x17) {
|
|
1299
1305
|
return _updateVersionOfTemplate.apply(this, arguments);
|
|
@@ -1485,11 +1491,11 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1485
1491
|
return prettier;
|
|
1486
1492
|
}()
|
|
1487
1493
|
/**
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1494
|
+
* 檔案最後編輯時間!
|
|
1495
|
+
console.log('older ==> ',utiller.getFileLastModifiedTime('./folderOfTestUsage/history_older.js'));
|
|
1496
|
+
console.log('latest ==> ',utiller.getFileLastModifiedTime('./folderOfTestUsage/history_latest.js'));
|
|
1497
|
+
console.log('compare latestTime > olderTime ?? ==> ',utiller.getFileLastModifiedTime('./folderOfTestUsage/history_latest.js') > utiller.getFileLastModifiedTime('./folderOfTestUsage/history_older.js'));
|
|
1498
|
+
*/
|
|
1493
1499
|
)
|
|
1494
1500
|
}, {
|
|
1495
1501
|
key: "getFileLastModifiedTime",
|
package/package.json
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"configerer": "^1.0.
|
|
14
|
-
"utiller": "^1.0.
|
|
15
|
-
"linepayer": "^1.0.
|
|
16
|
-
"databazer": "^1.0.
|
|
13
|
+
"configerer": "^1.0.13",
|
|
14
|
+
"utiller": "^1.0.363",
|
|
15
|
+
"linepayer": "^1.0.12",
|
|
16
|
+
"databazer": "^1.0.14",
|
|
17
17
|
"lodash": "^4.17.20",
|
|
18
18
|
"moment": "^2.29.1"
|
|
19
19
|
},
|