UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

1 lines 1.26 kB
Object.defineProperty(exports,"__esModule",{value:!0});let APIFunction_1=require("../../classes/structures/APIFunction"),Error_1=require("../../classes/structures/Error"),Util_1=require("../../classes/internal/Util");class EncodeURI extends APIFunction_1.APIFunction{name="$execRegex";description="Executes a regex in a string.";parameters=[{name:"Regex",description:"The regular expression to be executed.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Flags",description:"Regular expression flags.",type:APIFunction_1.ParamType.String,required:!1,rest:!1,defaultValue:"g"},{name:"Text",description:"Text to execute the regex on.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null},{name:"Index",description:"Index to get from the executed expression.",type:APIFunction_1.ParamType.Number,required:!1,rest:!1,defaultValue:"1"}];usage="$execRegex[regex;flags?;text;index?]";returns=APIFunction_1.ParamType.String;aliases=[];compile=!0;async run(e,[r,t="g",n,i="1"]){if(Util_1.Util.isNumber(i))return r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)),(e=new RegExp(r,t).exec(n))?e[Number(i)-1]:"";throw new Error_1.InvalidFieldIndex(i,e.function,"Execution Result Index")}}exports.default=EncodeURI;