Function guardPipe

  • Given one or multiple Type Guard as arguments, returns a Type Guard that checks if the given value matches all given Type Guard. Same as guardAll, but each Type Guard must implement the previous Type Guard output, which will be inferred up to 8 Type Guard.

    Example

    const isFooBar = guardPipe(
    matchType('string'),
    (val): val is `foo${string}` => val.startsWith('foo'),
    (val): val is 'foobar' => val === 'foobar'
    );

    const test = {} as unknown;
    if(isFooBar(test)){
    test; // 'foobar'
    }

    Type Parameters

    Parameters

    • Rest ...guard: readonly [A, B]

    Returns TypeGuardFn<GuardTypeInput<A>, GuardType<B>>

  • Given one or multiple Type Guard as arguments, returns a Type Guard that checks if the given value matches all given Type Guard. Same as guardAll, but each Type Guard must implement the previous Type Guard output, which will be inferred up to 8 Type Guard.

    Example

    const isFooBar = guardPipe(
    matchType('string'),
    (val): val is `foo${string}` => val.startsWith('foo'),
    (val): val is 'foobar' => val === 'foobar'
    );

    const test = {} as unknown;
    if(isFooBar(test)){
    test; // 'foobar'
    }

    Type Parameters

    Parameters

    • Rest ...guard: readonly [A, B, C]

    Returns TypeGuardFn<GuardTypeInput<A>, GuardType<C>>

  • Given one or multiple Type Guard as arguments, returns a Type Guard that checks if the given value matches all given Type Guard. Same as guardAll, but each Type Guard must implement the previous Type Guard output, which will be inferred up to 8 Type Guard.

    Example

    const isFooBar = guardPipe(
    matchType('string'),
    (val): val is `foo${string}` => val.startsWith('foo'),
    (val): val is 'foobar' => val === 'foobar'
    );

    const test = {} as unknown;
    if(isFooBar(test)){
    test; // 'foobar'
    }

    Type Parameters

    Parameters

    • Rest ...guard: readonly [A, B, C, D]

    Returns TypeGuardFn<GuardTypeInput<A>, GuardType<D>>

  • Given one or multiple Type Guard as arguments, returns a Type Guard that checks if the given value matches all given Type Guard. Same as guardAll, but each Type Guard must implement the previous Type Guard output, which will be inferred up to 8 Type Guard.

    Example

    const isFooBar = guardPipe(
    matchType('string'),
    (val): val is `foo${string}` => val.startsWith('foo'),
    (val): val is 'foobar' => val === 'foobar'
    );

    const test = {} as unknown;
    if(isFooBar(test)){
    test; // 'foobar'
    }

    Type Parameters

    Parameters

    • Rest ...guard: readonly [A, B, C, D, E]

    Returns TypeGuardFn<GuardTypeInput<A>, GuardType<E>>

  • Given one or multiple Type Guard as arguments, returns a Type Guard that checks if the given value matches all given Type Guard. Same as guardAll, but each Type Guard must implement the previous Type Guard output, which will be inferred up to 8 Type Guard.

    Example

    const isFooBar = guardPipe(
    matchType('string'),
    (val): val is `foo${string}` => val.startsWith('foo'),
    (val): val is 'foobar' => val === 'foobar'
    );

    const test = {} as unknown;
    if(isFooBar(test)){
    test; // 'foobar'
    }

    Type Parameters

    Parameters

    • Rest ...guard: readonly [A, B, C, D, E, F]

    Returns TypeGuardFn<GuardTypeInput<A>, GuardType<F>>

  • Given one or multiple Type Guard as arguments, returns a Type Guard that checks if the given value matches all given Type Guard. Same as guardAll, but each Type Guard must implement the previous Type Guard output, which will be inferred up to 8 Type Guard.

    Example

    const isFooBar = guardPipe(
    matchType('string'),
    (val): val is `foo${string}` => val.startsWith('foo'),
    (val): val is 'foobar' => val === 'foobar'
    );

    const test = {} as unknown;
    if(isFooBar(test)){
    test; // 'foobar'
    }

    Type Parameters

    Parameters

    • Rest ...guard: readonly [A, B, C, D, E, F, G]

    Returns TypeGuardFn<GuardTypeInput<A>, GuardType<G>>

  • Given one or multiple Type Guard as arguments, returns a Type Guard that checks if the given value matches all given Type Guard. Same as guardAll, but each Type Guard must implement the previous Type Guard output, which will be inferred up to 8 Type Guard.

    Example

    const isFooBar = guardPipe(
    matchType('string'),
    (val): val is `foo${string}` => val.startsWith('foo'),
    (val): val is 'foobar' => val === 'foobar'
    );

    const test = {} as unknown;
    if(isFooBar(test)){
    test; // 'foobar'
    }

    Type Parameters

    Parameters

    • Rest ...guard: readonly [A, B, C, D, E, F, G, H]

    Returns TypeGuardFn<GuardTypeInput<A>, GuardType<H>>

Generated using TypeDoc