How to use the isolated-vm.Isolate function in isolated-vm

To help you get started, we’ve selected a few isolated-vm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github superfly / fly / src / isolate.ts View on Github external
export function createIsolate(): Promise {
	const ivmIso = new ivm.Isolate({ snapshot })
	return new Promise((resolve, reject) => {
		createContext(ivmIso).then(function (ctx) {
			const iso = new Isolate(ivmIso, ctx)
			// test the isolate!
			iso.test().then(() => resolve(iso)).catch(reject)
		})
	})
}
github legraphista / isolated-threads / src / helpers / index.js View on Github external
index.createIsolate = ({ memoryLimit, inspector } = {}) => {
  const isolate = new ivm.Isolate({ memoryLimit, inspector });
  const context = isolate.createContextSync({ inspector });
  const jail = context.globalReference();
  jail.setSync('global', jail.derefInto());

  return {
    isolate,
    context,
    jail
  };
};
github Izzzio / izzzio / modules / smartContracts / VM.js View on Github external
constructor(options) {
        this.ramLimit = (typeof options === 'undefined' || typeof options.ramLimit === 'undefined' ? 32 : options.ramLimit);
        this.ivm = ivm;
        this.isolate = new ivm.Isolate({memoryLimit: this.ramLimit});
        this.script = '';
        this.state = undefined;
        this.context = undefined;
        this.timeout = (typeof options === 'undefined' || typeof options.timeLimit === 'undefined' ? 1000 : options.timeLimit);
        this.cpuLimit = (typeof options === 'undefined' || typeof options.cpuLimit === 'undefined' ? 500 : options.cpuLimit);
        this.logging = (typeof options === 'undefined' || typeof options.logging === 'undefined' ? true : options.logging);
        this.busy = false;
        this.waitingForResponse = false;
        this.logPrefix = (typeof options === 'undefined' || typeof options.logPrefix === 'undefined' ? '' : options.logPrefix);
    }
github kirjavascript / nibblrjr / irc / evaluate / index.js View on Github external
async function evaluate({
    canBroadcast = false,
    printResult = false,
    script,
    msgData,
    node,
    command,
    event,
}) {
    const isolate = new ivm.Isolate({ memoryLimit: 128 });
    const context = await isolate.createContext();
    const dispose = () => {
        if (!isolate.isDisposed) {
            isolate.dispose();
            context.release();
        }
    };

    try {
        const channels = Object.entries(_.cloneDeep(node.client.chans))
            .reduce((acc, [key, value]) => {
                delete value.users;
                acc[key.toLowerCase()] = value;
                return acc;
            }, {});

isolated-vm

Access to multiple isolates

ISC
Latest version published 4 months ago

Package Health Score

77 / 100
Full package analysis

Similar packages