{"size": 631, "ext": "js", "max_stars_repo_path": "lib/plugins/jsx/context/context.es6.js", "max_stars_repo_name": "d8corp/innet-dom", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/plugins/jsx/context/context.es6.js", "max_issues_repo_name": "d8corp/innet-dom", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/plugins/jsx/context/context.es6.js", "max_forks_repo_name": "d8corp/innet-dom", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.6818181818, "max_line_length": 80, "alphanum_fraction": 0.6973058637}
import innet from 'innet';

class Context {
    constructor(defaultValue, name) {
        this.defaultValue = defaultValue;
        this.key = Symbol(name);
    }
    get(handler) {
        return this.key in handler ? handler[this.key] : this.defaultValue;
    }
}
function createContextHandler(handler, context, value) {
    const childrenHandler = Object.create(handler);
    childrenHandler[context.key] = value;
    return childrenHandler;
}
function context({ props, children }, handler) {
    return innet(children, createContextHandler(handler, props.for, props.set));
}

export { Context, context, createContextHandler };
