@nanomatic/object_filter
v1.0.1
Published
Library that allows filtering the object by passed regular expressions
Downloads
1
Maintainers
Readme
📝 Table of Contents
🏁 Getting Started
Installing
npm i @nanomatic/object_filter
Using
Example code below:
import { getArray, getObject } from '@nanomatic/object_filter';
const salary = {
Bill: 1350,
Jackson: 1270,
Jenny: 1100,
Jhon: 1200,
Joseph: 1500
};
const array = getArray(salary, /^J/);
const object = getObject(salary, /^B/);
const sum = array.reduce((sum: number, salary: number) => sum + salary, 0);
console.log(`Sum salary for all J's persons: 💲${sum}`);
console.log(`Jenny salary: 💲${object.Jeny || '?'}`);
console.log(`Bill salary: 💲${object.Bill || '?'}`);
⛏️ Built With
- ts-node-dev - TypeScript Node Dev
- tsc-watch - The nodemon for TypeScript
- TSLint - TypeScript linter
- NodeJs - Test Environment
✍️ Authors
- @NANOmatic - Idea & Initial work
🎉 Acknowledgments
- Special thanks for Sebastian for working together and giving ideas 😉