@andrew_l/toolkit 0.2.13 → 0.2.15

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/index.d.cts CHANGED
@@ -133,6 +133,8 @@ declare function chunkSeries(list: number[], step?: number): number[][];
133
133
  * const array3 = [1, 5];
134
134
  * const result = difference(array1, array2, array3);
135
135
  * // result will be [3] since 1, 2, 4 and 5 are in other arrays and are excluded from the result.
136
+ *
137
+ * @group Array
136
138
  */
137
139
  declare function difference<T>(...arrays: readonly T[][]): T[];
138
140
 
@@ -173,6 +175,8 @@ declare function groupBy<T, K extends PropertyKey>(array: readonly T[], keyBy: (
173
175
  * const array2 = [3, 4, 5, 6, 7];
174
176
  * const result = intersection(array1, array2);
175
177
  * // result will be [3, 4, 5] since these elements are in both arrays.
178
+ *
179
+ * @group Array
176
180
  */
177
181
  declare function intersection<T>(...arrays: readonly T[][]): T[];
178
182
 
@@ -235,9 +239,78 @@ declare function orderBy<T>(array: readonly T[], fields: (string | ((item: T) =>
235
239
  * const array = [1, 2, 3, 4, 5];
236
240
  * const shuffledArray = shuffle(array);
237
241
  * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
242
+ *
243
+ * @group Array
238
244
  */
239
245
  declare function shuffle<T>(arr: readonly T[]): T[];
240
246
 
247
+ /**
248
+ * Function that compares two elements and returns a number indicating their relative order.
249
+ * - Negative number if a < b
250
+ * - Zero if a equals b
251
+ * - Positive number if a > b
252
+ *
253
+ * @template T The type of elements in the array
254
+ */
255
+ type SortedArrayCompareFn<T> = (a: T, b: T) => number;
256
+ /**
257
+ * A self-sorting array that maintains elements in a sorted order based on a comparison function.
258
+ * All mutating operations preserve the sorted order of elements.
259
+ *
260
+ * @template T The type of elements in the array
261
+ *
262
+ * @example
263
+ * // Create a numerically sorted array
264
+ * const arr = new SortedArray((a, b) => a - b);
265
+ * arr.push(3, 2, 1);
266
+ * console.log(arr); // [1, 2, 3]
267
+ *
268
+ * @example
269
+ * // Create a sorted array with initial values
270
+ * const names = new SortedArray((a, b) => a.localeCompare(b), ["Charlie", "Alice", "Bob"]);
271
+ * console.log(names); // ["Alice", "Bob", "Charlie"]
272
+ *
273
+ * @example
274
+ * // Create a sorted array with a custom comparator
275
+ * const people = new SortedArray(
276
+ * (a, b) => a.age - b.age || a.name.localeCompare(b.name),
277
+ * [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }]
278
+ * );
279
+ *
280
+ * @group Array
281
+ */
282
+ declare class SortedArray<T> extends Array<T> {
283
+ #private;
284
+ /**
285
+ * Creates a new SortedArray instance.
286
+ *
287
+ * @param compareFn The comparison function to determine the sort order
288
+ * @param items Optional initial items to add to the array (will be sorted immediately)
289
+ */
290
+ constructor(compareFn: SortedArrayCompareFn<T>, items?: T[]);
291
+ /**
292
+ * Inserts multiple items while maintaining sort order
293
+ * @param items The items to insert
294
+ * @returns The new length of the array
295
+ */
296
+ push(...items: T[]): number;
297
+ /**
298
+ * Override Array methods that would break the sorted order
299
+ */
300
+ unshift(...items: T[]): number;
301
+ /**
302
+ * Creates a new SortedArray with the same comparison function
303
+ * @returns A new SortedArray instance
304
+ */
305
+ slice(start?: number, end?: number): SortedArray<T>;
306
+ /**
307
+ * Concatenates arrays or values while maintaining sort order
308
+ * @param items Arrays or values to concatenate
309
+ * @returns A new SortedArray with the concatenated elements
310
+ */
311
+ concat(...items: (T | ConcatArray<T>)[]): SortedArray<T>;
312
+ }
313
+
241
314
  /**
242
315
  * Sums the values in an array of numbers, ignoring non-numeric values.
243
316
  *
@@ -1642,7 +1715,7 @@ declare const ColorParser: {
1642
1715
  * Calculate crc32 hash from string
1643
1716
  * @group Crypto
1644
1717
  */
1645
- declare function crc32(str: string, seed?: number): number;
1718
+ declare function crc32(current: Uint8Array | string, seed?: number): number;
1646
1719
 
1647
1720
  type DateObjectInput = Date | string | number | DateObject;
1648
1721
  declare function createDateObject(value: DateObjectInput): DateObject;
@@ -5160,4 +5233,4 @@ declare function wrapText(value: string, maxLength?: number): string;
5160
5233
  */
5161
5234
  declare function toError<T>(value: T, unknownMessage?: string): T extends Error ? T : Error;
5162
5235
 
5163
- export { type AnyFunction, AppError, type AppErrorOptions, type ArgumentsType, type Arrayable, AsyncIterableQueue, type Awaitable, type Base64ToBytesOptions, BrowserAssertionError, type BytesToBase64Options, CancellablePromise, type CatchErrorResult, Color, type ColorChannels, ColorParser, type Data, type DateObject, type DateObjectInput, type DebouncedFunction, type DeepPartial, type DeepReadonly, type Defer, instance as EJSON, EJSONStream, type EJSONStreamOptions, type EJSONStreamOptionsWithPayload, type EnvParser, type ExecResult, type ExecResultToSkip, type ExecResultToSuccess, type ExecSkip, type ExecSuccess, FindMean, FixedMap, FixedWeakMap, type Fn, type FormatMoney, type FormatNumber, type FunctionArgs, type GenericObject, type IfAny, type IsAny, type LiteralUnion, type Logger, LruCache, type Nothing, type OverwriteWith, type Prettify, type Primitive, type PromisifyFn, Queue, type RandomizerOptions, type RetryOnErrorConfig, type SelectOptionItem, type SelectOptions, type SimpleDefaultEventMap, SimpleEventEmitter, type SimpleEventMap, _default as TWEMOJI_REGEX, type ThemeConfig, type ThrottledFunction, TimeBucket, type TimeBucketOptions, type TimeObject, type TimeObjectInput, TimeSpan, type TimeSpanUnit, type TimeString, type TimeValue, type TimestampMsInput, type TypeOf, type TypeOfMap, type ValuesOfObject, type WithCache, type WithCacheBucketBatchOptions, type WithCacheBucketOptions, type WithCacheFixedOptions, type WithCacheLruOptions, type WithCacheOptions, type WithCachePointer, type WithCacheResult, type WithCacheStorage, type WithCustomizer, type WithCustomizerFactory, type WithCustomizerValue, type WrrItem, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, avgCircular, base64ToBytes, bigIntBytes, bigIntFromBytes, blendColors, buildCssColor, bytesToBase64, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, compareBytes, concatenateBytes, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDateObject, createDeepCloneWith, createEJSON, createEJSONStream, createEnvParser, createRandomizer, createSecureCustomizer, createTimeObject, createTimeSpan, createWithCache, cssVariable, dateInDays, dateInSeconds, debounce, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, difference, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getMostSpecificPaths, getRandomInt, getRandomTime, getWords, groupBy, has, hasOwn, hasProtocol, hex, hexToChannels, hmToSeconds, hslToChannels, humanFileSize, humanize, interpolateColor, intersection, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDateObject, isDef, isEmpty, isEqual, isError, isFunction, isInfinity, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isSkip, isString, isSuccess, isSymbol, isTimeObject, isTimeString, isTimeValue, isValidWeekDay, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, loggerSetLevel, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, secondsToHm, set, shuffle, snakeCase, sprintf, startCase, strAssign, sum, throttle, timeFromMinutes, timeStringify, timeToMinutes, timeout, timestamp, timestampMs, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, uint16ToUint8, uint32ToUint8, uint8ToUint16, uint8ToUint32, unflatten, union, uniq, uniqBy, unset, weeksInYear, weightedRoundRobin, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };
5236
+ export { type AnyFunction, AppError, type AppErrorOptions, type ArgumentsType, type Arrayable, AsyncIterableQueue, type Awaitable, type Base64ToBytesOptions, BrowserAssertionError, type BytesToBase64Options, CancellablePromise, type CatchErrorResult, Color, type ColorChannels, ColorParser, type Data, type DateObject, type DateObjectInput, type DebouncedFunction, type DeepPartial, type DeepReadonly, type Defer, instance as EJSON, EJSON as EJSONInstance, EJSONStream, type EJSONStreamOptions, type EJSONStreamOptionsWithPayload, type EJSONType, type EnvParser, type ExecResult, type ExecResultToSkip, type ExecResultToSuccess, type ExecSkip, type ExecSuccess, FindMean, FixedMap, FixedWeakMap, type Fn, type FormatMoney, type FormatNumber, type FunctionArgs, type GenericObject, type IfAny, type IsAny, type LiteralUnion, type Logger, LruCache, type Nothing, type OverwriteWith, type Prettify, type Primitive, type PromisifyFn, Queue, type RandomizerOptions, type RetryOnErrorConfig, type SelectOptionItem, type SelectOptions, type SimpleDefaultEventMap, SimpleEventEmitter, type SimpleEventMap, SortedArray, type SortedArrayCompareFn, _default as TWEMOJI_REGEX, type ThemeConfig, type ThrottledFunction, TimeBucket, type TimeBucketOptions, type TimeObject, type TimeObjectInput, TimeSpan, type TimeSpanUnit, type TimeString, type TimeValue, type TimestampMsInput, type TypeOf, type TypeOfMap, type ValuesOfObject, type WithCache, type WithCacheBucketBatchOptions, type WithCacheBucketOptions, type WithCacheFixedOptions, type WithCacheLruOptions, type WithCacheOptions, type WithCachePointer, type WithCacheResult, type WithCacheStorage, type WithCustomizer, type WithCustomizerFactory, type WithCustomizerValue, type WrrItem, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, avgCircular, base64ToBytes, bigIntBytes, bigIntFromBytes, blendColors, buildCssColor, bytesToBase64, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, compareBytes, concatenateBytes, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDateObject, createDeepCloneWith, createEJSON, createEJSONStream, createEnvParser, createRandomizer, createSecureCustomizer, createTimeObject, createTimeSpan, createWithCache, cssVariable, dateInDays, dateInSeconds, debounce, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, difference, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getMostSpecificPaths, getRandomInt, getRandomTime, getWords, groupBy, has, hasOwn, hasProtocol, hex, hexToChannels, hmToSeconds, hslToChannels, humanFileSize, humanize, interpolateColor, intersection, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDateObject, isDef, isEmpty, isEqual, isError, isFunction, isInfinity, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isSkip, isString, isSuccess, isSymbol, isTimeObject, isTimeString, isTimeValue, isValidWeekDay, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, loggerSetLevel, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, secondsToHm, set, shuffle, snakeCase, sprintf, startCase, strAssign, sum, throttle, timeFromMinutes, timeStringify, timeToMinutes, timeout, timestamp, timestampMs, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, uint16ToUint8, uint32ToUint8, uint8ToUint16, uint8ToUint32, unflatten, union, uniq, uniqBy, unset, weeksInYear, weightedRoundRobin, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };
package/dist/index.d.mts CHANGED
@@ -133,6 +133,8 @@ declare function chunkSeries(list: number[], step?: number): number[][];
133
133
  * const array3 = [1, 5];
134
134
  * const result = difference(array1, array2, array3);
135
135
  * // result will be [3] since 1, 2, 4 and 5 are in other arrays and are excluded from the result.
136
+ *
137
+ * @group Array
136
138
  */
137
139
  declare function difference<T>(...arrays: readonly T[][]): T[];
138
140
 
@@ -173,6 +175,8 @@ declare function groupBy<T, K extends PropertyKey>(array: readonly T[], keyBy: (
173
175
  * const array2 = [3, 4, 5, 6, 7];
174
176
  * const result = intersection(array1, array2);
175
177
  * // result will be [3, 4, 5] since these elements are in both arrays.
178
+ *
179
+ * @group Array
176
180
  */
177
181
  declare function intersection<T>(...arrays: readonly T[][]): T[];
178
182
 
@@ -235,9 +239,78 @@ declare function orderBy<T>(array: readonly T[], fields: (string | ((item: T) =>
235
239
  * const array = [1, 2, 3, 4, 5];
236
240
  * const shuffledArray = shuffle(array);
237
241
  * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
242
+ *
243
+ * @group Array
238
244
  */
239
245
  declare function shuffle<T>(arr: readonly T[]): T[];
240
246
 
247
+ /**
248
+ * Function that compares two elements and returns a number indicating their relative order.
249
+ * - Negative number if a < b
250
+ * - Zero if a equals b
251
+ * - Positive number if a > b
252
+ *
253
+ * @template T The type of elements in the array
254
+ */
255
+ type SortedArrayCompareFn<T> = (a: T, b: T) => number;
256
+ /**
257
+ * A self-sorting array that maintains elements in a sorted order based on a comparison function.
258
+ * All mutating operations preserve the sorted order of elements.
259
+ *
260
+ * @template T The type of elements in the array
261
+ *
262
+ * @example
263
+ * // Create a numerically sorted array
264
+ * const arr = new SortedArray((a, b) => a - b);
265
+ * arr.push(3, 2, 1);
266
+ * console.log(arr); // [1, 2, 3]
267
+ *
268
+ * @example
269
+ * // Create a sorted array with initial values
270
+ * const names = new SortedArray((a, b) => a.localeCompare(b), ["Charlie", "Alice", "Bob"]);
271
+ * console.log(names); // ["Alice", "Bob", "Charlie"]
272
+ *
273
+ * @example
274
+ * // Create a sorted array with a custom comparator
275
+ * const people = new SortedArray(
276
+ * (a, b) => a.age - b.age || a.name.localeCompare(b.name),
277
+ * [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }]
278
+ * );
279
+ *
280
+ * @group Array
281
+ */
282
+ declare class SortedArray<T> extends Array<T> {
283
+ #private;
284
+ /**
285
+ * Creates a new SortedArray instance.
286
+ *
287
+ * @param compareFn The comparison function to determine the sort order
288
+ * @param items Optional initial items to add to the array (will be sorted immediately)
289
+ */
290
+ constructor(compareFn: SortedArrayCompareFn<T>, items?: T[]);
291
+ /**
292
+ * Inserts multiple items while maintaining sort order
293
+ * @param items The items to insert
294
+ * @returns The new length of the array
295
+ */
296
+ push(...items: T[]): number;
297
+ /**
298
+ * Override Array methods that would break the sorted order
299
+ */
300
+ unshift(...items: T[]): number;
301
+ /**
302
+ * Creates a new SortedArray with the same comparison function
303
+ * @returns A new SortedArray instance
304
+ */
305
+ slice(start?: number, end?: number): SortedArray<T>;
306
+ /**
307
+ * Concatenates arrays or values while maintaining sort order
308
+ * @param items Arrays or values to concatenate
309
+ * @returns A new SortedArray with the concatenated elements
310
+ */
311
+ concat(...items: (T | ConcatArray<T>)[]): SortedArray<T>;
312
+ }
313
+
241
314
  /**
242
315
  * Sums the values in an array of numbers, ignoring non-numeric values.
243
316
  *
@@ -1642,7 +1715,7 @@ declare const ColorParser: {
1642
1715
  * Calculate crc32 hash from string
1643
1716
  * @group Crypto
1644
1717
  */
1645
- declare function crc32(str: string, seed?: number): number;
1718
+ declare function crc32(current: Uint8Array | string, seed?: number): number;
1646
1719
 
1647
1720
  type DateObjectInput = Date | string | number | DateObject;
1648
1721
  declare function createDateObject(value: DateObjectInput): DateObject;
@@ -5160,4 +5233,4 @@ declare function wrapText(value: string, maxLength?: number): string;
5160
5233
  */
5161
5234
  declare function toError<T>(value: T, unknownMessage?: string): T extends Error ? T : Error;
5162
5235
 
5163
- export { type AnyFunction, AppError, type AppErrorOptions, type ArgumentsType, type Arrayable, AsyncIterableQueue, type Awaitable, type Base64ToBytesOptions, BrowserAssertionError, type BytesToBase64Options, CancellablePromise, type CatchErrorResult, Color, type ColorChannels, ColorParser, type Data, type DateObject, type DateObjectInput, type DebouncedFunction, type DeepPartial, type DeepReadonly, type Defer, instance as EJSON, EJSONStream, type EJSONStreamOptions, type EJSONStreamOptionsWithPayload, type EnvParser, type ExecResult, type ExecResultToSkip, type ExecResultToSuccess, type ExecSkip, type ExecSuccess, FindMean, FixedMap, FixedWeakMap, type Fn, type FormatMoney, type FormatNumber, type FunctionArgs, type GenericObject, type IfAny, type IsAny, type LiteralUnion, type Logger, LruCache, type Nothing, type OverwriteWith, type Prettify, type Primitive, type PromisifyFn, Queue, type RandomizerOptions, type RetryOnErrorConfig, type SelectOptionItem, type SelectOptions, type SimpleDefaultEventMap, SimpleEventEmitter, type SimpleEventMap, _default as TWEMOJI_REGEX, type ThemeConfig, type ThrottledFunction, TimeBucket, type TimeBucketOptions, type TimeObject, type TimeObjectInput, TimeSpan, type TimeSpanUnit, type TimeString, type TimeValue, type TimestampMsInput, type TypeOf, type TypeOfMap, type ValuesOfObject, type WithCache, type WithCacheBucketBatchOptions, type WithCacheBucketOptions, type WithCacheFixedOptions, type WithCacheLruOptions, type WithCacheOptions, type WithCachePointer, type WithCacheResult, type WithCacheStorage, type WithCustomizer, type WithCustomizerFactory, type WithCustomizerValue, type WrrItem, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, avgCircular, base64ToBytes, bigIntBytes, bigIntFromBytes, blendColors, buildCssColor, bytesToBase64, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, compareBytes, concatenateBytes, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDateObject, createDeepCloneWith, createEJSON, createEJSONStream, createEnvParser, createRandomizer, createSecureCustomizer, createTimeObject, createTimeSpan, createWithCache, cssVariable, dateInDays, dateInSeconds, debounce, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, difference, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getMostSpecificPaths, getRandomInt, getRandomTime, getWords, groupBy, has, hasOwn, hasProtocol, hex, hexToChannels, hmToSeconds, hslToChannels, humanFileSize, humanize, interpolateColor, intersection, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDateObject, isDef, isEmpty, isEqual, isError, isFunction, isInfinity, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isSkip, isString, isSuccess, isSymbol, isTimeObject, isTimeString, isTimeValue, isValidWeekDay, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, loggerSetLevel, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, secondsToHm, set, shuffle, snakeCase, sprintf, startCase, strAssign, sum, throttle, timeFromMinutes, timeStringify, timeToMinutes, timeout, timestamp, timestampMs, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, uint16ToUint8, uint32ToUint8, uint8ToUint16, uint8ToUint32, unflatten, union, uniq, uniqBy, unset, weeksInYear, weightedRoundRobin, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };
5236
+ export { type AnyFunction, AppError, type AppErrorOptions, type ArgumentsType, type Arrayable, AsyncIterableQueue, type Awaitable, type Base64ToBytesOptions, BrowserAssertionError, type BytesToBase64Options, CancellablePromise, type CatchErrorResult, Color, type ColorChannels, ColorParser, type Data, type DateObject, type DateObjectInput, type DebouncedFunction, type DeepPartial, type DeepReadonly, type Defer, instance as EJSON, EJSON as EJSONInstance, EJSONStream, type EJSONStreamOptions, type EJSONStreamOptionsWithPayload, type EJSONType, type EnvParser, type ExecResult, type ExecResultToSkip, type ExecResultToSuccess, type ExecSkip, type ExecSuccess, FindMean, FixedMap, FixedWeakMap, type Fn, type FormatMoney, type FormatNumber, type FunctionArgs, type GenericObject, type IfAny, type IsAny, type LiteralUnion, type Logger, LruCache, type Nothing, type OverwriteWith, type Prettify, type Primitive, type PromisifyFn, Queue, type RandomizerOptions, type RetryOnErrorConfig, type SelectOptionItem, type SelectOptions, type SimpleDefaultEventMap, SimpleEventEmitter, type SimpleEventMap, SortedArray, type SortedArrayCompareFn, _default as TWEMOJI_REGEX, type ThemeConfig, type ThrottledFunction, TimeBucket, type TimeBucketOptions, type TimeObject, type TimeObjectInput, TimeSpan, type TimeSpanUnit, type TimeString, type TimeValue, type TimestampMsInput, type TypeOf, type TypeOfMap, type ValuesOfObject, type WithCache, type WithCacheBucketBatchOptions, type WithCacheBucketOptions, type WithCacheFixedOptions, type WithCacheLruOptions, type WithCacheOptions, type WithCachePointer, type WithCacheResult, type WithCacheStorage, type WithCustomizer, type WithCustomizerFactory, type WithCustomizerValue, type WrrItem, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, avgCircular, base64ToBytes, bigIntBytes, bigIntFromBytes, blendColors, buildCssColor, bytesToBase64, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, compareBytes, concatenateBytes, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDateObject, createDeepCloneWith, createEJSON, createEJSONStream, createEnvParser, createRandomizer, createSecureCustomizer, createTimeObject, createTimeSpan, createWithCache, cssVariable, dateInDays, dateInSeconds, debounce, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, difference, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getMostSpecificPaths, getRandomInt, getRandomTime, getWords, groupBy, has, hasOwn, hasProtocol, hex, hexToChannels, hmToSeconds, hslToChannels, humanFileSize, humanize, interpolateColor, intersection, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDateObject, isDef, isEmpty, isEqual, isError, isFunction, isInfinity, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isSkip, isString, isSuccess, isSymbol, isTimeObject, isTimeString, isTimeValue, isValidWeekDay, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, loggerSetLevel, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, secondsToHm, set, shuffle, snakeCase, sprintf, startCase, strAssign, sum, throttle, timeFromMinutes, timeStringify, timeToMinutes, timeout, timestamp, timestampMs, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, uint16ToUint8, uint32ToUint8, uint8ToUint16, uint8ToUint32, unflatten, union, uniq, uniqBy, unset, weeksInYear, weightedRoundRobin, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };
package/dist/index.d.ts CHANGED
@@ -133,6 +133,8 @@ declare function chunkSeries(list: number[], step?: number): number[][];
133
133
  * const array3 = [1, 5];
134
134
  * const result = difference(array1, array2, array3);
135
135
  * // result will be [3] since 1, 2, 4 and 5 are in other arrays and are excluded from the result.
136
+ *
137
+ * @group Array
136
138
  */
137
139
  declare function difference<T>(...arrays: readonly T[][]): T[];
138
140
 
@@ -173,6 +175,8 @@ declare function groupBy<T, K extends PropertyKey>(array: readonly T[], keyBy: (
173
175
  * const array2 = [3, 4, 5, 6, 7];
174
176
  * const result = intersection(array1, array2);
175
177
  * // result will be [3, 4, 5] since these elements are in both arrays.
178
+ *
179
+ * @group Array
176
180
  */
177
181
  declare function intersection<T>(...arrays: readonly T[][]): T[];
178
182
 
@@ -235,9 +239,78 @@ declare function orderBy<T>(array: readonly T[], fields: (string | ((item: T) =>
235
239
  * const array = [1, 2, 3, 4, 5];
236
240
  * const shuffledArray = shuffle(array);
237
241
  * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
242
+ *
243
+ * @group Array
238
244
  */
239
245
  declare function shuffle<T>(arr: readonly T[]): T[];
240
246
 
247
+ /**
248
+ * Function that compares two elements and returns a number indicating their relative order.
249
+ * - Negative number if a < b
250
+ * - Zero if a equals b
251
+ * - Positive number if a > b
252
+ *
253
+ * @template T The type of elements in the array
254
+ */
255
+ type SortedArrayCompareFn<T> = (a: T, b: T) => number;
256
+ /**
257
+ * A self-sorting array that maintains elements in a sorted order based on a comparison function.
258
+ * All mutating operations preserve the sorted order of elements.
259
+ *
260
+ * @template T The type of elements in the array
261
+ *
262
+ * @example
263
+ * // Create a numerically sorted array
264
+ * const arr = new SortedArray((a, b) => a - b);
265
+ * arr.push(3, 2, 1);
266
+ * console.log(arr); // [1, 2, 3]
267
+ *
268
+ * @example
269
+ * // Create a sorted array with initial values
270
+ * const names = new SortedArray((a, b) => a.localeCompare(b), ["Charlie", "Alice", "Bob"]);
271
+ * console.log(names); // ["Alice", "Bob", "Charlie"]
272
+ *
273
+ * @example
274
+ * // Create a sorted array with a custom comparator
275
+ * const people = new SortedArray(
276
+ * (a, b) => a.age - b.age || a.name.localeCompare(b.name),
277
+ * [{ name: "Alice", age: 30 }, { name: "Bob", age: 25 }]
278
+ * );
279
+ *
280
+ * @group Array
281
+ */
282
+ declare class SortedArray<T> extends Array<T> {
283
+ #private;
284
+ /**
285
+ * Creates a new SortedArray instance.
286
+ *
287
+ * @param compareFn The comparison function to determine the sort order
288
+ * @param items Optional initial items to add to the array (will be sorted immediately)
289
+ */
290
+ constructor(compareFn: SortedArrayCompareFn<T>, items?: T[]);
291
+ /**
292
+ * Inserts multiple items while maintaining sort order
293
+ * @param items The items to insert
294
+ * @returns The new length of the array
295
+ */
296
+ push(...items: T[]): number;
297
+ /**
298
+ * Override Array methods that would break the sorted order
299
+ */
300
+ unshift(...items: T[]): number;
301
+ /**
302
+ * Creates a new SortedArray with the same comparison function
303
+ * @returns A new SortedArray instance
304
+ */
305
+ slice(start?: number, end?: number): SortedArray<T>;
306
+ /**
307
+ * Concatenates arrays or values while maintaining sort order
308
+ * @param items Arrays or values to concatenate
309
+ * @returns A new SortedArray with the concatenated elements
310
+ */
311
+ concat(...items: (T | ConcatArray<T>)[]): SortedArray<T>;
312
+ }
313
+
241
314
  /**
242
315
  * Sums the values in an array of numbers, ignoring non-numeric values.
243
316
  *
@@ -1642,7 +1715,7 @@ declare const ColorParser: {
1642
1715
  * Calculate crc32 hash from string
1643
1716
  * @group Crypto
1644
1717
  */
1645
- declare function crc32(str: string, seed?: number): number;
1718
+ declare function crc32(current: Uint8Array | string, seed?: number): number;
1646
1719
 
1647
1720
  type DateObjectInput = Date | string | number | DateObject;
1648
1721
  declare function createDateObject(value: DateObjectInput): DateObject;
@@ -5160,4 +5233,4 @@ declare function wrapText(value: string, maxLength?: number): string;
5160
5233
  */
5161
5234
  declare function toError<T>(value: T, unknownMessage?: string): T extends Error ? T : Error;
5162
5235
 
5163
- export { type AnyFunction, AppError, type AppErrorOptions, type ArgumentsType, type Arrayable, AsyncIterableQueue, type Awaitable, type Base64ToBytesOptions, BrowserAssertionError, type BytesToBase64Options, CancellablePromise, type CatchErrorResult, Color, type ColorChannels, ColorParser, type Data, type DateObject, type DateObjectInput, type DebouncedFunction, type DeepPartial, type DeepReadonly, type Defer, instance as EJSON, EJSONStream, type EJSONStreamOptions, type EJSONStreamOptionsWithPayload, type EnvParser, type ExecResult, type ExecResultToSkip, type ExecResultToSuccess, type ExecSkip, type ExecSuccess, FindMean, FixedMap, FixedWeakMap, type Fn, type FormatMoney, type FormatNumber, type FunctionArgs, type GenericObject, type IfAny, type IsAny, type LiteralUnion, type Logger, LruCache, type Nothing, type OverwriteWith, type Prettify, type Primitive, type PromisifyFn, Queue, type RandomizerOptions, type RetryOnErrorConfig, type SelectOptionItem, type SelectOptions, type SimpleDefaultEventMap, SimpleEventEmitter, type SimpleEventMap, _default as TWEMOJI_REGEX, type ThemeConfig, type ThrottledFunction, TimeBucket, type TimeBucketOptions, type TimeObject, type TimeObjectInput, TimeSpan, type TimeSpanUnit, type TimeString, type TimeValue, type TimestampMsInput, type TypeOf, type TypeOfMap, type ValuesOfObject, type WithCache, type WithCacheBucketBatchOptions, type WithCacheBucketOptions, type WithCacheFixedOptions, type WithCacheLruOptions, type WithCacheOptions, type WithCachePointer, type WithCacheResult, type WithCacheStorage, type WithCustomizer, type WithCustomizerFactory, type WithCustomizerValue, type WrrItem, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, avgCircular, base64ToBytes, bigIntBytes, bigIntFromBytes, blendColors, buildCssColor, bytesToBase64, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, compareBytes, concatenateBytes, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDateObject, createDeepCloneWith, createEJSON, createEJSONStream, createEnvParser, createRandomizer, createSecureCustomizer, createTimeObject, createTimeSpan, createWithCache, cssVariable, dateInDays, dateInSeconds, debounce, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, difference, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getMostSpecificPaths, getRandomInt, getRandomTime, getWords, groupBy, has, hasOwn, hasProtocol, hex, hexToChannels, hmToSeconds, hslToChannels, humanFileSize, humanize, interpolateColor, intersection, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDateObject, isDef, isEmpty, isEqual, isError, isFunction, isInfinity, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isSkip, isString, isSuccess, isSymbol, isTimeObject, isTimeString, isTimeValue, isValidWeekDay, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, loggerSetLevel, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, secondsToHm, set, shuffle, snakeCase, sprintf, startCase, strAssign, sum, throttle, timeFromMinutes, timeStringify, timeToMinutes, timeout, timestamp, timestampMs, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, uint16ToUint8, uint32ToUint8, uint8ToUint16, uint8ToUint32, unflatten, union, uniq, uniqBy, unset, weeksInYear, weightedRoundRobin, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };
5236
+ export { type AnyFunction, AppError, type AppErrorOptions, type ArgumentsType, type Arrayable, AsyncIterableQueue, type Awaitable, type Base64ToBytesOptions, BrowserAssertionError, type BytesToBase64Options, CancellablePromise, type CatchErrorResult, Color, type ColorChannels, ColorParser, type Data, type DateObject, type DateObjectInput, type DebouncedFunction, type DeepPartial, type DeepReadonly, type Defer, instance as EJSON, EJSON as EJSONInstance, EJSONStream, type EJSONStreamOptions, type EJSONStreamOptionsWithPayload, type EJSONType, type EnvParser, type ExecResult, type ExecResultToSkip, type ExecResultToSuccess, type ExecSkip, type ExecSuccess, FindMean, FixedMap, FixedWeakMap, type Fn, type FormatMoney, type FormatNumber, type FunctionArgs, type GenericObject, type IfAny, type IsAny, type LiteralUnion, type Logger, LruCache, type Nothing, type OverwriteWith, type Prettify, type Primitive, type PromisifyFn, Queue, type RandomizerOptions, type RetryOnErrorConfig, type SelectOptionItem, type SelectOptions, type SimpleDefaultEventMap, SimpleEventEmitter, type SimpleEventMap, SortedArray, type SortedArrayCompareFn, _default as TWEMOJI_REGEX, type ThemeConfig, type ThrottledFunction, TimeBucket, type TimeBucketOptions, type TimeObject, type TimeObjectInput, TimeSpan, type TimeSpanUnit, type TimeString, type TimeValue, type TimestampMsInput, type TypeOf, type TypeOfMap, type ValuesOfObject, type WithCache, type WithCacheBucketBatchOptions, type WithCacheBucketOptions, type WithCacheFixedOptions, type WithCacheLruOptions, type WithCacheOptions, type WithCachePointer, type WithCacheResult, type WithCacheStorage, type WithCustomizer, type WithCustomizerFactory, type WithCustomizerValue, type WrrItem, alpha, arrayable, assert, asyncFilter, asyncFind, asyncForEach, asyncMap, avg, avgCircular, base64ToBytes, bigIntBytes, bigIntFromBytes, blendColors, buildCssColor, bytesToBase64, cache, cacheBucket, cacheFixed, cacheLRU, camelCase, capitalize, captureStackTrace, catchError, channelsToHSL, channelsToHex, channelsToRGB, checkBitmask, chunk, chunkSeries, clamp, cleanEmpty, cleanObject, colorToChannels, compareBytes, concatenateBytes, contrastRatio, convertToUnit, crc32, createCustomizer, createCustomizerFactory, createDateObject, createDeepCloneWith, createEJSON, createEJSONStream, createEnvParser, createRandomizer, createSecureCustomizer, createTimeObject, createTimeSpan, createWithCache, cssVariable, dateInDays, dateInSeconds, debounce, deepAssign, deepClone, deepCloneWith, deepDefaults, deepFreeze, def, defer, delay, difference, dropCache, env, escapeHtml, escapeNumeric, escapeRegExp, fastIdle, fastIdlePromise, fastRaf, findMean, flagsToMap, flatten, formatMoney, formatNumber, get, getFileExtension, getFileName, getInitials, getMostSpecificPaths, getRandomInt, getRandomTime, getWords, groupBy, has, hasOwn, hasProtocol, hex, hexToChannels, hmToSeconds, hslToChannels, humanFileSize, humanize, interpolateColor, intersection, isBigInt, isBoolean, isCached, isClient, isColorChannels, isCustomizerFactory, isDate, isDateObject, isDef, isEmpty, isEqual, isError, isFunction, isInfinity, isMap, isNullOrUndefined, isNumber, isObject, isOneEmoji, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isSkip, isString, isSuccess, isSymbol, isTimeObject, isTimeString, isTimeValue, isValidWeekDay, isWeakMap, isWeakSet, isWithCache, isoToFlagEmoji, kebabCase, keyBy, logger, loggerSetLevel, lowerCase, luminance, maskingEmail, maskingPhone, maskingWords, nextTickIteration, noop, objectId, omit, omitPrefixed, orderBy, parseAllNumbers, parseAlpha, parsePercentage, percentOf, pick, pickPrefixed, qs, rafPromise, randomString, removeVS16s, retryOnError, rgbToChannels, round2digits, secondsToHm, set, shuffle, snakeCase, sprintf, startCase, strAssign, sum, throttle, timeFromMinutes, timeStringify, timeToMinutes, timeout, timestamp, timestampMs, timestampToDate, tintedTextColor, toError, toMap, truncate, typeOf, uint16ToUint8, uint32ToUint8, uint8ToUint16, uint8ToUint32, unflatten, union, uniq, uniqBy, unset, weeksInYear, weightedRoundRobin, withCache, withCacheBucket, withCacheBucketBatch, withCacheFixed, withCacheLRU, withDeepClone, withPointerCache, wrapText };