@powfix/core-js 0.20.5 → 0.21.0
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/index.browser.js +3 -0
- package/dist/browser/cjs/shared/utils/index.js +1 -1
- package/dist/browser/esm/index.browser.mjs +1 -0
- package/dist/browser/esm/shared/utils/index.mjs +1 -1
- package/dist/browser/types/index.browser.d.ts +1 -0
- package/dist/browser/types/shared/utils/index.d.ts +1 -0
- package/dist/cjs/index.js +17 -0
- package/dist/cjs/shared/constants/COORDINATE.js +10 -0
- package/dist/cjs/shared/constants/CRUD.js +22 -0
- package/dist/cjs/shared/constants/DATE.js +26 -0
- package/dist/cjs/shared/constants/DISTANCE.js +18 -0
- package/dist/cjs/shared/constants/DURATION.js +21 -0
- package/dist/cjs/shared/constants/NOT_NULL.js +4 -0
- package/dist/cjs/shared/constants/index.js +22 -0
- package/dist/cjs/shared/index.js +23 -0
- package/dist/cjs/shared/interfaces/Coordinate.js +2 -0
- package/dist/cjs/shared/interfaces/Point2.js +2 -0
- package/dist/cjs/shared/interfaces/Point3.js +2 -0
- package/dist/cjs/shared/interfaces/StorageProvider.js +2 -0
- package/dist/cjs/shared/interfaces/index.js +20 -0
- package/dist/cjs/shared/managers/SessionManager.js +134 -0
- package/dist/cjs/shared/managers/SessionManager.type.js +2 -0
- package/dist/cjs/shared/managers/index.js +18 -0
- package/dist/cjs/shared/scripts/base64Polyfill.js +18 -0
- package/dist/cjs/shared/scripts/index.js +17 -0
- package/dist/cjs/shared/services/index.js +17 -0
- package/dist/cjs/shared/services/time/TimeService.js +180 -0
- package/dist/cjs/shared/services/time/TimeService.type.js +2 -0
- package/dist/cjs/shared/services/time/index.js +18 -0
- package/dist/cjs/shared/types/IntRage.js +2 -0
- package/dist/cjs/shared/types/PartialExcept.js +2 -0
- package/dist/cjs/shared/types/index.js +18 -0
- package/dist/cjs/shared/utils/ArrayUtils.js +30 -0
- package/dist/cjs/shared/utils/AxiosUtils.js +53 -0
- package/dist/cjs/shared/utils/BooleanUtils.js +8 -0
- package/dist/cjs/shared/utils/Calc.js +27 -0
- package/dist/cjs/shared/utils/CoordinateUtils.js +42 -0
- package/dist/cjs/shared/utils/DateUtils.js +310 -0
- package/dist/cjs/shared/utils/Enum.js +36 -0
- package/dist/cjs/shared/utils/Enum.types.js +2 -0
- package/dist/cjs/shared/utils/I18nUtils.js +13 -0
- package/dist/cjs/shared/utils/JuminNumberUtils.js +50 -0
- package/dist/cjs/shared/utils/NumberUtils.js +25 -0
- package/dist/cjs/shared/utils/ObjectIdUtils.js +30 -0
- package/dist/cjs/shared/utils/Point3Utils.js +12 -0
- package/dist/cjs/shared/utils/RandomUtils.js +64 -0
- package/dist/cjs/shared/utils/Sequencer.js +148 -0
- package/dist/cjs/shared/utils/StringUtils.js +37 -0
- package/dist/cjs/shared/utils/UUID.js +320 -0
- package/dist/cjs/shared/utils/UUID.types.js +2 -0
- package/dist/cjs/shared/utils/Uint8ArrayUtils.js +13 -0
- package/dist/cjs/shared/utils/UuidUtils.js +77 -0
- package/dist/cjs/shared/utils/Validator.js +118 -0
- package/dist/cjs/shared/utils/global/atob.js +9 -0
- package/dist/cjs/shared/utils/global/base64.js +25 -0
- package/dist/cjs/shared/utils/global/between.js +7 -0
- package/dist/cjs/shared/utils/global/btoa.js +9 -0
- package/dist/cjs/shared/utils/global/castArray.js +6 -0
- package/dist/cjs/shared/utils/global/circularDistance.js +14 -0
- package/dist/cjs/shared/utils/global/fallbackIfMatch.js +9 -0
- package/dist/cjs/shared/utils/global/fallbackIfNull.js +7 -0
- package/dist/cjs/shared/utils/global/fallbackIfNullish.js +9 -0
- package/dist/cjs/shared/utils/global/fallbackIfUndefined.js +7 -0
- package/dist/cjs/shared/utils/global/firstNonNullish.js +13 -0
- package/dist/cjs/shared/utils/global/flat.js +117 -0
- package/dist/cjs/shared/utils/global/index.js +31 -0
- package/dist/cjs/shared/utils/global/processFirstNonNullish.js +11 -0
- package/dist/cjs/shared/utils/global/pureEnum.js +23 -0
- package/dist/cjs/shared/utils/global/sleep.js +5 -0
- package/dist/cjs/shared/utils/index.js +39 -0
- package/dist/cjs/shared/utils/try-catch/TryCatch.js +78 -0
- package/dist/cjs/shared/utils/try-catch/index.js +17 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/shared/constants/COORDINATE.mjs +6 -0
- package/dist/esm/shared/constants/CRUD.mjs +19 -0
- package/dist/esm/shared/constants/DATE.mjs +22 -0
- package/dist/esm/shared/constants/DISTANCE.mjs +14 -0
- package/dist/esm/shared/constants/DURATION.mjs +17 -0
- package/dist/esm/shared/constants/NOT_NULL.mjs +1 -0
- package/dist/esm/shared/constants/index.mjs +6 -0
- package/dist/esm/shared/index.mjs +7 -0
- package/dist/esm/shared/interfaces/Coordinate.mjs +1 -0
- package/dist/esm/shared/interfaces/Point2.mjs +1 -0
- package/dist/esm/shared/interfaces/Point3.mjs +1 -0
- package/dist/esm/shared/interfaces/StorageProvider.mjs +1 -0
- package/dist/esm/shared/interfaces/index.mjs +4 -0
- package/dist/esm/shared/managers/SessionManager.mjs +127 -0
- package/dist/esm/shared/managers/SessionManager.type.mjs +1 -0
- package/dist/esm/shared/managers/index.mjs +2 -0
- package/dist/esm/shared/scripts/base64Polyfill.mjs +11 -0
- package/dist/esm/shared/scripts/index.mjs +1 -0
- package/dist/esm/shared/services/index.mjs +1 -0
- package/dist/esm/shared/services/time/TimeService.mjs +173 -0
- package/dist/esm/shared/services/time/TimeService.type.mjs +1 -0
- package/dist/esm/shared/services/time/index.mjs +2 -0
- package/dist/esm/shared/types/IntRage.mjs +1 -0
- package/dist/esm/shared/types/PartialExcept.mjs +1 -0
- package/dist/esm/shared/types/index.mjs +2 -0
- package/dist/esm/shared/utils/ArrayUtils.mjs +26 -0
- package/dist/esm/shared/utils/AxiosUtils.mjs +49 -0
- package/dist/esm/shared/utils/BooleanUtils.mjs +5 -0
- package/dist/esm/shared/utils/Calc.mjs +23 -0
- package/dist/esm/shared/utils/CoordinateUtils.mjs +38 -0
- package/dist/esm/shared/utils/DateUtils.mjs +303 -0
- package/dist/esm/shared/utils/Enum.mjs +32 -0
- package/dist/esm/shared/utils/Enum.types.mjs +1 -0
- package/dist/esm/shared/utils/I18nUtils.mjs +6 -0
- package/dist/esm/shared/utils/JuminNumberUtils.mjs +46 -0
- package/dist/esm/shared/utils/NumberUtils.mjs +21 -0
- package/dist/esm/shared/utils/ObjectIdUtils.mjs +26 -0
- package/dist/esm/shared/utils/Point3Utils.mjs +8 -0
- package/dist/esm/shared/utils/RandomUtils.mjs +60 -0
- package/dist/esm/shared/utils/Sequencer.mjs +141 -0
- package/dist/esm/shared/utils/StringUtils.mjs +33 -0
- package/dist/esm/shared/utils/UUID.mjs +316 -0
- package/dist/esm/shared/utils/UUID.types.mjs +1 -0
- package/dist/esm/shared/utils/Uint8ArrayUtils.mjs +9 -0
- package/dist/esm/shared/utils/UuidUtils.mjs +40 -0
- package/dist/esm/shared/utils/Validator.mjs +114 -0
- package/dist/esm/shared/utils/global/atob.mjs +3 -0
- package/dist/esm/shared/utils/global/base64.mjs +21 -0
- package/dist/esm/shared/utils/global/between.mjs +3 -0
- package/dist/esm/shared/utils/global/btoa.mjs +3 -0
- package/dist/esm/shared/utils/global/castArray.mjs +3 -0
- package/dist/esm/shared/utils/global/circularDistance.mjs +11 -0
- package/dist/esm/shared/utils/global/fallbackIfMatch.mjs +6 -0
- package/dist/esm/shared/utils/global/fallbackIfNull.mjs +4 -0
- package/dist/esm/shared/utils/global/fallbackIfNullish.mjs +6 -0
- package/dist/esm/shared/utils/global/fallbackIfUndefined.mjs +4 -0
- package/dist/esm/shared/utils/global/firstNonNullish.mjs +10 -0
- package/dist/esm/shared/utils/global/flat.mjs +113 -0
- package/dist/esm/shared/utils/global/index.mjs +15 -0
- package/dist/esm/shared/utils/global/processFirstNonNullish.mjs +8 -0
- package/dist/esm/shared/utils/global/pureEnum.mjs +18 -0
- package/dist/esm/shared/utils/global/sleep.mjs +1 -0
- package/dist/esm/shared/utils/index.mjs +23 -0
- package/dist/esm/shared/utils/try-catch/TryCatch.mjs +74 -0
- package/dist/esm/shared/utils/try-catch/index.mjs +1 -0
- package/dist/node/cjs/index.nodejs.js +3 -0
- package/dist/node/cjs/shared/utils/index.js +1 -1
- package/dist/node/esm/index.nodejs.mjs +1 -0
- package/dist/node/esm/shared/utils/index.mjs +1 -1
- package/dist/node/types/index.nodejs.d.ts +1 -0
- package/dist/node/types/shared/utils/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/shared/constants/COORDINATE.d.ts +7 -0
- package/dist/types/shared/constants/CRUD.d.ts +9 -0
- package/dist/types/shared/constants/DATE.d.ts +13 -0
- package/dist/types/shared/constants/DISTANCE.d.ts +13 -0
- package/dist/types/shared/constants/DURATION.d.ts +16 -0
- package/dist/types/shared/constants/NOT_NULL.d.ts +1 -0
- package/dist/types/shared/constants/index.d.ts +6 -0
- package/dist/types/shared/index.d.ts +7 -0
- package/dist/types/shared/interfaces/Coordinate.d.ts +8 -0
- package/dist/types/shared/interfaces/Point2.d.ts +4 -0
- package/dist/types/shared/interfaces/Point3.d.ts +4 -0
- package/dist/types/shared/interfaces/StorageProvider.d.ts +7 -0
- package/dist/types/shared/interfaces/index.d.ts +4 -0
- package/dist/types/shared/managers/SessionManager.d.ts +15 -0
- package/dist/types/shared/managers/SessionManager.type.d.ts +9 -0
- package/dist/types/shared/managers/index.d.ts +2 -0
- package/dist/types/shared/scripts/base64Polyfill.d.ts +1 -0
- package/dist/types/shared/scripts/index.d.ts +1 -0
- package/dist/types/shared/services/index.d.ts +1 -0
- package/dist/types/shared/services/time/TimeService.d.ts +31 -0
- package/dist/types/shared/services/time/TimeService.type.d.ts +21 -0
- package/dist/types/shared/services/time/index.d.ts +2 -0
- package/dist/types/shared/types/IntRage.d.ts +3 -0
- package/dist/types/shared/types/PartialExcept.d.ts +1 -0
- package/dist/types/shared/types/index.d.ts +2 -0
- package/dist/types/shared/utils/ArrayUtils.d.ts +12 -0
- package/dist/types/shared/utils/AxiosUtils.d.ts +5 -0
- package/dist/types/shared/utils/BooleanUtils.d.ts +1 -0
- package/dist/types/shared/utils/Calc.d.ts +4 -0
- package/dist/types/shared/utils/CoordinateUtils.d.ts +8 -0
- package/dist/types/shared/utils/DateUtils.d.ts +24 -0
- package/dist/types/shared/utils/Enum.d.ts +16 -0
- package/dist/types/shared/utils/Enum.types.d.ts +6 -0
- package/dist/types/shared/utils/I18nUtils.d.ts +4 -0
- package/dist/types/shared/utils/JuminNumberUtils.d.ts +4 -0
- package/dist/types/shared/utils/NumberUtils.d.ts +4 -0
- package/dist/types/shared/utils/ObjectIdUtils.d.ts +4 -0
- package/dist/types/shared/utils/Point3Utils.d.ts +4 -0
- package/dist/types/shared/utils/RandomUtils.d.ts +8 -0
- package/dist/types/shared/utils/Sequencer.d.ts +38 -0
- package/dist/types/shared/utils/StringUtils.d.ts +5 -0
- package/dist/types/shared/utils/UUID.d.ts +147 -0
- package/dist/types/shared/utils/UUID.types.d.ts +2 -0
- package/dist/types/shared/utils/Uint8ArrayUtils.d.ts +4 -0
- package/dist/types/shared/utils/UuidUtils.d.ts +14 -0
- package/dist/types/shared/utils/Validator.d.ts +48 -0
- package/dist/types/shared/utils/global/atob.d.ts +2 -0
- package/dist/types/shared/utils/global/base64.d.ts +2 -0
- package/dist/types/shared/utils/global/between.d.ts +1 -0
- package/dist/types/shared/utils/global/btoa.d.ts +2 -0
- package/dist/types/shared/utils/global/castArray.d.ts +1 -0
- package/dist/types/shared/utils/global/circularDistance.d.ts +1 -0
- package/dist/types/shared/utils/global/fallbackIfMatch.d.ts +1 -0
- package/dist/types/shared/utils/global/fallbackIfNull.d.ts +1 -0
- package/dist/types/shared/utils/global/fallbackIfNullish.d.ts +1 -0
- package/dist/types/shared/utils/global/fallbackIfUndefined.d.ts +1 -0
- package/dist/types/shared/utils/global/firstNonNullish.d.ts +1 -0
- package/dist/types/shared/utils/global/flat.d.ts +14 -0
- package/dist/types/shared/utils/global/index.d.ts +15 -0
- package/dist/types/shared/utils/global/processFirstNonNullish.d.ts +1 -0
- package/dist/types/shared/utils/global/pureEnum.d.ts +17 -0
- package/dist/types/shared/utils/global/sleep.d.ts +1 -0
- package/dist/types/shared/utils/index.d.ts +23 -0
- package/dist/types/shared/utils/try-catch/TryCatch.d.ts +24 -0
- package/dist/types/shared/utils/try-catch/index.d.ts +1 -0
- package/package.json +10 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class RandomUtils {
|
|
2
|
+
static randomNumber(min: number, max: number): number;
|
|
3
|
+
static randomLatinStrings(length: number): string;
|
|
4
|
+
static randomLatinLowercaseStrings(length: number): string;
|
|
5
|
+
static randomLatinUppercaseStrings(length: number): string;
|
|
6
|
+
static randomNumberStrings(length: number): string;
|
|
7
|
+
static randomStrings(length: number): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import EventEmitter3 from 'eventemitter3';
|
|
2
|
+
export interface Sequence {
|
|
3
|
+
key: string;
|
|
4
|
+
required?: boolean;
|
|
5
|
+
minimumExecutionTime?: number;
|
|
6
|
+
task: Function;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare enum SequencerStatus {
|
|
10
|
+
IDLE = 0,
|
|
11
|
+
RUNNING = 1,
|
|
12
|
+
ERROR = 2,
|
|
13
|
+
DONE = 3
|
|
14
|
+
}
|
|
15
|
+
export interface SequencerOption {
|
|
16
|
+
sequences?: Sequence[];
|
|
17
|
+
minimumExecutionTime?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare enum SequencerEvent {
|
|
20
|
+
START = "START",
|
|
21
|
+
END = "END",
|
|
22
|
+
SEQUENCE_START = "SEQUENCE_START",
|
|
23
|
+
SEQUENCE_END = "SEQUENCE_END"
|
|
24
|
+
}
|
|
25
|
+
export declare class Sequencer {
|
|
26
|
+
protected readonly sequences: Sequence[];
|
|
27
|
+
protected status: SequencerStatus;
|
|
28
|
+
protected minimumExecutionTime: number;
|
|
29
|
+
currentSequence: Sequence | null;
|
|
30
|
+
startTimestamp: number | null;
|
|
31
|
+
endTimestamp: number | null;
|
|
32
|
+
eventEmitter: EventEmitter3<string | symbol, any>;
|
|
33
|
+
constructor(option?: SequencerOption);
|
|
34
|
+
get getCurrentTimeStamp(): number;
|
|
35
|
+
get executionTime(): number | null;
|
|
36
|
+
pushSequence: (sequence: Sequence) => void;
|
|
37
|
+
start: () => Promise<undefined>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { UuidInput } from "./UUID.types";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a UUID (Universally Unique Identifier) and provides various utility
|
|
4
|
+
* methods for validation, conversion, comparison and creation.
|
|
5
|
+
*/
|
|
6
|
+
export declare class UUID {
|
|
7
|
+
/** Matches a 32‑character hexadecimal representation of a UUID without hyphens. */
|
|
8
|
+
private static REGEX_HEX;
|
|
9
|
+
/** Matches the RFC 4122 canonical UUID format with hyphens. */
|
|
10
|
+
private static REGEX_RFC4122;
|
|
11
|
+
/** Number of bytes that represent a UUID. */
|
|
12
|
+
private static BYTE_LENGTH;
|
|
13
|
+
/** Total length of an RFC 4122 UUID string (including hyphens). */
|
|
14
|
+
private static STR_LENGTH;
|
|
15
|
+
/** Length of a UUID represented as a plain hexadecimal string. */
|
|
16
|
+
private static HEX_STR_LENGTH;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if the supplied value is a valid hex representation of a UUID.
|
|
19
|
+
* @param hex - The string to validate.
|
|
20
|
+
* @returns true if the string matches {@link REGEX_HEX}.
|
|
21
|
+
*/
|
|
22
|
+
static isValidHex(hex: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if the supplied value is a valid RFC 4122 UUID string.
|
|
25
|
+
* @param str - The string to validate.
|
|
26
|
+
* @returns true if the string matches {@link REGEX_RFC4122}.
|
|
27
|
+
*/
|
|
28
|
+
static isValidString(str: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Checks whether an ArrayBufferView contains exactly {@link BYTE_LENGTH} bytes.
|
|
31
|
+
* @param bytes - The view to check.
|
|
32
|
+
* @returns true if the byte length is correct.
|
|
33
|
+
*/
|
|
34
|
+
static isValidBytes(bytes: ArrayBufferView): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Generic validation that accepts either a string (hex or RFC 4122 format)
|
|
37
|
+
* or an ArrayBufferView containing the raw bytes.
|
|
38
|
+
* @param input - The value to validate.
|
|
39
|
+
* @returns true if the input is a valid representation of a UUID.
|
|
40
|
+
*/
|
|
41
|
+
static isValid(input: UuidInput): boolean;
|
|
42
|
+
static version(input: UuidInput): number;
|
|
43
|
+
/**
|
|
44
|
+
* Inserts hyphens into a 32‑character hex string to produce an RFC 4122 string.
|
|
45
|
+
* @param hex - The plain hexadecimal UUID.
|
|
46
|
+
* @returns The formatted RFC 4122 string.
|
|
47
|
+
*/
|
|
48
|
+
private static formatHex;
|
|
49
|
+
/** Removes all hyphens from a UUID string. */
|
|
50
|
+
private static stripHyphens;
|
|
51
|
+
/**
|
|
52
|
+
* Converts a plain hexadecimal UUID into a Uint8Array.
|
|
53
|
+
* @param hex - The hex string to parse.
|
|
54
|
+
* @returns A Uint8Array containing the raw bytes.
|
|
55
|
+
*/
|
|
56
|
+
private static parseHex;
|
|
57
|
+
/**
|
|
58
|
+
* Parses an RFC 4122 string into a Uint8Array.
|
|
59
|
+
* @param str - The formatted UUID string.
|
|
60
|
+
* @returns A Uint8Array containing the raw bytes.
|
|
61
|
+
*/
|
|
62
|
+
private static parseString;
|
|
63
|
+
/**
|
|
64
|
+
* Parses an ArrayBufferView into a Uint8Array ensuring the correct byte length.
|
|
65
|
+
* @param bytes - The view to parse.
|
|
66
|
+
* @returns A Uint8Array containing the raw bytes.
|
|
67
|
+
*/
|
|
68
|
+
private static parseBytes;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a UUID instance from a plain hexadecimal string.
|
|
71
|
+
* @param hex - The hex representation of the UUID.
|
|
72
|
+
* @returns A new {@link UUID} object.
|
|
73
|
+
*/
|
|
74
|
+
static fromHex<T extends typeof UUID>(hex: string): InstanceType<T>;
|
|
75
|
+
/**
|
|
76
|
+
* Creates a UUID instance from an RFC 4122 formatted string.
|
|
77
|
+
* @param str - The UUID string with hyphens.
|
|
78
|
+
* @returns A new {@link UUID} object.
|
|
79
|
+
*/
|
|
80
|
+
static fromString<T extends typeof UUID>(str: string): InstanceType<T>;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a UUID instance from raw bytes.
|
|
83
|
+
* @param bytes - An ArrayBufferView containing 16 bytes.
|
|
84
|
+
* @returns A new {@link UUID} object.
|
|
85
|
+
*/
|
|
86
|
+
static fromBytes<T extends typeof UUID>(bytes: ArrayBufferView): InstanceType<T>;
|
|
87
|
+
/**
|
|
88
|
+
* Parses any supported input (string or bytes) and returns the raw byte array.
|
|
89
|
+
* @param input - The value to parse.
|
|
90
|
+
* @returns A Uint8Array of length {@link BYTE_LENGTH}.
|
|
91
|
+
*/
|
|
92
|
+
private static parse;
|
|
93
|
+
/**
|
|
94
|
+
* Creates a UUID from any supported input type.
|
|
95
|
+
* @param input - The value to parse.
|
|
96
|
+
* @returns A new {@link UUID} object.
|
|
97
|
+
*/
|
|
98
|
+
static from<T extends typeof UUID>(this: T, input: UuidInput): InstanceType<T>;
|
|
99
|
+
/** Returns the nil (all zero) UUID. */
|
|
100
|
+
static nil<T extends typeof UUID>(this: T): InstanceType<T>;
|
|
101
|
+
/** Returns a UUID consisting of all 0xFF bytes. */
|
|
102
|
+
static max<T extends typeof UUID>(this: T): InstanceType<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Compares multiple UUIDs for strict equality.
|
|
105
|
+
* @param inputs - The UUIDs to compare (at least two required).
|
|
106
|
+
* @returns true if all provided UUIDs are identical.
|
|
107
|
+
*/
|
|
108
|
+
static equals(...inputs: UuidInput[]): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Lexicographically compares two UUIDs.
|
|
111
|
+
* @param uuid1 - The first UUID.
|
|
112
|
+
* @param uuid2 - The second UUID.
|
|
113
|
+
* @returns -1 if uuid1 < uuid2, 1 if uuid1 > uuid2, 0 otherwise.
|
|
114
|
+
*/
|
|
115
|
+
static compare(uuid1: UuidInput, uuid2: UuidInput): number;
|
|
116
|
+
/** Raw byte representation of the UUID. */
|
|
117
|
+
protected readonly bytes: Uint8Array;
|
|
118
|
+
private _str?;
|
|
119
|
+
private _hex?;
|
|
120
|
+
/**
|
|
121
|
+
* Constructs a new {@link UUID} instance from any supported input type.
|
|
122
|
+
* @param input - The value to parse (string or ArrayBufferView).
|
|
123
|
+
*/
|
|
124
|
+
constructor(input: UuidInput);
|
|
125
|
+
/** Instance wrapper for {@link equals}. */
|
|
126
|
+
equals(...inputs: UuidInput[]): boolean;
|
|
127
|
+
/** Instance wrapper for {@link compare}. */
|
|
128
|
+
compare(other: UuidInput): number;
|
|
129
|
+
version(): number;
|
|
130
|
+
/**
|
|
131
|
+
* Returns the RFC 4122 string representation of this UUID.
|
|
132
|
+
* @returns The formatted UUID string.
|
|
133
|
+
*/
|
|
134
|
+
toString(): string;
|
|
135
|
+
/**
|
|
136
|
+
* Returns the plain hexadecimal representation of this UUID.
|
|
137
|
+
* @returns A 32‑character hex string.
|
|
138
|
+
*/
|
|
139
|
+
toHex(): string;
|
|
140
|
+
/**
|
|
141
|
+
* Returns a copy of the raw byte array.
|
|
142
|
+
* @returns A new Uint8Array containing the UUID bytes.
|
|
143
|
+
*/
|
|
144
|
+
toBytes(): Uint8Array;
|
|
145
|
+
/** JSON serialization helper – returns the RFC 4122 string. */
|
|
146
|
+
toJSON(): string;
|
|
147
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class UuidUtils {
|
|
2
|
+
static v4(): string;
|
|
3
|
+
static format(uuid: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* (UUID: Buffer) to (UUID: string)
|
|
6
|
+
* @param binary UUID
|
|
7
|
+
* @returns {string|null} When binary not exists return null
|
|
8
|
+
*/
|
|
9
|
+
static toString(binary: Uint8Array): string;
|
|
10
|
+
/** (UUID: string) to (UUID: Buffer) */
|
|
11
|
+
static toBuffer(uuid: string): Buffer;
|
|
12
|
+
static toBuffer(uuid: string | null | undefined): Buffer | null;
|
|
13
|
+
static isValidUUID(uuid: string): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare class Validator {
|
|
2
|
+
static validate(value: string | null | undefined, options: Validator.Options): {
|
|
3
|
+
result: boolean;
|
|
4
|
+
validations: Validator.VALIDATION[];
|
|
5
|
+
passes: Validator.VALIDATION[];
|
|
6
|
+
errors: Validator.VALIDATION[];
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare namespace Validator {
|
|
10
|
+
enum VALIDATION {
|
|
11
|
+
MIN_LENGTH = "MIN_LENGTH",
|
|
12
|
+
MAX_LENGTH = "MAX_LENGTH",
|
|
13
|
+
SPACE_MIN_COUNT = "SPACE_MIN_COUNT",
|
|
14
|
+
SPACE_MAX_COUNT = "SPACE_MAX_COUNT",
|
|
15
|
+
NUMBER_MIN_COUNT = "NUMBER_MIN_COUNT",
|
|
16
|
+
NUMBER_MAX_COUNT = "NUMBER_MAX_COUNT",
|
|
17
|
+
ALPHABET_MIN_COUNT = "ALPHABET_MIN_COUNT",
|
|
18
|
+
ALPHABET_MAX_COUNT = "ALPHABET_MAX_COUNT",
|
|
19
|
+
ALPHABET_LOWER_CASE_MIN_COUNT = "ALPHABET_LOWER_CASE_MIN_COUNT",
|
|
20
|
+
ALPHABET_LOWER_CASE_MAX_COUNT = "ALPHABET_LOWER_CASE_MAX_COUNT",
|
|
21
|
+
ALPHABET_UPPER_CASE_MIN_COUNT = "ALPHABET_UPPER_CASE_MIN_COUNT",
|
|
22
|
+
ALPHABET_UPPER_CASE_MAX_COUNT = "ALPHABET_UPPER_CASE_MAX_COUNT",
|
|
23
|
+
SPECIAL_CHARACTER_MIN_COUNT = "SPECIAL_CHARACTER_MIN_COUNT",
|
|
24
|
+
SPECIAL_CHARACTER_MAX_COUNT = "SPECIAL_CHARACTER_MAX_COUNT",
|
|
25
|
+
STARTS_WITH_ALPHABET = "STARTS_WITH_ALPHABET",
|
|
26
|
+
STARTS_WITH_NUMBER = "STARTS_WITH_NUMBER",
|
|
27
|
+
STARTS_WITH_SPECIAL_CHARACTER = "STARTS_WITH_SPECIAL_CHARACTER"
|
|
28
|
+
}
|
|
29
|
+
interface Options {
|
|
30
|
+
minLength?: number;
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
spaceMinCount?: number;
|
|
33
|
+
spaceMaxCount?: number;
|
|
34
|
+
numberMinCount?: number;
|
|
35
|
+
numberMaxCount?: number;
|
|
36
|
+
alphabetMinCount?: number;
|
|
37
|
+
alphabetMaxCount?: number;
|
|
38
|
+
alphabetLowerCaseMinCount?: number;
|
|
39
|
+
alphabetLowerCaseMaxCount?: number;
|
|
40
|
+
alphabetUpperCaseMinCount?: number;
|
|
41
|
+
alphabetUpperCaseMaxCount?: number;
|
|
42
|
+
specialCharacterMinCount?: number;
|
|
43
|
+
specialCharacterMaxCount?: number;
|
|
44
|
+
startsWithNumber?: boolean;
|
|
45
|
+
startsWithAlphabet?: boolean;
|
|
46
|
+
startsWithSpecialCharacter?: boolean;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const between: (value: number, from: number, to: number) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function castArray<T>(value: T | T[]): T[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function circularDistance(value: number, target: number, min: number, max: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fallbackIfMatch<V, C, F>(value: V, condition: C, fallback: F): V | F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fallbackIfNull<V, F>(value: V, fallback: F): V | F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fallbackIfNullish<T, F>(value: T | null | undefined, fallback: F): T | F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fallbackIfUndefined<V, F>(value: V, fallback: F): V | F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function firstNonNullish<T>(...args: T[]): NonNullable<T> | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface FlattenOptions {
|
|
2
|
+
delimiter?: string;
|
|
3
|
+
maxDepth?: number;
|
|
4
|
+
safe?: boolean;
|
|
5
|
+
transformKey?: (key: string) => string;
|
|
6
|
+
}
|
|
7
|
+
export interface UnflattenOptions {
|
|
8
|
+
delimiter?: string;
|
|
9
|
+
object?: boolean;
|
|
10
|
+
overwrite?: boolean;
|
|
11
|
+
transformKey?: (key: string) => string;
|
|
12
|
+
}
|
|
13
|
+
export declare function flatten<T extends object>(target: T, opts?: FlattenOptions): Record<string, any>;
|
|
14
|
+
export declare function unflatten<T extends object>(target: T, opts?: UnflattenOptions): any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './atob';
|
|
2
|
+
export * from './base64';
|
|
3
|
+
export * from './between';
|
|
4
|
+
export * from './btoa';
|
|
5
|
+
export * from './castArray';
|
|
6
|
+
export * from './circularDistance';
|
|
7
|
+
export * from './sleep';
|
|
8
|
+
export * from './fallbackIfMatch';
|
|
9
|
+
export * from './fallbackIfNull';
|
|
10
|
+
export * from './fallbackIfNullish';
|
|
11
|
+
export * from './fallbackIfUndefined';
|
|
12
|
+
export * from './firstNonNullish';
|
|
13
|
+
export * from './flat';
|
|
14
|
+
export * from './processFirstNonNullish';
|
|
15
|
+
export * from './pureEnum';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function processFirstNonNullish<T, R>(processor: (nonNullish: NonNullable<T>) => R, ...args: T[]): R | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type NonFunction<T, Type extends "keys" | "values"> = {
|
|
2
|
+
[K in keyof T]: T[K] extends Function ? never : Type extends "keys" ? K : T[K];
|
|
3
|
+
}[keyof T] extends infer R ? (R extends never ? never : R) : never;
|
|
4
|
+
type PureEnumReturnType<E extends object> = [NonFunction<E, "keys">, NonFunction<E, "values">][];
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use Enum instead.
|
|
7
|
+
*/
|
|
8
|
+
export declare function pureEnum<E extends object>(e: E): PureEnumReturnType<E>;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use Enum instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare function pureEnumKeys<E extends object>(e: E): NonFunction<E, "keys">[];
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use Enum instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare function pureEnumValues<E extends object>(e: E): NonFunction<E, "values">[];
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './global';
|
|
2
|
+
export * from './ArrayUtils';
|
|
3
|
+
export * from './AxiosUtils';
|
|
4
|
+
export * from './StringUtils';
|
|
5
|
+
export * from './Uint8ArrayUtils';
|
|
6
|
+
export * from './UUID';
|
|
7
|
+
export * from './UUID.types';
|
|
8
|
+
export * from './UuidUtils';
|
|
9
|
+
export * from './BooleanUtils';
|
|
10
|
+
export * from './Calc';
|
|
11
|
+
export * from './CoordinateUtils';
|
|
12
|
+
export * from './DateUtils';
|
|
13
|
+
export * from './Enum';
|
|
14
|
+
export * from './Enum.types';
|
|
15
|
+
export * from './I18nUtils';
|
|
16
|
+
export * from './NumberUtils';
|
|
17
|
+
export * from './ObjectIdUtils';
|
|
18
|
+
export * from './Point3Utils';
|
|
19
|
+
export * from './RandomUtils';
|
|
20
|
+
export * from './Validator';
|
|
21
|
+
export * from './JuminNumberUtils';
|
|
22
|
+
export * from './Sequencer';
|
|
23
|
+
export * from './try-catch';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides a utility class for handling synchronous and asynchronous operations with a consistent try-catch pattern.
|
|
3
|
+
* It returns a tuple where the first element is the error (or null on success) and the second element is the result (or undefined on error).
|
|
4
|
+
*/
|
|
5
|
+
export declare class TryCatch {
|
|
6
|
+
/**
|
|
7
|
+
* Executes a synchronous function within a try-catch block.
|
|
8
|
+
* @template T The return type of the function.
|
|
9
|
+
* @template E The type of the error that might be thrown (defaults to Error).
|
|
10
|
+
* @param fn The synchronous function to execute.
|
|
11
|
+
*@param disableLogging console.error is default way of logging on error. You can disable it by setting it true
|
|
12
|
+
* @returns A tuple containing the result of the function and an error (null if successful).
|
|
13
|
+
*/
|
|
14
|
+
static function<T, E = Error>(fn: () => T, disableLogging?: boolean): readonly [null, T] | readonly [E, undefined];
|
|
15
|
+
/**
|
|
16
|
+
* Executes an asynchronous function (Promise) within a try-catch block.
|
|
17
|
+
* @template T The resolved value type of the Promise.
|
|
18
|
+
* @template E The type of the error that might be rejected (defaults to Error).
|
|
19
|
+
* @param fn The Promise to await.
|
|
20
|
+
* @param disableLogging console.error is default way of logging on error. You can disable it by setting it true
|
|
21
|
+
* @returns A tuple containing the resolved value of the Promise and an error (null if successful).
|
|
22
|
+
*/
|
|
23
|
+
static asyncFunction<T, E = Error>(fn: Promise<T>, disableLogging?: boolean): Promise<readonly [null, Awaited<T>] | readonly [E, undefined]>;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TryCatch";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powfix/core-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "core package",
|
|
5
5
|
"author": "Kwon Kyung-Min <powfix@gmail.com>",
|
|
6
6
|
"private": false,
|
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
"homepage": "https://github.com/powfix/core-js",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"require": "./dist/cjs/index.js",
|
|
21
|
+
"import": "./dist/esm/index.mjs",
|
|
22
|
+
"default": "./dist/cjs/index.js",
|
|
23
|
+
"types": "./dist/types/index.d.ts"
|
|
24
|
+
},
|
|
19
25
|
"./browser": {
|
|
20
26
|
"require": "./dist/browser/cjs/index.browser.js",
|
|
21
27
|
"import": "./dist/browser/esm/index.browser.mjs",
|
|
@@ -33,9 +39,9 @@
|
|
|
33
39
|
"clean": "rm -rf dist | wc -l",
|
|
34
40
|
"esmfix": "tsc-esm-fix --ext='.mjs'",
|
|
35
41
|
"prebuild": "yarn clean",
|
|
36
|
-
"build:esm": "tsc -p tsconfig.browser.esm.json && tsc -p tsconfig.node.esm.json && yarn esmfix",
|
|
37
|
-
"build:cjs": "tsc -p tsconfig.browser.cjs.json && tsc -p tsconfig.node.cjs.json",
|
|
38
|
-
"build:types": "tsc -p tsconfig.browser.types.json && tsc -p tsconfig.node.types.json",
|
|
42
|
+
"build:esm": "tsc -p tsconfig.index.esm.json && tsc -p tsconfig.browser.esm.json && tsc -p tsconfig.node.esm.json && yarn esmfix",
|
|
43
|
+
"build:cjs": "tsc -p tsconfig.index.cjs.json && tsc -p tsconfig.browser.cjs.json && tsc -p tsconfig.node.cjs.json",
|
|
44
|
+
"build:types": "tsc -p tsconfig.index.types.json && tsc -p tsconfig.browser.types.json && tsc -p tsconfig.node.types.json",
|
|
39
45
|
"build": "yarn build:esm && yarn build:cjs && yarn build:types",
|
|
40
46
|
"deploy": "yarn deploy:patch",
|
|
41
47
|
"deploy:patch": "npm version patch && npm publish",
|