Code Monkey home page Code Monkey logo

object-filter's Introduction

Object filtering

Easily filter object by their properties - then get the filtered object back!

  • Two types of filtering available:
    • Exclude all of the matched properties or
    • Include only the matched properties.
  • Filter by a list names or regex filters.
  • Recursive filtering available.
    • Recursive filtering will not filter within arrays, sets, maps, dates, and other in-built classes.

What's new in version 1.3

  • Improved inclusive filtering: you no longer have to specify all the properties that lead to the target property to be included. Specify only those that you want to keep and the algorithm does the rest!
  • Filtering is now recursive by default, if not specified otherwise.
  • Compatibility with ES6 and CommonJS module systems.
  • Completely reworked filtering logic.

Detailed usage info

For a detailed description package use, filter types specifics and other important notes, be sure to visit the project's wiki!

Installation and basic info

  • Install the package via npm install @jericirenej/object-filter.
    • You can also clone the repo and transpile the files manually (npm install, followed by npm run compile which will transpile to dist).
  • To start using the objectFilter function, you can either import or require the function
// ES6 import
import objectFilter from "@jericirenej/object-filter";

// CommonJS import
const objectFilter = require("@jericirenej/object.filter").default;

Basic usage

objectFilter has the following signature:

const objectFilter = ({
  targetObject: Record<string,any>;
  filters?: string|string[];
  regexFilters?: string|RegExp|(string|RegExp)[]  // At least one filter group must be valid.
  filterType?: "exclude"|"include";               // Will default to exclude.
  recursive?: boolean;                            // Will default to true.
  }) => Record<string,any>

object-filter's People

Contributors

dependabot[bot] avatar jericirenej avatar

Watchers

 avatar

Forkers

benjamin-cizej

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.