Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 12x 12x 12x 267x 20x 20x 20x 20x 267x 267x 267x 267x | import { RequiredType } from "@jonloucks/concurrency-ts/api/Types";
import { Config as WaitableConfig, Waitable } from "@jonloucks/concurrency-ts/api/Waitable";
import { WaitableFactory } from "@jonloucks/concurrency-ts/api/WaitableFactory";
import { Config as ConcurrencyConfig, Contracts } from "@jonloucks/concurrency-ts/api/Concurrency";
import { create as createWaitableImpl } from "./Waitable.impl";
import { Internal } from "./Internal.impl";
/**
* Create a new WaitableFactory
*
* @return the new WaitableFactory
*/
export function create(config: ConcurrencyConfig): WaitableFactory {
return WaitableFactoryImpl.internalCreate(config);
}
// ---- Implementation details below ----
class WaitableFactoryImpl implements WaitableFactory {
createWaitable<T>(config?: WaitableConfig<T>): RequiredType<Waitable<T>> {
const validConfig = config ?? {};
const contracts: Contracts = Internal.resolveContracts(validConfig, this.#concurrencyConfig);
const finalConfig: WaitableConfig<T> = { ...validConfig, contracts: contracts };
return createWaitableImpl(finalConfig);
}
static internalCreate(config: ConcurrencyConfig): WaitableFactory {
return new WaitableFactoryImpl(config);
}
private constructor(config: ConcurrencyConfig) {
const contracts: Contracts = Internal.resolveContracts(config);
this.#concurrencyConfig = { ...config, contracts: contracts };
}
readonly #concurrencyConfig: ConcurrencyConfig;
}; |