@omnific/utils 0.4.0 → 0.5.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/@types/GetFieldType.d.ts +1 -2
- package/dist/@types/Many.d.ts +1 -3
- package/dist/@types/PropertyPath.d.ts +1 -3
- package/dist/_internal/isDeepKey.js +1 -2
- package/dist/_internal/isUnsafeProperty.js +1 -2
- package/dist/_internal/toKey.js +1 -2
- package/dist/buildURL.d.ts +20 -0
- package/dist/buildURL.js +39 -0
- package/dist/createChainedFunction.d.ts +0 -2
- package/dist/createChainedFunction.js +1 -2
- package/dist/debounce.d.ts +1 -3
- package/dist/debounce.js +3 -4
- package/dist/get.d.ts +1 -3
- package/dist/get.js +6 -7
- package/dist/hasValue.d.ts +0 -2
- package/dist/hasValue.js +1 -2
- package/dist/isArray.d.ts +1 -3
- package/dist/isArray.js +1 -2
- package/dist/isArrayBuffer.d.ts +1 -3
- package/dist/isArrayBuffer.js +1 -2
- package/dist/isArrayEmpty.d.ts +1 -3
- package/dist/isArrayEmpty.js +2 -3
- package/dist/isBlob.d.ts +1 -3
- package/dist/isBlob.js +1 -2
- package/dist/isBoolean.d.ts +1 -3
- package/dist/isBoolean.js +1 -2
- package/dist/isFormData.d.ts +1 -3
- package/dist/isFormData.js +1 -2
- package/dist/isFunction.d.ts +1 -3
- package/dist/isFunction.js +1 -2
- package/dist/isNil.d.ts +1 -3
- package/dist/isNil.js +1 -2
- package/dist/isNull.d.ts +1 -3
- package/dist/isNull.js +1 -2
- package/dist/isNumber.d.ts +1 -3
- package/dist/isNumber.js +1 -2
- package/dist/isObject.d.ts +1 -3
- package/dist/isObject.js +1 -2
- package/dist/isPlainObject.d.ts +1 -3
- package/dist/isPlainObject.js +2 -3
- package/dist/isPromise.d.ts +1 -3
- package/dist/isPromise.js +2 -3
- package/dist/isString.d.ts +1 -3
- package/dist/isString.js +1 -2
- package/dist/isStringEmpty.d.ts +1 -3
- package/dist/isStringEmpty.js +2 -3
- package/dist/isSymbol.d.ts +1 -3
- package/dist/isSymbol.js +1 -2
- package/dist/isURLSearchParameters.d.ts +1 -3
- package/dist/isURLSearchParameters.js +1 -2
- package/dist/isUndefined.d.ts +1 -3
- package/dist/isUndefined.js +1 -2
- package/dist/kebabCase.d.ts +1 -3
- package/dist/kebabCase.js +1 -2
- package/dist/main.d.ts +15 -14
- package/dist/main.js +9 -8
- package/dist/parseJson.d.ts +1 -3
- package/dist/parseJson.js +1 -2
- package/dist/resolveValue.d.ts +0 -2
- package/dist/resolveValue.js +1 -2
- package/dist/throttle.d.ts +1 -3
- package/dist/throttle.js +2 -3
- package/dist/uniqueId.d.ts +1 -3
- package/dist/uniqueId.js +1 -2
- package/dist/utils/toPath.js +2 -3
- package/dist/utils/toString.js +2 -3
- package/package.json +4 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region @types/GetFieldType.d.ts
|
|
2
1
|
type GetFieldTypeOfArrayLikeByKey<T extends unknown[], K> = K extends number ? T[K] : K extends `${infer N extends number}` ? T[N] : K extends keyof T ? T[K] : undefined;
|
|
3
2
|
type GetFieldTypeOfStringByKey<T extends string, K> = K extends number ? T[K] : K extends `${infer N extends number}` ? T[N] : K extends keyof T ? T[K] : undefined;
|
|
4
3
|
type GetFieldTypeOfNarrowedByKey<T, K> = T extends unknown[] ? GetFieldTypeOfArrayLikeByKey<T, K> : T extends string ? GetFieldTypeOfStringByKey<T, K> : K extends keyof T ? T[K] : K extends number ? `${K}` extends keyof T ? T[`${K}`] : undefined : K extends `${infer N extends number}` ? N extends keyof T ? T[N] : undefined : undefined;
|
|
@@ -12,4 +11,4 @@ type GetFieldTypeOfPrimitive<T, X, XT extends 'DotPath' | 'Key' | 'Path'> = Extr
|
|
|
12
11
|
* 解析指定键、点路径或括号路径对应的值类型。
|
|
13
12
|
*/
|
|
14
13
|
export type GetFieldType<T, X, XT extends 'DotPath' | 'Key' | 'Path' = 'Path'> = Extract<T, object> extends never ? GetFieldTypeOfPrimitive<T, X, XT> : GetFieldTypeOfPrimitive<Exclude<T, object>, X, XT> | GetFieldTypeOfObject<Extract<T, object>, X, XT>;
|
|
15
|
-
|
|
14
|
+
export {};
|
package/dist/@types/Many.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isString } from "../isString.js";
|
|
2
|
-
|
|
2
|
+
// _internal/isDeepKey.ts
|
|
3
3
|
/**
|
|
4
4
|
* Checks if a given key is a deep key.
|
|
5
5
|
*
|
|
@@ -20,5 +20,4 @@ import { isString } from "../isString.js";
|
|
|
20
20
|
function isDeepKey(key) {
|
|
21
21
|
return isString(key) ? key.includes(".") || key.includes("[") || key.includes("]") : false;
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { isDeepKey };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// _internal/isUnsafeProperty.ts
|
|
2
2
|
/**
|
|
3
3
|
* Checks if a property key is unsafe to modify directly.
|
|
4
4
|
*
|
|
@@ -12,5 +12,4 @@
|
|
|
12
12
|
function isUnsafeProperty(key) {
|
|
13
13
|
return key === "__proto__";
|
|
14
14
|
}
|
|
15
|
-
//#endregion
|
|
16
15
|
export { isUnsafeProperty };
|
package/dist/_internal/toKey.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isString } from "../isString.js";
|
|
2
2
|
import { isSymbol } from "../isSymbol.js";
|
|
3
|
-
|
|
3
|
+
// _internal/toKey.ts
|
|
4
4
|
/**
|
|
5
5
|
* 将属性路径片段规范化为字符串键。
|
|
6
6
|
*/
|
|
@@ -17,5 +17,4 @@ function normalizeKey(path) {
|
|
|
17
17
|
function toKey(value) {
|
|
18
18
|
return isString(value) || isSymbol(value) ? value : normalizeKey(value);
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
20
|
export { normalizeKey, toKey };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 查询参数序列化时接受的基础值类型。
|
|
3
|
+
*/
|
|
4
|
+
export type QueryValue = string | number | boolean | null | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* 查询参数映射。
|
|
7
|
+
*/
|
|
8
|
+
export type QueryParameters = Record<string, QueryValue | readonly QueryValue[]>;
|
|
9
|
+
/**
|
|
10
|
+
* buildURL 接受的查询参数。
|
|
11
|
+
*/
|
|
12
|
+
export type QueryInput = QueryParameters | URLSearchParams | string;
|
|
13
|
+
/**
|
|
14
|
+
* 将查询参数追加到 URL。
|
|
15
|
+
*
|
|
16
|
+
* - 支持对象、URLSearchParams 和原始查询字符串。
|
|
17
|
+
* - 对象中的 null/undefined 会被跳过,数组会展开为重复参数。
|
|
18
|
+
* - 保留已有查询参数,并按现有 request 行为移除 hash。
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildURL(url: string, parameters?: QueryInput): string;
|
package/dist/buildURL.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import hasValue from "./hasValue.js";
|
|
2
|
+
import { isNil } from "./isNil.js";
|
|
3
|
+
import { isString } from "./isString.js";
|
|
4
|
+
import { isStringEmpty } from "./isStringEmpty.js";
|
|
5
|
+
import { isURLSearchParameters } from "./isURLSearchParameters.js";
|
|
6
|
+
// buildURL.ts
|
|
7
|
+
function serializeParameters(parameters) {
|
|
8
|
+
if (isString(parameters)) return new URLSearchParams(parameters).toString();
|
|
9
|
+
if (isURLSearchParameters(parameters)) return parameters.toString();
|
|
10
|
+
const searchParameters = new URLSearchParams();
|
|
11
|
+
const keys = Object.keys(parameters);
|
|
12
|
+
for (let index = 0; index < keys.length; index += 1) {
|
|
13
|
+
const key = keys[index];
|
|
14
|
+
const value = parameters[key];
|
|
15
|
+
if (isNil(value)) continue;
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
for (const item of value) if (hasValue(item)) searchParameters.append(key, String(item));
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
searchParameters.append(key, String(value));
|
|
21
|
+
}
|
|
22
|
+
return searchParameters.toString();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 将查询参数追加到 URL。
|
|
26
|
+
*
|
|
27
|
+
* - 支持对象、URLSearchParams 和原始查询字符串。
|
|
28
|
+
* - 对象中的 null/undefined 会被跳过,数组会展开为重复参数。
|
|
29
|
+
* - 保留已有查询参数,并按现有 request 行为移除 hash。
|
|
30
|
+
*/
|
|
31
|
+
function buildURL(url, parameters) {
|
|
32
|
+
if (isNil(parameters)) return url;
|
|
33
|
+
const serializedParameters = serializeParameters(parameters);
|
|
34
|
+
if (isStringEmpty(serializedParameters)) return url;
|
|
35
|
+
const hashMarkIndex = url.indexOf("#");
|
|
36
|
+
const nextURL = hashMarkIndex === -1 ? url : url.slice(0, hashMarkIndex);
|
|
37
|
+
return `${nextURL}${nextURL.includes("?") ? "&" : "?"}${serializedParameters}`;
|
|
38
|
+
}
|
|
39
|
+
export { buildURL };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region createChainedFunction.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* A function with a bound `this` context and variadic arguments.
|
|
4
3
|
*/
|
|
@@ -15,5 +14,4 @@ export type ChainedFunction<TArguments extends any[], TThis> = (this: TThis, ...
|
|
|
15
14
|
* @returns {ChainedFunction<TArgs, TThis>} A single chained callback.
|
|
16
15
|
*/
|
|
17
16
|
export declare function createChainedFunction<TArguments extends any[], TThis>(...funcs: Array<ChainedFunction<TArguments, TThis> | null | undefined>): ChainedFunction<TArguments, TThis>;
|
|
18
|
-
//#endregion
|
|
19
17
|
export { createChainedFunction as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isArrayEmpty } from "./isArrayEmpty.js";
|
|
2
2
|
import hasValue from "./hasValue.js";
|
|
3
3
|
import { isFunction } from "./isFunction.js";
|
|
4
|
-
|
|
4
|
+
// createChainedFunction.ts
|
|
5
5
|
/**
|
|
6
6
|
* Composes multiple callbacks into a single callback while preserving `this`.
|
|
7
7
|
*
|
|
@@ -24,5 +24,4 @@ function createChainedFunction(...funcs) {
|
|
|
24
24
|
for (const function_ of validFuncs) function_.apply(this, arguments_);
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
//#endregion
|
|
28
27
|
export { createChainedFunction, createChainedFunction as default };
|
package/dist/debounce.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region debounce.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* 控制防抖函数何时调用或取消的选项。
|
|
4
3
|
*/
|
|
@@ -76,5 +75,4 @@ export interface DebouncedFunction<F extends (...arguments_: any[]) => void> {
|
|
|
76
75
|
* // Will cancel the debounced function call
|
|
77
76
|
* controller.abort();
|
|
78
77
|
*/
|
|
79
|
-
export declare function debounce<F extends (...arguments_: any[]) => void>(function_: F, debounceMs: number, { signal, edges }?: DebounceOptions): DebouncedFunction<F>;
|
|
80
|
-
//#endregion
|
|
78
|
+
export declare function debounce<F extends (...arguments_: any[]) => void>(function_: F, debounceMs: number, { signal, edges }?: DebounceOptions): DebouncedFunction<F>;
|
package/dist/debounce.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isUndefined } from "./isUndefined.js";
|
|
2
|
-
import { isNil } from "./isNil.js";
|
|
3
1
|
import hasValue from "./hasValue.js";
|
|
4
|
-
|
|
2
|
+
import { isNil } from "./isNil.js";
|
|
3
|
+
import { isUndefined } from "./isUndefined.js";
|
|
4
|
+
// debounce.ts
|
|
5
5
|
/**
|
|
6
6
|
* Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
|
|
7
7
|
* have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
|
|
@@ -86,5 +86,4 @@ function debounce(function_, debounceMs, { signal, edges } = {}) {
|
|
|
86
86
|
signal?.addEventListener("abort", cancel, { once: true });
|
|
87
87
|
return debounced;
|
|
88
88
|
}
|
|
89
|
-
//#endregion
|
|
90
89
|
export { debounce };
|
package/dist/get.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GetFieldType } from "./@types/GetFieldType.js";
|
|
2
2
|
import { PropertyPath } from "./@types/PropertyPath.js";
|
|
3
|
-
//#region get.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Gets the value at path of object. If the resolved value is undefined, the defaultValue is returned in its place.
|
|
6
5
|
*
|
|
@@ -322,5 +321,4 @@ export declare function get<TObject, TPath extends string, TDefault = GetFieldTy
|
|
|
322
321
|
* get(object, 'a.b.c', 'default');
|
|
323
322
|
* // => 1
|
|
324
323
|
*/
|
|
325
|
-
export declare function get(object: any, path: PropertyPath, defaultValue?: any): any;
|
|
326
|
-
//#endregion
|
|
324
|
+
export declare function get(object: any, path: PropertyPath, defaultValue?: any): any;
|
package/dist/get.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { isUndefined } from "./isUndefined.js";
|
|
2
|
-
import { isNil } from "./isNil.js";
|
|
3
1
|
import { isArrayEmpty } from "./isArrayEmpty.js";
|
|
4
|
-
import {
|
|
5
|
-
import { isString } from "./isString.js";
|
|
2
|
+
import { isUndefined } from "./isUndefined.js";
|
|
6
3
|
import { isUnsafeProperty } from "./_internal/isUnsafeProperty.js";
|
|
7
4
|
import { isDeepKey } from "./_internal/isDeepKey.js";
|
|
8
|
-
import {
|
|
5
|
+
import { isNil } from "./isNil.js";
|
|
6
|
+
import { isNumber } from "./isNumber.js";
|
|
9
7
|
import { normalizeKey, toKey } from "./_internal/toKey.js";
|
|
10
8
|
import { toPath } from "./utils/toPath.js";
|
|
11
|
-
|
|
9
|
+
import { isString } from "./isString.js";
|
|
10
|
+
import { isSymbol } from "./isSymbol.js";
|
|
11
|
+
// get.ts
|
|
12
12
|
/**
|
|
13
13
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
14
14
|
*
|
|
@@ -54,5 +54,4 @@ function getDirect(object, key, defaultValue) {
|
|
|
54
54
|
const result = object[key];
|
|
55
55
|
return isUndefined(result) ? defaultValue : result;
|
|
56
56
|
}
|
|
57
|
-
//#endregion
|
|
58
57
|
export { get };
|
package/dist/hasValue.d.ts
CHANGED
package/dist/hasValue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// hasValue.ts
|
|
2
2
|
/**
|
|
3
3
|
* Checks whether a value is neither `null` nor `undefined`.
|
|
4
4
|
*
|
|
@@ -18,5 +18,4 @@
|
|
|
18
18
|
function hasValue(value) {
|
|
19
19
|
return value !== null && value !== void 0;
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { hasValue as default, hasValue };
|
package/dist/isArray.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isArray.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if the given value is an array.
|
|
4
3
|
*
|
|
@@ -19,5 +18,4 @@
|
|
|
19
18
|
* console.log(isArray(value2)); // false
|
|
20
19
|
* console.log(isArray(value3)); // false
|
|
21
20
|
*/
|
|
22
|
-
export declare function isArray<T = unknown>(value: unknown): value is T[];
|
|
23
|
-
//#endregion
|
|
21
|
+
export declare function isArray<T = unknown>(value: unknown): value is T[];
|
package/dist/isArray.js
CHANGED
package/dist/isArrayBuffer.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isArrayBuffer.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if a given value is `ArrayBuffer`.
|
|
4
3
|
*
|
|
@@ -16,5 +15,4 @@
|
|
|
16
15
|
* console.log(isArrayBuffer(value2)); // false
|
|
17
16
|
* console.log(isArrayBuffer(value3)); // false
|
|
18
17
|
*/
|
|
19
|
-
export declare function isArrayBuffer(value: unknown): value is ArrayBuffer;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare function isArrayBuffer(value: unknown): value is ArrayBuffer;
|
package/dist/isArrayBuffer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import hasValue from "./hasValue.js";
|
|
2
|
-
|
|
2
|
+
// isArrayBuffer.ts
|
|
3
3
|
/**
|
|
4
4
|
* Checks if a given value is `ArrayBuffer`.
|
|
5
5
|
*
|
|
@@ -20,5 +20,4 @@ import hasValue from "./hasValue.js";
|
|
|
20
20
|
function isArrayBuffer(value) {
|
|
21
21
|
return hasValue(value) && value instanceof ArrayBuffer;
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { isArrayBuffer };
|
package/dist/isArrayEmpty.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
//#region isArrayEmpty.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks whether a value is nullish or an empty array.
|
|
4
3
|
*
|
|
5
4
|
* `null`, `undefined`, and arrays without elements are considered empty.
|
|
6
5
|
*/
|
|
7
|
-
export declare function isArrayEmpty<T>(value: readonly T[] | null | undefined): value is null | undefined | readonly [];
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare function isArrayEmpty<T>(value: readonly T[] | null | undefined): value is null | undefined | readonly [];
|
package/dist/isArrayEmpty.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { isNil } from "./isNil.js";
|
|
2
|
-
|
|
2
|
+
// isArrayEmpty.ts
|
|
3
3
|
/**
|
|
4
4
|
* Checks whether a value is nullish or an empty array.
|
|
5
5
|
*
|
|
6
6
|
* `null`, `undefined`, and arrays without elements are considered empty.
|
|
7
7
|
*/
|
|
8
8
|
function isArrayEmpty(value) {
|
|
9
|
-
return isNil(value)
|
|
9
|
+
return isNil(value) || value.length === 0;
|
|
10
10
|
}
|
|
11
|
-
//#endregion
|
|
12
11
|
export { isArrayEmpty };
|
package/dist/isBlob.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isBlob.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if a given value is `Blob`.
|
|
4
3
|
*
|
|
@@ -16,5 +15,4 @@
|
|
|
16
15
|
* console.log(isBlob(value2)); // false
|
|
17
16
|
* console.log(isBlob(value3)); // false
|
|
18
17
|
*/
|
|
19
|
-
export declare function isBlob(value: unknown): value is Blob;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare function isBlob(value: unknown): value is Blob;
|
package/dist/isBlob.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import hasValue from "./hasValue.js";
|
|
2
|
-
|
|
2
|
+
// isBlob.ts
|
|
3
3
|
/**
|
|
4
4
|
* Checks if a given value is `Blob`.
|
|
5
5
|
*
|
|
@@ -20,5 +20,4 @@ import hasValue from "./hasValue.js";
|
|
|
20
20
|
function isBlob(value) {
|
|
21
21
|
return hasValue(value) && value instanceof Blob;
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { isBlob };
|
package/dist/isBoolean.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isBoolean.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if the given value is boolean.
|
|
4
3
|
*
|
|
@@ -21,5 +20,4 @@
|
|
|
21
20
|
* console.log(isBoolean(value3)); // false
|
|
22
21
|
*
|
|
23
22
|
*/
|
|
24
|
-
export declare function isBoolean(x: unknown): x is boolean;
|
|
25
|
-
//#endregion
|
|
23
|
+
export declare function isBoolean(x: unknown): x is boolean;
|
package/dist/isBoolean.js
CHANGED
package/dist/isFormData.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isFormData.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if a given value is `FormData`.
|
|
4
3
|
*
|
|
@@ -16,5 +15,4 @@
|
|
|
16
15
|
* console.log(isFormData(value2)); // false
|
|
17
16
|
* console.log(isFormData(value3)); // false
|
|
18
17
|
*/
|
|
19
|
-
export declare function isFormData(value: unknown): value is FormData;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare function isFormData(value: unknown): value is FormData;
|
package/dist/isFormData.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import hasValue from "./hasValue.js";
|
|
2
|
-
|
|
2
|
+
// isFormData.ts
|
|
3
3
|
/**
|
|
4
4
|
* Checks if a given value is `FormData`.
|
|
5
5
|
*
|
|
@@ -20,5 +20,4 @@ import hasValue from "./hasValue.js";
|
|
|
20
20
|
function isFormData(value) {
|
|
21
21
|
return hasValue(value) && value instanceof FormData;
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { isFormData };
|
package/dist/isFunction.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isFunction.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if `value` is a function.
|
|
4
3
|
*
|
|
@@ -12,5 +11,4 @@
|
|
|
12
11
|
* isFunction(Proxy); // true
|
|
13
12
|
* isFunction(Int8Array); // true
|
|
14
13
|
*/
|
|
15
|
-
export declare function isFunction(value: any): value is (...arguments_: any[]) => any;
|
|
16
|
-
//#endregion
|
|
14
|
+
export declare function isFunction(value: any): value is (...arguments_: any[]) => any;
|
package/dist/isFunction.js
CHANGED
package/dist/isNil.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isNil.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if a given value is null or undefined.
|
|
4
3
|
*
|
|
@@ -18,5 +17,4 @@
|
|
|
18
17
|
* const result2 = isNil(value2); // true
|
|
19
18
|
* const result3 = isNil(value3); // false
|
|
20
19
|
*/
|
|
21
|
-
export declare function isNil(x: unknown): x is null | undefined;
|
|
22
|
-
//#endregion
|
|
20
|
+
export declare function isNil(x: unknown): x is null | undefined;
|
package/dist/isNil.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isUndefined } from "./isUndefined.js";
|
|
2
2
|
import { isNull } from "./isNull.js";
|
|
3
|
-
|
|
3
|
+
// isNil.ts
|
|
4
4
|
/**
|
|
5
5
|
* Checks if a given value is null or undefined.
|
|
6
6
|
*
|
|
@@ -23,5 +23,4 @@ import { isNull } from "./isNull.js";
|
|
|
23
23
|
function isNil(x) {
|
|
24
24
|
return isNull(x) || isUndefined(x);
|
|
25
25
|
}
|
|
26
|
-
//#endregion
|
|
27
26
|
export { isNil };
|
package/dist/isNull.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isNull.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if the given value is null.
|
|
4
3
|
*
|
|
@@ -19,5 +18,4 @@
|
|
|
19
18
|
* console.log(isNull(value2)); // false
|
|
20
19
|
* console.log(isNull(value3)); // false
|
|
21
20
|
*/
|
|
22
|
-
export declare function isNull(x: unknown): x is null;
|
|
23
|
-
//#endregion
|
|
21
|
+
export declare function isNull(x: unknown): x is null;
|
package/dist/isNull.js
CHANGED
package/dist/isNumber.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isNumber.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if the given value is a number.
|
|
4
3
|
*
|
|
@@ -21,5 +20,4 @@
|
|
|
21
20
|
* console.log(isNumber(value3)); // false
|
|
22
21
|
*
|
|
23
22
|
*/
|
|
24
|
-
export declare function isNumber(value: unknown): value is number;
|
|
25
|
-
//#endregion
|
|
23
|
+
export declare function isNumber(value: unknown): value is number;
|
package/dist/isNumber.js
CHANGED
package/dist/isObject.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isObject.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if the given value is an object. An object is a value that is
|
|
4
3
|
* not a primitive type (string, number, boolean, symbol, null, or undefined).
|
|
@@ -22,5 +21,4 @@
|
|
|
22
21
|
* console.log(isObject(value3)); // true
|
|
23
22
|
* console.log(isObject(value4)); // false
|
|
24
23
|
*/
|
|
25
|
-
export declare function isObject(value?: any): value is object;
|
|
26
|
-
//#endregion
|
|
24
|
+
export declare function isObject(value?: any): value is object;
|
package/dist/isObject.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// isObject.ts
|
|
2
2
|
/**
|
|
3
3
|
* Checks if the given value is an object. An object is a value that is
|
|
4
4
|
* not a primitive type (string, number, boolean, symbol, null, or undefined).
|
|
@@ -25,5 +25,4 @@
|
|
|
25
25
|
function isObject(value) {
|
|
26
26
|
return value !== null && (typeof value === "object" || typeof value === "function");
|
|
27
27
|
}
|
|
28
|
-
//#endregion
|
|
29
28
|
export { isObject };
|
package/dist/isPlainObject.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isPlainObject.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if a given value is a plain object.
|
|
4
3
|
*
|
|
@@ -41,5 +40,4 @@
|
|
|
41
40
|
* isPlainObject(globalThis); // ❌
|
|
42
41
|
* ```
|
|
43
42
|
*/
|
|
44
|
-
export declare function isPlainObject(value: unknown): value is Record<PropertyKey, any>;
|
|
45
|
-
//#endregion
|
|
43
|
+
export declare function isPlainObject(value: unknown): value is Record<PropertyKey, any>;
|
package/dist/isPlainObject.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNull } from "./isNull.js";
|
|
2
2
|
import { isObject } from "./isObject.js";
|
|
3
|
-
|
|
3
|
+
// isPlainObject.ts
|
|
4
4
|
/**
|
|
5
5
|
* Checks if a given value is a plain object.
|
|
6
6
|
*
|
|
@@ -46,7 +46,6 @@ import { isObject } from "./isObject.js";
|
|
|
46
46
|
function isPlainObject(value) {
|
|
47
47
|
if (!isObject(value)) return false;
|
|
48
48
|
const prototype = Object.getPrototypeOf(value);
|
|
49
|
-
return isNull(prototype) || prototype === Object.prototype || isNull(Object.getPrototypeOf(prototype))
|
|
49
|
+
return (isNull(prototype) || prototype === Object.prototype || isNull(Object.getPrototypeOf(prototype))) && Object.prototype.toString.call(value) === "[object Object]";
|
|
50
50
|
}
|
|
51
|
-
//#endregion
|
|
52
51
|
export { isPlainObject };
|
package/dist/isPromise.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isPromise.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if a given value is `Promise`.
|
|
4
3
|
*
|
|
@@ -16,5 +15,4 @@
|
|
|
16
15
|
* console.log(isPromise(value2)); // false
|
|
17
16
|
* console.log(isPromise(value3)); // false
|
|
18
17
|
*/
|
|
19
|
-
export declare function isPromise(value: unknown): value is Promise<any>;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare function isPromise(value: unknown): value is Promise<any>;
|
package/dist/isPromise.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import hasValue from "./hasValue.js";
|
|
2
1
|
import { isFunction } from "./isFunction.js";
|
|
2
|
+
import hasValue from "./hasValue.js";
|
|
3
3
|
import { isObject } from "./isObject.js";
|
|
4
|
-
|
|
4
|
+
// isPromise.ts
|
|
5
5
|
/**
|
|
6
6
|
* Checks if a given value is `Promise`.
|
|
7
7
|
*
|
|
@@ -22,5 +22,4 @@ import { isObject } from "./isObject.js";
|
|
|
22
22
|
function isPromise(value) {
|
|
23
23
|
return hasValue(value) && (isObject(value) || isFunction(value)) && isFunction(value.then);
|
|
24
24
|
}
|
|
25
|
-
//#endregion
|
|
26
25
|
export { isPromise };
|
package/dist/isString.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isString.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if a given value is string.
|
|
4
3
|
*
|
|
@@ -16,5 +15,4 @@
|
|
|
16
15
|
* console.log(isString(value2)); // false
|
|
17
16
|
* console.log(isString(value3)); // false
|
|
18
17
|
*/
|
|
19
|
-
export declare function isString(value: unknown): value is string;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare function isString(value: unknown): value is string;
|
package/dist/isString.js
CHANGED
package/dist/isStringEmpty.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
//#region isStringEmpty.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks whether a value is nullish or an empty string.
|
|
4
3
|
*
|
|
5
4
|
* `null`, `undefined`, and whitespace-only strings are considered empty.
|
|
6
5
|
*/
|
|
7
|
-
export declare function isStringEmpty(value: string | null | undefined): value is '' | null | undefined;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare function isStringEmpty(value: string | null | undefined): value is '' | null | undefined;
|
package/dist/isStringEmpty.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { isNil } from "./isNil.js";
|
|
2
|
-
|
|
2
|
+
// isStringEmpty.ts
|
|
3
3
|
/**
|
|
4
4
|
* Checks whether a value is nullish or an empty string.
|
|
5
5
|
*
|
|
6
6
|
* `null`, `undefined`, and whitespace-only strings are considered empty.
|
|
7
7
|
*/
|
|
8
8
|
function isStringEmpty(value) {
|
|
9
|
-
return isNil(value)
|
|
9
|
+
return isNil(value) || value.trim().length === 0;
|
|
10
10
|
}
|
|
11
|
-
//#endregion
|
|
12
11
|
export { isStringEmpty };
|
package/dist/isSymbol.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isSymbol.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Check whether a value is a symbol.
|
|
4
3
|
*
|
|
@@ -22,5 +21,4 @@
|
|
|
22
21
|
* isSymbol({}); // false
|
|
23
22
|
* isSymbol([1, 2, 3]); // false
|
|
24
23
|
*/
|
|
25
|
-
export declare function isSymbol(value: unknown): value is symbol;
|
|
26
|
-
//#endregion
|
|
24
|
+
export declare function isSymbol(value: unknown): value is symbol;
|
package/dist/isSymbol.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isURLSearchParameters.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if a given value is `URLSearchParams`.
|
|
4
3
|
*
|
|
@@ -16,5 +15,4 @@
|
|
|
16
15
|
* console.log(isURLSearchParameters(value2)); // false
|
|
17
16
|
* console.log(isURLSearchParameters(value3)); // false
|
|
18
17
|
*/
|
|
19
|
-
export declare function isURLSearchParameters(value: unknown): value is URLSearchParams;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare function isURLSearchParameters(value: unknown): value is URLSearchParams;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import hasValue from "./hasValue.js";
|
|
2
|
-
|
|
2
|
+
// isURLSearchParameters.ts
|
|
3
3
|
/**
|
|
4
4
|
* Checks if a given value is `URLSearchParams`.
|
|
5
5
|
*
|
|
@@ -20,5 +20,4 @@ import hasValue from "./hasValue.js";
|
|
|
20
20
|
function isURLSearchParameters(value) {
|
|
21
21
|
return hasValue(value) && value instanceof URLSearchParams;
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { isURLSearchParameters };
|
package/dist/isUndefined.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region isUndefined.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Checks if the given value is undefined.
|
|
4
3
|
*
|
|
@@ -19,5 +18,4 @@
|
|
|
19
18
|
* console.log(isUndefined(value2)); // false
|
|
20
19
|
* console.log(isUndefined(value3)); // false
|
|
21
20
|
*/
|
|
22
|
-
export declare const isUndefined: (value: unknown) => value is undefined;
|
|
23
|
-
//#endregion
|
|
21
|
+
export declare const isUndefined: (value: unknown) => value is undefined;
|
package/dist/isUndefined.js
CHANGED
package/dist/kebabCase.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region kebabCase.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* 将字符串转换为 kebab-case。
|
|
4
3
|
*
|
|
@@ -10,5 +9,4 @@
|
|
|
10
9
|
* kebabCase('some whitespace') // 'some-whitespace'
|
|
11
10
|
* kebabCase('HTTPRequest') // 'http-request'
|
|
12
11
|
*/
|
|
13
|
-
export declare function kebabCase(value: string): string;
|
|
14
|
-
//#endregion
|
|
12
|
+
export declare function kebabCase(value: string): string;
|
package/dist/kebabCase.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// kebabCase.ts
|
|
2
2
|
/**
|
|
3
3
|
* 用于拆分常见命名格式的正则;实现参考 es-toolkit 的 `kebabCase`。
|
|
4
4
|
*/
|
|
@@ -26,5 +26,4 @@ function words(value) {
|
|
|
26
26
|
function kebabCase(value) {
|
|
27
27
|
return words(value).map((word) => word.toLowerCase()).join("-");
|
|
28
28
|
}
|
|
29
|
-
//#endregion
|
|
30
29
|
export { kebabCase };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { ChainedFunction, createChainedFunction } from "./createChainedFunction.js";
|
|
2
|
-
import { DebounceOptions, DebouncedFunction, debounce } from "./debounce.js";
|
|
3
|
-
import { get } from "./get.js";
|
|
4
|
-
import hasValue from "./hasValue.js";
|
|
5
1
|
import { isArray } from "./isArray.js";
|
|
6
|
-
import {
|
|
2
|
+
import { QueryInput, QueryParameters, QueryValue, buildURL } from "./buildURL.js";
|
|
7
3
|
import { isArrayEmpty } from "./isArrayEmpty.js";
|
|
8
|
-
import { isBlob } from "./isBlob.js";
|
|
9
4
|
import { isBoolean } from "./isBoolean.js";
|
|
10
|
-
import {
|
|
5
|
+
import { isBlob } from "./isBlob.js";
|
|
6
|
+
import { ChainedFunction, createChainedFunction } from "./createChainedFunction.js";
|
|
7
|
+
import { DebounceOptions, DebouncedFunction, debounce } from "./debounce.js";
|
|
11
8
|
import { isFunction } from "./isFunction.js";
|
|
9
|
+
import hasValue from "./hasValue.js";
|
|
10
|
+
import { isFormData } from "./isFormData.js";
|
|
12
11
|
import { isNil } from "./isNil.js";
|
|
13
|
-
import { isNull } from "./isNull.js";
|
|
14
12
|
import { isNumber } from "./isNumber.js";
|
|
15
|
-
import { isObject } from "./isObject.js";
|
|
16
13
|
import { isPlainObject } from "./isPlainObject.js";
|
|
17
|
-
import { isPromise } from "./isPromise.js";
|
|
18
14
|
import { isString } from "./isString.js";
|
|
19
15
|
import { isStringEmpty } from "./isStringEmpty.js";
|
|
20
|
-
import { isSymbol } from "./isSymbol.js";
|
|
21
|
-
import { isURLSearchParameters } from "./isURLSearchParameters.js";
|
|
22
16
|
import { isUndefined } from "./isUndefined.js";
|
|
23
|
-
import {
|
|
17
|
+
import { isNull } from "./isNull.js";
|
|
18
|
+
import { isPromise } from "./isPromise.js";
|
|
19
|
+
import { isObject } from "./isObject.js";
|
|
20
|
+
import { isArrayBuffer } from "./isArrayBuffer.js";
|
|
21
|
+
import { isURLSearchParameters } from "./isURLSearchParameters.js";
|
|
24
22
|
import { parseJson } from "./parseJson.js";
|
|
23
|
+
import { get } from "./get.js";
|
|
24
|
+
import { kebabCase } from "./kebabCase.js";
|
|
25
|
+
import { isSymbol } from "./isSymbol.js";
|
|
25
26
|
import { ThrottleOptions, ThrottledFunction, throttle } from "./throttle.js";
|
|
26
27
|
import resolveValue from "./resolveValue.js";
|
|
27
28
|
import { uniqueId } from "./uniqueId.js";
|
|
28
|
-
export { type ChainedFunction, type DebounceOptions, type DebouncedFunction, type ThrottleOptions, type ThrottledFunction, createChainedFunction, debounce, get, hasValue, isArray, isArrayBuffer, isArrayEmpty, isBlob, isBoolean, isFormData, isFunction, isNil, isNull, isNumber, isObject, isPlainObject, isPromise, isString, isStringEmpty, isSymbol, isURLSearchParameters, isUndefined, kebabCase, parseJson, resolveValue, throttle, uniqueId };
|
|
29
|
+
export { type ChainedFunction, type DebounceOptions, type DebouncedFunction, type QueryInput, type QueryParameters, type QueryValue, type ThrottleOptions, type ThrottledFunction, buildURL, createChainedFunction, debounce, get, hasValue, isArray, isArrayBuffer, isArrayEmpty, isBlob, isBoolean, isFormData, isFunction, isNil, isNull, isNumber, isObject, isPlainObject, isPromise, isString, isStringEmpty, isSymbol, isURLSearchParameters, isUndefined, kebabCase, parseJson, resolveValue, throttle, uniqueId };
|
package/dist/main.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { isArray } from "./isArray.js";
|
|
2
|
-
import {
|
|
3
|
-
import { isNull } from "./isNull.js";
|
|
4
|
-
import { isNil } from "./isNil.js";
|
|
2
|
+
import { buildURL } from "./buildURL.js";
|
|
5
3
|
import { isArrayEmpty } from "./isArrayEmpty.js";
|
|
6
4
|
import { isBoolean } from "./isBoolean.js";
|
|
7
|
-
import hasValue from "./hasValue.js";
|
|
8
5
|
import { isBlob } from "./isBlob.js";
|
|
9
|
-
import { isFunction } from "./isFunction.js";
|
|
10
6
|
import { createChainedFunction } from "./createChainedFunction.js";
|
|
11
7
|
import { debounce } from "./debounce.js";
|
|
8
|
+
import { isFunction } from "./isFunction.js";
|
|
9
|
+
import hasValue from "./hasValue.js";
|
|
12
10
|
import { isFormData } from "./isFormData.js";
|
|
11
|
+
import { isNil } from "./isNil.js";
|
|
13
12
|
import { isNumber } from "./isNumber.js";
|
|
14
|
-
import { isObject } from "./isObject.js";
|
|
15
13
|
import { isPlainObject } from "./isPlainObject.js";
|
|
16
14
|
import { isString } from "./isString.js";
|
|
17
15
|
import { isStringEmpty } from "./isStringEmpty.js";
|
|
16
|
+
import { isUndefined } from "./isUndefined.js";
|
|
17
|
+
import { isNull } from "./isNull.js";
|
|
18
18
|
import { isPromise } from "./isPromise.js";
|
|
19
|
+
import { isObject } from "./isObject.js";
|
|
19
20
|
import { isArrayBuffer } from "./isArrayBuffer.js";
|
|
20
21
|
import { isURLSearchParameters } from "./isURLSearchParameters.js";
|
|
21
22
|
import { parseJson } from "./parseJson.js";
|
|
22
|
-
import { isSymbol } from "./isSymbol.js";
|
|
23
23
|
import { get } from "./get.js";
|
|
24
24
|
import { kebabCase } from "./kebabCase.js";
|
|
25
|
+
import { isSymbol } from "./isSymbol.js";
|
|
25
26
|
import { throttle } from "./throttle.js";
|
|
26
27
|
import resolveValue from "./resolveValue.js";
|
|
27
28
|
import { uniqueId } from "./uniqueId.js";
|
|
28
|
-
export { createChainedFunction, debounce, get, hasValue, isArray, isArrayBuffer, isArrayEmpty, isBlob, isBoolean, isFormData, isFunction, isNil, isNull, isNumber, isObject, isPlainObject, isPromise, isString, isStringEmpty, isSymbol, isURLSearchParameters, isUndefined, kebabCase, parseJson, resolveValue, throttle, uniqueId };
|
|
29
|
+
export { buildURL, createChainedFunction, debounce, get, hasValue, isArray, isArrayBuffer, isArrayEmpty, isBlob, isBoolean, isFormData, isFunction, isNil, isNull, isNumber, isObject, isPlainObject, isPromise, isString, isStringEmpty, isSymbol, isURLSearchParameters, isUndefined, kebabCase, parseJson, resolveValue, throttle, uniqueId };
|
package/dist/parseJson.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
//#region parseJson.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Parses JSON text into a value.
|
|
4
3
|
*
|
|
5
4
|
* Returns `undefined` for blank strings. When `fallback` is provided, invalid JSON
|
|
6
5
|
* returns the fallback instead of throwing.
|
|
7
6
|
*/
|
|
8
|
-
export declare function parseJson<T>(text: string, fallback?: T): T | undefined;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare function parseJson<T>(text: string, fallback?: T): T | undefined;
|
package/dist/parseJson.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isStringEmpty } from "./isStringEmpty.js";
|
|
2
|
-
|
|
2
|
+
// parseJson.ts
|
|
3
3
|
/**
|
|
4
4
|
* Parses JSON text into a value.
|
|
5
5
|
*
|
|
@@ -15,5 +15,4 @@ function parseJson(text, fallback) {
|
|
|
15
15
|
throw error;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { parseJson };
|
package/dist/resolveValue.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region resolveValue.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Resolves either a plain value or a lazily evaluated value factory.
|
|
4
3
|
*
|
|
@@ -13,5 +12,4 @@
|
|
|
13
12
|
* resolveValue(status => status === 'error' ? 'retry' : 'ok', 'error');
|
|
14
13
|
*/
|
|
15
14
|
export declare function resolveValue<TValue, TArguments extends any[]>(value: TValue | ((...arguments_: TArguments) => TValue), ...arguments_: TArguments): TValue;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { resolveValue as default };
|
package/dist/resolveValue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isFunction } from "./isFunction.js";
|
|
2
|
-
|
|
2
|
+
// resolveValue.ts
|
|
3
3
|
/**
|
|
4
4
|
* Resolves either a plain value or a lazily evaluated value factory.
|
|
5
5
|
*
|
|
@@ -16,5 +16,4 @@ import { isFunction } from "./isFunction.js";
|
|
|
16
16
|
function resolveValue(value, ...arguments_) {
|
|
17
17
|
return isFunction(value) ? value(...arguments_) : value;
|
|
18
18
|
}
|
|
19
|
-
//#endregion
|
|
20
19
|
export { resolveValue as default, resolveValue };
|
package/dist/throttle.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region throttle.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* 控制节流函数何时调用或取消的选项。
|
|
4
3
|
*/
|
|
@@ -50,5 +49,4 @@ export interface ThrottledFunction<F extends (...arguments_: any[]) => void> {
|
|
|
50
49
|
* throttledFunction(); // Will log 'Function executed'
|
|
51
50
|
* }, 1000);
|
|
52
51
|
*/
|
|
53
|
-
export declare function throttle<F extends (...arguments_: any[]) => void>(function_: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ThrottledFunction<F>;
|
|
54
|
-
//#endregion
|
|
52
|
+
export declare function throttle<F extends (...arguments_: any[]) => void>(function_: F, throttleMs: number, { signal, edges }?: ThrottleOptions): ThrottledFunction<F>;
|
package/dist/throttle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isUndefined } from "./isUndefined.js";
|
|
2
1
|
import { debounce } from "./debounce.js";
|
|
3
|
-
|
|
2
|
+
import { isUndefined } from "./isUndefined.js";
|
|
3
|
+
// throttle.ts
|
|
4
4
|
/**
|
|
5
5
|
* Creates a throttled function that only invokes the provided function at most once
|
|
6
6
|
* per every `throttleMs` milliseconds. Subsequent calls to the throttled function
|
|
@@ -54,5 +54,4 @@ function throttle(function_, throttleMs, { signal, edges = ["leading", "trailing
|
|
|
54
54
|
throttled.flush = debounced.flush;
|
|
55
55
|
return throttled;
|
|
56
56
|
}
|
|
57
|
-
//#endregion
|
|
58
57
|
export { throttle };
|
package/dist/uniqueId.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region uniqueId.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Generates a unique ID.
|
|
4
3
|
*
|
|
@@ -12,5 +11,4 @@
|
|
|
12
11
|
* uniqueId('contact_'); // 'contact_2'
|
|
13
12
|
* uniqueId('contact_'); // 'contact_3'
|
|
14
13
|
*/
|
|
15
|
-
export declare function uniqueId(prefix?: string): string;
|
|
16
|
-
//#endregion
|
|
14
|
+
export declare function uniqueId(prefix?: string): string;
|
package/dist/uniqueId.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// uniqueId.ts
|
|
2
2
|
const uniqueIdCounter = { value: 0 };
|
|
3
3
|
/**
|
|
4
4
|
* Generates a unique ID.
|
|
@@ -16,5 +16,4 @@ const uniqueIdCounter = { value: 0 };
|
|
|
16
16
|
function uniqueId(prefix = "") {
|
|
17
17
|
return `${prefix}${++uniqueIdCounter.value}`;
|
|
18
18
|
}
|
|
19
|
-
//#endregion
|
|
20
19
|
export { uniqueId };
|
package/dist/utils/toPath.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { toString } from "./toString.js";
|
|
1
2
|
import { isSymbol } from "../isSymbol.js";
|
|
2
3
|
import { toKey } from "../_internal/toKey.js";
|
|
3
|
-
|
|
4
|
-
//#region utils/toPath.ts
|
|
4
|
+
// utils/toPath.ts
|
|
5
5
|
/**
|
|
6
6
|
* Converts a deep key string into an array of path segments.
|
|
7
7
|
*
|
|
@@ -66,5 +66,4 @@ function toPath(deepKey) {
|
|
|
66
66
|
if (key) result.push(key);
|
|
67
67
|
return result;
|
|
68
68
|
}
|
|
69
|
-
//#endregion
|
|
70
69
|
export { toPath };
|
package/dist/utils/toString.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { normalizeKey } from "../_internal/toKey.js";
|
|
1
2
|
import { isNil } from "../isNil.js";
|
|
2
3
|
import { isString } from "../isString.js";
|
|
3
|
-
|
|
4
|
-
//#region utils/toString.ts
|
|
4
|
+
// utils/toString.ts
|
|
5
5
|
/**
|
|
6
6
|
* Converts `value` to a string.
|
|
7
7
|
*
|
|
@@ -23,5 +23,4 @@ function toString(value) {
|
|
|
23
23
|
if (isString(value)) return value;
|
|
24
24
|
return Array.isArray(value) ? value.map((item) => toString(item)).join(",") : normalizeKey(value);
|
|
25
25
|
}
|
|
26
|
-
//#endregion
|
|
27
26
|
export { toString };
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnific/utils",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shared
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Shared utilities for Omnific packages",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"utils",
|
|
9
9
|
"type-guards",
|
|
10
|
-
"predicates"
|
|
10
|
+
"predicates",
|
|
11
|
+
"url"
|
|
11
12
|
],
|
|
12
13
|
"author": "monhan-97",
|
|
13
14
|
"repository": {
|