UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

1 lines 1.07 kB
Object.defineProperty(exports,"__esModule",{value:!0});let APIFunction_1=require("../../classes/structures/APIFunction"),Util_1=require("../../classes/internal/Util");class Scope extends APIFunction_1.APIFunction{name="$scope";description="Executes a code field inside a different data scope.";parameters=[{name:"Code",description:"Code to be executed inside the new scope.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"New",description:"Whether create a new scope or inherit data from the parent scope.",type:APIFunction_1.ParamType.Boolean,required:!1,rest:!1,defaultValue:"false"}];usage="$scope[code;new?]";returns=APIFunction_1.ParamType.Unknown;aliases=["$block"];compile=!1;async run(e,[t,n="true"]){return n=await Util_1.Util.resolveCode(e,n),e=e.extend(e._,e.__),Util_1.Util.booleanify(n)&&e.overrideVars(null),e.functions.load(__dirname,e=>void 0!==e.parent&&e.parent.name===this.name),n=await Util_1.Util.resolveCode(e,t),e.internalVarExists("__SCOPE_RETURN__")?e.getInternalVar("__SCOPE_RETURN__"):n}}exports.default=Scope;