Function mapStr

  • Maps over each character in a string using the provided function.

    Type Parameters

    • T extends string

    Parameters

    • f: ((c) => string)

      Function to apply to each character

        • (c): string
        • Parameters

          • c: string

          Returns string

    Returns ((s) => string)

    A function that takes a string and returns the mapped string

      • (s): string
      • Parameters

        • s: T

        Returns string

    Example

    const toUpperCase = (c: string) => c.toUpperCase();
    mapStr(toUpperCase)('hello') // 'HELLO'
    mapStr(c => c === 'o' ? '0' : c)('hello world') // 'hell0 w0rld'
    * mapStr(c => c === 'r' ? 'ru' : c)('kirara') // 'kiruarua'
    mapStr(c => c === 'a' ? '' : c)('sango') // 'sngo'

Generated using TypeDoc