0.1.3 • Published 12 years ago

wrapit v0.1.3

Weekly downloads
5
License
-
Repository
github
Last release
12 years ago

Webservice to wrap any web resource in a header and footer. Good for wrapping javascript files in require calls.

Getting started

npm install wrapit

Command-line usage

 wrapit [options]

This starts a wrapit web service using the specified command-line options.

-p port to listen on (example, 85)
-q suppress the help message

Web service usage

http://localhost/?url=http://codemirror.net/lib/codemirror.js&header=provide('CodeMirror',function(require,exports,module){&footer=exports.CodeMirror=CodeMirror;})&type=text/javascript&type=text/javascript

There are four parts to this, ?url &header &footer &type. Let's break that up:

http://localhost/
**?url=**http://codemirror.net/lib/codemirror.js
**&header=**provide('CodeMirror',function(require,exports,module){
**&footer=**exports.CodeMirror=CodeMirror;})
**&type=**text/javascript

In this case, the url is http://codemirror.net/lib/codemirror.js, which gets wrapped in a 'provide' definition (taken from require-shim). Type signifies the mime type.

Of course, you can use whatever require library you want. Also, you don't have to just wrap javascript files -- you can wrap css or html or anything else for that matter. wrapit doesn't care.

Server-side usage

require('http').createServer(function (req, res) {
	require('wrapit').handleRequest(req, res);
}).listen(port);	

Run the Example

There is an example.html file in the local directory, demonstrating how to run uglify-js in a web page without installing anything (even Node.js) on your local machine.

Why might this be useful?

This utility is designed to help a web developer quickly prototype namespaced javascript code, but there are probably other uses as well.

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago

0.0.9

12 years ago

0.0.8

12 years ago

0.0.6

12 years ago

0.0.5

12 years ago

0.0.4-1

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2-1

12 years ago