mobily/ts-belt

A.dropWhile is completely broken

Opened this issue · 1 comments

A.dropWhile drops ALL items matching the predicate. It behaves exactly like A.reject:

import {A,D} from "@mobily/ts-belt"

console.log(
  A.dropWhile([0 ,           1, 0, 0, 0], (x) => x == 0),       // should drop the first zero
  A.reject   ([0 ,           1, 0, 0, 0], (x) => x == 0),       // should drop all zeros
  A.dropWhile([{},{foo: "Bar"},{},{},{}], (x) => D.isEmpty(x)), // should drop the first empty obj
  A.reject([{},{foo: "Bar"},{},{},{}], (x) => D.isEmpty(x)),    // should drop all empty objs
)
[ 1 ] // dropWhile, expected [ 1, 0, 0, 0 ]
[ 1 ] // reject
[ { foo: 'Bar' } ] // dropWhile, expected [ { foo: 'Bar' }, {}, {}, {} ]
[ { foo: 'Bar' } ] // reject

Hi. I made a PR to resolve this issue. please have a look and let me know if it's right.