@rtorcato/js-common 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +24 -0
- package/dist/abortController/index.d.ts +29 -0
- package/dist/abortController/index.d.ts.map +1 -0
- package/dist/arrays/index.d.ts +134 -0
- package/dist/arrays/index.d.ts.map +1 -0
- package/dist/boolean/index.d.ts +41 -0
- package/dist/boolean/index.d.ts.map +1 -0
- package/dist/colors/index.d.ts +63 -0
- package/dist/colors/index.d.ts.map +1 -0
- package/dist/console/index.d.ts +16 -0
- package/dist/console/index.d.ts.map +1 -0
- package/dist/crypto/index.d.ts +34 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/currency/currencies.d.ts +16 -0
- package/dist/currency/currencies.d.ts.map +1 -0
- package/dist/currency/index.d.ts +170 -0
- package/dist/currency/index.d.ts.map +1 -0
- package/dist/date/index.d.ts +44 -0
- package/dist/date/index.d.ts.map +1 -0
- package/dist/datetime/index.d.ts +52 -0
- package/dist/datetime/index.d.ts.map +1 -0
- package/dist/emails/banned/index.d.ts +9 -0
- package/dist/emails/banned/index.d.ts.map +1 -0
- package/dist/emails/index.d.ts +26 -0
- package/dist/emails/index.d.ts.map +1 -0
- package/dist/env/index.d.ts +63 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/errors/index.d.ts +39 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/events/index.d.ts +35 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/fetch/index.d.ts +38 -0
- package/dist/fetch/index.d.ts.map +1 -0
- package/dist/file/index.d.ts +32 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/formatting/index.d.ts +40 -0
- package/dist/formatting/index.d.ts.map +1 -0
- package/dist/functions/index.d.ts +33 -0
- package/dist/functions/index.d.ts.map +1 -0
- package/dist/geometry/index.d.ts +58 -0
- package/dist/geometry/index.d.ts.map +1 -0
- package/dist/html/index.d.ts +31 -0
- package/dist/html/index.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +37 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/interval/index.d.ts +13 -0
- package/dist/interval/index.d.ts.map +1 -0
- package/dist/json/index.d.ts +28 -0
- package/dist/json/index.d.ts.map +1 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/logger.d.ts +3 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logging/index.d.ts +29 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/maps/index.d.ts +32 -0
- package/dist/maps/index.d.ts.map +1 -0
- package/dist/math/index.d.ts +37 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/mime-types/db.d.ts +4605 -0
- package/dist/mime-types/db.d.ts.map +1 -0
- package/dist/mime-types/index.d.ts +25 -0
- package/dist/mime-types/index.d.ts.map +1 -0
- package/dist/node/index.d.ts +52 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/numbers/index.d.ts +82 -0
- package/dist/numbers/index.d.ts.map +1 -0
- package/dist/objects/index.d.ts +35 -0
- package/dist/objects/index.d.ts.map +1 -0
- package/dist/os/index.d.ts +26 -0
- package/dist/os/index.d.ts.map +1 -0
- package/dist/process/index.d.ts +31 -0
- package/dist/process/index.d.ts.map +1 -0
- package/dist/promises/index.d.ts +39 -0
- package/dist/promises/index.d.ts.map +1 -0
- package/dist/random/index.d.ts +33 -0
- package/dist/random/index.d.ts.map +1 -0
- package/dist/regex/index.d.ts +36 -0
- package/dist/regex/index.d.ts.map +1 -0
- package/dist/security/index.d.ts +14 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/sets/index.d.ts +48 -0
- package/dist/sets/index.d.ts.map +1 -0
- package/dist/sleep/index.d.ts +27 -0
- package/dist/sleep/index.d.ts.map +1 -0
- package/dist/strings/index.d.ts +296 -0
- package/dist/strings/index.d.ts.map +1 -0
- package/dist/system/index.d.ts +36 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/time/index.d.ts +36 -0
- package/dist/time/index.d.ts.map +1 -0
- package/dist/try/attempt.d.ts +8 -0
- package/dist/try/attempt.d.ts.map +1 -0
- package/dist/try/index.d.ts +2 -0
- package/dist/try/index.d.ts.map +1 -0
- package/dist/try/trycatch.d.ts +12 -0
- package/dist/try/trycatch.d.ts.map +1 -0
- package/dist/types/common/index.d.ts +9 -0
- package/dist/types/env.d.ts +5 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/url/index.d.ts +40 -0
- package/dist/url/index.d.ts.map +1 -0
- package/dist/uuid/index.d.ts +99 -0
- package/dist/uuid/index.d.ts.map +1 -0
- package/dist/validation/index.d.ts +49 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the current date and time as an ISO string (YYYY-MM-DDTHH:mm:ss.sssZ).
|
|
3
|
+
*/
|
|
4
|
+
export declare function nowIso(): string;
|
|
5
|
+
/**
|
|
6
|
+
* Parses an ISO date-time string to a Date object. Returns null if invalid.
|
|
7
|
+
* @param iso The ISO string.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseIsoDateTime(iso: string): Date | null;
|
|
10
|
+
/**
|
|
11
|
+
* Formats a Date as YYYY-MM-DD HH:mm:ss (local time).
|
|
12
|
+
* @param date The Date object.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatDateTimeLocal(date: Date): string;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the timezone offset in minutes for a given date (local - UTC).
|
|
17
|
+
* @param date The Date object.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getTimezoneOffset(date?: Date): number;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the UTC equivalent of a local Date.
|
|
22
|
+
* @param date The local Date object.
|
|
23
|
+
*/
|
|
24
|
+
export declare function toUtcDate(date: Date): Date;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the number of seconds since the Unix epoch (UTC).
|
|
27
|
+
*/
|
|
28
|
+
export declare function unixTimestamp(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the number of milliseconds since the Unix epoch.
|
|
31
|
+
*/
|
|
32
|
+
export declare function unixMillis(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the difference in seconds between two Date objects.
|
|
35
|
+
* @param a First date.
|
|
36
|
+
* @param b Second date.
|
|
37
|
+
*/
|
|
38
|
+
export declare function secondsBetween(a: Date, b: Date): number;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the ISO week number (1–53) of a given date using UTC.
|
|
41
|
+
* @param date A JavaScript Date object.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getIsoWeek(date: Date): number;
|
|
44
|
+
/**
|
|
45
|
+
* Returns ISO week number and ISO week year (which may differ from calendar year).
|
|
46
|
+
* @param date Date object (UTC-safe)
|
|
47
|
+
*/
|
|
48
|
+
export declare function getIsoWeekInfo(date: Date): {
|
|
49
|
+
week: number;
|
|
50
|
+
year: number;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datetime/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAGzD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAMtD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,IAAiB,GAAG,MAAM,CAEjE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAY1C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAoB7C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAmBzE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the domain part of the given email is present in a list of forbidden domains.
|
|
3
|
+
*
|
|
4
|
+
* @param email - The email address to check.
|
|
5
|
+
* @param forbiddenEmails - A newline-separated string of forbidden email domains.
|
|
6
|
+
* @throws Will throw an error if the email is not formatted properly or if the domain is forbidden.
|
|
7
|
+
*/
|
|
8
|
+
export declare const isEmailinBannedDomains: (email: string, forbiddenEmails: string) => void;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/emails/banned/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,EAAE,iBAAiB,MAAM,SAW5E,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates if a string is a valid email address (simple regex).
|
|
3
|
+
* @param email The email address to validate.
|
|
4
|
+
* @returns True if valid, false otherwise.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isValidEmail(email: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes an email address by trimming and converting to lowercase.
|
|
9
|
+
* @param email The email address to normalize.
|
|
10
|
+
* @returns The normalized email address.
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeEmail(email: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Masks an email address for privacy (e.g., j***@domain.com).
|
|
15
|
+
* @param email The email address to mask.
|
|
16
|
+
* @returns The masked email address.
|
|
17
|
+
*/
|
|
18
|
+
export declare function maskEmail(email: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Extracts the domain from an email address.
|
|
21
|
+
* @param email The email address.
|
|
22
|
+
* @returns The domain part of the email, or an empty string if invalid.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getEmailDomain(email: string): string;
|
|
25
|
+
export declare function isFreeEmailProvider(email: string): boolean;
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/emails/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD;AAiBD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE1D"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the value of an environment variable by its key.
|
|
4
|
+
*
|
|
5
|
+
* @param key - The name of the environment variable to retrieve.
|
|
6
|
+
* @param defaultValue - An optional default value to return if the environment variable is not defined.
|
|
7
|
+
* @returns The value of the environment variable if it exists, otherwise the default value if provided.
|
|
8
|
+
* @throws {Error} If the environment variable is undefined and no default value is provided.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getENV: (key: string, defaultValue?: string) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Determines if the current environment is set to development.
|
|
13
|
+
*
|
|
14
|
+
* @returns {boolean} `true` if `process.env.NODE_ENV` is `'development'`, otherwise `false`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const isDev: () => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Determines if the current environment is set to production.
|
|
19
|
+
*
|
|
20
|
+
* @returns {boolean} `true` if `process.env.NODE_ENV` is `'production'`, otherwise `false`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const isProd: () => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Determines if the current environment is set to test.
|
|
25
|
+
*
|
|
26
|
+
* @returns {boolean} `true` if `process.env.NODE_ENV` is `'test'`, otherwise `false`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const isTest: () => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the current NODE_ENV value, or 'development' if not set.
|
|
31
|
+
*
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
export declare const getNodeEnv: () => string;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* Validates the environment variables against a Zod schema.
|
|
38
|
+
* Throws an error if any required variables are missing or invalid.
|
|
39
|
+
* @param {z.ZodObject<T>} EnvSchema - The Zod schema to validate against.
|
|
40
|
+
* @param {Record<string, string | undefined>} buildEnv - The environment variables to validate, defaults to `process.env`.
|
|
41
|
+
* @throws {Error} If validation fails, an error with a message listing missing variables is thrown.
|
|
42
|
+
*/
|
|
43
|
+
export declare function checkEnv<T extends z.ZodRawShape>(EnvSchema: z.ZodObject<T>, buildEnv?: Record<string, string | undefined>): z.core.$InferObjectOutput<T, {}>;
|
|
44
|
+
/**
|
|
45
|
+
* Schema for validating the root environment variables.
|
|
46
|
+
* It includes NODE_ENV, LOG_LEVEL, and PORT with their respective types and defaults.
|
|
47
|
+
*/
|
|
48
|
+
export declare const RootApiEnvSchema: z.ZodObject<{
|
|
49
|
+
NODE_ENV: z.ZodDefault<z.ZodEnum<{
|
|
50
|
+
development: "development";
|
|
51
|
+
production: "production";
|
|
52
|
+
test: "test";
|
|
53
|
+
}>>;
|
|
54
|
+
LOG_LEVEL: z.ZodDefault<z.ZodEnum<{
|
|
55
|
+
debug: "debug";
|
|
56
|
+
info: "info";
|
|
57
|
+
warn: "warn";
|
|
58
|
+
error: "error";
|
|
59
|
+
}>>;
|
|
60
|
+
PORT: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type RootApiEnvSchema = z.infer<typeof RootApiEnvSchema>;
|
|
63
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,EAAE,eAAe,MAAM,WAUxD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAAO,OAExB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAO,OAEzB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAC/C,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACzB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,oCAc1D;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;iBAI3B,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new Error with a custom name and message.
|
|
3
|
+
* @param name The error name.
|
|
4
|
+
* @param message The error message.
|
|
5
|
+
* @returns The custom Error object.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createCustomError(name: string, message: string): Error;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if an error is an instance of a specific error name.
|
|
10
|
+
* @param error The error to check.
|
|
11
|
+
* @param name The error name to match.
|
|
12
|
+
* @returns True if the error matches the name, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isErrorName(error: unknown, name: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Gets the error message from an unknown error value.
|
|
17
|
+
* @param error The error value.
|
|
18
|
+
* @returns The error message, or a stringified version if not an Error.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
21
|
+
/**
|
|
22
|
+
* Throws an error if the condition is false.
|
|
23
|
+
* @param condition The condition to check.
|
|
24
|
+
* @param message The error message to throw if the condition is false.
|
|
25
|
+
*/
|
|
26
|
+
export declare function assert(condition: unknown, message: string): asserts condition;
|
|
27
|
+
/**
|
|
28
|
+
* Wraps a function and catches errors, returning a fallback value if an error occurs.
|
|
29
|
+
* Use this only when the fallback is genuinely safe and the error can be ignored.
|
|
30
|
+
* For typed error handling, prefer `tryCatch` from `@rtorcato/js-common/try`.
|
|
31
|
+
* @param fn The function to wrap.
|
|
32
|
+
* @param fallback The fallback value to return on error.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const result = await tryWithFallback(async () => fetchData(), [])
|
|
36
|
+
* // result will be [] if fetchData throws
|
|
37
|
+
*/
|
|
38
|
+
export declare function tryWithFallback<T>(fn: () => Promise<T> | T, fallback: T): Promise<T>;
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAItE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQtD;AAED;;;;GAIG;AAEH,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAI7E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAM1F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds an event listener and returns a function to remove it.
|
|
3
|
+
* @param target The event target.
|
|
4
|
+
* @param type The event type.
|
|
5
|
+
* @param handler The event handler.
|
|
6
|
+
* @param options Event listener options.
|
|
7
|
+
* @returns {() => void} Unsubscribe function.
|
|
8
|
+
*/
|
|
9
|
+
export declare function on<K extends keyof HTMLElementEventMap>(target: EventTarget, type: K, handler: (event: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Dispatches a custom event on the target.
|
|
12
|
+
* @param target The event target.
|
|
13
|
+
* @param type The event type.
|
|
14
|
+
* @param detail Optional detail data.
|
|
15
|
+
* @returns {boolean} True if not canceled.
|
|
16
|
+
*/
|
|
17
|
+
export declare function emit(target: EventTarget, type: string, detail?: unknown): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Waits for a single event to occur and resolves a promise.
|
|
20
|
+
* @param target The event target.
|
|
21
|
+
* @param type The event type.
|
|
22
|
+
* @returns {Promise<Event>} Resolves with the event object.
|
|
23
|
+
*/
|
|
24
|
+
export declare function once<K extends keyof HTMLElementEventMap>(target: EventTarget, type: K): Promise<HTMLElementEventMap[K]>;
|
|
25
|
+
/**
|
|
26
|
+
* Prevents the default action for an event.
|
|
27
|
+
* @param event The event object.
|
|
28
|
+
*/
|
|
29
|
+
export declare function preventDefault(event: Event): void;
|
|
30
|
+
/**
|
|
31
|
+
* Stops propagation for an event.
|
|
32
|
+
* @param event The event object.
|
|
33
|
+
*/
|
|
34
|
+
export declare function stopPropagation(event: Event): void;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACrD,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,EAChD,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GACzC,MAAM,IAAI,CAGZ;AAED;;;;;;GAMG;AAEH,wBAAgB,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACvD,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,CAAC,GACL,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAQjC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAEjD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAElD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches a resource with a timeout.
|
|
3
|
+
* @param url The URL to fetch.
|
|
4
|
+
* @param options Fetch options.
|
|
5
|
+
* @param timeout Timeout in milliseconds (default: 8000).
|
|
6
|
+
* @returns The parsed JSON response.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fetchWithTimeout(url: string, options?: RequestInit, timeout?: number): Promise<unknown>;
|
|
9
|
+
/**
|
|
10
|
+
* Sends a POST request with a JSON body.
|
|
11
|
+
* @param url The URL to post to.
|
|
12
|
+
* @param body The body to send.
|
|
13
|
+
* @param options Additional fetch options.
|
|
14
|
+
* @returns The parsed JSON response.
|
|
15
|
+
*/
|
|
16
|
+
export declare function postJson<T = unknown, R = unknown>(url: string, body: T, options?: RequestInit): Promise<R>;
|
|
17
|
+
/**
|
|
18
|
+
* Sends a GET request and returns JSON.
|
|
19
|
+
* @param url The URL to fetch.
|
|
20
|
+
* @param options Additional fetch options.
|
|
21
|
+
* @returns The parsed JSON response.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getJson<T = unknown>(url: string, options?: RequestInit): Promise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Fetches a resource and returns the response as text.
|
|
26
|
+
* @param url The URL to fetch.
|
|
27
|
+
* @param options Fetch options.
|
|
28
|
+
* @returns The response as text.
|
|
29
|
+
*/
|
|
30
|
+
export declare function fetchText(url: string, options?: RequestInit): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Handles fetch errors and returns a fallback value or throws.
|
|
33
|
+
* @param promise The fetch promise.
|
|
34
|
+
* @param fallback The fallback value to return on error.
|
|
35
|
+
* @returns The resolved value or the fallback.
|
|
36
|
+
*/
|
|
37
|
+
export declare function handleApiError<T>(promise: Promise<T>, fallback?: T): Promise<T>;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetch/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACrC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,OAAO,SAAO,GACZ,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EACtD,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,EACP,OAAO,GAAE,WAAgB,GACvB,OAAO,CAAC,CAAC,CAAC,CAQZ;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAG7F;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAGvF;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOrF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a file as a string (UTF-8).
|
|
3
|
+
* @param {string} filePath - The path to the file.
|
|
4
|
+
* @returns {Promise<string>} The file contents as a string.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readFileAsString(filePath: string): Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Writes a string to a file (UTF-8).
|
|
9
|
+
* @param {string} filePath - The path to the file.
|
|
10
|
+
* @param {string} data - The string data to write.
|
|
11
|
+
* @returns {Promise<void>}
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeFileAsString(filePath: string, data: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if a file exists.
|
|
16
|
+
* @param {string} filePath - The path to the file.
|
|
17
|
+
* @returns {Promise<boolean>} True if the file exists, false otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Deletes a file.
|
|
22
|
+
* @param {string} filePath - The path to the file.
|
|
23
|
+
* @returns {Promise<void>}
|
|
24
|
+
*/
|
|
25
|
+
export declare function deleteFile(filePath: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the file extension from a file path.
|
|
28
|
+
* @param {string} filePath - The path to the file.
|
|
29
|
+
* @returns {string} The file extension (including the dot), or an empty string if none.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getFileExtension(filePath: string): string;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAExE;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErF;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pads a string or number with leading zeros to a given length.
|
|
3
|
+
* @param value The value to pad.
|
|
4
|
+
* @param length The desired length.
|
|
5
|
+
* @returns The padded string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function padZero(value: string | number, length?: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Formats a number with thousands separators.
|
|
10
|
+
* @param num The number to format.
|
|
11
|
+
* @param locale Optional locale string (default: 'en-US').
|
|
12
|
+
* @returns The formatted string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatNumber(num: number, locale?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Formats a number as a percentage string.
|
|
17
|
+
* @param value The value to format (e.g. 0.25 for 25%).
|
|
18
|
+
* @param fractionDigits Number of decimal places (default: 0).
|
|
19
|
+
* @returns The formatted percentage string.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatPercent(value: number, fractionDigits?: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* Formats a Date as YYYY-MM-DD.
|
|
24
|
+
* @param date The date to format.
|
|
25
|
+
* @returns The formatted date string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatDate(date: Date): string;
|
|
28
|
+
/**
|
|
29
|
+
* Formats a Date as HH:MM:SS.
|
|
30
|
+
* @param date The date to format.
|
|
31
|
+
* @returns The formatted time string.
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatTime(date: Date): string;
|
|
34
|
+
/**
|
|
35
|
+
* Formats a Date as YYYY-MM-DD HH:MM:SS.
|
|
36
|
+
* @param date The date to format.
|
|
37
|
+
* @returns The formatted date-time string.
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatDateTime(date: Date): string;
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formatting/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAgB,GAAG,MAAM,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,SAAI,GAAG,MAAM,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEjD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a function that only calls the original function once.
|
|
3
|
+
* @param fn The function to wrap.
|
|
4
|
+
* @returns {Function}
|
|
5
|
+
*/
|
|
6
|
+
export declare function once<T extends (...args: any[]) => any>(fn: T): T;
|
|
7
|
+
/**
|
|
8
|
+
* Returns a debounced version of a function.
|
|
9
|
+
* @param fn The function to debounce.
|
|
10
|
+
* @param wait Milliseconds to wait.
|
|
11
|
+
* @returns {Function}
|
|
12
|
+
*/
|
|
13
|
+
export declare function debounce<T extends (...args: any[]) => void>(fn: T, wait: number): T;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a throttled version of a function.
|
|
16
|
+
* @param fn The function to throttle.
|
|
17
|
+
* @param wait Milliseconds to wait between calls.
|
|
18
|
+
* @returns {Function}
|
|
19
|
+
*/
|
|
20
|
+
export declare function throttle<T extends (...args: any[]) => void>(fn: T, wait: number): T;
|
|
21
|
+
/**
|
|
22
|
+
* Composes functions from right to left.
|
|
23
|
+
* @param fns Functions to compose.
|
|
24
|
+
* @returns {Function}
|
|
25
|
+
*/
|
|
26
|
+
export declare function compose<T>(...fns: Array<(arg: T) => T>): (arg: T) => T;
|
|
27
|
+
/**
|
|
28
|
+
* Pipes functions from left to right.
|
|
29
|
+
* @param fns Functions to pipe.
|
|
30
|
+
* @returns {Function}
|
|
31
|
+
*/
|
|
32
|
+
export declare function pipe<T>(...fns: Array<(arg: T) => T>): (arg: T) => T;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAUhE;AAED;;;;;GAKG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAMnF;AAED;;;;;GAKG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CASnF;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAEnE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the distance between two points in 2D space.
|
|
3
|
+
* @param x1 X coordinate of first point.
|
|
4
|
+
* @param y1 Y coordinate of first point.
|
|
5
|
+
* @param x2 X coordinate of second point.
|
|
6
|
+
* @param y2 Y coordinate of second point.
|
|
7
|
+
* @returns {number} The distance.
|
|
8
|
+
*/
|
|
9
|
+
export declare function distance2D(x1: number, y1: number, x2: number, y2: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Calculates the midpoint between two points in 2D space.
|
|
12
|
+
* @param x1 X coordinate of first point.
|
|
13
|
+
* @param y1 Y coordinate of first point.
|
|
14
|
+
* @param x2 X coordinate of second point.
|
|
15
|
+
* @param y2 Y coordinate of second point.
|
|
16
|
+
* @returns {[number, number]} The midpoint as [x, y].
|
|
17
|
+
*/
|
|
18
|
+
export declare function midpoint2D(x1: number, y1: number, x2: number, y2: number): [number, number];
|
|
19
|
+
/**
|
|
20
|
+
* Calculates the angle (in radians) between two points in 2D space.
|
|
21
|
+
* @param x1 X coordinate of first point.
|
|
22
|
+
* @param y1 Y coordinate of first point.
|
|
23
|
+
* @param x2 X coordinate of second point.
|
|
24
|
+
* @param y2 Y coordinate of second point.
|
|
25
|
+
* @returns {number} The angle in radians.
|
|
26
|
+
*/
|
|
27
|
+
export declare function angle2D(x1: number, y1: number, x2: number, y2: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if a point is inside a rectangle.
|
|
30
|
+
* @param px X coordinate of the point.
|
|
31
|
+
* @param py Y coordinate of the point.
|
|
32
|
+
* @param rx X coordinate of the rectangle's top-left corner.
|
|
33
|
+
* @param ry Y coordinate of the rectangle's top-left corner.
|
|
34
|
+
* @param rw Rectangle width.
|
|
35
|
+
* @param rh Rectangle height.
|
|
36
|
+
* @returns {boolean} True if inside, false otherwise.
|
|
37
|
+
*/
|
|
38
|
+
export declare function pointInRect(px: number, py: number, rx: number, ry: number, rw: number, rh: number): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if two rectangles overlap.
|
|
41
|
+
* @param ax X of rect A.
|
|
42
|
+
* @param ay Y of rect A.
|
|
43
|
+
* @param aw Width of rect A.
|
|
44
|
+
* @param ah Height of rect A.
|
|
45
|
+
* @param bx X of rect B.
|
|
46
|
+
* @param by Y of rect B.
|
|
47
|
+
* @param bw Width of rect B.
|
|
48
|
+
* @param bh Height of rect B.
|
|
49
|
+
* @returns {boolean} True if rectangles overlap.
|
|
50
|
+
*/
|
|
51
|
+
export declare function rectsOverlap(ax: number, ay: number, aw: number, ah: number, bx: number, by: number, bw: number, bh: number): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Calculates the area of a polygon given its vertices (Shoelace formula).
|
|
54
|
+
* @param points Array of [x, y] pairs.
|
|
55
|
+
* @returns {number} The area (positive value).
|
|
56
|
+
*/
|
|
57
|
+
export declare function polygonArea(points: [number, number][]): number;
|
|
58
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geometry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAE3F;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAC1B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACR,OAAO,CAET;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC3B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACR,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,MAAM,CAY9D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escapes special HTML characters in a string to prevent XSS attacks.
|
|
3
|
+
* @param str The string to escape.
|
|
4
|
+
* @returns The escaped string.
|
|
5
|
+
*/
|
|
6
|
+
export declare function escapeHtml(str: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Unescapes HTML entities in a string.
|
|
9
|
+
* @param str The string to unescape.
|
|
10
|
+
* @returns The unescaped string.
|
|
11
|
+
*/
|
|
12
|
+
export declare function unescapeHtml(str: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Strips all HTML tags from a string.
|
|
15
|
+
* @param str The string to strip tags from.
|
|
16
|
+
* @returns The plain text string.
|
|
17
|
+
*/
|
|
18
|
+
export declare function stripHtmlTags(str: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Converts a plain text string to a simple HTML paragraph (\n to <br>).
|
|
21
|
+
* @param str The plain text string.
|
|
22
|
+
* @returns The HTML string with <br> tags.
|
|
23
|
+
*/
|
|
24
|
+
export declare function textToHtml(str: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a string contains any HTML tags.
|
|
27
|
+
* @param str The string to check.
|
|
28
|
+
* @returns True if the string contains HTML tags, false otherwise.
|
|
29
|
+
*/
|
|
30
|
+
export declare function containsHtml(str: string): boolean;
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/html/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEjD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects the user's preferred language from the browser or Node.js environment.
|
|
3
|
+
* @returns {string} The language code (e.g., 'en', 'fr').
|
|
4
|
+
*/
|
|
5
|
+
export declare function detectLanguage(defaultLang?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Formats a number as a localized string.
|
|
8
|
+
* @param value The number to format.
|
|
9
|
+
* @param locale The locale code (e.g., 'en-US').
|
|
10
|
+
* @param options Intl.NumberFormat options.
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatNumber(value: number, locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
14
|
+
/**
|
|
15
|
+
* Formats a date as a localized string.
|
|
16
|
+
* @param date The date to format.
|
|
17
|
+
* @param locale The locale code (e.g., 'en-US').
|
|
18
|
+
* @param options Intl.DateTimeFormat options.
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatDateI18n(date: Date, locale?: string, options?: Intl.DateTimeFormatOptions): string;
|
|
22
|
+
/**
|
|
23
|
+
* Simple translation function using a dictionary object.
|
|
24
|
+
* @param key The translation key.
|
|
25
|
+
* @param dict The dictionary object (e.g., { en: { hello: 'Hello' }, fr: { hello: 'Bonjour' } }).
|
|
26
|
+
* @param lang The language code (optional, defaults to detected language).
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
export declare function t(key: string, dict: Record<string, Record<string, string>>, lang?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Pluralizes a word based on a count (basic English only).
|
|
32
|
+
* @param word The word to pluralize.
|
|
33
|
+
* @param count The count.
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
export declare function pluralize(word: string, count: number): string;
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,GAAE,MAAa,GAAG,MAAM,CAQjE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAChC,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,GAClC,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,CAAC,CAChB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC5C,IAAI,CAAC,EAAE,MAAM,GACX,MAAM,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs a function repeatedly at a specified interval (cross-platform).
|
|
3
|
+
* @param fn The function to run.
|
|
4
|
+
* @param ms The interval in milliseconds.
|
|
5
|
+
* @returns The interval ID (NodeJS.Timeout or number).
|
|
6
|
+
*/
|
|
7
|
+
export declare function runInterval(fn: () => void, ms: number): ReturnType<typeof setInterval>;
|
|
8
|
+
/**
|
|
9
|
+
* Cancels an interval by its ID (cross-platform).
|
|
10
|
+
* @param id The interval ID (NodeJS.Timeout or number).
|
|
11
|
+
*/
|
|
12
|
+
export declare function clearIntervalById(id: ReturnType<typeof setInterval>): void;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interval/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAEtF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,IAAI,CAE1E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safely parses a JSON string, returning a fallback value if parsing fails.
|
|
3
|
+
* @param {string} str - The JSON string to parse.
|
|
4
|
+
* @param {any} [fallback=null] - The value to return if parsing fails.
|
|
5
|
+
* @returns The parsed object or the fallback value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function safeJsonParse<T = any>(str: string, fallback?: T | null): T | null;
|
|
8
|
+
/**
|
|
9
|
+
* Safely stringifies a value to JSON, returning a fallback value if stringification fails.
|
|
10
|
+
* @param {any} value - The value to stringify.
|
|
11
|
+
* @param {string} [fallback=null] - The value to return if stringification fails.
|
|
12
|
+
* @returns The JSON string or the fallback value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function safeJsonStringify(value: any, fallback?: string | null): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Checks if a string is valid JSON.
|
|
17
|
+
* @param {string} str - The string to check.
|
|
18
|
+
* @returns {boolean} True if the string is valid JSON, false otherwise.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isValidJson(str: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Deep clones a value using JSON serialization.
|
|
23
|
+
* Note: Only works for JSON-safe values (no functions, undefined, etc).
|
|
24
|
+
* @param {T} value - The value to clone.
|
|
25
|
+
* @returns {T} The deep-cloned value.
|
|
26
|
+
*/
|
|
27
|
+
export declare function deepCloneJson<T>(value: T): T;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,CAAC,GAAG,IAAW,GAAG,CAAC,GAAG,IAAI,CAMvF;AAED;;;;;GAKG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,GAAG,IAAI,CAM3F;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOhD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAE5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAGvB,eAAO,MAAM,MAAM,6BAyBO,CAAA"}
|