@wexample/js-helpers 0.0.22 → 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.
- package/README.md +1 -1
- package/dist/Common/AsyncConstructor.js +39 -44
- package/dist/Common/AsyncConstructor.js.map +1 -1
- package/dist/Helper/Array.js +18 -19
- package/dist/Helper/Array.js.map +1 -1
- package/dist/Helper/Bytes.js +9 -13
- package/dist/Helper/Bytes.js.map +1 -1
- package/dist/Helper/Dom.js +61 -58
- package/dist/Helper/Dom.js.map +1 -1
- package/dist/Helper/Event.js +27 -31
- package/dist/Helper/Event.js.map +1 -1
- package/dist/Helper/Function.js +2 -6
- package/dist/Helper/Function.js.map +1 -1
- package/dist/Helper/KeyCode.js +2 -6
- package/dist/Helper/KeyCode.js.map +1 -1
- package/dist/Helper/Location.js +41 -43
- package/dist/Helper/Location.js.map +1 -1
- package/dist/Helper/Log.js +21 -25
- package/dist/Helper/Log.js.map +1 -1
- package/dist/Helper/Mixin.js +26 -24
- package/dist/Helper/Mixin.js.map +1 -1
- package/dist/Helper/Object.js +81 -86
- package/dist/Helper/Object.js.map +1 -1
- package/dist/Helper/Pointer.js +2 -6
- package/dist/Helper/Pointer.js.map +1 -1
- package/dist/Helper/Queue.js +72 -74
- package/dist/Helper/Queue.js.map +1 -1
- package/dist/Helper/String.js +250 -200
- package/dist/Helper/String.js.map +1 -1
- package/dist/Helper/Time.js +4 -8
- package/dist/Helper/Time.js.map +1 -1
- package/dist/Helper/Url.js +14 -18
- package/dist/Helper/Url.js.map +1 -1
- package/dist/Helper/Variables.js +9 -13
- package/dist/Helper/Variables.js.map +1 -1
- package/package.json +4 -11
- package/dist/Common/AsyncConstructor.cjs +0 -49
- package/dist/Common/AsyncConstructor.cjs.map +0 -1
- package/dist/Common/AsyncConstructor.d.cts +0 -13
- package/dist/Common/AsyncConstructor.d.ts +0 -13
- package/dist/Helper/Array.cjs +0 -33
- package/dist/Helper/Array.cjs.map +0 -1
- package/dist/Helper/Array.d.cts +0 -11
- package/dist/Helper/Array.d.ts +0 -11
- package/dist/Helper/Bytes.cjs +0 -17
- package/dist/Helper/Bytes.cjs.map +0 -1
- package/dist/Helper/Bytes.d.cts +0 -3
- package/dist/Helper/Bytes.d.ts +0 -3
- package/dist/Helper/Dom.cjs +0 -83
- package/dist/Helper/Dom.cjs.map +0 -1
- package/dist/Helper/Dom.d.cts +0 -32
- package/dist/Helper/Dom.d.ts +0 -32
- package/dist/Helper/Event.cjs +0 -35
- package/dist/Helper/Event.cjs.map +0 -1
- package/dist/Helper/Event.d.cts +0 -31
- package/dist/Helper/Event.d.ts +0 -31
- package/dist/Helper/Function.cjs +0 -10
- package/dist/Helper/Function.cjs.map +0 -1
- package/dist/Helper/Function.d.cts +0 -3
- package/dist/Helper/Function.d.ts +0 -3
- package/dist/Helper/KeyCode.cjs +0 -10
- package/dist/Helper/KeyCode.cjs.map +0 -1
- package/dist/Helper/KeyCode.d.cts +0 -6
- package/dist/Helper/KeyCode.d.ts +0 -6
- package/dist/Helper/Location.cjs +0 -57
- package/dist/Helper/Location.cjs.map +0 -1
- package/dist/Helper/Location.d.cts +0 -9
- package/dist/Helper/Location.d.ts +0 -9
- package/dist/Helper/Log.cjs +0 -37
- package/dist/Helper/Log.cjs.map +0 -1
- package/dist/Helper/Log.d.cts +0 -19
- package/dist/Helper/Log.d.ts +0 -19
- package/dist/Helper/Mixin.cjs +0 -29
- package/dist/Helper/Mixin.cjs.map +0 -1
- package/dist/Helper/Mixin.d.cts +0 -8
- package/dist/Helper/Mixin.d.ts +0 -8
- package/dist/Helper/Object.cjs +0 -103
- package/dist/Helper/Object.cjs.map +0 -1
- package/dist/Helper/Object.d.cts +0 -14
- package/dist/Helper/Object.d.ts +0 -14
- package/dist/Helper/Pointer.cjs +0 -10
- package/dist/Helper/Pointer.cjs.map +0 -1
- package/dist/Helper/Pointer.d.cts +0 -5
- package/dist/Helper/Pointer.d.ts +0 -5
- package/dist/Helper/Queue.cjs +0 -84
- package/dist/Helper/Queue.cjs.map +0 -1
- package/dist/Helper/Queue.d.cts +0 -35
- package/dist/Helper/Queue.d.ts +0 -35
- package/dist/Helper/String.cjs +0 -253
- package/dist/Helper/String.cjs.map +0 -1
- package/dist/Helper/String.d.cts +0 -50
- package/dist/Helper/String.d.ts +0 -50
- package/dist/Helper/Time.cjs +0 -12
- package/dist/Helper/Time.cjs.map +0 -1
- package/dist/Helper/Time.d.cts +0 -3
- package/dist/Helper/Time.d.ts +0 -3
- package/dist/Helper/Url.cjs +0 -24
- package/dist/Helper/Url.cjs.map +0 -1
- package/dist/Helper/Url.d.cts +0 -4
- package/dist/Helper/Url.d.ts +0 -4
- package/dist/Helper/Variables.cjs +0 -20
- package/dist/Helper/Variables.cjs.map +0 -1
- package/dist/Helper/Variables.d.cts +0 -12
- package/dist/Helper/Variables.d.ts +0 -12
package/dist/Helper/Log.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/Helper/Log.ts
|
|
4
|
-
var COLORS = {
|
|
5
|
-
blue: "34",
|
|
6
|
-
cyan: "36",
|
|
7
|
-
gray: "90",
|
|
8
|
-
green: "32",
|
|
9
|
-
magenta: "35",
|
|
10
|
-
yellow: "33",
|
|
11
|
-
red: "31"
|
|
12
|
-
};
|
|
13
|
-
function logColor(text, colorCode = COLORS.gray) {
|
|
14
|
-
const resolved = typeof colorCode === "string" && colorCode in COLORS ? COLORS[colorCode] : colorCode || COLORS.gray;
|
|
15
|
-
return `\x1B[${resolved}m${text}\x1B[0m`;
|
|
16
|
-
}
|
|
17
|
-
function logTitle(title, colorCode = COLORS.cyan) {
|
|
18
|
-
console.log("");
|
|
19
|
-
console.log(logColor(`# ${String(title).toUpperCase()}`, colorCode));
|
|
20
|
-
}
|
|
21
|
-
function logPath(label, value, labelColor = COLORS.gray, valueColor = COLORS.yellow) {
|
|
22
|
-
console.log(`${logColor(label, labelColor)} ${logColor(value, valueColor)}`);
|
|
23
|
-
}
|
|
24
|
-
function logEntry(action, entry) {
|
|
25
|
-
console.log(
|
|
26
|
-
`${logColor("\u2022", COLORS.green)} ${logColor(action, COLORS.blue)} ${logColor(entry.output, COLORS.yellow)}`
|
|
27
|
-
);
|
|
28
|
-
console.log(` ${logColor("from", COLORS.gray)} ${logColor(entry.source, COLORS.gray)}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.COLORS = COLORS;
|
|
32
|
-
exports.logColor = logColor;
|
|
33
|
-
exports.logEntry = logEntry;
|
|
34
|
-
exports.logPath = logPath;
|
|
35
|
-
exports.logTitle = logTitle;
|
|
36
|
-
//# sourceMappingURL=Log.cjs.map
|
|
37
|
-
//# sourceMappingURL=Log.cjs.map
|
package/dist/Helper/Log.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Helper/Log.ts"],"names":[],"mappings":";;;AAAO,IAAM,MAAA,GAAS;AAAA,EACpB,IAAA,EAAM,IAAA;AAAA,EACN,IAAA,EAAM,IAAA;AAAA,EACN,IAAA,EAAM,IAAA;AAAA,EACN,KAAA,EAAO,IAAA;AAAA,EACP,OAAA,EAAS,IAAA;AAAA,EACT,MAAA,EAAQ,IAAA;AAAA,EACR,GAAA,EAAK;AACP;AAIO,SAAS,QAAA,CAAS,IAAA,EAAc,SAAA,GAAwB,MAAA,CAAO,IAAA,EAAc;AAClF,EAAA,MAAM,QAAA,GACJ,OAAO,SAAA,KAAc,QAAA,IAAY,SAAA,IAAa,SAC1C,MAAA,CAAO,SAAgC,CAAA,GACvC,SAAA,IAAa,MAAA,CAAO,IAAA;AAE1B,EAAA,OAAO,CAAA,KAAA,EAAQ,QAAQ,CAAA,CAAA,EAAI,IAAI,CAAA,OAAA,CAAA;AACjC;AAEO,SAAS,QAAA,CAAS,KAAA,EAAe,SAAA,GAAwB,MAAA,CAAO,IAAA,EAAY;AACjF,EAAA,OAAA,CAAQ,IAAI,EAAE,CAAA;AACd,EAAA,OAAA,CAAQ,GAAA,CAAI,QAAA,CAAS,CAAA,EAAA,EAAK,MAAA,CAAO,KAAK,EAAE,WAAA,EAAa,CAAA,CAAA,EAAI,SAAS,CAAC,CAAA;AACrE;AAEO,SAAS,OAAA,CACd,OACA,KAAA,EACA,UAAA,GAAyB,OAAO,IAAA,EAChC,UAAA,GAAyB,OAAO,MAAA,EAC1B;AACN,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,EAAG,QAAA,CAAS,KAAA,EAAO,UAAU,CAAC,CAAA,CAAA,EAAI,QAAA,CAAS,KAAA,EAAO,UAAU,CAAC,CAAA,CAAE,CAAA;AAC7E;AAEO,SAAS,QAAA,CAAS,QAAgB,KAAA,EAAiD;AACxF,EAAA,OAAA,CAAQ,GAAA;AAAA,IACN,GAAG,QAAA,CAAS,QAAA,EAAK,OAAO,KAAK,CAAC,IAAI,QAAA,CAAS,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA,CAAA,EAAI,QAAA,CAAS,MAAM,MAAA,EAAQ,MAAA,CAAO,MAAM,CAAC,CAAA;AAAA,GAC1G;AACA,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,IAAA,EAAO,QAAA,CAAS,MAAA,EAAQ,OAAO,IAAI,CAAC,CAAA,CAAA,EAAI,QAAA,CAAS,KAAA,CAAM,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,CAAA,CAAE,CAAA;AAC3F","file":"Log.cjs","sourcesContent":["export const COLORS = {\n blue: '34',\n cyan: '36',\n gray: '90',\n green: '32',\n magenta: '35',\n yellow: '33',\n red: '31',\n} as const;\n\ntype ColorValue = keyof typeof COLORS | string;\n\nexport function logColor(text: string, colorCode: ColorValue = COLORS.gray): string {\n const resolved =\n typeof colorCode === 'string' && colorCode in COLORS\n ? COLORS[colorCode as keyof typeof COLORS]\n : colorCode || COLORS.gray;\n\n return `\\x1b[${resolved}m${text}\\x1b[0m`;\n}\n\nexport function logTitle(title: string, colorCode: ColorValue = COLORS.cyan): void {\n console.log('');\n console.log(logColor(`# ${String(title).toUpperCase()}`, colorCode));\n}\n\nexport function logPath(\n label: string,\n value: string,\n labelColor: ColorValue = COLORS.gray,\n valueColor: ColorValue = COLORS.yellow\n): void {\n console.log(`${logColor(label, labelColor)} ${logColor(value, valueColor)}`);\n}\n\nexport function logEntry(action: string, entry: { output: string; source: string }): void {\n console.log(\n `${logColor('•', COLORS.green)} ${logColor(action, COLORS.blue)} ${logColor(entry.output, COLORS.yellow)}`\n );\n console.log(` ${logColor('from', COLORS.gray)} ${logColor(entry.source, COLORS.gray)}`);\n}\n"]}
|
package/dist/Helper/Log.d.cts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const COLORS: {
|
|
2
|
-
readonly blue: "34";
|
|
3
|
-
readonly cyan: "36";
|
|
4
|
-
readonly gray: "90";
|
|
5
|
-
readonly green: "32";
|
|
6
|
-
readonly magenta: "35";
|
|
7
|
-
readonly yellow: "33";
|
|
8
|
-
readonly red: "31";
|
|
9
|
-
};
|
|
10
|
-
type ColorValue = keyof typeof COLORS | string;
|
|
11
|
-
declare function logColor(text: string, colorCode?: ColorValue): string;
|
|
12
|
-
declare function logTitle(title: string, colorCode?: ColorValue): void;
|
|
13
|
-
declare function logPath(label: string, value: string, labelColor?: ColorValue, valueColor?: ColorValue): void;
|
|
14
|
-
declare function logEntry(action: string, entry: {
|
|
15
|
-
output: string;
|
|
16
|
-
source: string;
|
|
17
|
-
}): void;
|
|
18
|
-
|
|
19
|
-
export { COLORS, logColor, logEntry, logPath, logTitle };
|
package/dist/Helper/Log.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const COLORS: {
|
|
2
|
-
readonly blue: "34";
|
|
3
|
-
readonly cyan: "36";
|
|
4
|
-
readonly gray: "90";
|
|
5
|
-
readonly green: "32";
|
|
6
|
-
readonly magenta: "35";
|
|
7
|
-
readonly yellow: "33";
|
|
8
|
-
readonly red: "31";
|
|
9
|
-
};
|
|
10
|
-
type ColorValue = keyof typeof COLORS | string;
|
|
11
|
-
declare function logColor(text: string, colorCode?: ColorValue): string;
|
|
12
|
-
declare function logTitle(title: string, colorCode?: ColorValue): void;
|
|
13
|
-
declare function logPath(label: string, value: string, labelColor?: ColorValue, valueColor?: ColorValue): void;
|
|
14
|
-
declare function logEntry(action: string, entry: {
|
|
15
|
-
output: string;
|
|
16
|
-
source: string;
|
|
17
|
-
}): void;
|
|
18
|
-
|
|
19
|
-
export { COLORS, logColor, logEntry, logPath, logTitle };
|
package/dist/Helper/Mixin.cjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/Helper/Mixin.ts
|
|
4
|
-
function mixinApply(targetCtor, mixins) {
|
|
5
|
-
mixins.forEach((mixinCtor) => {
|
|
6
|
-
Object.getOwnPropertyNames(mixinCtor.prototype).forEach((name) => {
|
|
7
|
-
if (name === "constructor") {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const descriptor = Object.getOwnPropertyDescriptor(mixinCtor.prototype, name);
|
|
11
|
-
if (descriptor) {
|
|
12
|
-
Object.defineProperty(targetCtor.prototype, name, descriptor);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
Object.getOwnPropertyNames(mixinCtor).forEach((name) => {
|
|
16
|
-
if (["length", "name", "prototype"].includes(name)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const descriptor = Object.getOwnPropertyDescriptor(mixinCtor, name);
|
|
20
|
-
if (descriptor) {
|
|
21
|
-
Object.defineProperty(targetCtor, name, descriptor);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
exports.mixinApply = mixinApply;
|
|
28
|
-
//# sourceMappingURL=Mixin.cjs.map
|
|
29
|
-
//# sourceMappingURL=Mixin.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Helper/Mixin.ts"],"names":[],"mappings":";;;AAMO,SAAS,UAAA,CAAW,YAAyB,MAAA,EAA6B;AAC/E,EAAA,MAAA,CAAO,OAAA,CAAQ,CAAC,SAAA,KAAc;AAE5B,IAAA,MAAA,CAAO,oBAAoB,SAAA,CAAU,SAAS,CAAA,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS;AAChE,MAAA,IAAI,SAAS,aAAA,EAAe;AAC1B,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,UAAA,GAAa,MAAA,CAAO,wBAAA,CAAyB,SAAA,CAAU,WAAW,IAAI,CAAA;AAC5E,MAAA,IAAI,UAAA,EAAY;AACd,QAAA,MAAA,CAAO,cAAA,CAAe,UAAA,CAAW,SAAA,EAAW,IAAA,EAAM,UAAU,CAAA;AAAA,MAC9D;AAAA,IACF,CAAC,CAAA;AAGD,IAAA,MAAA,CAAO,mBAAA,CAAoB,SAAS,CAAA,CAAE,OAAA,CAAQ,CAAC,IAAA,KAAS;AACtD,MAAA,IAAI,CAAC,QAAA,EAAU,MAAA,EAAQ,WAAW,CAAA,CAAE,QAAA,CAAS,IAAI,CAAA,EAAG;AAClD,QAAA;AAAA,MACF;AAEA,MAAA,MAAM,UAAA,GAAa,MAAA,CAAO,wBAAA,CAAyB,SAAA,EAAW,IAAI,CAAA;AAClE,MAAA,IAAI,UAAA,EAAY;AACd,QAAA,MAAA,CAAO,cAAA,CAAe,UAAA,EAAY,IAAA,EAAM,UAAU,CAAA;AAAA,MACpD;AAAA,IACF,CAAC,CAAA;AAAA,EACH,CAAC,CAAA;AACH","file":"Mixin.cjs","sourcesContent":["type Constructor<T = any> = abstract new (...args: any[]) => T;\n\n/**\n * Apply mixin classes to a target class (TypeScript-compatible).\n * Copy prototype properties (except constructor) and static props.\n */\nexport function mixinApply(targetCtor: Constructor, mixins: Constructor[]): void {\n mixins.forEach((mixinCtor) => {\n // Copy instance members (prototype).\n Object.getOwnPropertyNames(mixinCtor.prototype).forEach((name) => {\n if (name === 'constructor') {\n return;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(mixinCtor.prototype, name);\n if (descriptor) {\n Object.defineProperty(targetCtor.prototype, name, descriptor);\n }\n });\n\n // Copy static members if any (excluding length/name/prototype).\n Object.getOwnPropertyNames(mixinCtor).forEach((name) => {\n if (['length', 'name', 'prototype'].includes(name)) {\n return;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(mixinCtor, name);\n if (descriptor) {\n Object.defineProperty(targetCtor, name, descriptor);\n }\n });\n });\n}\n"]}
|
package/dist/Helper/Mixin.d.cts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type Constructor<T = any> = abstract new (...args: any[]) => T;
|
|
2
|
-
/**
|
|
3
|
-
* Apply mixin classes to a target class (TypeScript-compatible).
|
|
4
|
-
* Copy prototype properties (except constructor) and static props.
|
|
5
|
-
*/
|
|
6
|
-
declare function mixinApply(targetCtor: Constructor, mixins: Constructor[]): void;
|
|
7
|
-
|
|
8
|
-
export { mixinApply };
|
package/dist/Helper/Mixin.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type Constructor<T = any> = abstract new (...args: any[]) => T;
|
|
2
|
-
/**
|
|
3
|
-
* Apply mixin classes to a target class (TypeScript-compatible).
|
|
4
|
-
* Copy prototype properties (except constructor) and static props.
|
|
5
|
-
*/
|
|
6
|
-
declare function mixinApply(targetCtor: Constructor, mixins: Constructor[]): void;
|
|
7
|
-
|
|
8
|
-
export { mixinApply };
|
package/dist/Helper/Object.cjs
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/Helper/Object.ts
|
|
4
|
-
function objectMergeDeep(target = {}, source = {}) {
|
|
5
|
-
const output = { ...target };
|
|
6
|
-
Object.entries(source || {}).forEach(([key, value]) => {
|
|
7
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
8
|
-
output[key] = objectMergeDeep(
|
|
9
|
-
typeof output[key] === "object" && output[key] !== null ? output[key] : {},
|
|
10
|
-
value
|
|
11
|
-
);
|
|
12
|
-
} else {
|
|
13
|
-
output[key] = value;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
return output;
|
|
17
|
-
}
|
|
18
|
-
function objectToType(value) {
|
|
19
|
-
return {}.toString.call(value).match(/([a-z]+)(:?\])/i)?.[1] ?? typeof value;
|
|
20
|
-
}
|
|
21
|
-
function objectIsPlainObject(value) {
|
|
22
|
-
return objectToType(value) === "Object";
|
|
23
|
-
}
|
|
24
|
-
function objectDeepAssignWithOptions(options) {
|
|
25
|
-
const mergedOptions = {
|
|
26
|
-
nonEnum: true,
|
|
27
|
-
symbols: true,
|
|
28
|
-
descriptors: true,
|
|
29
|
-
proto: true,
|
|
30
|
-
...options
|
|
31
|
-
};
|
|
32
|
-
return (target, ...sources) => {
|
|
33
|
-
sources.forEach((source) => {
|
|
34
|
-
if (!objectIsPlainObject(source) || !objectIsPlainObject(target)) return;
|
|
35
|
-
const copyProperty = (property) => {
|
|
36
|
-
const descriptor = Object.getOwnPropertyDescriptor(source, property);
|
|
37
|
-
if (!descriptor) return;
|
|
38
|
-
if (descriptor.enumerable || mergedOptions.nonEnum) {
|
|
39
|
-
if (objectIsPlainObject(source[property]) && objectIsPlainObject(target[property])) {
|
|
40
|
-
descriptor.value = objectDeepAssignWithOptions(mergedOptions)(
|
|
41
|
-
target[property],
|
|
42
|
-
source[property]
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
if (mergedOptions.descriptors) {
|
|
46
|
-
Object.defineProperty(target, property, descriptor);
|
|
47
|
-
} else {
|
|
48
|
-
target[property] = descriptor.value;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
Object.getOwnPropertyNames(source).forEach(copyProperty);
|
|
53
|
-
if (mergedOptions.symbols) {
|
|
54
|
-
Object.getOwnPropertySymbols(source).forEach(copyProperty);
|
|
55
|
-
}
|
|
56
|
-
if (mergedOptions.proto) {
|
|
57
|
-
const targetProto = Object.getPrototypeOf(target);
|
|
58
|
-
const sourceProto = Object.getPrototypeOf(source);
|
|
59
|
-
if (targetProto && sourceProto) {
|
|
60
|
-
objectDeepAssignWithOptions({ ...mergedOptions, proto: false })(targetProto, sourceProto);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
return target;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function objectDeepAssign(...args) {
|
|
68
|
-
return objectDeepAssignWithOptions({
|
|
69
|
-
nonEnum: true,
|
|
70
|
-
symbols: true,
|
|
71
|
-
descriptors: true,
|
|
72
|
-
proto: true
|
|
73
|
-
}).apply(void 0, args);
|
|
74
|
-
}
|
|
75
|
-
function objectCallPrototypeMethodIfExists(self, methodName, args = []) {
|
|
76
|
-
const method = Object.getPrototypeOf(self)?.[methodName];
|
|
77
|
-
if (typeof method === "function") {
|
|
78
|
-
return method.apply(self, args);
|
|
79
|
-
}
|
|
80
|
-
return void 0;
|
|
81
|
-
}
|
|
82
|
-
function objectGetItemByPath(data, key, defaultValue = null, separator = ".") {
|
|
83
|
-
const keys = Array.isArray(key) ? key : key.split(separator);
|
|
84
|
-
let cursor = data;
|
|
85
|
-
for (const k of keys) {
|
|
86
|
-
if (cursor !== null && typeof cursor === "object" && k in cursor) {
|
|
87
|
-
cursor = cursor[k];
|
|
88
|
-
} else {
|
|
89
|
-
return defaultValue;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return cursor;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
exports.objectCallPrototypeMethodIfExists = objectCallPrototypeMethodIfExists;
|
|
96
|
-
exports.objectDeepAssign = objectDeepAssign;
|
|
97
|
-
exports.objectDeepAssignWithOptions = objectDeepAssignWithOptions;
|
|
98
|
-
exports.objectGetItemByPath = objectGetItemByPath;
|
|
99
|
-
exports.objectIsPlainObject = objectIsPlainObject;
|
|
100
|
-
exports.objectMergeDeep = objectMergeDeep;
|
|
101
|
-
exports.objectToType = objectToType;
|
|
102
|
-
//# sourceMappingURL=Object.cjs.map
|
|
103
|
-
//# sourceMappingURL=Object.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Helper/Object.ts"],"names":[],"mappings":";;;AAAO,SAAS,gBACd,MAAA,GAAY,EAAC,EACb,MAAA,GAAY,EAAC,EACN;AACP,EAAA,MAAM,MAAA,GAA8B,EAAE,GAAG,MAAA,EAAO;AAEhD,EAAA,MAAA,CAAO,OAAA,CAAQ,MAAA,IAAU,EAAE,CAAA,CAAE,QAAQ,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AACrD,IAAA,IAAI,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC/D,MAAA,MAAA,CAAO,GAAG,CAAA,GAAI,eAAA;AAAA,QACZ,OAAO,MAAA,CAAO,GAAG,CAAA,KAAM,QAAA,IAAY,MAAA,CAAO,GAAG,CAAA,KAAM,IAAA,GAAO,MAAA,CAAO,GAAG,CAAA,GAAI,EAAC;AAAA,QACzE;AAAA,OACF;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAA,CAAO,GAAG,CAAA,GAAI,KAAA;AAAA,IAChB;AAAA,EACF,CAAC,CAAA;AAED,EAAA,OAAO,MAAA;AACT;AAEO,SAAS,aAAa,KAAA,EAAwB;AACnD,EAAA,OAAO,EAAC,CAAE,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA,CAAE,KAAA,CAAM,iBAAiB,CAAA,GAAI,CAAC,CAAA,IAAK,OAAO,KAAA;AACzE;AAEO,SAAS,oBAAoB,KAAA,EAAuD;AACzF,EAAA,OAAO,YAAA,CAAa,KAAK,CAAA,KAAM,QAAA;AACjC;AAEO,SAAS,4BAA4B,OAAA,EAKzC;AACD,EAAA,MAAM,aAAA,GAAgB;AAAA,IACpB,OAAA,EAAS,IAAA;AAAA,IACT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MAAA,KAAW,QAAA,IAAY,KAAK,MAAA,EAAQ;AAChE,MAAA,MAAA,GAAS,OAAO,CAAC,CAAA;AAAA,IACnB,CAAA,MAAO;AACL,MAAA,OAAO,YAAA;AAAA,IACT;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"Object.cjs","sourcesContent":["export function objectMergeDeep<T extends Record<string, any>, U extends Record<string, any>>(\n target: T = {} as T,\n source: U = {} as U\n): T & U {\n const output: Record<string, any> = { ...target };\n\n Object.entries(source || {}).forEach(([key, value]) => {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n output[key] = objectMergeDeep(\n typeof output[key] === 'object' && output[key] !== null ? output[key] : {},\n value as Record<string, any>\n );\n } else {\n output[key] = value;\n }\n });\n\n return output as T & U;\n}\n\nexport function objectToType(value: unknown): string {\n return {}.toString.call(value).match(/([a-z]+)(:?\\])/i)?.[1] ?? typeof value;\n}\n\nexport function objectIsPlainObject(value: unknown): value is Record<PropertyKey, unknown> {\n return objectToType(value) === 'Object';\n}\n\nexport function objectDeepAssignWithOptions(options: {\n nonEnum?: boolean;\n symbols?: boolean;\n descriptors?: boolean;\n proto?: boolean;\n}) {\n const mergedOptions = {\n nonEnum: true,\n symbols: true,\n descriptors: true,\n proto: true,\n ...options,\n };\n\n return (target: any, ...sources: any[]) => {\n sources.forEach((source) => {\n if (!objectIsPlainObject(source) || !objectIsPlainObject(target)) return;\n\n const copyProperty = (property: string | symbol) => {\n const descriptor = Object.getOwnPropertyDescriptor(source, property);\n if (!descriptor) return;\n\n if (descriptor.enumerable || mergedOptions.nonEnum) {\n if (objectIsPlainObject(source[property]) && objectIsPlainObject(target[property])) {\n descriptor.value = objectDeepAssignWithOptions(mergedOptions)(\n target[property],\n source[property]\n );\n }\n\n if (mergedOptions.descriptors) {\n Object.defineProperty(target, property, descriptor);\n } else {\n target[property] = descriptor.value;\n }\n }\n };\n\n Object.getOwnPropertyNames(source).forEach(copyProperty);\n\n if (mergedOptions.symbols) {\n Object.getOwnPropertySymbols(source).forEach(copyProperty);\n }\n\n if (mergedOptions.proto) {\n const targetProto = Object.getPrototypeOf(target);\n const sourceProto = Object.getPrototypeOf(source);\n if (targetProto && sourceProto) {\n objectDeepAssignWithOptions({ ...mergedOptions, proto: false })(targetProto, sourceProto);\n }\n }\n });\n return target;\n };\n}\n\nexport function objectDeepAssign(...args: any[]): any {\n return objectDeepAssignWithOptions({\n nonEnum: true,\n symbols: true,\n descriptors: true,\n proto: true,\n }).apply(undefined, args as [any, ...any[]]);\n}\n\nexport function objectCallPrototypeMethodIfExists<T extends object, R>(\n self: T,\n methodName: string,\n args: unknown[] = []\n): R | undefined {\n const method = Object.getPrototypeOf(self)?.[methodName];\n if (typeof method === 'function') {\n return method.apply(self, args);\n }\n return undefined;\n}\n\nexport function objectGetItemByPath(\n data: any,\n key: string | string[],\n defaultValue: any = null,\n separator = '.'\n): any {\n const keys = Array.isArray(key) ? key : key.split(separator);\n let cursor: any = data;\n\n for (const k of keys) {\n if (cursor !== null && typeof cursor === 'object' && k in cursor) {\n cursor = cursor[k];\n } else {\n return defaultValue;\n }\n }\n\n return cursor;\n}\n"]}
|
package/dist/Helper/Object.d.cts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare function objectMergeDeep<T extends Record<string, any>, U extends Record<string, any>>(target?: T, source?: U): T & U;
|
|
2
|
-
declare function objectToType(value: unknown): string;
|
|
3
|
-
declare function objectIsPlainObject(value: unknown): value is Record<PropertyKey, unknown>;
|
|
4
|
-
declare function objectDeepAssignWithOptions(options: {
|
|
5
|
-
nonEnum?: boolean;
|
|
6
|
-
symbols?: boolean;
|
|
7
|
-
descriptors?: boolean;
|
|
8
|
-
proto?: boolean;
|
|
9
|
-
}): (target: any, ...sources: any[]) => any;
|
|
10
|
-
declare function objectDeepAssign(...args: any[]): any;
|
|
11
|
-
declare function objectCallPrototypeMethodIfExists<T extends object, R>(self: T, methodName: string, args?: unknown[]): R | undefined;
|
|
12
|
-
declare function objectGetItemByPath(data: any, key: string | string[], defaultValue?: any, separator?: string): any;
|
|
13
|
-
|
|
14
|
-
export { objectCallPrototypeMethodIfExists, objectDeepAssign, objectDeepAssignWithOptions, objectGetItemByPath, objectIsPlainObject, objectMergeDeep, objectToType };
|
package/dist/Helper/Object.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare function objectMergeDeep<T extends Record<string, any>, U extends Record<string, any>>(target?: T, source?: U): T & U;
|
|
2
|
-
declare function objectToType(value: unknown): string;
|
|
3
|
-
declare function objectIsPlainObject(value: unknown): value is Record<PropertyKey, unknown>;
|
|
4
|
-
declare function objectDeepAssignWithOptions(options: {
|
|
5
|
-
nonEnum?: boolean;
|
|
6
|
-
symbols?: boolean;
|
|
7
|
-
descriptors?: boolean;
|
|
8
|
-
proto?: boolean;
|
|
9
|
-
}): (target: any, ...sources: any[]) => any;
|
|
10
|
-
declare function objectDeepAssign(...args: any[]): any;
|
|
11
|
-
declare function objectCallPrototypeMethodIfExists<T extends object, R>(self: T, methodName: string, args?: unknown[]): R | undefined;
|
|
12
|
-
declare function objectGetItemByPath(data: any, key: string | string[], defaultValue?: any, separator?: string): any;
|
|
13
|
-
|
|
14
|
-
export { objectCallPrototypeMethodIfExists, objectDeepAssign, objectDeepAssignWithOptions, objectGetItemByPath, objectIsPlainObject, objectMergeDeep, objectToType };
|
package/dist/Helper/Pointer.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Helper/Pointer.ts"],"names":[],"mappings":";;;AAAO,IAAM,OAAA,GAAU;AAAA,EACrB,cAAA,EAAgB;AAClB","file":"Pointer.cjs","sourcesContent":["export const POINTER = {\n CLICK_DURATION: 500,\n} as const;\n"]}
|
package/dist/Helper/Pointer.d.ts
DELETED
package/dist/Helper/Queue.cjs
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/Helper/Queue.ts
|
|
4
|
-
var Queue = class {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
this.queue = [];
|
|
7
|
-
this.activeCount = 0;
|
|
8
|
-
this.paused = false;
|
|
9
|
-
this.worker = options.worker;
|
|
10
|
-
this.concurrency = Math.max(1, options.concurrency ?? 1);
|
|
11
|
-
this.autoStart = options.autoStart ?? true;
|
|
12
|
-
this.callbacks = {
|
|
13
|
-
onItemStart: options.onItemStart,
|
|
14
|
-
onItemSuccess: options.onItemSuccess,
|
|
15
|
-
onItemError: options.onItemError,
|
|
16
|
-
onItemDone: options.onItemDone,
|
|
17
|
-
onDrain: options.onDrain
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
enqueue(item) {
|
|
21
|
-
this.queue.push(item);
|
|
22
|
-
if (this.autoStart) {
|
|
23
|
-
this.pump();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
enqueueMany(items) {
|
|
27
|
-
this.queue.push(...items);
|
|
28
|
-
if (this.autoStart) {
|
|
29
|
-
this.pump();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
pause() {
|
|
33
|
-
this.paused = true;
|
|
34
|
-
}
|
|
35
|
-
resume() {
|
|
36
|
-
if (!this.paused) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this.paused = false;
|
|
40
|
-
this.pump();
|
|
41
|
-
}
|
|
42
|
-
clear() {
|
|
43
|
-
this.queue = [];
|
|
44
|
-
}
|
|
45
|
-
size() {
|
|
46
|
-
return this.queue.length;
|
|
47
|
-
}
|
|
48
|
-
active() {
|
|
49
|
-
return this.activeCount;
|
|
50
|
-
}
|
|
51
|
-
isIdle() {
|
|
52
|
-
return this.queue.length === 0 && this.activeCount === 0;
|
|
53
|
-
}
|
|
54
|
-
pump() {
|
|
55
|
-
if (this.paused) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
while (this.activeCount < this.concurrency && this.queue.length > 0) {
|
|
59
|
-
const item = this.queue.shift();
|
|
60
|
-
this.runItem(item);
|
|
61
|
-
}
|
|
62
|
-
if (this.isIdle()) {
|
|
63
|
-
this.callbacks.onDrain?.();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
async runItem(item) {
|
|
67
|
-
this.activeCount += 1;
|
|
68
|
-
this.callbacks.onItemStart?.(item);
|
|
69
|
-
try {
|
|
70
|
-
const result = await this.worker(item);
|
|
71
|
-
this.callbacks.onItemSuccess?.(item, result);
|
|
72
|
-
} catch (error) {
|
|
73
|
-
this.callbacks.onItemError?.(item, error);
|
|
74
|
-
} finally {
|
|
75
|
-
this.callbacks.onItemDone?.(item);
|
|
76
|
-
this.activeCount -= 1;
|
|
77
|
-
this.pump();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
module.exports = Queue;
|
|
83
|
-
//# sourceMappingURL=Queue.cjs.map
|
|
84
|
-
//# sourceMappingURL=Queue.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Helper/Queue.ts"],"names":[],"mappings":";;;AAgBA,IAAqB,QAArB,MAAqD;AAAA,EASnD,YAAY,OAAA,EAAuC;AARnD,IAAA,IAAA,CAAQ,QAAiB,EAAC;AAC1B,IAAA,IAAA,CAAQ,WAAA,GAAc,CAAA;AACtB,IAAA,IAAA,CAAQ,MAAA,GAAS,KAAA;AAOf,IAAA,IAAA,CAAK,SAAS,OAAA,CAAQ,MAAA;AACtB,IAAA,IAAA,CAAK,cAAc,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,OAAA,CAAQ,eAAe,CAAC,CAAA;AACvD,IAAA,IAAA,CAAK,SAAA,GAAY,QAAQ,SAAA,IAAa,IAAA;AACtC,IAAA,IAAA,CAAK,SAAA,GAAY;AAAA,MACf,aAAa,OAAA,CAAQ,WAAA;AAAA,MACrB,eAAe,OAAA,CAAQ,aAAA;AAAA,MACvB,aAAa,OAAA,CAAQ,WAAA;AAAA,MACrB,YAAY,OAAA,CAAQ,UAAA;AAAA,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,GAAO,IAAA,CAAK,KAAA,CAAM,KAAA,EAAM;AAC9B,MAAA,IAAA,CAAK,QAAQ,IAAI,CAAA;AAAA,IACnB;AAEA,IAAA,IAAI,IAAA,CAAK,QAAO,EAAG;AACjB,MAAA,IAAA,CAAK,UAAU,OAAA,IAAU;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,MAAc,QAAQ,IAAA,EAA4B;AAChD,IAAA,IAAA,CAAK,WAAA,IAAe,CAAA;AACpB,IAAA,IAAA,CAAK,SAAA,CAAU,cAAc,IAAI,CAAA;AAEjC,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,MAAA,CAAO,IAAI,CAAA;AACrC,MAAA,IAAA,CAAK,SAAA,CAAU,aAAA,GAAgB,IAAA,EAAM,MAAM,CAAA;AAAA,IAC7C,SAAS,KAAA,EAAO;AACd,MAAA,IAAA,CAAK,SAAA,CAAU,WAAA,GAAc,IAAA,EAAM,KAAK,CAAA;AAAA,IAC1C,CAAA,SAAE;AACA,MAAA,IAAA,CAAK,SAAA,CAAU,aAAa,IAAI,CAAA;AAChC,MAAA,IAAA,CAAK,WAAA,IAAe,CAAA;AACpB,MAAA,IAAA,CAAK,IAAA,EAAK;AAAA,IACZ;AAAA,EACF;AACF","file":"Queue.cjs","sourcesContent":["export type QueueWorker<TItem, TResult = unknown> = (item: TItem) => Promise<TResult> | TResult;\n\nexport type QueueCallbacks<TItem, TResult = unknown> = {\n onItemStart?: (item: TItem) => void;\n onItemSuccess?: (item: TItem, result: TResult) => void;\n onItemError?: (item: TItem, error: unknown) => void;\n onItemDone?: (item: TItem) => void;\n onDrain?: () => void;\n};\n\nexport type QueueOptions<TItem, TResult = unknown> = QueueCallbacks<TItem, TResult> & {\n worker: QueueWorker<TItem, TResult>;\n concurrency?: number;\n autoStart?: boolean;\n};\n\nexport default class Queue<TItem, TResult = unknown> {\n private queue: TItem[] = [];\n private activeCount = 0;\n private paused = false;\n private readonly worker: QueueWorker<TItem, TResult>;\n private readonly concurrency: number;\n private readonly autoStart: boolean;\n private readonly callbacks: QueueCallbacks<TItem, TResult>;\n\n constructor(options: QueueOptions<TItem, TResult>) {\n this.worker = options.worker;\n this.concurrency = Math.max(1, options.concurrency ?? 1);\n this.autoStart = options.autoStart ?? true;\n this.callbacks = {\n onItemStart: options.onItemStart,\n onItemSuccess: options.onItemSuccess,\n onItemError: options.onItemError,\n onItemDone: options.onItemDone,\n onDrain: options.onDrain,\n };\n }\n\n enqueue(item: TItem): void {\n this.queue.push(item);\n if (this.autoStart) {\n this.pump();\n }\n }\n\n enqueueMany(items: TItem[]): void {\n this.queue.push(...items);\n if (this.autoStart) {\n this.pump();\n }\n }\n\n pause(): void {\n this.paused = true;\n }\n\n resume(): void {\n if (!this.paused) {\n return;\n }\n\n this.paused = false;\n this.pump();\n }\n\n clear(): void {\n this.queue = [];\n }\n\n size(): number {\n return this.queue.length;\n }\n\n active(): number {\n return this.activeCount;\n }\n\n isIdle(): boolean {\n return this.queue.length === 0 && this.activeCount === 0;\n }\n\n private pump(): void {\n if (this.paused) {\n return;\n }\n\n while (this.activeCount < this.concurrency && this.queue.length > 0) {\n const item = this.queue.shift() as TItem;\n this.runItem(item);\n }\n\n if (this.isIdle()) {\n this.callbacks.onDrain?.();\n }\n }\n\n private async runItem(item: TItem): Promise<void> {\n this.activeCount += 1;\n this.callbacks.onItemStart?.(item);\n\n try {\n const result = await this.worker(item);\n this.callbacks.onItemSuccess?.(item, result);\n } catch (error) {\n this.callbacks.onItemError?.(item, error);\n } finally {\n this.callbacks.onItemDone?.(item);\n this.activeCount -= 1;\n this.pump();\n }\n }\n}\n"]}
|
package/dist/Helper/Queue.d.cts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
type QueueWorker<TItem, TResult = unknown> = (item: TItem) => Promise<TResult> | TResult;
|
|
2
|
-
type QueueCallbacks<TItem, TResult = unknown> = {
|
|
3
|
-
onItemStart?: (item: TItem) => void;
|
|
4
|
-
onItemSuccess?: (item: TItem, result: TResult) => void;
|
|
5
|
-
onItemError?: (item: TItem, error: unknown) => void;
|
|
6
|
-
onItemDone?: (item: TItem) => void;
|
|
7
|
-
onDrain?: () => void;
|
|
8
|
-
};
|
|
9
|
-
type QueueOptions<TItem, TResult = unknown> = QueueCallbacks<TItem, TResult> & {
|
|
10
|
-
worker: QueueWorker<TItem, TResult>;
|
|
11
|
-
concurrency?: number;
|
|
12
|
-
autoStart?: boolean;
|
|
13
|
-
};
|
|
14
|
-
declare class Queue<TItem, TResult = unknown> {
|
|
15
|
-
private queue;
|
|
16
|
-
private activeCount;
|
|
17
|
-
private paused;
|
|
18
|
-
private readonly worker;
|
|
19
|
-
private readonly concurrency;
|
|
20
|
-
private readonly autoStart;
|
|
21
|
-
private readonly callbacks;
|
|
22
|
-
constructor(options: QueueOptions<TItem, TResult>);
|
|
23
|
-
enqueue(item: TItem): void;
|
|
24
|
-
enqueueMany(items: TItem[]): void;
|
|
25
|
-
pause(): void;
|
|
26
|
-
resume(): void;
|
|
27
|
-
clear(): void;
|
|
28
|
-
size(): number;
|
|
29
|
-
active(): number;
|
|
30
|
-
isIdle(): boolean;
|
|
31
|
-
private pump;
|
|
32
|
-
private runItem;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { type QueueCallbacks, type QueueOptions, type QueueWorker, Queue as default };
|
package/dist/Helper/Queue.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
type QueueWorker<TItem, TResult = unknown> = (item: TItem) => Promise<TResult> | TResult;
|
|
2
|
-
type QueueCallbacks<TItem, TResult = unknown> = {
|
|
3
|
-
onItemStart?: (item: TItem) => void;
|
|
4
|
-
onItemSuccess?: (item: TItem, result: TResult) => void;
|
|
5
|
-
onItemError?: (item: TItem, error: unknown) => void;
|
|
6
|
-
onItemDone?: (item: TItem) => void;
|
|
7
|
-
onDrain?: () => void;
|
|
8
|
-
};
|
|
9
|
-
type QueueOptions<TItem, TResult = unknown> = QueueCallbacks<TItem, TResult> & {
|
|
10
|
-
worker: QueueWorker<TItem, TResult>;
|
|
11
|
-
concurrency?: number;
|
|
12
|
-
autoStart?: boolean;
|
|
13
|
-
};
|
|
14
|
-
declare class Queue<TItem, TResult = unknown> {
|
|
15
|
-
private queue;
|
|
16
|
-
private activeCount;
|
|
17
|
-
private paused;
|
|
18
|
-
private readonly worker;
|
|
19
|
-
private readonly concurrency;
|
|
20
|
-
private readonly autoStart;
|
|
21
|
-
private readonly callbacks;
|
|
22
|
-
constructor(options: QueueOptions<TItem, TResult>);
|
|
23
|
-
enqueue(item: TItem): void;
|
|
24
|
-
enqueueMany(items: TItem[]): void;
|
|
25
|
-
pause(): void;
|
|
26
|
-
resume(): void;
|
|
27
|
-
clear(): void;
|
|
28
|
-
size(): number;
|
|
29
|
-
active(): number;
|
|
30
|
-
isIdle(): boolean;
|
|
31
|
-
private pump;
|
|
32
|
-
private runItem;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { type QueueCallbacks, type QueueOptions, type QueueWorker, Queue as default };
|