4.0.4 • Published 2 years ago

bhscript v4.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Installation

npm i bhscript

let bhscript = require("bhscript");

or:

<script src="bhscript.web.js"></script>

Basic usage:

let sandbox = bhscript({
    onError: function(isCore, error) {}, // isCore ? bhscript 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:
```js
[
  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,
]
4.0.4

2 years ago

4.0.3

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.2

2 years ago

3.1.8

4 years ago

3.1.7

4 years ago

3.1.6

4 years ago

3.1.5

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.10

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.5

4 years ago

2.0.3

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.22.0

4 years ago

1.21.0

4 years ago

1.20.0

4 years ago

1.19.0

4 years ago

1.18.0

4 years ago

1.17.0

4 years ago

1.16.0

4 years ago

1.15.0

4 years ago

1.13.0

4 years ago

1.12.0

4 years ago

1.11.0

4 years ago

1.10.0

4 years ago

1.9.0

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.0.0

4 years ago