Getting Started โ
Welcome to @mcabreradev/filter - a powerful, SQL-like array filtering library for TypeScript and JavaScript with advanced pattern matching, MongoDB-style operators, deep object comparison, and zero dependencies.
What is @mcabreradev/filter? โ
Go beyond JavaScript's native Array.filter() with a library that understands your data:
- ๐ฏ SQL-like Wildcards - Use
%and_for flexible pattern matching - ๐ Deep Object Filtering - Search through nested objects up to configurable depths
- โก Zero Dependencies - Lightweight and production-ready (only Zod for runtime validation)
- ๐ Type-Safe - Built with strict TypeScript for maximum reliability
- ๐จ Multiple Strategies - String patterns, objects, predicates, operators, or custom comparators
- ๐ Performance Optimized - Optional caching and regex compilation optimization
- ๐ฆ MongoDB-Style Operators - 18 operators for advanced filtering (v5.0.0+)
- ๐จ Lazy Evaluation - Process large datasets efficiently with generators (v5.1.0+)
- ๐งช Battle-Tested - 300+ tests ensuring reliability
Why Choose This Library? โ
Developer Experience โ
The API is designed to be intuitive and familiar. If you know SQL wildcards or MongoDB queries, you already know how to use this library.
typescript
// Familiar SQL-like syntax
filter(users, '%@example.com%');
// MongoDB-style operators
filter(products, { price: { $gte: 100, $lte: 500 } });
// Simple object matching
filter(items, { category: 'Electronics', inStock: true });Performance โ
Built for production with multiple optimization strategies:
- 530x faster with result caching
- 500x faster with lazy evaluation for early exits
- Regex pattern caching for repeated queries
- Predicate memoization across different arrays
Type Safety โ
Full TypeScript support with strict typing:
typescript
interface User {
name: string;
age: number;
email: string;
}
const users: User[] = [...];
const result = filter<User>(users, { age: { $gte: 18 } });
// result is User[] with full type inferenceFramework Integration โ
First-class support for modern frameworks:
- React Hooks -
useFilter,useDebouncedFilter,usePaginatedFilter - Vue Composables - Full Composition API support with reactivity
- Svelte Stores - Reactive store-based filtering
Browser Support โ
Works in all modern browsers and Node.js:
- Node.js: >= 20
- Browsers: Chrome, Firefox, Safari, Edge (latest versions)
- TypeScript: >= 5.0
- Module Systems: ESM, CommonJS
Next Steps โ
- Installation - Install and set up the library
- Quick Start - Start filtering in minutes
- Operators Guide - Learn all 18 MongoDB-style operators
- Framework Integration - Integrate with React, Vue, or Svelte
Community & Support โ
- ๐ Complete Documentation
- ๐ฌ GitHub Discussions
- ๐ Issue Tracker
- โญ Star on GitHub