@wzyjs/utils 0.2.57 → 0.2.58
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/browser.cjs.js +50 -0
- package/dist/browser.esm.js +50 -0
- package/dist/common/dayjs.d.ts +1 -0
- package/dist/common/enum.d.ts +34 -0
- package/dist/common/index.d.ts +2 -1
- package/dist/node.cjs.js +50 -0
- package/dist/node.esm.js +50 -0
- package/package.json +2 -2
package/dist/browser.cjs.js
CHANGED
|
@@ -10398,6 +10398,7 @@ __export(exports_browser, {
|
|
|
10398
10398
|
consola: () => import_consola.default,
|
|
10399
10399
|
coerce: () => coerce,
|
|
10400
10400
|
classnames: () => import_classnames.default,
|
|
10401
|
+
chinaDayjs: () => chinaDayjs,
|
|
10401
10402
|
calcJsText: () => calcJsText,
|
|
10402
10403
|
boolean: () => booleanType,
|
|
10403
10404
|
bigint: () => bigIntType,
|
|
@@ -10457,6 +10458,7 @@ __export(exports_browser, {
|
|
|
10457
10458
|
OK: () => OK,
|
|
10458
10459
|
NEVER: () => NEVER,
|
|
10459
10460
|
INVALID: () => INVALID,
|
|
10461
|
+
Enum: () => Enum,
|
|
10460
10462
|
EMPTY_PATH: () => EMPTY_PATH,
|
|
10461
10463
|
Dayjs: () => import_dayjs2.Dayjs,
|
|
10462
10464
|
DIRTY: () => DIRTY,
|
|
@@ -19455,6 +19457,53 @@ async function imageToBase64(url) {
|
|
|
19455
19457
|
throw error;
|
|
19456
19458
|
}
|
|
19457
19459
|
}
|
|
19460
|
+
// src/common/enum.ts
|
|
19461
|
+
class EnumItem {
|
|
19462
|
+
label;
|
|
19463
|
+
value;
|
|
19464
|
+
extra;
|
|
19465
|
+
constructor(config2) {
|
|
19466
|
+
this.value = config2.value;
|
|
19467
|
+
this.label = config2.label;
|
|
19468
|
+
this.extra = config2.extra;
|
|
19469
|
+
}
|
|
19470
|
+
}
|
|
19471
|
+
var Enum = {
|
|
19472
|
+
create: (members) => {
|
|
19473
|
+
const usedValues = new Set;
|
|
19474
|
+
const enumObj = {};
|
|
19475
|
+
const map = new Map;
|
|
19476
|
+
const options = [];
|
|
19477
|
+
const extras = new Map;
|
|
19478
|
+
const labels = new Map;
|
|
19479
|
+
const enums = {};
|
|
19480
|
+
for (const key in members) {
|
|
19481
|
+
const member = members[key];
|
|
19482
|
+
if (!member)
|
|
19483
|
+
continue;
|
|
19484
|
+
if (usedValues.has(member.value)) {
|
|
19485
|
+
throw new Error(`Duplicate enum value detected: ${member.value}`);
|
|
19486
|
+
}
|
|
19487
|
+
usedValues.add(member.value);
|
|
19488
|
+
const item = new EnumItem(member);
|
|
19489
|
+
enumObj[key] = item;
|
|
19490
|
+
map.set(item.value, item);
|
|
19491
|
+
labels.set(item.value, item.label);
|
|
19492
|
+
options.push(item);
|
|
19493
|
+
enums[item.value] = { text: item.label, status: item.extra?.status };
|
|
19494
|
+
if (member.extra !== undefined) {
|
|
19495
|
+
extras.set(item.value, { ...member.extra });
|
|
19496
|
+
}
|
|
19497
|
+
}
|
|
19498
|
+
enumObj.map = map;
|
|
19499
|
+
enumObj.options = options;
|
|
19500
|
+
enumObj.extras = extras;
|
|
19501
|
+
enumObj.source = members;
|
|
19502
|
+
enumObj.labels = labels;
|
|
19503
|
+
enumObj.enums = enums;
|
|
19504
|
+
return enumObj;
|
|
19505
|
+
}
|
|
19506
|
+
};
|
|
19458
19507
|
// src/common/dayjs.ts
|
|
19459
19508
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
19460
19509
|
var import_isBetween = __toESM(require_isBetween());
|
|
@@ -19493,6 +19542,7 @@ var initChinaDayjs = () => {
|
|
|
19493
19542
|
});
|
|
19494
19543
|
return import_dayjs.default;
|
|
19495
19544
|
};
|
|
19545
|
+
var chinaDayjs = initChinaDayjs();
|
|
19496
19546
|
var dayjs_default = import_dayjs.default;
|
|
19497
19547
|
// src/browser/index.ts
|
|
19498
19548
|
var import_md5 = __toESM(require_md5());
|
package/dist/browser.esm.js
CHANGED
|
@@ -19272,6 +19272,53 @@ async function imageToBase64(url) {
|
|
|
19272
19272
|
throw error;
|
|
19273
19273
|
}
|
|
19274
19274
|
}
|
|
19275
|
+
// src/common/enum.ts
|
|
19276
|
+
class EnumItem {
|
|
19277
|
+
label;
|
|
19278
|
+
value;
|
|
19279
|
+
extra;
|
|
19280
|
+
constructor(config2) {
|
|
19281
|
+
this.value = config2.value;
|
|
19282
|
+
this.label = config2.label;
|
|
19283
|
+
this.extra = config2.extra;
|
|
19284
|
+
}
|
|
19285
|
+
}
|
|
19286
|
+
var Enum = {
|
|
19287
|
+
create: (members) => {
|
|
19288
|
+
const usedValues = new Set;
|
|
19289
|
+
const enumObj = {};
|
|
19290
|
+
const map = new Map;
|
|
19291
|
+
const options = [];
|
|
19292
|
+
const extras = new Map;
|
|
19293
|
+
const labels = new Map;
|
|
19294
|
+
const enums = {};
|
|
19295
|
+
for (const key in members) {
|
|
19296
|
+
const member = members[key];
|
|
19297
|
+
if (!member)
|
|
19298
|
+
continue;
|
|
19299
|
+
if (usedValues.has(member.value)) {
|
|
19300
|
+
throw new Error(`Duplicate enum value detected: ${member.value}`);
|
|
19301
|
+
}
|
|
19302
|
+
usedValues.add(member.value);
|
|
19303
|
+
const item = new EnumItem(member);
|
|
19304
|
+
enumObj[key] = item;
|
|
19305
|
+
map.set(item.value, item);
|
|
19306
|
+
labels.set(item.value, item.label);
|
|
19307
|
+
options.push(item);
|
|
19308
|
+
enums[item.value] = { text: item.label, status: item.extra?.status };
|
|
19309
|
+
if (member.extra !== undefined) {
|
|
19310
|
+
extras.set(item.value, { ...member.extra });
|
|
19311
|
+
}
|
|
19312
|
+
}
|
|
19313
|
+
enumObj.map = map;
|
|
19314
|
+
enumObj.options = options;
|
|
19315
|
+
enumObj.extras = extras;
|
|
19316
|
+
enumObj.source = members;
|
|
19317
|
+
enumObj.labels = labels;
|
|
19318
|
+
enumObj.enums = enums;
|
|
19319
|
+
return enumObj;
|
|
19320
|
+
}
|
|
19321
|
+
};
|
|
19275
19322
|
// src/common/dayjs.ts
|
|
19276
19323
|
var import_dayjs = __toESM(require_dayjs_min(), 1);
|
|
19277
19324
|
var import_isBetween = __toESM(require_isBetween(), 1);
|
|
@@ -19310,6 +19357,7 @@ var initChinaDayjs = () => {
|
|
|
19310
19357
|
});
|
|
19311
19358
|
return import_dayjs.default;
|
|
19312
19359
|
};
|
|
19360
|
+
var chinaDayjs = initChinaDayjs();
|
|
19313
19361
|
var dayjs_default = import_dayjs.default;
|
|
19314
19362
|
// src/browser/index.ts
|
|
19315
19363
|
var import_md5 = __toESM(require_md5(), 1);
|
|
@@ -20949,6 +20997,7 @@ export {
|
|
|
20949
20997
|
export_consola as consola,
|
|
20950
20998
|
coerce,
|
|
20951
20999
|
export_classnames as classnames,
|
|
21000
|
+
chinaDayjs,
|
|
20952
21001
|
calcJsText,
|
|
20953
21002
|
booleanType as boolean,
|
|
20954
21003
|
bigIntType as bigint,
|
|
@@ -21008,6 +21057,7 @@ export {
|
|
|
21008
21057
|
OK,
|
|
21009
21058
|
NEVER,
|
|
21010
21059
|
INVALID,
|
|
21060
|
+
Enum,
|
|
21011
21061
|
EMPTY_PATH,
|
|
21012
21062
|
export_Dayjs as Dayjs,
|
|
21013
21063
|
DIRTY,
|
package/dist/common/dayjs.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare enum Timezone {
|
|
|
13
13
|
EuropeBerlin = "Europe/Berlin"
|
|
14
14
|
}
|
|
15
15
|
export declare const initChinaDayjs: () => typeof dayjs;
|
|
16
|
+
export declare const chinaDayjs: typeof dayjs;
|
|
16
17
|
export { Dayjs } from 'dayjs';
|
|
17
18
|
declare const _default: typeof dayjs & {
|
|
18
19
|
isBetween: typeof isBetween;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface Option<V, L extends string, E> {
|
|
2
|
+
value: V;
|
|
3
|
+
label?: L;
|
|
4
|
+
extra?: E;
|
|
5
|
+
}
|
|
6
|
+
declare class EnumItem<V, L extends string, E> {
|
|
7
|
+
readonly label: L;
|
|
8
|
+
readonly value: V;
|
|
9
|
+
readonly extra?: E;
|
|
10
|
+
constructor(config: Readonly<Option<V, L, E>>);
|
|
11
|
+
}
|
|
12
|
+
type EnumExtras<V, L extends string, E, S> = {
|
|
13
|
+
source: S;
|
|
14
|
+
map: Map<V, EnumItem<V, L, E>>;
|
|
15
|
+
enums: Record<string, {
|
|
16
|
+
text: string;
|
|
17
|
+
status?: string;
|
|
18
|
+
}>;
|
|
19
|
+
extras: Map<V, E>;
|
|
20
|
+
labels: Map<V, string>;
|
|
21
|
+
options: (Option<V, L, E>)[];
|
|
22
|
+
};
|
|
23
|
+
type EnumWithKeys<T extends Record<string, Readonly<Option<any, any, Record<string, any>>>>> = {
|
|
24
|
+
[K in keyof T]: EnumItem<T[K]['value'], T[K]['label'], T[K]['extra']>;
|
|
25
|
+
} & EnumExtras<T[keyof T]['value'], T[keyof T]['label'], T[keyof T]['extra'], T>;
|
|
26
|
+
declare global {
|
|
27
|
+
export type EnumKey<T extends Record<string, Option<any, any, Record<string, any>>>> = keyof T;
|
|
28
|
+
export type EnumLabel<T extends Record<string, Option<any, any, Record<string, any>>>> = T[keyof T]['label'];
|
|
29
|
+
export type EnumValue<T extends Record<string, Option<any, any, Record<string, any>>>> = T[keyof T]['value'];
|
|
30
|
+
}
|
|
31
|
+
export declare const Enum: {
|
|
32
|
+
create: <T extends Record<string, Readonly<Option<any, any, Record<string, any>>>>>(members: T) => EnumWithKeys<T>;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
package/dist/common/index.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export * from './other';
|
|
|
9
9
|
export * from './number';
|
|
10
10
|
export * from './array';
|
|
11
11
|
export * from './image';
|
|
12
|
-
export
|
|
12
|
+
export * from './enum';
|
|
13
|
+
export { default as dayjs, Dayjs, Timezone, initChinaDayjs, chinaDayjs } from './dayjs';
|
package/dist/node.cjs.js
CHANGED
|
@@ -6544,6 +6544,7 @@ __export(exports_node, {
|
|
|
6544
6544
|
custom: () => custom,
|
|
6545
6545
|
consola: () => import_consola.default,
|
|
6546
6546
|
coerce: () => coerce,
|
|
6547
|
+
chinaDayjs: () => chinaDayjs,
|
|
6547
6548
|
cheerio: () => cheerio,
|
|
6548
6549
|
calcJsText: () => calcJsText,
|
|
6549
6550
|
boolean: () => booleanType,
|
|
@@ -6604,6 +6605,7 @@ __export(exports_node, {
|
|
|
6604
6605
|
OK: () => OK,
|
|
6605
6606
|
NEVER: () => NEVER,
|
|
6606
6607
|
INVALID: () => INVALID,
|
|
6608
|
+
Enum: () => Enum,
|
|
6607
6609
|
EMPTY_PATH: () => EMPTY_PATH,
|
|
6608
6610
|
Dayjs: () => import_dayjs2.Dayjs,
|
|
6609
6611
|
DataStoreOptions: () => import_nedb.DataStoreOptions,
|
|
@@ -13275,6 +13277,53 @@ async function imageToBase64(url) {
|
|
|
13275
13277
|
throw error;
|
|
13276
13278
|
}
|
|
13277
13279
|
}
|
|
13280
|
+
// src/common/enum.ts
|
|
13281
|
+
class EnumItem {
|
|
13282
|
+
label;
|
|
13283
|
+
value;
|
|
13284
|
+
extra;
|
|
13285
|
+
constructor(config2) {
|
|
13286
|
+
this.value = config2.value;
|
|
13287
|
+
this.label = config2.label;
|
|
13288
|
+
this.extra = config2.extra;
|
|
13289
|
+
}
|
|
13290
|
+
}
|
|
13291
|
+
var Enum = {
|
|
13292
|
+
create: (members) => {
|
|
13293
|
+
const usedValues = new Set;
|
|
13294
|
+
const enumObj = {};
|
|
13295
|
+
const map = new Map;
|
|
13296
|
+
const options = [];
|
|
13297
|
+
const extras = new Map;
|
|
13298
|
+
const labels = new Map;
|
|
13299
|
+
const enums = {};
|
|
13300
|
+
for (const key in members) {
|
|
13301
|
+
const member = members[key];
|
|
13302
|
+
if (!member)
|
|
13303
|
+
continue;
|
|
13304
|
+
if (usedValues.has(member.value)) {
|
|
13305
|
+
throw new Error(`Duplicate enum value detected: ${member.value}`);
|
|
13306
|
+
}
|
|
13307
|
+
usedValues.add(member.value);
|
|
13308
|
+
const item = new EnumItem(member);
|
|
13309
|
+
enumObj[key] = item;
|
|
13310
|
+
map.set(item.value, item);
|
|
13311
|
+
labels.set(item.value, item.label);
|
|
13312
|
+
options.push(item);
|
|
13313
|
+
enums[item.value] = { text: item.label, status: item.extra?.status };
|
|
13314
|
+
if (member.extra !== undefined) {
|
|
13315
|
+
extras.set(item.value, { ...member.extra });
|
|
13316
|
+
}
|
|
13317
|
+
}
|
|
13318
|
+
enumObj.map = map;
|
|
13319
|
+
enumObj.options = options;
|
|
13320
|
+
enumObj.extras = extras;
|
|
13321
|
+
enumObj.source = members;
|
|
13322
|
+
enumObj.labels = labels;
|
|
13323
|
+
enumObj.enums = enums;
|
|
13324
|
+
return enumObj;
|
|
13325
|
+
}
|
|
13326
|
+
};
|
|
13278
13327
|
// src/common/dayjs.ts
|
|
13279
13328
|
var import_dayjs = __toESM(require("dayjs"));
|
|
13280
13329
|
var import_isBetween = __toESM(require("dayjs/plugin/isBetween"));
|
|
@@ -13313,6 +13362,7 @@ var initChinaDayjs = () => {
|
|
|
13313
13362
|
});
|
|
13314
13363
|
return import_dayjs.default;
|
|
13315
13364
|
};
|
|
13365
|
+
var chinaDayjs = initChinaDayjs();
|
|
13316
13366
|
var dayjs_default = import_dayjs.default;
|
|
13317
13367
|
// src/ai/302/index.ts
|
|
13318
13368
|
var exports_302 = {};
|
package/dist/node.esm.js
CHANGED
|
@@ -13093,6 +13093,53 @@ async function imageToBase64(url) {
|
|
|
13093
13093
|
throw error;
|
|
13094
13094
|
}
|
|
13095
13095
|
}
|
|
13096
|
+
// src/common/enum.ts
|
|
13097
|
+
class EnumItem {
|
|
13098
|
+
label;
|
|
13099
|
+
value;
|
|
13100
|
+
extra;
|
|
13101
|
+
constructor(config2) {
|
|
13102
|
+
this.value = config2.value;
|
|
13103
|
+
this.label = config2.label;
|
|
13104
|
+
this.extra = config2.extra;
|
|
13105
|
+
}
|
|
13106
|
+
}
|
|
13107
|
+
var Enum = {
|
|
13108
|
+
create: (members) => {
|
|
13109
|
+
const usedValues = new Set;
|
|
13110
|
+
const enumObj = {};
|
|
13111
|
+
const map = new Map;
|
|
13112
|
+
const options = [];
|
|
13113
|
+
const extras = new Map;
|
|
13114
|
+
const labels = new Map;
|
|
13115
|
+
const enums = {};
|
|
13116
|
+
for (const key in members) {
|
|
13117
|
+
const member = members[key];
|
|
13118
|
+
if (!member)
|
|
13119
|
+
continue;
|
|
13120
|
+
if (usedValues.has(member.value)) {
|
|
13121
|
+
throw new Error(`Duplicate enum value detected: ${member.value}`);
|
|
13122
|
+
}
|
|
13123
|
+
usedValues.add(member.value);
|
|
13124
|
+
const item = new EnumItem(member);
|
|
13125
|
+
enumObj[key] = item;
|
|
13126
|
+
map.set(item.value, item);
|
|
13127
|
+
labels.set(item.value, item.label);
|
|
13128
|
+
options.push(item);
|
|
13129
|
+
enums[item.value] = { text: item.label, status: item.extra?.status };
|
|
13130
|
+
if (member.extra !== undefined) {
|
|
13131
|
+
extras.set(item.value, { ...member.extra });
|
|
13132
|
+
}
|
|
13133
|
+
}
|
|
13134
|
+
enumObj.map = map;
|
|
13135
|
+
enumObj.options = options;
|
|
13136
|
+
enumObj.extras = extras;
|
|
13137
|
+
enumObj.source = members;
|
|
13138
|
+
enumObj.labels = labels;
|
|
13139
|
+
enumObj.enums = enums;
|
|
13140
|
+
return enumObj;
|
|
13141
|
+
}
|
|
13142
|
+
};
|
|
13096
13143
|
// src/common/dayjs.ts
|
|
13097
13144
|
import dayjs from "dayjs";
|
|
13098
13145
|
import isBetween from "dayjs/plugin/isBetween";
|
|
@@ -13131,6 +13178,7 @@ var initChinaDayjs = () => {
|
|
|
13131
13178
|
});
|
|
13132
13179
|
return dayjs;
|
|
13133
13180
|
};
|
|
13181
|
+
var chinaDayjs = initChinaDayjs();
|
|
13134
13182
|
var dayjs_default = dayjs;
|
|
13135
13183
|
// src/ai/302/index.ts
|
|
13136
13184
|
var exports_302 = {};
|
|
@@ -13433,6 +13481,7 @@ export {
|
|
|
13433
13481
|
custom,
|
|
13434
13482
|
default5 as consola,
|
|
13435
13483
|
coerce,
|
|
13484
|
+
chinaDayjs,
|
|
13436
13485
|
cheerio,
|
|
13437
13486
|
calcJsText,
|
|
13438
13487
|
booleanType as boolean,
|
|
@@ -13493,6 +13542,7 @@ export {
|
|
|
13493
13542
|
OK,
|
|
13494
13543
|
NEVER,
|
|
13495
13544
|
INVALID,
|
|
13545
|
+
Enum,
|
|
13496
13546
|
EMPTY_PATH,
|
|
13497
13547
|
Dayjs,
|
|
13498
13548
|
DataStoreOptions,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.58",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
6
|
"scripts": {
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"@types/nodemailer": "^6.4.7",
|
|
69
69
|
"@types/papaparse": "^5.3.15"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "c293b90cf37a8425c75eb8f3880787b40b951593"
|
|
72
72
|
}
|