π Smart, precise type-detection and exclusion filtering for data cleaning
Features β’ Installation β’ Usage β’ API Reference β’ Performance
RozFil is a lightweight, precise JavaScript utility library built to solve one of JS's biggest headaches: data cleaning and type identification. Instead of writing messy, repetitive conditional loops, RozFil allows you to seamlessly exclude and filter out unwanted data types, exact values, or even stringified data structures from your collections.
Whether you're handling dirty datasets or need strict type-safe exclusion, RozFil provides predictable tools without unnecessary library overhead.
- Pure, predictable logic with zero global state side-effects
- Lightweight footprint with zero third-party dependencies
- Clean, composable API design
- Fixes traditional
typeoflimitations (correctly distinguishes between Arrays and Objects) - Reliable handling of JS edge cases (NaN, Infinity, etc.)
- Predictable behavior across different native data types
- Intelligent detection for text-wrapped structures
- Able to detect
'[]','{}', or'1'as their actual semantic types
- Native ES Modules (
import/export) - Clean, organized file structure with intelligent indexing
- Easy to integrate into modern JavaScript projects
- Multiple exclusion strategies for arrays
arrUtils.fbType- Exclude by basic JS typearrUtils.fbExType- Exclude by exact type matching (differentiates NaN from numbers)arrUtils.fbTypeSmart- Intelligent exclusion including stringified typesarrUtils.fbVal- Exclude by exact valuearrUtils.fbIncludeVal- Exclude by value inclusion
git clone https://github.com/OmarPGH/RozFil.git
cd RozFilimport { arrUtils, objUtils } from './src/index.js';npm install rozfilπ‘ IMPORTANT NOTE: RozFil filters operate on an exclusion basis. The types or values you pass to the functions are the ones that will be removed from your array.
import { arrUtils } from './src/index.js';
const data = [
1,
'hello',
NaN,
[],
'[]',
'123',
undefined,
null
];
// params : [inPlace, arr, ...input]
// 1. Standard exclusion (Removes basic JS types)
const noNumbers = arrUtils.fbType(false, data, 'number'); (Note: false to clone the array instead of edit it)
// Result: ['hello', [], '[]', '123', undefined, null] (Note: NaN is technically a 'number' in JS!)
// 2. Exact type exclusion (Differentiates NaN from numbers, Arrays from Objects)
const strictClean = arrUtils.fbExType(false, data, 'NaN', 'arr');
// Result: [1, 'hello', '[]', '123', undefined, null]
// 3. Smart type exclusion (Detects types inside strings!)
const smartClean = arrUtils.fbTypeSmart(false, data, 'arr', 'num');
// Result: ['hello', NaN, undefined, null] (Removed both native arrays / numbers and '[]' / '123' strings)RozFil is engineered to be lightweight and reliable for everyday data manipulation:
| Feature | Benefit |
|---|---|
| Native Execution | Relies on standard, optimized JavaScript loops |
| Predictable Flow | Processes data directly without complex abstractions |
| Zero Dependencies | Ensures your node_modules stays clean and secure |
| Lightweight | No heavy wrapper objects or unnecessary overhead |
| Strict Type Safety | Prevents runtime errors caused by unexpected data types |
RozFil/
βββ src/
β βββ index.js # Main entry point
β βββ arrUtils/ # Array utilities module
β β βββ index.js
β β βββ filterByType.js # Basic type-exclusion
β β βββ filterByExactType.js # Strict type exclusion
β β βββ filterByTypeSmart.js # Advanced exclusion (stringified types)
β β βββ filterByValue.js # Exact value exclusion
β β βββ filterByIncludeValue.js # Value inclusion exclusion
β β βββ translator.js # Type translation utilities
β β βββ regexBook.js # Regex patterns library
β βββ objUtils/ # Object utilities module (WIP)
β βββ index.js
β βββ filterByType.js
β βββ translator.js
β βββ regexBook.js
βββ package.json
βββ test.js
βββ README.md
| Method | Description | Signature |
|---|---|---|
| arrUtils.fbType() | Excludes items matching basic JS types | arrUtils.fbType(array, ...types) |
| arrUtils.fbExType() | Excludes items matching exact types | arrUtils.fbExType(array, ...types) |
| arrUtils.fbTypeSmart() | Excludes items using smart string detection | arrUtils.fbTypeSmart(array, ...types) |
| arrUtils.fbVal() | Excludes matching exact values | arrUtils.fbVal(array, value) |
| arrUtils.fbIncludeVal() | Excludes items containing the value | arrUtils.fbIncludeVal(array, value) |
| arrUtils.translate() | Type translation utility | arrUtils.translate(value) |
| arrUtils.reBook | Regex patterns dictionary | arrUtils.reBook.{pattern} |
π§ Currently In Development
- β Data Cleaning: Remove invalid, unwanted, or corrupted entries from datasets.
- β Type Safety: Ensure only clean, specific types remain in your collections.
- β API Response Handling: Strip out null, undefined, or stringified empty objects received from backend APIs.
- β Form Validation: Clean up mixed user inputs effortlessly.
| Component | Status |
|---|---|
| Array Utils (arrUtils) | β Ready |
| Object Utils (objUtils) | π§ In Development |
| Documentation | β Complete |
| Tests | π§ In Progress |
Contributions are welcome! Whether you have ideas for new exact types, optimizing the regex books, or fixing bugs:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the GNU Lesser General Public License v3.0 only / LGPL-3.0-only License - see the LICENSE file for details.
Omar Gamal - Creator & Maintainer
- Built to make JavaScript type-checking actually make sense.
- Community feedback and contributions.
Found a bug? Have a suggestion for a new smart type?
- Open an issue on GitHub
- Reach out with your feedback