@benev/slate
Version:
frontend web stuff
42 lines • 1.38 kB
JavaScript
import { ob } from "../../tools/ob.js";
export var ZipAction;
(function (ZipAction) {
function actualize(tree, blueprint) {
return ob(blueprint).map(value => {
if (typeof value === "function") {
return (...params) => {
tree.transmute(state => {
const setState = (newState) => { state = newState; };
value(state, setState)(...params);
return state;
});
};
}
else {
return actualize(tree, value);
}
});
}
ZipAction.actualize = actualize;
function fn() {
return (fn) => fn;
}
ZipAction.fn = fn;
function blueprint() {
return (blueprint) => blueprint;
}
ZipAction.blueprint = blueprint;
ZipAction.prepFn = (helpers) => (fun) => ((state, setState) => (...params) => {
fun(helpers(state, setState))(...params);
return state;
});
ZipAction.prepBlueprint = (helpers) => (makeBp) => (makeBp(ZipAction.prepFn(helpers)));
function prep(helpers) {
return {
action: ZipAction.prepFn(helpers),
blueprint: ZipAction.prepBlueprint(helpers),
};
}
ZipAction.prep = prep;
})(ZipAction || (ZipAction = {}));
//# sourceMappingURL=action.js.map