All files / src/api WaitableFactory.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 5/5

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 3712x 12x                                                 12x 27x           12x      
import { Contract, createContract,RequiredType } from "@jonloucks/contracts-ts";
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
import { Waitable, Config } from "@jonloucks/concurrency-ts/api/Waitable";
 
/**
 * Waitable Factory
 */
export interface WaitableFactory {
 
  /**
   * Create a new Waitable with the given initial value
   *
   * @param config the configuration for the waitable (null is not allowed)
   * @return the waitable
   * @param <T> the type of waitable
   * @throws IllegalArgumentException if initialValue is null
   */
  createWaitable<T>(config?: Config<T>): RequiredType<Waitable<T>>;
}
 
/**
 * Determine if the given instance is a WaitableFactory
 *
 * @param instance the instance to check
 * @return true if the instance is a WaitableFactory
 */
export function guard(instance: unknown): instance is RequiredType<WaitableFactory> {
  return guardFunctions(instance, 'createWaitable');
}
 
/**
 * Contract for WaitableFactory
 */
export const CONTRACT: Contract<WaitableFactory> = createContract({
  name: "WaitableFactory",
  test: guard
});