1.0.2 • Published 4 years ago

get-filtered v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Description

  • filter an array of object based on an array and a key

Install

npm i get-filtered

Usage

const {getFiltered} = require('getFiltered')

const data = [
    {
        id: 1,
        name: "USA",
        continent: "North America",
        planet: "Earth"
    },
    {
        id: 2,
        name: "Canada",
        planet: "Earth"
    },
    {
        id: 3,
        name: "Haiti",
        continent: "North America",
    }
]

const config = {
    inc: ["Earth"],
    filter_key: "planet"
}

const callback = (f) => {
    console.log(f)
    return f
}
const gotFiltered = getFiltered(data, config, callback)