safeify
<div align="center">
Last updated 5 years ago by houzhanfeng .
Apache License 2.0 · Original npm · Tarball · package.json
$ cnpm install safeify 
SYNC missed versions from official npm registry.

Safeify

npm NPM Version Build Status Coverage Status npm

说明

Safeify 可让 Node 应用安全的隔离执行非信任的用户自定义代码,了解详细

安装

npm install safeify -S

使用

import { Safeify } from "safeify";

(async ()=>{

  // 创建 safeify 实例
  const safeVm = new Safeify({
    timeout: 3000,
    asyncTimeout: 60000
  });

  // 定义 context
  const context = {
    a: 1,
    b: 2,
    system: {
      add(a: number, b: number) {
        return (a + b) * 2;
      }
    }
  };

  // 执行动态代码
  const result= await safeVm.run(`return system.add(1,2)`, context);
  console.log('result', result);

  // 释放资源
  safeVm.destroy();
  
})();

Current Tags

  • 5.0.6                                ...           latest (5 years ago)

29 Versions

  • 5.0.6                                ...           5 years ago
  • 5.0.5 [deprecated]           ...           6 years ago
  • 5.0.4 [deprecated]           ...           6 years ago
  • 5.0.3 [deprecated]           ...           7 years ago
  • 5.0.2                                ...           7 years ago
  • 5.0.1                                ...           7 years ago
  • 5.0.0                                ...           7 years ago
  • 4.0.1                                ...           7 years ago
  • 4.0.0                                ...           7 years ago
  • 3.1.0                                ...           7 years ago
  • 3.0.3                                ...           7 years ago
  • 3.0.2                                ...           7 years ago
  • 3.0.1                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 2.0.8                                ...           7 years ago
  • 2.0.5                                ...           8 years ago
  • 2.0.3                                ...           8 years ago
  • 2.0.2                                ...           8 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.1.4                                ...           8 years ago
  • 1.1.3                                ...           8 years ago
  • 1.1.2                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.2                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (5)
Dev Dependencies (16)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |