@augment-vir/common 4.6.0 → 5.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/{augments → cjs/augments}/ansi.d.ts +0 -0
- package/dist/{augments → cjs/augments}/ansi.js +0 -0
- package/dist/{augments → cjs/augments}/array.d.ts +1 -8
- package/dist/cjs/augments/array.js +25 -0
- package/dist/cjs/augments/async.d.ts +14 -0
- package/dist/cjs/augments/async.js +29 -0
- package/dist/{augments/number.d.ts → cjs/augments/common-number.d.ts} +8 -3
- package/dist/{augments/number.js → cjs/augments/common-number.js} +39 -11
- package/dist/{augments/string.d.ts → cjs/augments/common-string.d.ts} +14 -4
- package/dist/{augments/string.js → cjs/augments/common-string.js} +30 -27
- package/dist/{augments → cjs/augments}/date.d.ts +1 -1
- package/dist/{augments → cjs/augments}/date.js +2 -2
- package/dist/cjs/augments/environment.d.ts +1 -0
- package/dist/cjs/augments/environment.js +7 -0
- package/dist/{augments → cjs/augments}/error.d.ts +0 -0
- package/dist/{augments → cjs/augments}/error.js +0 -0
- package/dist/{augments → cjs/augments}/function.d.ts +0 -0
- package/dist/{augments → cjs/augments}/function.js +0 -0
- package/dist/{augments → cjs/augments}/object.d.ts +0 -0
- package/dist/{augments → cjs/augments}/object.js +0 -0
- package/dist/{augments → cjs/augments}/promise.d.ts +0 -0
- package/dist/{augments → cjs/augments}/promise.js +0 -0
- package/dist/{augments → cjs/augments}/regexp.d.ts +0 -0
- package/dist/{augments → cjs/augments}/regexp.js +0 -0
- package/dist/{augments → cjs/augments}/tuple.d.ts +0 -0
- package/dist/{augments → cjs/augments}/tuple.js +0 -0
- package/dist/{augments → cjs/augments}/type-of.d.ts +0 -0
- package/dist/{augments → cjs/augments}/type-of.js +2 -0
- package/dist/{augments → cjs/augments}/type.d.ts +0 -0
- package/dist/{augments → cjs/augments}/type.js +0 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +4 -3
- package/dist/{index.js → cjs/index.js} +4 -3
- package/dist/esm/augments/ansi.d.ts +1 -0
- package/dist/esm/augments/ansi.js +24 -0
- package/dist/esm/augments/array.d.ts +13 -0
- package/dist/esm/augments/array.js +17 -0
- package/dist/esm/augments/async.d.ts +14 -0
- package/dist/esm/augments/async.js +23 -0
- package/dist/esm/augments/common-number.d.ts +32 -0
- package/dist/esm/augments/common-number.js +105 -0
- package/dist/esm/augments/common-string.d.ts +44 -0
- package/dist/esm/augments/common-string.js +180 -0
- package/dist/esm/augments/date.d.ts +26 -0
- package/dist/esm/augments/date.js +74 -0
- package/dist/esm/augments/environment.d.ts +1 -0
- package/dist/esm/augments/environment.js +3 -0
- package/dist/esm/augments/error.d.ts +8 -0
- package/dist/esm/augments/error.js +36 -0
- package/dist/esm/augments/function.d.ts +1 -0
- package/dist/esm/augments/function.js +3 -0
- package/dist/esm/augments/object.d.ts +63 -0
- package/dist/esm/augments/object.js +252 -0
- package/dist/esm/augments/promise.d.ts +23 -0
- package/dist/esm/augments/promise.js +84 -0
- package/dist/esm/augments/regexp.d.ts +3 -0
- package/dist/esm/augments/regexp.js +14 -0
- package/dist/esm/augments/tuple.d.ts +8 -0
- package/dist/esm/augments/tuple.js +3 -0
- package/dist/esm/augments/type-of.d.ts +17 -0
- package/dist/esm/augments/type-of.js +12 -0
- package/dist/esm/augments/type.d.ts +54 -0
- package/dist/esm/augments/type.js +24 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +15 -0
- package/dist/types/augments/ansi.d.ts +1 -0
- package/dist/types/augments/array.d.ts +13 -0
- package/dist/types/augments/async.d.ts +14 -0
- package/dist/types/augments/common-number.d.ts +32 -0
- package/dist/types/augments/common-string.d.ts +44 -0
- package/dist/types/augments/date.d.ts +26 -0
- package/dist/types/augments/environment.d.ts +1 -0
- package/dist/types/augments/error.d.ts +8 -0
- package/dist/types/augments/function.d.ts +1 -0
- package/dist/types/augments/object.d.ts +63 -0
- package/dist/types/augments/promise.d.ts +23 -0
- package/dist/types/augments/regexp.d.ts +3 -0
- package/dist/types/augments/tuple.d.ts +8 -0
- package/dist/types/augments/type-of.d.ts +17 -0
- package/dist/types/augments/type.d.ts +54 -0
- package/dist/types/index.d.ts +15 -0
- package/package.json +6 -6
- package/dist/augments/array.js +0 -44
- package/dist/augments/type-test.d.ts +0 -3
- package/dist/augments/type-test.js +0 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const englishFullMonthNames: readonly ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"];
|
|
2
|
+
export declare const englishShortMonthNames: string[];
|
|
3
|
+
export declare class InvalidDateError extends Error {
|
|
4
|
+
readonly name = "InvalidDateError";
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @param slashFormatString String that should be of format "MM/DD/YY", "MM/DD/YYYY". When the year
|
|
8
|
+
* portion only contains 2 numbers ("MM/DD/YY") the century must be provided in the form of the
|
|
9
|
+
* yearPrefix input.
|
|
10
|
+
* @param yearPrefix String or number that is used to prefix slash format strings that only contain
|
|
11
|
+
* 2 digits ("MM/DD/YY"). If the year is entirely missing form the given slash format string, the
|
|
12
|
+
* year will default to year 00 of the given century. See test file for examples.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createDateFromSlashFormat(slashFormatString: string, yearPrefix?: number | string): Date;
|
|
15
|
+
/**
|
|
16
|
+
* @param commaFormatString Should be at string of the form "monthName dayNumber, fullYear" Example:
|
|
17
|
+
* "May 19, 2005"
|
|
18
|
+
* @param ignoreInvalidMonth Set to true to ignore invalid months and just use the current UTC month
|
|
19
|
+
*/
|
|
20
|
+
export declare function createDateFromNamedCommaFormat(commaFormatString: string, ignoreInvalidMonth?: boolean): Date;
|
|
21
|
+
/**
|
|
22
|
+
* Converts an iso-formatted string to a UTC date object. The time is nulled out to all zeros.
|
|
23
|
+
*
|
|
24
|
+
* @param isoFormatString Should be a date in the format YYYY-MM-DD.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createDateFromUtcIsoFormat(isoFormatString: string): Date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isBrowser(): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AtLeastTuple } from './tuple';
|
|
2
|
+
export declare function combineErrors(errors: AtLeastTuple<Error, 1>): Error;
|
|
3
|
+
export declare function combineErrors(errors: ReadonlyArray<never>): undefined;
|
|
4
|
+
export declare function combineErrors(errors: ReadonlyArray<Error>): Error | undefined;
|
|
5
|
+
export declare function combineErrors(errors?: undefined): undefined;
|
|
6
|
+
export declare function combineErrorMessages(errors?: ReadonlyArray<Error | string | undefined> | undefined): string;
|
|
7
|
+
export declare function extractErrorMessage(error: unknown): string;
|
|
8
|
+
export declare function ensureError(input: unknown): Error;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isTruthy<T>(input: T): input is NonNullable<T>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AtLeastOneEntryArray } from './array';
|
|
2
|
+
import { NoInfer, RequiredBy, UnPromise } from './type';
|
|
3
|
+
export declare function getEnumTypedKeys<T extends object>(input: T): (keyof T)[];
|
|
4
|
+
export declare function getEnumTypedValues<T extends object>(input: T): T[keyof T][];
|
|
5
|
+
export declare function isEnumValue<T extends object>(input: unknown, checkEnum: T): input is T[keyof T];
|
|
6
|
+
export declare function isKeyof<ObjectGeneric>(key: PropertyKey, object: ObjectGeneric): key is keyof object;
|
|
7
|
+
export declare function filterToEnumValues<T extends object>(inputs: ReadonlyArray<unknown>, checkEnum: T, caseInsensitive?: boolean): T[keyof T][];
|
|
8
|
+
export declare function getObjectTypedKeys<ObjectGeneric extends unknown>(input: ObjectGeneric): ReadonlyArray<keyof ObjectGeneric>;
|
|
9
|
+
export declare function getObjectTypedValues<ObjectGeneric extends unknown>(input: ObjectGeneric): ObjectGeneric[keyof ObjectGeneric][];
|
|
10
|
+
declare type ExtractValue<KeyGeneric extends PropertyKey, ParentGeneric> = KeyGeneric extends keyof ParentGeneric ? RequiredBy<ParentGeneric, KeyGeneric>[KeyGeneric] : KeyGeneric extends keyof Extract<ParentGeneric, Record<KeyGeneric, any>> ? RequiredBy<Extract<ParentGeneric, Record<KeyGeneric, any>>, KeyGeneric>[KeyGeneric] : never;
|
|
11
|
+
declare type CombinedParentValue<KeyGeneric extends PropertyKey, ParentGeneric> = ExtractValue<KeyGeneric, ParentGeneric> extends never ? unknown : ExtractValue<KeyGeneric, ParentGeneric>;
|
|
12
|
+
declare type CombineTypeWithKey<KeyGeneric extends PropertyKey, ParentGeneric> = ParentGeneric & Record<KeyGeneric, CombinedParentValue<KeyGeneric, ParentGeneric>>;
|
|
13
|
+
export declare function typedHasProperty<KeyGeneric extends PropertyKey, ParentGeneric>(inputObject: ParentGeneric, inputKey: KeyGeneric): inputObject is CombineTypeWithKey<KeyGeneric, ParentGeneric>;
|
|
14
|
+
export declare function typedHasProperties<KeyGeneric extends PropertyKey, ParentGeneric>(inputObject: ParentGeneric, inputKeys: ReadonlyArray<KeyGeneric>): inputObject is CombineTypeWithKey<KeyGeneric, ParentGeneric>;
|
|
15
|
+
export declare function isObject(input: any): input is NonNullable<object>;
|
|
16
|
+
export declare function getEntriesSortedByKey(input: object): [string, unknown][];
|
|
17
|
+
export declare function areJsonEqual(a: object, b: object): boolean;
|
|
18
|
+
export declare type InnerMappedValues<EntireInputGeneric extends object, MappedValueGeneric> = {
|
|
19
|
+
[MappedProp in keyof EntireInputGeneric]: MappedValueGeneric;
|
|
20
|
+
};
|
|
21
|
+
export declare type MappedValues<EntireInputGeneric extends object, MappedValueGeneric> = MappedValueGeneric extends PromiseLike<unknown> ? Promise<InnerMappedValues<EntireInputGeneric, UnPromise<MappedValueGeneric>>> : InnerMappedValues<EntireInputGeneric, UnPromise<MappedValueGeneric>>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new object with the same properties as the input object, but with values set to the
|
|
24
|
+
* result of mapCallback for each property.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mapObjectValues<EntireInputGeneric extends object, MappedValueGeneric>(inputObject: EntireInputGeneric, mapCallback: (inputKey: keyof EntireInputGeneric, keyValue: EntireInputGeneric[typeof inputKey], fullObject: EntireInputGeneric) => MappedValueGeneric): MappedValues<EntireInputGeneric, MappedValueGeneric>;
|
|
27
|
+
export declare function filterObject<ObjectGeneric extends object>(inputObject: ObjectGeneric, callback: (key: keyof ObjectGeneric, value: ObjectValueType<ObjectGeneric>, fullObject: ObjectGeneric) => boolean): Partial<ObjectGeneric>;
|
|
28
|
+
/** The input here must be serializable otherwise JSON parsing errors will be thrown */
|
|
29
|
+
export declare function copyThroughJson<T>(input: T): T;
|
|
30
|
+
export declare type ObjectValueType<T extends object> = T[keyof T];
|
|
31
|
+
/**
|
|
32
|
+
* Checks that the first input, testThisOne, matches the object shape of the second input,
|
|
33
|
+
* compareToThisOne. Does not compare exact values of properties, only types.
|
|
34
|
+
*
|
|
35
|
+
* To allow the test input, the first input, to have additional keys that the compare input, the
|
|
36
|
+
* second input, does not have, pass in a third argument set to true.
|
|
37
|
+
*
|
|
38
|
+
* This function REQUIRES a generic to be assigned to it: it cannot infer it from the inputs.
|
|
39
|
+
*
|
|
40
|
+
* The compare input, the second input, is required to have at least one entry in every array value
|
|
41
|
+
* that exists. If more array values are present, they will be considered other possible types for
|
|
42
|
+
* entries in that array.
|
|
43
|
+
*/
|
|
44
|
+
export declare function matchesObjectShape<MatchThisGeneric extends object>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean, shouldLogWhy?: boolean): testThisOne is MatchThisGeneric;
|
|
45
|
+
export declare type ObjectWithAtLeastSingleEntryArrays<BaseObject extends object> = {
|
|
46
|
+
[Prop in keyof BaseObject]: BaseObject[Prop] extends ReadonlyArray<any> ? AtLeastOneEntryArray<BaseObject[Prop]> : BaseObject[Prop] extends object ? ObjectWithAtLeastSingleEntryArrays<BaseObject[Prop]> : BaseObject[Prop];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Asserts that the first input, testThisOne, matches the object shape of the second input,
|
|
50
|
+
* compareToThisOne. Does not compare exact values of properties, only types.
|
|
51
|
+
*
|
|
52
|
+
* To allow the test input, the first input, to have additional keys that the compare input, the
|
|
53
|
+
* second input, does not have, pass in a third argument set to true.
|
|
54
|
+
*
|
|
55
|
+
* This function REQUIRES a generic to be assigned to it: it cannot infer it from the inputs.
|
|
56
|
+
*
|
|
57
|
+
* The compare input, the second input, is required to have at least one entry in every array value
|
|
58
|
+
* that exists. If more array values are present, they will be considered other possible types for
|
|
59
|
+
* entries in that array.
|
|
60
|
+
*/
|
|
61
|
+
export declare function assertMatchesObjectShape<MatchThisGeneric extends object = never>(testThisOne: unknown, compareToThisOne: NoInfer<ObjectWithAtLeastSingleEntryArrays<MatchThisGeneric>>, allowExtraProps?: boolean): asserts testThisOne is MatchThisGeneric;
|
|
62
|
+
export declare function typedObjectFromEntries<KeyType extends PropertyKey, ValueType>(entries: ReadonlyArray<Readonly<[KeyType, ValueType]>>): Record<KeyType, ValueType>;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function wait(delayMs: number): Promise<void>;
|
|
2
|
+
export declare function isPromiseLike<T>(input: T | unknown): input is T extends PromiseLike<infer ValueType> ? PromiseLike<ValueType> : PromiseLike<unknown>;
|
|
3
|
+
export declare class PromiseTimeoutError extends Error {
|
|
4
|
+
readonly durationMs: number;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly name = "PromiseTimeoutError";
|
|
7
|
+
constructor(durationMs: number, message?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare function wrapPromiseInTimeout<PromiseValueType>(durationMs: number, originalPromise: PromiseLike<PromiseValueType>): Promise<PromiseValueType>;
|
|
10
|
+
/** A promise which can be resolved or rejected by external code. */
|
|
11
|
+
export declare type DeferredPromiseWrapper<T> = {
|
|
12
|
+
promise: Promise<T>;
|
|
13
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
14
|
+
reject: (reason?: any) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function createDeferredPromiseWrapper<T = void>(): DeferredPromiseWrapper<T>;
|
|
17
|
+
export declare type WaitForConditionInputs = {
|
|
18
|
+
conditionCallback: () => boolean | Promise<boolean>;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
intervalMs?: number;
|
|
21
|
+
timeoutMessage?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function waitForCondition({ conditionCallback, timeoutMs, intervalMs, timeoutMessage, }: WaitForConditionInputs): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare type Tuple<ArrayElementGeneric, LengthGeneric extends number> = LengthGeneric extends LengthGeneric ? number extends LengthGeneric ? ArrayElementGeneric[] : _TupleOf<ArrayElementGeneric, LengthGeneric, []> : never;
|
|
2
|
+
declare type _TupleOf<ArrayElementGeneric, LengthGeneric extends number, FullArrayGeneric extends unknown[]> = FullArrayGeneric['length'] extends LengthGeneric ? FullArrayGeneric : _TupleOf<ArrayElementGeneric, LengthGeneric, [ArrayElementGeneric, ...FullArrayGeneric]>;
|
|
3
|
+
export declare type AtLeastTuple<ArrayElementGeneric, LengthGeneric extends number> = readonly [
|
|
4
|
+
...Tuple<ArrayElementGeneric, LengthGeneric>,
|
|
5
|
+
...ArrayElementGeneric[]
|
|
6
|
+
];
|
|
7
|
+
export declare function isLengthAtLeast<ArrayElementGeneric, LengthGeneric extends number>(array: ReadonlyArray<ArrayElementGeneric>, length: LengthGeneric): array is AtLeastTuple<ArrayElementGeneric, LengthGeneric>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare function getTypeOf(x: any): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
2
|
+
export declare type TypeOf = ReturnType<typeof getTypeOf>;
|
|
3
|
+
export declare type TypeOfWithArray = TypeOf | 'array';
|
|
4
|
+
export declare type TypeOfMapping = {
|
|
5
|
+
array: any[];
|
|
6
|
+
bigint: bigint;
|
|
7
|
+
boolean: boolean;
|
|
8
|
+
function: (...args: any[]) => any;
|
|
9
|
+
number: number;
|
|
10
|
+
object: object;
|
|
11
|
+
string: string;
|
|
12
|
+
symbol: symbol;
|
|
13
|
+
undefined: undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare function typeOfWithArray(input: unknown): TypeOfWithArray;
|
|
16
|
+
export declare function isTypeOfWithArray<T extends TypeOfWithArray>(input: unknown, testType: T): input is TypeOfMapping[T];
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Makes all properties in an object writable. This is the opposite of Readonly<> */
|
|
2
|
+
export declare type Writeable<T> = {
|
|
3
|
+
-readonly [P in keyof T]: T[P];
|
|
4
|
+
};
|
|
5
|
+
/** Makes all property values in an object also readonly. Can cause issues on primitive. */
|
|
6
|
+
export declare type DeepWriteable<T> = {
|
|
7
|
+
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
8
|
+
};
|
|
9
|
+
/** Replace properties in T with properties in U. */
|
|
10
|
+
export declare type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
11
|
+
/** Extract the element type out of an array type. */
|
|
12
|
+
export declare type ArrayElement<ArrayType extends ReadonlyArray<any>> = ArrayType[number];
|
|
13
|
+
/**
|
|
14
|
+
* Same as the Required<> built-in type helper but this requires that each property be present and
|
|
15
|
+
* be not null.
|
|
16
|
+
*/
|
|
17
|
+
export declare type RequiredAndNotNull<T> = {
|
|
18
|
+
[P in keyof T]-?: NonNullable<T[P]>;
|
|
19
|
+
};
|
|
20
|
+
/** Require only a subset of object properties. */
|
|
21
|
+
export declare type RequiredBy<T, K extends keyof T> = Overwrite<T, Required<Pick<T, K>>>;
|
|
22
|
+
/**
|
|
23
|
+
* Require only a subset of object properties and require that they be not null. This is
|
|
24
|
+
* particularly useful in conjunction with the "exactOptionalPropertyTypes" tsconfig flag.
|
|
25
|
+
*/
|
|
26
|
+
export declare type RequiredAndNotNullBy<T, K extends keyof T> = Omit<T, K> & Required<{
|
|
27
|
+
[PropertyName in K]: NonNullable<T[PropertyName]>;
|
|
28
|
+
}>;
|
|
29
|
+
/** If type T = type U, then type Y. Else type N. */
|
|
30
|
+
export declare type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;
|
|
31
|
+
export declare type UnPromise<T> = T extends PromiseLike<infer PromiseType> ? Awaited<PromiseType> : T;
|
|
32
|
+
/**
|
|
33
|
+
* This function returns another function that simply returns whatever input it's given. However, it
|
|
34
|
+
* also checks that the input matches the original wrapNarrowTypeWithTypeCheck's generic, while
|
|
35
|
+
* maintaining strict "const" like typing.
|
|
36
|
+
*
|
|
37
|
+
* Use like this: wrapNarrowTypeWithTypeCheck<EnforcedTypeHere>()(valueToEnforceTypeOn as const)
|
|
38
|
+
*
|
|
39
|
+
* Sometimes "as const" isn't required, usually it is for any object or array though.
|
|
40
|
+
*/
|
|
41
|
+
export declare function wrapNarrowTypeWithTypeCheck<P>(): <T extends P>(input: T) => Readonly<T>;
|
|
42
|
+
/**
|
|
43
|
+
* This type helper is useful for forcing function generics to be explicitly provided, rather than
|
|
44
|
+
* inferring them from the given inputs. See the test file for examples.
|
|
45
|
+
*/
|
|
46
|
+
export declare type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
47
|
+
/**
|
|
48
|
+
* This is a type helper that ensures the given input matches the given generic type. The generic is
|
|
49
|
+
* setup in such a way that if it is omitted (which is typically allowed in TypeScript, resulting in
|
|
50
|
+
* the generic being inferred from the inputs), there will actually be a type error. This forces
|
|
51
|
+
* each usage of this function to explicitly specify the generic, thus giving us type safety for the
|
|
52
|
+
* input.
|
|
53
|
+
*/
|
|
54
|
+
export declare function ensureType<ExpectedType = never>(input: NoInfer<ExpectedType>): NoInfer<ExpectedType>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './augments/ansi';
|
|
2
|
+
export * from './augments/array';
|
|
3
|
+
export * from './augments/async';
|
|
4
|
+
export * from './augments/common-number';
|
|
5
|
+
export * from './augments/common-string';
|
|
6
|
+
export * from './augments/date';
|
|
7
|
+
export * from './augments/environment';
|
|
8
|
+
export * from './augments/error';
|
|
9
|
+
export * from './augments/function';
|
|
10
|
+
export * from './augments/object';
|
|
11
|
+
export * from './augments/promise';
|
|
12
|
+
export * from './augments/regexp';
|
|
13
|
+
export * from './augments/tuple';
|
|
14
|
+
export * from './augments/type';
|
|
15
|
+
export * from './augments/type-of';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/electrovir/augment-vir/issues"
|
|
@@ -14,18 +14,19 @@
|
|
|
14
14
|
"name": "electrovir",
|
|
15
15
|
"url": "https://github.com/electrovir"
|
|
16
16
|
},
|
|
17
|
-
"main": "dist/index.js",
|
|
18
|
-
"
|
|
17
|
+
"main": "dist/cjs/index.js",
|
|
18
|
+
"module": "dist/esm/index.js",
|
|
19
|
+
"types": "dist/types/index.d.ts",
|
|
19
20
|
"scripts": {
|
|
20
|
-
"compile": "tsc --
|
|
21
|
+
"compile": "tsc --project tsconfig.json && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json",
|
|
21
22
|
"docs:update": "virmator code-in-markdown",
|
|
22
23
|
"test": "echo \"use common-test to run tests\" && exit 0"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@type-challenges/utils": "^0.1.1",
|
|
26
26
|
"type-fest": "^3.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
+
"istanbul-smart-text-reporter": "^1.0.0",
|
|
29
30
|
"prettier": "^2.7.1",
|
|
30
31
|
"prettier-plugin-jsdoc": "^0.4.2",
|
|
31
32
|
"prettier-plugin-multiline-arrays": "^1.1.1",
|
|
@@ -33,7 +34,6 @@
|
|
|
33
34
|
"prettier-plugin-packagejson": "^2.3.0",
|
|
34
35
|
"prettier-plugin-sort-json": "^0.0.3",
|
|
35
36
|
"prettier-plugin-toml": "^0.3.1",
|
|
36
|
-
"ts-node": "^10.9.1",
|
|
37
37
|
"typescript": "^4.8.4"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
package/dist/augments/array.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.typedMap = exports.isInTypedArray = exports.awaitedBlockingMap = exports.awaitedForEach = exports.trimArrayStrings = exports.flatten2dArray = exports.filterOutIndexes = void 0;
|
|
4
|
-
function filterOutIndexes(array, indexes) {
|
|
5
|
-
return array.filter((_, index) => !indexes.includes(index));
|
|
6
|
-
}
|
|
7
|
-
exports.filterOutIndexes = filterOutIndexes;
|
|
8
|
-
function flatten2dArray(array2d) {
|
|
9
|
-
const flattened = array2d.reduce((accum, row) => accum.concat(row), []);
|
|
10
|
-
return flattened;
|
|
11
|
-
}
|
|
12
|
-
exports.flatten2dArray = flatten2dArray;
|
|
13
|
-
function trimArrayStrings(input) {
|
|
14
|
-
return input.map((line) => line.trim()).filter((line) => line !== '');
|
|
15
|
-
}
|
|
16
|
-
exports.trimArrayStrings = trimArrayStrings;
|
|
17
|
-
/**
|
|
18
|
-
* Acts like calling Array.prototype.forEach in that all elements are executed upon in order, and
|
|
19
|
-
* each execution is blocking. Meaning, the callback won't be called on element 2 until the callback
|
|
20
|
-
* has finished its call on element 1.
|
|
21
|
-
*/
|
|
22
|
-
async function awaitedForEach(input, callback) {
|
|
23
|
-
await awaitedBlockingMap(input, callback);
|
|
24
|
-
}
|
|
25
|
-
exports.awaitedForEach = awaitedForEach;
|
|
26
|
-
async function awaitedBlockingMap(input, callback) {
|
|
27
|
-
const mappedValues = await input.reduce(async (accumPromise, currentElement, index, wholeArray) => {
|
|
28
|
-
const accum = await accumPromise;
|
|
29
|
-
const mappedValue = await callback(currentElement, index, wholeArray);
|
|
30
|
-
accum.push(mappedValue);
|
|
31
|
-
return accum;
|
|
32
|
-
}, Promise.resolve([]));
|
|
33
|
-
return mappedValues;
|
|
34
|
-
}
|
|
35
|
-
exports.awaitedBlockingMap = awaitedBlockingMap;
|
|
36
|
-
function isInTypedArray(array, input) {
|
|
37
|
-
return array.includes(input);
|
|
38
|
-
}
|
|
39
|
-
exports.isInTypedArray = isInTypedArray;
|
|
40
|
-
/** Preserves tuple types. */
|
|
41
|
-
function typedMap(arrayToMap, mapCallback) {
|
|
42
|
-
return arrayToMap.map(mapCallback);
|
|
43
|
-
}
|
|
44
|
-
exports.typedMap = typedMap;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { Equal } from '@type-challenges/utils';
|
|
2
|
-
export type { Alike, Debug, Equal, ExpectExtends as DoesExtend, ExpectFalse, ExpectTrue, ExpectValidArgs as HasValidArgs, IsAny, IsFalse, IsTrue, MergeInsertions, NotAny, NotEqual, UnionToIntersection, } from '@type-challenges/utils';
|
|
3
|
-
export declare type CouldBeNullish<VALUE> = Equal<VALUE, NonNullable<VALUE>> extends true ? false : true;
|