@erikwatson/applyfilters

Apply a set of filter functions to a dataset

Usage no npm install needed!

<script type="module">
  import erikwatsonApplyfilters from 'https://cdn.skypack.dev/@erikwatson/applyfilters';
</script>

README

applyFilters.js

This is simply a function that runs a list of filters against a list of something, returning the result.

const applyFilters = require('@erikwatson/applyfilters')

const data = [
  { name: 'Nobody', age: 22 },
  { name: 'Normal Name', age: 33 },
  { name: 'Weird Name': age: 44 }
]

const filters = [
  x => x.age > 27,
  x => x.age < 37
]

const result = applyFilters(data, filters)

// result: [
//   { name: 'Normal Name', age: 33 }
// ]

Author