Sha256: a47661625d3aba1bedaea8f2d410a2f83b02e0e02c34bbeb0b5f04870fab236a
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
recipes ======= Here are some recipe-style examples for getting started. use an npm module in the browser ================================ First install a module: ``` npm install traverse ``` Then write an `entry.js`: ````javascript var traverse = require('traverse'); var obj = traverse({ a : 3, b : [ 4, 5 ] }).map(function (x) { if (typeof x === 'number') this.update(x * 100) }); console.dir(obj); ```` now bundle it! ``` $ browserify entry.js -o bundle.js ``` then put it in your html ``` html <script src="bundle.js"></script> ``` and the entry.js will just run and `require('traverse')` will just workâ˘. convert a node module into a browser require-able standalone file ----------------------------------------------------------------- Install the `traverse` package into `./node_modules`: ``` npm install traverse ``` Bundle everything up with browserify: ``` $ npm install -g browserify $ browserify -r traverse -o bundle.js ``` Look at the files! There is a new one: `bundle.js`. Now go into HTML land: ``` html <script src="bundle.js"></script> <script> var traverse = require('traverse'); </script> ```
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sprockets-browserify-0.1.2 | node_modules/browserify/doc/recipes.markdown |
sprockets-browserify-0.1.0 | node_modules/browserify/doc/recipes.markdown |