zmdms-utils 0.0.23 → 0.0.24

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.
@@ -30,6 +30,7 @@ function parseTime(config) {
30
30
  // 浅拷贝一下
31
31
  var newParams_1 = Object.assign({}, params);
32
32
  fromKeys.forEach(function (fromKey, index) {
33
+ var _a, _b;
33
34
  var toKey = toKeys[index];
34
35
  var endTypeItem = Array.isArray(endType) ? endType[index] : endType;
35
36
  // 1. 从一个键 转成 一个键
@@ -55,12 +56,12 @@ function parseTime(config) {
55
56
  endEndType = endTypeItem[1];
56
57
  }
57
58
  newParams_1[toKey1] = getParseResult({
58
- value: newParams_1[fromKey],
59
+ value: (_a = newParams_1[fromKey]) === null || _a === void 0 ? void 0 : _a[0],
59
60
  index: index,
60
61
  endType: startEndType,
61
62
  });
62
63
  newParams_1[toKey2] = getParseResult({
63
- value: newParams_1[fromKey],
64
+ value: (_b = newParams_1[fromKey]) === null || _b === void 0 ? void 0 : _b[1],
64
65
  index: index,
65
66
  endType: endEndType,
66
67
  });
@@ -134,7 +135,7 @@ function parseTime(config) {
134
135
  function parseByResult(option) {
135
136
  var _a = option.format, format = _a === void 0 ? defaultFormat : _a, _b = option.type, type = _b === void 0 ? "string" : _b;
136
137
  return function (option) {
137
- var value = option.value, _a = option.index, index = _a === void 0 ? 0 : _a, endType = option.endType;
138
+ var value = option.value, _a = option.index, index = _a === void 0 ? 0 : _a, endType = option.endType; option.formatType;
138
139
  if (!value) {
139
140
  return undefined;
140
141
  }
@@ -53,12 +53,12 @@ function parseTime(config) {
53
53
  endEndType = endTypeItem[1];
54
54
  }
55
55
  newParams[toKey1] = getParseResult({
56
- value: newParams[fromKey],
56
+ value: newParams[fromKey]?.[0],
57
57
  index,
58
58
  endType: startEndType,
59
59
  });
60
60
  newParams[toKey2] = getParseResult({
61
- value: newParams[fromKey],
61
+ value: newParams[fromKey]?.[1],
62
62
  index,
63
63
  endType: endEndType,
64
64
  });
@@ -241,4 +241,15 @@ console.log(
241
241
  ["startOf", "startOf"],
242
242
  ],
243
243
  })
244
+ );
245
+ console.log(
246
+ parseTime({
247
+ params: {
248
+ time: [dayjs(), dayjs()],
249
+ timea: dayjs(),
250
+ },
251
+ fromKeys: ["time", "timea"],
252
+ toKeys: [["time1", "time2"], "timea"],
253
+ format: ["YYYY-MM-DD", "YYYY-MM-DD HH:mm:ss"],
254
+ })
244
255
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-utils",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/parseTime.ts CHANGED
@@ -82,12 +82,12 @@ export default function parseTime(config: IConfig) {
82
82
  endEndType = endTypeItem[1];
83
83
  }
84
84
  newParams[toKey1] = getParseResult({
85
- value: newParams[fromKey],
85
+ value: newParams[fromKey]?.[0],
86
86
  index,
87
87
  endType: startEndType,
88
88
  });
89
89
  newParams[toKey2] = getParseResult({
90
- value: newParams[fromKey],
90
+ value: newParams[fromKey]?.[1],
91
91
  index,
92
92
  endType: endEndType,
93
93
  });
@@ -168,12 +168,13 @@ interface IResultProps {
168
168
  value?: any;
169
169
  index?: number;
170
170
  endType?: IEndType | IEndType[];
171
+ formatType?: string;
171
172
  }
172
173
  function parseByResult(option: IProps) {
173
174
  const { format = defaultFormat, type = "string" } = option;
174
175
 
175
176
  return (option: IResultProps) => {
176
- const { value, index = 0, endType } = option;
177
+ const { value, index = 0, endType, formatType } = option;
177
178
  if (!value) {
178
179
  return undefined;
179
180
  }
@@ -51,12 +51,12 @@ function parseTime(config) {
51
51
  endEndType = endTypeItem[1];
52
52
  }
53
53
  newParams[toKey1] = getParseResult({
54
- value: newParams[fromKey],
54
+ value: newParams[fromKey]?.[0],
55
55
  index,
56
56
  endType: startEndType,
57
57
  });
58
58
  newParams[toKey2] = getParseResult({
59
- value: newParams[fromKey],
59
+ value: newParams[fromKey]?.[1],
60
60
  index,
61
61
  endType: endEndType,
62
62
  });
@@ -240,3 +240,14 @@ console.log(
240
240
  ],
241
241
  })
242
242
  );
243
+ console.log(
244
+ parseTime({
245
+ params: {
246
+ time: [dayjs(), dayjs()],
247
+ timea: dayjs(),
248
+ },
249
+ fromKeys: ["time", "timea"],
250
+ toKeys: [["time1", "time2"], "timea"],
251
+ format: ["YYYY-MM-DD", "YYYY-MM-DD HH:mm:ss"],
252
+ })
253
+ );