This package has been deprecated

Author message:

This package is no longer being maintained. You should not use it.

wadsworth

1.0.0 • Public • Published

wadsworth

GitHub license Build Status npm Project Status

Easily serve plain JS scripts to the browser with auto-generated HTML.

It will automatically create the HTML page that the JS script will run in, and will show the console output (using console.log, etc.) on the page.

Show console output

Example

const serve = require('wadsworth');
const http = require('http');
 
const src = 'alert("Hello World!");';
 
http.createServer(serve({ src: src })).listen(8000);
 
// View http://localhost:8000/ in your browser to be alerted

Also with Express:

const express = require('express');
const serve = require('wadsworth');
 
const src = 'alert("Hello World!);';
 
express()
  .use(server({ src }))
  .listen(8000);

Options

Pass the options object as the first argument to the wadsworth function. It will return a function that can be used as a request listener for a server that will serve the automatically generated HTML and JS code.

The returned function can also be used as Connect middleware.

src

The src option can be either a string, stream, or a function. If it is a function, it must call the provided callback with an optional error and a string or stream.

Examples:

server({
  src: 'alert("Hello World!");'
});
server({
  src: browserify().add('test.js').bundle()
});
serve({
  src: function(callback) {
    callback(myError, mySource);
  }
});

noConsole

The noConsole argument will disable the console redirection when it is true. By default, the generated HTML page will display the output that was printed to the console with console.log. If noConsole is true, this behavior is disabled.

wadsworth(1)

Creates an HTTP server that serves the provided JS script to browsers. To make available globally, install with npm install -g wadsworth.

Usage: wadsworth [file] [options]

file specifies the JS file to serve. If no file is provided, uses stdin.

Options

  • -p, --port: The HTTP port to listen on (default 8000).
  • --no-console: Do not show console.log output on the web page.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Published

Version History

  • Version
    Downloads (Last 7 Days)
    • Published

Package Sidebar

Install

npm i wadsworth

Weekly Downloads

0

Version

1.0.0

License

BSD-2-Clause

Unpacked Size

18.9 kB

Total Files

14

Last publish

Collaborators

  • w33ble