@kikiutils/shared 18.0.0 → 18.1.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/buffer.d.ts +19 -21
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.js +18 -19
- package/dist/buffer.js.map +1 -1
- package/dist/classes/enhanced-date.d.ts +425 -0
- package/dist/classes/enhanced-date.d.ts.map +1 -0
- package/dist/classes/enhanced-date.js +591 -0
- package/dist/classes/enhanced-date.js.map +1 -0
- package/dist/classes/path.d.ts +211 -48
- package/dist/classes/path.d.ts.map +1 -1
- package/dist/classes/path.js +181 -52
- package/dist/classes/path.js.map +1 -1
- package/dist/classes/precision-number.d.ts +44 -39
- package/dist/classes/precision-number.d.ts.map +1 -1
- package/dist/classes/precision-number.js +51 -45
- package/dist/classes/precision-number.js.map +1 -1
- package/dist/classes/ssh-client.d.ts +3 -4
- package/dist/classes/ssh-client.d.ts.map +1 -1
- package/dist/classes/ssh-client.js +2 -2
- package/dist/classes/ssh-client.js.map +1 -1
- package/dist/clipboard.d.ts +25 -26
- package/dist/clipboard.d.ts.map +1 -1
- package/dist/clipboard.js +23 -23
- package/dist/clipboard.js.map +1 -1
- package/dist/consola.d.ts +12 -15
- package/dist/consola.d.ts.map +1 -1
- package/dist/consola.js +10 -12
- package/dist/consola.js.map +1 -1
- package/dist/crypto-hash.d.ts +65 -56
- package/dist/crypto-hash.d.ts.map +1 -1
- package/dist/crypto-hash.js +55 -45
- package/dist/crypto-hash.js.map +1 -1
- package/dist/datetime.d.ts +41 -53
- package/dist/datetime.d.ts.map +1 -1
- package/dist/datetime.js +53 -66
- package/dist/datetime.js.map +1 -1
- package/dist/element-plus.d.ts +13 -14
- package/dist/element-plus.d.ts.map +1 -1
- package/dist/element-plus.js +11 -11
- package/dist/element-plus.js.map +1 -1
- package/dist/enum.d.ts +39 -36
- package/dist/enum.d.ts.map +1 -1
- package/dist/enum.js +36 -32
- package/dist/enum.js.map +1 -1
- package/dist/env.d.ts +22 -15
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -12
- package/dist/env.js.map +1 -1
- package/dist/event-awaiter.d.ts +47 -52
- package/dist/event-awaiter.d.ts.map +1 -1
- package/dist/event-awaiter.js +46 -50
- package/dist/event-awaiter.js.map +1 -1
- package/dist/general.d.ts +22 -17
- package/dist/general.d.ts.map +1 -1
- package/dist/general.js.map +1 -1
- package/dist/hash.d.ts +24 -21
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +20 -16
- package/dist/hash.js.map +1 -1
- package/dist/math.d.ts +20 -19
- package/dist/math.d.ts.map +1 -1
- package/dist/math.js +14 -12
- package/dist/math.js.map +1 -1
- package/dist/number.d.ts +10 -9
- package/dist/number.d.ts.map +1 -1
- package/dist/number.js +9 -7
- package/dist/number.js.map +1 -1
- package/dist/object.d.ts +22 -10
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +21 -8
- package/dist/object.js.map +1 -1
- package/dist/pino.d.ts +12 -15
- package/dist/pino.d.ts.map +1 -1
- package/dist/pino.js +10 -15
- package/dist/pino.js.map +1 -1
- package/dist/random.d.ts +17 -15
- package/dist/random.d.ts.map +1 -1
- package/dist/random.js +16 -13
- package/dist/random.js.map +1 -1
- package/dist/redis/script-runner.d.ts +57 -0
- package/dist/redis/script-runner.d.ts.map +1 -0
- package/dist/redis/script-runner.js +46 -0
- package/dist/redis/script-runner.js.map +1 -0
- package/dist/storages/lru/keyed-store.d.ts +18 -14
- package/dist/storages/lru/keyed-store.d.ts.map +1 -1
- package/dist/storages/lru/keyed-store.js +17 -12
- package/dist/storages/lru/keyed-store.js.map +1 -1
- package/dist/storages/redis/keyed-store.d.ts +11 -21
- package/dist/storages/redis/keyed-store.d.ts.map +1 -1
- package/dist/storages/redis/keyed-store.js +10 -19
- package/dist/storages/redis/keyed-store.js.map +1 -1
- package/dist/storages/redis/msgpack.d.ts +33 -13
- package/dist/storages/redis/msgpack.d.ts.map +1 -1
- package/dist/storages/redis/msgpack.js +32 -11
- package/dist/storages/redis/msgpack.js.map +1 -1
- package/dist/storages/redis/types.d.ts +34 -17
- package/dist/storages/redis/types.d.ts.map +1 -1
- package/dist/string.d.ts +12 -11
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +20 -15
- package/dist/string.js.map +1 -1
- package/dist/time.d.ts +35 -10
- package/dist/time.d.ts.map +1 -1
- package/dist/time.js +49 -9
- package/dist/time.js.map +1 -1
- package/dist/types/filtered-key-path.d.ts +4 -15
- package/dist/types/filtered-key-path.d.ts.map +1 -1
- package/dist/types/index.d.ts +10 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/vue.d.ts +7 -7
- package/dist/types/vue.d.ts.map +1 -1
- package/dist/url.d.ts +15 -14
- package/dist/url.d.ts.map +1 -1
- package/dist/url.js +12 -10
- package/dist/url.js.map +1 -1
- package/dist/vue.d.ts +19 -21
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +15 -16
- package/dist/vue.js.map +1 -1
- package/dist/web.d.ts +14 -11
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +12 -8
- package/dist/web.js.map +1 -1
- package/package.json +20 -20
- package/src/buffer.ts +18 -19
- package/src/classes/enhanced-date.ts +665 -0
- package/src/classes/path.ts +232 -91
- package/src/classes/precision-number.ts +61 -53
- package/src/classes/ssh-client.ts +8 -5
- package/src/clipboard.ts +23 -23
- package/src/consola.ts +10 -12
- package/src/crypto-hash.ts +55 -45
- package/src/datetime.ts +65 -85
- package/src/element-plus.ts +11 -11
- package/src/enum.ts +36 -32
- package/src/env.ts +20 -12
- package/src/event-awaiter.ts +49 -50
- package/src/general.ts +20 -14
- package/src/hash.ts +20 -16
- package/src/math.ts +18 -16
- package/src/number.ts +9 -7
- package/src/object.ts +21 -8
- package/src/pino.ts +11 -15
- package/src/random.ts +16 -13
- package/src/redis/script-runner.ts +107 -0
- package/src/storages/lru/keyed-store.ts +17 -12
- package/src/storages/redis/keyed-store.ts +10 -19
- package/src/storages/redis/msgpack.ts +32 -11
- package/src/storages/redis/types.ts +32 -14
- package/src/string.ts +10 -8
- package/src/time.ts +52 -8
- package/src/types/filtered-key-path.ts +9 -14
- package/src/types/vue.ts +6 -5
- package/src/url.ts +12 -10
- package/src/vue.ts +15 -16
- package/src/web.ts +12 -8
package/dist/types/index.d.ts
CHANGED
|
@@ -4,39 +4,39 @@ import { Blob as Blob$1, Buffer, File as File$1 } from "node:buffer";
|
|
|
4
4
|
/**
|
|
5
5
|
* A generic string-keyed object for utility APIs that intentionally accept any value shape.
|
|
6
6
|
*/
|
|
7
|
-
type AnyRecord = Record<string, any>;
|
|
7
|
+
export type AnyRecord = Record<string, any>;
|
|
8
8
|
/**
|
|
9
9
|
* Binary-like inputs accepted by `toBuffer` across browser and Node.js runtimes.
|
|
10
10
|
*/
|
|
11
|
-
type BinaryInput = ArrayBuffer | Blob | Buffer | File | Blob$1 | File$1 | Uint8Array;
|
|
11
|
+
export type BinaryInput = ArrayBuffer | Blob | Buffer | File | Blob$1 | File$1 | Uint8Array;
|
|
12
12
|
/**
|
|
13
13
|
* Boolean values represented either as booleans or common string literals.
|
|
14
14
|
*/
|
|
15
|
-
type Booleanish = 'false' | 'true' | boolean;
|
|
15
|
+
export type Booleanish = 'false' | 'true' | boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Accepts either a full object or a partial patch of that object.
|
|
18
18
|
*/
|
|
19
|
-
type MaybePartial<T> = Partial<T> | T;
|
|
19
|
+
export type MaybePartial<T> = Partial<T> | T;
|
|
20
20
|
/**
|
|
21
21
|
* Accepts either a mutable value or a readonly view of that value.
|
|
22
22
|
*/
|
|
23
|
-
type MaybeReadonly<T> = Readonly<T> | T;
|
|
23
|
+
export type MaybeReadonly<T> = Readonly<T> | T;
|
|
24
24
|
/**
|
|
25
25
|
* Number-like value represented as a number or a numeric string.
|
|
26
26
|
*/
|
|
27
|
-
type Numberish = number | string;
|
|
27
|
+
export type Numberish = number | string;
|
|
28
28
|
/**
|
|
29
29
|
* A `Record` where every key is optional.
|
|
30
30
|
*/
|
|
31
|
-
type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>;
|
|
31
|
+
export type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>;
|
|
32
32
|
/**
|
|
33
33
|
* A readonly `PartialRecord`.
|
|
34
34
|
*/
|
|
35
|
-
type ReadonlyPartialRecord<K extends keyof any, T> = Readonly<PartialRecord<K, T>>;
|
|
35
|
+
export type ReadonlyPartialRecord<K extends keyof any, T> = Readonly<PartialRecord<K, T>>;
|
|
36
36
|
/**
|
|
37
37
|
* A readonly `Record`.
|
|
38
38
|
*/
|
|
39
|
-
type ReadonlyRecord<K extends keyof any, T> = Readonly<Record<K, T>>;
|
|
39
|
+
export type ReadonlyRecord<K extends keyof any, T> = Readonly<Record<K, T>>;
|
|
40
40
|
//#endregion
|
|
41
|
-
export {
|
|
41
|
+
export type { FilteredKeyPath };
|
|
42
42
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["NodeBlob","NodeFile"],"sources":["../../src/types/index.ts"],"mappings":";;;;;;YAWY,YAAY;;;;YAKZ,cAAc,cAAc,OAAO,SAAS,OAAOA,SAAWC,SAAW;;;;YAKzE;;;;YAKA,aAAa,KAAK,QAAQ,KAAK;;;;YAK/B,cAAc,KAAK,SAAS,KAAK;;;;YAKjC;;;;YAKA,cAAc,qBAAqB,KAAK,QAAQ,OAAO,GAAG;;;;YAK1D,sBAAsB,qBAAqB,KAAK,SAAS,cAAc,GAAG;;;;YAK1E,eAAe,qBAAqB,KAAK,SAAS,OAAO,GAAG"}
|
package/dist/types/vue.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { GlobalComponents } from "vue";
|
|
2
2
|
//#region src/types/vue.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* A
|
|
5
|
-
* The reference can be either an instance of the specified component or null.
|
|
4
|
+
* A nullable reference to an instance of a globally registered Vue component.
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
6
|
+
* @typeParam K - The component name in Vue's `GlobalComponents` registry.
|
|
8
7
|
*
|
|
9
8
|
* @example
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import type { ComponentRef } from '@kikiutils/shared/types/vue';
|
|
12
|
+
* import { ref } from 'vue';
|
|
12
13
|
*
|
|
13
14
|
* const keepAliveRef = ref<ComponentRef<'KeepAlive'>>(null);
|
|
14
15
|
* ```
|
|
15
16
|
*/
|
|
16
|
-
type ComponentRef<K extends keyof GlobalComponents> = InstanceType<GlobalComponents[K]> | null;
|
|
17
|
+
export type ComponentRef<K extends keyof GlobalComponents> = InstanceType<GlobalComponents[K]> | null;
|
|
17
18
|
//#endregion
|
|
18
|
-
export { ComponentRef };
|
|
19
19
|
//# sourceMappingURL=vue.d.ts.map
|
package/dist/types/vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.d.ts","names":[],"sources":["../../src/types/vue.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vue.d.ts","names":[],"sources":["../../src/types/vue.ts"],"mappings":";;;;;;;;;;;;;;;;YAgBY,aAAa,gBAAgB,oBAAoB,aAAa,iBAAiB"}
|
package/dist/url.d.ts
CHANGED
|
@@ -2,41 +2,42 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Appends or updates the `redirect` query parameter on a given URL.
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* Typically used to preserve the user's current path for post-login navigation.
|
|
6
7
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* (must be a safe same-origin application path starting with `/`)
|
|
8
|
+
* @param url - The target URL to modify.
|
|
9
|
+
* @param redirectPath - The safe same-origin application path starting with `/` to use as the redirect destination.
|
|
10
10
|
*
|
|
11
|
-
* @returns
|
|
11
|
+
* @returns A new URL string with the `redirect` query parameter.
|
|
12
12
|
*
|
|
13
|
-
* @throws
|
|
13
|
+
* @throws Error if `redirectPath` is not a safe same-origin application path.
|
|
14
14
|
*/
|
|
15
|
-
declare function appendRedirectParamToUrl(url: string, redirectPath: string): string;
|
|
15
|
+
export declare function appendRedirectParamToUrl(url: string, redirectPath: string): string;
|
|
16
16
|
/**
|
|
17
17
|
* Returns whether a value is a safe same-origin redirect path.
|
|
18
18
|
*
|
|
19
|
+
* @remarks
|
|
19
20
|
* Safe redirect paths are absolute application paths such as `/dashboard`.
|
|
20
21
|
* Protocol-relative URLs (`//example.com`), absolute URLs, backslash paths,
|
|
21
22
|
* and non-string values are rejected.
|
|
22
23
|
*
|
|
23
|
-
* @param
|
|
24
|
+
* @param value - The value to check.
|
|
24
25
|
*
|
|
25
|
-
* @returns
|
|
26
|
+
* @returns Whether the value is safe to use as an application redirect path.
|
|
26
27
|
*/
|
|
27
|
-
declare function isSafeRedirectPath(value: unknown): value is string;
|
|
28
|
+
export declare function isSafeRedirectPath(value: unknown): value is string;
|
|
28
29
|
/**
|
|
29
30
|
* Normalizes a redirect value into a safe same-origin application path.
|
|
30
31
|
*
|
|
32
|
+
* @remarks
|
|
31
33
|
* If an array is provided, the first value is checked. Unsafe values fall back
|
|
32
34
|
* to the provided fallback path.
|
|
33
35
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
+
* @param value - The redirect value to normalize.
|
|
37
|
+
* @param fallback - The caller-supplied safe fallback path; it is returned unchanged and is not validated.
|
|
36
38
|
*
|
|
37
|
-
* @returns
|
|
39
|
+
* @returns The validated input path, or the unvalidated fallback path.
|
|
38
40
|
*/
|
|
39
|
-
declare function normalizeRedirectPath(value: unknown, fallback?: string): string;
|
|
41
|
+
export declare function normalizeRedirectPath(value: unknown, fallback?: string): string;
|
|
40
42
|
//#endregion
|
|
41
|
-
export { appendRedirectParamToUrl, isSafeRedirectPath, normalizeRedirectPath };
|
|
42
43
|
//# sourceMappingURL=url.d.ts.map
|
package/dist/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","names":[],"sources":["../src/url.ts"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"url.d.ts","names":[],"sources":["../src/url.ts"],"mappings":";;;;;;;;;;;;;;wBAagB,yBAAyB,aAAa;;;;;;;;;;;;;wBAwBtC,mBAAmB,iBAAiB;;;;;;;;;;;;;wBAoBpC,sBAAsB,gBAAgB"}
|
package/dist/url.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Appends or updates the `redirect` query parameter on a given URL.
|
|
4
4
|
*
|
|
5
|
+
* @remarks
|
|
5
6
|
* Typically used to preserve the user's current path for post-login navigation.
|
|
6
7
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* (must be a safe same-origin application path starting with `/`)
|
|
8
|
+
* @param url - The target URL to modify.
|
|
9
|
+
* @param redirectPath - The safe same-origin application path starting with `/` to use as the redirect destination.
|
|
10
10
|
*
|
|
11
|
-
* @returns
|
|
11
|
+
* @returns A new URL string with the `redirect` query parameter.
|
|
12
12
|
*
|
|
13
|
-
* @throws
|
|
13
|
+
* @throws Error if `redirectPath` is not a safe same-origin application path.
|
|
14
14
|
*/
|
|
15
15
|
function appendRedirectParamToUrl(url, redirectPath) {
|
|
16
16
|
if (!isSafeRedirectPath(redirectPath)) throw new Error(`Invalid redirect path: "${redirectPath}". Redirect paths must be safe same-origin paths starting with '/'.`);
|
|
@@ -24,13 +24,14 @@ function appendRedirectParamToUrl(url, redirectPath) {
|
|
|
24
24
|
/**
|
|
25
25
|
* Returns whether a value is a safe same-origin redirect path.
|
|
26
26
|
*
|
|
27
|
+
* @remarks
|
|
27
28
|
* Safe redirect paths are absolute application paths such as `/dashboard`.
|
|
28
29
|
* Protocol-relative URLs (`//example.com`), absolute URLs, backslash paths,
|
|
29
30
|
* and non-string values are rejected.
|
|
30
31
|
*
|
|
31
|
-
* @param
|
|
32
|
+
* @param value - The value to check.
|
|
32
33
|
*
|
|
33
|
-
* @returns
|
|
34
|
+
* @returns Whether the value is safe to use as an application redirect path.
|
|
34
35
|
*/
|
|
35
36
|
function isSafeRedirectPath(value) {
|
|
36
37
|
if (typeof value !== "string") return false;
|
|
@@ -42,13 +43,14 @@ function isSafeRedirectPath(value) {
|
|
|
42
43
|
/**
|
|
43
44
|
* Normalizes a redirect value into a safe same-origin application path.
|
|
44
45
|
*
|
|
46
|
+
* @remarks
|
|
45
47
|
* If an array is provided, the first value is checked. Unsafe values fall back
|
|
46
48
|
* to the provided fallback path.
|
|
47
49
|
*
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
+
* @param value - The redirect value to normalize.
|
|
51
|
+
* @param fallback - The caller-supplied safe fallback path; it is returned unchanged and is not validated.
|
|
50
52
|
*
|
|
51
|
-
* @returns
|
|
53
|
+
* @returns The validated input path, or the unvalidated fallback path.
|
|
52
54
|
*/
|
|
53
55
|
function normalizeRedirectPath(value, fallback = "/") {
|
|
54
56
|
const redirectPath = Array.isArray(value) ? value[0] : value;
|
package/dist/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","names":[],"sources":["../src/url.ts"],"sourcesContent":["/**\n * Appends or updates the `redirect` query parameter on a given URL.\n *\n * Typically used to preserve the user's current path for post-login navigation.\n *\n * @param
|
|
1
|
+
{"version":3,"file":"url.js","names":[],"sources":["../src/url.ts"],"sourcesContent":["/**\n * Appends or updates the `redirect` query parameter on a given URL.\n *\n * @remarks\n * Typically used to preserve the user's current path for post-login navigation.\n *\n * @param url - The target URL to modify.\n * @param redirectPath - The safe same-origin application path starting with `/` to use as the redirect destination.\n *\n * @returns A new URL string with the `redirect` query parameter.\n *\n * @throws Error if `redirectPath` is not a safe same-origin application path.\n */\nexport function appendRedirectParamToUrl(url: string, redirectPath: string) {\n // eslint-disable-next-line style/max-len\n if (!isSafeRedirectPath(redirectPath)) throw new Error(`Invalid redirect path: \"${redirectPath}\". Redirect paths must be safe same-origin paths starting with '/'.`);\n\n const [baseAndHash, rawQuery = ''] = url.split('?');\n const [base, hash] = (baseAndHash || '').split('#');\n const searchParams = new URLSearchParams(rawQuery);\n searchParams.set('redirect', redirectPath);\n const queryString = searchParams.toString();\n return hash ? `${base}?${queryString}#${hash}` : `${base}?${queryString}`;\n}\n\n/**\n * Returns whether a value is a safe same-origin redirect path.\n *\n * @remarks\n * Safe redirect paths are absolute application paths such as `/dashboard`.\n * Protocol-relative URLs (`//example.com`), absolute URLs, backslash paths,\n * and non-string values are rejected.\n *\n * @param value - The value to check.\n *\n * @returns Whether the value is safe to use as an application redirect path.\n */\nexport function isSafeRedirectPath(value: unknown): value is string {\n if (typeof value !== 'string') return false;\n if (!value.startsWith('/')) return false;\n if (value.startsWith('//')) return false;\n if (value.includes('\\\\')) return false;\n return true;\n}\n\n/**\n * Normalizes a redirect value into a safe same-origin application path.\n *\n * @remarks\n * If an array is provided, the first value is checked. Unsafe values fall back\n * to the provided fallback path.\n *\n * @param value - The redirect value to normalize.\n * @param fallback - The caller-supplied safe fallback path; it is returned unchanged and is not validated.\n *\n * @returns The validated input path, or the unvalidated fallback path.\n */\nexport function normalizeRedirectPath(value: unknown, fallback = '/') {\n const redirectPath = Array.isArray(value) ? value[0] : value;\n return isSafeRedirectPath(redirectPath) ? redirectPath : fallback;\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,SAAgB,yBAAyB,KAAa,cAAsB;CAExE,IAAI,CAAC,mBAAmB,YAAY,GAAG,MAAM,IAAI,MAAM,2BAA2B,aAAa,oEAAoE;CAEnK,MAAM,CAAC,aAAa,WAAW,MAAM,IAAI,MAAM,GAAG;CAClD,MAAM,CAAC,MAAM,SAAS,eAAe,GAAA,CAAI,MAAM,GAAG;CAClD,MAAM,eAAe,IAAI,gBAAgB,QAAQ;CACjD,aAAa,IAAI,YAAY,YAAY;CACzC,MAAM,cAAc,aAAa,SAAS;CAC1C,OAAO,OAAO,GAAG,KAAK,GAAG,YAAY,GAAG,SAAS,GAAG,KAAK,GAAG;AAChE;;;;;;;;;;;;;AAcA,SAAgB,mBAAmB,OAAiC;CAChE,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,CAAC,MAAM,WAAW,GAAG,GAAG,OAAO;CACnC,IAAI,MAAM,WAAW,IAAI,GAAG,OAAO;CACnC,IAAI,MAAM,SAAS,IAAI,GAAG,OAAO;CACjC,OAAO;AACX;;;;;;;;;;;;;AAcA,SAAgB,sBAAsB,OAAgB,WAAW,KAAK;CAClE,MAAM,eAAe,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;CACvD,OAAO,mBAAmB,YAAY,IAAI,eAAe;AAC7D"}
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,40 +1,38 @@
|
|
|
1
1
|
import { Ref } from "vue";
|
|
2
2
|
//#region src/vue.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.
|
|
4
|
+
* Appends the current Vue Router route's `fullPath` as the `redirect` query parameter to the given URL.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param url - The base URL to modify.
|
|
7
7
|
*
|
|
8
|
-
* @returns
|
|
8
|
+
* @returns A new URL with the current route `fullPath` as the `redirect` parameter.
|
|
9
9
|
*/
|
|
10
|
-
declare function appendRedirectParamFromCurrentRouteToUrl(url: string): string;
|
|
10
|
+
export declare function appendRedirectParamFromCurrentRouteToUrl(url: string): string;
|
|
11
11
|
/**
|
|
12
|
-
* Clears an interval referenced by a Vue ref and sets it to null
|
|
12
|
+
* Clears an interval referenced by a Vue ref and sets it to `null`.
|
|
13
13
|
*
|
|
14
|
-
* @param
|
|
14
|
+
* @param intervalRef - A Vue ref holding a timer handle or `null`.
|
|
15
15
|
*/
|
|
16
|
-
declare function clearIntervalRef(intervalRef: Ref<null | ReturnType<typeof setInterval>>): void;
|
|
16
|
+
export declare function clearIntervalRef(intervalRef: Ref<null | ReturnType<typeof setInterval>>): void;
|
|
17
17
|
/**
|
|
18
|
-
* Clears a timeout referenced by a Vue ref and sets it to null
|
|
18
|
+
* Clears a timeout referenced by a Vue ref and sets it to `null`.
|
|
19
19
|
*
|
|
20
|
-
* @param
|
|
20
|
+
* @param timeoutRef - A Vue ref holding a timer handle or `null`.
|
|
21
21
|
*/
|
|
22
|
-
declare function clearTimeoutRef(timeoutRef: Ref<null | ReturnType<typeof setTimeout>>): void;
|
|
22
|
+
export declare function clearTimeoutRef(timeoutRef: Ref<null | ReturnType<typeof setTimeout>>): void;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* of a scrollable container across route changes and keep-alive activation.
|
|
24
|
+
* Registers hooks that save and restore a container's scroll position across kept-alive route changes.
|
|
26
25
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* Call within Vue component setup with Vue Router and `KeepAlive`.
|
|
28
|
+
* Route leave saves the current offsets, and each activation restores them to the currently referenced element.
|
|
29
|
+
* A missing element saves zero offsets and skips restoration. Without `KeepAlive`, unmounting discards the state.
|
|
30
|
+
* The hooks follow the component lifecycle; there is no separate cleanup handle.
|
|
29
31
|
*
|
|
30
|
-
*
|
|
31
|
-
* so scroll position will not be preserved.
|
|
32
|
+
* @typeParam T - The scrollable element type.
|
|
32
33
|
*
|
|
33
|
-
* @
|
|
34
|
-
*
|
|
35
|
-
* @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element
|
|
34
|
+
* @param containerRef - The reference to the scrollable element, or `null` while it is unavailable.
|
|
36
35
|
*/
|
|
37
|
-
declare function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<null | T>): void;
|
|
36
|
+
export declare function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<null | T>): void;
|
|
38
37
|
//#endregion
|
|
39
|
-
export { appendRedirectParamFromCurrentRouteToUrl, clearIntervalRef, clearTimeoutRef, usePreserveScroll };
|
|
40
38
|
//# sourceMappingURL=vue.d.ts.map
|
package/dist/vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.d.ts","names":[],"sources":["../src/vue.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"vue.d.ts","names":[],"sources":["../src/vue.ts"],"mappings":";;;;;;;;;wBAgBgB,yCAAyC;;;;;;wBASzC,iBAAiB,aAAa,WAAW,kBAAkB;;;;;;wBAU3D,gBAAgB,YAAY,WAAW,kBAAkB;;;;;;;;;;;;;;wBAkBzD,kBAAkB,UAAU,UAAU,aAAa,cAAc,WAAW"}
|
package/dist/vue.js
CHANGED
|
@@ -3,46 +3,45 @@ import { onActivated } from "vue";
|
|
|
3
3
|
import { onBeforeRouteLeave, useRoute } from "vue-router";
|
|
4
4
|
//#region src/vue.ts
|
|
5
5
|
/**
|
|
6
|
-
* Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.
|
|
6
|
+
* Appends the current Vue Router route's `fullPath` as the `redirect` query parameter to the given URL.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
8
|
+
* @param url - The base URL to modify.
|
|
9
9
|
*
|
|
10
|
-
* @returns
|
|
10
|
+
* @returns A new URL with the current route `fullPath` as the `redirect` parameter.
|
|
11
11
|
*/
|
|
12
12
|
function appendRedirectParamFromCurrentRouteToUrl(url) {
|
|
13
13
|
return appendRedirectParamToUrl(url, useRoute().fullPath);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Clears an interval referenced by a Vue ref and sets it to null
|
|
16
|
+
* Clears an interval referenced by a Vue ref and sets it to `null`.
|
|
17
17
|
*
|
|
18
|
-
* @param
|
|
18
|
+
* @param intervalRef - A Vue ref holding a timer handle or `null`.
|
|
19
19
|
*/
|
|
20
20
|
function clearIntervalRef(intervalRef) {
|
|
21
21
|
if (intervalRef.value) clearInterval(intervalRef.value);
|
|
22
22
|
intervalRef.value = null;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Clears a timeout referenced by a Vue ref and sets it to null
|
|
25
|
+
* Clears a timeout referenced by a Vue ref and sets it to `null`.
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
27
|
+
* @param timeoutRef - A Vue ref holding a timer handle or `null`.
|
|
28
28
|
*/
|
|
29
29
|
function clearTimeoutRef(timeoutRef) {
|
|
30
30
|
if (timeoutRef.value) clearTimeout(timeoutRef.value);
|
|
31
31
|
timeoutRef.value = null;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* of a scrollable container across route changes and keep-alive activation.
|
|
34
|
+
* Registers hooks that save and restore a container's scroll position across kept-alive route changes.
|
|
36
35
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Call within Vue component setup with Vue Router and `KeepAlive`.
|
|
38
|
+
* Route leave saves the current offsets, and each activation restores them to the currently referenced element.
|
|
39
|
+
* A missing element saves zero offsets and skips restoration. Without `KeepAlive`, unmounting discards the state.
|
|
40
|
+
* The hooks follow the component lifecycle; there is no separate cleanup handle.
|
|
39
41
|
*
|
|
40
|
-
*
|
|
41
|
-
* so scroll position will not be preserved.
|
|
42
|
+
* @typeParam T - The scrollable element type.
|
|
42
43
|
*
|
|
43
|
-
* @
|
|
44
|
-
*
|
|
45
|
-
* @param {Ref<null | T>} containerRef - A ref to the scrollable HTML element
|
|
44
|
+
* @param containerRef - The reference to the scrollable element, or `null` while it is unavailable.
|
|
46
45
|
*/
|
|
47
46
|
function usePreserveScroll(containerRef) {
|
|
48
47
|
let scrollLeft = 0;
|
package/dist/vue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.js","names":[],"sources":["../src/vue.ts"],"sourcesContent":["import { onActivated } from 'vue';\nimport type { Ref } from 'vue';\nimport {\n onBeforeRouteLeave,\n useRoute,\n} from 'vue-router';\n\nimport { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current Vue Router route's fullPath as the `redirect` query parameter to the given URL.\n *\n * @param
|
|
1
|
+
{"version":3,"file":"vue.js","names":[],"sources":["../src/vue.ts"],"sourcesContent":["import { onActivated } from 'vue';\nimport type { Ref } from 'vue';\nimport {\n onBeforeRouteLeave,\n useRoute,\n} from 'vue-router';\n\nimport { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current Vue Router route's `fullPath` as the `redirect` query parameter to the given URL.\n *\n * @param url - The base URL to modify.\n *\n * @returns A new URL with the current route `fullPath` as the `redirect` parameter.\n */\nexport function appendRedirectParamFromCurrentRouteToUrl(url: string) {\n return appendRedirectParamToUrl(url, useRoute().fullPath);\n}\n\n/**\n * Clears an interval referenced by a Vue ref and sets it to `null`.\n *\n * @param intervalRef - A Vue ref holding a timer handle or `null`.\n */\nexport function clearIntervalRef(intervalRef: Ref<null | ReturnType<typeof setInterval>>) {\n if (intervalRef.value) clearInterval(intervalRef.value);\n intervalRef.value = null;\n}\n\n/**\n * Clears a timeout referenced by a Vue ref and sets it to `null`.\n *\n * @param timeoutRef - A Vue ref holding a timer handle or `null`.\n */\nexport function clearTimeoutRef(timeoutRef: Ref<null | ReturnType<typeof setTimeout>>) {\n if (timeoutRef.value) clearTimeout(timeoutRef.value);\n timeoutRef.value = null;\n}\n\n/**\n * Registers hooks that save and restore a container's scroll position across kept-alive route changes.\n *\n * @remarks\n * Call within Vue component setup with Vue Router and `KeepAlive`.\n * Route leave saves the current offsets, and each activation restores them to the currently referenced element.\n * A missing element saves zero offsets and skips restoration. Without `KeepAlive`, unmounting discards the state.\n * The hooks follow the component lifecycle; there is no separate cleanup handle.\n *\n * @typeParam T - The scrollable element type.\n *\n * @param containerRef - The reference to the scrollable element, or `null` while it is unavailable.\n */\nexport function usePreserveScroll<T extends Element = HTMLElement>(containerRef: Ref<null | T>) {\n let scrollLeft = 0;\n let scrollTop = 0;\n onActivated(() => {\n if (!containerRef.value) return;\n containerRef.value.scrollLeft = scrollLeft;\n containerRef.value.scrollTop = scrollTop;\n });\n\n onBeforeRouteLeave(() => {\n scrollLeft = containerRef.value?.scrollLeft || 0;\n scrollTop = containerRef.value?.scrollTop || 0;\n });\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgB,yCAAyC,KAAa;CAClE,OAAO,yBAAyB,KAAK,SAAS,CAAC,CAAC,QAAQ;AAC5D;;;;;;AAOA,SAAgB,iBAAiB,aAAyD;CACtF,IAAI,YAAY,OAAO,cAAc,YAAY,KAAK;CACtD,YAAY,QAAQ;AACxB;;;;;;AAOA,SAAgB,gBAAgB,YAAuD;CACnF,IAAI,WAAW,OAAO,aAAa,WAAW,KAAK;CACnD,WAAW,QAAQ;AACvB;;;;;;;;;;;;;;AAeA,SAAgB,kBAAmD,cAA6B;CAC5F,IAAI,aAAa;CACjB,IAAI,YAAY;CAChB,kBAAkB;EACd,IAAI,CAAC,aAAa,OAAO;EACzB,aAAa,MAAM,aAAa;EAChC,aAAa,MAAM,YAAY;CACnC,CAAC;CAED,yBAAyB;EACrB,aAAa,aAAa,OAAO,cAAc;EAC/C,YAAY,aAAa,OAAO,aAAa;CACjD,CAAC;AACL"}
|
package/dist/web.d.ts
CHANGED
|
@@ -2,22 +2,25 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
5
|
+
* @param url - The base URL to modify.
|
|
6
6
|
*
|
|
7
|
-
* @returns
|
|
7
|
+
* @returns A new URL with the current location as the `redirect` parameter.
|
|
8
8
|
*/
|
|
9
|
-
declare function appendRedirectParamFromCurrentLocationToUrl(url: string): string;
|
|
9
|
+
export declare function appendRedirectParamFromCurrentLocationToUrl(url: string): string;
|
|
10
10
|
/**
|
|
11
|
-
* Navigates to
|
|
12
|
-
* (path, query, and hash) as the `redirect` query parameter.
|
|
11
|
+
* Navigates to a URL with the current browser path, query, and hash as its redirect parameter.
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Omitting `delayMs` navigates immediately. Providing a delay, including `0`, schedules navigation;
|
|
15
|
+
* the current location is read when the timer fires, not when the timer is created.
|
|
16
|
+
* Requires a browser environment. Redirect-path validation errors propagate from the URL helper.
|
|
16
17
|
*
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
18
|
+
* @param url - The destination URL.
|
|
19
|
+
* @param delayMs - The navigation delay in milliseconds, using native `setTimeout` timing rules.
|
|
20
|
+
*
|
|
21
|
+
* @returns A timer handle when delayed, which the caller can cancel with `clearTimeout`, or `undefined`
|
|
22
|
+
* when navigation is immediate.
|
|
19
23
|
*/
|
|
20
|
-
declare function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number): NodeJS.Timeout | undefined;
|
|
24
|
+
export declare function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number): NodeJS.Timeout | undefined;
|
|
21
25
|
//#endregion
|
|
22
|
-
export { appendRedirectParamFromCurrentLocationToUrl, assignUrlWithRedirectParamFromCurrentLocation };
|
|
23
26
|
//# sourceMappingURL=web.d.ts.map
|
package/dist/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","names":[],"sources":["../src/web.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"web.d.ts","names":[],"sources":["../src/web.ts"],"mappings":";;;;;;;;wBASgB,4CAA4C;;;;;;;;;;;;;;;wBAmB5C,8CAA8C,aAAa,mBAAgB,OAAA"}
|
package/dist/web.js
CHANGED
|
@@ -3,23 +3,27 @@ import { appendRedirectParamToUrl } from "./url.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param url - The base URL to modify.
|
|
7
7
|
*
|
|
8
|
-
* @returns
|
|
8
|
+
* @returns A new URL with the current location as the `redirect` parameter.
|
|
9
9
|
*/
|
|
10
10
|
function appendRedirectParamFromCurrentLocationToUrl(url) {
|
|
11
11
|
const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
12
12
|
return appendRedirectParamToUrl(url, currentPath);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Navigates to
|
|
16
|
-
* (path, query, and hash) as the `redirect` query parameter.
|
|
15
|
+
* Navigates to a URL with the current browser path, query, and hash as its redirect parameter.
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Omitting `delayMs` navigates immediately. Providing a delay, including `0`, schedules navigation;
|
|
19
|
+
* the current location is read when the timer fires, not when the timer is created.
|
|
20
|
+
* Requires a browser environment. Redirect-path validation errors propagate from the URL helper.
|
|
20
21
|
*
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
22
|
+
* @param url - The destination URL.
|
|
23
|
+
* @param delayMs - The navigation delay in milliseconds, using native `setTimeout` timing rules.
|
|
24
|
+
*
|
|
25
|
+
* @returns A timer handle when delayed, which the caller can cancel with `clearTimeout`, or `undefined`
|
|
26
|
+
* when navigation is immediate.
|
|
23
27
|
*/
|
|
24
28
|
function assignUrlWithRedirectParamFromCurrentLocation(url, delayMs) {
|
|
25
29
|
if (delayMs === void 0) window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url));
|
package/dist/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","names":[],"sources":["../src/web.ts"],"sourcesContent":["import { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.\n *\n * @param
|
|
1
|
+
{"version":3,"file":"web.js","names":[],"sources":["../src/web.ts"],"sourcesContent":["import { appendRedirectParamToUrl } from './url';\n\n/**\n * Appends the current browser URL (including path, query, and hash) as the `redirect` query parameter to the given URL.\n *\n * @param url - The base URL to modify.\n *\n * @returns A new URL with the current location as the `redirect` parameter.\n */\nexport function appendRedirectParamFromCurrentLocationToUrl(url: string) {\n const currentPath = `${window.location.pathname}${window.location.search}${window.location.hash}`;\n return appendRedirectParamToUrl(url, currentPath);\n}\n\n/**\n * Navigates to a URL with the current browser path, query, and hash as its redirect parameter.\n *\n * @remarks\n * Omitting `delayMs` navigates immediately. Providing a delay, including `0`, schedules navigation;\n * the current location is read when the timer fires, not when the timer is created.\n * Requires a browser environment. Redirect-path validation errors propagate from the URL helper.\n *\n * @param url - The destination URL.\n * @param delayMs - The navigation delay in milliseconds, using native `setTimeout` timing rules.\n *\n * @returns A timer handle when delayed, which the caller can cancel with `clearTimeout`, or `undefined`\n * when navigation is immediate.\n */\nexport function assignUrlWithRedirectParamFromCurrentLocation(url: string, delayMs?: number) {\n if (delayMs === undefined) window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url));\n else return setTimeout(() => window.location.assign(appendRedirectParamFromCurrentLocationToUrl(url)), delayMs);\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,4CAA4C,KAAa;CACrE,MAAM,cAAc,GAAG,OAAO,SAAS,WAAW,OAAO,SAAS,SAAS,OAAO,SAAS;CAC3F,OAAO,yBAAyB,KAAK,WAAW;AACpD;;;;;;;;;;;;;;;AAgBA,SAAgB,8CAA8C,KAAa,SAAkB;CACzF,IAAI,YAAY,KAAA,GAAW,OAAO,SAAS,OAAO,4CAA4C,GAAG,CAAC;MAC7F,OAAO,iBAAiB,OAAO,SAAS,OAAO,4CAA4C,GAAG,CAAC,GAAG,OAAO;AAClH"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "18.
|
|
4
|
+
"version": "18.1.0",
|
|
5
5
|
"description": "A lightweight and modular utility library for modern JavaScript and TypeScript — includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.",
|
|
6
6
|
"author": "kiki-kanri",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"lint:fix": "eslint --fix --max-warnings 0",
|
|
63
63
|
"prepack": "pnpm run build",
|
|
64
64
|
"release": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build && changelogen --hideAuthorEmail --push --release && npm publish",
|
|
65
|
-
"test": "cross-env TZ=UTC vitest run --coverage",
|
|
65
|
+
"test": "cross-env TZ=UTC vitest run --coverage && cross-env TZ='America/New_York' vitest run tests/classes/enhanced-date.test.ts",
|
|
66
66
|
"test:watch": "cross-env TZ=UTC vitest watch --coverage",
|
|
67
67
|
"typecheck": "tsc -b --noEmit"
|
|
68
68
|
},
|
|
@@ -135,36 +135,36 @@
|
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
"devDependencies": {
|
|
138
|
-
"@antfu/eslint-config": "^9.
|
|
139
|
-
"@kikiutils/eslint-config": "^9.2.
|
|
138
|
+
"@antfu/eslint-config": "^9.5.1",
|
|
139
|
+
"@kikiutils/eslint-config": "^9.2.1",
|
|
140
140
|
"@kikiutils/tsconfigs": "^7.0.0",
|
|
141
|
-
"@noble/hashes": "^2.
|
|
142
|
-
"@types/node": "^26.
|
|
143
|
-
"@types/ssh2": "^1.15.
|
|
144
|
-
"@vitest/coverage-v8": "^
|
|
141
|
+
"@noble/hashes": "^2.4.0",
|
|
142
|
+
"@types/node": "^26.6.3",
|
|
143
|
+
"@types/ssh2": "^1.15.6",
|
|
144
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
145
145
|
"async-validator": "^4.2.5",
|
|
146
|
-
"bson": "^7.3.
|
|
146
|
+
"bson": "^7.3.3",
|
|
147
147
|
"changelogen": "^0.6.2",
|
|
148
148
|
"consola": "^3.4.2",
|
|
149
149
|
"cross-env": "^10.1.0",
|
|
150
150
|
"date-fns": "^4.4.0",
|
|
151
151
|
"decimal.js": "^10.6.0",
|
|
152
|
-
"element-plus": "^2.14.
|
|
153
|
-
"eslint": "^10.
|
|
154
|
-
"jsdom": "^30.
|
|
155
|
-
"knip": "^6.
|
|
156
|
-
"lru-cache": "^11.5.
|
|
152
|
+
"element-plus": "^2.14.7",
|
|
153
|
+
"eslint": "^10.11.0",
|
|
154
|
+
"jsdom": "^30.1.1",
|
|
155
|
+
"knip": "^6.39.0",
|
|
156
|
+
"lru-cache": "^11.5.3",
|
|
157
157
|
"millify": "^6.1.0",
|
|
158
|
-
"msgpackr": "^2.0
|
|
158
|
+
"msgpackr": "^2.1.0",
|
|
159
159
|
"node-ssh": "^13.2.1",
|
|
160
160
|
"pino": "^10.3.1",
|
|
161
161
|
"pino-pretty": "^13.1.3",
|
|
162
|
-
"publint": "^0.3.
|
|
163
|
-
"tsdown": "^0.
|
|
162
|
+
"publint": "^0.3.25",
|
|
163
|
+
"tsdown": "^0.23.0",
|
|
164
164
|
"typescript": "^6.0.3",
|
|
165
165
|
"unplugin-unused": "^0.6.0",
|
|
166
|
-
"vitest": "^
|
|
167
|
-
"vue": "^3.5.
|
|
168
|
-
"vue-router": "^5.
|
|
166
|
+
"vitest": "^5.0.3",
|
|
167
|
+
"vue": "^3.5.43",
|
|
168
|
+
"vue-router": "^5.3.1"
|
|
169
169
|
}
|
|
170
170
|
}
|
package/src/buffer.ts
CHANGED
|
@@ -3,33 +3,32 @@ import { Buffer } from 'node:buffer';
|
|
|
3
3
|
import type { BinaryInput } from './types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Converts
|
|
6
|
+
* Converts binary input to a Node.js `Buffer`.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* optimal performance.
|
|
8
|
+
* @remarks
|
|
9
|
+
* An existing `Buffer` is returned unchanged. `ArrayBuffer` and `Uint8Array` inputs share their backing memory
|
|
10
|
+
* with the result, so changes are visible through both views. `Blob` and `File` inputs are read asynchronously.
|
|
12
11
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* Supports Blob, Buffer, File, ArrayBuffer, and Uint8Array.
|
|
12
|
+
* @param input - The binary data to convert.
|
|
15
13
|
*
|
|
16
|
-
* @returns
|
|
14
|
+
* @returns A promise resolving to the original buffer or a new buffer view after the input is available.
|
|
15
|
+
*
|
|
16
|
+
* @throws TypeError through promise rejection if the input is unsupported.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* import { toBuffer } from '@kikiutils/shared/buffer';
|
|
21
19
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* const bufferFromAB = await toBuffer(ab);
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { toBuffer } from '@kikiutils/shared/buffer';
|
|
25
22
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* const bytes = new Uint8Array([
|
|
24
|
+
* 10,
|
|
25
|
+
* 20,
|
|
26
|
+
* 30,
|
|
27
|
+
* ]);
|
|
29
28
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
29
|
+
* const buffer = await toBuffer(bytes);
|
|
30
|
+
* bytes[0] = 40;
|
|
31
|
+
* console.log(buffer[0]); // => 40
|
|
33
32
|
* ```
|
|
34
33
|
*/
|
|
35
34
|
export async function toBuffer(input: BinaryInput) {
|