UNPKG

@sudoo/marked

Version:

JavaScript & TypeScript code runner in JavaScript, safe with marked territory, asynchronous

37 lines (36 loc) 915 B
"use strict"; /** * @author WMXPY * @namespace Variable_SandFunction * @description Sand Function */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SandFunction = void 0; class SandFunction { static wrapFunction(func) { if (func instanceof SandFunction) { return func; } return SandFunction.create(func); } static create(func) { return new SandFunction(func); } constructor(func) { this._function = func; this._thisValue = null; } get thisValue() { return this._thisValue; } execute(...args) { const thisValue = this._thisValue; return this._function(thisValue, ...args); } bindThisValue(thisValue) { const bind = new SandFunction(this._function); bind._thisValue = thisValue; return bind; } } exports.SandFunction = SandFunction;