@sudoo/marked
Version:
JavaScript & TypeScript code runner in JavaScript, safe with marked territory, asynchronous
31 lines (30 loc) • 1.06 kB
JavaScript
;
/**
* @author WMXPY
* @namespace Operation_MemberExpression
* @description Class
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.memberExpressionClass = void 0;
const error_code_1 = require("../../declare/error-code");
const error_1 = require("../../util/error/error");
const sand_function_1 = require("../../variable/sand-function/sand-function");
const memberExpressionClass = (sandbox, sandClass, key) => {
if (typeof key === "string") {
if (sandClass.staticBody.has(key)) {
const target = sandClass.staticBody.get(key);
if (target instanceof sand_function_1.SandFunction) {
return target.bindThisValue(sandClass);
}
return target;
}
switch (key) {
case "name": {
return sandClass.className;
}
}
return undefined;
}
throw (0, error_1.error)(error_code_1.ERROR_CODE.ONLY_STRING_AVAILABLE_FOR_CLASS);
};
exports.memberExpressionClass = memberExpressionClass;