UNPKG

@sudoo/marked

Version:

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

50 lines (49 loc) 1.79 kB
"use strict"; /** * @author WMXPY * @namespace Marked * @description Executer */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Executer = void 0; const scope_1 = require("../variable/scope"); class Executer { static from(sandbox) { return new Executer(sandbox); } constructor(sandbox) { this._parent = sandbox; this._rootScope = scope_1.Scope.executeScope(sandbox.bridgeScope); this._executing = false; } get parent() { return this._parent; } get scope() { return this._rootScope; } get exposed() { return this._rootScope.exposed; } isExecuting() { return this._executing; } evaluate(script, breakPoints, scriptLocation) { return __awaiter(this, void 0, void 0, function* () { this._executing = true; const evaluateResult = yield this._parent.evaluate(script, breakPoints, scriptLocation, this._rootScope); this._executing = false; return evaluateResult; }); } } exports.Executer = Executer;