Method and accessor delegation utilty for Deno. Based on https://github.com/tj/node-delegates
.
import { delegates, Delegator } from "https://raw.githubusercontent.com/ako-deno/delegates/master/mod.ts";
import { delegates } from "https://raw.githubusercontent.com/ako-deno/delegates/master/mod.ts";
const obj: any = {
request: {
get type() {
return this._type.toUpperCase();
},
set type(val) {
this._type = val;
},
}
};
delegates(obj, "request").setter("type").getter("type");
obj.type = "hey";
obj.type // "HEY"
Delegates getters, setters, values, and methods from targetProto to proto. Assumes that targetProto objects will exist under proto objects with the key targetProp.
Allows the given method name
to be accessed on the host.
Creates a "getter" for the property with the given name
on the delegated
object.
Creates a "setter" for the property with the given name
on the delegated
object.
Creates an "accessor" (ie: both getter and setter) for the property with the
given name
on the delegated object.