Class Index | File Index

Classes


Namespace modulify

Namepsace for atropa's modulify.
Defined in: <src/modulify.js>.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Namepsace for atropa's modulify.
Method Summary
Method Attributes Method Name and Description
<static>  
modulify.file(srcFile)
Converts a javascript file into a commonjs module.
<static>  
modulify.string(src)
Converts a string of source code into a commonjs module.
Namespace Detail
modulify
Namepsace for atropa's modulify.
Method Detail
<static> {String} modulify.file(srcFile)
Converts a javascript file into a commonjs module. **Caution** This function runs the given script through eval so if the script is supposed to do things like delete all your files, then it will.
 var str = modulify.file('myfile.js');
 console.log(str);
Parameters:
{String} srcFile
The path to the file to evaluate.
Returns:
{String} Returns a script as a string. The script will be a commonjs module exporting the new global properties, vars, and functions declared in the top scope. The module exports statements will be wrapped in a try catch block so the script will continue to work in the browser and only export if `module.exports` is assignable.
Requires:
fs
esprima

<static> {String} modulify.string(src)
Converts a string of source code into a commonjs module. **Caution** This function runs the given script through eval so if the script is supposed to do things like delete all your files, then it will.
 var src = 'a = "global prop"; ' +
     'var d = "I am a declared variable"; function e () {};';
 var str = modulify.string(src);
 console.log(str);
Parameters:
{String} src
The source code to evaluate.
Returns:
{String} Returns a script as a string. The script will be a commonjs module exporting the new global properties, vars, and functions declared in the top scope. The module exports statements will be wrapped in a try catch block so the script will continue to work in the browser and only export if `module.exports` is assignable.
Requires:
esprima

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Nov 17 2022 17:54:29 GMT-0500 (Eastern Standard Time)