Ninjas Practicing Multidimensionality
    Wondering what’s next for npm?Check out our public roadmap! »

    @basic-streams/skip-duplicates
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    @basic-streams/skip-duplicates

    skipDuplicates<T>(
      comparator: (previous: T, next: T) => boolean,
      streamStream<T>,
    )Stream<T>

    Creates a stream containing each value x from the source stream if comparator(p, x) returns false, where p is the latest value produced from the resulting stream. The first event from source stream isn't tested and always comes through.

    import ofMany from "@basic-streams/of-many"
    import skipDuplicates from "@basic-streams/skip-duplicates"
     
    const stream = ofMany([1, 2, 2, 3], 5000)
     
    const result = skipDuplicates((a, b) => a === b, stream)
     
    result(x => {
      console.log(x)
    })
     
    // > 1
    // > 2
    // > 3
     
    // stream: ____1____2____2____3
    // result: ____1____2_________3

    Install

    npm i @basic-streams/skip-duplicates

    DownloadsWeekly Downloads

    4

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    4.6 kB

    Total Files

    8

    Last publish

    Collaborators

    • avatar