@zelgadis87/utils-core 5.2.12 → 5.3.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.
- package/.rollup/index.cjs +3448 -0
- package/.rollup/index.cjs.map +1 -0
- package/.rollup/index.d.ts +1409 -0
- package/.rollup/index.mjs +3268 -0
- package/.rollup/index.mjs.map +1 -0
- package/.rollup/tsconfig.tsbuildinfo +1 -0
- package/CHANGELOG.md +17 -0
- package/package.json +6 -8
- package/src/lazy/Cached.ts +216 -0
- package/src/lazy/Lazy.ts +4 -0
- package/src/lazy/LazyAsync.ts +4 -0
- package/src/lazy/_index.ts +1 -0
- package/src/utils/arrays/indexBy.ts +17 -17
- 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
package/dist/utils/arrays.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { type TOptional } from "../Optional.js";
|
|
2
|
-
import type { TComparisonFunction } from "../sorting/_index.js";
|
|
3
|
-
import type { TAccumulator, TBiPredicate, TPredicate, TTransformer } from "./functions.js";
|
|
4
|
-
import { type TMaybe } from "./nulls.js";
|
|
5
|
-
export * from './arrays/groupBy.js';
|
|
6
|
-
export * from './arrays/indexBy.js';
|
|
7
|
-
export * from './arrays/statistics.js';
|
|
8
|
-
export * from './arrays/uniqBy.js';
|
|
9
|
-
export type TReadableArray<T> = Array<T> | ReadonlyArray<T>;
|
|
10
|
-
export type TArrayable<T> = T | T[];
|
|
11
|
-
export type TEmptyArray = [];
|
|
12
|
-
export declare function ensureArray<const T>(t: T | Array<T> | null | undefined): Array<T>;
|
|
13
|
-
export declare function ensureReadableArray<const T>(t: T | Array<T> | ReadonlyArray<T> | null | undefined): TReadableArray<T>;
|
|
14
|
-
export declare function isArray<const T>(t: unknown): t is Array<T>;
|
|
15
|
-
/**
|
|
16
|
-
* Generate a new copy of an array with:
|
|
17
|
-
* - the first instance of an item matching the predicate being replaced with the given argument
|
|
18
|
-
* - the given argument added as last item of the array if the predicate did not produce a match
|
|
19
|
-
* @param arr - the original array of items
|
|
20
|
-
* @param item - the item to insert or update
|
|
21
|
-
* @param predicate - a function that returns true iff an item is equal to the given argument
|
|
22
|
-
* @returns a new copy of the array with the item updated or added in last place
|
|
23
|
-
*/
|
|
24
|
-
export declare function upsert<T>(arr: ReadonlyArray<T>, item: T, isEqual: TBiPredicate<T>): Array<T>;
|
|
25
|
-
export declare function range(start: number, end: number): Array<number>;
|
|
26
|
-
export declare function fill<T>(length: number, value: T): Array<T>;
|
|
27
|
-
export declare function extendArray<T extends Record<string | number | symbol, unknown>, X extends Record<string | number | symbol, unknown>>(arr: TReadableArray<T>, props: X): Array<(T & X)>;
|
|
28
|
-
export declare function extendArrayWith<T extends Record<string | number | symbol, unknown>, X extends Record<string | number | symbol, unknown>>(arr: TReadableArray<T>, propsFn: (t: T) => X): Array<(T & X)>;
|
|
29
|
-
export declare function reverse<T>(arr: TReadableArray<T>): Array<T>;
|
|
30
|
-
export declare function first<T>(arr: TReadableArray<T>, defaultValue?: TMaybe<T>): TMaybe<T>;
|
|
31
|
-
export declare function last<T>(arr: TReadableArray<T>, defaultValue?: TMaybe<T>): TMaybe<T>;
|
|
32
|
-
export declare const head: typeof first;
|
|
33
|
-
export declare function tail<T>(arr: TReadableArray<T>): T[];
|
|
34
|
-
export declare function sortedArray<T>(arr: Array<T>, sortFn?: TComparisonFunction<T> | undefined): Array<T>;
|
|
35
|
-
export declare function sortedArray<T>(arr: ReadonlyArray<T>, sortFn?: TComparisonFunction<T> | undefined): ReadonlyArray<T>;
|
|
36
|
-
/**
|
|
37
|
-
* Custom implementation of includes which allows checking for arbitrary items inside the array.
|
|
38
|
-
*/
|
|
39
|
-
export declare function includes<T>(arr: TReadableArray<T>, item: unknown, fromIndex?: number): boolean;
|
|
40
|
-
export declare function mapTruthys<T, R>(arr: Array<T>, mapper: (value: T, index: number, array: T[]) => R | undefined): Array<R>;
|
|
41
|
-
export declare function flatMapTruthys<T, R>(arr: Array<T>, mapper: (value: T, index: number, array: T[]) => R | undefined): Array<R>;
|
|
42
|
-
export declare function filterMap<T, R>(array: T[], filterFn: TPredicate<T>, mapFn: TTransformer<T, R>): R[];
|
|
43
|
-
export declare function filterMapReduce<T, U, R>(array: T[], filterFn: TPredicate<T>, mapFn: TTransformer<T, U>, reduceFn: TAccumulator<R, U>, initialValue: R): R;
|
|
44
|
-
/**
|
|
45
|
-
* Partitions the given array in two groups, in the first one there will be any and only values of the array that match the given predicate, in the second one there will be any and only values that don't.
|
|
46
|
-
* @param arr the array of items
|
|
47
|
-
* @param predicate the predicate to use to partition the array
|
|
48
|
-
* @returns a tuple, where the first array contains items matching the predicate, and the second array contains items not matching the predicate.
|
|
49
|
-
*/
|
|
50
|
-
export declare function partition<T>(arr: T[], predicate: TPredicate<T>): [T[], T[]];
|
|
51
|
-
/**
|
|
52
|
-
* Maps the first truthy value in the array using the provided mapping function.
|
|
53
|
-
* @param arr - The array of items.
|
|
54
|
-
* @param mapFn - The mapping function.
|
|
55
|
-
* @returns The first truthy value returned by the mapping function, or null if no truthy value is found.
|
|
56
|
-
*/
|
|
57
|
-
export declare function mapFirstTruthy<T, R>(arr: T[], mapFn: TTransformer<T, R>): R | null;
|
|
58
|
-
export declare function listToDict<T, K extends string, V>(arr: T[], mapFn: TTransformer<T, [K, V]>): Record<K, V>;
|
|
59
|
-
export declare function shallowArrayEquals(a: unknown[], b: unknown[]): boolean;
|
|
60
|
-
export declare function findInArray<T>(arr: T[], predicate: TPredicate<T>): TOptional<T>;
|
|
61
|
-
export declare function findIndexInArray<T>(arr: T[], predicate: TPredicate<T>): TOptional<number>;
|
|
62
|
-
export declare function zip<T, R>(ts: T[], rs: R[]): [T, R][];
|
|
63
|
-
export declare function unzip<T, R>(arr: [T, R][]): [T[], R[]];
|
|
64
|
-
/**
|
|
65
|
-
* Gets the element at the specified index in the array, wrapped in an Optional.
|
|
66
|
-
* Returns an empty Optional if the index is out of bounds (negative or >= array length).
|
|
67
|
-
* @param arr - The array to get the element from
|
|
68
|
-
* @param index - The index of the element to retrieve
|
|
69
|
-
* @returns An Optional containing the element at the index, or empty if index is out of bounds
|
|
70
|
-
*/
|
|
71
|
-
export declare function arrayGet<T>(arr: TReadableArray<T>, index: number): import("../Optional.js").TEmptyOptional<T> | import("../Optional.js").TPresentOptional<T>;
|
package/dist/utils/booleans.d.ts
DELETED
package/dist/utils/css.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type TProducer } from "./_index.ts";
|
|
2
|
-
import { type TKeysOfType } from "./records.ts";
|
|
3
|
-
export type TCssRuleDeclarationKey = TKeysOfType<CSSStyleDeclaration, string> & string;
|
|
4
|
-
export type TCssVariableDeclarationKey = `--${string}`;
|
|
5
|
-
export type TCssGenericDeclarationKey = TCssRuleDeclarationKey | TCssVariableDeclarationKey;
|
|
6
|
-
export type TCssDeclarationRulesDictionary = Partial<Record<TCssGenericDeclarationKey, string>>;
|
|
7
|
-
export type TCssSelectorDeclarationRulesDictionary = {
|
|
8
|
-
[selector: string]: TCssDeclarationRulesDictionary | TCssSelectorDeclarationRulesDictionary;
|
|
9
|
-
};
|
|
10
|
-
export declare function cssDeclarationRulesDictionaryToCss(syleDeclarationRulesForSelectorsProduceable: TProduceable<TCssSelectorDeclarationRulesDictionary>, indent?: number): string;
|
|
11
|
-
export declare function cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRules: TCssDeclarationRulesDictionary | TCssSelectorDeclarationRulesDictionary, indent?: number): string[];
|
|
12
|
-
export declare function transformCssDictionary(dict: TCssSelectorDeclarationRulesDictionary, transformer: (key: TCssGenericDeclarationKey, value: string) => string): TCssSelectorDeclarationRulesDictionary;
|
|
13
|
-
type TProduceable<T> = T | TProducer<T>;
|
|
14
|
-
export {};
|
package/dist/utils/empties.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Define a new type that is true if T is the empty object, false otherwise.
|
|
3
|
-
*/
|
|
4
|
-
export type TIsEmptyObject<T> = keyof T extends never ? true : false;
|
|
5
|
-
/**
|
|
6
|
-
* Defines a new type that is the empty array, if T is an empty object, or is the array containing T if T is not the empty object.<br/>
|
|
7
|
-
* This type can be used as function argument, to conditionally require an argument based on type T.<br/>
|
|
8
|
-
* Usage example:
|
|
9
|
-
* ```
|
|
10
|
-
* type TMetadata = { a: {}, b: {}, c: { x: 1 } };
|
|
11
|
-
* function foo<X extends keyof TMetadata>( type: X, metadata: TMetadata[X] ) { ... };
|
|
12
|
-
* export function fooWrapper<X extends keyof TMetadata>( type: X, ...args: TConditionalOptionalType<TMetadata[X]> ) {
|
|
13
|
-
* const bar = foo( type, args.length === 0 ? void 0 : args[ 0 ] );
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export type TConditionalOptionalType<T> = TIsEmptyObject<T> extends true ? [] : [T];
|
|
18
|
-
export type TEmptyObject = Record<string, never>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type TFunction, type TTransformer } from "../functions.js";
|
|
2
|
-
import type { TAsyncOperationTuple, TOperationTuple } from "../operations.js";
|
|
3
|
-
export declare function withTryCatch<R>(fn: TFunction<void, R>, errMapFn?: TTransformer<Error, Error>): TOperationTuple<R, Error>;
|
|
4
|
-
export declare function withTryCatchAsync<R>(fn: TFunction<void, Promise<R>>, errMapFn?: TTransformer<Error, Error>): TAsyncOperationTuple<R, Error>;
|
package/dist/utils/errors.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export * from './errors/withTryCatch.js';
|
|
2
|
-
export declare function asError(e: unknown): Error;
|
|
3
|
-
export declare function isError(e: unknown): e is Error;
|
|
4
|
-
export declare function getMessageFromError(error: Error): string;
|
|
5
|
-
export declare function getStackFromError(error: Error): string;
|
|
6
|
-
export declare function getCauseMessageFromError(error: Error): string;
|
|
7
|
-
export declare function getCauseStackFromError(error: Error): string;
|
|
8
|
-
/**
|
|
9
|
-
* Throws an error if a switch discriminated union type does not cover all the expected cases.
|
|
10
|
-
* Expected usage: `
|
|
11
|
-
* switch ( x.type ) {
|
|
12
|
-
* case "x": return doX();
|
|
13
|
-
* case "y": return doY();
|
|
14
|
-
* ...
|
|
15
|
-
* default: throw new NonExhaustiveSwitchError( x satisfies never );
|
|
16
|
-
* }`
|
|
17
|
-
*/
|
|
18
|
-
export declare class NonExhaustiveSwitchError extends Error {
|
|
19
|
-
constructor(value: unknown);
|
|
20
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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 constantUndefined: () => undefined;
|
|
8
|
-
export declare const alwaysTrue: () => boolean;
|
|
9
|
-
export declare const alwaysFalse: () => boolean;
|
|
10
|
-
export declare const constantZero: () => number;
|
|
11
|
-
export declare const constantOne: () => number;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TPredicate } from "../_index";
|
|
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 declare function iff<T>(firstPredicate: TBooleanOrPredicate, valueIfTrue: T): TIff<T>;
|
|
8
|
-
export default iff;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export * from './functions/_index.js';
|
|
2
|
-
export type TFunction<A, R> = (a: A) => R;
|
|
3
|
-
export type TTransformer<A, R> = TFunction<A, R>;
|
|
4
|
-
export type TVoidFunction = TFunction<void, void>;
|
|
5
|
-
export type TProducer<R> = TFunction<void, R>;
|
|
6
|
-
export type TConsumer<T> = TFunction<T, void>;
|
|
7
|
-
export type TPredicate<T> = TFunction<T, boolean>;
|
|
8
|
-
export type TTypePredicate<T, R extends T> = (t: T) => t is R;
|
|
9
|
-
export type TIdentityFunction<T> = TFunction<T, T>;
|
|
10
|
-
export type TBiFunction<A, B, R> = (a: A, b: B) => R;
|
|
11
|
-
export type TBiConsumer<A, B> = TBiFunction<A, B, void>;
|
|
12
|
-
export type TBiPredicate<T> = TBiFunction<T, T, boolean>;
|
|
13
|
-
export type TAccumulator<A, B> = TBiFunction<A, B, A>;
|
|
14
|
-
export type TAsyncFunction<A, R> = TFunction<A, Promise<R>>;
|
|
15
|
-
export type TAsyncVoidFunction = TAsyncFunction<void, void>;
|
|
16
|
-
export type TAsyncProducer<R> = TAsyncFunction<void, R>;
|
|
17
|
-
export type TAsyncConsumer<T> = TAsyncFunction<T, void>;
|
|
18
|
-
export type TAsyncPredicate<T> = TAsyncFunction<T, boolean>;
|
|
19
|
-
export type TAsyncBiFunction<A, B, R> = TBiFunction<A, B, Promise<R>>;
|
|
20
|
-
export type TAsyncBiConsumer<A, B> = TAsyncBiFunction<A, B, void>;
|
|
21
|
-
export type TAsyncBiPredicate<T> = TAsyncBiFunction<T, T, boolean>;
|
|
22
|
-
export type TAnyFunction<R> = (...args: unknown[]) => R;
|
|
23
|
-
export type TAsyncAnyFunction<R> = (...args: unknown[]) => Promise<R>;
|
|
24
|
-
export declare function isFunction(t: unknown): t is Function;
|
|
25
|
-
export declare function noop(): void;
|
|
26
|
-
export declare function filterWithTypePredicate<T, R extends T>(filter: TPredicate<T>): TTypePredicate<T, R>;
|
|
27
|
-
export declare function not<T>(predicate: TPredicate<T>): TPredicate<T>;
|
|
28
|
-
export declare function and<T>(a: TPredicate<T>, b: TPredicate<T>): TPredicate<T>;
|
|
29
|
-
export declare function or<T>(a: TPredicate<T>, b: TPredicate<T>): TPredicate<T>;
|
|
30
|
-
export declare function xor<T>(a: TPredicate<T>, b: TPredicate<T>): TPredicate<T>;
|
|
31
|
-
export declare function pipedInvoke<T, A>(op1: TFunction<T, A>): TFunction<T, A>;
|
|
32
|
-
export declare function pipedInvoke<T, A, B>(op1: TFunction<T, A>, op2: TFunction<A, B>): TFunction<T, B>;
|
|
33
|
-
export declare function pipedInvoke<T, A, B, C>(op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>): TFunction<T, C>;
|
|
34
|
-
export declare function pipedInvoke<T, A, B, C, D>(op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>): TFunction<T, D>;
|
|
35
|
-
export declare function pipedInvoke<T, A, B, C, D, E>(op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>): TFunction<T, E>;
|
|
36
|
-
export declare function pipedInvoke<T, A, B, C, D, E, F>(op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F>): TFunction<T, F>;
|
|
37
|
-
export declare function pipedInvoke<T, A, B, C, D, E, F, G>(op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F>, op7: TFunction<F, G>): TFunction<T, G>;
|
|
38
|
-
export declare function pipedInvoke<T, A, B, C, D, E, F, G, H>(op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F>, op7: TFunction<F, G>, op8: TFunction<G, H>): TFunction<T, H>;
|
|
39
|
-
export declare function pipedInvoke<T, A, B, C, D, E, F, G, H, I>(op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F>, op7: TFunction<F, G>, op8: TFunction<G, H>, op9: TFunction<H, I>): TFunction<T, I>;
|
|
40
|
-
export declare function pipedInvoke<T, A, B, C, D, E, F, G, H, I>(op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F>, op7: TFunction<F, G>, op8: TFunction<G, H>, op9: TFunction<H, I>, ...operations: TFunction<any, any>[]): TFunction<T, unknown>;
|
|
41
|
-
export declare function pipedInvokeFromArray<T, R>(fns: Array<TFunction<any, any>>): TFunction<any, any>;
|
package/dist/utils/json.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type TJsonPrimitive = string | number | boolean | null | undefined;
|
|
2
|
-
export type TJsonArray = Array<TJsonSerializable> | ReadonlyArray<TJsonSerializable>;
|
|
3
|
-
export type TJsonObject = {
|
|
4
|
-
[key: string]: TJsonSerializable;
|
|
5
|
-
};
|
|
6
|
-
export type TJsonSerializable = TJsonPrimitive | TJsonArray | TJsonObject;
|
|
7
|
-
export declare function tryToParseJson<T extends TJsonSerializable>(jsonContent: string): [T, undefined] | [undefined, Error];
|
|
8
|
-
export declare function parseJson<T extends TJsonSerializable>(jsonContent: string): T;
|
|
9
|
-
export declare function stringifyJson(jsonSerializable: TJsonSerializable, minify?: boolean): string;
|
|
10
|
-
export declare function jsonCloneDeep<A extends TJsonSerializable>(a: A): A;
|
|
11
|
-
export declare function omitFromJsonObject<T extends TJsonObject, K extends keyof T>(o: T, ...keys: K[]): Omit<T, K>;
|
package/dist/utils/nulls.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { TConsumer, TFunction, TProducer, TVoidFunction } from "./functions.js";
|
|
2
|
-
export type TMaybe<T> = T | null;
|
|
3
|
-
export declare function ensureDefined<T>(v: T, name?: string): T;
|
|
4
|
-
export declare function isDefined<T>(x: T | null | undefined): x is T;
|
|
5
|
-
export declare function isNullOrUndefined(x: unknown): x is null | undefined;
|
|
6
|
-
export declare function ifDefined<R>(source: TMaybe<R>, callback: TConsumer<R>): void;
|
|
7
|
-
export declare function mapDefined<R, S>(source: TMaybe<R>, mapper: TFunction<R, S>): TMaybe<S>;
|
|
8
|
-
export declare function ifNullOrUndefined(source: TMaybe<unknown>, callback: TVoidFunction): void;
|
|
9
|
-
export declare function throwIfNullOrUndefined(source: TMaybe<unknown>, errorProducer?: TProducer<Error>): void;
|
|
@@ -1,8 +0,0 @@
|
|
|
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;
|
package/dist/utils/numbers.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { TFunction } from "./functions.js";
|
|
2
|
-
export * from './numbers/round.js';
|
|
3
|
-
export type TNumericString = `${number}`;
|
|
4
|
-
export type TNumericFloatingPointString = `${number}.${number}`;
|
|
5
|
-
export type TPositiveNumber = number;
|
|
6
|
-
export type TNegativeNumber = number;
|
|
7
|
-
export type TZero = 0;
|
|
8
|
-
export type TDigit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
9
|
-
export type TDigit1_9 = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
10
|
-
export type TNumber0_100 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100;
|
|
11
|
-
export type TNumber0_1000 = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999;
|
|
12
|
-
export type TNumber0_5 = 0 | 1 | 2 | 3 | 4 | 5;
|
|
13
|
-
export type TNumber0_10 = TNumber0_5 | 6 | 7 | 8 | 9 | 10;
|
|
14
|
-
export type TNumber0_15 = TNumber0_10 | 11 | 12 | 13 | 14 | 15;
|
|
15
|
-
export type TNumber0_20 = TNumber0_15 | 16 | 17 | 18 | 19 | 20;
|
|
16
|
-
export type TNumber1_10 = Exclude<TNumber0_10, 0>;
|
|
17
|
-
export type TParseInt<T> = T extends `${infer N extends number}` ? N : never;
|
|
18
|
-
export type TParseableInt<T> = T extends `${number}` ? T : never;
|
|
19
|
-
export declare function ensurePositiveNumber(v: number, name?: string): number;
|
|
20
|
-
export declare function ensureNonNegativeNumber(v: number, name?: string): number;
|
|
21
|
-
export declare function ensureNonPositiveNumber(v: number, name?: string): number;
|
|
22
|
-
export declare function ensureNegativeNumber(v: number, name?: string): number;
|
|
23
|
-
export declare function incrementBy(n: number): TFunction<number, number>;
|
|
24
|
-
export declare function multiplyBy(n: number): TFunction<number, number>;
|
|
25
|
-
export declare function divideBy(n: number): TFunction<number, number>;
|
|
26
|
-
export declare const increment: TFunction<number, number>;
|
|
27
|
-
export declare const decrement: TFunction<number, number>;
|
|
28
|
-
export declare const decrementBy: (n: number) => TFunction<number, number>;
|
|
29
|
-
export declare function isNumber(v: unknown): v is number;
|
|
30
|
-
export declare function isPositiveNumber(v: number): v is TPositiveNumber;
|
|
31
|
-
export declare function isNegativeNumber(v: number): v is TNegativeNumber;
|
|
32
|
-
export declare function isZero(v: number): v is TZero;
|
|
33
|
-
export declare function clamp(n: number, min: number, max: number): number;
|
|
34
|
-
export declare function clampInt0_100(n: number): TNumber0_100;
|
|
35
|
-
export declare function tryToParseNumber(numberStr: string): import("./operations.js").TOperationTuple<number, Error>;
|
|
@@ -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;
|