Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

import-string

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

import-string

This package allow us to import code from simple string, with support to:

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

import-string

This package allow us to import code from simple string, with support to:

  • node
  • deno
  • bun

🚀 Getting started

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

📖 Usage

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
}

💻 Development

  1. Clone this repository
  2. Install dependencies using pnpm install

Send a PR with the feat|fix|refactor etc

🛟 Support

  • BTC: 1Bwo1Htd47rLRM4PZhydWtoC5ZAR4Fv9KZ
  • USDT: binance-qr

Author

David Arenas 🇻🇪

License

This project is licensed under MIT

Keywords

FAQs

Package last updated on 15 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc