xjs-common 13.0.0-alpha.2 → 13.0.0-alpha.3
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/README.md +26 -26
- package/build/cjs/const/http-method.js +12 -0
- package/build/cjs/const/time-unit.js +13 -0
- package/build/cjs/const/types.js +14 -0
- package/build/cjs/func/decorator/d-type.js +91 -0
- package/build/cjs/func/decorator/transaction.js +35 -0
- package/build/cjs/func/u-array.js +81 -0
- package/build/cjs/func/u-http.js +32 -0
- package/build/cjs/func/u-obj.js +74 -0
- package/build/cjs/func/u-string.js +120 -0
- package/build/cjs/func/u-type.js +67 -0
- package/build/cjs/func/u.js +83 -0
- package/build/cjs/index.js +30 -0
- package/build/cjs/obj/xjs-err.js +13 -0
- package/package.json +15 -9
- /package/build/{const → esm/const}/http-method.d.ts +0 -0
- /package/build/{const → esm/const}/http-method.js +0 -0
- /package/build/{const → esm/const}/time-unit.d.ts +0 -0
- /package/build/{const → esm/const}/time-unit.js +0 -0
- /package/build/{const → esm/const}/types.d.ts +0 -0
- /package/build/{const → esm/const}/types.js +0 -0
- /package/build/{func → esm/func}/decorator/d-type.d.ts +0 -0
- /package/build/{func → esm/func}/decorator/d-type.js +0 -0
- /package/build/{func → esm/func}/decorator/transaction.d.ts +0 -0
- /package/build/{func → esm/func}/decorator/transaction.js +0 -0
- /package/build/{func → esm/func}/u-array.d.ts +0 -0
- /package/build/{func → esm/func}/u-array.js +0 -0
- /package/build/{func → esm/func}/u-http.d.ts +0 -0
- /package/build/{func → esm/func}/u-http.js +0 -0
- /package/build/{func → esm/func}/u-obj.d.ts +0 -0
- /package/build/{func → esm/func}/u-obj.js +0 -0
- /package/build/{func → esm/func}/u-string.d.ts +0 -0
- /package/build/{func → esm/func}/u-string.js +0 -0
- /package/build/{func → esm/func}/u-type.d.ts +0 -0
- /package/build/{func → esm/func}/u-type.js +0 -0
- /package/build/{func → esm/func}/u.d.ts +0 -0
- /package/build/{func → esm/func}/u.js +0 -0
- /package/build/{index.d.ts → esm/index.d.ts} +0 -0
- /package/build/{index.js → esm/index.js} +0 -0
- /package/build/{obj → esm/obj}/xjs-err.d.ts +0 -0
- /package/build/{obj → esm/obj}/xjs-err.js +0 -0
package/README.md
CHANGED
|
@@ -93,32 +93,7 @@ import { UString } from "xjs-common";
|
|
|
93
93
|
console.log(UString.simpleTime({ date: getJSTDate(), unit: TimeUnit.Day }));
|
|
94
94
|
})();
|
|
95
95
|
```
|
|
96
|
-
###
|
|
97
|
-
**NOTE**: this feature uses decorator, so requires `"experimentalDecorators": true` in tsconfig.
|
|
98
|
-
```ts
|
|
99
|
-
import { transaction, delay } from "xjs-common";
|
|
100
|
-
|
|
101
|
-
class Cls {
|
|
102
|
-
constructor() { }
|
|
103
|
-
// default timeout sec is 30.
|
|
104
|
-
@transaction()
|
|
105
|
-
async exe1(): Promise<void> {
|
|
106
|
-
}
|
|
107
|
-
@transaction({ timeoutSec: 3 })
|
|
108
|
-
async exe2(): Promise<void> {
|
|
109
|
-
await delay(10);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
(async () => {
|
|
113
|
-
const cls = new Cls();
|
|
114
|
-
await Promise.all([cls.exe2(), cls.exe2()]);
|
|
115
|
-
})().catch(e => {
|
|
116
|
-
// reach here after 3 sec from second call for Cls#exe2().
|
|
117
|
-
// XjsErr [Error]: [XJS] An exclusive process to execute was already running by other request.
|
|
118
|
-
console.log(e);
|
|
119
|
-
});
|
|
120
|
-
```
|
|
121
|
-
### Validate and crop class fields.
|
|
96
|
+
### Validate and crop object properties with annotation.
|
|
122
97
|
**NOTE**: this feature uses decorator, so requires `"experimentalDecorators": true` in tsconfig.
|
|
123
98
|
**NOTE**: some functionalities in this feature are based on `"useDefineForClassFields": true` in tsconfig.
|
|
124
99
|
this flag is true by default at the target higher than `ES2022`, [here is for more](https://www.typescriptlang.org/tsconfig/#useDefineForClassFields).
|
|
@@ -181,6 +156,31 @@ class Cls_A implements If_A {
|
|
|
181
156
|
console.log(UType.validate(invalid5, Cls_A)); // [ 'objA.aryB.0' ]
|
|
182
157
|
})();
|
|
183
158
|
```
|
|
159
|
+
### Mark method as transaction.
|
|
160
|
+
**NOTE**: this feature uses decorator, so requires `"experimentalDecorators": true` in tsconfig.
|
|
161
|
+
```ts
|
|
162
|
+
import { transaction, delay } from "xjs-common";
|
|
163
|
+
|
|
164
|
+
class Cls {
|
|
165
|
+
constructor() { }
|
|
166
|
+
// default timeout sec is 30.
|
|
167
|
+
@transaction()
|
|
168
|
+
async exe1(): Promise<void> {
|
|
169
|
+
}
|
|
170
|
+
@transaction({ timeoutSec: 3 })
|
|
171
|
+
async exe2(): Promise<void> {
|
|
172
|
+
await delay(10);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
(async () => {
|
|
176
|
+
const cls = new Cls();
|
|
177
|
+
await Promise.all([cls.exe2(), cls.exe2()]);
|
|
178
|
+
})().catch(e => {
|
|
179
|
+
// reach here after 3 sec from second call for Cls#exe2().
|
|
180
|
+
// XjsErr [Error]: [XJS] An exclusive process to execute was already running by other request.
|
|
181
|
+
console.log(e);
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
184
|
# Error definition
|
|
185
185
|
XJS throws error with `code` property which has one of the following numbers.
|
|
186
186
|
|code|thrown by|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpMethod = void 0;
|
|
4
|
+
var HttpMethod;
|
|
5
|
+
(function (HttpMethod) {
|
|
6
|
+
HttpMethod["Get"] = "GET";
|
|
7
|
+
HttpMethod["Put"] = "PUT";
|
|
8
|
+
HttpMethod["Post"] = "POST";
|
|
9
|
+
HttpMethod["Delete"] = "DELETE";
|
|
10
|
+
HttpMethod["Patch"] = "PATCH";
|
|
11
|
+
HttpMethod["Connect"] = "CONNECT";
|
|
12
|
+
})(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeUnit = void 0;
|
|
4
|
+
var TimeUnit;
|
|
5
|
+
(function (TimeUnit) {
|
|
6
|
+
TimeUnit[TimeUnit["Year"] = 1] = "Year";
|
|
7
|
+
TimeUnit[TimeUnit["Month"] = 2] = "Month";
|
|
8
|
+
TimeUnit[TimeUnit["Day"] = 3] = "Day";
|
|
9
|
+
TimeUnit[TimeUnit["Hour"] = 4] = "Hour";
|
|
10
|
+
TimeUnit[TimeUnit["Min"] = 5] = "Min";
|
|
11
|
+
TimeUnit[TimeUnit["Sec"] = 6] = "Sec";
|
|
12
|
+
TimeUnit[TimeUnit["Msec"] = 7] = "Msec";
|
|
13
|
+
})(TimeUnit || (exports.TimeUnit = TimeUnit = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Type = void 0;
|
|
4
|
+
var Type;
|
|
5
|
+
(function (Type) {
|
|
6
|
+
Type["string"] = "string";
|
|
7
|
+
Type["number"] = "number";
|
|
8
|
+
Type["bigint"] = "bigint";
|
|
9
|
+
Type["boolean"] = "boolean";
|
|
10
|
+
Type["symbol"] = "symbol";
|
|
11
|
+
Type["object"] = "object";
|
|
12
|
+
Type["undefined"] = "undefined";
|
|
13
|
+
Type["null"] = "null";
|
|
14
|
+
})(Type || (exports.Type = Type = {}));
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DType = exports.smbl_tm = void 0;
|
|
4
|
+
const types_1 = require("../../const/types");
|
|
5
|
+
const xjs_err_1 = require("../../obj/xjs-err");
|
|
6
|
+
const u_type_1 = require("../u-type");
|
|
7
|
+
const s_errCode = 30;
|
|
8
|
+
exports.smbl_tm = Symbol.for("xjs:typeMap");
|
|
9
|
+
/**
|
|
10
|
+
* decorators to be validated by {@link UType.validate},
|
|
11
|
+
* and to be cropped by {@link UObj.crop}.
|
|
12
|
+
*/
|
|
13
|
+
var DType;
|
|
14
|
+
(function (DType) {
|
|
15
|
+
/** express `string` property. */
|
|
16
|
+
function string(target, propKey) {
|
|
17
|
+
setTypeDesc(target, propKey, types_1.Type.string);
|
|
18
|
+
}
|
|
19
|
+
DType.string = string;
|
|
20
|
+
/** express `number` property. */
|
|
21
|
+
function number(target, propKey) {
|
|
22
|
+
setTypeDesc(target, propKey, types_1.Type.number);
|
|
23
|
+
}
|
|
24
|
+
DType.number = number;
|
|
25
|
+
/** express `boolean` property. */
|
|
26
|
+
function boolean(target, propKey) {
|
|
27
|
+
setTypeDesc(target, propKey, types_1.Type.boolean);
|
|
28
|
+
}
|
|
29
|
+
DType.boolean = boolean;
|
|
30
|
+
function setTypeDesc(target, propKey, t) {
|
|
31
|
+
setDesc(target, propKey, (td) => {
|
|
32
|
+
if (td.t)
|
|
33
|
+
throw new xjs_err_1.XjsErr(s_errCode, "decorator to express type is duplicate.");
|
|
34
|
+
td.t = t;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** express required property. */
|
|
38
|
+
function required(target, propKey) {
|
|
39
|
+
setDesc(target, propKey, (td) => td.req = true);
|
|
40
|
+
}
|
|
41
|
+
DType.required = required;
|
|
42
|
+
/**
|
|
43
|
+
* express array.
|
|
44
|
+
* @param elmDesc {@link TypeDesc} or class constructor type.
|
|
45
|
+
*/
|
|
46
|
+
function array(elmDesc = {}) {
|
|
47
|
+
return (target, propKey) => setDesc(target, propKey, (td) => u_type_1.UType.isFunction(elmDesc) ? td.ary = { cls: elmDesc } : td.ary = elmDesc);
|
|
48
|
+
}
|
|
49
|
+
DType.array = array;
|
|
50
|
+
/**
|
|
51
|
+
* express record object. note that this may allow array type because array is essentialy object type has properties.
|
|
52
|
+
* @param elmDesc {@link TypeDesc} or class constructor type.
|
|
53
|
+
*/
|
|
54
|
+
function record(elmDesc = {}) {
|
|
55
|
+
return (target, propKey) => setDesc(target, propKey, (td) => u_type_1.UType.isFunction(elmDesc) ? td.rcd = { cls: elmDesc } : td.rcd = elmDesc);
|
|
56
|
+
}
|
|
57
|
+
DType.record = record;
|
|
58
|
+
/**
|
|
59
|
+
* express an object which has properties that specified class express with {@link DType}.
|
|
60
|
+
* @param ctor class constructor type.
|
|
61
|
+
*/
|
|
62
|
+
function object(ctor) {
|
|
63
|
+
return (target, propKey) => setDesc(target, propKey, (td) => td.cls = ctor);
|
|
64
|
+
}
|
|
65
|
+
DType.object = object;
|
|
66
|
+
function keep(target, propKey) {
|
|
67
|
+
setDesc(target, propKey, (_) => { });
|
|
68
|
+
}
|
|
69
|
+
DType.keep = keep;
|
|
70
|
+
function setDesc(target, propKey, setter) {
|
|
71
|
+
const map = target[exports.smbl_tm] ? Object.assign({}, target[exports.smbl_tm]) : {};
|
|
72
|
+
map[propKey] ??= { t: null, req: false, cls: null, ary: null, rcd: null };
|
|
73
|
+
const td = map[propKey];
|
|
74
|
+
setter(td);
|
|
75
|
+
const structualDescs = [[td.ary, "array"], [td.cls, "class"], [td.rcd, "record"]].filter(e => e[0]);
|
|
76
|
+
if (structualDescs.length > 0) {
|
|
77
|
+
let ex1 = null, ex2 = null;
|
|
78
|
+
if (td.t) {
|
|
79
|
+
ex1 = "type";
|
|
80
|
+
ex2 = structualDescs[0][1];
|
|
81
|
+
}
|
|
82
|
+
if (structualDescs.length > 1) {
|
|
83
|
+
ex1 = structualDescs[0][1];
|
|
84
|
+
ex2 = structualDescs[1][1];
|
|
85
|
+
}
|
|
86
|
+
if (ex1 && ex2)
|
|
87
|
+
throw new xjs_err_1.XjsErr(s_errCode, `decorator to express ${ex1} and ${ex2} are exclusive.`);
|
|
88
|
+
}
|
|
89
|
+
Object.defineProperty(target, exports.smbl_tm, { value: map, configurable: true });
|
|
90
|
+
}
|
|
91
|
+
})(DType || (exports.DType = DType = {}));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transaction = transaction;
|
|
4
|
+
const xjs_err_1 = require("../../obj/xjs-err");
|
|
5
|
+
const u_1 = require("../u");
|
|
6
|
+
const s_errCode = 100;
|
|
7
|
+
/**
|
|
8
|
+
* applies transation to the method. note that the method must return a Promise.
|
|
9
|
+
* @param op.timeoutSec default is `30`.
|
|
10
|
+
*/
|
|
11
|
+
function transaction(op) {
|
|
12
|
+
let lock = 0;
|
|
13
|
+
const timeoutSec = op?.timeoutSec ?? 30;
|
|
14
|
+
return (target, propertyKey, descriptor) => {
|
|
15
|
+
const method = descriptor.value;
|
|
16
|
+
async function exe(...p) {
|
|
17
|
+
const timelimit = Date.now() + timeoutSec * 1000;
|
|
18
|
+
while (lock > 0) {
|
|
19
|
+
if (timelimit <= Date.now())
|
|
20
|
+
throw new xjs_err_1.XjsErr(s_errCode, "An exclusive process to execute was already running by other request.");
|
|
21
|
+
await (0, u_1.delay)(1);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
lock++;
|
|
25
|
+
const ret = method.apply(this, p);
|
|
26
|
+
return ret instanceof Promise ? await ret : ret;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
lock--;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
;
|
|
33
|
+
descriptor.value = exe;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UArray = void 0;
|
|
4
|
+
const u_1 = require("./u");
|
|
5
|
+
var UArray;
|
|
6
|
+
(function (UArray) {
|
|
7
|
+
/**
|
|
8
|
+
* compares two arrays to valuate equality.
|
|
9
|
+
* if one side is null or undefined, it returns true when other side is the same.
|
|
10
|
+
* this function has compatibility {@link AlmostArray} like {@link Uint8Array} etc.
|
|
11
|
+
* @param v1 it uses equal operator for comparing elements, so applying object element is not recommended.
|
|
12
|
+
* @param v2 same as v1.
|
|
13
|
+
* @param sort it uses {@link Array.sort()} on v1 and v2 if true. default is true.
|
|
14
|
+
* @param useStrictEqual check equality whether {@link Array} or not and it uses `===` operator for compareing elements if true, otherwise using `==` operator. default is true.
|
|
15
|
+
*/
|
|
16
|
+
function eq(v1, v2, op = {}) {
|
|
17
|
+
const { sort, useStrictEqual } = Object.assign({ sort: true, useStrictEqual: true }, op);
|
|
18
|
+
if (v1 && !v2 || !v1 && v2)
|
|
19
|
+
return false;
|
|
20
|
+
if (!v1)
|
|
21
|
+
return true;
|
|
22
|
+
if (v1.length !== v2.length)
|
|
23
|
+
return false;
|
|
24
|
+
if (useStrictEqual && v1 instanceof Array !== v2 instanceof Array)
|
|
25
|
+
return false;
|
|
26
|
+
const a = sort ? v1.slice().sort() : v1, b = sort ? v2.slice().sort() : v2;
|
|
27
|
+
return a.every((v, i) => useStrictEqual ? v === b[i] : v == b[i]);
|
|
28
|
+
}
|
|
29
|
+
UArray.eq = eq;
|
|
30
|
+
function distinct(array, op) {
|
|
31
|
+
if (!array || array.length === 0)
|
|
32
|
+
return [];
|
|
33
|
+
if (op?.k)
|
|
34
|
+
return Array.from((0, u_1.array2map)(array, e => e[op.k]).values()).map(a => op?.takeLast ? a.pop() : a.shift());
|
|
35
|
+
const a = op?.takeLast ? [...array].reverse() : [...array];
|
|
36
|
+
const p = op?.predicate ?? ((v1, v2) => v1 == v2);
|
|
37
|
+
const result = [a.shift()];
|
|
38
|
+
a.forEach(v => result.some(v2 => p(v, v2)) ? {} : result.push(v));
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
UArray.distinct = distinct;
|
|
42
|
+
function chop(array, len) {
|
|
43
|
+
return [...Array(Math.ceil(array.length / len)).keys()]
|
|
44
|
+
.map(i => {
|
|
45
|
+
let endIdx = (i + 1) * len;
|
|
46
|
+
if (endIdx > array.length)
|
|
47
|
+
endIdx = array.length;
|
|
48
|
+
return array.slice(i * len, endIdx);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
UArray.chop = chop;
|
|
52
|
+
function remove(array, v) {
|
|
53
|
+
const idx = array.indexOf(v);
|
|
54
|
+
if (idx !== -1)
|
|
55
|
+
array.splice(idx, 1);
|
|
56
|
+
}
|
|
57
|
+
UArray.remove = remove;
|
|
58
|
+
function randomPick(array, takeout = true) {
|
|
59
|
+
const i = Math.floor(array.length * Math.random());
|
|
60
|
+
const r = array[i];
|
|
61
|
+
if (takeout)
|
|
62
|
+
array.splice(i, 1);
|
|
63
|
+
return r;
|
|
64
|
+
}
|
|
65
|
+
UArray.randomPick = randomPick;
|
|
66
|
+
function shuffle(array) {
|
|
67
|
+
const cp = [...array];
|
|
68
|
+
return (0, u_1.int2array)(array.length).map(_ => randomPick(cp));
|
|
69
|
+
}
|
|
70
|
+
UArray.shuffle = shuffle;
|
|
71
|
+
function takeOut(array, filter) {
|
|
72
|
+
const result = [];
|
|
73
|
+
for (let i = array.length - 1; i >= 0; i--)
|
|
74
|
+
if (filter(array[i], i)) {
|
|
75
|
+
result.unshift(array[i]);
|
|
76
|
+
array.splice(i, 1);
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
UArray.takeOut = takeOut;
|
|
81
|
+
})(UArray || (exports.UArray = UArray = {}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UHttp = void 0;
|
|
4
|
+
var UHttp;
|
|
5
|
+
(function (UHttp) {
|
|
6
|
+
function isHttpSuccess(statusCode) {
|
|
7
|
+
return statusCategoryOf(statusCode) === 2;
|
|
8
|
+
}
|
|
9
|
+
UHttp.isHttpSuccess = isHttpSuccess;
|
|
10
|
+
function statusCategoryOf(statusCode) {
|
|
11
|
+
return Math.floor(statusCode / 100);
|
|
12
|
+
}
|
|
13
|
+
UHttp.statusCategoryOf = statusCategoryOf;
|
|
14
|
+
function concatParamsWithEncoding(end, params) {
|
|
15
|
+
if (!params || Object.keys(params).length === 0)
|
|
16
|
+
return end;
|
|
17
|
+
const paramsFlatten = Object.entries(params)
|
|
18
|
+
.flatMap(kv => Array.isArray(kv[1]) ? kv[1].map(v => [kv[0], v]) : [kv]);
|
|
19
|
+
let result = end ? end + "?" : "";
|
|
20
|
+
for (var kv of paramsFlatten)
|
|
21
|
+
result += kv[0] + "=" + encodeURIComponent(kv[1]) + "&";
|
|
22
|
+
return result.substring(0, result.length - 1);
|
|
23
|
+
}
|
|
24
|
+
UHttp.concatParamsWithEncoding = concatParamsWithEncoding;
|
|
25
|
+
/** normalize object keys to lower case. */
|
|
26
|
+
function normalizeHeaders(headers) {
|
|
27
|
+
if (!headers)
|
|
28
|
+
return {};
|
|
29
|
+
return Object.entries(headers).reduce((a, b) => { a[b[0].toLowerCase()] = b[1]; return a; }, {});
|
|
30
|
+
}
|
|
31
|
+
UHttp.normalizeHeaders = normalizeHeaders;
|
|
32
|
+
})(UHttp || (exports.UHttp = UHttp = {}));
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UObj = void 0;
|
|
4
|
+
const d_type_1 = require("./decorator/d-type");
|
|
5
|
+
const u_type_1 = require("./u-type");
|
|
6
|
+
var UObj;
|
|
7
|
+
(function (UObj) {
|
|
8
|
+
/**
|
|
9
|
+
* assign properties to the object with specified property keys.
|
|
10
|
+
* @param t target object.
|
|
11
|
+
* @param s source object.
|
|
12
|
+
* @param keys property keys which are copied from source object. if omit this, all keys in source object is applied.
|
|
13
|
+
* @param keepDtypeClass if true, class which has properties decorated with {@link DType} in target object is kept and that is assigned properties recursively.
|
|
14
|
+
*/
|
|
15
|
+
function assignProperties(t, s, keys, keepDtypeClass) {
|
|
16
|
+
for (const k of keys ?? Object.keys(s))
|
|
17
|
+
if (u_type_1.UType.isDefined(s[k]))
|
|
18
|
+
if (keepDtypeClass && u_type_1.UType.isObject(t[k]) && u_type_1.UType.isObject(s[k]) && t[k]?.[d_type_1.smbl_tm]) {
|
|
19
|
+
assignProperties(t[k], s[k], null, true);
|
|
20
|
+
}
|
|
21
|
+
else
|
|
22
|
+
t[k] = s[k];
|
|
23
|
+
return t;
|
|
24
|
+
}
|
|
25
|
+
UObj.assignProperties = assignProperties;
|
|
26
|
+
function crop(o, keys_or_ctor, removeKeys) {
|
|
27
|
+
const tm = Array.isArray(keys_or_ctor) ? null
|
|
28
|
+
: (!keys_or_ctor || o instanceof keys_or_ctor ? o[d_type_1.smbl_tm] : new keys_or_ctor()[d_type_1.smbl_tm]);
|
|
29
|
+
const _keys = tm ? Object.keys(tm) : (keys_or_ctor ?? []);
|
|
30
|
+
if (_keys.length === 0)
|
|
31
|
+
return removeKeys ? o : {};
|
|
32
|
+
Object.keys(o).filter(k => {
|
|
33
|
+
if (tm && tm[k] && o[k]) {
|
|
34
|
+
if (tm[k].cls)
|
|
35
|
+
crop(o[k], tm[k]?.cls);
|
|
36
|
+
else {
|
|
37
|
+
const vCtor = tm[k].ary?.cls ?? tm[k].rcd?.cls;
|
|
38
|
+
Object.values(o[k]).forEach(v => crop(v, vCtor));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return !!removeKeys === _keys.includes(k);
|
|
42
|
+
}).forEach(k => delete o[k]);
|
|
43
|
+
return o;
|
|
44
|
+
}
|
|
45
|
+
UObj.crop = crop;
|
|
46
|
+
/**
|
|
47
|
+
* manipulate properties of an object.
|
|
48
|
+
* as default if the properties contains object, it also manipulates properties of that recursively.
|
|
49
|
+
* @param o object whose properties the process applies to.
|
|
50
|
+
* @param process process to be applied to properties of the object. note that function property is not included in the properties.
|
|
51
|
+
* @param op.ignoreEmpty skip null or undefined properties to manipuldate. default is true.
|
|
52
|
+
* @param op.recursive whether it manipulate properties of an object recursively. default is true.
|
|
53
|
+
* @param op.targetType primitive types which filter the properties to be processed.
|
|
54
|
+
*/
|
|
55
|
+
function manipulateProperties(o, process, op) {
|
|
56
|
+
const target = op?.targetType && u_type_1.UType.takeAsArray(op?.targetType);
|
|
57
|
+
const _ignoreEmpty = !u_type_1.UType.isDefined(op?.ignoreEmpty) || op?.ignoreEmpty;
|
|
58
|
+
const _recursive = !u_type_1.UType.isDefined(op?.recursive) || op?.recursive;
|
|
59
|
+
const rec = (_o) => {
|
|
60
|
+
for (const k in _o) {
|
|
61
|
+
const prop = _o[k];
|
|
62
|
+
if (_ignoreEmpty && u_type_1.UType.isEmpty(prop))
|
|
63
|
+
continue;
|
|
64
|
+
if (u_type_1.UType.isObject(prop) && _recursive)
|
|
65
|
+
rec(prop);
|
|
66
|
+
else if (!u_type_1.UType.isFunction(prop) && (!target || target.some(t => typeof prop === t)))
|
|
67
|
+
_o[k] = process(prop);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
rec(o);
|
|
71
|
+
return o;
|
|
72
|
+
}
|
|
73
|
+
UObj.manipulateProperties = manipulateProperties;
|
|
74
|
+
})(UObj || (exports.UObj = UObj = {}));
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UString = void 0;
|
|
4
|
+
const time_unit_1 = require("../const/time-unit");
|
|
5
|
+
const xjs_err_1 = require("../obj/xjs-err");
|
|
6
|
+
const u_1 = require("./u");
|
|
7
|
+
const u_type_1 = require("./u-type");
|
|
8
|
+
const s_errCode = 20;
|
|
9
|
+
var UString;
|
|
10
|
+
(function (UString) {
|
|
11
|
+
function eq(s1, s2) {
|
|
12
|
+
return !u_type_1.UType.isString(s1) || !u_type_1.UType.isString(s2) ? s1 === s2 : s1.trim() === s2.trim();
|
|
13
|
+
}
|
|
14
|
+
UString.eq = eq;
|
|
15
|
+
function repeat(token, mlt) {
|
|
16
|
+
return (0, u_1.int2array)(mlt).map(_ => token).join("");
|
|
17
|
+
}
|
|
18
|
+
UString.repeat = repeat;
|
|
19
|
+
/**
|
|
20
|
+
* generate date time number as fixed length (depends on `unit`) string without separator charactor.
|
|
21
|
+
* For example, `2025-06-08T10:15:06.366Z` is to be `20250608101506366`.
|
|
22
|
+
* @param op.date Date object refered by this. default is `new Date()`.
|
|
23
|
+
* @param op.unit time unit. default is secound.
|
|
24
|
+
*/
|
|
25
|
+
function simpleTime(op) {
|
|
26
|
+
const t = (op?.date ?? new Date()).toISOString().split(".")[0].replace(/[-T:]/g, "");
|
|
27
|
+
if (op?.unit === time_unit_1.TimeUnit.Msec)
|
|
28
|
+
return t;
|
|
29
|
+
return t.substring(0, 14 - (6 - (op?.unit ?? time_unit_1.TimeUnit.Sec)) * 2);
|
|
30
|
+
}
|
|
31
|
+
UString.simpleTime = simpleTime;
|
|
32
|
+
function generateRandomString(len) {
|
|
33
|
+
return (0, u_1.int2array)(len).map(_ => {
|
|
34
|
+
let rnd = Math.floor(62 * Math.random());
|
|
35
|
+
const remain = rnd - 52;
|
|
36
|
+
if (remain >= 0)
|
|
37
|
+
return remain.toString();
|
|
38
|
+
if (rnd > 26)
|
|
39
|
+
rnd += 6;
|
|
40
|
+
return String.fromCharCode(rnd + 65);
|
|
41
|
+
}).join("");
|
|
42
|
+
}
|
|
43
|
+
UString.generateRandomString = generateRandomString;
|
|
44
|
+
function idx2az(idx) {
|
|
45
|
+
let az = "", num = idx;
|
|
46
|
+
while (num >= 0) {
|
|
47
|
+
az = String.fromCharCode(num % 26 + 97) + az;
|
|
48
|
+
num = Math.floor(num / 26) - 1;
|
|
49
|
+
}
|
|
50
|
+
return az.toUpperCase();
|
|
51
|
+
}
|
|
52
|
+
UString.idx2az = idx2az;
|
|
53
|
+
function az2idx(az) {
|
|
54
|
+
if (!az?.match(/^[a-zA-Z]+$/))
|
|
55
|
+
throw new xjs_err_1.XjsErr(s_errCode, "the parameter isn't az(AZ) format.");
|
|
56
|
+
return az.toLowerCase().split("").map(c => c.charCodeAt(0) - 97).reverse()
|
|
57
|
+
.map((idx, i) => (idx + 1) * (26 ** i)).reduce((v1, v2) => v1 + v2) - 1;
|
|
58
|
+
}
|
|
59
|
+
UString.az2idx = az2idx;
|
|
60
|
+
function asAmount(amount, unit) {
|
|
61
|
+
const int2dec = amount.toString().split(".");
|
|
62
|
+
const etni = int2dec[0].split("").reverse().join("");
|
|
63
|
+
let fetni = "";
|
|
64
|
+
const max = Math.ceil(etni.length / 3);
|
|
65
|
+
for (let i = 0; i < max; i++) {
|
|
66
|
+
if (i === max - 1)
|
|
67
|
+
fetni += etni.substring(i * 3);
|
|
68
|
+
else
|
|
69
|
+
fetni += (etni.substring(i * 3, (i + 1) * 3) + ",");
|
|
70
|
+
}
|
|
71
|
+
const finte = unit + fetni.split("").reverse().join("");
|
|
72
|
+
if (int2dec.length === 1)
|
|
73
|
+
return finte;
|
|
74
|
+
else
|
|
75
|
+
return finte + "." + int2dec[1];
|
|
76
|
+
}
|
|
77
|
+
function asJpy(amount) {
|
|
78
|
+
return u_type_1.UType.isEmpty(amount) ? "" : asAmount(Math.floor(amount), "¥");
|
|
79
|
+
}
|
|
80
|
+
UString.asJpy = asJpy;
|
|
81
|
+
function asUsd(amount) {
|
|
82
|
+
return u_type_1.UType.isEmpty(amount) ? "" : asAmount(Number(amount.toFixed(2)), "$");
|
|
83
|
+
}
|
|
84
|
+
UString.asUsd = asUsd;
|
|
85
|
+
function asPercentage(amount) {
|
|
86
|
+
if (u_type_1.UType.isEmpty(amount))
|
|
87
|
+
return "";
|
|
88
|
+
let percent = (amount * 100).toFixed(2);
|
|
89
|
+
while (percent.endsWith("0"))
|
|
90
|
+
percent = percent.substring(0, percent.length - 1);
|
|
91
|
+
if (percent.endsWith("."))
|
|
92
|
+
percent = percent.substring(0, percent.length - 1);
|
|
93
|
+
return percent + "%";
|
|
94
|
+
}
|
|
95
|
+
UString.asPercentage = asPercentage;
|
|
96
|
+
function is_yyyy(v) {
|
|
97
|
+
return !!v?.match(/^[1-9]\d{3}$/);
|
|
98
|
+
}
|
|
99
|
+
UString.is_yyyy = is_yyyy;
|
|
100
|
+
function is_yyyyMM(v) {
|
|
101
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])$/);
|
|
102
|
+
}
|
|
103
|
+
UString.is_yyyyMM = is_yyyyMM;
|
|
104
|
+
function is_yyyyMMdd(v) {
|
|
105
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])$/);
|
|
106
|
+
}
|
|
107
|
+
UString.is_yyyyMMdd = is_yyyyMMdd;
|
|
108
|
+
function is_yyyyMMddhh(v) {
|
|
109
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])([01]\d|2[0-3])$/);
|
|
110
|
+
}
|
|
111
|
+
UString.is_yyyyMMddhh = is_yyyyMMddhh;
|
|
112
|
+
function is_yyyyMMddhhmm(v) {
|
|
113
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])([01]\d|2[0-3])[0-5]\d$/);
|
|
114
|
+
}
|
|
115
|
+
UString.is_yyyyMMddhhmm = is_yyyyMMddhhmm;
|
|
116
|
+
function is_yyyyMMddhhmmss(v) {
|
|
117
|
+
return !!v?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])([01]\d|2[0-3])[0-5]\d[0-5]\d$/);
|
|
118
|
+
}
|
|
119
|
+
UString.is_yyyyMMddhhmmss = is_yyyyMMddhhmmss;
|
|
120
|
+
})(UString || (exports.UString = UString = {}));
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UType = void 0;
|
|
4
|
+
const types_1 = require("../const/types");
|
|
5
|
+
const d_type_1 = require("./decorator/d-type");
|
|
6
|
+
var UType;
|
|
7
|
+
(function (UType) {
|
|
8
|
+
function isDefined(v) {
|
|
9
|
+
return typeof v !== types_1.Type.undefined;
|
|
10
|
+
}
|
|
11
|
+
UType.isDefined = isDefined;
|
|
12
|
+
function isEmpty(v) {
|
|
13
|
+
return v === null || typeof v === types_1.Type.undefined;
|
|
14
|
+
}
|
|
15
|
+
UType.isEmpty = isEmpty;
|
|
16
|
+
function isString(v) { return typeof v === types_1.Type.string; }
|
|
17
|
+
UType.isString = isString;
|
|
18
|
+
function isNumber(v) { return typeof v === types_1.Type.number; }
|
|
19
|
+
UType.isNumber = isNumber;
|
|
20
|
+
function isBigint(v) { return typeof v === types_1.Type.bigint; }
|
|
21
|
+
UType.isBigint = isBigint;
|
|
22
|
+
function isBoolean(v) { return typeof v === types_1.Type.boolean; }
|
|
23
|
+
UType.isBoolean = isBoolean;
|
|
24
|
+
function isSymbol(v) { return typeof v === types_1.Type.symbol; }
|
|
25
|
+
UType.isSymbol = isSymbol;
|
|
26
|
+
function isObject(v) { return typeof v === types_1.Type.object; }
|
|
27
|
+
UType.isObject = isObject;
|
|
28
|
+
function isFunction(v) { return typeof v === "function"; }
|
|
29
|
+
UType.isFunction = isFunction;
|
|
30
|
+
function isArray(v, t) {
|
|
31
|
+
return Array.isArray(v) && (!t || v.every(e => typeof e === t));
|
|
32
|
+
}
|
|
33
|
+
UType.isArray = isArray;
|
|
34
|
+
/**
|
|
35
|
+
* validate properties decorated with {@link DType}.
|
|
36
|
+
* @param o object to be validated. if this is class object decorated with {@link DType}, it can omits `ctor` parameter.
|
|
37
|
+
* @param ctor class constructor type whose properties are decorated. **NOTE** that need to have public constructor without any parameter.
|
|
38
|
+
* @returns invalid property keys. returns an empty array if `o` is valid.
|
|
39
|
+
*/
|
|
40
|
+
function validate(o, ctor) {
|
|
41
|
+
const _o = (!ctor || o instanceof ctor) ? o : Object.assign(new ctor(), o);
|
|
42
|
+
if (!_o[d_type_1.smbl_tm])
|
|
43
|
+
return [];
|
|
44
|
+
return Object.entries(_o[d_type_1.smbl_tm]).flatMap(e => validateProp(e[0], _o[e[0]], e[1]));
|
|
45
|
+
}
|
|
46
|
+
UType.validate = validate;
|
|
47
|
+
function validateProp(k, prop, td) {
|
|
48
|
+
if (isEmpty(prop))
|
|
49
|
+
return td.req ? [k] : [];
|
|
50
|
+
if (td.t && typeof prop !== td.t)
|
|
51
|
+
return [k];
|
|
52
|
+
const joinKey = (k2) => `${k}.${k2}`;
|
|
53
|
+
if (td.ary)
|
|
54
|
+
return Array.isArray(prop)
|
|
55
|
+
? prop.flatMap((e, i) => validateProp(i.toString(), e, td.ary)).map(joinKey) : [k];
|
|
56
|
+
if (td.rcd)
|
|
57
|
+
return UType.isObject(prop)
|
|
58
|
+
? Object.entries(prop).flatMap(e => validateProp(e[0], e[1], td.rcd)).map(joinKey) : [k];
|
|
59
|
+
if (td.cls)
|
|
60
|
+
return validate(prop, td.cls).flatMap(joinKey);
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
function takeAsArray(v) {
|
|
64
|
+
return Array.isArray(v) ? v : [v];
|
|
65
|
+
}
|
|
66
|
+
UType.takeAsArray = takeAsArray;
|
|
67
|
+
})(UType || (exports.UType = UType = {}));
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getJSTDate = getJSTDate;
|
|
4
|
+
exports.delay = delay;
|
|
5
|
+
exports.int2array = int2array;
|
|
6
|
+
exports.array2map = array2map;
|
|
7
|
+
exports.bitor = bitor;
|
|
8
|
+
exports.retry = retry;
|
|
9
|
+
const xjs_err_1 = require("../obj/xjs-err");
|
|
10
|
+
const s_errCode = 10;
|
|
11
|
+
function getJSTDate(d) {
|
|
12
|
+
return new Date((d ? d.getTime() : Date.now()) + 9 * 60 * 60 * 1000);
|
|
13
|
+
}
|
|
14
|
+
function delay(sec) {
|
|
15
|
+
return new Promise(resolve => setTimeout(resolve, 1000 * sec));
|
|
16
|
+
}
|
|
17
|
+
function int2array(size) {
|
|
18
|
+
const s = Number(size);
|
|
19
|
+
if (Number.isNaN(s))
|
|
20
|
+
throw new xjs_err_1.XjsErr(s_errCode, "size of the argument is not number.");
|
|
21
|
+
return Array.from(Array(s).keys());
|
|
22
|
+
}
|
|
23
|
+
function array2map(array, keyGen) {
|
|
24
|
+
const map = new Map();
|
|
25
|
+
for (const e of array) {
|
|
26
|
+
const k = keyGen(e);
|
|
27
|
+
if (map.has(k))
|
|
28
|
+
map.get(k).push(e);
|
|
29
|
+
else
|
|
30
|
+
map.set(k, [e]);
|
|
31
|
+
}
|
|
32
|
+
return map;
|
|
33
|
+
}
|
|
34
|
+
function bitor(...bit) {
|
|
35
|
+
return bit.reduce((a, b) => a | b);
|
|
36
|
+
}
|
|
37
|
+
;
|
|
38
|
+
;
|
|
39
|
+
;
|
|
40
|
+
function retry(cb, op) {
|
|
41
|
+
const l = op?.logger ?? console;
|
|
42
|
+
const initialCount = op?.count ?? 1;
|
|
43
|
+
const handleError = (e) => {
|
|
44
|
+
if (op?.errorCriterion && !op.errorCriterion(e))
|
|
45
|
+
return false;
|
|
46
|
+
l.warn(e);
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
const prcs = (c) => {
|
|
50
|
+
if (c < 0)
|
|
51
|
+
throw new xjs_err_1.XjsErr(s_errCode, "failure exceeds retryable count.");
|
|
52
|
+
let ret = null;
|
|
53
|
+
const innerPrcs = () => {
|
|
54
|
+
try {
|
|
55
|
+
ret = cb();
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
if (handleError(e))
|
|
59
|
+
ret = prcs(c - 1);
|
|
60
|
+
else
|
|
61
|
+
throw e;
|
|
62
|
+
}
|
|
63
|
+
if (ret instanceof Promise) {
|
|
64
|
+
return new Promise((resolve, reject) => ret.then(resolve).catch((e) => { if (handleError(e))
|
|
65
|
+
resolve(prcs(c - 1));
|
|
66
|
+
else
|
|
67
|
+
reject(e); }));
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
return ret;
|
|
71
|
+
};
|
|
72
|
+
const chain = (c) => ret instanceof Promise ? ret.then(() => c()) : c();
|
|
73
|
+
if (c < initialCount) {
|
|
74
|
+
if (op?.intervalPredicate)
|
|
75
|
+
ret = op?.intervalPredicate();
|
|
76
|
+
const intervalSec = op?.intervalSec;
|
|
77
|
+
if (intervalSec)
|
|
78
|
+
ret = chain(() => delay(intervalSec));
|
|
79
|
+
}
|
|
80
|
+
return chain(innerPrcs);
|
|
81
|
+
};
|
|
82
|
+
return prcs(initialCount);
|
|
83
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.DType = void 0;
|
|
18
|
+
__exportStar(require("./const/types"), exports);
|
|
19
|
+
__exportStar(require("./const/time-unit"), exports);
|
|
20
|
+
__exportStar(require("./const/http-method"), exports);
|
|
21
|
+
__exportStar(require("./func/u"), exports);
|
|
22
|
+
__exportStar(require("./func/u-obj"), exports);
|
|
23
|
+
__exportStar(require("./func/u-string"), exports);
|
|
24
|
+
__exportStar(require("./func/u-array"), exports);
|
|
25
|
+
__exportStar(require("./func/u-http"), exports);
|
|
26
|
+
__exportStar(require("./func/u-type"), exports);
|
|
27
|
+
__exportStar(require("./func/decorator/transaction"), exports);
|
|
28
|
+
var d_type_1 = require("./func/decorator/d-type");
|
|
29
|
+
Object.defineProperty(exports, "DType", { enumerable: true, get: function () { return d_type_1.DType; } });
|
|
30
|
+
__exportStar(require("./obj/xjs-err"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XjsErr = void 0;
|
|
4
|
+
class XjsErr extends Error {
|
|
5
|
+
code;
|
|
6
|
+
origin;
|
|
7
|
+
constructor(code, msg, origin) {
|
|
8
|
+
super(`[XJS] ${msg}`);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.origin = origin;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.XjsErr = XjsErr;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xjs-common",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.3",
|
|
4
4
|
"description": "library modules for typescript that bundled general-purpose implementations.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,22 +12,28 @@
|
|
|
12
12
|
"utility"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "rm -rdf ./build && tsc",
|
|
15
|
+
"build": "rm -rdf ./build && tsc && tsc -p ./tsconfig.cjs.json",
|
|
16
16
|
"test": "tsx ./src/test/test.ts"
|
|
17
17
|
},
|
|
18
18
|
"author": "begyyal",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"files": [
|
|
21
21
|
"build",
|
|
22
|
-
"!/build
|
|
22
|
+
"!/build/**/test*"
|
|
23
23
|
],
|
|
24
|
-
"main": "./build/index",
|
|
25
|
-
"types": "./build/index.d.ts",
|
|
24
|
+
"main": "./build/esm/index.js",
|
|
25
|
+
"types": "./build/esm/index.d.ts",
|
|
26
26
|
"exports": {
|
|
27
|
-
".":
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./build/esm/index.ts",
|
|
30
|
+
"default": "./build/esm/index.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./build/esm/index.ts",
|
|
34
|
+
"default": "./build/cjs/index.js"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
31
37
|
},
|
|
32
38
|
"devDependencies": {
|
|
33
39
|
"@types/node": "^24.2.1",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|