vitorluizc / cullender Goto Github PK
View Code? Open in Web Editor NEWSearch data and create complex filters by compose filter functions.
License: MIT License
Search data and create complex filters by compose filter functions.
License: MIT License
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 travis or another CI to show tests result and keep lib / build safe.
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
}
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, '')
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.