0.1.8 • Published 2 years ago

eval v0.1.8

Weekly downloads
162,928
License
-
Repository
github
Last release
2 years ago

Eval - require() for module content!

Overview

This module is a simple way to evaluate a module content in the same way as require() but without loading it from a file. Effectively, it mimicks the javascript evil eval function but leverages Node's VM module instead.

Benefits

Why would you be using the eval module over the nativerequire? Most of the time require is fine but in some situations, I have found myself wishing for the following:

  • Ability to supply a context to a module
  • Ability to load the module file(s) from non node standard places

Or simply to leverage JavaScript's eval but with sandboxing.

Download

It is published on node package manager (npm). To install, do:

npm install eval

Usage

var _eval = require('eval')
var res = _eval(content /*, filename, scope, includeGlobals */)

The following options are available:

  • content (String): the content to be evaluated
  • filename (String): optional dummy name to be given (used in stacktraces)
  • scope (Object): scope properties are provided as variables to the content
  • includeGlobals (Boolean): allow/disallow global variables (and require) to be supplied to the content (default=false)

Examples

var _eval = require('eval')
var res = _eval('var x = 123; exports.x = x')
// => res === { x: 123 }

res = _eval('module.exports = function () { return 123 }')
// => res() === 123

res = _eval('module.exports = require("events")', true)
// => res === require('events')

res = _eval('exports.x = process', true)
// => res.x === process

License

Here

meiroo-steedos-server@equippedcoding/appfactoryrollup-plugin-treat@everything-registry/sub-chunk-1621@andybau/kala@aunovis/beam-nodes@alicloud/gatsby-plugin-mdx-forkconnectorjs-client@decago/typescript-extractor@bitev.io/core@blastlauncher/runtime@box-extractor/vanilla-extract@box-extractor/vanilla-windzzzxxxyyy321123priyanshbotpriyanshbot12react-html-webpack-pluginsea-floorserver-mockudias-clivite-plugin-verceltreattransformationserviceunidays-javascriptunidays-offer-redemption-jstypescript-react-router-static-html-webpack-plugintypewindwavy-apiwebpack-plugin-react-to-htmlustwo.com-frontendtldrawligninsocket-pouchsocket-pouchdbsitegensvelticsom-exp-sdksom-exp-sdk1steedos-serverstexenginestatic-generator-webpack-pluginstatic-html-webpack-pluginstream-playgroundspl-js-enginestatic-render-webpack-pluginstatic-webpack-pluginstatic-react-render-webpack-pluginstatic-site-generator-webpack-pluginrequire-lsrollup-plugin-externalrollup-plugin-inlinesagittareactor-jsrioct-clisku-for-testingrc-loaderreact-static-page-webpack-pluginreact-static-renderer-webpackreact-static-site-webpack-pluginreact-static-webpack-plugin-thorreact-to-html-webpackreact-to-html-webpack-pluginreact-to-static-html-webpack-pluginredactcordrender-async@christian-villar/unit-testclearest@crackle/core@crackle-solid/corecortexmap@equippedcoding/appfactory-cli@endiliey/static-site-generator-webpack-plugin@eztool/unit-test6ix@intrnl/vite-plugin-vanilla-extract-runtime@intrnl/esbuild-plugin-vanilla-extractdozencomptime-css-esbuild@glzr/vanilla-extract-integration@kaze-style/build@kaze-style/build-man@kaze-style/builder@kuma-ui/vite@kuma-ui/webpack-plugin@makesenseorg/design-system@mxmul/vanilla-extract-snowpack-plugin@lunde/webpack@mattsjones/css-webpack-plugin@nlabs/webpack-plugin-static-site@moonthug/m0ck@isotope/docking@optimistdigital/create-frontendi18n-temp@saulx/aristotle-watcherjseval-confine-runtimelede-cli@terra/actionslilieming_nice@sa-labs/graphql-directory-api@sa-labs/leo-corejavaboxes
0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

7 years ago

0.1.1

9 years ago

0.1.0

11 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago