ioscript
v1.1.4
Published
> `npm i ioscript` ```js let IOScript = require("ioscript"); ``` # Basic usage: ```js let sandbox = IOScript({ onError: function(isCore, error) {}, // isCore ? ioscript error : provided script error pure: true, // whether internal scopes inherit p
Downloads
8
Readme
Installation
npm i ioscript
let IOScript = require("ioscript");
Basic usage:
let sandbox = IOScript({
onError: function(isCore, error) {}, // isCore ? ioscript error : provided script error
pure: true, // whether internal scopes inherit parent scope variables (pure by default doesn't)
maxOps: -1, // max amount of ops triggers
opTriggers: [], // ops that trigger ops count
noOpTriggers: [], // ops that don't trigger ops count
debug: false, // displays debugging information as it parses and runs through a script
cleanEnv: false, // true if you dont want to expose basic properties/methods, (isNaN, Array, Object, etc...)
globals: {}, // global variables provided for inside the sandbox (functions, objects, anything...)
});
sandbox.run(scriptName, scriptCode); // run a script
sandbox.global; // global scope inside sandbox
sandbox.ops; /* {
current, // view the current op count
limit, // view/set the op limit
clear, // clear the op counter
} */
sandbox.types; // Array of op trigger types
Op triggers:
[
ThisExpression,
Identifier,
Literal,
ArrayExpression,
ObjectExpression,
FunctionExpression,
ArrowFunctionExpression,
ClassExpression, // Unsupported
TaggedTemplateExpression, // Unsupported
MemberExpression,
Super, // Unsupported
MetaProperty, // Unsupported
CallExpression,
NewExpression,
UpdateExpression,
AwaitExpression, // Unsupported
UnaryExpression,
BinaryExpression,
LogicalExpression,
ConditionalExpression,
YieldExpression, // Unsupported
AssignmentExpression,
SequenceExpression,
BlockStatement,
BreakStatement,
ClassDeclaration, // Unsupported
ContinueStatement,
DebuggerStatement, // Unsupported
DoWhileStatement,
EmptyStatement,
ExpressionStatement,
ForStatement,
ForInStatement,
ForOfStatement,
FunctionDeclaration,
IfStatement,
LabelledStatement, // Unsupported
ReturnStatement,
SwitchStatement,
ThrowStatement,
TryStatement,
VariableDeclaration,
WhileStatement,
WithStatement,
Program,
ImportDeclaration, // Unsupported
ExportAllDeclaration, // Unsupported
ExportDefaultDeclaration, // Unsupported
ExportNamedDeclaration, // Unsupported
TemplateLiteral,
]