Fp-filters – A curated collection of TS/JS array filter functions
Fp-filters – A curated collection of TS/JS array filter functions
Hello HN, I wanted to share a library I've been working on called: fp-filters - A curated collection of 130+ common-use filter functions that are written (and can be used) in a functional programming style. Why I built this: I have noticed in several codebases the tendency to keep writing the same or similar filter functions over and over again. Often inlined, taxing readability. And realized that most of them do pretty much the same N things. Therefore they could be isolated, curated, and maintained separately. fp-filters provides 130+ composable, point-free filtering functions that make data transformation pipelines more readable and maintainable. All functions are predicates and can be used as such, but they shine when used as filters. Key features: 1. Pure functional approach with no side effects 2. Composable predicates (and, or, not combinators through fp-booleans) 3. Common filter patterns as reusable functions 4. Type safety with TypeScript definitions 5. Exported as both esm and cjs 6. Zero dependencies, tiny footprint 7. Individual exports. Tree shaking is not even needed. 8. 100% test coverage Example usage: const input = [[1, 2, 3], [2, 4], [0, 4, 8, 16]]; // JS input.filter((array) => array.every((element) => element % 2 === 0)); // fp-filters input.filter(everyElement(isEven)) // JS dates.filter((date) => { const day = date.getDay(); return day === 0 || day === 6; }); // fp-filters dates.filter(isWeekend); // JS array.filter((arg) => arg.length > 0); // fp-filters array.filter(isNotEmpty); What makes this different: Unlike lodash/fp or ramda, fp-filters focuses specifically on array filtering patterns with an emphasis on readability in complex data transformations. It's designed to be intuitive for developers already familiar with JavaScript's array methods while providing the benefits of functional composition. The project is MIT licensed and open to contributions. I'd love to hear feedback from the HN community. Links: npm: https://www.npmjs.com/package/fp-filters GitHub: https://github.com/Oaxoa/fp-filters Documentation: https://oaxoa.github.io/fp-filters Thanks for checking it out
Share cardActual performance
Launch Intel predictions
Analyze your own launch →Correct prediction on native model
Similar products
Search and filter your boardgame collection
Curated collection of greatest explainers from all over the world
VueToolbox – Collection of the best Vue.js libraries
Collection of the best Vue.js libraries.
Easy Filters – Collection of Image Filters (iOS)
Curated collection of stories and poetry by talented writers
A curated collection of entrepreneurial podcasts
Filters for Eloquent
Stable Diffusion Without Filters
Decruft your Rails filters with FilterDecrufter