• Converts an array of anything into a human friendly list.

    Returns a new array that contains the items separated by commas, except for the last item, which is separated by "and". This is useful for creating human-friendly sentences.

    Type Parameters

    • T

    Parameters

    • items: T[]

      Token[].

    Returns (T | string)[]

    Token[].

      const items = ['apple', 'banana', {command: "--flag"}];
    const result = asHumanFriendlyList(items)

    // ['apple', ',', 'banana', ',', 'and', {command: "--flag"}]
    console.log(result);