├── .gitignore ├── .prettierrc ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── core ├── __tests__ │ ├── multiLevelDepthFilter.test.ts │ └── oneLevelDepthFilter.test.ts ├── orbiter.ts └── workers │ ├── multiLevelDepthFilter.ts │ └── oneLevelDepthFilter.ts ├── jestconfig.json ├── orbit.md ├── package-lock.json ├── package.json ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | lib -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "trailingComma": "all", 4 | "singleQuote": true 5 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "conventionalCommits.scopes": [ 3 | "Orbit-Array-Querier" 4 | ] 5 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Orbit Turner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🟢 Array Querier 🔎 2 | [![Compatible Status](https://img.shields.io/badge/works%20with-ts/js-blue)](https://www.npmjs.com/package/array-querier) 3 | [![Code Size Status](https://img.shields.io/github/languages/code-size/orbitturner/array-querier)](https://www.npmjs.com/package/array-querier) 4 | [![Commit Status](https://img.shields.io/github/commit-activity/m/orbitturner/array-querier?color=red)](https://www.npmjs.com/package/array-querier) 5 | [![Issues Status](https://img.shields.io/github/issues/orbitturner/array-querier)](https://www.npmjs.com/package/array-querier) 6 | [![npm version](https://img.shields.io/npm/v/array-querier.svg)](https://www.npmjs.com/package/array-querier) [![license](https://img.shields.io/npm/l/array-querier.svg)](https://www.npmjs.com/package/array-querier) 7 | 8 | **Array-Querier** is a TS/JS [NPM](http://npmjs.com/) Package to Filter an Array of objects with multiple match-criteria. 9 | 10 |

11 | array-querier COVER 12 |

13 | 14 | 15 |

INSTALLATION

16 |

17 | 18 | 19 |

20 |
21 | 22 | ___ 23 | ## 📚 Table Of Contents 📑 24 | - [🟢 Array Querier 🔎](#---array-querier---) 25 | * [📚 Table Of Contents 📑](#---table-of-contents---) 26 | * [💨 What is this Library for? 🤔](#---what-is-this-library-for----) 27 | * [✨ Key Features 🎯](#--key-features---) 28 | * [📥 Installation 🔰](#---installation---) 29 | * [🤔 One-Level vs Multi-Level Depth JSON ? 🤔](#---one-level-vs-multi-level-depth-json-----) 30 | * [⚙ Usage: One-Level Depth Arrays (Simple Arrays) 🎚](#--usage--one-level-depth-arrays--simple-arrays----) 31 | + [➤ Querier.filterSimpleArray(yourData, filterObject); 🟢](#--querierfiltersimplearray-yourdata--filterobject-----) 32 | * [⚙ Usage: Multi-Level Depth Arrays (Complex Arrays) 🎛](#--usage--multi-level-depth-arrays--complex-arrays----) 33 | + [➤ Querier.filterComplexArray(yourData, filterObject); 🟢](#--querierfiltercomplexarray-yourdata--filterobject-----) 34 | * [Configuration Options](#configuration-options) 35 | * [Contributing ❤](#contributing--) 36 | * [Issue Reporting](#issue-reporting) 37 | * [GREETINGS](#greetings) 38 | * [Author](#author) 39 | * [License](#license) 40 | 41 | ___ 42 | 43 | ## 💨 What is this Library for? 🤔 44 | 45 | **array-querier** is a small library that is useful for filtering a `One Level or Multi Level Depth` array of objects with `multiple match-criteria`. The exposed methods **receives** an **array as the first argument**, and **a plain object describing the fields to filter as the last argument**. 46 | 47 | 48 | > **Note:** This library can only be used with typescript or js but you already know that 🤦🏿‍♂️. 49 | 50 | 51 | 52 | ## ✨ Key Features 🎯 53 | 54 | * Use it **without `Instanciation`** because all the methods are `Static`. 55 | * **Multi Level Depth Filtering** with complex filtering condition. 56 | * Optimized for Great Performance even with **Big Fat @/@ Arrays** of Objects. 57 | * ✅ TOO EASY TO USE !! 🥳🥳 58 | 59 | ___ 60 | 61 | ## 📥 Installation 🔰 62 | 63 | ```bash 64 | # installation with npm 65 | npm install array-querier 66 | 67 | # or you may prefer 68 | npm i --save array-querier 69 | 70 | # installation with yarn 71 | yarn add array-querier 72 | ``` 73 | 74 | **This HELPER relies on NOTHING SO YOU DON'T NEED ADDITIONNAL PACKAGES.** 75 | 76 | ___ 77 | ## 🤔 One-Level vs Multi-Level Depth JSON ? 🤔 78 | 79 | A JSON depth level is just an nesting of another object within a current JSON object. 80 | For example : 81 | If you have a User object as follows -> 82 | ```json 83 | // Nested Object Planet in User 84 | User = { 85 | "name": "Orbit", 86 | "age": 21, 87 | "planet": { 88 | "id": 4, 89 | "codename" : "Shadow-Coders", 90 | "galaxyName" : "Turner" 91 | } 92 | } 93 | ``` 94 | **Then User is an Array of two level Depth.** 95 | 96 | Of course if you don't have any nested object then you got an One level Depth. 97 | ___ 98 | 99 | 100 | 101 | ## ⚙ Usage: One-Level Depth Arrays (Simple Arrays) 🎚 102 | 103 | ### ➤ Querier.filterSimpleArray(yourData, filterObject); 🟢 104 | 105 | If you are only interested in filtering an simple array of **JSON objects** directly: 106 | 107 | ```ts 108 | import {Querier} from 'array-querier/lib/orbiter'; 109 | 110 | /** 111 | * Your array of JSON Objects. 112 | * This can be pulled directly from your Backend Rest API. 113 | */ 114 | const products = [ 115 | { name: 'A', color: 'Blue', size: 50 }, 116 | { name: 'B', color: 'Blue', size: 60 }, 117 | { name: 'C', color: 'Black', size: 70 }, 118 | { name: 'D', color: 'Green', size: 50 }, 119 | ]; 120 | 121 | // ⚠ You need a Filter Object to make your condition ⚠ 122 | const filters = { 123 | color: ['BLUE', 'black'], 124 | size: [70, 50], 125 | }; 126 | 127 | /** 128 | * Calling Simple Array Filterer In Query. 129 | * Filters an array of objects (one level-depth) with multiple criteria. 130 | * The function returns an array of the same type as the input array. 131 | */ 132 | const MyFilteredResult = Querier.filterSimpleArray(products, filters); 133 | 134 | console.table(MyFilteredResult); 135 | /* 🟢 The Result Will Be :🟢 136 | { name: 'A', color: 'Blue', size: 50 }, 137 | { name: 'C', color: 'Black', size: 70 }, 138 | */ 139 | ``` 140 | > **⚠ Note: ⚠** The `filterSimpleArray` method **IS NOT** **Case-Sensitive** 🚨. 141 | 142 | ___ 143 | ## ⚙ Usage: Multi-Level Depth Arrays (Complex Arrays) 🎛 144 | 145 | ### ➤ Querier.filterComplexArray(yourData, filterObject); 🟢 146 | 147 | In everyday life, as developers, our JSON arrays are often very complex because of foreign keys and / or the nesting of objects that allow us to better describe our entities. 148 | 149 | In this case this Method is the most appropriate because it allows to apply very advanced filters to our Array regardless of the depth level. 150 | 151 | ```ts 152 | import {Querier} from 'array-querier/lib/orbiter'; 153 | 154 | /** 155 | * Your Complex array of JSON Objects. 156 | * This can be pulled directly from your Backend Rest API. 157 | */ 158 | const products = [ 159 | { name: 'Orbit', color: 'Blue', size: 50, locations: ['USA', 'Europe'], details: { length: 20, width: 70 } }, 160 | { name: 'Galsen', color: 'Blue', size: 60, locations: [], details: { length: 20, width: 70 } }, 161 | { name: 'DaoudaBa', color: 'Black', size: 70, locations: ['Japan'], details: { length: 20, width: 71 } }, 162 | { name: 'Mmnl', color: 'Green', size: 50, locations: ['USA'], details: { length: 20, width: 71 } }, 163 | ]; 164 | 165 | // ⚠ Filter Object with complex conditions ⚠ 166 | const filters = { 167 | size: (size: number) => size === 50 || size === 70, 168 | color: (color: string) => ['blue', 'black'].includes(color.toLowerCase()), 169 | locations: (locations: any[]) => locations.find(x => ['JAPAN', 'USA'].includes(x.toUpperCase())), 170 | details: (details: { length: number; width: number; }) => details.length < 30 && details.width >= 70, 171 | }; 172 | 173 | /** 174 | * Calling Simple Array Filterer In Query. 175 | * Filters an array of objects (one level-depth) with multiple criteria. 176 | * The function returns an array of the same type as the input array. 177 | */ 178 | const MyFilteredResult = Querier.filterComplexArray(products, filters); 179 | 180 | console.table(MyFilteredResult); 181 | /* 🟢 The Result Will Be :🟢 182 | { name: 'A', color: 'Blue', size: 50, locations: ['USA', 'Europe'], details: { length: 20, width: 70 } }, 183 | { name: 'C', color: 'Black', size: 70, locations: ['Japan'], details: { length: 20, width: 71 } }, 184 | */ 185 | ``` 186 | 187 | **The Filter can be more complex and advance like the following use case case :** 188 | 189 | ```ts 190 | ... 191 | 192 | // ⚠ Filter Object with VERY Complex Conditions 🏃🏾‍♂️🏃🏾‍♂️⚠ 193 | const filters = { 194 | size: (size: number) => size === 50 || size === 70, 195 | color: (color: string) => ['blue', 'black'].includes(color.toLowerCase()), 196 | details: (details: { length: number; width: number; }) => details.length < 30 && details.width >= 70, 197 | locations: (locations: string | string[]) => { 198 | if (locations.includes('USA')) { return true; } // case sensitive 199 | if (locations.includes('Japan')) { return true; } // case sensitive 200 | 201 | const url = window.location.pathname.toLowerCase(); 202 | if (url.includes('/en-us/')) { return true; } // not case sensitive 203 | if (url.includes('/es/')) { return true; } // not case sensitive 204 | return false; 205 | } 206 | }; 207 | 208 | const MyFilteredResult = Querier.filterComplexArray(products, filters); 209 | ``` 210 | 211 |
212 | ✨🤗 AS I SAID BEFORE : EASYYY 🤗✨ 213 | 214 | ___ 215 | ## Configuration Options 216 | 217 | *Coming Soon !* 218 | ___ 219 | ## Contributing ❤ 220 | 221 | 👋🏾 Pull requests are welcome! 222 | ___ 223 | 224 | ## Issue Reporting 225 | 226 | If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](mailto:support@orbitturner.com) details the procedure for disclosing security issues. 227 | ___ 228 | 229 | ## GREETINGS 230 | ❤❤ *Coming Soon !* ❤❤ 231 | 232 | ___ 233 | ## Author 234 | 235 | [Orbit Turner](https://orbitturner.com) 236 | 237 | ___ 238 | ## License 239 | 240 | This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info. 241 | ______________________________________________________ 242 | **❤ MADE WITH LOVE ❤** 243 | 244 | ![Image of OT](https://raw.githubusercontent.com/orbitturner/orbitturner/master/LOGO-OT.png) 245 | 246 | 247 | -------------------------------------------------------------------------------- /core/__tests__/multiLevelDepthFilter.test.ts: -------------------------------------------------------------------------------- 1 | import { Querier } from '../orbiter'; 2 | 3 | /** 4 | * ==================================== 5 | * 🧪🔬 TEST OF MLDF WORKER🩺🧫 6 | * ==================================== 7 | */ 8 | describe('🟡 Testing Querier.filterComplexArray() ...', () => { 9 | it('should filter a Multi Level Depth array of objects by custom predicates', () => { 10 | const products = [ 11 | { name: 'A', color: 'Blue', size: 50, locations: ['USA', 'Europe'], details: { length: 20, width: 70 } }, 12 | { name: 'B', color: 'Blue', size: 60, locations: [], details: { length: 20, width: 70 } }, 13 | { name: 'C', color: 'Black', size: 70, locations: ['Japan'], details: { length: 20, width: 71 } }, 14 | { name: 'D', color: 'Green', size: 50, locations: ['USA'], details: { length: 20, width: 71 } }, 15 | ]; 16 | 17 | /** 18 | * Exemple One Of Filters Possibility. 19 | * You can choose one Of Those to Test with. 20 | */ 21 | const filters = { 22 | size: (size: number) => size === 50 || size === 70, 23 | color: (color: string) => ['blue', 'black'].includes(color.toLowerCase()), 24 | locations: (locations: any[]) => locations.find((x: string) => ['JAPAN', 'USA'].includes(x.toUpperCase())), 25 | details: (details: { length: number; width: number }) => details.length < 30 && details.width >= 70, 26 | }; 27 | 28 | /** 29 | * Exemple Two Of Filters Possibility. 30 | * You can choose one Of Those to Test with. 31 | */ 32 | const filters2 = { 33 | size: (size: number) => size === 50 || size === 70, 34 | color: (color: string) => ['blue', 'black'].includes(color.toLowerCase()), 35 | details: (details: { length: number; width: number }) => details.length < 30 && details.width >= 70, 36 | locations: (locations: string | string[]) => { 37 | if (locations.includes('USA')) return true; // case sensitive 38 | if (locations.includes('Japan')) return true; // case sensitive 39 | 40 | const url = window.location.pathname.toLowerCase(); 41 | if (url.includes('/en-us/')) return true; // not case sensitive 42 | if (url.includes('/es/')) return true; // not case sensitive 43 | return false; 44 | }, 45 | }; 46 | 47 | // Data Extraction using Filters 48 | const filtered = Querier.filterComplexArray(products, filters); 49 | 50 | const expected = [ 51 | { name: 'A', color: 'Blue', size: 50, locations: ['USA', 'Europe'], details: { length: 20, width: 70 } }, 52 | { name: 'C', color: 'Black', size: 70, locations: ['Japan'], details: { length: 20, width: 71 } }, 53 | ]; 54 | expect(filtered).toStrictEqual(expected); 55 | }); 56 | }); 57 | -------------------------------------------------------------------------------- /core/__tests__/oneLevelDepthFilter.test.ts: -------------------------------------------------------------------------------- 1 | import { Querier } from '../orbiter'; 2 | 3 | /** 4 | * ==================================== 5 | * 🧪🔬 TEST OF OLDF WORKER🩺🧫 6 | * ==================================== 7 | */ 8 | describe('🟡 Testing Querier.filterSimpleArray() ...', () => { 9 | it('should filter an array of objects with one level-depth', () => { 10 | const products = [ 11 | { name: 'A', color: 'Blue', size: 50 }, 12 | { name: 'B', color: 'Blue', size: 60 }, 13 | { name: 'C', color: 'Black', size: 70 }, 14 | { name: 'D', color: 'Green', size: 50 }, 15 | ]; 16 | 17 | const filters = { 18 | color: ['BLUE', 'black'], 19 | size: [70, 50], 20 | }; 21 | 22 | // Data Extraction using Filters 23 | const filtered = Querier.filterSimpleArray(products, filters); 24 | 25 | const expected = [ 26 | { name: 'A', color: 'Blue', size: 50 }, 27 | { name: 'C', color: 'Black', size: 70 }, 28 | ]; 29 | expect(filtered).toStrictEqual(expected); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /core/orbiter.ts: -------------------------------------------------------------------------------- 1 | import { ComplexFilter } from './workers/multiLevelDepthFilter'; 2 | import { SimpleFilter } from './workers/oneLevelDepthFilter'; 3 | 4 | // 🟢💻 WELCOME TO THE SPACESHIP - DEVELOPED BY 💻🟢 5 | // ██████╗ ██████╗ ██████╗ ██╗████████╗ ████████╗██╗ ██╗██████╗ ███╗ ██╗███████╗██████╗ 6 | // ██╔═══██╗██╔══██╗██╔══██╗██║╚══██╔══╝ ╚══██╔══╝██║ ██║██╔══██╗████╗ ██║██╔════╝██╔══██╗ 7 | // ██║ ██║██████╔╝██████╔╝██║ ██║ ██║ ██║ ██║██████╔╝██╔██╗ ██║█████╗ ██████╔╝ 8 | // ██║ ██║██╔══██╗██╔══██╗██║ ██║ ██║ ██║ ██║██╔══██╗██║╚██╗██║██╔══╝ ██╔══██╗ 9 | // ╚██████╔╝██║ ██║██████╔╝██║ ██║ ██║ ╚██████╔╝██║ ██║██║ ╚████║███████╗██║ ██║ 10 | // ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ 11 | // 💚🔰 KEEP GOING FURTHER 🔰💚 12 | /** 13 | * 💨 Project Name : Array-Querier 14 | * 💨 Project Repo : https://github.com/orbitturner/array-querier 15 | * 💨 My GitHub : https://github.com/orbitturner 16 | * 💨 My LinkedIn : https://linkedin.com/in/orbitturner 17 | * 💨 My Twitter : https://twitter.com/orbitturner 18 | */ 19 | 20 | /** 21 | * Filters an array of objects with multiple match-criteria. 22 | * Choose One of the available function depending on your array composition. 23 | * 24 | * @see -> https://github.com/orbitturner/array-querier 25 | * @exports {filterSimpleArray, filterComplexArray} 26 | */ 27 | export class Querier { 28 | /** 29 | * Filters an array of objects (one level-depth) with multiple criteria. 30 | * The function returns an array of the same type as the input array. 31 | * 32 | * @param array -> The Array of JSON Object to filter. 33 | * @param filters -> An object with all the filter criteria you want. 34 | * @returns {Array} -> Filtered Data Array. 35 | */ 36 | public static filterSimpleArray(array: any[], filters: { [x: string]: any[] }): any[] { 37 | return SimpleFilter.oneLevelDepthFilter(array, filters); 38 | } 39 | 40 | /** 41 | * Filters a multi Level Depth array of objects using custom predicates. 42 | * 43 | * @param {Array} -> The Array of JSON Object to filter. 44 | * @param {Object} -> An object with all the filter criteria you want. 45 | * @return {Array} -> Filtered Data Array. 46 | */ 47 | public static filterComplexArray(array: any[], filters: { [x: string]: (arg0: any) => any }): any[] { 48 | return ComplexFilter.multiLevelDepthFilter(array, filters); 49 | } 50 | } 51 | 52 | // export } as Querier; 53 | -------------------------------------------------------------------------------- /core/workers/multiLevelDepthFilter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * ============================================= 3 | * 🧱 Multi Level Depth Array Worker Class. 🧱 4 | * ============================================= 5 | */ 6 | export class ComplexFilter { 7 | /** 8 | * Filters a multi Level Depth array of objects using custom predicates. 9 | * 10 | * @param {Array} -> The Array of JSON Object to filter. 11 | * @param {Object} -> An object with all the filter criteria you want. 12 | * @return {Array} -> Filtered Data Array. 13 | */ 14 | public static multiLevelDepthFilter(array: any[], filters: { [x: string]: (arg0: any) => any }) { 15 | const filterKeys = Object.keys(filters); 16 | return array.filter((item: { [x: string]: any }) => { 17 | // validates all filter criteria 18 | return filterKeys.every((key) => { 19 | // ignores non-function predicates 20 | if (typeof filters[key] !== 'function') return true; 21 | return filters[key](item[key]); 22 | }); 23 | }); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/workers/oneLevelDepthFilter.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * ========================================== 3 | * 🔹 One Level Depth Array Worker Class. 🔹 4 | * ========================================== 5 | */ 6 | export class SimpleFilter { 7 | // ================================================= 8 | // ignores case-sensitive for Array Filter 9 | private static getValue = (value: string) => (typeof value === 'string' ? value.toUpperCase() : value); 10 | // ================================================= 11 | 12 | /** 13 | * Filters an array of objects (one level-depth) with multiple criteria. 14 | * The function returns an array of the same type as the input array. 15 | * 16 | * @param array -> The Array of JSON Object to filter. 17 | * @param filters -> An object with all the filter criteria you want. 18 | * @returns {Array} -> Filtered Data Array. 19 | */ 20 | public static oneLevelDepthFilter(array: any[], filters: { [x: string]: any[] }): any[] { 21 | const filterKeys = Object.keys(filters); 22 | return array.filter((item) => { 23 | // validates all filter criteria 24 | return filterKeys.every((key) => { 25 | // ignores an empty filter 26 | if (!filters[key].length) { 27 | return true; 28 | } 29 | return filters[key].find((filter) => this.getValue(filter) === this.getValue(item[key])); 30 | }); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jestconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "transform": { 3 | "^.+\\.(t|j)sx?$": "ts-jest" 4 | }, 5 | "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", 6 | "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"] 7 | } -------------------------------------------------------------------------------- /orbit.md: -------------------------------------------------------------------------------- 1 | // 🟢💻 WELCOME TO THE SPACESHIP - DEVELOPED BY 💻🟢 2 | // ██████╗ ██████╗ ██████╗ ██╗████████╗ ████████╗██╗ ██╗██████╗ ███╗ ██╗███████╗██████╗ 3 | // ██╔═══██╗██╔══██╗██╔══██╗██║╚══██╔══╝ ╚══██╔══╝██║ ██║██╔══██╗████╗ ██║██╔════╝██╔══██╗ 4 | // ██║ ██║██████╔╝██████╔╝██║ ██║ ██║ ██║ ██║██████╔╝██╔██╗ ██║█████╗ ██████╔╝ 5 | // ██║ ██║██╔══██╗██╔══██╗██║ ██║ ██║ ██║ ██║██╔══██╗██║╚██╗██║██╔══╝ ██╔══██╗ 6 | // ╚██████╔╝██║ ██║██████╔╝██║ ██║ ██║ ╚██████╔╝██║ ██║██║ ╚████║███████╗██║ ██║ 7 | // ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ 8 | // 💚🔰 KEEP GOING FURTHER 🔰💚 9 | /** 10 | * 💨 Project Name : Array-Querier 11 | * 💨 Project Repo : https://github.com/orbitturner/array-querier 12 | * 💨 My GitHub : https://github.com/orbitturner 13 | * 💨 My LinkedIn : https://linkedin.com/in/orbitturner 14 | * 💨 My Twitter : https://twitter.com/orbitturner 15 | */ -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "array-querier", 3 | "version": "1.2.1", 4 | "description": "A TS/JS NPM Package to Filter an array of objects with multiple match-criteria.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest --config jestconfig.json", 8 | "build": "tsc", 9 | "format": "prettier --write \"core/**/*.ts\"", 10 | "lint": "tslint -p tsconfig.json", 11 | "prepublishOnly": "npm test", 12 | "prepare": "npm run build", 13 | "preversion": "npm run lint", 14 | "xversion": "npm run format && npm --no-git-tag-version version patch", 15 | "gitupdate": "git add . && git commit -m \"🟢 RELEASING V %npm_package_version% ✨\" && git push --tags ", 16 | "release": "npm run xversion && npm run gitupdate && npm publish" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/orbitturner/array-querier.git" 21 | }, 22 | "keywords": [ 23 | "Array Filter", 24 | "Array Query", 25 | "Query", 26 | "Filter", 27 | "orbitturner" 28 | ], 29 | "author": "Orbit Turner", 30 | "license": "MIT", 31 | "bugs": { 32 | "url": "https://github.com/orbitturner/array-querier/issues" 33 | }, 34 | "homepage": "https://github.com/orbitturner/array-querier#readme", 35 | "devDependencies": { 36 | "@types/jest": "^26.0.22", 37 | "jest": "^26.6.3", 38 | "prettier": "^2.2.1", 39 | "ts-jest": "^26.5.4", 40 | "tslint": "^6.1.3", 41 | "tslint-config-prettier": "^1.18.0", 42 | "typescript": "^4.2.3" 43 | }, 44 | "files": [ 45 | "lib/**/*" 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "outDir": "./lib", 7 | "strict": true 8 | }, 9 | "include": ["core"], 10 | "exclude": ["node_modules", "**/__tests__/*"] 11 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint:recommended", "tslint-config-prettier"] 3 | } --------------------------------------------------------------------------------