@jonloucks/concurrency-ts 0.4.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/README.md +248 -0
- package/api/Completable.d.ts +51 -0
- package/api/Completable.d.ts.map +1 -0
- package/api/Completable.js +11 -0
- package/api/Completable.js.map +1 -0
- package/api/CompletableFactory.d.ts +29 -0
- package/api/CompletableFactory.d.ts.map +1 -0
- package/api/CompletableFactory.js +19 -0
- package/api/CompletableFactory.js.map +1 -0
- package/api/Completion.d.ts +18 -0
- package/api/Completion.d.ts.map +1 -0
- package/api/Completion.js +2 -0
- package/api/Completion.js.map +1 -0
- package/api/CompletionNotify.d.ts +23 -0
- package/api/CompletionNotify.d.ts.map +1 -0
- package/api/CompletionNotify.js +11 -0
- package/api/CompletionNotify.js.map +1 -0
- package/api/CompletionState.d.ts +35 -0
- package/api/CompletionState.d.ts.map +1 -0
- package/api/CompletionState.js +64 -0
- package/api/CompletionState.js.map +1 -0
- package/api/Concurrency.d.ts +90 -0
- package/api/Concurrency.d.ts.map +1 -0
- package/api/Concurrency.js +19 -0
- package/api/Concurrency.js.map +1 -0
- package/api/ConcurrencyException.d.ts +27 -0
- package/api/ConcurrencyException.d.ts.map +1 -0
- package/api/ConcurrencyException.js +53 -0
- package/api/ConcurrencyException.js.map +1 -0
- package/api/ConcurrencyFactory.d.ts +41 -0
- package/api/ConcurrencyFactory.d.ts.map +1 -0
- package/api/ConcurrencyFactory.js +19 -0
- package/api/ConcurrencyFactory.js.map +1 -0
- package/api/IsCompleted.d.ts +20 -0
- package/api/IsCompleted.d.ts.map +1 -0
- package/api/IsCompleted.js +11 -0
- package/api/IsCompleted.js.map +1 -0
- package/api/OnCompletion.d.ts +23 -0
- package/api/OnCompletion.d.ts.map +1 -0
- package/api/OnCompletion.js +12 -0
- package/api/OnCompletion.js.map +1 -0
- package/api/Rule.d.ts +28 -0
- package/api/Rule.d.ts.map +1 -0
- package/api/Rule.js +11 -0
- package/api/Rule.js.map +1 -0
- package/api/StateMachine.d.ts +95 -0
- package/api/StateMachine.d.ts.map +1 -0
- package/api/StateMachine.js +13 -0
- package/api/StateMachine.js.map +1 -0
- package/api/StateMachineFactory.d.ts +29 -0
- package/api/StateMachineFactory.d.ts.map +1 -0
- package/api/StateMachineFactory.js +19 -0
- package/api/StateMachineFactory.js.map +1 -0
- package/api/TimeoutException.d.ts +21 -0
- package/api/TimeoutException.d.ts.map +1 -0
- package/api/TimeoutException.js +27 -0
- package/api/TimeoutException.js.map +1 -0
- package/api/Transition.d.ts +44 -0
- package/api/Transition.d.ts.map +1 -0
- package/api/Transition.js +11 -0
- package/api/Transition.js.map +1 -0
- package/api/Types.d.ts +27 -0
- package/api/Types.d.ts.map +1 -0
- package/api/Types.js +28 -0
- package/api/Types.js.map +1 -0
- package/api/Waitable.d.ts +39 -0
- package/api/Waitable.d.ts.map +1 -0
- package/api/Waitable.js +17 -0
- package/api/Waitable.js.map +1 -0
- package/api/WaitableConsumer.d.ts +54 -0
- package/api/WaitableConsumer.d.ts.map +1 -0
- package/api/WaitableConsumer.js +11 -0
- package/api/WaitableConsumer.js.map +1 -0
- package/api/WaitableFactory.d.ts +29 -0
- package/api/WaitableFactory.d.ts.map +1 -0
- package/api/WaitableFactory.js +19 -0
- package/api/WaitableFactory.js.map +1 -0
- package/api/WaitableNotify.d.ts +31 -0
- package/api/WaitableNotify.d.ts.map +1 -0
- package/api/WaitableNotify.js +12 -0
- package/api/WaitableNotify.js.map +1 -0
- package/api/WaitableSupplier.d.ts +53 -0
- package/api/WaitableSupplier.d.ts.map +1 -0
- package/api/WaitableSupplier.js +11 -0
- package/api/WaitableSupplier.js.map +1 -0
- package/auxiliary/Checks.d.ts +116 -0
- package/auxiliary/Checks.d.ts.map +1 -0
- package/auxiliary/Checks.js +145 -0
- package/auxiliary/Checks.js.map +1 -0
- package/auxiliary/Consumer.d.ts +45 -0
- package/auxiliary/Consumer.d.ts.map +1 -0
- package/auxiliary/Consumer.js +45 -0
- package/auxiliary/Consumer.js.map +1 -0
- package/auxiliary/Predicate.d.ts +55 -0
- package/auxiliary/Predicate.d.ts.map +1 -0
- package/auxiliary/Predicate.js +73 -0
- package/auxiliary/Predicate.js.map +1 -0
- package/auxiliary/Supplier.d.ts +52 -0
- package/auxiliary/Supplier.d.ts.map +1 -0
- package/auxiliary/Supplier.js +67 -0
- package/auxiliary/Supplier.js.map +1 -0
- package/impl/Completable.impl.d.ts +10 -0
- package/impl/Completable.impl.d.ts.map +1 -0
- package/impl/Completable.impl.js +136 -0
- package/impl/Completable.impl.js.map +1 -0
- package/impl/CompletableFactory.impl.d.ts +9 -0
- package/impl/CompletableFactory.impl.d.ts.map +1 -0
- package/impl/CompletableFactory.impl.js +42 -0
- package/impl/CompletableFactory.impl.js.map +1 -0
- package/impl/CompleteLater.impl.d.ts +12 -0
- package/impl/CompleteLater.impl.d.ts.map +1 -0
- package/impl/CompleteLater.impl.js +31 -0
- package/impl/CompleteLater.impl.js.map +1 -0
- package/impl/CompleteNow.impl.d.ts +14 -0
- package/impl/CompleteNow.impl.d.ts.map +1 -0
- package/impl/CompleteNow.impl.js +33 -0
- package/impl/CompleteNow.impl.js.map +1 -0
- package/impl/Concurrency.impl.d.ts +9 -0
- package/impl/Concurrency.impl.d.ts.map +1 -0
- package/impl/Concurrency.impl.js +84 -0
- package/impl/Concurrency.impl.js.map +1 -0
- package/impl/ConcurrencyFactory.impl.d.ts +10 -0
- package/impl/ConcurrencyFactory.impl.d.ts.map +1 -0
- package/impl/ConcurrencyFactory.impl.js +74 -0
- package/impl/ConcurrencyFactory.impl.js.map +1 -0
- package/impl/ConcurrencyWrapper.impl.d.ts +13 -0
- package/impl/ConcurrencyWrapper.impl.d.ts.map +1 -0
- package/impl/ConcurrencyWrapper.impl.js +85 -0
- package/impl/ConcurrencyWrapper.impl.js.map +1 -0
- package/impl/Events.d.ts +25 -0
- package/impl/Events.d.ts.map +1 -0
- package/impl/Events.impl.d.ts +11 -0
- package/impl/Events.impl.d.ts.map +1 -0
- package/impl/Events.impl.js +63 -0
- package/impl/Events.impl.js.map +1 -0
- package/impl/Events.js +3 -0
- package/impl/Events.js.map +1 -0
- package/impl/ExposedPromise.d.ts +26 -0
- package/impl/ExposedPromise.d.ts.map +1 -0
- package/impl/ExposedPromise.impl.d.ts +9 -0
- package/impl/ExposedPromise.impl.d.ts.map +1 -0
- package/impl/ExposedPromise.impl.js +41 -0
- package/impl/ExposedPromise.impl.js.map +1 -0
- package/impl/ExposedPromise.js +2 -0
- package/impl/ExposedPromise.js.map +1 -0
- package/impl/Internal.impl.d.ts +35 -0
- package/impl/Internal.impl.d.ts.map +1 -0
- package/impl/Internal.impl.js +90 -0
- package/impl/Internal.impl.js.map +1 -0
- package/impl/StateMachine.impl.d.ts +9 -0
- package/impl/StateMachine.impl.d.ts.map +1 -0
- package/impl/StateMachine.impl.js +184 -0
- package/impl/StateMachine.impl.js.map +1 -0
- package/impl/StateMachineFactory.impl.d.ts +9 -0
- package/impl/StateMachineFactory.impl.d.ts.map +1 -0
- package/impl/StateMachineFactory.impl.js +43 -0
- package/impl/StateMachineFactory.impl.js.map +1 -0
- package/impl/Waitable.impl.d.ts +8 -0
- package/impl/Waitable.impl.d.ts.map +1 -0
- package/impl/Waitable.impl.js +212 -0
- package/impl/Waitable.impl.js.map +1 -0
- package/impl/WaitableFactory.impl.d.ts +9 -0
- package/impl/WaitableFactory.impl.d.ts.map +1 -0
- package/impl/WaitableFactory.impl.js +42 -0
- package/impl/WaitableFactory.impl.js.map +1 -0
- package/index.d.ts +25 -0
- package/index.d.ts.map +1 -0
- package/index.js +33 -0
- package/index.js.map +1 -0
- package/package.json +88 -0
- package/version.d.ts +3 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
package/api/Types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { type Consumer, type Method as ConsumerFunction, guard as consumerGuard, type Type as ConsumerType } from "@jonloucks/concurrency-ts/auxiliary/Consumer";
|
|
2
|
+
export { type Predicate, type Method as PredicateFunction, guard as predicateGuard, type Type as PredicateType } from "@jonloucks/concurrency-ts/auxiliary/Predicate";
|
|
3
|
+
export { type Supplier, type Method as SupplierFunction, guard as supplierGuard, type Type as SupplierType, toValue as supplierToValue } from "@jonloucks/concurrency-ts/auxiliary/Supplier";
|
|
4
|
+
export { guardFunctions, isNotPresent, isNumber, isPresent, isString, type OptionalType, type RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
5
|
+
/**
|
|
6
|
+
* A type that can be a value of type T, null, or undefined
|
|
7
|
+
*/
|
|
8
|
+
export type Throwable<T> = T | null | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Type guard to determine if a value is Throwable
|
|
11
|
+
*
|
|
12
|
+
* @param value the value to check
|
|
13
|
+
* @return true if the value is Throwable
|
|
14
|
+
*/
|
|
15
|
+
export declare function isThrowable<T>(value: unknown): value is Throwable<T>;
|
|
16
|
+
export interface Duration {
|
|
17
|
+
get milliSeconds(): number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The minimum timeout duration
|
|
21
|
+
*/
|
|
22
|
+
export declare const MIN_TIMEOUT: Duration;
|
|
23
|
+
/**
|
|
24
|
+
* The maximum timeout duration
|
|
25
|
+
*/
|
|
26
|
+
export declare const MAX_TIMEOUT: Duration;
|
|
27
|
+
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../src/api/Types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,IAAI,gBAAgB,EAAE,KAAK,IAAI,aAAa,EAAE,KAAK,IAAI,IAAI,YAAY,EAAE,MAAM,8CAA8C,CAAC;AACjK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,IAAI,iBAAiB,EAAE,KAAK,IAAI,cAAc,EAAE,KAAK,IAAI,IAAI,aAAa,EAAE,MAAM,+CAA+C,CAAC;AACtK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,IAAI,gBAAgB,EAAE,KAAK,IAAI,aAAa,EAAE,KAAK,IAAI,IAAI,YAAY,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC7L,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGtJ;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAAiB;AAItF,MAAM,WAAW,QAAQ;IACvB,IAAI,YAAY,IAAI,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,QAIzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,QAIzB,CAAC"}
|
package/api/Types.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { guard as consumerGuard } from "@jonloucks/concurrency-ts/auxiliary/Consumer";
|
|
2
|
+
export { guard as predicateGuard } from "@jonloucks/concurrency-ts/auxiliary/Predicate";
|
|
3
|
+
export { guard as supplierGuard, toValue as supplierToValue } from "@jonloucks/concurrency-ts/auxiliary/Supplier";
|
|
4
|
+
export { guardFunctions, isNotPresent, isNumber, isPresent, isString } from "@jonloucks/contracts-ts/api/Types";
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to determine if a value is Throwable
|
|
7
|
+
*
|
|
8
|
+
* @param value the value to check
|
|
9
|
+
* @return true if the value is Throwable
|
|
10
|
+
*/
|
|
11
|
+
export function isThrowable(value) { return true; }
|
|
12
|
+
/**
|
|
13
|
+
* The minimum timeout duration
|
|
14
|
+
*/
|
|
15
|
+
export const MIN_TIMEOUT = {
|
|
16
|
+
get milliSeconds() {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The maximum timeout duration
|
|
22
|
+
*/
|
|
23
|
+
export const MAX_TIMEOUT = {
|
|
24
|
+
get milliSeconds() {
|
|
25
|
+
return Number.MAX_SAFE_INTEGER;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=Types.js.map
|
package/api/Types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.js","sourceRoot":"","sources":["../../src/api/Types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,IAAI,aAAa,EAA6B,MAAM,8CAA8C,CAAC;AACjK,OAAO,EAAoD,KAAK,IAAI,cAAc,EAA8B,MAAM,+CAA+C,CAAC;AACtK,OAAO,EAAkD,KAAK,IAAI,aAAa,EAA6B,OAAO,IAAI,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC7L,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAwC,MAAM,mCAAmC,CAAC;AAQtJ;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAI,KAAc,IAA2B,OAAO,IAAI,CAAC,CAAC,CAAC;AAQtF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAa;IACnC,IAAI,YAAY;QACd,OAAO,CAAC,CAAC;IACX,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAa;IACnC,IAAI,YAAY;QACd,OAAO,MAAM,CAAC,gBAAgB,CAAC;IACjC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { WaitableConsumer } from "@jonloucks/concurrency-ts/api/WaitableConsumer";
|
|
2
|
+
import { WaitableNotify } from "@jonloucks/concurrency-ts/api/WaitableNotify";
|
|
3
|
+
import { WaitableSupplier } from "@jonloucks/concurrency-ts/api/WaitableSupplier";
|
|
4
|
+
import { OptionalType, RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
5
|
+
import { Open } from "@jonloucks/contracts-ts/api/Open";
|
|
6
|
+
import { Contracts } from "@jonloucks/contracts-ts";
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for creating a Waitable
|
|
9
|
+
*/
|
|
10
|
+
export interface Config<T> {
|
|
11
|
+
/**
|
|
12
|
+
* Optional contracts for validation or other purposes
|
|
13
|
+
*/
|
|
14
|
+
contracts?: Contracts;
|
|
15
|
+
/**
|
|
16
|
+
* Optional initial value of the Waitable
|
|
17
|
+
*/
|
|
18
|
+
initialValue?: OptionalType<T>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Export Waitable Config type
|
|
22
|
+
*/
|
|
23
|
+
export { type Config as WaitableConfig };
|
|
24
|
+
/**
|
|
25
|
+
* Provides mutable reference that allows other threads to wait until
|
|
26
|
+
* the value satisfies a given condition.
|
|
27
|
+
*
|
|
28
|
+
* @param <T> the type of references
|
|
29
|
+
*/
|
|
30
|
+
export interface Waitable<T> extends Open, WaitableSupplier<T>, WaitableConsumer<T>, WaitableNotify<T> {
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Determine if the given instance is a Waitable
|
|
34
|
+
*
|
|
35
|
+
* @param instance the instance to check
|
|
36
|
+
* @return true if the instance is a Waitable
|
|
37
|
+
*/
|
|
38
|
+
export declare function guard<T>(instance: unknown): instance is RequiredType<Waitable<T>>;
|
|
39
|
+
//# sourceMappingURL=Waitable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Waitable.d.ts","sourceRoot":"","sources":["../../src/api/Waitable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gDAAgD,CAAC;AAClH,OAAO,EAAE,cAAc,EAAgC,MAAM,8CAA8C,CAAC;AAC5G,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gDAAgD,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,qCAAqC,CAAC;AACjG,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,OAAO,EAAE,KAAK,MAAM,IAAI,cAAc,EAAE,CAAE;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,CAAE,SAAQ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;CACrG;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAKjF"}
|
package/api/Waitable.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { guard as guardWaitableConsumer } from "@jonloucks/concurrency-ts/api/WaitableConsumer";
|
|
2
|
+
import { guard as guardWaitableNotify } from "@jonloucks/concurrency-ts/api/WaitableNotify";
|
|
3
|
+
import { guard as guardWaitableSupplier } from "@jonloucks/concurrency-ts/api/WaitableSupplier";
|
|
4
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
5
|
+
/**
|
|
6
|
+
* Determine if the given instance is a Waitable
|
|
7
|
+
*
|
|
8
|
+
* @param instance the instance to check
|
|
9
|
+
* @return true if the instance is a Waitable
|
|
10
|
+
*/
|
|
11
|
+
export function guard(instance) {
|
|
12
|
+
return guardFunctions(instance, 'open')
|
|
13
|
+
&& guardWaitableConsumer(instance)
|
|
14
|
+
&& guardWaitableNotify(instance)
|
|
15
|
+
&& guardWaitableSupplier(instance);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=Waitable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Waitable.js","sourceRoot":"","sources":["../../src/api/Waitable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,IAAI,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAClH,OAAO,EAAkB,KAAK,IAAI,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAC5G,OAAO,EAAoB,KAAK,IAAI,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAClH,OAAO,EAA8B,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAiCjG;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC;WAClC,qBAAqB,CAAI,QAAQ,CAAC;WAClC,mBAAmB,CAAI,QAAQ,CAAC;WAChC,qBAAqB,CAAI,QAAQ,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Consumer, Duration, OptionalType, PredicateType, RequiredType, SupplierType } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Waitable consumer
|
|
4
|
+
* @param <T> the type of value
|
|
5
|
+
*/
|
|
6
|
+
export interface WaitableConsumer<T> extends Consumer<T> {
|
|
7
|
+
/**
|
|
8
|
+
* Assign a new value
|
|
9
|
+
*
|
|
10
|
+
* @param value the new value
|
|
11
|
+
* @throws IllegalArgumentException if value is null
|
|
12
|
+
*/
|
|
13
|
+
consume(value: SupplierType<T>): void;
|
|
14
|
+
/**
|
|
15
|
+
* Consume a new value if conditions are satisfied
|
|
16
|
+
*
|
|
17
|
+
* In languages that support synchronization this method would lock
|
|
18
|
+
* before checking the predicate. In JavaScript/TypeScript this is not possible so
|
|
19
|
+
* if becomes a variant of an 'if' check followed by a 'set' operation.
|
|
20
|
+
*
|
|
21
|
+
* @param predicate the predicate to test if a value should be replaced
|
|
22
|
+
* @param value the new value
|
|
23
|
+
* @return the supplied value if and only if the condition is satisfied
|
|
24
|
+
* @throws IllegalArgumentException if predicate is null or if value is null
|
|
25
|
+
*/
|
|
26
|
+
consumeIf(predicate: RequiredType<PredicateType<T>>, value: SupplierType<T>): OptionalType<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Consume a new value when conditions are satisfied
|
|
29
|
+
*
|
|
30
|
+
* Create a one-time promise that evaluates the predicate against the current value.
|
|
31
|
+
* If the predicate is satisfied the value is replaced and the promise resolves with the previous value.
|
|
32
|
+
*
|
|
33
|
+
* if the predicate is not satisfied the promise remains pending until either:
|
|
34
|
+
* - another thread updates the value and the predicate is satisfied, or
|
|
35
|
+
* - the optional timeout elapses
|
|
36
|
+
*
|
|
37
|
+
* In languages that support synchronization this method would lock
|
|
38
|
+
*
|
|
39
|
+
* @param predicate the predicate to test if a value should be replaced
|
|
40
|
+
* @param value the new value
|
|
41
|
+
* @param timeout how long to wait for the predicate to be satisfied
|
|
42
|
+
* @return the supplied value if and only if the condition is satisfied
|
|
43
|
+
* @throws IllegalArgumentException if predicate is not defined
|
|
44
|
+
*/
|
|
45
|
+
consumeWhen(predicate: RequiredType<PredicateType<T>>, value: SupplierType<T>, timeout?: Duration): Promise<OptionalType<T>>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Determine if the given instance is a WaitableConsumer
|
|
49
|
+
*
|
|
50
|
+
* @param instance the instance to check
|
|
51
|
+
* @return true if the instance is a WaitableConsumer
|
|
52
|
+
*/
|
|
53
|
+
export declare function guard<T>(instance: unknown): instance is RequiredType<WaitableConsumer<T>>;
|
|
54
|
+
//# sourceMappingURL=WaitableConsumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitableConsumer.d.ts","sourceRoot":"","sources":["../../src/api/WaitableConsumer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAAE,QAAQ,EAElB,YAAY,EAAE,aAAa,EAC3B,YAAY,EACZ,YAAY,EACb,MAAM,qCAAqC,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;IAEtD;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAEtC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,SAAS,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAE9F;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,SAAS,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9H;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAMzF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Determine if the given instance is a WaitableConsumer
|
|
4
|
+
*
|
|
5
|
+
* @param instance the instance to check
|
|
6
|
+
* @return true if the instance is a WaitableConsumer
|
|
7
|
+
*/
|
|
8
|
+
export function guard(instance) {
|
|
9
|
+
return guardFunctions(instance, 'consume', 'consumeIf', 'consumeWhen');
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=WaitableConsumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitableConsumer.js","sourceRoot":"","sources":["../../src/api/WaitableConsumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAIf,MAAM,qCAAqC,CAAC;AAmD7C;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAC5B,SAAS,EACT,WAAW,EACX,aAAa,CACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Contract } from "@jonloucks/contracts-ts";
|
|
2
|
+
import { RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
3
|
+
import { Waitable, Config } from "@jonloucks/concurrency-ts/api/Waitable";
|
|
4
|
+
/**
|
|
5
|
+
* Waitable Factory
|
|
6
|
+
*/
|
|
7
|
+
export interface WaitableFactory {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new Waitable with the given initial value
|
|
10
|
+
*
|
|
11
|
+
* @param config the configuration for the waitable (null is not allowed)
|
|
12
|
+
* @return the waitable
|
|
13
|
+
* @param <T> the type of waitable
|
|
14
|
+
* @throws IllegalArgumentException if initialValue is null
|
|
15
|
+
*/
|
|
16
|
+
createWaitable<T>(config?: Config<T>): RequiredType<Waitable<T>>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Determine if the given instance is a WaitableFactory
|
|
20
|
+
*
|
|
21
|
+
* @param instance the instance to check
|
|
22
|
+
* @return true if the instance is a WaitableFactory
|
|
23
|
+
*/
|
|
24
|
+
export declare function guard(instance: unknown): instance is RequiredType<WaitableFactory>;
|
|
25
|
+
/**
|
|
26
|
+
* Contract for WaitableFactory
|
|
27
|
+
*/
|
|
28
|
+
export declare const CONTRACT: Contract<WaitableFactory>;
|
|
29
|
+
//# sourceMappingURL=WaitableFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitableFactory.d.ts","sourceRoot":"","sources":["../../src/api/WaitableFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAkB,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,eAAe;IAE9B;;;;;;;OAOG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CAClE;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,eAAe,CAAC,CAElF;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAG7C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createContract } from "@jonloucks/contracts-ts";
|
|
2
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
3
|
+
/**
|
|
4
|
+
* Determine if the given instance is a WaitableFactory
|
|
5
|
+
*
|
|
6
|
+
* @param instance the instance to check
|
|
7
|
+
* @return true if the instance is a WaitableFactory
|
|
8
|
+
*/
|
|
9
|
+
export function guard(instance) {
|
|
10
|
+
return guardFunctions(instance, 'createWaitable');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Contract for WaitableFactory
|
|
14
|
+
*/
|
|
15
|
+
export const CONTRACT = createContract({
|
|
16
|
+
name: "WaitableFactory",
|
|
17
|
+
test: guard
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=WaitableFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitableFactory.js","sourceRoot":"","sources":["../../src/api/WaitableFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAgB,MAAM,qCAAqC,CAAC;AAmBnF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACrC,OAAO,cAAc,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA8B,cAAc,CAAC;IAChE,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,KAAK;CACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
import { Type as ConsumerType } from "@jonloucks/concurrency-ts/auxiliary/Consumer";
|
|
3
|
+
import { Type as PredicateType } from "@jonloucks/concurrency-ts/auxiliary/Predicate";
|
|
4
|
+
import { AutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
5
|
+
export { type AutoClose, type ConsumerType, type PredicateType, type RequiredType };
|
|
6
|
+
/**
|
|
7
|
+
* Notify lister when condition is satisfied
|
|
8
|
+
* @param <T> the type of value
|
|
9
|
+
*/
|
|
10
|
+
export interface WaitableNotify<T> {
|
|
11
|
+
/**
|
|
12
|
+
* When condition is satisfied the listener is invoked
|
|
13
|
+
* Note: It is likely the listener will be called within a write lock context.
|
|
14
|
+
* Deadlocks could happen of listener is waiting on another thread to acquire a lock to this WaitableNotify
|
|
15
|
+
*
|
|
16
|
+
* @param predicate the predicate to test if the value should be passed to listener
|
|
17
|
+
* @param listener the listener
|
|
18
|
+
* @return AutoClose which removes the listener
|
|
19
|
+
* @throws IllegalArgumentException if predicate is null or the listener is null
|
|
20
|
+
*/
|
|
21
|
+
notifyWhile(predicate: RequiredType<PredicateType<T>>, listener: RequiredType<ConsumerType<T>>): RequiredType<AutoClose>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Duck type guard check for WaitableNotify
|
|
25
|
+
*
|
|
26
|
+
* @param value the value to check
|
|
27
|
+
* @param <T> the type of value
|
|
28
|
+
* @returns true if value is WaitableNotify, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
export declare function guard<T>(value: unknown): value is RequiredType<WaitableNotify<T>>;
|
|
31
|
+
//# sourceMappingURL=WaitableNotify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitableNotify.d.ts","sourceRoot":"","sources":["../../src/api/WaitableNotify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAElE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,CAAC;AAEpF;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAE/B;;;;;;;;;KASC;IACD,WAAW,CAAC,SAAS,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;CAC1H;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAEjF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Duck type guard check for WaitableNotify
|
|
4
|
+
*
|
|
5
|
+
* @param value the value to check
|
|
6
|
+
* @param <T> the type of value
|
|
7
|
+
* @returns true if value is WaitableNotify, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export function guard(value) {
|
|
10
|
+
return guardFunctions(value, 'notifyWhile');
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=WaitableNotify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitableNotify.js","sourceRoot":"","sources":["../../src/api/WaitableNotify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,qCAAqC,CAAC;AA0BnF;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAI,KAAc;IACrC,OAAO,cAAc,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Duration, OptionalType, RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
import { Type as PredicateType } from "@jonloucks/concurrency-ts/auxiliary/Predicate";
|
|
3
|
+
import { Supplier } from "@jonloucks/concurrency-ts/auxiliary/Supplier";
|
|
4
|
+
export { type RequiredType, type OptionalType, type Duration, type PredicateType, type Supplier };
|
|
5
|
+
/**
|
|
6
|
+
* Waitable supplier
|
|
7
|
+
* @param <T> the type of value supplied
|
|
8
|
+
*/
|
|
9
|
+
export interface WaitableSupplier<T> extends Supplier<T> {
|
|
10
|
+
/**
|
|
11
|
+
* @return Get current value
|
|
12
|
+
*/
|
|
13
|
+
supply(): T;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the current value if it satisfies a condition
|
|
16
|
+
*
|
|
17
|
+
* In languages that support synchronization this method would lock before checking the predicate. In JavaScript/TypeScript this is not possible so
|
|
18
|
+
* this method creates a one-time promise that evaluates the predicate against the current value.
|
|
19
|
+
* If the predicate is satisfied the promise resolves with the current value.
|
|
20
|
+
*
|
|
21
|
+
* @param predicate the predicate
|
|
22
|
+
* @return the current value if and only if the condition is satisfied
|
|
23
|
+
* @throws IllegalArgumentException if predicate is null or if value is null
|
|
24
|
+
*/
|
|
25
|
+
supplyIf(predicate: PredicateType<T>): OptionalType<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Waits until the current value if it satisfies a condition or a timeout is reached
|
|
28
|
+
*
|
|
29
|
+
* In languages that support synchronization this method would lock before checking the predicate. In JavaScript/TypeScript this is not possible so
|
|
30
|
+
* this method creates a one-time promise that evaluates the predicate against the current value.
|
|
31
|
+
* If the predicate is satisfied the promise resolves with the current value.
|
|
32
|
+
*
|
|
33
|
+
* if the predicate is not satisfied the promise remains pending until either:
|
|
34
|
+
* - another thread updates the value and the predicate is satisfied, or
|
|
35
|
+
* - the optional timeout elapses
|
|
36
|
+
*
|
|
37
|
+
* In languages that support synchronization this method would lock
|
|
38
|
+
*
|
|
39
|
+
* @param predicate the predicate to test if the value satisfies the stop waiting condition
|
|
40
|
+
* @param timeout the time to wait for the value to satisfy the predicate
|
|
41
|
+
* @return the current value if and only if the condition is satisfied
|
|
42
|
+
* @throws IllegalArgumentException if predicate is null, duration is null, or duration is negative
|
|
43
|
+
*/
|
|
44
|
+
supplyWhen(predicate: RequiredType<PredicateType<T>>, timeout?: Duration): Promise<T>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Determine if the given instance is a WaitableSupplier
|
|
48
|
+
*
|
|
49
|
+
* @param instance the instance to check
|
|
50
|
+
* @return true if the instance is a WaitableSupplier
|
|
51
|
+
*/
|
|
52
|
+
export declare function guard<T>(instance: unknown): instance is RequiredType<WaitableSupplier<T>>;
|
|
53
|
+
//# sourceMappingURL=WaitableSupplier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitableSupplier.d.ts","sourceRoot":"","sources":["../../src/api/WaitableSupplier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,qCAAqC,CAAC;AAE3G,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,8CAA8C,CAAC;AAExE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,CAAA;AAEjG;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;IAEtD;;OAEG;IACH,MAAM,IAAI,CAAC,CAAC;IAEZ;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAEvD;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,CAAC,SAAS,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACvF;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAMzF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Determine if the given instance is a WaitableSupplier
|
|
4
|
+
*
|
|
5
|
+
* @param instance the instance to check
|
|
6
|
+
* @return true if the instance is a WaitableSupplier
|
|
7
|
+
*/
|
|
8
|
+
export function guard(instance) {
|
|
9
|
+
return guardFunctions(instance, 'supply', 'supplyIf', 'supplyWhen');
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=WaitableSupplier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitableSupplier.js","sourceRoot":"","sources":["../../src/api/WaitableSupplier.ts"],"names":[],"mappings":"AACA,OAAO,EAAwC,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAoD3G;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAC5B,QAAQ,EACR,UAAU,EACV,YAAY,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Duration, OptionalType, RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
import { illegalCheck, presentCheck, configCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
3
|
+
export { presentCheck, illegalCheck, configCheck };
|
|
4
|
+
/**
|
|
5
|
+
* Check that a state is present
|
|
6
|
+
*
|
|
7
|
+
* @param state the state to check
|
|
8
|
+
* @return the state if present
|
|
9
|
+
* @throws IllegalArgumentException if the state is not present
|
|
10
|
+
*/
|
|
11
|
+
export declare function stateCheck<T>(state: T): T;
|
|
12
|
+
/**
|
|
13
|
+
* Check that an event is present
|
|
14
|
+
*
|
|
15
|
+
* @param event the event to check
|
|
16
|
+
* @return the event if present
|
|
17
|
+
* @throws IllegalArgumentException if the event is not present
|
|
18
|
+
*/
|
|
19
|
+
export declare function eventCheck(event: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Check that a rule is present
|
|
22
|
+
*
|
|
23
|
+
* @param rule the rule to check
|
|
24
|
+
* @return the rule if present
|
|
25
|
+
* @throws IllegalArgumentException if the rule is not present
|
|
26
|
+
*/
|
|
27
|
+
export declare function ruleCheck<T>(rule: T): T;
|
|
28
|
+
/**
|
|
29
|
+
* Check that rules are present
|
|
30
|
+
*
|
|
31
|
+
* @param rules the rules to check
|
|
32
|
+
* @return the rules if present
|
|
33
|
+
* @throws IllegalArgumentException if the rules are not present
|
|
34
|
+
*/
|
|
35
|
+
export declare function rulesCheck<T>(rules: readonly T[]): readonly T[];
|
|
36
|
+
/**
|
|
37
|
+
* Check that a listener is present
|
|
38
|
+
*
|
|
39
|
+
* @param consumer the listener to check
|
|
40
|
+
* @return the listener if present
|
|
41
|
+
* @throws IllegalArgumentException if the listener is not present
|
|
42
|
+
*/
|
|
43
|
+
export declare function listenerCheck<T>(consumer: T): T;
|
|
44
|
+
/**
|
|
45
|
+
* Check that a timeout is valid
|
|
46
|
+
*
|
|
47
|
+
* @param timeout the timeout to check
|
|
48
|
+
* @return the timeout if valid
|
|
49
|
+
* @throws IllegalArgumentException if the timeout is not valid
|
|
50
|
+
*/
|
|
51
|
+
export declare function timeoutCheck(timeout: Duration): Duration;
|
|
52
|
+
/**
|
|
53
|
+
* Check that a completion value is present
|
|
54
|
+
*
|
|
55
|
+
* @param completion the completion value to check
|
|
56
|
+
* @return the completion value if present
|
|
57
|
+
* @throws IllegalArgumentException if the completion value is not present
|
|
58
|
+
*/
|
|
59
|
+
export declare function completionCheck<T>(completion: OptionalType<T>): RequiredType<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Check that an onCompletion consumer is present
|
|
62
|
+
*
|
|
63
|
+
* @param onCompletion the onCompletion consumer to check
|
|
64
|
+
* @return the onCompletion consumer if present
|
|
65
|
+
* @throws IllegalArgumentException if the onCompletion consumer is not present
|
|
66
|
+
*/
|
|
67
|
+
export declare function onCompletionCheck<T>(onCompletion: OptionalType<T>): RequiredType<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Check that a finally block is present
|
|
70
|
+
*
|
|
71
|
+
* @param block the finally block to check
|
|
72
|
+
* @return the finally block if present
|
|
73
|
+
* @throws IllegalArgumentException if the finally block is not present
|
|
74
|
+
*/
|
|
75
|
+
export declare function finallyBlockCheck<T>(block: OptionalType<T>): RequiredType<T>;
|
|
76
|
+
/**
|
|
77
|
+
* Check that a success block is present
|
|
78
|
+
*
|
|
79
|
+
* @param onSuccess the success block to check
|
|
80
|
+
* @return the success block if present
|
|
81
|
+
* @throws IllegalArgumentException if the success block is not present
|
|
82
|
+
*/
|
|
83
|
+
export declare function successBlockCheck<T>(onSuccess: OptionalType<T>): RequiredType<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Check that a failure block is present
|
|
86
|
+
*
|
|
87
|
+
* @param onFailure the failure block to check
|
|
88
|
+
* @return the failure block if present
|
|
89
|
+
* @throws IllegalArgumentException if the failure block is not present
|
|
90
|
+
*/
|
|
91
|
+
export declare function failureBlockCheck<T>(onFailure: OptionalType<T>): RequiredType<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Check that a predicate is present
|
|
94
|
+
*
|
|
95
|
+
* @param predicate the predicate to check
|
|
96
|
+
* @return the predicate if present
|
|
97
|
+
* @throws IllegalArgumentException if the predicate is not present
|
|
98
|
+
*/
|
|
99
|
+
export declare function predicateCheck<T>(predicate: OptionalType<T>): RequiredType<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Check that an initial value is present
|
|
102
|
+
*
|
|
103
|
+
* @param initialValue the initial value to check
|
|
104
|
+
* @return the initial value if present
|
|
105
|
+
* @throws IllegalArgumentException if the initial value is not present
|
|
106
|
+
*/
|
|
107
|
+
export declare function initialValueCheck<T>(initialValue: OptionalType<T>): RequiredType<T>;
|
|
108
|
+
/**
|
|
109
|
+
* explicitly mark a value as used to avoid compiler warnings
|
|
110
|
+
* useful for "using" variable which are used for disposal or other side-effects
|
|
111
|
+
* but not directly referenced in code.
|
|
112
|
+
*
|
|
113
|
+
* @param value the value which you wish to declare as used
|
|
114
|
+
*/
|
|
115
|
+
export declare const used: (value: unknown) => void;
|
|
116
|
+
//# sourceMappingURL=Checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checks.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Checks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,YAAY,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEnG,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAC,CAAC;AAElD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAEvC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAKxD;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAE/E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEnF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAE5E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEhF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEhF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAE7E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAEnF;AAED;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAC7B,IACkC,CAAA"}
|