Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Use Proxy instead of function scope #21

@jaandrle

Description

@jaandrle

Is your feature request related to a problem? Please describe:

Current implementation:

function component(/* … */){
	return { add /* … */ };
	function add(/* … */){ /* … */ }
}

Describe the solution you'd like:

Use Class+Proxy?

class Component{ /* … */ }
const bind_protocol= {
    get(target, property){
        if(property==="chain")
            return ()=> target;
        if(property==="class")
            return target;
        const out= target[property];
        if(typeof out!=="function") return out;
        return out.bind(target);
    }
};
function component(/* … */){
	return new Proxy( new Component(/* … */), bind_protocol );
}

Full example (.txt just because GitHub restriction ⇒ remove):
Proxy_test.js.txt


Thanks for your help 🎉!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions