@augment-vir/common 9.1.0 → 9.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/dist/cjs/augments/promise.d.ts +1 -0
- package/dist/cjs/augments/promise.js +5 -1
- package/dist/cjs/augments/type.d.ts +4 -0
- package/dist/esm/augments/promise.d.ts +1 -0
- package/dist/esm/augments/promise.js +3 -0
- package/dist/esm/augments/type.d.ts +4 -0
- package/dist/types/augments/promise.d.ts +1 -0
- package/dist/types/augments/type.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function wait(delayMs: number): Promise<void>;
|
|
2
|
+
export declare function waitValue<ResolutionValue>(delayMs: number, returnValue: ResolutionValue): Promise<ResolutionValue>;
|
|
2
3
|
export declare function isPromiseLike<T>(input: T | unknown): input is T extends PromiseLike<infer ValueType> ? PromiseLike<ValueType> : PromiseLike<unknown>;
|
|
3
4
|
export declare class PromiseTimeoutError extends Error {
|
|
4
5
|
readonly durationMs: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.waitForCondition = exports.createDeferredPromiseWrapper = exports.wrapPromiseInTimeout = exports.PromiseTimeoutError = exports.isPromiseLike = exports.wait = void 0;
|
|
3
|
+
exports.waitForCondition = exports.createDeferredPromiseWrapper = exports.wrapPromiseInTimeout = exports.PromiseTimeoutError = exports.isPromiseLike = exports.waitValue = exports.wait = void 0;
|
|
4
4
|
const error_1 = require("./error");
|
|
5
5
|
const typed_has_property_1 = require("./object/typed-has-property");
|
|
6
6
|
function wait(delayMs) {
|
|
@@ -13,6 +13,10 @@ function wait(delayMs) {
|
|
|
13
13
|
return deferredPromiseWrapper.promise;
|
|
14
14
|
}
|
|
15
15
|
exports.wait = wait;
|
|
16
|
+
async function waitValue(delayMs, returnValue) {
|
|
17
|
+
return wait(delayMs).then(() => returnValue);
|
|
18
|
+
}
|
|
19
|
+
exports.waitValue = waitValue;
|
|
16
20
|
function isPromiseLike(input) {
|
|
17
21
|
if ((0, typed_has_property_1.typedHasProperty)(input, 'then') && typeof input.then === 'function') {
|
|
18
22
|
return true;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Except, Simplify } from 'type-fest';
|
|
1
2
|
/** Makes all properties in an object writable. This is the opposite of Readonly<> */
|
|
2
3
|
export type Writeable<T> = {
|
|
3
4
|
-readonly [P in keyof T]: T[P];
|
|
@@ -17,6 +18,9 @@ export type ArrayElement<ArrayType extends ReadonlyArray<any>> = ArrayType[numbe
|
|
|
17
18
|
export type RequiredAndNotNull<T> = {
|
|
18
19
|
[P in keyof T]-?: NonNullable<T[P]>;
|
|
19
20
|
};
|
|
21
|
+
export type SetOptionalAndNullable<OriginalObjectGeneric, OptionalKeysGeneric extends keyof OriginalObjectGeneric> = Simplify<Except<OriginalObjectGeneric, OptionalKeysGeneric> & {
|
|
22
|
+
[PropKey in OptionalKeysGeneric]?: OriginalObjectGeneric[PropKey] | null | undefined;
|
|
23
|
+
}>;
|
|
20
24
|
/** Require only a subset of object properties. */
|
|
21
25
|
export type RequiredBy<T, K extends keyof T> = Overwrite<T, Required<Pick<T, K>>>;
|
|
22
26
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function wait(delayMs: number): Promise<void>;
|
|
2
|
+
export declare function waitValue<ResolutionValue>(delayMs: number, returnValue: ResolutionValue): Promise<ResolutionValue>;
|
|
2
3
|
export declare function isPromiseLike<T>(input: T | unknown): input is T extends PromiseLike<infer ValueType> ? PromiseLike<ValueType> : PromiseLike<unknown>;
|
|
3
4
|
export declare class PromiseTimeoutError extends Error {
|
|
4
5
|
readonly durationMs: number;
|
|
@@ -9,6 +9,9 @@ export function wait(delayMs) {
|
|
|
9
9
|
}
|
|
10
10
|
return deferredPromiseWrapper.promise;
|
|
11
11
|
}
|
|
12
|
+
export async function waitValue(delayMs, returnValue) {
|
|
13
|
+
return wait(delayMs).then(() => returnValue);
|
|
14
|
+
}
|
|
12
15
|
export function isPromiseLike(input) {
|
|
13
16
|
if (typedHasProperty(input, 'then') && typeof input.then === 'function') {
|
|
14
17
|
return true;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Except, Simplify } from 'type-fest';
|
|
1
2
|
/** Makes all properties in an object writable. This is the opposite of Readonly<> */
|
|
2
3
|
export type Writeable<T> = {
|
|
3
4
|
-readonly [P in keyof T]: T[P];
|
|
@@ -17,6 +18,9 @@ export type ArrayElement<ArrayType extends ReadonlyArray<any>> = ArrayType[numbe
|
|
|
17
18
|
export type RequiredAndNotNull<T> = {
|
|
18
19
|
[P in keyof T]-?: NonNullable<T[P]>;
|
|
19
20
|
};
|
|
21
|
+
export type SetOptionalAndNullable<OriginalObjectGeneric, OptionalKeysGeneric extends keyof OriginalObjectGeneric> = Simplify<Except<OriginalObjectGeneric, OptionalKeysGeneric> & {
|
|
22
|
+
[PropKey in OptionalKeysGeneric]?: OriginalObjectGeneric[PropKey] | null | undefined;
|
|
23
|
+
}>;
|
|
20
24
|
/** Require only a subset of object properties. */
|
|
21
25
|
export type RequiredBy<T, K extends keyof T> = Overwrite<T, Required<Pick<T, K>>>;
|
|
22
26
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function wait(delayMs: number): Promise<void>;
|
|
2
|
+
export declare function waitValue<ResolutionValue>(delayMs: number, returnValue: ResolutionValue): Promise<ResolutionValue>;
|
|
2
3
|
export declare function isPromiseLike<T>(input: T | unknown): input is T extends PromiseLike<infer ValueType> ? PromiseLike<ValueType> : PromiseLike<unknown>;
|
|
3
4
|
export declare class PromiseTimeoutError extends Error {
|
|
4
5
|
readonly durationMs: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Except, Simplify } from 'type-fest';
|
|
1
2
|
/** Makes all properties in an object writable. This is the opposite of Readonly<> */
|
|
2
3
|
export type Writeable<T> = {
|
|
3
4
|
-readonly [P in keyof T]: T[P];
|
|
@@ -17,6 +18,9 @@ export type ArrayElement<ArrayType extends ReadonlyArray<any>> = ArrayType[numbe
|
|
|
17
18
|
export type RequiredAndNotNull<T> = {
|
|
18
19
|
[P in keyof T]-?: NonNullable<T[P]>;
|
|
19
20
|
};
|
|
21
|
+
export type SetOptionalAndNullable<OriginalObjectGeneric, OptionalKeysGeneric extends keyof OriginalObjectGeneric> = Simplify<Except<OriginalObjectGeneric, OptionalKeysGeneric> & {
|
|
22
|
+
[PropKey in OptionalKeysGeneric]?: OriginalObjectGeneric[PropKey] | null | undefined;
|
|
23
|
+
}>;
|
|
20
24
|
/** Require only a subset of object properties. */
|
|
21
25
|
export type RequiredBy<T, K extends keyof T> = Overwrite<T, Required<Pick<T, K>>>;
|
|
22
26
|
/**
|