This package allow us to import code from simple string, with support to:
This is a lightweight and simple package, you can install it using your favorite node package manager:
npm i import-string
pnpm add import-string
yarn add import-string
bun add import-string
In your file you can declare the module, functionality or variable in a string like the following example:
const stringSrc = `export const example = (): string => {
return {
foo: 'baz'
}
}`;
From the package you can import the importModule
function that receive string and returns the module:
import { importModule } from 'import-string';
async function main() {
const mod = await importModule(stringSrc);
console.log(mod.example().foo); // output -> baz
}
- Clone this repository
- Install dependencies using
pnpm install
Send a PR with the feat|fix|refactor
etc
- BTC:
1Bwo1Htd47rLRM4PZhydWtoC5ZAR4Fv9KZ
- USDT: binance-qr
David Arenas 🇻🇪
This project is licensed under MIT