TS-Scribe - v1.2.0
    Preparing search index...

    Function pipe

    • Composes functions from left to right, threading the return value of each function as the argument to the next. Returns a new function that, when called, passes the initial value through the entire pipeline.

      For composing async functions (or mixing sync and async), see asyncPipe.

      Returns <T>(x: T) => T

      A function that passes its argument through every function in order.

      // Basic usage
      const add1 = (n: number) => n + 1;
      const double = (n: number) => n * 2;
      const add1ThenDouble = pipe(add1, double);

      add1ThenDouble(3); // (3 + 1) * 2 = 8
      // With zero arguments — returns identity
      const id = pipe();
      id(42); // 42
      // With ts-scribe utilities
      import { slugify, toCamelCase } from 'ts-scribe';

      const normalize = pipe(
      (s: string) => s.trim(),
      toCamelCase,
      slugify,
      );

      normalize(' Hello World '); // 'helloWorld'
    • Composes functions from left to right, threading the return value of each function as the argument to the next. Returns a new function that, when called, passes the initial value through the entire pipeline.

      For composing async functions (or mixing sync and async), see asyncPipe.

      Type Parameters

      • A
      • B

      Parameters

      • f1: (x: A) => B

      Returns (x: A) => B

      A function that passes its argument through every function in order.

      // Basic usage
      const add1 = (n: number) => n + 1;
      const double = (n: number) => n * 2;
      const add1ThenDouble = pipe(add1, double);

      add1ThenDouble(3); // (3 + 1) * 2 = 8
      // With zero arguments — returns identity
      const id = pipe();
      id(42); // 42
      // With ts-scribe utilities
      import { slugify, toCamelCase } from 'ts-scribe';

      const normalize = pipe(
      (s: string) => s.trim(),
      toCamelCase,
      slugify,
      );

      normalize(' Hello World '); // 'helloWorld'
    • Composes functions from left to right, threading the return value of each function as the argument to the next. Returns a new function that, when called, passes the initial value through the entire pipeline.

      For composing async functions (or mixing sync and async), see asyncPipe.

      Type Parameters

      • A
      • B
      • C

      Parameters

      • f1: (x: A) => B
      • f2: (x: B) => C

      Returns (x: A) => C

      A function that passes its argument through every function in order.

      // Basic usage
      const add1 = (n: number) => n + 1;
      const double = (n: number) => n * 2;
      const add1ThenDouble = pipe(add1, double);

      add1ThenDouble(3); // (3 + 1) * 2 = 8
      // With zero arguments — returns identity
      const id = pipe();
      id(42); // 42
      // With ts-scribe utilities
      import { slugify, toCamelCase } from 'ts-scribe';

      const normalize = pipe(
      (s: string) => s.trim(),
      toCamelCase,
      slugify,
      );

      normalize(' Hello World '); // 'helloWorld'
    • Composes functions from left to right, threading the return value of each function as the argument to the next. Returns a new function that, when called, passes the initial value through the entire pipeline.

      For composing async functions (or mixing sync and async), see asyncPipe.

      Type Parameters

      • A
      • B
      • C
      • D

      Parameters

      • f1: (x: A) => B
      • f2: (x: B) => C
      • f3: (x: C) => D

      Returns (x: A) => D

      A function that passes its argument through every function in order.

      // Basic usage
      const add1 = (n: number) => n + 1;
      const double = (n: number) => n * 2;
      const add1ThenDouble = pipe(add1, double);

      add1ThenDouble(3); // (3 + 1) * 2 = 8
      // With zero arguments — returns identity
      const id = pipe();
      id(42); // 42
      // With ts-scribe utilities
      import { slugify, toCamelCase } from 'ts-scribe';

      const normalize = pipe(
      (s: string) => s.trim(),
      toCamelCase,
      slugify,
      );

      normalize(' Hello World '); // 'helloWorld'
    • Composes functions from left to right, threading the return value of each function as the argument to the next. Returns a new function that, when called, passes the initial value through the entire pipeline.

      For composing async functions (or mixing sync and async), see asyncPipe.

      Type Parameters

      • A
      • B
      • C
      • D
      • E

      Parameters

      • f1: (x: A) => B
      • f2: (x: B) => C
      • f3: (x: C) => D
      • f4: (x: D) => E

      Returns (x: A) => E

      A function that passes its argument through every function in order.

      // Basic usage
      const add1 = (n: number) => n + 1;
      const double = (n: number) => n * 2;
      const add1ThenDouble = pipe(add1, double);

      add1ThenDouble(3); // (3 + 1) * 2 = 8
      // With zero arguments — returns identity
      const id = pipe();
      id(42); // 42
      // With ts-scribe utilities
      import { slugify, toCamelCase } from 'ts-scribe';

      const normalize = pipe(
      (s: string) => s.trim(),
      toCamelCase,
      slugify,
      );

      normalize(' Hello World '); // 'helloWorld'
    • Composes functions from left to right, threading the return value of each function as the argument to the next. Returns a new function that, when called, passes the initial value through the entire pipeline.

      For composing async functions (or mixing sync and async), see asyncPipe.

      Type Parameters

      • A
      • B
      • C
      • D
      • E
      • F

      Parameters

      • f1: (x: A) => B
      • f2: (x: B) => C
      • f3: (x: C) => D
      • f4: (x: D) => E
      • f5: (x: E) => F

      Returns (x: A) => F

      A function that passes its argument through every function in order.

      // Basic usage
      const add1 = (n: number) => n + 1;
      const double = (n: number) => n * 2;
      const add1ThenDouble = pipe(add1, double);

      add1ThenDouble(3); // (3 + 1) * 2 = 8
      // With zero arguments — returns identity
      const id = pipe();
      id(42); // 42
      // With ts-scribe utilities
      import { slugify, toCamelCase } from 'ts-scribe';

      const normalize = pipe(
      (s: string) => s.trim(),
      toCamelCase,
      slugify,
      );

      normalize(' Hello World '); // 'helloWorld'
    • Composes functions from left to right, threading the return value of each function as the argument to the next. Returns a new function that, when called, passes the initial value through the entire pipeline.

      For composing async functions (or mixing sync and async), see asyncPipe.

      Type Parameters

      • A
      • B
      • C
      • D
      • E
      • F
      • G

      Parameters

      • f1: (x: A) => B
      • f2: (x: B) => C
      • f3: (x: C) => D
      • f4: (x: D) => E
      • f5: (x: E) => F
      • f6: (x: F) => G

      Returns (x: A) => G

      A function that passes its argument through every function in order.

      // Basic usage
      const add1 = (n: number) => n + 1;
      const double = (n: number) => n * 2;
      const add1ThenDouble = pipe(add1, double);

      add1ThenDouble(3); // (3 + 1) * 2 = 8
      // With zero arguments — returns identity
      const id = pipe();
      id(42); // 42
      // With ts-scribe utilities
      import { slugify, toCamelCase } from 'ts-scribe';

      const normalize = pipe(
      (s: string) => s.trim(),
      toCamelCase,
      slugify,
      );

      normalize(' Hello World '); // 'helloWorld'
    • Composes functions from left to right, threading the return value of each function as the argument to the next. Returns a new function that, when called, passes the initial value through the entire pipeline.

      For composing async functions (or mixing sync and async), see asyncPipe.

      Parameters

      • ...fns: ((x: any) => any)[]

        One or more functions to compose left-to-right.

      Returns (x: any) => any

      A function that passes its argument through every function in order.

      // Basic usage
      const add1 = (n: number) => n + 1;
      const double = (n: number) => n * 2;
      const add1ThenDouble = pipe(add1, double);

      add1ThenDouble(3); // (3 + 1) * 2 = 8
      // With zero arguments — returns identity
      const id = pipe();
      id(42); // 42
      // With ts-scribe utilities
      import { slugify, toCamelCase } from 'ts-scribe';

      const normalize = pipe(
      (s: string) => s.trim(),
      toCamelCase,
      slugify,
      );

      normalize(' Hello World '); // 'helloWorld'