Add pattern composers, implements #82
This commit is contained in:
parent
36d1a68b9a
commit
b370c405da
2 changed files with 60 additions and 25 deletions
|
|
@ -275,14 +275,14 @@ const generic_params = [
|
|||
|
||||
const _name = (name, ...pats) => sequence(...pats).withValue((x) => ({ [name]: x }));
|
||||
|
||||
const _unionise = (func) =>
|
||||
const _setter = (func) =>
|
||||
function (...pats) {
|
||||
return this.union(func(...pats));
|
||||
return this.set(func(...pats));
|
||||
};
|
||||
|
||||
generic_params.forEach(([type, name, description]) => {
|
||||
controls[name] = (...pats) => _name(name, ...pats);
|
||||
Pattern.prototype[name] = _unionise(controls[name]);
|
||||
Pattern.prototype[name] = _setter(controls[name]);
|
||||
});
|
||||
|
||||
export default controls;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue