GithubHelp home page GithubHelp logo

vitorluizc / cullender Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 1.0 195 KB

Search data and create complex filters by compose filter functions.

License: MIT License

JavaScript 100.00%
compose cull cullender filter filter-data filter-lists filter-plugin filterable filtering filterlist filters fp functional-programming javascript search searching

cullender's People

Contributors

vitorluizc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

danetheory

cullender's Issues

Support for TypeScript

Add type definitions or refactor using TypeScript.

type Map <T, U> = (item: T, index: number, items: ReadonlyArray<T>) => U
type Filter <T> = (item: T, index: number, items: ReadonlyArray<T>) => boolean;

const cull: <T> (items: Iterable<T>, ...λs: Array<Filter<T>>) => Array<T>;
const create: <T> (type: 'AND' | 'OR', ...λs: Array<Filter<T>>) => Filter<T>;

namespace filters {
  export const not: <T> (filter: Filter<T>) => Filter<T>;
  export const into: <T, U> (items: Array<U>, λ?: Map<T, U>) => Filter<T>;
  export const search: <T> (text: string, λ?: Map<T, (string | Array<string>)>) => Filter<T>;
  export const truthy: <T> (λ?: Map<T, boolean>) => Filter<T>;
}

export { cull, create, filters, Filter, Map };

Add CI

Add travis or another CI to show tests result and keep lib / build safe.

Add "list includes" to filters

Add a filter to check if value is present in a list.

cull([1,2,3,4,5], filters.in([1,2])) // [1, 2]
cull([1,2,3,4,5], filters.in([7,6])) // []

I thought something like function below would be awesome.

export const in = (list, λ = DEFAULT_Λ) => (...args) => {
  const result = list.includes(λ(...args))
  return result
}

Use String.normalize instead of diacritics

String.prototype.normalize combined with a character set replace do exactly what I'm looking for on diacritics module.

const normalize = (text) => text.normalize('NFKD').replace(/[\u0080-\uF8FF]/g, '')

Add not() filter

There's no way to negate filter results.

This function is useful to decorate a function negating it's results.

const not = (filter) => (...args) => !filter(...args)

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.