@ntnyq/utils 0.11.0 → 0.11.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +563 -509
  2. package/dist/index.js +44 -76
  3. package/package.json +27 -26
package/dist/index.d.ts CHANGED
@@ -1,49 +1,52 @@
1
1
  //#region src/fn/noop.d.ts
2
2
  /**
3
- * A function that does nothing.
4
- */
3
+ * A function that does nothing.
4
+ */
5
5
  declare function noop(): void;
6
6
  /**
7
- * Alias of {@link noop}.
8
- */
7
+ * Alias of {@link noop}.
8
+ */
9
9
  declare const NOOP: typeof noop;
10
10
  //#endregion
11
11
  //#region src/fn/once.d.ts
12
12
  /**
13
- * Creates a function that is restricted to invoking `func` once. Repeat calls to the function return `false`.
14
- *
15
- * @param func - The function to restrict.
16
- * @returns A new function that returns `true` when `func` is invoked for the first time and `false` on subsequent calls.
17
- *
18
- * @example
19
- *
20
- * ```ts
21
- * const initialize = once(() => {
22
- * console.log('Initialized')
23
- * })
24
- *
25
- * initialize() // Logs: 'Initialized', returns true
26
- * ```
27
- */
13
+ * Creates a function that is restricted to invoking `func` once. Repeat calls to the function return `false`.
14
+ *
15
+ * @param func - The function to restrict.
16
+ * @returns A new function that returns `true` when `func` is invoked for the first time and `false` on subsequent calls.
17
+ *
18
+ * @example
19
+ *
20
+ * ```ts
21
+ * const initialize = once(() => {
22
+ * console.log('Initialized')
23
+ * })
24
+ *
25
+ * initialize() // Logs: 'Initialized', returns true
26
+ * ```
27
+ */
28
28
  declare function once<T extends unknown[]>(func: (...args: T) => void): (this: unknown, ...args: T) => boolean;
29
29
  //#endregion
30
30
  //#region src/is/dom.d.ts
31
31
  /**
32
- * Check if given value is an HTMLElement
33
- * @param value - The value to check
34
- * @returns True if the value is an HTMLElement, false otherwise
35
- */
32
+ * @file is/dom.ts
33
+ */
34
+ /**
35
+ * Check if given value is an HTMLElement
36
+ * @param value - The value to check
37
+ * @returns True if the value is an HTMLElement, false otherwise
38
+ */
36
39
  declare function isHTMLElement(value: unknown): value is HTMLElement;
37
40
  //#endregion
38
41
  //#region src/is/core.d.ts
39
42
  /**
40
- * @file is utils
41
- * @module is
42
- * @copyright {@link https://github.com/sindresorhus/is}
43
- */
44
- type Whitespace = " ";
43
+ * @file is utils
44
+ * @module is
45
+ * @copyright {@link https://github.com/sindresorhus/is}
46
+ */
47
+ type Whitespace = ' ';
45
48
  type NonEmptyString = string & {
46
- 0: "";
49
+ 0: '';
47
50
  };
48
51
  declare function getObjectType(value: unknown): string;
49
52
  declare function isUndefined(value: unknown): value is undefined;
@@ -51,10 +54,10 @@ declare function isNull(value: unknown): value is null;
51
54
  declare function isNil(value: unknown): value is null | undefined;
52
55
  declare const isNullOrUndefined: typeof isNil;
53
56
  declare function isString(value: unknown): value is string;
54
- declare function isEmptyString(value: unknown): value is "";
57
+ declare function isEmptyString(value: unknown): value is '';
55
58
  declare function isNonEmptyString(value: unknown): value is NonEmptyString;
56
59
  declare function isWhitespaceString(value: unknown): value is Whitespace;
57
- declare function isEmptyStringOrWhitespace(value: unknown): value is "" | Whitespace;
60
+ declare function isEmptyStringOrWhitespace(value: unknown): value is '' | Whitespace;
58
61
  declare function isNumbericString(value: unknown): value is `${number}`;
59
62
  declare function isNumber(value: unknown): value is number;
60
63
  declare function isZero(value: unknown): value is 0;
@@ -67,12 +70,12 @@ declare function isFunction(value: unknown): value is Function;
67
70
  declare function isArray(value: unknown): value is unknown[];
68
71
  declare function isEmptyArray(value: unknown): value is [];
69
72
  declare function isNonEmptyArray<T = unknown, Item = unknown>(value: T | Item[]): value is [Item, ...Item[]];
70
- declare function isObject(value: unknown): value is object;
71
- declare function isEmptyObject(value: unknown): value is {};
72
73
  declare function isMap<Key = unknown, Value = unknown>(value: unknown): value is Map<Key, Value>;
73
- declare function isEmptyMap(value: unknown): value is Map<never, never>;
74
74
  declare function isSet<Value = unknown>(value: unknown): value is Set<Value>;
75
75
  declare function isEmptySet(value: unknown): value is Set<never>;
76
+ declare function isObject(value: unknown): value is object;
77
+ declare function isEmptyObject(value: unknown): value is {};
78
+ declare function isEmptyMap(value: unknown): value is Map<never, never>;
76
79
  declare function isRegExp(value: unknown): value is RegExp;
77
80
  declare function isError(value: unknown): value is Error;
78
81
  declare function isNativePromise<T = unknown>(value: unknown): value is Promise<T>;
@@ -82,29 +85,29 @@ declare function isBlob(value: unknown): value is Blob;
82
85
  declare function isFormData(value: unknown): value is FormData;
83
86
  declare function isFile(value: unknown): value is File;
84
87
  type UrlString = string & {
85
- readonly __brand: "UrlString";
88
+ readonly __brand: 'UrlString';
86
89
  };
87
90
  declare function isUrlString(value: unknown): value is UrlString;
88
91
  //#endregion
89
92
  //#region src/is/isDeepEqual.d.ts
90
93
  /**
91
- * check if two values are deeply equal
92
- */
94
+ * check if two values are deeply equal
95
+ */
93
96
  declare function isDeepEqual(value1: any, value2: any): boolean;
94
97
  //#endregion
95
98
  //#region src/dom/scrollIntoView.d.ts
96
99
  interface Options extends ScrollIntoViewOptions {
97
100
  /**
98
- * @default `document.body`
99
- */
101
+ * @default `document.body`
102
+ */
100
103
  parent?: HTMLElement;
101
104
  }
102
105
  /**
103
- * Scroll element into view if it is out of view.
104
- *
105
- * @param element - element to scroll
106
- * @param options - scroll options
107
- */
106
+ * Scroll element into view if it is out of view.
107
+ *
108
+ * @param element - element to scroll
109
+ * @param options - scroll options
110
+ */
108
111
  declare function scrollElementIntoView(element: HTMLElement, options?: Options): void;
109
112
  //#endregion
110
113
  //#region src/types/base.d.ts
@@ -115,12 +118,12 @@ type Callable<T> = AnyFn<any, T> | T;
115
118
  type MayBe<T> = T | undefined;
116
119
  type Nullable<T> = T | null;
117
120
  /**
118
- * Overwrite some keys type
119
- */
120
- type Overwrite<T, U$1> = Pick<T, Exclude<keyof T, keyof U$1>> & U$1;
121
+ * Overwrite some keys type
122
+ */
123
+ type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
121
124
  /**
122
- * Prettify object type
123
- */
125
+ * Prettify object type
126
+ */
124
127
  type Prettify<T> = { [K in keyof T]: T[K] } & {};
125
128
  type PrettifyV2<T> = Omit<T, never>;
126
129
  type Primitive = bigint | boolean | number | string | symbol | AnyFn | null | undefined;
@@ -133,169 +136,172 @@ type JsonArray = JsonValue[] | readonly JsonValue[];
133
136
  type JsonObject = { [Key in string]: JsonValue } & { [Key in string]?: JsonValue | undefined };
134
137
  type JsonPrimitive = boolean | number | string | null;
135
138
  /**
136
- * @copyright {@link https://github.com/sindresorhus/type-fest/blob/main/source/basic.d.ts}
137
- */
139
+ * @copyright {@link https://github.com/sindresorhus/type-fest/blob/main/source/basic.d.ts}
140
+ */
138
141
  type JsonValue = JsonArray | JsonObject | JsonPrimitive;
139
142
  //#endregion
140
143
  //#region src/types/utils.d.ts
141
144
  /**
142
- * A literal type that supports custom further strings but preserves autocompletion in IDEs.
143
- *
144
- * @see {@link https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609}
145
- */
145
+ * A literal type that supports custom further strings but preserves autocompletion in IDEs.
146
+ *
147
+ * @see {@link https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609}
148
+ */
146
149
  type LiteralUnion<Union extends Base, Base = string> = Union | (Base & {
147
150
  zz_IGNORE_ME?: never;
148
151
  });
149
152
  /**
150
- * @see {@link TODO:}
151
- */
152
- type Merge<T, U$1> = keyof T & keyof U$1 extends never ? T & U$1 : Omit<T, keyof T & keyof U$1> & U$1;
153
+ * @see {@link TODO:}
154
+ */
155
+ type Merge<T, U> = keyof T & keyof U extends never ? T & U : Omit<T, keyof T & keyof U> & U;
153
156
  /**
154
- * Non empty object `{}`
155
- */
157
+ * Non empty object `{}`
158
+ */
156
159
  type NonEmptyObject<T> = T extends Record<string, never> ? never : T;
157
160
  /**
158
- * A type that represents the values of an object type.
159
- */
161
+ * A type that represents the values of an object type.
162
+ */
160
163
  type ValueOf<T> = T[keyof T];
161
164
  /**
162
- * A type that represents the elements of an array type.
163
- */
164
- type ElementOf<T extends unknown[] | null | undefined> = T extends Array<infer U> ? U : never;
165
+ * A type that represents the elements of an array type.
166
+ */
167
+ type ElementOf<T extends unknown[] | null | undefined> = T extends (infer U)[] ? U : never;
165
168
  //#endregion
166
169
  //#region src/types/module.d.ts
167
170
  /**
168
- * interop module
169
- */
171
+ * interop module
172
+ */
170
173
  type InteropModuleDefault<T> = T extends {
171
174
  default: infer U;
172
175
  } ? U : T;
173
176
  /**
174
- * Resolve `boolean | Options` to `Options`
175
- */
177
+ * Resolve `boolean | Options` to `Options`
178
+ */
176
179
  type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
177
180
  //#endregion
178
181
  //#region src/dom/openExternalURL.d.ts
179
182
  interface OpenExternalURLOptions {
180
183
  /**
181
- * open target
182
- *
183
- * @default `_blank`
184
- */
185
- target?: LiteralUnion<"_self" | "_top" | "_blank" | "_parent">;
184
+ * open target
185
+ *
186
+ * @default `_blank`
187
+ */
188
+ target?: LiteralUnion<'_self' | '_top' | '_blank' | '_parent'>;
186
189
  }
187
190
  /**
188
- * Open external url
189
- * @param url - URL to open
190
- * @param options - open options
191
- * @returns window proxy
192
- */
191
+ * Open external url
192
+ * @param url - URL to open
193
+ * @param options - open options
194
+ * @returns window proxy
195
+ */
193
196
  declare function openExternalURL(url: string | URL, options?: OpenExternalURLOptions): WindowProxy | null;
194
197
  //#endregion
195
198
  //#region src/dom/isVisibleInViewport.d.ts
196
199
  /**
197
- * Check if element is in viewport
198
- * @param element - checked element
199
- * @param targetWindow - window
200
- * @returns true if element is in viewport, false otherwise
201
- */
200
+ * Check if element is in viewport
201
+ * @param element - checked element
202
+ * @param targetWindow - window
203
+ * @returns true if element is in viewport, false otherwise
204
+ */
202
205
  declare function isElementVisibleInViewport(element: HTMLElement, targetWindow?: Window): boolean;
203
206
  //#endregion
204
207
  //#region src/env/isBrowser.d.ts
205
208
  /**
206
- * Checks if the code is running in a browser
207
- *
208
- * @returns true if the code is running in a browser
209
- */
209
+ * Checks if the code is running in a browser
210
+ *
211
+ * @returns true if the code is running in a browser
212
+ */
210
213
  declare function isBrowser(): boolean;
211
214
  //#endregion
212
215
  //#region src/file/extension.d.ts
213
216
  /**
214
- * Removes the file extension from a filename.
215
- *
216
- * @param filename - The filename to remove the extension from.
217
- * @returns The filename without the extension.
218
- */
217
+ * Removes the file extension from a filename.
218
+ *
219
+ * @param filename - The filename to remove the extension from.
220
+ * @returns The filename without the extension.
221
+ */
219
222
  declare function removeFileExtension(filename: string): string;
220
223
  /**
221
- * Gets the file extension from a filename.
222
- * @param filePath - The filePath to get the extension from.
223
- * @returns The file extension, or undefined if there is none.
224
- */
224
+ * Gets the file extension from a filename.
225
+ * @param filePath - The filePath to get the extension from.
226
+ * @returns The file extension, or undefined if there is none.
227
+ */
225
228
  declare function getFileExtension(filePath?: string): string | undefined;
226
229
  //#endregion
227
230
  //#region src/html/escape.d.ts
228
231
  /**
229
- * Escape html chars
230
- */
232
+ * Escape html chars
233
+ */
231
234
  declare function escapeHTML(str: string): string;
232
235
  /**
233
- * Unescape html chars
234
- */
236
+ * Unescape html chars
237
+ */
235
238
  declare function unescapeHTML(str: string): string;
236
239
  //#endregion
237
240
  //#region src/misc/raf.d.ts
238
241
  /**
239
- * Gets the global root object.
240
- * @returns the global root object
241
- */
242
+ * @file raf.ts
243
+ */
244
+ /**
245
+ * Gets the global root object.
246
+ * @returns the global root object
247
+ */
242
248
  declare function getRoot(): Window | typeof globalThis;
243
249
  /**
244
- * Request animation frame
245
- *
246
- * @param fn - callback
247
- * @returns id
248
- */
250
+ * Request animation frame
251
+ *
252
+ * @param fn - callback
253
+ * @returns id
254
+ */
249
255
  declare function rAF(fn: FrameRequestCallback): number;
250
256
  /**
251
- * Cancel animation frame
252
- *
253
- * @param id - id
254
- * @returns void
255
- */
257
+ * Cancel animation frame
258
+ *
259
+ * @param id - id
260
+ * @returns void
261
+ */
256
262
  declare function cAF(id: number): void;
257
263
  //#endregion
258
264
  //#region src/misc/clamp.d.ts
259
265
  /**
260
- * Clamps a number between a minimum and maximum value
261
- * @param value - the value to clamp within the given range
262
- * @param min - the minimum value to clamp
263
- * @param max - the maximum value to clamp
264
- * @returns the new value
265
- */
266
+ * Clamps a number between a minimum and maximum value
267
+ * @param value - the value to clamp within the given range
268
+ * @param min - the minimum value to clamp
269
+ * @param max - the maximum value to clamp
270
+ * @returns the new value
271
+ */
266
272
  declare function clamp(value: number, min?: number, max?: number): number;
267
273
  //#endregion
268
274
  //#region src/misc/waitFor.d.ts
269
275
  /**
270
- * Wait for a number of milliseconds
271
- *
272
- * @param ms - millseconds to wait
273
- * @returns a promise that resolves after ms milliseconds
274
- *
275
- * @example
276
- * ```
277
- * import { waitFor } from '@ntnyq/utils'
278
- * await waitFor(3e3)
279
- * // do somthing after 3 seconds
280
- * ```
281
- */
276
+ * Wait for a number of milliseconds
277
+ *
278
+ * @param ms - millseconds to wait
279
+ * @returns a promise that resolves after ms milliseconds
280
+ *
281
+ * @example
282
+ * ```
283
+ * import { waitFor } from '@ntnyq/utils'
284
+ * await waitFor(3e3)
285
+ * // do somthing after 3 seconds
286
+ * ```
287
+ */
282
288
  declare function waitFor(ms: number): Promise<void>;
283
289
  //#endregion
284
290
  //#region src/misc/throttle.d.ts
285
291
  interface ThrottleDebounceOptions {
286
292
  /**
287
- * @default false
288
- */
293
+ * @default false
294
+ */
289
295
  isDebounce?: boolean;
290
296
  }
291
297
  /**
292
- * Throttle a function to limit its execution to a maximum of once per a specified time interval.
293
- *
294
- * @param delay - Zero or greater delay in milliseconds
295
- * @param callback - A function to be throttled
296
- * @param options - throttle options
297
- * @returns A throttled function
298
- */
298
+ * Throttle a function to limit its execution to a maximum of once per a specified time interval.
299
+ *
300
+ * @param delay - Zero or greater delay in milliseconds
301
+ * @param callback - A function to be throttled
302
+ * @param options - throttle options
303
+ * @returns A throttled function
304
+ */
299
305
  declare function throttle<T extends ((...args: any[]) => undefined | void) | undefined | null>(delay: number, callback: Exclude<T, undefined | null>, options?: ThrottleDebounceOptions): T & {
300
306
  cancel: () => void;
301
307
  };
@@ -305,20 +311,20 @@ declare function debounce<T extends ((...args: any[]) => undefined | void) | und
305
311
  //#endregion
306
312
  //#region src/misc/warnOnce.d.ts
307
313
  /**
308
- * Warn message only once
309
- *
310
- * @param message - warning message
311
- */
314
+ * Warn message only once
315
+ *
316
+ * @param message - warning message
317
+ */
312
318
  declare function warnOnce(message: string): void;
313
319
  //#endregion
314
320
  //#region src/misc/convertTime.d.ts
315
321
  /**
316
- * @file time utils
317
- * @module Time
318
- */
322
+ * @file time utils
323
+ * @module Time
324
+ */
319
325
  /**
320
- * Time unit conversion constants (in milliseconds)
321
- */
326
+ * Time unit conversion constants (in milliseconds)
327
+ */
322
328
  declare const TIME_UNITS: {
323
329
  readonly MILLISECOND: 1;
324
330
  readonly SECOND: 1000;
@@ -329,54 +335,54 @@ declare const TIME_UNITS: {
329
335
  };
330
336
  type TimeUnit = keyof typeof TIME_UNITS;
331
337
  /**
332
- * Converts time units to milliseconds.
333
- * @param value - The time value.
334
- * @param fromUnit - The source unit (default: 'SECOND').
335
- * @returns The time in milliseconds.
336
- * @example
337
- * ```ts
338
- * convertToMilliseconds(5, 'SECOND') // 5000
339
- * convertToMilliseconds(2, 'MINUTE') // 120000
340
- * convertToMilliseconds(1, 'HOUR') // 3600000
341
- * ```
342
- */
338
+ * Converts time units to milliseconds.
339
+ * @param value - The time value.
340
+ * @param fromUnit - The source unit (default: 'SECOND').
341
+ * @returns The time in milliseconds.
342
+ * @example
343
+ * ```ts
344
+ * convertToMilliseconds(5, 'SECOND') // 5000
345
+ * convertToMilliseconds(2, 'MINUTE') // 120000
346
+ * convertToMilliseconds(1, 'HOUR') // 3600000
347
+ * ```
348
+ */
343
349
  declare function convertToMilliseconds(value: number, fromUnit?: TimeUnit): number;
344
350
  /**
345
- * Converts milliseconds to specified time unit.
346
- * @param milliseconds - The time in milliseconds.
347
- * @param toUnit - The target unit (default: 'SECOND').
348
- * @returns The time in the specified unit.
349
- * @example
350
- * ```ts
351
- * convertFromMilliseconds(5000, 'SECOND') // 5
352
- * convertFromMilliseconds(120000, 'MINUTE') // 2
353
- * convertFromMilliseconds(3600000, 'HOUR') // 1
354
- * ```
355
- */
351
+ * Converts milliseconds to specified time unit.
352
+ * @param milliseconds - The time in milliseconds.
353
+ * @param toUnit - The target unit (default: 'SECOND').
354
+ * @returns The time in the specified unit.
355
+ * @example
356
+ * ```ts
357
+ * convertFromMilliseconds(5000, 'SECOND') // 5
358
+ * convertFromMilliseconds(120000, 'MINUTE') // 2
359
+ * convertFromMilliseconds(3600000, 'HOUR') // 1
360
+ * ```
361
+ */
356
362
  declare function convertFromMilliseconds(milliseconds: number, toUnit?: TimeUnit): number;
357
363
  /**
358
- * Converts between time units.
359
- * @param value - The time value.
360
- * @param fromUnit - The source unit.
361
- * @param toUnit - The target unit.
362
- * @returns The converted time.
363
- * @example
364
- * ```ts
365
- * convertTimeUnit(1, 'HOUR', 'MINUTE') // 60
366
- * convertTimeUnit(120, 'SECOND', 'MINUTE') // 2
367
- * convertTimeUnit(2, 'WEEK', 'DAY') // 14
368
- * ```
369
- */
364
+ * Converts between time units.
365
+ * @param value - The time value.
366
+ * @param fromUnit - The source unit.
367
+ * @param toUnit - The target unit.
368
+ * @returns The converted time.
369
+ * @example
370
+ * ```ts
371
+ * convertTimeUnit(1, 'HOUR', 'MINUTE') // 60
372
+ * convertTimeUnit(120, 'SECOND', 'MINUTE') // 2
373
+ * convertTimeUnit(2, 'WEEK', 'DAY') // 14
374
+ * ```
375
+ */
370
376
  declare function convertTimeUnit(value: number, fromUnit: TimeUnit, toUnit: TimeUnit): number;
371
377
  //#endregion
372
378
  //#region src/misc/convertStorage.d.ts
373
379
  /**
374
- * @file storage utils
375
- * @module Storage
376
- */
380
+ * @file storage utils
381
+ * @module Storage
382
+ */
377
383
  /**
378
- * Storage unit conversion constants
379
- */
384
+ * Storage unit conversion constants
385
+ */
380
386
  declare const STORAGE_UNITS: {
381
387
  readonly BYTE: 1;
382
388
  readonly KB: 1024;
@@ -386,140 +392,140 @@ declare const STORAGE_UNITS: {
386
392
  };
387
393
  type StorageUnit = keyof typeof STORAGE_UNITS;
388
394
  /**
389
- * Converts storage units to bytes.
390
- * @param value - The size value.
391
- * @param fromUnit - The source unit (default: 'MB').
392
- * @returns The size in bytes.
393
- * @example
394
- * ```ts
395
- * convertToBytes(5, 'MB') // 5242880
396
- * convertToBytes(1, 'GB') // 1073741824
397
- * convertToBytes(512, 'KB') // 524288
398
- * ```
399
- */
395
+ * Converts storage units to bytes.
396
+ * @param value - The size value.
397
+ * @param fromUnit - The source unit (default: 'MB').
398
+ * @returns The size in bytes.
399
+ * @example
400
+ * ```ts
401
+ * convertToBytes(5, 'MB') // 5242880
402
+ * convertToBytes(1, 'GB') // 1073741824
403
+ * convertToBytes(512, 'KB') // 524288
404
+ * ```
405
+ */
400
406
  declare function convertToBytes(value: number, fromUnit?: StorageUnit): number;
401
407
  /**
402
- * Converts bytes to specified storage unit.
403
- * @param bytes - The size in bytes.
404
- * @param toUnit - The target unit (default: 'MB').
405
- * @returns The size in the specified unit.
406
- * @example
407
- * ```ts
408
- * convertFromBytes(5242880, 'MB') // 5
409
- * convertFromBytes(1073741824, 'GB') // 1
410
- * convertFromBytes(524288, 'KB') // 512
411
- * ```
412
- */
408
+ * Converts bytes to specified storage unit.
409
+ * @param bytes - The size in bytes.
410
+ * @param toUnit - The target unit (default: 'MB').
411
+ * @returns The size in the specified unit.
412
+ * @example
413
+ * ```ts
414
+ * convertFromBytes(5242880, 'MB') // 5
415
+ * convertFromBytes(1073741824, 'GB') // 1
416
+ * convertFromBytes(524288, 'KB') // 512
417
+ * ```
418
+ */
413
419
  declare function convertFromBytes(bytes: number, toUnit?: StorageUnit): number;
414
420
  /**
415
- * Converts between storage units.
416
- * @param value - The size value.
417
- * @param fromUnit - The source unit.
418
- * @param toUnit - The target unit.
419
- * @returns The converted size.
420
- * @example
421
- * ```ts
422
- * convertStorageUnit(1, 'GB', 'MB') // 1024
423
- * convertStorageUnit(2048, 'MB', 'GB') // 2
424
- * convertStorageUnit(1024, 'KB', 'MB') // 1
425
- * ```
426
- */
421
+ * Converts between storage units.
422
+ * @param value - The size value.
423
+ * @param fromUnit - The source unit.
424
+ * @param toUnit - The target unit.
425
+ * @returns The converted size.
426
+ * @example
427
+ * ```ts
428
+ * convertStorageUnit(1, 'GB', 'MB') // 1024
429
+ * convertStorageUnit(2048, 'MB', 'GB') // 2
430
+ * convertStorageUnit(1024, 'KB', 'MB') // 1
431
+ * ```
432
+ */
427
433
  declare function convertStorageUnit(value: number, fromUnit: StorageUnit, toUnit: StorageUnit): number;
428
434
  //#endregion
429
435
  //#region src/array/at.d.ts
430
436
  /**
431
- * Get array item by index, negative for backward
432
- * @param array - given array
433
- * @param index - index of item
434
- * @returns undefined if not match, otherwise matched item
435
- */
437
+ * Get array item by index, negative for backward
438
+ * @param array - given array
439
+ * @param index - index of item
440
+ * @returns undefined if not match, otherwise matched item
441
+ */
436
442
  declare function at<T>(array: readonly T[], index: number): T | undefined;
437
443
  /**
438
- * Get the last item of given array
439
- * @param array - given array
440
- * @returns undefined if empty array, otherwise last item
441
- */
444
+ * Get the last item of given array
445
+ * @param array - given array
446
+ * @returns undefined if empty array, otherwise last item
447
+ */
442
448
  declare function last<T>(array: readonly T[]): T | undefined;
443
449
  //#endregion
444
450
  //#region src/array/chunk.d.ts
445
451
  /**
446
- * Splits an array into smaller chunks of a given size.
447
- * @param array - The array to split
448
- * @param size - The size of each chunk
449
- * @returns An array of arrays, where each sub-array has `size` elements from the original array.
450
- */
452
+ * Splits an array into smaller chunks of a given size.
453
+ * @param array - The array to split
454
+ * @param size - The size of each chunk
455
+ * @returns An array of arrays, where each sub-array has `size` elements from the original array.
456
+ */
451
457
  declare function chunk<T>(array: T[], size: number): T[][];
452
458
  //#endregion
453
459
  //#region src/array/remove.d.ts
454
460
  /**
455
- * Remove given item from an array
456
- * @param array - given array
457
- * @param value - item to be removed
458
- * @returns true if item was removed, otherwise false
459
- */
461
+ * Remove given item from an array
462
+ * @param array - given array
463
+ * @param value - item to be removed
464
+ * @returns true if item was removed, otherwise false
465
+ */
460
466
  declare function remove<T>(array: T[], value: T): boolean;
461
467
  //#endregion
462
468
  //#region src/array/unique.d.ts
463
469
  /**
464
- * Returns a new array with unique values.
465
- * @param array - The array to process.
466
- * @returns The new array.
467
- */
470
+ * Returns a new array with unique values.
471
+ * @param array - The array to process.
472
+ * @returns The new array.
473
+ */
468
474
  declare function unique<T>(array: T[]): T[];
469
475
  /**
470
- * Returns a new array with unique values.
471
- * @param array - The array to process.
472
- * @param equalFn - The function to compare values.
473
- * @returns The new array.
474
- */
476
+ * Returns a new array with unique values.
477
+ * @param array - The array to process.
478
+ * @param equalFn - The function to compare values.
479
+ * @returns The new array.
480
+ */
475
481
  declare function uniqueBy<T>(array: T[], equalFn: (a: T, b: T) => boolean): T[];
476
482
  //#endregion
477
483
  //#region src/array/shuffle.d.ts
478
484
  /**
479
- * Fisher–Yates shuffle
480
- *
481
- * @param array - array to shuffle
482
- * @returns shuffled array
483
- */
485
+ * Fisher–Yates shuffle
486
+ *
487
+ * @param array - array to shuffle
488
+ * @returns shuffled array
489
+ */
484
490
  declare function shuffle<T>(array: T[]): T[];
485
491
  //#endregion
486
492
  //#region src/array/toArray.d.ts
487
493
  /**
488
- * Converts a value to an array.
489
- * @param array - The value to convert.
490
- * @returns The array.
491
- */
494
+ * Converts a value to an array.
495
+ * @param array - The value to convert.
496
+ * @returns The array.
497
+ */
492
498
  declare function toArray<T>(array?: Nullable<Arrayable<T>>): T[];
493
499
  //#endregion
494
500
  //#region src/array/arrayable.d.ts
495
501
  /**
496
- * Convert `Arrayable<T>` to `Array<T>` and flatten the result
497
- * @param array - given array
498
- * @returns Array<T>
499
- */
500
- declare function flattenArrayable<T>(array?: Nullable<Arrayable<T | Array<T>>>): Array<T>;
502
+ * Convert `Arrayable<T>` to `Array<T>` and flatten the result
503
+ * @param array - given array
504
+ * @returns Array<T>
505
+ */
506
+ declare function flattenArrayable<T>(array?: Nullable<Arrayable<T | T[]>>): T[];
501
507
  /**
502
- * Use rest arguments to merge arrays
503
- * @param args - rest arguments
504
- * @returns Array<T>
505
- */
506
- declare function mergeArrayable<T>(...args: Nullable<Arrayable<T>>[]): Array<T>;
508
+ * Use rest arguments to merge arrays
509
+ * @param args - rest arguments
510
+ * @returns Array<T>
511
+ */
512
+ declare function mergeArrayable<T>(...args: Nullable<Arrayable<T>>[]): T[];
507
513
  //#endregion
508
514
  //#region src/array/intersect.d.ts
509
515
  /**
510
- * Get intersect items
511
- *
512
- * @returns intersect items
513
- */
516
+ * Get intersect items
517
+ *
518
+ * @returns intersect items
519
+ */
514
520
  declare function intersect<T>(a: T[], b: T[]): T[];
515
521
  //#endregion
516
522
  //#region src/array/isArrayEqual.d.ts
517
523
  /**
518
- * Check if values of two arrays are equal
519
- * @param array1 - array 1
520
- * @param array2 - array 2
521
- * @returns `true` if equal
522
- */
524
+ * Check if values of two arrays are equal
525
+ * @param array1 - array 1
526
+ * @param array2 - array 2
527
+ * @returns `true` if equal
528
+ */
523
529
  declare function isArrayEqual(array1: unknown[], array2: unknown[]): boolean;
524
530
  //#endregion
525
531
  //#region src/color/color.d.ts
@@ -538,265 +544,313 @@ declare class Color {
538
544
  toHexString(isUpperCase?: boolean): string;
539
545
  toRGBAString(): string;
540
546
  /**
541
- * add alpha value to {@link Color}
542
- *
543
- * @param alpha - alpha value
544
- * @returns instance of {@link Color}
545
- */
547
+ * add alpha value to {@link Color}
548
+ *
549
+ * @param alpha - alpha value
550
+ * @returns instance of {@link Color}
551
+ */
546
552
  withAlpha(alpha?: number): Color;
547
553
  /**
548
- * lighten the color by percentage
549
- *
550
- * @param percentage - percentage to lighten
551
- */
554
+ * lighten the color by percentage
555
+ *
556
+ * @param percentage - percentage to lighten
557
+ */
552
558
  lighten(percentage?: number): Color;
553
559
  /**
554
- * darken the color by percentage
555
- *
556
- * @param percentage - percentage to darken
557
- */
560
+ * darken the color by percentage
561
+ *
562
+ * @param percentage - percentage to darken
563
+ */
558
564
  darken(percentage?: number): Color;
559
565
  }
560
566
  //#endregion
561
567
  //#region src/color/random.d.ts
562
568
  /**
563
- * get a random RGB color
564
- * @returns a random RGB color
565
- */
569
+ * get a random RGB color
570
+ * @returns a random RGB color
571
+ */
566
572
  declare function randomRGBColor(): string;
567
573
  /**
568
- * get a random RGBA color
569
- * @returns a random RGBA color
570
- */
574
+ * get a random RGBA color
575
+ * @returns a random RGBA color
576
+ */
571
577
  declare function randomRGBAColor(): string;
572
578
  /**
573
- * get a random hex color
574
- * @returns a random hex color
575
- */
579
+ * get a random hex color
580
+ * @returns a random hex color
581
+ */
576
582
  declare function randomHexColor(): string;
577
583
  //#endregion
578
584
  //#region src/proxy/enhance.d.ts
579
585
  /**
580
- * enhance object
581
- * @module proxy
582
- */
586
+ * enhance object
587
+ * @module proxy
588
+ */
583
589
  declare function enhance<T extends Record<PropertyKey, any>, E extends Record<PropertyKey, any>>(module: T, extra: E): T;
584
590
  //#endregion
591
+ //#region src/tree/flatTree.d.ts
592
+ interface FlatTreeOptions<T extends Record<PropertyKey, any>, K extends keyof T> {
593
+ /**
594
+ * children key, maybe `children`, `nodes`, `items` or other name
595
+ *
596
+ * @default `children`
597
+ */
598
+ childrenKey?: K;
599
+ /**
600
+ * whether to include the current node in the result
601
+ * @default true
602
+ */
603
+ includeSelf?: boolean;
604
+ /**
605
+ * map function, return value will be used as the result of the current node, if not provided, the current node will be used as the result
606
+ */
607
+ map?: (ctx: {
608
+ node: T;
609
+ parent: T | null;
610
+ depth: number;
611
+ /**
612
+ * index of the current node in the current level, starting from 0
613
+ */
614
+ index: number;
615
+ path: T[];
616
+ }) => any;
617
+ }
618
+ /**
619
+ * Flatten tree nodes into a one-dimensional array with depth-first pre-order traversal.
620
+ *
621
+ * If `options.map` is not provided, original nodes are returned.
622
+ *
623
+ * @param roots - Root nodes of the tree.
624
+ * @param options - Flatten options.
625
+ * @returns Flattened nodes.
626
+ */
627
+ declare function flatTree<T extends Record<PropertyKey, any>, K extends keyof T>(roots: readonly T[], options?: FlatTreeOptions<T, K>): T[];
628
+ /**
629
+ * Flatten tree nodes and map each visited node to a custom result.
630
+ *
631
+ * @param roots - Root nodes of the tree.
632
+ * @param options - Flatten options with a `map` callback.
633
+ * @returns Flattened mapped results.
634
+ */
635
+ declare function flatTree<T extends Record<PropertyKey, any>, K extends keyof T, R>(roots: readonly T[], options: FlatTreeOptions<T, K> & {
636
+ map: (ctx: any) => R;
637
+ }): R[];
638
+ //#endregion
585
639
  //#region src/module/interopDefault.d.ts
586
640
  /**
587
- * Interop default export from a module
588
- *
589
- * @param mod - The module
590
- * @returns The default export
591
- *
592
- * @example
593
- *
594
- * ```ts
595
- * import { interopDefault } from '@ntnyq/utils'
596
- *
597
- * const { unindent } = await interopDefault(import('@ntnyq/utils'))
598
- * ```
599
- */
641
+ * Interop default export from a module
642
+ *
643
+ * @param mod - The module
644
+ * @returns The default export
645
+ *
646
+ * @example
647
+ *
648
+ * ```ts
649
+ * import { interopDefault } from '@ntnyq/utils'
650
+ *
651
+ * const { unindent } = await interopDefault(import('@ntnyq/utils'))
652
+ * ```
653
+ */
600
654
  declare function interopDefault<T>(mod: Awaitable<T>): Promise<InteropModuleDefault<T>>;
601
655
  //#endregion
602
656
  //#region src/module/resolveSubOptions.d.ts
603
657
  /**
604
- * Resolve sub options `boolean | Options` to `Options`
605
- * @param options - core options
606
- * @param key - sub options key
607
- * @returns resolved sub options
608
- *
609
- * @example
610
- *
611
- * ```ts
612
- * import { resolveSubOptions } from '@ntnyq/utils'
613
- *
614
- * interface Options {
615
- * compile?: boolean | {
616
- * include?: string[]
617
- * exclude?: string[]
618
- * }
619
- * }
620
- *
621
- * const options: Options = {
622
- * compile: true
623
- * }
624
- *
625
- * console.log(resolveSubOptions(options, 'compile'))
626
- *
627
- * // => {}
628
- * ```
629
- */
630
- declare function resolveSubOptions<T extends Record<string, any>, K$1 extends keyof T>(options: T, key: K$1): Partial<ResolvedOptions<T[K$1]>>;
658
+ * Resolve sub options `boolean | Options` to `Options`
659
+ * @param options - core options
660
+ * @param key - sub options key
661
+ * @returns resolved sub options
662
+ *
663
+ * @example
664
+ *
665
+ * ```ts
666
+ * import { resolveSubOptions } from '@ntnyq/utils'
667
+ *
668
+ * interface Options {
669
+ * compile?: boolean | {
670
+ * include?: string[]
671
+ * exclude?: string[]
672
+ * }
673
+ * }
674
+ *
675
+ * const options: Options = {
676
+ * compile: true
677
+ * }
678
+ *
679
+ * console.log(resolveSubOptions(options, 'compile'))
680
+ *
681
+ * // => {}
682
+ * ```
683
+ */
684
+ declare function resolveSubOptions<T extends Record<string, any>, K extends keyof T>(options: T, key: K): Partial<ResolvedOptions<T[K]>>;
631
685
  //#endregion
632
686
  //#region src/number/random.d.ts
633
687
  interface RamdomNumberOptions {
634
688
  /**
635
- * include max value
636
- *
637
- * @default false
638
- */
689
+ * include max value
690
+ *
691
+ * @default false
692
+ */
639
693
  includeMax?: boolean;
640
694
  }
641
695
  /**
642
- * random an integer by given range
643
- *
644
- * @param min - min value
645
- * @param max - max value
646
- * @returns random integer in range
647
- */
696
+ * random an integer by given range
697
+ *
698
+ * @param min - min value
699
+ * @param max - max value
700
+ * @returns random integer in range
701
+ */
648
702
  declare function randomNumber(min: number, max?: number, options?: RamdomNumberOptions): number;
649
703
  //#endregion
650
704
  //#region src/number/toInteger.d.ts
651
705
  interface ToIntegerOptions {
652
706
  /**
653
- * The number to convert to an integer.
654
- *
655
- * @default 0
656
- */
707
+ * The number to convert to an integer.
708
+ *
709
+ * @default 0
710
+ */
657
711
  defaultValue?: number;
658
712
  /**
659
- * @default false
660
- */
713
+ * @default false
714
+ */
661
715
  allowDecimal?: boolean;
662
716
  /**
663
- * @default false
664
- */
717
+ * @default false
718
+ */
665
719
  allowNaN?: boolean;
666
720
  /**
667
- * @default `useDefault`
668
- */
669
- onError?: "useDefault" | "throwError" | "returnOriginal";
721
+ * @default `useDefault`
722
+ */
723
+ onError?: 'useDefault' | 'throwError' | 'returnOriginal';
670
724
  /**
671
- * Minimum value of the number. included
672
- */
725
+ * Minimum value of the number. included
726
+ */
673
727
  min?: number;
674
728
  /**
675
- * Maximum value of the number. included
676
- */
729
+ * Maximum value of the number. included
730
+ */
677
731
  max?: number;
678
732
  /**
679
- * @default `clamp`
680
- */
681
- outOfRange?: "clamp" | "useDefault" | "throwError";
733
+ * @default `clamp`
734
+ */
735
+ outOfRange?: 'clamp' | 'useDefault' | 'throwError';
682
736
  }
683
737
  /**
684
- * Transforms a value to an integer.
685
- * @param value - The value to convert to an integer.
686
- * @param options - Options for the conversion.
687
- * @returns The converted integer.
688
- */
738
+ * Transforms a value to an integer.
739
+ * @param value - The value to convert to an integer.
740
+ * @param options - Options for the conversion.
741
+ * @returns The converted integer.
742
+ */
689
743
  declare function toInteger(value: unknown, options?: ToIntegerOptions): number;
690
744
  //#endregion
691
745
  //#region src/object/omit.d.ts
692
- declare function omit<T, K$1 extends keyof T>(object: T, ...keys: K$1[]): Omit<T, K$1>;
746
+ declare function omit<T, K extends keyof T>(object: T, ...keys: K[]): Omit<T, K>;
693
747
  //#endregion
694
748
  //#region src/object/pick.d.ts
695
- declare function pick<T, K$1 extends keyof T>(object: T, keys: K$1[]): Pick<T, K$1>;
749
+ declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
696
750
  //#endregion
697
751
  //#region src/object/clean.d.ts
698
752
  interface CleanObjectOptions {
699
753
  /**
700
- * clean undefined
701
- *
702
- * @default true
703
- */
754
+ * clean undefined
755
+ *
756
+ * @default true
757
+ */
704
758
  cleanUndefined?: boolean;
705
759
  /**
706
- * clean null
707
- *
708
- * @default true
709
- */
760
+ * clean null
761
+ *
762
+ * @default true
763
+ */
710
764
  cleanNull?: boolean;
711
765
  /**
712
- * clean zero
713
- *
714
- * @default false
715
- */
766
+ * clean zero
767
+ *
768
+ * @default false
769
+ */
716
770
  cleanZero?: boolean;
717
771
  /**
718
- * clean NaN
719
- *
720
- * @default true
721
- */
772
+ * clean NaN
773
+ *
774
+ * @default true
775
+ */
722
776
  cleanNaN?: boolean;
723
777
  /**
724
- * clean empty string
725
- *
726
- * @default false
727
- */
778
+ * clean empty string
779
+ *
780
+ * @default false
781
+ */
728
782
  cleanEmptyString?: boolean;
729
783
  /**
730
- * clean empty array
731
- *
732
- * @default false
733
- */
784
+ * clean empty array
785
+ *
786
+ * @default false
787
+ */
734
788
  cleanEmptyArray?: boolean;
735
789
  /**
736
- * clean empty object
737
- *
738
- * @default false
739
- */
790
+ * clean empty object
791
+ *
792
+ * @default false
793
+ */
740
794
  cleanEmptyObject?: boolean;
741
795
  /**
742
- * recursive clean object
743
- *
744
- * @default true
745
- */
796
+ * recursive clean object
797
+ *
798
+ * @default true
799
+ */
746
800
  recursive?: boolean;
747
801
  }
748
802
  /**
749
- * clean undefined, null, zero, empty string, empty array, empty object from object
750
- * @param obj - object to be cleaned
751
- * @param options - clean options
752
- * @returns cleaned object
753
- */
803
+ * clean undefined, null, zero, empty string, empty array, empty object from object
804
+ * @param obj - object to be cleaned
805
+ * @param options - clean options
806
+ * @returns cleaned object
807
+ */
754
808
  declare function cleanObject<T extends object>(obj: T, options?: CleanObjectOptions): T;
755
809
  //#endregion
756
810
  //#region src/object/hasOwn.d.ts
757
811
  /**
758
- * check object has a property with given key
759
- * @param object - the object to check
760
- * @param key - the key to check
761
- * @returns true if object has a property with given key, false otherwise
762
- */
812
+ * check object has a property with given key
813
+ * @param object - the object to check
814
+ * @param key - the key to check
815
+ * @returns true if object has a property with given key, false otherwise
816
+ */
763
817
  declare function hasOwn<T>(object: T, key: PropertyKey): boolean;
764
818
  //#endregion
765
819
  //#region src/object/isKeyOf.d.ts
766
820
  /**
767
- * Type guard for any key, `k`
768
- * marks `k` as a key of `T` if `k` is a key of `T`
769
- *
770
- * @param obj - object to query for key
771
- * @param k - key to check for
772
- * @returns true if `k` is a key of `T`
773
- */
821
+ * Type guard for any key, `k`
822
+ * marks `k` as a key of `T` if `k` is a key of `T`
823
+ *
824
+ * @param obj - object to query for key
825
+ * @param k - key to check for
826
+ * @returns true if `k` is a key of `T`
827
+ */
774
828
  declare function isKeyOf<T extends object>(obj: T, k: keyof T): k is keyof T;
775
829
  //#endregion
776
830
  //#region src/object/sortObject.d.ts
777
831
  interface SortObjectOptions {
778
832
  /**
779
- * Recursive sorting
780
- * @default false
781
- */
833
+ * Recursive sorting
834
+ * @default false
835
+ */
782
836
  deep?: boolean;
783
837
  /**
784
- * Compare function
785
- */
838
+ * Compare function
839
+ */
786
840
  compareFn?: (left: string, right: string) => number;
787
841
  }
788
842
  /**
789
- * Sort object properties
790
- */
791
- declare function sortObject<T extends Record<string, any>>(obj: T, options?: SortObjectOptions): T;
843
+ * Sort object properties
844
+ */
845
+ declare function sortObject<T extends Record<string, any>>(object: T, options?: SortObjectOptions): T;
792
846
  //#endregion
793
847
  //#region src/object/isPlainObject.d.ts
794
848
  /**
795
- * Check if a value is a plain object (not an array, Date, RegExp, Map, Set, etc.)
796
- *
797
- * @param value - Checked value
798
- * @copyright {@link https://github.com/sindresorhus/is/blob/main/source/index.ts}
799
- */
849
+ * Check if a value is a plain object (not an array, Date, RegExp, Map, Set, etc.)
850
+ *
851
+ * @param value - Checked value
852
+ * @copyright {@link https://github.com/sindresorhus/is/blob/main/source/index.ts}
853
+ */
800
854
  declare function isPlainObject<Value = unknown>(value: unknown): value is Record<PropertyKey, Value>;
801
855
  //#endregion
802
856
  //#region src/string/pad.d.ts
@@ -810,70 +864,70 @@ declare function createPadString(options: CreatePadStringOptions): (value: strin
810
864
  type JoinableValue = string | number | null | undefined;
811
865
  interface JoinOptions {
812
866
  /**
813
- * @default ''
814
- */
867
+ * @default ''
868
+ */
815
869
  separator?: string;
816
870
  }
817
871
  /**
818
- * Joins an array of strings or numbers into a single string.
819
- * @param array - An array of strings or numbers.
820
- * @param options - An object of options.
821
- * @returns A string.
822
- */
872
+ * Joins an array of strings or numbers into a single string.
873
+ * @param array - An array of strings or numbers.
874
+ * @param options - An object of options.
875
+ * @returns A string.
876
+ */
823
877
  declare function join(array: JoinableValue[], options?: JoinOptions): string;
824
878
  //#endregion
825
879
  //#region src/string/slash.d.ts
826
880
  /**
827
- * Replace backslash to slash
828
- */
881
+ * Replace backslash to slash
882
+ */
829
883
  declare function slash(input: string): string;
830
884
  //#endregion
831
885
  //#region src/string/escape.d.ts
832
886
  /**
833
- * @copyright {@link https://github.com/sindresorhus/escape-string-regexp}
834
- */
887
+ * @copyright {@link https://github.com/sindresorhus/escape-string-regexp}
888
+ */
835
889
  declare function escapeStringRegexp(value: string): string;
836
890
  //#endregion
837
891
  //#region src/string/random.d.ts
838
892
  /**
839
- * randome a string useing given chars
840
- *
841
- * @param length - string length
842
- * @param chars - string chars
843
- * @returns random string
844
- */
893
+ * randome a string useing given chars
894
+ *
895
+ * @param length - string length
896
+ * @param chars - string chars
897
+ * @returns random string
898
+ */
845
899
  declare function randomString(length?: number, chars?: string): string;
846
900
  //#endregion
847
901
  //#region src/string/slugify.d.ts
848
902
  /**
849
- * Default slugify function
850
- */
903
+ * Default slugify function
904
+ */
851
905
  declare function slugify(str: string): string;
852
906
  //#endregion
853
907
  //#region src/string/unindent.d.ts
854
908
  /**
855
- * Remove common leading whitespace from a template string
856
- * Empty lines at the beginning and end of the template string are also removed.
857
- * @param input - template string
858
- *
859
- * @example
860
- *
861
- * ```ts
862
- * const str = unindent`
863
- * if (foo) {
864
- * bar()
865
- * }
866
- * `
867
- * ```
868
- */
909
+ * Remove common leading whitespace from a template string
910
+ * Empty lines at the beginning and end of the template string are also removed.
911
+ * @param input - template string
912
+ *
913
+ * @example
914
+ *
915
+ * ```ts
916
+ * const str = unindent`
917
+ * if (foo) {
918
+ * bar()
919
+ * }
920
+ * `
921
+ * ```
922
+ */
869
923
  declare function unindent(input: TemplateStringsArray | string): string;
870
924
  //#endregion
871
925
  //#region src/string/getLength.d.ts
872
926
  /**
873
- * Counts graphemes in a given string
874
- * @param value - A string to count graphemes.
875
- * @returns The number of graphemes in `value`.
876
- */
927
+ * Counts graphemes in a given string
928
+ * @param value - A string to count graphemes.
929
+ * @returns The number of graphemes in `value`.
930
+ */
877
931
  declare function getStringLength(value: string): number;
878
932
  //#endregion
879
933
  //#region src/string/ensurePrefix.d.ts
@@ -884,67 +938,67 @@ declare function ensureSuffix(input: string, suffix: string): string;
884
938
  //#endregion
885
939
  //#region src/string/getSimilarity.d.ts
886
940
  /**
887
- * @copyright {@link https://github.com/stephenjjbrown/string-similarity-js}
888
- */
941
+ * @copyright {@link https://github.com/stephenjjbrown/string-similarity-js}
942
+ */
889
943
  interface GetStringSimilarityOptions {
890
944
  /**
891
- * The length of the slice to compare.
892
- * @default 2
893
- */
945
+ * The length of the slice to compare.
946
+ * @default 2
947
+ */
894
948
  sliceLength?: number;
895
949
  /**
896
- * Whether to ignore case when comparing strings.
897
- * @default false
898
- */
950
+ * Whether to ignore case when comparing strings.
951
+ * @default false
952
+ */
899
953
  caseSensitive?: boolean;
900
954
  }
901
955
  declare function getStringSimilarity(str1: string, str2: string, options?: GetStringSimilarityOptions): number;
902
956
  //#endregion
903
957
  //#region src/constants/char.d.ts
904
958
  /**
905
- * Special chars
906
- */
959
+ * Special chars
960
+ */
907
961
  declare const SPECIAL_CHAR: {
908
962
  /**
909
- * 中文顿号
910
- */
963
+ * 中文顿号
964
+ */
911
965
  chineseComma: string;
912
966
  /**
913
- * 英文逗号
914
- */
967
+ * 英文逗号
968
+ */
915
969
  englishComma: string;
916
970
  /**
917
- * 英文句号
918
- */
971
+ * 英文句号
972
+ */
919
973
  englishPeriod: string;
920
974
  /**
921
- * 连接符
922
- */
975
+ * 连接符
976
+ */
923
977
  hyphen: string;
924
978
  /**
925
- * 换行
926
- */
979
+ * 换行
980
+ */
927
981
  newline: string;
928
982
  /**
929
- * 空格
930
- */
983
+ * 空格
984
+ */
931
985
  whitespace: string;
932
986
  };
933
987
  //#endregion
934
988
  //#region src/constants/regexp.d.ts
935
989
  /**
936
- * 注释正则
937
- *
938
- * 匹配 \<!-- 或 /* 开头的注释,直到 --> 或 *\/ 结尾
939
- */
990
+ * 注释正则
991
+ *
992
+ * 匹配 \<!-- 或 /* 开头的注释,直到 --> 或 *\/ 结尾
993
+ */
940
994
  declare const RE_COMMENTS: RegExp;
941
995
  /**
942
- * JavaScript line comment
943
- */
996
+ * JavaScript line comment
997
+ */
944
998
  declare const RE_LINE_COMMENT: RegExp;
945
999
  /**
946
- * JavaScript block comment
947
- */
1000
+ * JavaScript block comment
1001
+ */
948
1002
  declare const RE_BLOCK_COMMENT: RegExp;
949
1003
  //#endregion
950
- export { AnyFn, Arrayable, Awaitable, Callable, CleanObjectOptions, Color, CreatePadStringOptions, DeepRequired, ElementOf, GetStringSimilarityOptions, InteropModuleDefault, JsonArray, JsonObject, JsonPrimitive, JsonValue, LiteralUnion, MayBe, Merge, NOOP, NonEmptyObject, NonEmptyString, Nullable, OpenExternalURLOptions, Overwrite, Prettify, PrettifyV2, Primitive, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, RamdomNumberOptions, ResolvedOptions, SPECIAL_CHAR, STORAGE_UNITS, SortObjectOptions, StorageUnit, TIME_UNITS, ThrottleDebounceOptions, TimeUnit, ToIntegerOptions, UrlString, ValueOf, Whitespace, at, cAF, chunk, clamp, cleanObject, convertFromBytes, convertFromMilliseconds, convertStorageUnit, convertTimeUnit, convertToBytes, convertToMilliseconds, createPadString, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, escapeStringRegexp, flattenArrayable, getFileExtension, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBlob, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFile, isFormData, isFunction, isHTMLElement, isInteger, isIterable, isKeyOf, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isUrlString, isWhitespaceString, isZero, join, last, mergeArrayable, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, remove, removeFileExtension, resolveSubOptions, scrollElementIntoView, shuffle, slash, slugify, sortObject, throttle, toArray, toInteger, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce };
1004
+ export { AnyFn, Arrayable, Awaitable, Callable, CleanObjectOptions, Color, CreatePadStringOptions, DeepRequired, ElementOf, FlatTreeOptions, GetStringSimilarityOptions, InteropModuleDefault, JsonArray, JsonObject, JsonPrimitive, JsonValue, LiteralUnion, MayBe, Merge, NOOP, NonEmptyObject, NonEmptyString, Nullable, OpenExternalURLOptions, Overwrite, Prettify, PrettifyV2, Primitive, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, RamdomNumberOptions, ResolvedOptions, SPECIAL_CHAR, STORAGE_UNITS, SortObjectOptions, StorageUnit, TIME_UNITS, ThrottleDebounceOptions, TimeUnit, ToIntegerOptions, UrlString, ValueOf, Whitespace, at, cAF, chunk, clamp, cleanObject, convertFromBytes, convertFromMilliseconds, convertStorageUnit, convertTimeUnit, convertToBytes, convertToMilliseconds, createPadString, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, escapeStringRegexp, flatTree, flattenArrayable, getFileExtension, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBlob, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFile, isFormData, isFunction, isHTMLElement, isInteger, isIterable, isKeyOf, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isUrlString, isWhitespaceString, isZero, join, last, mergeArrayable, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, remove, removeFileExtension, resolveSubOptions, scrollElementIntoView, shuffle, slash, slugify, sortObject, throttle, toArray, toInteger, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce };