utiller 1.0.393 → 1.0.395
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
CHANGED
|
@@ -4243,6 +4243,11 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
4243
4243
|
value: function isFirestoreAutoId(id) {
|
|
4244
4244
|
return _lodash["default"].isString(id) && id.length === 20 && /^[A-Za-z0-9]{20}$/.test(id);
|
|
4245
4245
|
}
|
|
4246
|
+
}, {
|
|
4247
|
+
key: "getAutoIdOfFirestore",
|
|
4248
|
+
value: function getAutoIdOfFirestore() {
|
|
4249
|
+
return this.getRandomHashV2(20);
|
|
4250
|
+
}
|
|
4246
4251
|
}, {
|
|
4247
4252
|
key: "getStringOfConvertTimeRange",
|
|
4248
4253
|
value:
|
|
@@ -4389,15 +4394,14 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
4389
4394
|
* 🧩 範例:
|
|
4390
4395
|
* ```js
|
|
4391
4396
|
* const array = [
|
|
4392
|
-
* { a: { c:
|
|
4393
|
-
* { b: { d:
|
|
4394
|
-
* { a: { f: 3 } }
|
|
4397
|
+
* { a: { b: { c: 2 } } },
|
|
4398
|
+
* { b: { d: { g: 1 } }, a: { b: { y: 1 }, h: { e: 1 } } }
|
|
4395
4399
|
* ];
|
|
4396
4400
|
*
|
|
4397
4401
|
* ArrayHelper.mergeArrayByKey(array);
|
|
4398
4402
|
*
|
|
4399
4403
|
* console.log(array);
|
|
4400
|
-
* // 👉 [ { a: { c: 1,
|
|
4404
|
+
* // 👉 [ { a: { b: { c: 2, y: 1 }, h: { e: 1 } } }, { b: { d: { g: 1 } } } ]
|
|
4401
4405
|
* ```
|
|
4402
4406
|
*
|
|
4403
4407
|
* @param {Array<Object>} array - 需被合併的物件陣列
|
|
@@ -4406,14 +4410,36 @@ var Utiller = /*#__PURE__*/function () {
|
|
|
4406
4410
|
function mergeArrayByKey(array) {
|
|
4407
4411
|
if (!Array.isArray(array)) return array;
|
|
4408
4412
|
|
|
4409
|
-
//
|
|
4410
|
-
var
|
|
4413
|
+
// 收集所有 key 的合併結果
|
|
4414
|
+
var resultMap = {};
|
|
4415
|
+
var _iterator20 = _createForOfIteratorHelper(array),
|
|
4416
|
+
_step20;
|
|
4417
|
+
try {
|
|
4418
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
4419
|
+
var obj = _step20.value;
|
|
4420
|
+
if (!_lodash["default"].isPlainObject(obj)) continue;
|
|
4421
|
+
for (var _i16 = 0, _Object$entries = Object.entries(obj); _i16 < _Object$entries.length; _i16++) {
|
|
4422
|
+
var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i16], 2),
|
|
4423
|
+
_key45 = _Object$entries$_i[0],
|
|
4424
|
+
value = _Object$entries$_i[1];
|
|
4425
|
+
if (!resultMap[_key45]) {
|
|
4426
|
+
resultMap[_key45] = _lodash["default"].cloneDeep(value);
|
|
4427
|
+
} else {
|
|
4428
|
+
_lodash["default"].merge(resultMap[_key45], value);
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4411
4432
|
|
|
4412
|
-
|
|
4433
|
+
// 清空原陣列(mutate)
|
|
4434
|
+
} catch (err) {
|
|
4435
|
+
_iterator20.e(err);
|
|
4436
|
+
} finally {
|
|
4437
|
+
_iterator20.f();
|
|
4438
|
+
}
|
|
4413
4439
|
array.length = 0;
|
|
4414
4440
|
|
|
4415
|
-
//
|
|
4416
|
-
Object.entries(
|
|
4441
|
+
// 重建結構
|
|
4442
|
+
Object.entries(resultMap).forEach(function (_ref12) {
|
|
4417
4443
|
var _ref13 = (0, _slicedToArray2["default"])(_ref12, 2),
|
|
4418
4444
|
key = _ref13[0],
|
|
4419
4445
|
value = _ref13[1];
|
|
@@ -1129,7 +1129,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1129
1129
|
release = _this7.persistByPath(_path4["default"].join(path, "release"));
|
|
1130
1130
|
/** 利用babel 產生出 es5相容性高的src file */
|
|
1131
1131
|
_context13.next = 8;
|
|
1132
|
-
return _this7.executeCommandLine("cd ".concat(path, " &&
|
|
1132
|
+
return _this7.executeCommandLine("cd ".concat(path, " && babel ./temp --out-dir ./release/lib --config-file ./babel.config.js"));
|
|
1133
1133
|
case 8:
|
|
1134
1134
|
pathOfPackageJson = _path4["default"].join(path, "package.json");
|
|
1135
1135
|
_context13.prev = 9;
|
package/package.json
CHANGED