Socket
Socket
Sign inDemoInstall

static-module

Package Overview
Dependencies
23
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    static-module

convert module usage to inline expressions


Version published
Weekly downloads
1.2M
increased by7.18%
Maintainers
1
Install size
4.03 MB
Created
Weekly downloads
 

Readme

Source

static-module

convert module usage to inline expressions

build status

example

Here's a simplified version of the brfs module using static-module.

brfs converts fs.readFileSync(file) calls to inline strings with the contents of file included in-place.

var staticModule = require('static-module');
var quote = require('quote-stream');
var fs = require('fs');

var sm = staticModule({
    fs: {
        readFileSync: function (file) {
            return fs.createReadStream(file).pipe(quote());
        }
    }
}, { vars: { __dirname: __dirname + '/brfs' } });
process.stdin.pipe(sm).pipe(process.stdout);

input:

$ cat brfs/source.js
var fs = require('fs');
var src = fs.readFileSync(__dirname + '/x.txt');
console.log(src);

output:

$ node brfs.js < brfs/source.js 

var src = "beep boop\n";
console.log(src);

methods

var staticModule = require('static-module')

var sm = staticModule(modules, opts={})

Return a transform stream sm that transforms javascript source input to javascript source output with each property in the modules object expanded in inline form.

Properties in the modules object can be ordinary values that will be included directly or functions that will be executed with the statically evaluated arguments from the source under an optional set of opts.vars variables.

Property functions can return streams, in which case their contents will be piped directly into the source output.

install

With npm do:

npm install static-module

license

MIT

Keywords

FAQs

Last updated on 22 Apr 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc