@ceale/util 1.14.0 → 1.14.1
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/dist/cjs/index.js +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/types/type.d.ts +14 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(exports_src, {
|
|
|
37
37
|
sleepAsync: () => sleepAsync,
|
|
38
38
|
sleep: () => sleep,
|
|
39
39
|
quadraticCurve: () => quadraticCurve,
|
|
40
|
+
defineEnum: () => defineEnum,
|
|
40
41
|
debounce: () => debounce,
|
|
41
42
|
cubicCurve: () => cubicCurve,
|
|
42
43
|
css: () => css,
|
|
@@ -422,3 +423,9 @@ var tryCatch = (parameter) => {
|
|
|
422
423
|
};
|
|
423
424
|
// src/type.ts
|
|
424
425
|
var assert = (variable) => {};
|
|
426
|
+
var defineEnum = (...keys) => {
|
|
427
|
+
return keys.reduce((acc, key) => {
|
|
428
|
+
acc[key] = key;
|
|
429
|
+
return acc;
|
|
430
|
+
}, {});
|
|
431
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -374,6 +374,12 @@ var tryCatch = (parameter) => {
|
|
|
374
374
|
};
|
|
375
375
|
// src/type.ts
|
|
376
376
|
var assert = (variable) => {};
|
|
377
|
+
var defineEnum = (...keys) => {
|
|
378
|
+
return keys.reduce((acc, key) => {
|
|
379
|
+
acc[key] = key;
|
|
380
|
+
return acc;
|
|
381
|
+
}, {});
|
|
382
|
+
};
|
|
377
383
|
export {
|
|
378
384
|
waitSync,
|
|
379
385
|
wait,
|
|
@@ -383,6 +389,7 @@ export {
|
|
|
383
389
|
sleepAsync,
|
|
384
390
|
sleep,
|
|
385
391
|
quadraticCurve,
|
|
392
|
+
defineEnum,
|
|
386
393
|
debounce,
|
|
387
394
|
cubicCurve,
|
|
388
395
|
css,
|
package/dist/types/type.d.ts
CHANGED
|
@@ -4,3 +4,17 @@
|
|
|
4
4
|
* @param variable 待断言的变量
|
|
5
5
|
*/
|
|
6
6
|
export declare const assert: <Type = any>(variable: any) => asserts variable is Type;
|
|
7
|
+
/**
|
|
8
|
+
* 定义一个枚举类型。
|
|
9
|
+
* 返回一个枚举对象,其中每个键名与值相同。
|
|
10
|
+
* @param keys 若干个枚举的键名
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const type = defineEnum("A", "B", "C")
|
|
14
|
+
* type === (typeof type) === {
|
|
15
|
+
* A: "A",
|
|
16
|
+
* B: "B",
|
|
17
|
+
* C: "C"
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
export declare const defineEnum: <T extends string>(...keys: T[]) => { [K in T]: K; };
|