Socket
Book a DemoInstallSign in
Socket

mofilterjs

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

mofilterjs

quickly filters large array of object. simple to use

1.0.0
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

filter.js

[![NPM version][npm-version-image]][npm-url]

filter.js filters array of object with few lines of codes. It is simple to use, scalable, light weight and very easy to use

Description

filter.js is a light weight, plain javascript package that can be used to filter large array of object.

Installation

npm i filter --save

Usage

...

import filter from "filter";

...

filter is an a function that receives 4 compulsory arguments.

  • An array of the object you want to filter
  • An array containing strings of values or keys in the object you want to filter the it with
  • a string a number you want to use and filter the object with
  • a callback that receives 2 arguments.
    • The first one returns the filtered data
    • Second returns error if not null

Example codes

...

import filter from "./filter.js"

const arrayObj = [
    {
        id: "1",
        name: "name1",
        product: "product1",
        email: "example1@gmail.com"
    },
    {
        id: "2",
        name: "name2",
        product: "product2",
        email: "example2@gmail.com"
    },
    {
        id: "3",
        name: "name3",
        product: "product3",
        email: "example3@gmail.com"
    },
    {
        id: "3",
        name: "name3",
        product: "product3",
        email: "example4@gmail.com"
    }
]


const val = "name3"
//can be anything that you want the use to find the data with
//val is the value from search input

filter(arrayObj, ["name", "email", "product"], val, (data, err)=>{
    if(err){
        console.log(err)
    }else{
        console.log(data)
    }
})

//results. Two objects with the name "name3" were found and returned

/*
    {
        id: "3",
        name: "name3",
        product: "product3",
        email: "example3@gmail.com"
    },
    {
        id: "3",
        name: "name3",
        product: "product3",
        email: "example4@gmail.com"
    }
*/

//if input value is empty string, all the object will be returned

...

Limitation

Cannot do deep object filtering for now. This feature comes soon.

Thank you...

Keywords

filter

FAQs

Package last updated on 10 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.