@zelgadis87/utils-core 4.0.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/Lazy.d.ts +21 -0
- package/dist/LazyAsync.d.ts +23 -0
- package/dist/Logger.d.ts +21 -0
- package/dist/Optional.d.ts +70 -0
- package/dist/async/CancelableDeferred.d.ts +17 -0
- package/dist/async/Deferred.d.ts +27 -0
- package/dist/async/RateThrottler.d.ts +12 -0
- package/dist/async/Semaphore.d.ts +10 -0
- package/dist/async/index.d.ts +4 -0
- package/dist/index.d.ts +11 -0
- package/dist/random/index.d.ts +2 -0
- package/dist/random/randomInterval.d.ts +1 -0
- package/dist/random/randomPercentage.d.ts +1 -0
- package/dist/sorting/ComparisonChain.d.ts +57 -0
- package/dist/sorting/Sorter.d.ts +100 -0
- package/dist/sorting/index.d.ts +4 -0
- package/dist/sorting/types.d.ts +5 -0
- package/dist/time/RandomTimeDuration.d.ts +9 -0
- package/dist/time/TimeBase.d.ts +38 -0
- package/dist/time/TimeDuration.d.ts +81 -0
- package/dist/time/TimeFrequency.d.ts +10 -0
- package/dist/time/TimeInstant.d.ts +137 -0
- package/dist/time/TimeInstantBuilder.d.ts +77 -0
- package/dist/time/TimeUnit.d.ts +17 -0
- package/dist/time/index.d.ts +6 -0
- package/dist/time/types.d.ts +26 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/arrays.d.ts +33 -0
- package/dist/types/booleans.d.ts +2 -0
- package/dist/types/functions.d.ts +20 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/json.d.ts +6 -0
- package/dist/types/nulls.d.ts +8 -0
- package/dist/types/numbers.d.ts +31 -0
- package/dist/types/promises.d.ts +6 -0
- package/dist/types/records.d.ts +14 -0
- package/dist/types/strings.d.ts +40 -0
- package/dist/upgrade/DataUpgrader.d.ts +22 -0
- package/dist/upgrade/errors.d.ts +12 -0
- package/dist/upgrade/getTransitionsPath.d.ts +3 -0
- package/dist/upgrade/index.d.ts +2 -0
- package/dist/upgrade/types.d.ts +31 -0
- package/dist/utils/asError.d.ts +1 -0
- package/dist/utils/bindThis.d.ts +1 -0
- package/dist/utils/constant.d.ts +8 -0
- package/dist/utils/entries.d.ts +4 -0
- package/dist/utils/groupBy.d.ts +7 -0
- package/dist/utils/iff.d.ts +8 -0
- package/dist/utils/index.d.ts +22 -0
- package/dist/utils/indexBy.d.ts +7 -0
- package/dist/utils/jsonCloneDeep.d.ts +2 -0
- package/dist/utils/math.d.ts +9 -0
- package/dist/utils/noop.d.ts +1 -0
- package/dist/utils/omit.d.ts +2 -0
- package/dist/utils/pad.d.ts +3 -0
- package/dist/utils/pluralize.d.ts +1 -0
- package/dist/utils/round.d.ts +8 -0
- package/dist/utils/sortBy.d.ts +7 -0
- package/dist/utils/throttle.d.ts +3 -0
- package/dist/utils/uniq.d.ts +1 -0
- package/dist/utils/uniqBy.d.ts +2 -0
- package/dist/utils/uniqByKey.d.ts +1 -0
- package/dist/utils/upsert.d.ts +0 -0
- package/dist/utils/withTryCatch.d.ts +2 -0
- package/dist/utils/withTryCatchAsync.d.ts +2 -0
- package/dist/utils/wrap.d.ts +1 -0
- package/esbuild/index.cjs +2670 -0
- package/esbuild/index.mjs +2518 -0
- package/package.json +159 -0
- package/src/Lazy.ts +77 -0
- package/src/LazyAsync.ts +100 -0
- package/src/Logger.ts +44 -0
- package/src/Optional.ts +172 -0
- package/src/async/CancelableDeferred.ts +36 -0
- package/src/async/Deferred.ts +84 -0
- package/src/async/RateThrottler.ts +46 -0
- package/src/async/Semaphore.ts +45 -0
- package/src/async/index.ts +6 -0
- package/src/index.ts +13 -0
- package/src/random/index.ts +3 -0
- package/src/random/randomInterval.ts +4 -0
- package/src/random/randomPercentage.ts +6 -0
- package/src/sorting/ComparisonChain.ts +209 -0
- package/src/sorting/Sorter.ts +357 -0
- package/src/sorting/index.ts +5 -0
- package/src/sorting/types.ts +7 -0
- package/src/time/RandomTimeDuration.ts +21 -0
- package/src/time/TimeBase.ts +113 -0
- package/src/time/TimeDuration.ts +296 -0
- package/src/time/TimeFrequency.ts +28 -0
- package/src/time/TimeInstant.ts +488 -0
- package/src/time/TimeInstantBuilder.ts +126 -0
- package/src/time/TimeUnit.ts +43 -0
- package/src/time/index.ts +8 -0
- package/src/time/types.ts +56 -0
- package/src/types/arrays.ts +89 -0
- package/src/types/booleans.ts +8 -0
- package/src/types/functions.ts +27 -0
- package/src/types/index.ts +18 -0
- package/src/types/json.ts +5 -0
- package/src/types/nulls.ts +33 -0
- package/src/types/numbers.ts +80 -0
- package/src/types/promises.ts +23 -0
- package/src/types/records.ts +21 -0
- package/src/types/strings.ts +143 -0
- package/src/upgrade/DataUpgrader.ts +100 -0
- package/src/upgrade/errors.ts +25 -0
- package/src/upgrade/getTransitionsPath.ts +89 -0
- package/src/upgrade/index.ts +4 -0
- package/src/upgrade/types.ts +36 -0
- package/src/utils/asError.ts +12 -0
- package/src/utils/bindThis.ts +4 -0
- package/src/utils/constant.ts +9 -0
- package/src/utils/entries.ts +13 -0
- package/src/utils/groupBy.ts +39 -0
- package/src/utils/iff.ts +26 -0
- package/src/utils/index.ts +24 -0
- package/src/utils/indexBy.ts +36 -0
- package/src/utils/jsonCloneDeep.ts +31 -0
- package/src/utils/math.ts +44 -0
- package/src/utils/noop.ts +2 -0
- package/src/utils/omit.ts +8 -0
- package/src/utils/pad.ts +20 -0
- package/src/utils/pluralize.ts +20 -0
- package/src/utils/round.ts +24 -0
- package/src/utils/sortBy.ts +27 -0
- package/src/utils/throttle.ts +10 -0
- package/src/utils/uniq.ts +6 -0
- package/src/utils/uniqBy.ts +15 -0
- package/src/utils/uniqByKey.ts +5 -0
- package/src/utils/upsert.ts +2 -0
- package/src/utils/withTryCatch.ts +10 -0
- package/src/utils/withTryCatchAsync.ts +6 -0
- package/src/utils/wrap.ts +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function asError(e: unknown): Error;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function bindThis<F extends Function>(this: void, fn: F, _this: object): F;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function constant<T>(v: T): () => T;
|
|
2
|
+
export declare function identity<T>(t: T): T;
|
|
3
|
+
export default constant;
|
|
4
|
+
export declare const constantNull: () => null;
|
|
5
|
+
export declare const constantTrue: () => boolean;
|
|
6
|
+
export declare const constantFalse: () => boolean;
|
|
7
|
+
export declare const constantZero: () => number;
|
|
8
|
+
export declare const constantOne: () => number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TFunction } from "../types";
|
|
2
|
+
export declare function dictToEntries<V, K extends string = string>(obj: Record<K, V>): [K, V][];
|
|
3
|
+
export declare function entriesToDict<V, K extends string = string>(entries: [K, V][]): Record<K, V>;
|
|
4
|
+
export declare function mapEntries<K1 extends string, V1, K2 extends string, V2>(dict: Record<K1, V1>, mapper: TFunction<[K1, V1], [K2, V2]>): Record<K2, V2>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TFunction, TKeysOfType } from "../types";
|
|
2
|
+
export declare function groupByString<V, K extends TKeysOfType<V, string>>(arr: V[], field: K): Record<V[K] & string, V[]>;
|
|
3
|
+
export declare function groupByNumber<V, K extends TKeysOfType<V, number>>(arr: V[], field: K): Record<V[K] & number, V[]>;
|
|
4
|
+
export declare function groupBySymbol<V, K extends TKeysOfType<V, symbol>>(arr: V[], field: K): Record<V[K] & symbol, V[]>;
|
|
5
|
+
export declare function groupByStringWith<V, K extends string>(arr: V[], getter: TFunction<V, K>): Record<K, V[]>;
|
|
6
|
+
export declare function groupByNumberWith<V, K extends number>(arr: V[], getter: TFunction<V, K>): Record<K, V[]>;
|
|
7
|
+
export declare function groupBySymbolWith<V, K extends symbol>(arr: V[], getter: TFunction<V, K>): Record<K, V[]>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TPredicate } from "../types";
|
|
2
|
+
type TBooleanOrPredicate = boolean | TPredicate<void>;
|
|
3
|
+
type TIff<T> = {
|
|
4
|
+
elseIf<R>(pred: TBooleanOrPredicate, valueIfTrue: R): TIff<T | R>;
|
|
5
|
+
otherwise<R>(valueIfElse: R): T | R;
|
|
6
|
+
};
|
|
7
|
+
export default function iff<T>(firstPredicate: TBooleanOrPredicate, valueIfTrue: T): TIff<T>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { default as asError } from './asError';
|
|
2
|
+
export { default as bindThis } from './bindThis';
|
|
3
|
+
export * from './constant.js';
|
|
4
|
+
export * from './entries.js';
|
|
5
|
+
export * from './groupBy.js';
|
|
6
|
+
export { default as iff } from './iff';
|
|
7
|
+
export * from './indexBy.js';
|
|
8
|
+
export { default as jsonCloneDeep } from './jsonCloneDeep';
|
|
9
|
+
export * from './math.js';
|
|
10
|
+
export { default as noop } from './noop';
|
|
11
|
+
export { default as omit } from './omit';
|
|
12
|
+
export { default as pad } from './pad';
|
|
13
|
+
export { default as pluralize } from './pluralize';
|
|
14
|
+
export * from './round.js';
|
|
15
|
+
export { default as sortBy } from './sortBy';
|
|
16
|
+
export { default as throttle } from './throttle';
|
|
17
|
+
export { default as uniq } from './uniq';
|
|
18
|
+
export { default as uniqBy } from './uniqBy';
|
|
19
|
+
export { default as uniqByKey } from './uniqByKey';
|
|
20
|
+
export { default as withTryCatch } from './withTryCatch';
|
|
21
|
+
export { default as withTryCatchAsync } from './withTryCatchAsync';
|
|
22
|
+
export { default as wrap } from './wrap';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TFunction, TKeysOfType } from "../types";
|
|
2
|
+
export declare function indexByString<V, K extends TKeysOfType<V, string>>(arr: V[], field: K): Record<V[K] & string, V>;
|
|
3
|
+
export declare function indexByNumber<V, K extends TKeysOfType<V, number>>(arr: V[], field: K): Record<V[K] & number, V>;
|
|
4
|
+
export declare function indexBySymbol<V, K extends TKeysOfType<V, symbol>>(arr: V[], field: K): Record<V[K] & symbol, V>;
|
|
5
|
+
export declare function indexByStringWith<V>(arr: V[], getter: TFunction<V, string>): Record<string, V>;
|
|
6
|
+
export declare function indexByNumberWith<V>(arr: V[], getter: TFunction<V, number>): Record<number, V>;
|
|
7
|
+
export declare function indexBySymbolWith<V>(arr: V[], getter: TFunction<V, symbol>): Record<symbol, V>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TReadableArray } from "../types/arrays.js";
|
|
2
|
+
export declare function clamp(n: number, min: number, max: number): number;
|
|
3
|
+
export declare function average(arr: TReadableArray<number>): number;
|
|
4
|
+
export declare function sum(arr: TReadableArray<number>): number;
|
|
5
|
+
export declare function sumBy<T>(arr: TReadableArray<T>, getter: (t: T) => number): number;
|
|
6
|
+
export declare function min(arr: TReadableArray<number>): number;
|
|
7
|
+
export declare function minBy<T>(arr: TReadableArray<T>, getter: (t: T) => number): number;
|
|
8
|
+
export declare function max(arr: TReadableArray<number>): number;
|
|
9
|
+
export declare function maxBy<T>(arr: TReadableArray<T>, getter: (t: T) => number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function noop(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function pluralize(n: number, singular: string, plural?: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type TRoundMode = 'toNearest' | 'toLower' | 'toUpper' | 'towardsZero' | 'awayFromZero';
|
|
2
|
+
export declare function round(n: number, precision?: number, mode?: TRoundMode): number;
|
|
3
|
+
export default round;
|
|
4
|
+
export declare const roundToNearest: (n: number, precision?: number) => number;
|
|
5
|
+
export declare const roundToLower: (n: number, precision?: number) => number;
|
|
6
|
+
export declare const roundToUpper: (n: number, precision?: number) => number;
|
|
7
|
+
export declare const roundTowardsZero: (n: number, precision?: number) => number;
|
|
8
|
+
export declare const roundAwayFromZero: (n: number, precision?: number) => number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TFunction, TKeysOfType } from "../types";
|
|
2
|
+
type TKeyOrGetter<T> = T extends Record<string, unknown> ? TKeysOfType<T, number> & keyof T | TFunction<T, number | null> : TFunction<T, number | null>;
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated[2023-11-01]: Use {@link Sorter} instead.
|
|
5
|
+
*/
|
|
6
|
+
export default function sortBy<T>(keyOrGetter: TKeyOrGetter<T>, direction?: 'ASC' | 'DESC', nulls?: 'FIRST' | 'LAST'): (a: T, b: T) => number;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function uniq<T>(arr: T[]): T[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function uniqByKey<T, K extends keyof T>(arr: T[], key: K): T[];
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function wrap(str: string, delimiter: string): string;
|