Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (28 sloc) 878 Bytes


Colander is a simple rule-based filtering tool. Keep the stuff you want, discard the stuff you don't.


npm install colander


Code speaks louder than words, so here we go. Say we have some spaghetti that's just finished cooking, so it's still in the water...

var pot = [
  {type: "spaghetti"},
  {type: "water"},
  {type: "spaghetti"},
  {type: "water"},
  {type: "water"},
  {type: "spaghetti"},
  {type: "spaghetti"},
  {type: "water"},

var colander = require('colander')
var strainer = colander({
  accept_when: {"type": "spaghetti"},
  reject_when: {"type": "water"}

// test some individual objects
strainer.strain({type: "spaghetti"}) // => true
strainer.strain({type: "water"}) // => false

// strain the whole pot at once
Something went wrong with that request. Please try again.