@zelgadis87/utils-core 5.2.12 → 5.3.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/.rollup/index.cjs +3267 -0
- package/.rollup/index.cjs.map +1 -0
- package/.rollup/index.d.ts +1303 -0
- package/.rollup/index.mjs +3088 -0
- package/.rollup/index.mjs.map +1 -0
- package/.rollup/tsconfig.tsbuildinfo +1 -0
- package/CHANGELOG.md +10 -0
- package/package.json +6 -8
- package/src/utils/arrays.ts +3 -1
- package/dist/Logger.d.ts +0 -22
- package/dist/Optional.d.ts +0 -108
- package/dist/async/CancelableDeferred.d.ts +0 -17
- package/dist/async/Deferred.d.ts +0 -32
- package/dist/async/RateThrottler.d.ts +0 -13
- package/dist/async/Semaphore.d.ts +0 -17
- package/dist/async/_index.d.ts +0 -3
- package/dist/index.d.ts +0 -8
- package/dist/lazy/Lazy.d.ts +0 -22
- package/dist/lazy/LazyAsync.d.ts +0 -24
- package/dist/lazy/LazyDictionary.d.ts +0 -9
- package/dist/lazy/_index.d.ts +0 -3
- package/dist/sorting/ComparisonChain.d.ts +0 -57
- package/dist/sorting/Sorter.d.ts +0 -121
- package/dist/sorting/_index.d.ts +0 -2
- package/dist/sorting/types.d.ts +0 -5
- package/dist/time/RandomTimeDuration.d.ts +0 -9
- package/dist/time/TimeBase.d.ts +0 -49
- package/dist/time/TimeDuration.d.ts +0 -71
- package/dist/time/TimeFrequency.d.ts +0 -10
- package/dist/time/TimeInstant.d.ts +0 -174
- package/dist/time/TimeInstantBuilder.d.ts +0 -72
- package/dist/time/TimeRange.d.ts +0 -11
- package/dist/time/TimeUnit.d.ts +0 -15
- package/dist/time/_index.d.ts +0 -8
- package/dist/time/constants.d.ts +0 -14
- package/dist/time/types.d.ts +0 -29
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/upgrade/DataUpgrader.d.ts +0 -22
- package/dist/upgrade/_index.d.ts +0 -2
- package/dist/upgrade/errors.d.ts +0 -12
- package/dist/upgrade/getTransitionsPath.d.ts +0 -3
- package/dist/upgrade/types.d.ts +0 -31
- package/dist/utils/_index.d.ts +0 -15
- package/dist/utils/arrays/groupBy.d.ts +0 -9
- package/dist/utils/arrays/indexBy.d.ts +0 -7
- package/dist/utils/arrays/statistics.d.ts +0 -8
- package/dist/utils/arrays/uniqBy.d.ts +0 -4
- package/dist/utils/arrays.d.ts +0 -71
- package/dist/utils/booleans.d.ts +0 -2
- package/dist/utils/css.d.ts +0 -14
- package/dist/utils/empties.d.ts +0 -18
- package/dist/utils/errors/withTryCatch.d.ts +0 -4
- package/dist/utils/errors.d.ts +0 -20
- package/dist/utils/functions/_index.d.ts +0 -3
- package/dist/utils/functions/constant.d.ts +0 -11
- package/dist/utils/functions/iff.d.ts +0 -8
- package/dist/utils/functions/predicateBuilder.d.ts +0 -7
- package/dist/utils/functions.d.ts +0 -41
- package/dist/utils/json.d.ts +0 -11
- package/dist/utils/nulls.d.ts +0 -9
- package/dist/utils/numbers/round.d.ts +0 -8
- package/dist/utils/numbers.d.ts +0 -35
- package/dist/utils/operations.d.ts +0 -28
- package/dist/utils/primitives.d.ts +0 -3
- package/dist/utils/promises.d.ts +0 -10
- package/dist/utils/random.d.ts +0 -3
- package/dist/utils/records/entries.d.ts +0 -7
- package/dist/utils/records.d.ts +0 -63
- package/dist/utils/strings/StringParts.d.ts +0 -38
- package/dist/utils/strings.d.ts +0 -20
- package/esbuild/index.cjs +0 -3380
- package/esbuild/index.cjs.map +0 -7
- package/esbuild/index.mjs +0 -3177
- package/esbuild/index.mjs.map +0 -7
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type TOperation<T, E = Error> = {
|
|
2
|
-
success: false;
|
|
3
|
-
error: E;
|
|
4
|
-
} | {
|
|
5
|
-
success: true;
|
|
6
|
-
data: T;
|
|
7
|
-
};
|
|
8
|
-
export type TAsyncOperation<T, E = Error> = Promise<TOperation<T, E>>;
|
|
9
|
-
export type TOperationTuple<T, E = Error> = [T, undefined] | [undefined, E];
|
|
10
|
-
export type TAsyncOperationTuple<T, E = Error> = Promise<TOperationTuple<T, E>>;
|
|
11
|
-
export type TValidation<T, E = Error> = {
|
|
12
|
-
success: false;
|
|
13
|
-
errors: E[];
|
|
14
|
-
} | {
|
|
15
|
-
success: true;
|
|
16
|
-
data: T;
|
|
17
|
-
};
|
|
18
|
-
export type TAsyncValidation<T, E = Error> = Promise<TValidation<T, E>>;
|
|
19
|
-
export declare const Operation: {
|
|
20
|
-
ok: <const T>(data: T) => {
|
|
21
|
-
readonly success: true;
|
|
22
|
-
readonly data: T;
|
|
23
|
-
};
|
|
24
|
-
ko: <const E>(error: E) => {
|
|
25
|
-
readonly success: false;
|
|
26
|
-
readonly error: E;
|
|
27
|
-
};
|
|
28
|
-
};
|
package/dist/utils/promises.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import TimeDuration from "../time/TimeDuration.js";
|
|
2
|
-
import { TAsyncFunction, TFunction } from "./functions.js";
|
|
3
|
-
export type TPromisable<T> = T | Promise<T>;
|
|
4
|
-
export declare function asPromise<T>(promisable: TPromisable<T>): Promise<T>;
|
|
5
|
-
export declare function promiseSequence<R>(...fns: TFunction<void, Promise<R>>[]): TFunction<void, Promise<R[]>>;
|
|
6
|
-
export declare function delayPromise<T>(duration: TimeDuration): TAsyncFunction<T, T>;
|
|
7
|
-
export declare class TimeoutError extends Error {
|
|
8
|
-
}
|
|
9
|
-
export declare function awaitAtMost<T>(promise: Promise<T>, duration: TimeDuration): Promise<T>;
|
|
10
|
-
export declare const NEVER: Promise<unknown>;
|
package/dist/utils/random.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { TFunction } from "../_index";
|
|
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 entriesToEntries<K1 extends string, V1, K2 extends string, V2>(dict: Record<K1, V1>, mapper: TFunction<[K1, V1], [K2, V2]>): Record<K2, V2>;
|
|
5
|
-
/** @deprecated[2025.08.01]: Compatibility layer. */
|
|
6
|
-
export declare const mapEntries: typeof entriesToEntries;
|
|
7
|
-
export declare function entriesToList<K1 extends string, V1, R>(dict: Record<K1, V1>, mapper: TFunction<[K1, V1], R>): Array<R>;
|
package/dist/utils/records.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export * from './records/entries.js';
|
|
2
|
-
export type TEmpty = Record<string, never>;
|
|
3
|
-
export type TKeysOfType<T, V> = {
|
|
4
|
-
[K in keyof T]-?: T[K] extends V ? K : never;
|
|
5
|
-
}[keyof T];
|
|
6
|
-
export declare function dictToList<T>(obj: Record<string | number, T>): T[];
|
|
7
|
-
export declare function pick<T extends object, K extends keyof T>(o: T, keys: K[]): Pick<T, K>;
|
|
8
|
-
export type TOptionsWithoutDefaults<T, R> = Partial<T> & Required<Omit<T, keyof R>>;
|
|
9
|
-
export type TOptionalKeysForType<T> = {
|
|
10
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
|
|
11
|
-
}[keyof T];
|
|
12
|
-
export type TRequiredKeysForType<T> = Exclude<keyof T, TOptionalKeysForType<T>>;
|
|
13
|
-
export type TAllKeysOptional<T> = TRequiredKeysForType<T> extends never ? true : false;
|
|
14
|
-
export type TConditionalParameter<T> = TAllKeysOptional<T> extends true ? T | undefined : T;
|
|
15
|
-
export type TConditionalParameterOptions<T, R> = TConditionalParameter<TOptionsWithoutDefaults<T, R>>;
|
|
16
|
-
/**
|
|
17
|
-
* Given a type T, replaces all fields of type From to fields of type To.
|
|
18
|
-
*/
|
|
19
|
-
export type TReplaceType<T, From, To> = {
|
|
20
|
-
[K in keyof T]: T[K] extends From ? To : T[K];
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Given a type T, make field K required instead of optional.
|
|
24
|
-
*/
|
|
25
|
-
export type TWithRequiredProperty<T, K extends keyof T> = T & {
|
|
26
|
-
[Property in K]-?: T[Property];
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Given a type T, make all fields required instead of optional.
|
|
30
|
-
*/
|
|
31
|
-
export type TWithRequiredProperties<T> = Required<T>;
|
|
32
|
-
/**
|
|
33
|
-
* Type that forces a record to contain a few properties, but allows for extraneous properties.
|
|
34
|
-
*/
|
|
35
|
-
export type TWithExtras<R extends Record<any, any>, T extends Record<any, any> = Record<string, unknown>> = R & T;
|
|
36
|
-
/**
|
|
37
|
-
* Types that improves the human readability of a Typescript type.
|
|
38
|
-
*/
|
|
39
|
-
export type TPrettify<T> = {
|
|
40
|
-
[K in keyof T]: T[K];
|
|
41
|
-
} & {};
|
|
42
|
-
export declare function shallowRecordEquals(a: Record<string, unknown>, b: Record<string, unknown>): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* A utility type that checks if any property in a record type `T` has the `never` type.
|
|
45
|
-
* This type evaluates to `true` if at least one property in `T` is of type `never`, and `false` otherwise.
|
|
46
|
-
* It's commonly used to create compile-time assertions that prevent unintended changes where properties might accidentally become `never` due to type mismatches.
|
|
47
|
-
*
|
|
48
|
-
* @example Advanced usage for type guards
|
|
49
|
-
* ```typescript
|
|
50
|
-
* type TMap = { a: string; b: number; c: boolean };
|
|
51
|
-
* type TJsonSerializable = string | number | boolean;
|
|
52
|
-
*
|
|
53
|
-
* type TFiltered = {
|
|
54
|
-
* [K in keyof TMap]: TMap[K] extends TJsonSerializable ? TMap[K] : never;
|
|
55
|
-
* };
|
|
56
|
-
*
|
|
57
|
-
* // If TMap changes and some property becomes not serializable, TFiltered will have 'never' values
|
|
58
|
-
* const _guard: THasNever<TFiltered> = false; // Compile error if any property became 'never'
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export type THasNever<T> = {
|
|
62
|
-
[K in keyof T]: [T[K]] extends [never] ? true : false;
|
|
63
|
-
}[keyof T] extends false ? false : true;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { TReadableArray } from "../arrays.js";
|
|
2
|
-
import { TMaybe } from "../nulls.js";
|
|
3
|
-
export declare class StringParts {
|
|
4
|
-
private readonly _parts;
|
|
5
|
-
private constructor();
|
|
6
|
-
toUpperCase(): StringParts;
|
|
7
|
-
toLowerCase(): StringParts;
|
|
8
|
-
capitalizeFirst(): StringParts;
|
|
9
|
-
capitalizeEach(): StringParts;
|
|
10
|
-
get parts(): string[];
|
|
11
|
-
get tail(): string[];
|
|
12
|
-
get first(): TMaybe<string>;
|
|
13
|
-
get last(): TMaybe<string>;
|
|
14
|
-
get length(): number;
|
|
15
|
-
trim(): StringParts;
|
|
16
|
-
toSnakeCase(): string;
|
|
17
|
-
toCamelCase(): string;
|
|
18
|
-
toKebabCase(): string;
|
|
19
|
-
toPascalCase(): string;
|
|
20
|
-
toHumanCase(): string;
|
|
21
|
-
join(separator: string): string;
|
|
22
|
-
mergeWith({ parts: otherParts }: {
|
|
23
|
-
parts: TReadableArray<string>;
|
|
24
|
-
}): StringParts;
|
|
25
|
-
slice(start: number, end?: number): StringParts;
|
|
26
|
-
splice(start: number, deleteCount: number, ...items: string[]): StringParts;
|
|
27
|
-
push(part: string): StringParts;
|
|
28
|
-
shift(part: string): StringParts;
|
|
29
|
-
reverse(): StringParts;
|
|
30
|
-
static fromString: (s: string, separator?: string | RegExp) => StringParts;
|
|
31
|
-
static fromParts: (...parts: string[]) => StringParts;
|
|
32
|
-
/**
|
|
33
|
-
* Tries to convert a word in PascalCase to an array of words. Will not work if there are spaces or special characters. Does not cope well on uppercase abbreviations (eg, "CSS").
|
|
34
|
-
* @param s a string in PascalCase.
|
|
35
|
-
* @returns a StringParts where each sub-word in PascalCase is now a part.
|
|
36
|
-
*/
|
|
37
|
-
static tryToParsePascalCaseWord(s: string): StringParts;
|
|
38
|
-
}
|
package/dist/utils/strings.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TMaybe } from "./nulls.js";
|
|
2
|
-
export * from './strings/StringParts.js';
|
|
3
|
-
export type THtmlString = string;
|
|
4
|
-
export type TUrl = string;
|
|
5
|
-
export type TRelativeUrl = string;
|
|
6
|
-
export declare function hashCode(str: string): number;
|
|
7
|
-
export declare function repeat(char: string, times: number): string;
|
|
8
|
-
export declare function capitalizeWord(word: string): string;
|
|
9
|
-
export declare function splitWords(text: string, regEx?: RegExp): string[];
|
|
10
|
-
export declare function stringToNumber(s: string | null | undefined): number | null;
|
|
11
|
-
export declare function pad(str: string, n: number, char: string, where?: 'left' | 'right'): string;
|
|
12
|
-
export declare function padLeft(str: string, n: number, char: string): string;
|
|
13
|
-
export declare function padRight(str: string, n: number, char: string): string;
|
|
14
|
-
export declare function ellipsis(str: string, maxLength: number): string;
|
|
15
|
-
export declare function pluralize(n: number, singular: string, plural?: string): string;
|
|
16
|
-
export declare function isString(source: unknown): source is string;
|
|
17
|
-
export declare function isEmpty(source: string): boolean;
|
|
18
|
-
export declare function isNullOrUndefinedOrEmpty(source: TMaybe<string>): boolean;
|
|
19
|
-
export declare function wrapWithString(str: string, delimiter: string): string;
|
|
20
|
-
export declare function wrapWithString(str: string, start: string, end: string): string;
|