0.1.8 • Published 8 years ago

superfilter v0.1.8

Weekly downloads
10
License
MIT
Repository
github
Last release
8 years ago

superfilter

A function to filter all the things. Utilizes heavy memoization to quickly filter JSON string / object / array data in flexible ways.

Build Status codecov

NPM

Install

npm install -S superfilter

Dependencies

none

Usage

import superfilter from 'superfilter'

const data = (
  { foo: 'bar'
  , kung: (
      { fu: (
          { bar: 'foo'
          , fuji: (
              [ 1
              , 2
              , { coo: 'car'
                , __type__: 'something'
                }
              ]
            )
          }
        )
      }
    )
  }
)

const print = _ => console.info(JSON.stringify(_))

print(superfilter(data, 2))
// { kung: { fu: { fuji: [ 2 ] } } }

print(superfilter(data, `x => Object.keys(x).includes('foo')`)
// { foo: 'bar' }

Options

The third parameter an options object to tweak how you filter:

optionNametypedescription
filterKeysundefined, Array<string>Only keys supplied will be used in filtering values. (undefined => filter on all keys)
walkKeysundefined, Array<string>Only keys supplied will be used in recursive traversal. (undefined => walk all paths)
insertMarksundefined, booleanInserts <mark></mark> tags around matching text.
0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago