@mll-lab/js-utils 2.15.3 → 2.17.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/index.common.js +11 -0
- package/dist/index.common.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/pick.d.ts +7 -0
- package/dist/pick.test.d.ts +1 -0
- package/dist/typeGuards.d.ts +1 -1
- package/dist/types.check.d.ts +28 -0
- package/dist/types.d.ts +27 -0
- package/package.json +1 -1
package/dist/pick.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/typeGuards.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function isString(value: unknown): value is string;
|
|
2
|
-
export declare function isNotNullish<T>(value: T): value is
|
|
2
|
+
export declare function isNotNullish<T>(value: T): value is NonNullable<T>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DeepPartial, Either, Exact, Maybe, MaybePromise, Modify, ValueOf } from './types';
|
|
2
|
+
declare type Bar = {
|
|
3
|
+
baz: number;
|
|
4
|
+
};
|
|
5
|
+
declare type Obj = {
|
|
6
|
+
foo: string;
|
|
7
|
+
bar: Bar;
|
|
8
|
+
};
|
|
9
|
+
export declare const allowsAssigningEmptyObjectToDeepPartial: DeepPartial<Obj>;
|
|
10
|
+
export declare function acceptsMaybePromise(v: MaybePromise<number>): Promise<number>;
|
|
11
|
+
export declare const modifiedType: Modify<Obj, {
|
|
12
|
+
foo: number;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function acceptsValueOf(v: ValueOf<Obj>): string | Bar;
|
|
15
|
+
export declare const maybeAllowsNull: Maybe<number>;
|
|
16
|
+
export declare const maybeAllowsUndefined: Maybe<number>;
|
|
17
|
+
export declare const maybeAllowsT: Maybe<number>;
|
|
18
|
+
export declare const maybeDoesNotAllowOtherType: Maybe<number>;
|
|
19
|
+
declare type BarOrObj = Either<Bar, Obj>;
|
|
20
|
+
export declare const onlyFoo: BarOrObj;
|
|
21
|
+
export declare const onlyBar: BarOrObj;
|
|
22
|
+
export declare const both: BarOrObj;
|
|
23
|
+
export declare const none: BarOrObj;
|
|
24
|
+
declare type ExactlyBar = Exact<Bar>;
|
|
25
|
+
export declare const exactlyBar: ExactlyBar;
|
|
26
|
+
export declare const lessThanBar: ExactlyBar;
|
|
27
|
+
export declare const moreThanBar: ExactlyBar;
|
|
28
|
+
export {};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Recursively optional deep partial type. */
|
|
2
|
+
export declare type DeepPartial<T> = {
|
|
3
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
4
|
+
};
|
|
5
|
+
/** Either a value or a promise that will resolve to that value. */
|
|
6
|
+
export declare type MaybePromise<T> = T | Promise<T>;
|
|
7
|
+
/** Modify a given type, e.g. to make some properties optional. */
|
|
8
|
+
export declare type Modify<T, R> = Pick<T, Exclude<keyof T, keyof R>> & R;
|
|
9
|
+
/** The missing counterpart to keyof. */
|
|
10
|
+
export declare type ValueOf<T> = T[keyof T];
|
|
11
|
+
/** Add null and undefined to a type. */
|
|
12
|
+
export declare type Maybe<T> = T | null | undefined;
|
|
13
|
+
/** Only props that are contained in T but not U. */
|
|
14
|
+
declare type Subtract<T, U> = {
|
|
15
|
+
[P in keyof T]: T[P];
|
|
16
|
+
} & {
|
|
17
|
+
[P in keyof U]?: never;
|
|
18
|
+
};
|
|
19
|
+
/** Only one of both types (exclusively). */
|
|
20
|
+
export declare type Either<T, U> = Subtract<T, U> | Subtract<U, T>;
|
|
21
|
+
/** Only the given keys and no others. */
|
|
22
|
+
export declare type Exact<T extends {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}> = {
|
|
25
|
+
[K in keyof T]: T[K];
|
|
26
|
+
};
|
|
27
|
+
export {};
|