Options
All
  • Public
  • Public/Protected
  • All
Menu

virtual-module

NPM version NPM downloads CircleCI chat

Evaluate a module in sandbox. This package is extracted and modified from vue-server-renderer.

Install

yarn add virtual-module

Usage

const { createModule } = require('virtual-module')

const evaluate = createModule({
  'entry.js': `
    const isThree = require('is-three.js')
    module.exports = context => isThree(context.a + context.b)
  `,
  'is-three.js': `
    module.exports = input => input === 3
  `
})

evaluate('entry.js')({ a: 1, b: 2 })
//=> true

evaluate('is-three.js')(4)
//=> false

API

https://virtual-module.egoist.sh

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

virtual-module © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).

egoist.sh · GitHub @EGOIST · Twitter @_egoistlily

Index

Interfaces

Type aliases

Functions

Type aliases

EvaluateModule

EvaluateModule: function

Type declaration

    • <TModuleExports, TFile>(file: TFile): TModuleExports
    • Type parameters

      • TModuleExports: any

      • TFile: string

      Parameters

      • file: TFile

      Returns TModuleExports

Functions

createModule

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc