utiller 1.0.358 → 1.0.360

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.
@@ -410,7 +410,7 @@ var Utiller = /*#__PURE__*/function () {
410
410
  var value;
411
411
  do {
412
412
  // Firestore 可接受的整數範圍(可調整範圍)
413
- value = _lodash["default"].random(2, 999999);
413
+ value = _lodash["default"].random(2, 999999999);
414
414
  } while (usedValues.has(value)); // 確保 value 唯一
415
415
 
416
416
  // 5. 記錄該值為已使用,避免後續重複
@@ -595,6 +595,34 @@ var Utiller = /*#__PURE__*/function () {
595
595
  return match ? _lodash["default"].merge({}, item, match) : item;
596
596
  });
597
597
  });
598
+ /**
599
+ * @param {Array<Object>} current - 要更新的目標陣列
600
+ * @param {Array<Object>} reference - 用來替換屬性的參照陣列
601
+ * @returns {Array<Object>} - 更新後的陣列
602
+ *
603
+ * const current = [{ value: 1, label: 'one' }, { value: 2, label: 'two' }];
604
+ * const reference = [{ value: 1, label: 'ㄧ', type: 'a' }, { value: 2, label: '二', type: 'b' }, { value: 3, label: '三' }, { value: 3, label: '四' }];
605
+ * const latest = updateArrayByReference(current, reference);
606
+ * console.log(latest);
607
+ * 預期輸出:
608
+ * [
609
+ * { value: 1, label: 'ㄧ', type: 'a' },
610
+ * { value: 2, label: '二', type: 'b' }
611
+ * ]
612
+ */
613
+ (0, _defineProperty2["default"])(this, "getArrayOfMappingRef", function (current, reference) {
614
+ // 使用 _.map 迭代 current 陣列,為每個物件建立一個新物件
615
+ return _lodash["default"].map(current, function (currentObj) {
616
+ // 使用 _.find 在 reference 陣列中尋找與 currentObj.value 相同的物件
617
+ var referenceObj = _lodash["default"].find(reference, {
618
+ value: currentObj.value
619
+ });
620
+ // 如果找到對應的參考物件,則使用 _.merge 來合併它們
621
+ // _.merge 會將 referenceObj 的屬性覆蓋到 currentObj 上
622
+ // 否則,返回原始的 currentObj
623
+ return referenceObj ? _lodash["default"].merge({}, currentObj, referenceObj) : currentObj;
624
+ });
625
+ });
598
626
  this.init();
599
627
  this.env = "dev";
600
628
  }
@@ -4190,64 +4218,47 @@ var Utiller = /*#__PURE__*/function () {
4190
4218
  // true: 超過資源負荷
4191
4219
  items: conflictItems // 衝突的任務列表
4192
4220
  };
4193
- }
4194
- }, {
4195
- key: "testOfConflict",
4196
- value: function testOfConflict() {
4197
- // ===== 測試資料 =====
4198
- var newTask = {
4199
- timeSlot: "2025/08/20 (三)|16:00-17:00",
4200
- // 格式: YYYY/MM/DD (週)|HH:mm-HH:mm
4201
- id: "JOB001",
4202
- description: "安裝冷氣"
4203
- };
4204
- var existingTasks = [{
4205
- id: "T001",
4206
- period: "202508151400-202508151500"
4207
- }, {
4208
- id: "T002",
4209
- period: "202508151600-202508151700"
4210
- }, {
4211
- id: "T003",
4212
- period: "202508161400-202508161500"
4213
- }, {
4214
- id: "T004",
4215
- period: "202508171600-202508171700"
4216
- }, {
4217
- id: "T005",
4218
- period: "202508201630-202508201700"
4219
- },
4220
- // 衝突
4221
- {
4222
- id: "T006",
4223
- period: "202508201645-202508201700"
4224
- } // 衝突
4225
- ];
4226
-
4227
- // 測試:一人資源
4228
- console.log(checkPeriodConflict(newTask, existingTasks, 1));
4229
- /*
4230
- {
4231
- conflict: true,
4232
- items: [
4233
- { id: 'T005', period: '202508201630-202508201700' },
4234
- { id: 'T006', period: '202508201645-202508201700' }
4235
- ]
4236
- }
4237
- */
4238
-
4239
- // 測試:兩人資源
4240
- console.log(checkPeriodConflict(newTask, existingTasks, 2));
4241
- /*
4242
- {
4243
- conflict: false,
4244
- items: [
4245
- { id: 'T005', period: '202508201630-202508201700' },
4246
- { id: 'T006', period: '202508201645-202508201700' }
4247
- ]
4248
- }
4249
- */
4250
- }
4221
+ } // testOfConflict() {
4222
+ // // ===== 測試資料 =====
4223
+ // const newTask = {
4224
+ // timeSlot: "2025/08/20 ()|16:00-17:00", // 格式: YYYY/MM/DD (週)|HH:mm-HH:mm
4225
+ // id: "JOB001",
4226
+ // description: "安裝冷氣"
4227
+ // };
4228
+ //
4229
+ // const existingTasks = [
4230
+ // { id: "T001", period: "202508151400-202508151500" },
4231
+ // { id: "T002", period: "202508151600-202508151700" },
4232
+ // { id: "T003", period: "202508161400-202508161500" },
4233
+ // { id: "T004", period: "202508171600-202508171700" },
4234
+ // { id: "T005", period: "202508201630-202508201700" }, // 衝突
4235
+ // { id: "T006", period: "202508201645-202508201700" } // 衝突
4236
+ // ];
4237
+ //
4238
+ // // 測試:一人資源
4239
+ // console.log(this.checkPeriodConflict(newTask, existingTasks, 1));
4240
+ // /*
4241
+ // {
4242
+ // conflict: true,
4243
+ // items: [
4244
+ // { id: 'T005', period: '202508201630-202508201700' },
4245
+ // { id: 'T006', period: '202508201645-202508201700' }
4246
+ // ]
4247
+ // }
4248
+ // */
4249
+ //
4250
+ // // 測試:兩人資源
4251
+ // console.log(this.checkPeriodConflict(newTask, existingTasks, 2));
4252
+ // /*
4253
+ // {
4254
+ // conflict: false,
4255
+ // items: [
4256
+ // { id: 'T005', period: '202508201630-202508201700' },
4257
+ // { id: 'T006', period: '202508201645-202508201700' }
4258
+ // ]
4259
+ // }
4260
+ // */
4261
+ // }
4251
4262
  /** ============== 排課系統公式 結束 ============== */
4252
4263
  }]);
4253
4264
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utiller",
3
- "version": "1.0.358",
3
+ "version": "1.0.360",
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.357",
14
+ "utiller": "^1.0.359",
15
15
  "linepayer": "^1.0.4",
16
16
  "databazer": "^1.0.12",
17
17
  "lodash": "^4.17.20",