UNPKG

@extra-array/reject

Version:

Discards values which pass a test.

54 lines (40 loc) 1.77 kB
Discards values which pass a test. [:package:](https://www.npmjs.com/package/@extra-array/reject) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/reject) [:vhs:](https://asciinema.org/a/339802) [:moon:](https://www.npmjs.com/package/@extra-array/reject.min) [:scroll:](https://unpkg.com/@extra-array/reject/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [reject], [reject$], [rejectAt].<br> > Similar: [map], [filter], [reject], [reduce], [accumulate]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.reject(x, ft); // x: an array // ft: test function (v, i, x) ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 4, 5]; array.reject(x, v => v % 2 === 1); // [ 2, 4 ] array.reject(x, v => v % 2 === 0); // [ 1, 3, 5 ] ``` <br> <br> ## References - [Data.List.filter: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:filter) - [Array.prototype.filter: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) - [iterable_filter: PHP](https://www.php.net/manual/en/function.iterable-filter.php) [reject]: https://github.com/nodef/extra-array/wiki/reject [reject$]: https://github.com/nodef/extra-array/wiki/reject$ [rejectAt]: https://github.com/nodef/extra-array/wiki/rejectAt [map]: https://github.com/nodef/extra-array/wiki/map [filter]: https://github.com/nodef/extra-array/wiki/filter [reduce]: https://github.com/nodef/extra-array/wiki/reduce [accumulate]: https://github.com/nodef/extra-array/wiki/accumulate