sheinsight / n-sandbox

The sandbox runtime environment of Node can support any advanced syntax as well as TypeScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ“¦ n-sandbox

The sandbox runtime environment of Node can support any advanced syntax as well as TypeScript.

πŸ€” why

  • Sometimes during runtime, we need to load some more advanced syntax files.
  • A typical scenario, our configuration files are usually written in TypeScript, and we need to dynamically load them at runtime.

πŸ”₯ Install

npm install @shined/n-sandbox

🦾 Usage

import { sandbox } from "./index";

const fn = () => {
  const config = require("../fixtures/ts/define-config");
  return config;
};

const res = await sandbox(fn);

console.log(res.default);

πŸ“š Api

type Fn<R> = () => Promise<R> | R;

interface SandboxOptions {
  target?: string[];
}

declare function sandbox<R>(fn: Fn<R>, options?: SandboxOptions): Promise<R>;

Options

target

πŸ«‚ Maintainers

About

The sandbox runtime environment of Node can support any advanced syntax as well as TypeScript.

License:MIT License


Languages

Language:TypeScript 100.0%