Function same

  • Creates an endless Stream of the provided value. One use case is zipping with another stream to remember some state.

    // Find items inside quotes
    streamOf('a', '"', 'b', 'c', '"', 'd', '"', 'e', '"', 'f')
    .zip(same({inQuotes: false}))
    .peek(([c, st]) => {
    if (c === '"') st.inQuotes = !st.inQuotes
    })
    .filter(([c, {inQuotes}]) => c !== '"' && inQuotes)
    .map(([c]) => c) // Unzip state
    .toArray() // => ['b', 'c', 'e']

    Type Parameters

    • T

      Value type

    Parameters

    • value: T

      An item to repeat endlessly

    Returns Stream<T>

    An endless stream of the provided value.