Skip to content

v2.1.0

Choose a tag to compare

@nvie nvie released this 10 Apr 19:54
· 153 commits to main since this release
  • The following functions retain richer type information about their arguments:

    • ifilter()
    • filter()
    • partition()

    For example, TypeScript will now know the following:

    const items = [3, 'hi', -7, 'foo', 13];
    
    function isNum(value: unknown): value is number {
        return typeof value === 'number';
    }
    
    const numbers: number[] = filter(items, isNum); // ✅
    
    const [numbers, strings] = partition(items, isNum); // ✅
    //     ^^^^^^^  ^^^^^^^ string[]
    //     number[]
  • Add new find(iterable, pred) function, which is almost the same as first(iterable, pred) but behaves slightly more intuitive in the case where no predicate function is given.

  • Fix bug in chunked() with size=1