parse a bundle generated by browser-pack
JavaScript
Latest commit 870d1cd Mar 1, 2017 substack 1.2.0
Permalink
Failed to load latest commit information.
bin usage and -h Dec 24, 2013
example entries properly work Dec 24, 2013
test Merge branch 'fix-identifier' of https://github.com/mattdesl/browser-… Jul 19, 2015
.travis.yml npm is broken Feb 28, 2014
LICENSE package.json Dec 24, 2013
index.js upgrade acorn Jul 19, 2015
package.json 1.2.0 Mar 1, 2017
readme.markdown using travis Dec 24, 2013

readme.markdown

browser-unpack

parse a bundle generated by browser-pack

build status

example

$ node main.js
129.50502147699586
$ browserify main.js > bundle.js
$ browser-unpack < bundle.js
[
{"id":"/home/substack/projects/browser-unpack/example/foo.js","source":"module.exports = function (n) { return n * 111 }\n\n","deps":{}}
,
{"id":"/home/substack/projects/browser-unpack/example/main.js","source":"var foo = require('./foo.js');\nvar gamma = require('gamma');\n\nconsole.log(foo(gamma(2.3)));","deps":{"./foo.js":"/home/substack/projects/browser-unpack/example/foo.js","gamma":"/home/substack/projects/browser-unpack/node_modules/gamma/index.js"},"entry":true}
,
{"id":"/home/substack/projects/browser-unpack/node_modules/gamma/index.js","source":"var g = 7;\nvar p = [\n    0.99999999999980993,\n    676.5203681218851,\n    -1259.1392167224028,\n    771.32342877765313,\n    -176.61502916214059,\n    12.507343278686905,\n    -0.13857109526572012,\n    9.9843695780195716e-6,\n    1.5056327351493116e-7\n];\n\nvar g_ln = 607/128;\nvar p_ln = [\n    0.99999999999999709182,\n    57.156235665862923517,\n    -59.597960355475491248,\n    14.136097974741747174,\n    -0.49191381609762019978,\n    0.33994649984811888699e-4,\n    0.46523628927048575665e-4,\n    -0.98374475304879564677e-4,\n    0.15808870322491248884e-3,\n    -0.21026444172410488319e-3,\n    0.21743961811521264320e-3,\n    -0.16431810653676389022e-3,\n    0.84418223983852743293e-4,\n    -0.26190838401581408670e-4,\n    0.36899182659531622704e-5\n];\n\n// Spouge approximation (suitable for large arguments)\nfunction lngamma(z) {\n\n    if(z < 0) return Number('0/0');\n    var x = p_ln[0];\n    for(var i = p_ln.length - 1; i > 0; --i) x += p_ln[i] / (z + i);\n    var t = z + g_ln + 0.5;\n    return .5*Math.log(2*Math.PI)+(z+.5)*Math.log(t)-t+Math.log(x)-Math.log(z);\n}\n\nmodule.exports = function gamma (z) {\n    if (z < 0.5) {\n        return Math.PI / (Math.sin(Math.PI * z) * gamma(1 - z));\n    }\n    else if(z > 100) return Math.exp(lngamma(z));\n    else {\n        z -= 1;\n        var x = p[0];\n        for (var i = 1; i < g + 2; i++) {\n            x += p[i] / (z + i);\n        }\n        var t = z + g + 0.5;\n\n        return Math.sqrt(2 * Math.PI)\n            * Math.pow(t, z + 0.5)\n            * Math.exp(-t)\n            * x\n        ;\n    }\n};\n\nmodule.exports.log = lngamma;","deps":{}}
]
$ browser-unpack < bundle.js | browser-pack | node
129.50502147699586

usage

usage: browser-unpack

  Write a browser bundle to STDIN.
  Outputs a JSON array in the module-deps format.

methods

var unpack = require('browser-unpack')

var rows = unpack(src)

Return an array of rows from the bundle source string src.

install

With npm do:

npm install browser-unpack

license

MIT