@cka1o1/filter-items

A simple filter function to filter the desired items from the provided list

Usage no npm install needed!

<script type="module">
  import cka1o1FilterItems from 'https://cdn.skypack.dev/@cka1o1/filter-items';
</script>

README

Filter Items

A simple and easy to use method to filter desired items from the list

Installation

npm install @cka1o1/filter-items

Usage

Arguments:

  1. List (supports single variable array as well)
  2. value to be filtered
  3. default attribute ( default value is id)

Returns: List of matched items

import filterItems from '@cka1o1/filter-items'

const demoList = [
    { id: 1, title: 'Apple', category: 'fruits'},
    { id: 4, title: 'Carrot', category: 'vegetables' },
    { id: 3, title: 'Banana', category: 'fruits' }
];
                 
console.log("filteredItems: "filterItems(demoList, 'vegetables', 'category'))

// filteredItems [ { id: 4, title: 'Carrot', category: 'vegetables' } ]