option-tree-filter

1.1.0 • Public • Published

option-tree-filter build status

Filter an option tree

 
var FilterTree = require('option-tree-filter')
var assert = require('assert')
 
var tree = FilterTree([{
  id: '1',
  options: [
    {id: 'a'},
    {id: 'b'}
  ]
}, {
  id: '2',
  options: [{
    id: 'c',
    options: [
      {id: 'd'}
    ]
  }]
}, {
  id: '3',
  options: [
    {id: 'e'},
    {id: 'f'}
  ]
}], function idExact (opt, query) {
  return opt.id && opt.id === query
})
 
// returns a copy. original data is unchanged.
assert.deepEqual(tree.query('e'), [{
  id: '3',
  options: [
    {
      id: 'e',
      passes: true,
      keep: true
    }
  ],
  passes: false,
  keep: true
}])

usage

Readme

Keywords

none

Package Sidebar

Install

npm i option-tree-filter

Weekly Downloads

1

Version

1.1.0

License

none

Last publish

Collaborators

  • nrw