File: readme.markdown

package info (click to toggle)
node-browser-unpack 1.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 232 kB
  • sloc: javascript: 626; makefile: 6
file content (56 lines) | stat: -rw-r--r-- 2,995 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# browser-unpack

parse a bundle generated by
[browser-pack](https://npmjs.org/package/browser-pack)

[![build status](https://secure.travis-ci.org/browserify/browser-unpack.png)](http://travis-ci.org/browserify/browser-unpack)

# 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

``` js
var unpack = require('browser-unpack')
```

## var rows = unpack(src)

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

# install

With [npm](https://npmjs.org) do:

```
npm install browser-unpack
```

# license

MIT