From 9aa23239469a6c2851296ac7a6d19960819f1127 Mon Sep 17 00:00:00 2001 From: macmenot Date: Tue, 8 Jul 2014 19:37:21 +0100 Subject: [PATCH] Remove dependencies from nodeunit git --- .gitignore | 1 + node_modules/.bin/tap | 1 - node_modules/.bin/uglifyjs | 1 - node_modules/qbox/.project | 17 - node_modules/qbox/.settings/.jsdtscope | 4 - ...rg.eclipse.wst.jsdt.ui.superType.container | 1 - .../org.eclipse.wst.jsdt.ui.superType.name | 1 - node_modules/qbox/lib-cov/qbox.js | 221 - node_modules/qbox/lib/qbox.js | 122 - node_modules/qbox/package.json | 23 - node_modules/qbox/readme.md | 58 - node_modules/qbox/tests/qbox.js | 188 - node_modules/should/.gitmodules | 3 - node_modules/should/.npmignore | 1 - node_modules/should/History.md | 94 - node_modules/should/Makefile | 6 - node_modules/should/Readme.md | 367 -- node_modules/should/examples/runner.js | 53 - node_modules/should/index.js | 2 - node_modules/should/lib/eql.js | 91 - node_modules/should/lib/should.js | 693 --- node_modules/should/package.json | 13 - node_modules/should/test/exist.test.js | 96 - node_modules/should/test/should.test.js | 534 -- node_modules/tap-assert/AUTHORS | 2 - node_modules/tap-assert/LICENSE | 23 - node_modules/tap-assert/README.md | 3 - node_modules/tap-assert/assert.js | 396 -- node_modules/tap-assert/package.json | 29 - node_modules/tap-producer/README.md | 4 - .../node_modules/inherits/README.md | 51 - .../node_modules/inherits/inherits.js | 29 - .../node_modules/inherits/package.json | 7 - .../node_modules/tap-results/README.md | 2 - .../node_modules/tap-results/package.json | 11 - .../node_modules/tap-results/results.js | 68 - .../tap-producer/node_modules/yamlish/LICENSE | 19 - .../node_modules/yamlish/README.md | 20 - .../node_modules/yamlish/package.json | 9 - .../node_modules/yamlish/yamlish.js | 221 - node_modules/tap-producer/package.json | 12 - node_modules/tap-producer/tap-producer.js | 113 - node_modules/tap/.npmignore | 0 node_modules/tap/AUTHORS | 8 - node_modules/tap/LICENSE | 23 - node_modules/tap/README.md | 82 - node_modules/tap/bin/tap-http.js | 19 - node_modules/tap/bin/tap-reader.js | 33 - node_modules/tap/bin/tap.js | 127 - node_modules/tap/coverage-example/lib/bar.js | 15 - node_modules/tap/coverage-example/lib/foo.js | 15 - .../tap/coverage-example/test/bar.test.js | 20 - .../tap/coverage-example/test/baz.test.js | 29 - .../tap/coverage-example/test/foo.test.js | 20 - node_modules/tap/example/lib/math.js | 1 - node_modules/tap/example/test/test-example.js | 237 - node_modules/tap/lib/harness.js | 130 - node_modules/tap/lib/main.js | 16 - node_modules/tap/lib/tap-assert.js | 430 -- node_modules/tap/lib/tap-browser-harness.js | 63 - node_modules/tap/lib/tap-consumer.js | 243 - node_modules/tap/lib/tap-cov-html.js | 78 - node_modules/tap/lib/tap-global-harness.js | 68 - node_modules/tap/lib/tap-harness.js | 219 - node_modules/tap/lib/tap-producer.js | 125 - node_modules/tap/lib/tap-results.js | 71 - node_modules/tap/lib/tap-runner.js | 434 -- node_modules/tap/lib/tap-test.js | 109 - node_modules/tap/node_modules/.bin/nopt | 1 - .../node_modules/deep-equal/README.markdown | 55 - .../node_modules/deep-equal/example/cmp.js | 11 - .../tap/node_modules/deep-equal/index.js | 84 - .../tap/node_modules/deep-equal/package.json | 33 - .../tap/node_modules/deep-equal/test/cmp.js | 18 - .../tap/node_modules/difflet/.travis.yml | 4 - .../tap/node_modules/difflet/README.markdown | 116 - .../node_modules/difflet/example/cmp_array.js | 6 - .../difflet/example/cmp_object.js | 6 - .../node_modules/difflet/example/colors.js | 18 - .../difflet/example/comma_first.js | 12 - .../tap/node_modules/difflet/example/html.js | 34 - .../node_modules/difflet/example/string.js | 4 - node_modules/tap/node_modules/difflet/fail.js | 9 - .../tap/node_modules/difflet/index.js | 357 -- .../node_modules/charm/README.markdown | 199 - .../node_modules/charm/example/column.js | 10 - .../node_modules/charm/example/cursor.js | 22 - .../node_modules/charm/example/http_spin.js | 35 - .../node_modules/charm/example/lucky.js | 30 - .../node_modules/charm/example/position.js | 7 - .../node_modules/charm/example/progress.js | 16 - .../node_modules/charm/example/spin.js | 23 - .../difflet/node_modules/charm/index.js | 267 - .../difflet/node_modules/charm/lib/encode.js | 18 - .../difflet/node_modules/charm/package.json | 32 - .../difflet/node_modules/traverse/.npmignore | 1 - .../difflet/node_modules/traverse/LICENSE | 24 - .../node_modules/traverse/README.markdown | 256 - .../node_modules/traverse/examples/json.js | 16 - .../node_modules/traverse/examples/leaves.js | 15 - .../traverse/examples/negative.js | 8 - .../node_modules/traverse/examples/scrub.js | 10 - .../traverse/examples/stringify.js | 38 - .../difflet/node_modules/traverse/index.js | 279 - .../node_modules/traverse/package.json | 18 - .../node_modules/traverse/test/circular.js | 115 - .../node_modules/traverse/test/date.js | 35 - .../node_modules/traverse/test/equal.js | 220 - .../difflet/node_modules/traverse/test/has.js | 13 - .../node_modules/traverse/test/instance.js | 17 - .../node_modules/traverse/test/interface.js | 42 - .../node_modules/traverse/test/json.js | 47 - .../node_modules/traverse/test/keys.js | 29 - .../node_modules/traverse/test/leaves.js | 21 - .../traverse/test/lib/deep_equal.js | 92 - .../node_modules/traverse/test/mutability.js | 252 - .../node_modules/traverse/test/negative.js | 20 - .../difflet/node_modules/traverse/test/obj.js | 15 - .../node_modules/traverse/test/siblings.js | 35 - .../node_modules/traverse/test/stop.js | 41 - .../node_modules/traverse/test/stringify.js | 36 - .../node_modules/traverse/test/subexpr.js | 34 - .../node_modules/traverse/test/super_deep.js | 55 - .../node_modules/traverse/testling/leaves.js | 22 - .../tap/node_modules/difflet/package.json | 41 - .../tap/node_modules/difflet/test/html.js | 80 - .../tap/node_modules/inherits/LICENSE | 26 - .../tap/node_modules/inherits/README.md | 51 - .../tap/node_modules/inherits/inherits-old.js | 40 - .../tap/node_modules/inherits/inherits.js | 29 - .../tap/node_modules/inherits/package.json | 8 - .../tap/node_modules/mkdirp/.gitignore.orig | 2 - .../tap/node_modules/mkdirp/.gitignore.rej | 5 - .../tap/node_modules/mkdirp/.npmignore | 2 - node_modules/tap/node_modules/mkdirp/LICENSE | 21 - .../tap/node_modules/mkdirp/README.markdown | 54 - .../tap/node_modules/mkdirp/examples/pow.js | 6 - .../node_modules/mkdirp/examples/pow.js.orig | 6 - .../node_modules/mkdirp/examples/pow.js.rej | 19 - node_modules/tap/node_modules/mkdirp/index.js | 90 - .../tap/node_modules/mkdirp/package.json | 23 - .../tap/node_modules/mkdirp/test/chmod.js | 39 - .../tap/node_modules/mkdirp/test/clobber.js | 37 - .../tap/node_modules/mkdirp/test/mkdirp.js | 28 - .../tap/node_modules/mkdirp/test/perm.js | 32 - .../tap/node_modules/mkdirp/test/perm_sync.js | 39 - .../tap/node_modules/mkdirp/test/race.js | 41 - .../tap/node_modules/mkdirp/test/rel.js | 32 - .../tap/node_modules/mkdirp/test/sync.js | 27 - .../tap/node_modules/mkdirp/test/umask.js | 28 - .../node_modules/mkdirp/test/umask_sync.js | 27 - node_modules/tap/node_modules/nopt/.npmignore | 0 node_modules/tap/node_modules/nopt/LICENSE | 23 - node_modules/tap/node_modules/nopt/README.md | 208 - .../tap/node_modules/nopt/bin/nopt.js | 44 - .../node_modules/nopt/examples/my-program.js | 30 - .../tap/node_modules/nopt/lib/nopt.js | 552 -- .../nopt/node_modules/abbrev/README.md | 23 - .../nopt/node_modules/abbrev/lib/abbrev.js | 106 - .../nopt/node_modules/abbrev/package.json | 8 - .../tap/node_modules/nopt/package.json | 12 - .../node_modules/runforcover/README.markdown | 56 - .../tap/node_modules/runforcover/index.js | 127 - .../node_modules/bunker/.npmignore | 1 - .../node_modules/bunker/README.markdown | 80 - .../node_modules/bunker/example/prof.js | 51 - .../node_modules/bunker/example/tiny.js | 18 - .../node_modules/bunker/example/top/run.js | 31 - .../node_modules/bunker/example/top/src.js | 18 - .../runforcover/node_modules/bunker/index.js | 101 - .../bunker/node_modules/burrito/.npmignore | 1 - .../node_modules/burrito/README.markdown | 185 - .../bunker/node_modules/burrito/browserify.js | 4296 --------------- .../node_modules/burrito/example/microwave.js | 7 - .../node_modules/burrito/example/web/bs.js | 4832 ----------------- .../burrito/example/web/index.html | 14 - .../node_modules/burrito/example/web/main.js | 17 - .../burrito/example/web/server.js | 12 - .../node_modules/burrito/example/wrap.js | 7 - .../bunker/node_modules/burrito/index.html | 8 - .../bunker/node_modules/burrito/index.js | 208 - .../bunker/node_modules/burrito/main.js | 11 - .../burrito/node_modules/.bin/uglifyjs | 1 - .../burrito/node_modules/traverse/.npmignore | 1 - .../burrito/node_modules/traverse/LICENSE | 24 - .../node_modules/traverse/README.markdown | 237 - .../node_modules/traverse/examples/json.js | 16 - .../node_modules/traverse/examples/leaves.js | 15 - .../traverse/examples/negative.js | 8 - .../node_modules/traverse/examples/scrub.js | 10 - .../traverse/examples/stringify.js | 38 - .../burrito/node_modules/traverse/index.js | 267 - .../burrito/node_modules/traverse/main.js | 10 - .../node_modules/traverse/package.json | 18 - .../node_modules/traverse/test/circular.js | 115 - .../node_modules/traverse/test/date.js | 35 - .../node_modules/traverse/test/equal.js | 220 - .../node_modules/traverse/test/instance.js | 17 - .../node_modules/traverse/test/interface.js | 42 - .../node_modules/traverse/test/json.js | 47 - .../node_modules/traverse/test/keys.js | 29 - .../node_modules/traverse/test/leaves.js | 21 - .../traverse/test/lib/deep_equal.js | 92 - .../node_modules/traverse/test/mutability.js | 252 - .../node_modules/traverse/test/negative.js | 20 - .../burrito/node_modules/traverse/test/obj.js | 15 - .../node_modules/traverse/test/siblings.js | 35 - .../node_modules/traverse/test/stop.js | 41 - .../node_modules/traverse/test/stringify.js | 36 - .../node_modules/traverse/test/subexpr.js | 34 - .../node_modules/traverse/test/super_deep.js | 55 - .../burrito/node_modules/uglify-js/.npmignore | 4 - .../node_modules/uglify-js/README.html | 888 --- .../burrito/node_modules/uglify-js/README.org | 463 -- .../node_modules/uglify-js/bin/uglifyjs | 317 -- .../node_modules/uglify-js/docstyle.css | 75 - .../node_modules/uglify-js/lib/object-ast.js | 75 - .../node_modules/uglify-js/lib/parse-js.js | 1341 ----- .../node_modules/uglify-js/lib/process.js | 1949 ------- .../uglify-js/lib/squeeze-more.js | 51 - .../node_modules/uglify-js/package.json | 22 - .../node_modules/uglify-js/test/beautify.js | 28 - .../node_modules/uglify-js/test/testparser.js | 402 -- .../test/unit/compress/expected/array1.js | 1 - .../test/unit/compress/expected/array2.js | 1 - .../test/unit/compress/expected/array3.js | 1 - .../test/unit/compress/expected/array4.js | 1 - .../test/unit/compress/expected/assignment.js | 1 - .../unit/compress/expected/concatstring.js | 1 - .../test/unit/compress/expected/const.js | 1 - .../unit/compress/expected/empty-blocks.js | 1 - .../unit/compress/expected/forstatement.js | 1 - .../test/unit/compress/expected/if.js | 1 - .../test/unit/compress/expected/ifreturn.js | 1 - .../test/unit/compress/expected/ifreturn2.js | 1 - .../test/unit/compress/expected/issue10.js | 1 - .../test/unit/compress/expected/issue11.js | 1 - .../test/unit/compress/expected/issue13.js | 1 - .../test/unit/compress/expected/issue14.js | 1 - .../test/unit/compress/expected/issue16.js | 1 - .../test/unit/compress/expected/issue17.js | 1 - .../test/unit/compress/expected/issue20.js | 1 - .../test/unit/compress/expected/issue21.js | 1 - .../test/unit/compress/expected/issue25.js | 1 - .../test/unit/compress/expected/issue27.js | 1 - .../test/unit/compress/expected/issue28.js | 1 - .../test/unit/compress/expected/issue29.js | 1 - .../test/unit/compress/expected/issue30.js | 1 - .../test/unit/compress/expected/issue34.js | 1 - .../test/unit/compress/expected/issue4.js | 1 - .../test/unit/compress/expected/issue48.js | 1 - .../test/unit/compress/expected/issue50.js | 1 - .../test/unit/compress/expected/issue53.js | 1 - .../test/unit/compress/expected/issue54.1.js | 1 - .../test/unit/compress/expected/issue68.js | 1 - .../test/unit/compress/expected/issue69.js | 1 - .../test/unit/compress/expected/issue9.js | 1 - .../test/unit/compress/expected/mangle.js | 1 - .../unit/compress/expected/strict-equals.js | 1 - .../test/unit/compress/expected/var.js | 1 - .../test/unit/compress/expected/with.js | 1 - .../test/unit/compress/test/array1.js | 3 - .../test/unit/compress/test/array2.js | 4 - .../test/unit/compress/test/array3.js | 4 - .../test/unit/compress/test/array4.js | 6 - .../test/unit/compress/test/assignment.js | 20 - .../test/unit/compress/test/concatstring.js | 3 - .../test/unit/compress/test/const.js | 5 - .../test/unit/compress/test/empty-blocks.js | 4 - .../test/unit/compress/test/forstatement.js | 10 - .../uglify-js/test/unit/compress/test/if.js | 6 - .../test/unit/compress/test/ifreturn.js | 9 - .../test/unit/compress/test/ifreturn2.js | 16 - .../test/unit/compress/test/issue10.js | 1 - .../test/unit/compress/test/issue11.js | 3 - .../test/unit/compress/test/issue13.js | 1 - .../test/unit/compress/test/issue14.js | 1 - .../test/unit/compress/test/issue16.js | 1 - .../test/unit/compress/test/issue17.js | 4 - .../test/unit/compress/test/issue20.js | 1 - .../test/unit/compress/test/issue21.js | 6 - .../test/unit/compress/test/issue25.js | 7 - .../test/unit/compress/test/issue27.js | 1 - .../test/unit/compress/test/issue28.js | 3 - .../test/unit/compress/test/issue29.js | 1 - .../test/unit/compress/test/issue30.js | 3 - .../test/unit/compress/test/issue34.js | 3 - .../test/unit/compress/test/issue4.js | 3 - .../test/unit/compress/test/issue48.js | 1 - .../test/unit/compress/test/issue50.js | 9 - .../test/unit/compress/test/issue53.js | 1 - .../test/unit/compress/test/issue54.1.js | 3 - .../test/unit/compress/test/issue68.js | 5 - .../test/unit/compress/test/issue69.js | 1 - .../test/unit/compress/test/issue9.js | 4 - .../test/unit/compress/test/mangle.js | 5 - .../test/unit/compress/test/strict-equals.js | 3 - .../uglify-js/test/unit/compress/test/var.js | 3 - .../uglify-js/test/unit/compress/test/with.js | 2 - .../uglify-js/test/unit/scripts.js | 55 - .../node_modules/uglify-js/tmp/hoist.js | 33 - .../node_modules/uglify-js/tmp/instrument.js | 97 - .../node_modules/uglify-js/tmp/instrument2.js | 138 - .../node_modules/uglify-js/tmp/test.js | 16 - .../node_modules/uglify-js/uglify-js.js | 17 - .../bunker/node_modules/burrito/package.json | 43 - .../bunker/node_modules/burrito/server.js | 4 - .../bunker/node_modules/burrito/test/ast.js | 29 - .../bunker/node_modules/burrito/test/err.js | 47 - .../bunker/node_modules/burrito/test/fail.js | 8 - .../node_modules/burrito/test/fail/src.js | 60 - .../bunker/node_modules/burrito/test/label.js | 110 - .../node_modules/burrito/test/microwave.js | 33 - .../node_modules/burrito/test/parent.js | 26 - .../bunker/node_modules/burrito/test/wrap.js | 157 - .../node_modules/bunker/package.json | 35 - .../node_modules/bunker/test/cover.js | 35 - .../node_modules/bunker/test/src/cover.js | 6 - .../tap/node_modules/runforcover/package.json | 32 - .../node_modules/runforcover/test/index.js | 1 - .../runforcover/test/interface.js | 50 - .../runforcover/test/src/coverage.js | 7 - node_modules/tap/node_modules/slide/README.md | 27 - node_modules/tap/node_modules/slide/index.js | 1 - .../slide/lib/async-map-ordered.js | 65 - .../tap/node_modules/slide/lib/async-map.js | 56 - .../tap/node_modules/slide/lib/bind-actor.js | 16 - .../tap/node_modules/slide/lib/chain.js | 20 - .../tap/node_modules/slide/lib/slide.js | 3 - .../slide/nodejs-controlling-flow.pdf | Bin 167502 -> 0 bytes .../tap/node_modules/slide/package.json | 19 - node_modules/tap/node_modules/yamlish/LICENSE | 19 - .../tap/node_modules/yamlish/README.md | 20 - .../tap/node_modules/yamlish/package.json | 9 - .../tap/node_modules/yamlish/yamlish.js | 260 - node_modules/tap/package.json | 40 - node_modules/tap/test-disabled/bailout.js | 36 - node_modules/tap/test-disabled/foo.js | 1 - node_modules/tap/test-disabled/t.js | 16 - node_modules/tap/test/common.js | 32 - node_modules/tap/test/deep.js | 43 - node_modules/tap/test/independent-timeouts.js | 16 - node_modules/tap/test/isolated-conf-test.js | 16 - node_modules/tap/test/meta-test.js | 58 - node_modules/tap/test/nested-test.js | 23 - node_modules/tap/test/non-tap-output.js | 12 - node_modules/tap/test/result-trap.js | 25 - .../tap/test/simple-harness-test-with-plan.js | 16 - node_modules/tap/test/simple-harness-test.js | 13 - node_modules/tap/test/test-test.js | 91 - node_modules/tap/test/timeout.js | 33 - node_modules/tap/test/trivial-success.js | 0 node_modules/uglify-js/.gitignore | 4 - node_modules/uglify-js/README.html | 1026 ---- node_modules/uglify-js/README.org | 571 -- node_modules/uglify-js/bin/uglifyjs | 317 -- node_modules/uglify-js/docstyle.css | 75 - node_modules/uglify-js/lib/object-ast.js | 75 - node_modules/uglify-js/lib/parse-js.js | 1339 ----- node_modules/uglify-js/lib/process.js | 2001 ------- node_modules/uglify-js/lib/squeeze-more.js | 51 - node_modules/uglify-js/package.json | 24 - node_modules/uglify-js/test/beautify.js | 28 - node_modules/uglify-js/test/testparser.js | 403 -- .../test/unit/compress/expected/array1.js | 1 - .../test/unit/compress/expected/array2.js | 1 - .../test/unit/compress/expected/array3.js | 1 - .../test/unit/compress/expected/array4.js | 1 - .../test/unit/compress/expected/assignment.js | 1 - .../unit/compress/expected/concatstring.js | 1 - .../test/unit/compress/expected/const.js | 1 - .../unit/compress/expected/empty-blocks.js | 1 - .../unit/compress/expected/forstatement.js | 1 - .../test/unit/compress/expected/if.js | 1 - .../test/unit/compress/expected/ifreturn.js | 1 - .../test/unit/compress/expected/ifreturn2.js | 1 - .../test/unit/compress/expected/issue10.js | 1 - .../test/unit/compress/expected/issue11.js | 1 - .../test/unit/compress/expected/issue13.js | 1 - .../test/unit/compress/expected/issue14.js | 1 - .../test/unit/compress/expected/issue16.js | 1 - .../test/unit/compress/expected/issue17.js | 1 - .../test/unit/compress/expected/issue20.js | 1 - .../test/unit/compress/expected/issue21.js | 1 - .../test/unit/compress/expected/issue25.js | 1 - .../test/unit/compress/expected/issue27.js | 1 - .../test/unit/compress/expected/issue28.js | 1 - .../test/unit/compress/expected/issue29.js | 1 - .../test/unit/compress/expected/issue30.js | 1 - .../test/unit/compress/expected/issue34.js | 1 - .../test/unit/compress/expected/issue4.js | 1 - .../test/unit/compress/expected/issue48.js | 1 - .../test/unit/compress/expected/issue50.js | 1 - .../test/unit/compress/expected/issue53.js | 1 - .../test/unit/compress/expected/issue54.1.js | 1 - .../test/unit/compress/expected/issue68.js | 1 - .../test/unit/compress/expected/issue69.js | 1 - .../test/unit/compress/expected/issue9.js | 1 - .../test/unit/compress/expected/mangle.js | 1 - .../unit/compress/expected/null_string.js | 1 - .../unit/compress/expected/strict-equals.js | 1 - .../test/unit/compress/expected/var.js | 1 - .../test/unit/compress/expected/whitespace.js | 1 - .../test/unit/compress/expected/with.js | 1 - .../test/unit/compress/test/array1.js | 3 - .../test/unit/compress/test/array2.js | 4 - .../test/unit/compress/test/array3.js | 4 - .../test/unit/compress/test/array4.js | 6 - .../test/unit/compress/test/assignment.js | 20 - .../test/unit/compress/test/concatstring.js | 3 - .../test/unit/compress/test/const.js | 5 - .../test/unit/compress/test/empty-blocks.js | 4 - .../test/unit/compress/test/forstatement.js | 10 - .../uglify-js/test/unit/compress/test/if.js | 6 - .../test/unit/compress/test/ifreturn.js | 9 - .../test/unit/compress/test/ifreturn2.js | 16 - .../test/unit/compress/test/issue10.js | 1 - .../test/unit/compress/test/issue11.js | 3 - .../test/unit/compress/test/issue13.js | 1 - .../test/unit/compress/test/issue14.js | 1 - .../test/unit/compress/test/issue16.js | 1 - .../test/unit/compress/test/issue17.js | 4 - .../test/unit/compress/test/issue20.js | 1 - .../test/unit/compress/test/issue21.js | 6 - .../test/unit/compress/test/issue25.js | 7 - .../test/unit/compress/test/issue27.js | 1 - .../test/unit/compress/test/issue28.js | 3 - .../test/unit/compress/test/issue29.js | 1 - .../test/unit/compress/test/issue30.js | 3 - .../test/unit/compress/test/issue34.js | 3 - .../test/unit/compress/test/issue4.js | 3 - .../test/unit/compress/test/issue48.js | 1 - .../test/unit/compress/test/issue50.js | 9 - .../test/unit/compress/test/issue53.js | 1 - .../test/unit/compress/test/issue54.1.js | 3 - .../test/unit/compress/test/issue68.js | 5 - .../test/unit/compress/test/issue69.js | 1 - .../test/unit/compress/test/issue9.js | 4 - .../test/unit/compress/test/mangle.js | 5 - .../test/unit/compress/test/null_string.js | 1 - .../test/unit/compress/test/strict-equals.js | 3 - .../uglify-js/test/unit/compress/test/var.js | 3 - .../test/unit/compress/test/whitespace.js | 21 - .../uglify-js/test/unit/compress/test/with.js | 2 - node_modules/uglify-js/test/unit/scripts.js | 55 - node_modules/uglify-js/tmp/hoist.js | 33 - node_modules/uglify-js/tmp/instrument.js | 97 - node_modules/uglify-js/tmp/instrument2.js | 138 - node_modules/uglify-js/tmp/test.js | 30 - node_modules/uglify-js/uglify-js.js | 17 - 450 files changed, 1 insertion(+), 37484 deletions(-) delete mode 120000 node_modules/.bin/tap delete mode 120000 node_modules/.bin/uglifyjs delete mode 100644 node_modules/qbox/.project delete mode 100644 node_modules/qbox/.settings/.jsdtscope delete mode 100644 node_modules/qbox/.settings/org.eclipse.wst.jsdt.ui.superType.container delete mode 100644 node_modules/qbox/.settings/org.eclipse.wst.jsdt.ui.superType.name delete mode 100644 node_modules/qbox/lib-cov/qbox.js delete mode 100644 node_modules/qbox/lib/qbox.js delete mode 100644 node_modules/qbox/package.json delete mode 100644 node_modules/qbox/readme.md delete mode 100644 node_modules/qbox/tests/qbox.js delete mode 100644 node_modules/should/.gitmodules delete mode 100644 node_modules/should/.npmignore delete mode 100644 node_modules/should/History.md delete mode 100644 node_modules/should/Makefile delete mode 100644 node_modules/should/Readme.md delete mode 100644 node_modules/should/examples/runner.js delete mode 100644 node_modules/should/index.js delete mode 100644 node_modules/should/lib/eql.js delete mode 100644 node_modules/should/lib/should.js delete mode 100644 node_modules/should/package.json delete mode 100644 node_modules/should/test/exist.test.js delete mode 100644 node_modules/should/test/should.test.js delete mode 100644 node_modules/tap-assert/AUTHORS delete mode 100644 node_modules/tap-assert/LICENSE delete mode 100644 node_modules/tap-assert/README.md delete mode 100644 node_modules/tap-assert/assert.js delete mode 100644 node_modules/tap-assert/package.json delete mode 100644 node_modules/tap-producer/README.md delete mode 100644 node_modules/tap-producer/node_modules/inherits/README.md delete mode 100644 node_modules/tap-producer/node_modules/inherits/inherits.js delete mode 100644 node_modules/tap-producer/node_modules/inherits/package.json delete mode 100644 node_modules/tap-producer/node_modules/tap-results/README.md delete mode 100644 node_modules/tap-producer/node_modules/tap-results/package.json delete mode 100644 node_modules/tap-producer/node_modules/tap-results/results.js delete mode 100644 node_modules/tap-producer/node_modules/yamlish/LICENSE delete mode 100644 node_modules/tap-producer/node_modules/yamlish/README.md delete mode 100644 node_modules/tap-producer/node_modules/yamlish/package.json delete mode 100644 node_modules/tap-producer/node_modules/yamlish/yamlish.js delete mode 100644 node_modules/tap-producer/package.json delete mode 100644 node_modules/tap-producer/tap-producer.js delete mode 100644 node_modules/tap/.npmignore delete mode 100644 node_modules/tap/AUTHORS delete mode 100644 node_modules/tap/LICENSE delete mode 100644 node_modules/tap/README.md delete mode 100644 node_modules/tap/bin/tap-http.js delete mode 100755 node_modules/tap/bin/tap-reader.js delete mode 100755 node_modules/tap/bin/tap.js delete mode 100644 node_modules/tap/coverage-example/lib/bar.js delete mode 100644 node_modules/tap/coverage-example/lib/foo.js delete mode 100644 node_modules/tap/coverage-example/test/bar.test.js delete mode 100644 node_modules/tap/coverage-example/test/baz.test.js delete mode 100644 node_modules/tap/coverage-example/test/foo.test.js delete mode 100644 node_modules/tap/example/lib/math.js delete mode 100644 node_modules/tap/example/test/test-example.js delete mode 100644 node_modules/tap/lib/harness.js delete mode 100644 node_modules/tap/lib/main.js delete mode 100644 node_modules/tap/lib/tap-assert.js delete mode 100644 node_modules/tap/lib/tap-browser-harness.js delete mode 100644 node_modules/tap/lib/tap-consumer.js delete mode 100644 node_modules/tap/lib/tap-cov-html.js delete mode 100644 node_modules/tap/lib/tap-global-harness.js delete mode 100644 node_modules/tap/lib/tap-harness.js delete mode 100644 node_modules/tap/lib/tap-producer.js delete mode 100644 node_modules/tap/lib/tap-results.js delete mode 100644 node_modules/tap/lib/tap-runner.js delete mode 100644 node_modules/tap/lib/tap-test.js delete mode 120000 node_modules/tap/node_modules/.bin/nopt delete mode 100644 node_modules/tap/node_modules/deep-equal/README.markdown delete mode 100644 node_modules/tap/node_modules/deep-equal/example/cmp.js delete mode 100644 node_modules/tap/node_modules/deep-equal/index.js delete mode 100644 node_modules/tap/node_modules/deep-equal/package.json delete mode 100644 node_modules/tap/node_modules/deep-equal/test/cmp.js delete mode 100644 node_modules/tap/node_modules/difflet/.travis.yml delete mode 100644 node_modules/tap/node_modules/difflet/README.markdown delete mode 100644 node_modules/tap/node_modules/difflet/example/cmp_array.js delete mode 100644 node_modules/tap/node_modules/difflet/example/cmp_object.js delete mode 100644 node_modules/tap/node_modules/difflet/example/colors.js delete mode 100644 node_modules/tap/node_modules/difflet/example/comma_first.js delete mode 100644 node_modules/tap/node_modules/difflet/example/html.js delete mode 100644 node_modules/tap/node_modules/difflet/example/string.js delete mode 100644 node_modules/tap/node_modules/difflet/fail.js delete mode 100644 node_modules/tap/node_modules/difflet/index.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/README.markdown delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/example/column.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/example/cursor.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/example/http_spin.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/example/lucky.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/example/position.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/example/progress.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/example/spin.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/index.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/lib/encode.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/charm/package.json delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/.npmignore delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/LICENSE delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/README.markdown delete mode 100755 node_modules/tap/node_modules/difflet/node_modules/traverse/examples/json.js delete mode 100755 node_modules/tap/node_modules/difflet/node_modules/traverse/examples/leaves.js delete mode 100755 node_modules/tap/node_modules/difflet/node_modules/traverse/examples/negative.js delete mode 100755 node_modules/tap/node_modules/difflet/node_modules/traverse/examples/scrub.js delete mode 100755 node_modules/tap/node_modules/difflet/node_modules/traverse/examples/stringify.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/index.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/package.json delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/circular.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/date.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/equal.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/has.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/instance.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/interface.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/json.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/keys.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/leaves.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/lib/deep_equal.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/mutability.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/negative.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/obj.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/siblings.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/stop.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/stringify.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/subexpr.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/test/super_deep.js delete mode 100644 node_modules/tap/node_modules/difflet/node_modules/traverse/testling/leaves.js delete mode 100644 node_modules/tap/node_modules/difflet/package.json delete mode 100644 node_modules/tap/node_modules/difflet/test/html.js delete mode 100644 node_modules/tap/node_modules/inherits/LICENSE delete mode 100644 node_modules/tap/node_modules/inherits/README.md delete mode 100644 node_modules/tap/node_modules/inherits/inherits-old.js delete mode 100644 node_modules/tap/node_modules/inherits/inherits.js delete mode 100644 node_modules/tap/node_modules/inherits/package.json delete mode 100644 node_modules/tap/node_modules/mkdirp/.gitignore.orig delete mode 100644 node_modules/tap/node_modules/mkdirp/.gitignore.rej delete mode 100644 node_modules/tap/node_modules/mkdirp/.npmignore delete mode 100644 node_modules/tap/node_modules/mkdirp/LICENSE delete mode 100644 node_modules/tap/node_modules/mkdirp/README.markdown delete mode 100644 node_modules/tap/node_modules/mkdirp/examples/pow.js delete mode 100644 node_modules/tap/node_modules/mkdirp/examples/pow.js.orig delete mode 100644 node_modules/tap/node_modules/mkdirp/examples/pow.js.rej delete mode 100644 node_modules/tap/node_modules/mkdirp/index.js delete mode 100644 node_modules/tap/node_modules/mkdirp/package.json delete mode 100644 node_modules/tap/node_modules/mkdirp/test/chmod.js delete mode 100644 node_modules/tap/node_modules/mkdirp/test/clobber.js delete mode 100644 node_modules/tap/node_modules/mkdirp/test/mkdirp.js delete mode 100644 node_modules/tap/node_modules/mkdirp/test/perm.js delete mode 100644 node_modules/tap/node_modules/mkdirp/test/perm_sync.js delete mode 100644 node_modules/tap/node_modules/mkdirp/test/race.js delete mode 100644 node_modules/tap/node_modules/mkdirp/test/rel.js delete mode 100644 node_modules/tap/node_modules/mkdirp/test/sync.js delete mode 100644 node_modules/tap/node_modules/mkdirp/test/umask.js delete mode 100644 node_modules/tap/node_modules/mkdirp/test/umask_sync.js delete mode 100644 node_modules/tap/node_modules/nopt/.npmignore delete mode 100644 node_modules/tap/node_modules/nopt/LICENSE delete mode 100644 node_modules/tap/node_modules/nopt/README.md delete mode 100755 node_modules/tap/node_modules/nopt/bin/nopt.js delete mode 100755 node_modules/tap/node_modules/nopt/examples/my-program.js delete mode 100644 node_modules/tap/node_modules/nopt/lib/nopt.js delete mode 100644 node_modules/tap/node_modules/nopt/node_modules/abbrev/README.md delete mode 100644 node_modules/tap/node_modules/nopt/node_modules/abbrev/lib/abbrev.js delete mode 100644 node_modules/tap/node_modules/nopt/node_modules/abbrev/package.json delete mode 100644 node_modules/tap/node_modules/nopt/package.json delete mode 100644 node_modules/tap/node_modules/runforcover/README.markdown delete mode 100644 node_modules/tap/node_modules/runforcover/index.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/.npmignore delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/README.markdown delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/example/prof.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/example/tiny.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/run.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/src.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/index.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.npmignore delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/README.markdown delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/browserify.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/microwave.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/bs.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/index.html delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/main.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/server.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/wrap.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.html delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/main.js delete mode 120000 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/.bin/uglifyjs delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/.npmignore delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/LICENSE delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/README.markdown delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/json.js delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/leaves.js delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/negative.js delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/scrub.js delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/stringify.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/index.js delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/main.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/package.json delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/circular.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/date.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/equal.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/instance.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/interface.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/json.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/keys.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/leaves.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/mutability.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/negative.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/obj.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/siblings.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stop.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stringify.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/subexpr.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/super_deep.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/.npmignore delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.html delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.org delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/bin/uglifyjs delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/docstyle.css delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/lib/object-ast.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/lib/process.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/package.json delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/beautify.js delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/testparser.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array1.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array2.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array3.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/array4.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/assignment.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/concatstring.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/const.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/forstatement.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/if.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue10.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue11.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue13.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue14.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue16.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue17.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue20.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue21.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue25.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue27.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue28.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue29.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue30.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue34.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue4.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue48.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue50.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue53.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue68.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue69.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/issue9.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/mangle.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/var.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/expected/with.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array1.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array2.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array3.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/array4.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/assignment.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/concatstring.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/const.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/forstatement.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/if.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/ifreturn.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/ifreturn2.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue10.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue11.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue13.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue14.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue16.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue17.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue20.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue21.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue25.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue27.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue28.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue29.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue30.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue34.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue4.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue48.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue50.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue53.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue54.1.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue68.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue69.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/issue9.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/mangle.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/strict-equals.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/var.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/compress/test/with.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/test/unit/scripts.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/tmp/hoist.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/tmp/instrument.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/tmp/instrument2.js delete mode 100755 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/tmp/test.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/uglify-js.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/package.json delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/server.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/test/ast.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/test/err.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/test/fail.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/test/fail/src.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/test/label.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/test/microwave.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/test/parent.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/test/wrap.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/package.json delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/test/cover.js delete mode 100644 node_modules/tap/node_modules/runforcover/node_modules/bunker/test/src/cover.js delete mode 100644 node_modules/tap/node_modules/runforcover/package.json delete mode 100644 node_modules/tap/node_modules/runforcover/test/index.js delete mode 100644 node_modules/tap/node_modules/runforcover/test/interface.js delete mode 100644 node_modules/tap/node_modules/runforcover/test/src/coverage.js delete mode 100644 node_modules/tap/node_modules/slide/README.md delete mode 100644 node_modules/tap/node_modules/slide/index.js delete mode 100644 node_modules/tap/node_modules/slide/lib/async-map-ordered.js delete mode 100644 node_modules/tap/node_modules/slide/lib/async-map.js delete mode 100644 node_modules/tap/node_modules/slide/lib/bind-actor.js delete mode 100644 node_modules/tap/node_modules/slide/lib/chain.js delete mode 100644 node_modules/tap/node_modules/slide/lib/slide.js delete mode 100644 node_modules/tap/node_modules/slide/nodejs-controlling-flow.pdf delete mode 100644 node_modules/tap/node_modules/slide/package.json delete mode 100644 node_modules/tap/node_modules/yamlish/LICENSE delete mode 100644 node_modules/tap/node_modules/yamlish/README.md delete mode 100644 node_modules/tap/node_modules/yamlish/package.json delete mode 100644 node_modules/tap/node_modules/yamlish/yamlish.js delete mode 100644 node_modules/tap/package.json delete mode 100644 node_modules/tap/test-disabled/bailout.js delete mode 100644 node_modules/tap/test-disabled/foo.js delete mode 100644 node_modules/tap/test-disabled/t.js delete mode 100644 node_modules/tap/test/common.js delete mode 100644 node_modules/tap/test/deep.js delete mode 100644 node_modules/tap/test/independent-timeouts.js delete mode 100644 node_modules/tap/test/isolated-conf-test.js delete mode 100644 node_modules/tap/test/meta-test.js delete mode 100644 node_modules/tap/test/nested-test.js delete mode 100644 node_modules/tap/test/non-tap-output.js delete mode 100644 node_modules/tap/test/result-trap.js delete mode 100644 node_modules/tap/test/simple-harness-test-with-plan.js delete mode 100644 node_modules/tap/test/simple-harness-test.js delete mode 100644 node_modules/tap/test/test-test.js delete mode 100644 node_modules/tap/test/timeout.js delete mode 100644 node_modules/tap/test/trivial-success.js delete mode 100644 node_modules/uglify-js/.gitignore delete mode 100644 node_modules/uglify-js/README.html delete mode 100644 node_modules/uglify-js/README.org delete mode 100755 node_modules/uglify-js/bin/uglifyjs delete mode 100644 node_modules/uglify-js/docstyle.css delete mode 100644 node_modules/uglify-js/lib/object-ast.js delete mode 100644 node_modules/uglify-js/lib/parse-js.js delete mode 100644 node_modules/uglify-js/lib/process.js delete mode 100644 node_modules/uglify-js/lib/squeeze-more.js delete mode 100644 node_modules/uglify-js/package.json delete mode 100755 node_modules/uglify-js/test/beautify.js delete mode 100755 node_modules/uglify-js/test/testparser.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/array1.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/array2.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/array3.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/array4.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/assignment.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/concatstring.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/const.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/forstatement.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/if.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/ifreturn.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue10.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue11.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue13.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue14.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue16.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue17.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue20.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue21.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue25.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue27.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue28.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue29.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue30.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue34.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue4.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue48.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue50.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue53.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue54.1.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue68.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue69.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/issue9.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/mangle.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/null_string.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/strict-equals.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/var.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/whitespace.js delete mode 100644 node_modules/uglify-js/test/unit/compress/expected/with.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/array1.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/array2.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/array3.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/array4.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/assignment.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/concatstring.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/const.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/empty-blocks.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/forstatement.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/if.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/ifreturn.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/ifreturn2.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue10.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue11.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue13.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue14.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue16.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue17.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue20.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue21.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue25.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue27.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue28.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue29.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue30.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue34.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue4.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue48.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue50.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue53.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue54.1.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue68.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue69.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/issue9.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/mangle.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/null_string.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/strict-equals.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/var.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/whitespace.js delete mode 100644 node_modules/uglify-js/test/unit/compress/test/with.js delete mode 100644 node_modules/uglify-js/test/unit/scripts.js delete mode 100644 node_modules/uglify-js/tmp/hoist.js delete mode 100644 node_modules/uglify-js/tmp/instrument.js delete mode 100644 node_modules/uglify-js/tmp/instrument2.js delete mode 100755 node_modules/uglify-js/tmp/test.js delete mode 100644 node_modules/uglify-js/uglify-js.js diff --git a/.gitignore b/.gitignore index 627ae169d..22152199e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ stamp-build gmon.out v8.log .DS_Store +node_modules diff --git a/node_modules/.bin/tap b/node_modules/.bin/tap deleted file mode 120000 index 999914bf5..000000000 --- a/node_modules/.bin/tap +++ /dev/null @@ -1 +0,0 @@ -../tap/bin/tap.js \ No newline at end of file diff --git a/node_modules/.bin/uglifyjs b/node_modules/.bin/uglifyjs deleted file mode 120000 index fef3468b6..000000000 --- a/node_modules/.bin/uglifyjs +++ /dev/null @@ -1 +0,0 @@ -../uglify-js/bin/uglifyjs \ No newline at end of file diff --git a/node_modules/qbox/.project b/node_modules/qbox/.project deleted file mode 100644 index 9230c3728..000000000 --- a/node_modules/qbox/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Queue Box - - - - - - org.eclipse.wst.jsdt.core.javascriptValidator - - - - - - org.eclipse.wst.jsdt.core.jsNature - - diff --git a/node_modules/qbox/.settings/.jsdtscope b/node_modules/qbox/.settings/.jsdtscope deleted file mode 100644 index 0e4b119ca..000000000 --- a/node_modules/qbox/.settings/.jsdtscope +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/node_modules/qbox/.settings/org.eclipse.wst.jsdt.ui.superType.container b/node_modules/qbox/.settings/org.eclipse.wst.jsdt.ui.superType.container deleted file mode 100644 index 49c8cd4f1..000000000 --- a/node_modules/qbox/.settings/org.eclipse.wst.jsdt.ui.superType.container +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.wst.jsdt.launching.JRE_CONTAINER \ No newline at end of file diff --git a/node_modules/qbox/.settings/org.eclipse.wst.jsdt.ui.superType.name b/node_modules/qbox/.settings/org.eclipse.wst.jsdt.ui.superType.name deleted file mode 100644 index 11006e2a5..000000000 --- a/node_modules/qbox/.settings/org.eclipse.wst.jsdt.ui.superType.name +++ /dev/null @@ -1 +0,0 @@ -Global \ No newline at end of file diff --git a/node_modules/qbox/lib-cov/qbox.js b/node_modules/qbox/lib-cov/qbox.js deleted file mode 100644 index 93282e20f..000000000 --- a/node_modules/qbox/lib-cov/qbox.js +++ /dev/null @@ -1,221 +0,0 @@ -/* automatically generated by JSCoverage - do not edit */ -if (typeof _$jscoverage === 'undefined') _$jscoverage = {}; -if (! _$jscoverage['qbox.js']) { - _$jscoverage['qbox.js'] = []; - _$jscoverage['qbox.js'][1] = 0; - _$jscoverage['qbox.js'][2] = 0; - _$jscoverage['qbox.js'][4] = 0; - _$jscoverage['qbox.js'][6] = 0; - _$jscoverage['qbox.js'][7] = 0; - _$jscoverage['qbox.js'][8] = 0; - _$jscoverage['qbox.js'][9] = 0; - _$jscoverage['qbox.js'][11] = 0; - _$jscoverage['qbox.js'][12] = 0; - _$jscoverage['qbox.js'][14] = 0; - _$jscoverage['qbox.js'][16] = 0; - _$jscoverage['qbox.js'][19] = 0; - _$jscoverage['qbox.js'][22] = 0; - _$jscoverage['qbox.js'][23] = 0; - _$jscoverage['qbox.js'][24] = 0; - _$jscoverage['qbox.js'][26] = 0; - _$jscoverage['qbox.js'][34] = 0; - _$jscoverage['qbox.js'][35] = 0; - _$jscoverage['qbox.js'][36] = 0; - _$jscoverage['qbox.js'][37] = 0; - _$jscoverage['qbox.js'][38] = 0; - _$jscoverage['qbox.js'][40] = 0; - _$jscoverage['qbox.js'][41] = 0; - _$jscoverage['qbox.js'][49] = 0; - _$jscoverage['qbox.js'][50] = 0; - _$jscoverage['qbox.js'][53] = 0; - _$jscoverage['qbox.js'][55] = 0; - _$jscoverage['qbox.js'][56] = 0; - _$jscoverage['qbox.js'][57] = 0; - _$jscoverage['qbox.js'][58] = 0; - _$jscoverage['qbox.js'][60] = 0; - _$jscoverage['qbox.js'][62] = 0; - _$jscoverage['qbox.js'][63] = 0; - _$jscoverage['qbox.js'][65] = 0; - _$jscoverage['qbox.js'][66] = 0; - _$jscoverage['qbox.js'][67] = 0; - _$jscoverage['qbox.js'][71] = 0; - _$jscoverage['qbox.js'][74] = 0; - _$jscoverage['qbox.js'][82] = 0; - _$jscoverage['qbox.js'][84] = 0; - _$jscoverage['qbox.js'][85] = 0; - _$jscoverage['qbox.js'][86] = 0; - _$jscoverage['qbox.js'][87] = 0; - _$jscoverage['qbox.js'][93] = 0; - _$jscoverage['qbox.js'][94] = 0; - _$jscoverage['qbox.js'][101] = 0; - _$jscoverage['qbox.js'][102] = 0; - _$jscoverage['qbox.js'][103] = 0; - _$jscoverage['qbox.js'][104] = 0; - _$jscoverage['qbox.js'][105] = 0; - _$jscoverage['qbox.js'][106] = 0; - _$jscoverage['qbox.js'][110] = 0; - _$jscoverage['qbox.js'][111] = 0; - _$jscoverage['qbox.js'][112] = 0; - _$jscoverage['qbox.js'][113] = 0; - _$jscoverage['qbox.js'][114] = 0; - _$jscoverage['qbox.js'][118] = 0; - _$jscoverage['qbox.js'][120] = 0; - _$jscoverage['qbox.js'][121] = 0; -} -_$jscoverage['qbox.js'][1]++; -var util = require("util"); -_$jscoverage['qbox.js'][2]++; -var EventEmitter = require("events").EventEmitter; -_$jscoverage['qbox.js'][4]++; -function QBox(steps) { - _$jscoverage['qbox.js'][6]++; - var isReady = false; - _$jscoverage['qbox.js'][7]++; - var queue = []; - _$jscoverage['qbox.js'][8]++; - var isStop = false; - _$jscoverage['qbox.js'][9]++; - var startingCallback; - _$jscoverage['qbox.js'][11]++; - var ticks; - _$jscoverage['qbox.js'][12]++; - var countingSteps = null; - _$jscoverage['qbox.js'][14]++; - if (typeof steps == "number") { - _$jscoverage['qbox.js'][16]++; - countingSteps = steps; - } - else { - _$jscoverage['qbox.js'][19]++; - addTicks(); - } - _$jscoverage['qbox.js'][22]++; - this.ready = (function (callback) { - _$jscoverage['qbox.js'][23]++; - if (isReady && ! isStop) { - _$jscoverage['qbox.js'][24]++; - callback(); - } - else { - _$jscoverage['qbox.js'][26]++; - queue.push(callback); - } -}); - _$jscoverage['qbox.js'][34]++; - this.start = (function () { - _$jscoverage['qbox.js'][35]++; - if (! isStop) { - _$jscoverage['qbox.js'][36]++; - isReady = true; - _$jscoverage['qbox.js'][37]++; - queue.forEach((function (callback) { - _$jscoverage['qbox.js'][38]++; - callback(); -})); - _$jscoverage['qbox.js'][40]++; - queue = []; - _$jscoverage['qbox.js'][41]++; - if (startingCallback) { - _$jscoverage['qbox.js'][41]++; - startingCallback(); - } - } -}); - _$jscoverage['qbox.js'][49]++; - this.onStart = (function (callback) { - _$jscoverage['qbox.js'][50]++; - startingCallback = callback; -}); - _$jscoverage['qbox.js'][53]++; - this.tick = (function (step) { - _$jscoverage['qbox.js'][55]++; - if (countingSteps != null) { - _$jscoverage['qbox.js'][56]++; - countingSteps--; - _$jscoverage['qbox.js'][57]++; - if (countingSteps == 0) { - _$jscoverage['qbox.js'][58]++; - this.start(); - } - } - else { - _$jscoverage['qbox.js'][60]++; - if (ticks && ticks instanceof Array) { - _$jscoverage['qbox.js'][62]++; - var index = ticks.indexOf(step); - _$jscoverage['qbox.js'][63]++; - if (index >= 0) { - _$jscoverage['qbox.js'][65]++; - ticks.splice(index, 1); - _$jscoverage['qbox.js'][66]++; - if (ticks.length == 0) { - _$jscoverage['qbox.js'][67]++; - this.start(); - } - } - else { - _$jscoverage['qbox.js'][71]++; - throw new Error("Invalid step: '" + step + "' provided"); - } - } - else { - _$jscoverage['qbox.js'][74]++; - throw new Error("Cannot tick - no steps are provided"); - } - } -}); - _$jscoverage['qbox.js'][82]++; - this.timeout = (function (amount, callback) { - _$jscoverage['qbox.js'][84]++; - if (! isStop) { - _$jscoverage['qbox.js'][85]++; - setTimeout((function () { - _$jscoverage['qbox.js'][86]++; - if (! isReady && ! isStop) { - _$jscoverage['qbox.js'][87]++; - callback(ticks); - } -}), amount); - } -}); - _$jscoverage['qbox.js'][93]++; - this.stop = (function () { - _$jscoverage['qbox.js'][94]++; - isStop = true; -}); - _$jscoverage['qbox.js'][101]++; - this.reset = (function () { - _$jscoverage['qbox.js'][102]++; - isReady = false; - _$jscoverage['qbox.js'][103]++; - isStop = false; - _$jscoverage['qbox.js'][104]++; - addTicks(); - _$jscoverage['qbox.js'][105]++; - if (countingSteps != null) { - _$jscoverage['qbox.js'][106]++; - countingSteps = steps; - } -}); - _$jscoverage['qbox.js'][110]++; - function addTicks() { - _$jscoverage['qbox.js'][111]++; - if (steps && steps.length > 0) { - _$jscoverage['qbox.js'][112]++; - ticks = []; - _$jscoverage['qbox.js'][113]++; - steps.forEach((function (tick) { - _$jscoverage['qbox.js'][114]++; - ticks.push(tick); -})); - } -} -} -_$jscoverage['qbox.js'][118]++; -; -_$jscoverage['qbox.js'][120]++; -exports.create = (function (steps) { - _$jscoverage['qbox.js'][121]++; - return new QBox(steps); -}); -_$jscoverage['qbox.js'].source = ["var util = require('util');","var EventEmitter = require('events').EventEmitter;","","function QBox(steps) {","\t","\tvar isReady = false;","\tvar queue = [];","\tvar isStop = false;","\tvar startingCallback;","","\tvar ticks;","\tvar countingSteps = null;","","\tif(typeof(steps) == 'number') {","\t\t//used for steps in a number","\t\tcountingSteps = steps;","\t} else {","\t\t//used for steps as an array","\t\taddTicks(); //copy steps into ticks","\t}","","\tthis.ready = function(callback) {","\t\tif(isReady && !isStop) {","\t\t\tcallback();","\t\t} else {","\t\t\tqueue.push(callback);","\t\t}","\t};","\t","\t/**","\t\tStart the QBox and execute all the callbacks in the queue","\t\tand clear the queue","\t*/","\tthis.start = function() {","\t\tif(!isStop) {","\t\t\tisReady = true;","\t\t\tqueue.forEach(function(callback) {","\t\t\t\tcallback();","\t\t\t});","\t\t\tqueue = [];","\t\t\tif(startingCallback) startingCallback();","\t\t}","\t};","","\t/**","\t\tAdd a single callback to call each and every time ","\t\tQbox starting (mostely used with reset())","\t*/","\tthis.onStart = function(callback) {","\t\tstartingCallback = callback;","\t};","\t","\tthis.tick = function(step) {","\t\t","\t\tif(countingSteps != null) {","\t\t\tcountingSteps--;","\t\t\tif(countingSteps == 0) {","\t\t\t\tthis.start();","\t\t\t}","\t\t} else if(ticks && ticks instanceof Array) {","\t\t\t","\t\t\tvar index = ticks.indexOf(step);","\t\t\tif(index >= 0) {","\t\t\t\t","\t\t\t\tticks.splice(index, 1);","\t\t\t\tif(ticks.length == 0) {","\t\t\t\t\tthis.start();","\t\t\t\t}","\t\t\t} else {","\t\t\t\t","\t\t\t\tthrow new Error(\"Invalid step: '\" + step + \"' provided\");","\t\t\t}","\t\t} else {","\t\t\tthrow new Error(\"Cannot tick - no steps are provided\");","\t\t}","\t};","\t","\t/**","\t * @param amount - no of millies fot timeout","\t * callback - function([]){} containing remaining steps","\t */","\tthis.timeout = function(amount, callback) {","\t\t","\t\tif(!isStop) {","\t\t\tsetTimeout(function() {","\t\t\t\tif(!isReady && !isStop) {","\t\t\t\t\tcallback(ticks);","\t\t\t\t}","\t\t\t}, amount);","\t\t}","\t};","\t","\tthis.stop = function() {","\t\tisStop = true;","\t};","","\t/**","\t\tReset the QBOX and make is available to start again","\t\tAnd does not clean callbacks in the queue and onStart Callback","\t*/","\tthis.reset = function() {","\t\tisReady = false;","\t\tisStop = false;","\t\taddTicks();","\t\tif(countingSteps != null) {","\t\t\tcountingSteps = steps;","\t\t}","\t};","","\tfunction addTicks() {","\t\tif(steps && steps.length > 0) {","\t\t\tticks = [];","\t\t\tsteps.forEach(function(tick) {","\t\t\t\tticks.push(tick);","\t\t\t});","\t\t}","\t}","};","","exports.create = function(steps) {","\treturn new QBox(steps);","};"]; diff --git a/node_modules/qbox/lib/qbox.js b/node_modules/qbox/lib/qbox.js deleted file mode 100644 index e3440c6e2..000000000 --- a/node_modules/qbox/lib/qbox.js +++ /dev/null @@ -1,122 +0,0 @@ -var util = require('util'); -var EventEmitter = require('events').EventEmitter; - -function QBox(steps) { - - var isReady = false; - var queue = []; - var isStop = false; - var startingCallback; - - var ticks; - var countingSteps = null; - - if(typeof(steps) == 'number') { - //used for steps in a number - countingSteps = steps; - } else { - //used for steps as an array - addTicks(); //copy steps into ticks - } - - this.ready = function(callback) { - if(isReady && !isStop) { - callback(); - } else { - queue.push(callback); - } - }; - - /** - Start the QBox and execute all the callbacks in the queue - and clear the queue - */ - this.start = function() { - if(!isStop) { - isReady = true; - queue.forEach(function(callback) { - callback(); - }); - queue = []; - if(startingCallback) startingCallback(); - } - }; - - /** - Add a single callback to call each and every time - Qbox starting (mostely used with reset()) - */ - this.onStart = function(callback) { - startingCallback = callback; - }; - - this.tick = function(step) { - - if(countingSteps != null) { - countingSteps--; - if(countingSteps == 0) { - this.start(); - } - } else if(ticks && ticks instanceof Array) { - - var index = ticks.indexOf(step); - if(index >= 0) { - - ticks.splice(index, 1); - if(ticks.length == 0) { - this.start(); - } - } else { - - throw new Error("Invalid step: '" + step + "' provided"); - } - } else { - throw new Error("Cannot tick - no steps are provided"); - } - }; - - /** - * @param amount - no of millies fot timeout - * callback - function([]){} containing remaining steps - */ - this.timeout = function(amount, callback) { - - if(!isStop) { - setTimeout(function() { - if(!isReady && !isStop) { - callback(ticks); - } - }, amount); - } - }; - - this.stop = function() { - isStop = true; - }; - - /** - Reset the QBOX and make is available to start again - And does not clean callbacks in the queue and onStart Callback - */ - this.reset = function() { - isReady = false; - isStop = false; - addTicks(); - if(countingSteps != null) { - countingSteps = steps; - } - }; - - function addTicks() { - if(steps && steps.length > 0) { - ticks = []; - steps.forEach(function(tick) { - ticks.push(tick); - }); - } - } -}; - -exports.create = function(steps) { - return new QBox(steps); -}; diff --git a/node_modules/qbox/package.json b/node_modules/qbox/package.json deleted file mode 100644 index 7a41f280b..000000000 --- a/node_modules/qbox/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "qbox", - "version": "0.1.7", - "directories": { - "lib": "./lib" - }, - "main": "./lib/qbox", - "description": "JQuery like queue solution for NodeJs", - "author": "Arunoda Susiripala ", - "homepage": "https://github.com/arunoda/qbox", - "licenses": [ - { - "type": "The MIT License", - "url": "http://www.opensource.org/licenses/mit-license.php" - } - ], - - "repository" : - { - "type" : "git", - "url" : "git@github.com:arunoda/qbox.git" - } -} diff --git a/node_modules/qbox/readme.md b/node_modules/qbox/readme.md deleted file mode 100644 index 618da0e77..000000000 --- a/node_modules/qbox/readme.md +++ /dev/null @@ -1,58 +0,0 @@ -QBox - Quick Flow Control library for NodeJS -======================================= - -Introduction ------------- - -There are whole a bunch of NodeJS Flow Control libraries exists. -In order to use most of them you need change the way how you program. -Or learn some new syntax. - -*Qbox* is meant for people who loves to code using their natural style -but also to control the flow of the code as they wish. - -Install ---------- - npm install qbox - -Usage ------ - -### Complete After Something happens - -I need to do some tasks after I connect've connect with the database - - var db = qbox.create(); - - mydatabase.connect(function() { - $.start(); - }); - - $.ready(function() { - //do something - }); - - //at somewhere else in your programme - $.ready(function() { - //do some other stuff - }); - -### Complete After Some Few things happens - -I need to do some task after I'm connected to database and registry - - var go = qbox.ready(['db', 'registry']); - - mydatabase.connect(function() { go.tick('db'); }); - registry.connect(function() { go.tick('db'); }); - - go.ready(function() { - //do something - }); - - //timeout after 5 seconds - go.timeout(5000, function() { - //show the errors - }); - -Browse [Tests](https://github.com/arunoda/qbox/blob/master/tests/qbox.js) for more usage patterns \ No newline at end of file diff --git a/node_modules/qbox/tests/qbox.js b/node_modules/qbox/tests/qbox.js deleted file mode 100644 index 8fa633440..000000000 --- a/node_modules/qbox/tests/qbox.js +++ /dev/null @@ -1,188 +0,0 @@ -var qbox = require("qbox"); - -exports.testSteps = function(test) { - - test.expect(1); - var $ = qbox.create(["db1", "db2"]); - $.ready(function() { - test.ok(true); - }); - - $.tick("db1"); - $.tick("db2"); - test.done(); -}; - -exports.testStepsInvalid = function(test) { - - var $ = qbox.create(["db1", "db2"]); - $.ready(function() { - test.fail(); - }); - - $.tick("db1"); - test.throws(function() { - $.tick("db222"); - }); - test.done(); -}; - -exports.testTimeout = function(test) { - - test.expect(1); - var $ = qbox.create(["db1", "db2"]); - $.ready(function() { - test.fail(); - }); - - $.tick("db1"); - var start = new Date().getTime(); - $.timeout(200, function() { - var end = new Date().getTime(); - if(end-start >= 200) { - test.ok(true); - test.done(); - } else { - test.fail("Timeout time smaller"); - } - }); -}; - -exports.testStopWIthTick = function(test) { - - var $ = qbox.create(["db1", "db2"]); - $.ready(function() { - test.fail("Should not execute after stops"); - }); - - $.stop(); - $.tick("db1"); - $.tick("db2"); - test.done(); -}; - -exports.testStopWithoutTick = function(test) { - - var $ = qbox.create(); - $.start(); - $.stop(); - $.ready(function() { - test.fail("Should not execute after stops"); - }); - - test.done(); -}; - -exports.testAfterStopTimeout = function(test) { - - var $ = qbox.create(); - $.stop(); - $.timeout(1000, function() { - test.fail("Should not call the timeout"); - }); - - setTimeout(function() { - test.done(); - }, 1500); -}; - -exports.testBeforeStopTimeout = function(test) { - - var $ = qbox.create(); - - $.timeout(1000, function() { - test.fail("Should not call the timeout"); - }); - $.stop(); - setTimeout(function() { - test.done(); - }, 1500); -}; - -exports.testReset = function(test) { - - var $ = qbox.create([1,2]); - $.tick(2); - $.reset(); - $.tick(1); - $.tick(2); - - $.ready(function() { - test.done(); - }); -}; - -exports.testResetAfterStop = function(test) { - - test.expect(2); - var $ = qbox.create([1,2]); - - $.ready(function() { - test.ok(true); - }); - - $.tick(2); - $.tick(1); - $.reset(); - $.ready(function() { - test.ok(true); - }); - $.tick(1); - $.tick(2); - - test.done(); -}; - -exports.testOnStart = function(test) { - - test.expect(2); - var $ = qbox.create([1,2]); - - $.onStart(function() { - test.ok(true); - }); - - $.tick(2); - $.tick(1); - $.reset(); - $.tick(1); - $.tick(2); - - test.done(); -}; - -exports.testCountingSteps = function(test) { - - test.expect(1); - var $ = qbox.create(4); - $.ready(function() { - test.ok(true); - }); - - [1,2,3,4].forEach(function(step) { - $.tick(); - }); - test.done(); -}; - -exports.testCountingStepsWithReset = function(test) { - - test.expect(2); - var $ = qbox.create(4); - $.ready(function() { - test.ok(true); - }); - - [1,2,3,4].forEach(function(step) { - $.tick(); - }); - $.reset(); - $.ready(function() { - test.ok(true); - }); - [1,2,3,4].forEach(function(step) { - $.tick(); - }); - - test.done(); -}; \ No newline at end of file diff --git a/node_modules/should/.gitmodules b/node_modules/should/.gitmodules deleted file mode 100644 index ffe0dcbd6..000000000 --- a/node_modules/should/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "support/expresso"] - path = support/expresso - url = git://github.com/visionmedia/expresso.git diff --git a/node_modules/should/.npmignore b/node_modules/should/.npmignore deleted file mode 100644 index 3c3629e64..000000000 --- a/node_modules/should/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/node_modules/should/History.md b/node_modules/should/History.md deleted file mode 100644 index 409a11817..000000000 --- a/node_modules/should/History.md +++ /dev/null @@ -1,94 +0,0 @@ - -0.5.1 / 2012-01-13 -================== - - * Added better `.json` - * Added better `.html` - -0.5.0 / 2012-01-12 -================== - - * Added string matching to `.throw()` [serby] - * Added regexp matching to `.throw()` [serby] - * Added `.includeEql()` [RubenVerborgh] - * Added `.should.be.html` - * Added `.should.be.json` - * Added optional description args to most matchers [Mike Swift] - -0.4.2 / 2011-12-17 -================== - - * Fixed .header() for realzzz - -0.4.1 / 2011-12-16 -================== - - * Fixed: chain .header() to retain negation - -0.4.0 / 2011-12-16 -================== - - * Added `.should.throw()` - * Added `.include()` support for strings - * Added `.include()` support for arrays - * Removed `keys()` `.include` modifier support - * Removed `.object()` - * Removed `.string()` - * Removed `.contain()` - * Removed `.respondTo()` rubyism - * expresso -> mocha - -0.3.2 / 2011-10-24 -================== - - * Fixed tests for 0.5.x - * Fixed sys warning - -0.3.1 / 2011-08-22 -================== - - * configurable - -0.3.0 / 2011-08-20 -================== - - * Added assertion for inclusion of an object: `foo.should.include.object({ foo: 'bar' })` - -0.2.1 / 2011-05-13 -================== - - * Fixed .status(code). Closes #18 - -0.2.0 / 2011-04-17 -================== - - * Added `res.should.have.status(code)` method - * Added `res.should.have.header(field, val)` method - -0.1.0 / 2011-04-06 -================== - - * Added `should.exist(obj)` [aseemk] - * Added `should.not.exist(obj)` [aseemk] - -0.0.4 / 2010-11-24 -================== - - * Added `.ok` to assert truthfulness - * Added `.arguments` - * Fixed double required bug. [thanks dominictarr] - -0.0.3 / 2010-11-19 -================== - - * Added `true` / `false` assertions - -0.0.2 / 2010-11-19 -================== - - * Added chaining support - -0.0.1 / 2010-11-19 -================== - - * Initial release diff --git a/node_modules/should/Makefile b/node_modules/should/Makefile deleted file mode 100644 index 19e886820..000000000 --- a/node_modules/should/Makefile +++ /dev/null @@ -1,6 +0,0 @@ - -test: - @./node_modules/.bin/mocha \ - --ui exports - -.PHONY: test \ No newline at end of file diff --git a/node_modules/should/Readme.md b/node_modules/should/Readme.md deleted file mode 100644 index 2036df13d..000000000 --- a/node_modules/should/Readme.md +++ /dev/null @@ -1,367 +0,0 @@ -_should_ is an expressive, readable, test framework agnostic, assertion library for [node](http://nodejs.org). - -It extends the Object prototype with a single non-enumerable getter that allows you to express how that object should behave. - -_should_ literally extends node's _assert_ module, in fact, it is node's assert module, for example `should.equal(str, 'foo')` will work, just as `assert.equal(str, 'foo')` would, and `should.AssertionError` **is** `assert.AssertionError`, meaning any test framework supporting this constructor will function properly with _should_. - -## Example - - var user = { - name: 'tj' - , pets: ['tobi', 'loki', 'jane', 'bandit'] - }; - - user.should.have.property('name', 'tj'); - user.should.have.property('pets').with.lengthOf(4); - - someAsyncTask(foo, function(err, result){ - should.not.exist(err); - should.exist(result); - result.bar.should.equal(foo); - }); - -## Installation - - $ npm install should - -## assert extras - -As mentioned above, _should_ extends node's _assert_. The returned object from `require('should')` is thus similar to the returned object from `require('assert')`, but it has one extra convenience method: - - should.exist('hello') - should.exist([]) - should.exist(null) // will throw - -This is equivalent to `should.ok`, which is equivalent to `assert.ok`, but reads a bit better. It gets better, though: - - should.not.exist(false) - should.not.exist('') - should.not.exist({}) // will throw - -We may add more _assert_ extras in the future... ;) - -## chaining assertions - -Some assertions can be chained, for example if a property is volatile we can first assert property existence: - - user.should.have.property('pets').with.lengthOf(4) - -which is essentially equivalent to below, however the property may not exist: - - user.pets.should.have.lengthOf(4) - -our dummy getters such as _and_ also help express chaining: - - user.should.be.a('object').and.have.property('name', 'tj') - -## exist (static) - -The returned object from `require('should')` is the same object as `require('assert')`. So you can use `should` just like `assert`: - - should.fail('expected an error!') - should.strictEqual(foo, bar) - -In general, using the Object prototype's _should_ is nicer than using these `assert` equivalents, because _should_ gives you access to the expressive and readable language described above: - - foo.should.equal(bar) // same as should.strictEqual(foo, bar) above - -The only exception, though, is when you can't be sure that a particular object exists. In that case, attempting to access the _should_ property may throw a TypeError: - - foo.should.equal(bar) // throws if foo is null or undefined! - -For this case, `require('should')` extends `require('assert')` with an extra convenience method to check whether an object exists: - - should.exist({}) - should.exist([]) - should.exist('') - should.exist(0) - should.exist(null) // will throw - should.exist(undefined) // will throw - -You can also check the negation: - - should.not.exist(undefined) - should.not.exist(null) - should.not.exist('') // will throw - should.not.exist({}) // will throw - -Once you know an object exists, you can safely use the _should_ property on it. - -## ok - -Assert truthfulness: - - true.should.be.ok - 'yay'.should.be.ok - (1).should.be.ok - -or negated: - - false.should.not.be.ok - ''.should.not.be.ok - (0).should.not.be.ok - -## true - -Assert === true: - - true.should.be.true - '1'.should.not.be.true - -## false - -Assert === false: - - false.should.be.false - (0).should.not.be.false - -## arguments - -Assert `Arguments`: - - var args = (function(){ return arguments; })(1,2,3); - args.should.be.arguments; - [].should.not.be.arguments; - -## empty - -Asserts that length is 0: - - [].should.be.empty - ''.should.be.empty - ({ length: 0 }).should.be.empty - -## eql - -equality: - - ({ foo: 'bar' }).should.eql({ foo: 'bar' }) - [1,2,3].should.eql([1,2,3]) - -## equal - -strict equality: - - should.strictEqual(undefined, value) - should.strictEqual(false, value) - (4).should.equal(4) - 'test'.should.equal('test') - [1,2,3].should.not.equal([1,2,3]) - -## within - -Assert inclusive numeric range: - - user.age.should.be.within(5, 50) - -## a - -Assert __typeof__: - - user.should.be.a('object') - 'test'.should.be.a('string') - -## instanceof - -Assert __instanceof__: - - user.should.be.an.instanceof(User) - [].should.be.an.instanceof(Array) - -## above - -Assert numeric value above the given value: - - user.age.should.be.above(5) - user.age.should.not.be.above(100) - -## below - -Assert numeric value below the given value: - - user.age.should.be.below(100) - user.age.should.not.be.below(5) - -## match - -Assert regexp match: - - username.should.match(/^\w+$/) - -## length - -Assert _length_ property exists and has a value of the given number: - - user.pets.should.have.length(5) - user.pets.should.have.a.lengthOf(5) - -Aliases: _lengthOf_ - -## property - -Assert property exists and has optional value: - - user.should.have.property('name') - user.should.have.property('age', 15) - user.should.not.have.property('rawr') - user.should.not.have.property('age', 0) - -## ownProperty - -Assert own property (on the immediate object): - - ({ foo: 'bar' }).should.have.ownProperty('foo') - -## status(code) - - Asserts that `.statusCode` is `code`: - - res.should.have.status(200); - -## header(field[, value]) - - Asserts that a `.headers` object with `field` and optional `value` are present: - - res.should.have.header('content-length'); - res.should.have.header('Content-Length', '123'); - res.should.have.header('content-length', '123'); - -## json - - Assert that Content-Type is "application/json; charset=utf-8" - - res.should.be.json - -## html - - Assert that Content-Type is "text/html; charset=utf-8" - - res.should.be.html - -## include(obj) - -Assert that the given `obj` is present via `indexOf()`, so this works for strings, arrays, or custom objects implementing indexOf: - -Assert array value: - - [1,2,3].should.include(3) - [1,2,3].should.include(2) - [1,2,3].should.not.include(4) - -Assert substring: - - 'foo bar baz'.should.include('foo') - 'foo bar baz'.should.include('bar') - 'foo bar baz'.should.include('baz') - 'foo bar baz'.should.not.include('FOO') - -## includeEql(obj) - -Assert that an object equal to the given `obj` is present in an Array: - - [[1],[2],[3]].should.includeEql([3]) - [[1],[2],[3]].should.includeEql([2]) - [[1],[2],[3]].should.not.includeEql([4]) - -## throw() - -Assert an exception is thrown: - -```js -(function(){ - throw new Error('fail'); -}).should.throw(); -``` - -Assert an exception is not thrown: - -```js -(function(){ - -}).should.not.throw(); -``` -Assert exepection message matches string: - -```js -(function(){ - throw new Error('fail'); -}).should.throw('fail'); -``` - -Assert exepection message matches regexp: - -```js -(function(){ - throw new Error('failed to foo'); -}).should.throw(/^fail/); -``` - -## keys - -Assert own object keys, which must match _exactly_, -and will fail if you omit a key or two: - - var obj = { foo: 'bar', baz: 'raz' }; - obj.should.have.keys('foo', 'bar'); - obj.should.have.keys(['foo', 'bar']); - -## Optional Error description - -As it can often be difficult to assertain exactly where failed assertions are comming from in your tests, an optional description parameter can be passed to several should matchers. The description will follow the failed assertion in the error: - - (1).should.eql(0, 'some useful description') - - AssertionError: expected 1 to equal 0 | some useful description - at Object.eql (/Users/swift/code/should.js/node_modules/should/lib/should.js:280:10) - ... - -The methods that support this optional description are: `eql`, `equal`, `within`, `a`, `instanceof`, `above`, `below`, `match`, `length`, `property`, `ownProperty`, `include`, and `includeEql`. - -## Express example - -For example you can use should with the [Expresso TDD Framework](https://github.com/visionmedia/expresso) by simply including it: - - var lib = require('mylib') - , should = require('should'); - - module.exports = { - 'test .version': function(){ - lib.version.should.match(/^\d+\.\d+\.\d+$/); - } - }; - -## Running tests - -To run the tests for _should_ simple update your git submodules and run: - - $ make test - -## OMG IT EXTENDS OBJECT???!?!@ - -Yes, yes it does, with a single getter _should_, and no it wont break your code, because it does this **properly** with a non-enumerable property. - -## License - -(The MIT License) - -Copyright (c) 2010-2011 TJ Holowaychuk <tj@vision-media.ca> -Copyright (c) 2011 Aseem Kishore <aseem.kishore@gmail.com> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/should/examples/runner.js b/node_modules/should/examples/runner.js deleted file mode 100644 index 93559556e..000000000 --- a/node_modules/should/examples/runner.js +++ /dev/null @@ -1,53 +0,0 @@ - -/** - * Module dependencies. - */ - -var should = require('../'); - -function test(name, fn){ - try { - fn(); - } catch (err) { - console.log(' \x1b[31m%s', name); - console.log(' %s\x1b[0m', err.stack); - return; - } - console.log(' √ \x1b[32m%s\x1b[0m', name); -} - -function Point(x, y) { - this.x = x; - this.y = y; - this.sub = function(other){ - return new Point( - this.x - other.x - , this.y - other.y); - } -} - -console.log(); - -test('new Point(x, y)', function(){ - var point = new Point(50, 100); - point.should.be.an.instanceof(Point); - point.should.have.property('x', 50); - point.should.have.property('y', 100); -}); - -test('Point#sub()', function(){ - var a = new Point(50, 100) - , b = new Point(20, 50); - a.sub(b).should.be.an.instanceof(Point); - a.sub(b).should.not.equal(a); - a.sub(b).should.not.equal(b); - a.sub(b).should.have.property('x', 30); - a.sub(b).should.have.property('y', 50); -}); - -test('Point#add()', function(){ - var point = new Point(50, 100); - point.should.respondTo('add'); -}); - -console.log(); \ No newline at end of file diff --git a/node_modules/should/index.js b/node_modules/should/index.js deleted file mode 100644 index 6dbdbdea2..000000000 --- a/node_modules/should/index.js +++ /dev/null @@ -1,2 +0,0 @@ - -module.exports = require('./lib/should'); \ No newline at end of file diff --git a/node_modules/should/lib/eql.js b/node_modules/should/lib/eql.js deleted file mode 100644 index ef219233f..000000000 --- a/node_modules/should/lib/eql.js +++ /dev/null @@ -1,91 +0,0 @@ - -// Taken from node's assert module, because it sucks -// and exposes next to nothing useful. - -module.exports = _deepEqual; - -function _deepEqual(actual, expected) { - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - - } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { - if (actual.length != expected.length) return false; - - for (var i = 0; i < actual.length; i++) { - if (actual[i] !== expected[i]) return false; - } - - return true; - - // 7.2. If the expected value is a Date object, the actual value is - // equivalent if it is also a Date object that refers to the same time. - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - // 7.3. Other pairs that do not both pass typeof value == "object", - // equivalence is determined by ==. - } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual === expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical "prototype" property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected); - } -} - -function isUndefinedOrNull (value) { - return value === null || value === undefined; -} - -function isArguments (object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; -} - -function objEquiv (a, b) { - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - // an identical "prototype" property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return _deepEqual(a, b); - } - try{ - var ka = Object.keys(a), - kb = Object.keys(b), - key, i; - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!_deepEqual(a[key], b[key] )) - return false; - } - return true; -} diff --git a/node_modules/should/lib/should.js b/node_modules/should/lib/should.js deleted file mode 100644 index 32ad1a82d..000000000 --- a/node_modules/should/lib/should.js +++ /dev/null @@ -1,693 +0,0 @@ -/*! - * Should - * Copyright(c) 2010 TJ Holowaychuk - * MIT Licensed - */ - -/** - * Module dependencies. - */ - -var util = require('util') - , http = require('http') - , assert = require('assert') - , AssertionError = assert.AssertionError - , statusCodes = http.STATUS_CODES - , eql = require('./eql') - , i = util.inspect; - -/** - * Expose assert as should. - * - * This allows you to do things like below - * without require()ing the assert module. - * - * should.equal(foo.bar, undefined); - * - */ - -exports = module.exports = assert; - -/** - * Library version. - */ - -exports.version = '0.5.1'; - -/** - * Assert _obj_ exists, with optional message. - * - * @param {Mixed} obj - * @param {String} msg - * @api public - */ - -exports.exist = function(obj, msg){ - if (null == obj) { - throw new AssertionError({ - message: msg || ('expected ' + i(obj) + ' to exist') - , stackStartFunction: should.exist - }); - } -}; - -/** - * Asserts _obj_ does not exist, with optional message. - * - * @param {Mixed} obj - * @param {String} msg - * @api public - */ - -exports.not = {}; -exports.not.exist = function(obj, msg){ - if (null != obj) { - throw new AssertionError({ - message: msg || ('expected ' + i(obj) + ' to not exist') - , stackStartFunction: should.not.exist - }); - } -}; - -/** - * Expose api via `Object#should`. - * - * @api public - */ - -Object.defineProperty(Object.prototype, 'should', { - set: function(){}, - get: function(){ - return new Assertion(this); - }, - configurable: true -}); - -/** - * Initialize a new `Assertion` with the given _obj_. - * - * @param {Mixed} obj - * @api private - */ - -var Assertion = exports.Assertion = function Assertion(obj) { - this.obj = obj; -}; - -/** - * Prototype. - */ - -Assertion.prototype = { - - /** - * HACK: prevents double require() from failing. - */ - - exports: exports, - - /** - * Assert _expr_ with the given _msg_ and _negatedMsg_. - * - * @param {Boolean} expr - * @param {String} msg - * @param {String} negatedMsg - * @api private - */ - - assert: function(expr, msg, negatedMsg){ - var msg = this.negate ? negatedMsg : msg - , ok = this.negate ? !expr : expr; - if (!ok) { - throw new AssertionError({ - message: msg - , stackStartFunction: this.assert - }); - } - }, - - /** - * Dummy getter. - * - * @api public - */ - - get an() { - return this; - }, - - /** - * Dummy getter. - * - * @api public - */ - - get and() { - return this; - }, - - /** - * Dummy getter. - * - * @api public - */ - - get be() { - return this; - }, - - /** - * Dummy getter. - * - * @api public - */ - - get have() { - return this; - }, - - /** - * Dummy getter. - * - * @api public - */ - - get with() { - return this; - }, - - /** - * Negation modifier. - * - * @api public - */ - - get not() { - this.negate = true; - return this; - }, - - /** - * Get object inspection string. - * - * @return {String} - * @api private - */ - - get inspect() { - return i(this.obj); - }, - - /** - * Assert instanceof `Arguments`. - * - * @api public - */ - - get arguments() { - this.assert( - '[object Arguments]' == Object.prototype.toString.call(this.obj) - , 'expected ' + this.inspect + ' to be arguments' - , 'expected ' + this.inspect + ' to not be arguments'); - return this; - }, - - /** - * Assert that an object is empty aka length of 0. - * - * @api public - */ - - get empty() { - this.obj.should.have.property('length'); - this.assert( - 0 === this.obj.length - , 'expected ' + this.inspect + ' to be empty' - , 'expected ' + this.inspect + ' not to be empty'); - return this; - }, - - /** - * Assert ok. - * - * @api public - */ - - get ok() { - this.assert( - this.obj - , 'expected ' + this.inspect + ' to be truthy' - , 'expected ' + this.inspect + ' to be falsey'); - return this; - }, - - /** - * Assert true. - * - * @api public - */ - - get true() { - this.assert( - true === this.obj - , 'expected ' + this.inspect + ' to be true' - , 'expected ' + this.inspect + ' not to be true'); - return this; - }, - - /** - * Assert false. - * - * @api public - */ - - get false() { - this.assert( - false === this.obj - , 'expected ' + this.inspect + ' to be false' - , 'expected ' + this.inspect + ' not to be false'); - return this; - }, - - /** - * Assert equal. - * - * @param {Mixed} val - * @param {String} description - * @api public - */ - - eql: function(val, desc){ - this.assert( - eql(val, this.obj) - , 'expected ' + this.inspect + ' to equal ' + i(val) + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to not equal ' + i(val) + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert strict equal. - * - * @param {Mixed} val - * @param {String} description - * @api public - */ - - equal: function(val, desc){ - this.assert( - val === this.obj - , 'expected ' + this.inspect + ' to equal ' + i(val) + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to not equal ' + i(val) + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert within start to finish (inclusive). - * - * @param {Number} start - * @param {Number} finish - * @param {String} description - * @api public - */ - - within: function(start, finish, desc){ - var range = start + '..' + finish; - this.assert( - this.obj >= start && this.obj <= finish - , 'expected ' + this.inspect + ' to be within ' + range + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to not be within ' + range + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert typeof. - * - * @param {Mixed} type - * @param {String} description - * @api public - */ - - a: function(type, desc){ - this.assert( - type == typeof this.obj - , 'expected ' + this.inspect + ' to be a ' + type + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' not to be a ' + type + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert instanceof. - * - * @param {Function} constructor - * @param {String} description - * @api public - */ - - instanceof: function(constructor, desc){ - var name = constructor.name; - this.assert( - this.obj instanceof constructor - , 'expected ' + this.inspect + ' to be an instance of ' + name + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' not to be an instance of ' + name + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert numeric value above _n_. - * - * @param {Number} n - * @param {String} description - * @api public - */ - - above: function(n, desc){ - this.assert( - this.obj > n - , 'expected ' + this.inspect + ' to be above ' + n + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to be below ' + n + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert numeric value below _n_. - * - * @param {Number} n - * @param {String} description - * @api public - */ - - below: function(n, desc){ - this.assert( - this.obj < n - , 'expected ' + this.inspect + ' to be below ' + n + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to be above ' + n + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert string value matches _regexp_. - * - * @param {RegExp} regexp - * @param {String} description - * @api public - */ - - match: function(regexp, desc){ - this.assert( - regexp.exec(this.obj) - , 'expected ' + this.inspect + ' to match ' + regexp + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' not to match ' + regexp + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert property "length" exists and has value of _n_. - * - * @param {Number} n - * @param {String} description - * @api public - */ - - length: function(n, desc){ - this.obj.should.have.property('length'); - var len = this.obj.length; - this.assert( - n == len - , 'expected ' + this.inspect + ' to have a length of ' + n + ' but got ' + len + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to not have a length of ' + len + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert property _name_ exists, with optional _val_. - * - * @param {String} name - * @param {Mixed} val - * @param {String} description - * @api public - */ - - property: function(name, val, desc){ - if (this.negate && undefined !== val) { - if (undefined === this.obj[name]) { - throw new Error(this.inspect + ' has no property ' + i(name) + (desc ? " | " + desc : "")); - } - } else { - this.assert( - undefined !== this.obj[name] - , 'expected ' + this.inspect + ' to have a property ' + i(name) + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to not have a property ' + i(name) + (desc ? " | " + desc : "")); - } - - if (undefined !== val) { - this.assert( - val === this.obj[name] - , 'expected ' + this.inspect + ' to have a property ' + i(name) - + ' of ' + i(val) + ', but got ' + i(this.obj[name]) + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to not have a property ' + i(name) + ' of ' + i(val) + (desc ? " | " + desc : "")); - } - - this.obj = this.obj[name]; - return this; - }, - - /** - * Assert own property _name_ exists. - * - * @param {String} name - * @param {String} description - * @api public - */ - - ownProperty: function(name, desc){ - this.assert( - this.obj.hasOwnProperty(name) - , 'expected ' + this.inspect + ' to have own property ' + i(name) + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to not have own property ' + i(name) + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert that `obj` is present via `.indexOf()`. - * - * @param {Mixed} obj - * @param {String} description - * @api public - */ - - include: function(obj, desc){ - this.assert( - ~this.obj.indexOf(obj) - , 'expected ' + this.inspect + ' to include ' + i(obj) + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to not include ' + i(obj) + (desc ? " | " + desc : "")); - - return this; - }, - - /** - * Assert that an object equal to `obj` is present. - * - * @param {Array} obj - * @param {String} description - * @api public - */ - - includeEql: function(obj, desc){ - this.assert( - this.obj.some(function(item) { return eql(obj, item); }) - , 'expected ' + this.inspect + ' to include an object equal to ' + i(obj) + (desc ? " | " + desc : "") - , 'expected ' + this.inspect + ' to not include an object equal to ' + i(obj) + (desc ? " | " + desc : "")); - return this; - }, - - /** - * Assert that the array contains _obj_. - * - * @param {Mixed} obj - * @api public - */ - - contain: function(obj){ - console.warn('should.contain() is deprecated, use should.include()'); - this.obj.should.be.an.instanceof(Array); - this.assert( - ~this.obj.indexOf(obj) - , 'expected ' + this.inspect + ' to contain ' + i(obj) - , 'expected ' + this.inspect + ' to not contain ' + i(obj)); - return this; - }, - - /** - * Assert exact keys or inclusion of keys by using - * the `.include` modifier. - * - * @param {Array|String ...} keys - * @api public - */ - - keys: function(keys){ - var str - , ok = true; - - keys = keys instanceof Array - ? keys - : Array.prototype.slice.call(arguments); - - if (!keys.length) throw new Error('keys required'); - - var actual = Object.keys(this.obj) - , len = keys.length; - - // make sure they're all present - ok = keys.every(function(key){ - return ~actual.indexOf(key); - }); - - // matching length - ok = ok && keys.length == actual.length; - - // key string - if (len > 1) { - keys = keys.map(function(key){ - return i(key); - }); - var last = keys.pop(); - str = keys.join(', ') + ', and ' + last; - } else { - str = i(keys[0]); - } - - // message - str = 'have ' + (len > 1 ? 'keys ' : 'key ') + str; - - this.assert( - ok - , 'expected ' + this.inspect + ' to ' + str - , 'expected ' + this.inspect + ' to not ' + str); - - return this; - }, - - /** - * Assert that header `field` has the given `val`. - * - * @param {String} field - * @param {String} val - * @return {Assertion} for chaining - * @api public - */ - - header: function(field, val){ - this.obj.should - .have.property('headers').and - .have.property(field.toLowerCase(), val); - return this; - }, - - /** - * Assert `.statusCode` of `code`. - * - * @param {Number} code - * @return {Assertion} for chaining - * @api public - */ - - status: function(code){ - this.obj.should.have.property('statusCode'); - var status = this.obj.statusCode; - - this.assert( - code == status - , 'expected response code of ' + code + ' ' + i(statusCodes[code]) - + ', but got ' + status + ' ' + i(statusCodes[status]) - , 'expected to not respond with ' + code + ' ' + i(statusCodes[code])); - - return this; - }, - - /** - * Assert that this response has content-type: application/json. - * - * @return {Assertion} for chaining - * @api public - */ - - get json() { - this.obj.should.have.property('headers'); - this.obj.headers.should.have.property('content-type'); - this.obj.headers['content-type'].should.include('application/json'); - }, - - /** - * Assert that this response has content-type: text/html. - * - * @return {Assertion} for chaining - * @api public - */ - - get html() { - this.obj.should.have.property('headers'); - this.obj.headers.should.have.property('content-type'); - this.obj.headers['content-type'].should.include('text/html'); - }, - - /** - * Assert that this function will or will not - * throw an exception. - * - * @return {Assertion} for chaining - * @api public - */ - - throw: function(message){ - var fn = this.obj - , err = {} - , errorInfo = '' - , ok = true; - - try { - fn(); - ok = false; - } catch (e) { - err = e; - } - - if (ok) { - if ('string' == typeof message) { - ok = message == err.message; - } else if (message instanceof RegExp) { - ok = message.test(err.message); - } - - if (message && !ok) { - if ('string' == typeof message) { - errorInfo = " with a message matching '" + message + "', but got '" + err.message + "'"; - } else { - errorInfo = " with a message matching " + message + ", but got '" + err.message + "'"; - } - } - } - - this.assert( - ok - , 'expected an exception to be thrown' + errorInfo - , 'expected no exception to be thrown, got "' + err.message + '"'); - - return this; - } -}; - -/** - * Aliases. - */ - -(function alias(name, as){ - Assertion.prototype[as] = Assertion.prototype[name]; - return alias; -}) -('length', 'lengthOf') -('keys', 'key') -('ownProperty', 'haveOwnProperty') -('above', 'greaterThan') -('below', 'lessThan'); - diff --git a/node_modules/should/package.json b/node_modules/should/package.json deleted file mode 100644 index e8c98f65b..000000000 --- a/node_modules/should/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ "name": "should" - , "description": "test framework agnostic BDD-style assertions" - , "version": "0.5.1" - , "author": "TJ Holowaychuk " - , "contributors": [ "Aseem Kishore " ] - , "devDependencies": { - "mocha": "*" - , "should": "*" - } - , "keywords": ["test", "bdd", "assert"] - , "main": "./lib/should.js" - , "engines": { "node": ">= 0.2.0" } -} \ No newline at end of file diff --git a/node_modules/should/test/exist.test.js b/node_modules/should/test/exist.test.js deleted file mode 100644 index 7aa108200..000000000 --- a/node_modules/should/test/exist.test.js +++ /dev/null @@ -1,96 +0,0 @@ - -/** - * Module dependencies. - */ - -var should = require('../'); -var util = require('util'); - -function err(fn, msg) { - try { - fn(); - should.fail('expected an error'); - } catch (err) { - should.equal(msg, err.message); - } -} - -function err_should_exist(obj) { - err(function () { - should.exist(obj); - }, 'expected ' + util.inspect(obj) + ' to exist'); -} - -function err_should_not_exist(obj) { - err(function () { - should.not.exist(obj); - }, 'expected ' + util.inspect(obj) + ' to not exist'); -} - -module.exports = { - - // static should.exist() pass: - - 'test static should.exist() pass w/ bool': function () { - should.exist(false); - }, - - 'test static should.exist() pass w/ number': function () { - should.exist(0); - }, - - 'test static should.exist() pass w/ string': function () { - should.exist(''); - }, - - 'test static should.exist() pass w/ object': function () { - should.exist({}); - }, - - 'test static should.exist() pass w/ array': function () { - should.exist([]); - }, - - // static should.exist() fail: - - 'test static should.exist() fail w/ null': function () { - err_should_exist(null); - }, - - 'test static should.exist() fail w/ undefined': function () { - err_should_exist(undefined); - }, - - // static should.not.exist() pass: - - 'test static should.not.exist() pass w/ null': function () { - should.not.exist(null); - }, - - 'test static should.not.exist() pass w/ undefined': function () { - should.not.exist(undefined); - }, - - // static should.not.exist() fail: - - 'test static should.not.exist() fail w/ bool': function () { - err_should_not_exist(false); - }, - - 'test static should.not.exist() fail w/ number': function () { - err_should_not_exist(0); - }, - - 'test static should.not.exist() fail w/ string': function () { - err_should_not_exist(''); - }, - - 'test static should.not.exist() fail w/ object': function () { - err_should_not_exist({}); - }, - - 'test static should.not.exist() fail w/ array': function () { - err_should_not_exist([]); - }, - -}; diff --git a/node_modules/should/test/should.test.js b/node_modules/should/test/should.test.js deleted file mode 100644 index 6b629410d..000000000 --- a/node_modules/should/test/should.test.js +++ /dev/null @@ -1,534 +0,0 @@ - -/** - * Module dependencies. - */ - -var should = require('../'); - -function err(fn, msg) { - try { - fn(); - should.fail('expected an error'); - } catch (err) { - should.equal(msg, err.message); - } -} - -module.exports = { - 'test .version': function(){ - should.version.should.match(/^\d+\.\d+\.\d+$/); - }, - - 'test double require': function(){ - require('should').should.equal(should); - }, - - 'test assertion': function(){ - 'test'.should.be.a.string; - should.equal('foo', 'foo'); - }, - - 'test true': function(){ - true.should.be.true; - false.should.not.be.true; - (1).should.not.be.true; - - err(function(){ - 'test'.should.be.true; - }, "expected 'test' to be true") - }, - - 'test ok': function(){ - true.should.be.ok; - false.should.not.be.ok; - (1).should.be.ok; - (0).should.not.be.ok; - - err(function(){ - ''.should.be.ok; - }, "expected '' to be truthy"); - - err(function(){ - 'test'.should.not.be.ok; - }, "expected 'test' to be falsey"); - }, - - 'test false': function(){ - false.should.be.false; - true.should.not.be.false; - (0).should.not.be.false; - - err(function(){ - ''.should.be.false; - }, "expected '' to be false") - }, - - 'test arguments': function(){ - var args = (function(){ return arguments; })(1,2,3); - args.should.be.arguments; - [].should.not.be.arguments; - }, - - 'test .equal()': function(){ - var foo; - should.equal(undefined, foo); - }, - - 'test typeof': function(){ - 'test'.should.be.a('string'); - - err(function(){ - 'test'.should.not.be.a('string'); - }, "expected 'test' not to be a string"); - - err(function(){ - 'test'.should.not.be.a('string', 'foo'); - }, "expected 'test' not to be a string | foo"); - - (5).should.be.a('number'); - - err(function(){ - (5).should.not.be.a('number'); - }, "expected 5 not to be a number"); - - err(function(){ - (5).should.not.be.a('number', 'foo'); - }, "expected 5 not to be a number | foo"); - }, - - 'test instanceof': function(){ - function Foo(){} - new Foo().should.be.an.instanceof(Foo); - - err(function(){ - (3).should.an.instanceof(Foo); - }, "expected 3 to be an instance of Foo"); - - err(function(){ - (3).should.an.instanceof(Foo, 'foo'); - }, "expected 3 to be an instance of Foo | foo"); - }, - - 'test within(start, finish)': function(){ - (5).should.be.within(5, 10); - (5).should.be.within(3,6); - (5).should.be.within(3,5); - (5).should.not.be.within(1,3); - - err(function(){ - (5).should.not.be.within(4,6); - }, "expected 5 to not be within 4..6"); - - err(function(){ - (10).should.be.within(50,100); - }, "expected 10 to be within 50..100"); - - err(function(){ - (5).should.not.be.within(4,6, 'foo'); - }, "expected 5 to not be within 4..6 | foo"); - - err(function(){ - (10).should.be.within(50,100, 'foo'); - }, "expected 10 to be within 50..100 | foo"); - }, - - 'test above(n)': function(){ - (5).should.be.above(2); - (5).should.be.greaterThan(2); - (5).should.not.be.above(5); - (5).should.not.be.above(6); - - err(function(){ - (5).should.be.above(6); - }, "expected 5 to be above 6"); - - err(function(){ - (10).should.not.be.above(6); - }, "expected 10 to be below 6"); - - err(function(){ - (5).should.be.above(6, 'foo'); - }, "expected 5 to be above 6 | foo"); - - err(function(){ - (10).should.not.be.above(6, 'foo'); - }, "expected 10 to be below 6 | foo"); - }, - - 'test below(n)': function(){ - (2).should.be.below(5); - (2).should.be.lessThan(5); - (5).should.not.be.below(5); - (6).should.not.be.below(5); - - err(function(){ - (6).should.be.below(5); - }, "expected 6 to be below 5"); - - err(function(){ - (6).should.not.be.below(10); - }, "expected 6 to be above 10"); - - err(function(){ - (6).should.be.below(5, 'foo'); - }, "expected 6 to be below 5 | foo"); - - err(function(){ - (6).should.not.be.below(10, 'foo'); - }, "expected 6 to be above 10 | foo"); - }, - - 'test match(regexp)': function(){ - 'foobar'.should.match(/^foo/) - 'foobar'.should.not.match(/^bar/) - - err(function(){ - 'foobar'.should.match(/^bar/i) - }, "expected 'foobar' to match /^bar/i"); - - err(function(){ - 'foobar'.should.not.match(/^foo/i) - }, "expected 'foobar' not to match /^foo/i"); - - err(function(){ - 'foobar'.should.match(/^bar/i, 'foo') - }, "expected 'foobar' to match /^bar/i | foo"); - - err(function(){ - 'foobar'.should.not.match(/^foo/i, 'foo') - }, "expected 'foobar' not to match /^foo/i | foo"); - }, - - 'test length(n)': function(){ - 'test'.should.have.length(4); - 'test'.should.not.have.length(3); - [1,2,3].should.have.length(3); - - err(function(){ - (4).should.have.length(3); - }, 'expected 4 to have a property \'length\''); - - err(function(){ - 'asd'.should.not.have.length(3); - }, "expected 'asd' to not have a length of 3"); - - err(function(){ - 'asd'.should.have.length(4, 'foo'); - }, "expected 'asd' to have a length of 4 but got 3 | foo"); - - err(function(){ - 'asd'.should.not.have.length(3, 'foo'); - }, "expected 'asd' to not have a length of 3 | foo"); - - }, - - 'test eql(val)': function(){ - 'test'.should.eql('test'); - ({ foo: 'bar' }).should.eql({ foo: 'bar' }); - (1).should.eql(1); - '4'.should.not.eql(4); - - err(function(){ - (4).should.eql(3); - }, 'expected 4 to equal 3'); - - err(function(){ - (4).should.eql(3, "foo"); - }, 'expected 4 to equal 3 | foo'); - - err(function(){ - (3).should.not.eql(3, "foo"); - }, 'expected 3 to not equal 3 | foo'); - }, - - 'test .json': function(){ - var req = { - headers: { - 'content-type': 'application/json' - } - }; - - req.should.be.json; - - var req = { - headers: { - 'content-type': 'application/json; charset=utf-8' - } - }; - - req.should.be.json; - }, - - 'test equal(val)': function(){ - 'test'.should.equal('test'); - (1).should.equal(1); - - err(function(){ - (4).should.equal(3); - }, 'expected 4 to equal 3'); - - err(function(){ - '4'.should.equal(4); - }, "expected '4' to equal 4"); - - err(function(){ - (3).should.equal(4, "foo"); - }, "expected 3 to equal 4 | foo"); - - err(function(){ - (4).should.not.equal(4, "foo"); - }, "expected 4 to not equal 4 | foo"); - }, - - 'test empty': function(){ - ''.should.be.empty; - [].should.be.empty; - ({ length: 0 }).should.be.empty; - - err(function(){ - ({}).should.be.empty; - }, 'expected {} to have a property \'length\''); - - err(function(){ - 'asd'.should.be.empty; - }, "expected 'asd' to be empty"); - - err(function(){ - ''.should.not.be.empty; - }, "expected '' not to be empty"); - }, - - 'test property(name)': function(){ - 'test'.should.have.property('length'); - (4).should.not.have.property('length'); - - err(function(){ - 'asd'.should.have.property('foo'); - }, "expected 'asd' to have a property 'foo'"); - - err(function(){ - 'asd'.should.have.property('foo', undefined, 'foo'); - }, "expected 'asd' to have a property 'foo' | foo"); - - err(function(){ - 'asd'.should.not.have.property('length', undefined, 'foo'); - }, "expected 'asd' to not have a property 'length' | foo"); - }, - - 'test property(name, val)': function(){ - 'test'.should.have.property('length', 4); - 'asd'.should.have.property('constructor', String); - - err(function(){ - 'asd'.should.have.property('length', 4); - }, "expected 'asd' to have a property 'length' of 4, but got 3"); - - err(function(){ - 'asd'.should.not.have.property('length', 3); - }, "expected 'asd' to not have a property 'length' of 3"); - - err(function(){ - 'asd'.should.not.have.property('foo', 3); - }, "'asd' has no property 'foo'"); - - err(function(){ - 'asd'.should.have.property('constructor', Number); - }, "expected 'asd' to have a property 'constructor' of [Function: Number], but got [Function: String]"); - - err(function(){ - 'asd'.should.have.property('length', 4, 'foo'); - }, "expected 'asd' to have a property 'length' of 4, but got 3 | foo"); - - err(function(){ - 'asd'.should.not.have.property('length', 3, 'foo'); - }, "expected 'asd' to not have a property 'length' of 3 | foo"); - - err(function(){ - 'asd'.should.not.have.property('foo', 3, 'foo'); - }, "'asd' has no property 'foo' | foo"); - - err(function(){ - 'asd'.should.have.property('constructor', Number, 'foo'); - }, "expected 'asd' to have a property 'constructor' of [Function: Number], but got [Function: String] | foo"); - }, - - 'test ownProperty(name)': function(){ - 'test'.should.have.ownProperty('length'); - 'test'.should.haveOwnProperty('length'); - ({ length: 12 }).should.have.ownProperty('length'); - - err(function(){ - ({ length: 12 }).should.not.have.ownProperty('length'); - }, "expected { length: 12 } to not have own property 'length'"); - - err(function(){ - ({ length: 12 }).should.not.have.ownProperty('length', 'foo'); - }, "expected { length: 12 } to not have own property 'length' | foo"); - - err(function(){ - ({ length: 12 }).should.have.ownProperty('foo', 'foo'); - }, "expected { length: 12 } to have own property 'foo' | foo"); - }, - - 'test include() with string': function(){ - 'foobar'.should.include('bar'); - 'foobar'.should.include('foo'); - 'foobar'.should.not.include('baz'); - - err(function(){ - 'foobar'.should.include('baz'); - }, "expected 'foobar' to include 'baz'"); - - err(function(){ - 'foobar'.should.not.include('bar'); - }, "expected 'foobar' to not include 'bar'"); - - err(function(){ - 'foobar'.should.include('baz', 'foo'); - }, "expected 'foobar' to include 'baz' | foo"); - - err(function(){ - 'foobar'.should.not.include('bar', 'foo'); - }, "expected 'foobar' to not include 'bar' | foo"); - }, - - 'test include() with array': function(){ - ['foo', 'bar'].should.include('foo'); - ['foo', 'bar'].should.include('foo'); - ['foo', 'bar'].should.include('bar'); - [1,2].should.include(1); - ['foo', 'bar'].should.not.include('baz'); - ['foo', 'bar'].should.not.include(1); - - err(function(){ - ['foo'].should.include('bar'); - }, "expected [ 'foo' ] to include 'bar'"); - - err(function(){ - ['bar', 'foo'].should.not.include('foo'); - }, "expected [ 'bar', 'foo' ] to not include 'foo'"); - - err(function(){ - ['foo'].should.include('bar', 'foo'); - }, "expected [ 'foo' ] to include 'bar' | foo"); - - err(function(){ - ['bar', 'foo'].should.not.include('foo', 'foo'); - }, "expected [ 'bar', 'foo' ] to not include 'foo' | foo"); - }, - - 'test includeEql() with array': function(){ - [['foo'], ['bar']].should.includeEql(['foo']); - [['foo'], ['bar']].should.includeEql(['bar']); - [['foo'], ['bar']].should.not.includeEql(['baz']); - [].should.not.includeEql(['baz']); - - err(function(){ - [['foo']].should.includeEql(['bar']); - }, "expected [ [ 'foo' ] ] to include an object equal to [ 'bar' ]"); - - err(function(){ - [['foo']].should.not.includeEql(['foo']); - }, "expected [ [ 'foo' ] ] to not include an object equal to [ 'foo' ]"); - - err(function(){ - [['foo']].should.includeEql(['bar'], 'foo'); - }, "expected [ [ 'foo' ] ] to include an object equal to [ 'bar' ] | foo"); - - err(function(){ - [['foo']].should.not.includeEql(['foo'], 'foo'); - }, "expected [ [ 'foo' ] ] to not include an object equal to [ 'foo' ] | foo"); - }, - - 'test keys(array)': function(){ - ({ foo: 1 }).should.have.keys(['foo']); - ({ foo: 1, bar: 2 }).should.have.keys(['foo', 'bar']); - ({ foo: 1, bar: 2 }).should.have.keys('foo', 'bar'); - - err(function(){ - ({ foo: 1 }).should.have.keys(); - }, "keys required"); - - err(function(){ - ({ foo: 1 }).should.have.keys([]); - }, "keys required"); - - err(function(){ - ({ foo: 1 }).should.not.have.keys([]); - }, "keys required"); - - err(function(){ - ({ foo: 1 }).should.have.keys(['bar']); - }, "expected { foo: 1 } to have key 'bar'"); - - err(function(){ - ({ foo: 1 }).should.have.keys(['bar', 'baz']); - }, "expected { foo: 1 } to have keys 'bar', and 'baz'"); - - err(function(){ - ({ foo: 1 }).should.have.keys(['foo', 'bar', 'baz']); - }, "expected { foo: 1 } to have keys 'foo', 'bar', and 'baz'"); - - err(function(){ - ({ foo: 1 }).should.not.have.keys(['foo']); - }, "expected { foo: 1 } to not have key 'foo'"); - - err(function(){ - ({ foo: 1 }).should.not.have.keys(['foo']); - }, "expected { foo: 1 } to not have key 'foo'"); - - err(function(){ - ({ foo: 1, bar: 2 }).should.not.have.keys(['foo', 'bar']); - }, "expected { foo: 1, bar: 2 } to not have keys 'foo', and 'bar'"); - }, - - 'test chaining': function(){ - var user = { name: 'tj', pets: ['tobi', 'loki', 'jane', 'bandit'] }; - user.should.have.property('pets').with.lengthOf(4); - - err(function(){ - user.should.have.property('pets').with.lengthOf(5); - }, "expected [ 'tobi', 'loki', 'jane', 'bandit' ] to have a length of 5 but got 4"); - - user.should.be.a('object').and.have.property('name', 'tj'); - }, - - 'test throw()': function(){ - (function(){}).should.not.throw(); - (function(){ throw new Error('fail') }).should.throw(); - - err(function(){ - (function(){}).should.throw(); - }, 'expected an exception to be thrown'); - - err(function(){ - (function(){ - throw new Error('fail'); - }).should.not.throw(); - }, 'expected no exception to be thrown, got "fail"'); - }, - - 'test throw() with regex message': function(){ - (function(){ throw new Error('fail'); }).should.throw(/fail/); - - err(function(){ - (function(){}).should.throw(/fail/); - }, 'expected an exception to be thrown'); - - err(function(){ - (function(){ throw new Error('error'); }).should.throw(/fail/); - }, "expected an exception to be thrown with a message matching /fail/, but got 'error'"); - }, - - 'test throw() with string message': function(){ - (function(){ throw new Error('fail'); }).should.throw('fail'); - - err(function(){ - (function(){}).should.throw('fail'); - }, 'expected an exception to be thrown'); - - err(function(){ - (function(){ throw new Error('error'); }).should.throw('fail'); - }, "expected an exception to be thrown with a message matching 'fail', but got 'error'"); - } -}; diff --git a/node_modules/tap-assert/AUTHORS b/node_modules/tap-assert/AUTHORS deleted file mode 100644 index 96726f817..000000000 --- a/node_modules/tap-assert/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Isaac Z. Schlueter (http://blog.izs.me) -baudehlo diff --git a/node_modules/tap-assert/LICENSE b/node_modules/tap-assert/LICENSE deleted file mode 100644 index 05a401094..000000000 --- a/node_modules/tap-assert/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/tap-assert/README.md b/node_modules/tap-assert/README.md deleted file mode 100644 index 6792aa63a..000000000 --- a/node_modules/tap-assert/README.md +++ /dev/null @@ -1,3 +0,0 @@ -An assert module for node-tap. - -More coming. diff --git a/node_modules/tap-assert/assert.js b/node_modules/tap-assert/assert.js deleted file mode 100644 index 8d3bba095..000000000 --- a/node_modules/tap-assert/assert.js +++ /dev/null @@ -1,396 +0,0 @@ -// an assert module that returns tappable data for each assertion. - -module.exports = assert - -var syns = {} - , id = 1 - -function assert (ok, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - - //console.error("assert %j", [ok, message, extra]) - //if (extra && extra.skip) return assert.skip(message, extra) - //console.error("assert", [ok, message, extra]) - ok = !!ok - var res = { id : id ++, ok: ok } - - var caller = getCaller(extra && extra.error) - if (extra && extra.error) { - res.type = extra.error.name - res.message = extra.error.message - res.code = extra.error.code - || extra.error.type - res.errno = extra.error.errno - delete extra.error - } - if (caller.file) { - res.file = caller.file - res.line = +caller.line - res.column = +caller.column - } - res.stack = caller.stack - - res.name = message || "(unnamed assert)" - - if (extra) Object.keys(extra).forEach(function (k) { - if (!res.hasOwnProperty(k)) res[k] = extra[k] - }) - - // strings and objects are hard to diff by eye - if (!ok && - res.hasOwnProperty("found") && - res.hasOwnProperty("wanted") && - res.found !== res.wanted) { - if (typeof res.wanted !== typeof res.found || - typeof res.wanted === "object" && (!res.found || !res.wanted)) { - res.type = { found: typeof found - , wanted: typeof wanted } - } else if (typeof res.wanted === "string") { - res.diff = diffString(res.found, res.wanted) - } else if (typeof res.wanted === "object") { - res.diff = diffObject(res.found, res.wanted) - } - } - - //console.error("assert return", res) - - return res -} -assert.ok = assert -syns.ok = [ "true", "assert" ] - - -function notOk (ok, message, extra) { - return assert(!ok, message, extra) -} -assert.notOk = notOk -syns.notOk = [ "false", "notok" ] - -function error (er, message, extra) { - if (!er) { - // just like notOk(er) - return assert(!er, message, extra) - } - message = message || er.message - extra = extra || {} - extra.error = er - return assert.fail(message, extra) -} -assert.error = error -syns.error = [ "ifError", "ifErr", "iferror" ] - - -function pass (message, extra) { - return assert(true, message, extra) -} -assert.pass = pass - -function fail (message, extra) { - //console.error("assert.fail", [message, extra]) - //if (extra && extra.skip) return assert.skip(message, extra) - return assert(false, message, extra) -} -assert.fail = fail - -function skip (message, extra) { - //console.error("assert.skip", message, extra) - if (!extra) extra = {} - return { id: id ++, skip: true, name: message || "" } -} -assert.skip = skip - -function throws (fn, wanted, message, extra) { - if (typeof wanted === "string") { - extra = message - message = wanted - wanted = null - } - - if (extra && extra.skip) return assert.skip(message, extra) - - var found = null - try { - fn() - } catch (e) { - found = { name: e.name, message: e.message } - } - - extra = extra || {} - - extra.found = found - if (wanted) { - wanted = { name: wanted.name, message: wanted.message } - extra.wanted = wanted - } - - if (!message) { - message = "Expected to throw" - if (wanted) message += ": "+wanted.name + " " + wanted.message - } - - return (wanted) ? assert.similar(found, wanted, message, extra) - : assert.ok(found, message, extra) -} -assert.throws = throws - - -function doesNotThrow (fn, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var found = null - try { - fn() - } catch (e) { - found = {name: e.name, message: e.message} - } - message = message || "Should not throw" - - return assert.equal(found, null, message, extra) -} -assert.doesNotThrow = doesNotThrow - - -function equal (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should be equal" - extra.found = a - extra.wanted = b - return assert(a === b, message, extra) -} -assert.equal = equal -syns.equal = ["equals" - ,"isEqual" - ,"is" - ,"strictEqual" - ,"strictEquals"] - - -function equivalent (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var extra = extra || {} - message = message || "should be equivalent" - extra.found = a - extra.wanted = b - return assert(stringify(a) === stringify(b), message, extra) -} -assert.equivalent = equivalent -syns.equivalent = ["isEquivalent" - ,"looseEqual" - ,"looseEquals" - ,"isDeeply" - ,"same" - ,"deepEqual" - ,"deepEquals"] - - -function inequal (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should not be equal" - extra.found = a - extra.doNotWant = b - return assert(a !== b, message, extra) -} -assert.inequal = inequal -syns.inequal = ["notEqual" - ,"notEquals" - ,"isNotEqual" - ,"isNot" - ,"not" - ,"doesNotEqual" - ,"isInequal"] - - -function inequivalent (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should not be equivalent" - extra.found = a - extra.doNotWant = b - return assert(stringify(a) !== stringify(b), message, extra) -} -assert.inequivalent = inequivalent -syns.inequivalent = ["notEquivalent" - ,"notDeepEqual" - ,"notDeeply" - ,"isNotDeepEqual" - ,"isNotDeeply" - ,"isNotEquivalent" - ,"isInequivalent"] - -function similar (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - // test that a has all the fields in b - message = message || "should be similar" - return equivalent(selectFields(a, b), b, message, extra) -} -assert.similar = similar -syns.similar = ["isSimilar" - ,"has" - ,"hasFields" - ,"like" - ,"isLike"] - -function dissimilar (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - // test that a has all the fields in b - message = message || "should be dissimilar" - return inequivalent(selectFields(a, b), b, message, extra) -} -assert.dissimilar = dissimilar -syns.dissimilar = ["unsimilar" - ,"notSimilar" - ,"unlike" - ,"isUnlike" - ,"notLike" - ,"isNotLike" - ,"doesNotHave" - ,"isNotSimilar" - ,"isDissimilar"] - -function type (thing, t, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var name = t - if (typeof name === "function") name = name.name || "(anonymous ctor)" - //console.error("name=%s", name) - message = message || "type is "+name - var type = typeof thing - //console.error("type=%s", type) - if (!thing && type === "object") type = "null" - if (type === "object" && t !== "object") { - if (typeof t === "function") { - //console.error("it is a function!") - extra = extra || {} - extra.found = Object.getPrototypeOf(thing).constructor.name - extra.wanted = name - //console.error(thing instanceof t, name) - return assert.ok(thing instanceof t, message, extra) - } - - //console.error("check prototype chain") - // check against classnames or objects in prototype chain, as well. - // type(new Error("asdf"), "Error") - // type(Object.create(foo), foo) - var p = thing - while (p = Object.getPrototypeOf(p)) { - if (p === t || p.constructor && p.constructor.name === t) { - type = name - break - } - } - } - //console.error(type, name, type === name) - return assert.equal(type, name, message, extra) -} -assert.type = type -syns.type = ["isa"] - -// synonyms are helpful. -Object.keys(syns).forEach(function (c) { - syns[c].forEach(function (s) { - Object.defineProperty(assert, s, { value: assert[c], enumerable: false }) - }) -}) - -// helpers below - -function selectFields (a, b) { - // get the values in A of the fields in B - var ret = Array.isArray(b) ? [] : {} - Object.keys(b).forEach(function (k) { - if (!a.hasOwnProperty(k)) return - var v = b[k] - , av = a[k] - if (v && av && typeof v === "object" && typeof av === "object") { - ret[k] = selectFields(av, v) - } else ret[k] = av - }) - return ret -} - -function stringify (a) { - return JSON.stringify(a, (function () { - var seen = [] - , keys = [] - return function (key, val) { - var s = seen.indexOf(val) - if (s !== -1) { - return "[Circular: "+keys[s]+"]" - } - if (val && typeof val === "object" || typeof val === "function") { - seen.push(val) - keys.push(val["!"] || val.name || key || "") - if (typeof val === "function") { - return val.toString().split(/\n/)[0] - } - var proto = Object.getPrototypeOf(val) - } - return val - }})()) -} - -function diffString (f, w) { - if (w === f) return null - var p = 0 - , l = w.length - while (p < l && w.charAt(p) === f.charAt(p)) p ++ - w = stringify(w).substr(1).replace(/"$/, "") - f = stringify(f).substr(1).replace(/"$/, "") - return diff(f, w, p) -} - -function diffObject (f, w) { - var f = stringify(f) - , w = stringify(w) - , l = w.length - if (f === w) return null - var p = 0 - while (p < l && f.charAt(p) === w.charAt(p)) p ++ - return diff(f, w, p) -} - -function diff (f, w, p) { - if (w === f) return null - var i = p || 0 // it's going to be at least p. JSON can only be bigger. - , l = w.length - while (i < l && w.charAt(i) === f.charAt(i)) i ++ - var pos = Math.max(0, i - 20) - w = w.substr(pos, 40) - f = f.substr(pos, 40) - var pointer = i - pos - return "FOUND: "+f+"\n" - + "WANTED: "+w+"\n" - + (new Array(pointer + 9).join(" ")) - + "^ (at position = "+p+")" -} - -function getCaller (er) { - // get the first file/line that isn't this file. - if (!er) er = new Error - var stack = er.stack || "" - stack = stack.split(/\n/) - for (var i = 1, l = stack.length; i < l; i ++) { - var s = stack[i].match(/\(([^):]+):([0-9]+):([0-9]+)\)$/) - if (!s) continue - var file = s[1] - , line = +s[2] - , col = +s[3] - if (file.indexOf(__dirname) === 0) continue - if (file.match(/tap-test\/test.js$/)) continue - else break - } - var res = {} - if (file && file !== __filename && !file.match(/tap-test\/test.js$/)) { - res.file = file - res.line = line - res.column = col - } - - res.stack = stack.slice(1).map(function (s) { - return s.replace(/^\s*at\s*/, "") - }) - - return res -} - - diff --git a/node_modules/tap-assert/package.json b/node_modules/tap-assert/package.json deleted file mode 100644 index bfc2c5c4a..000000000 --- a/node_modules/tap-assert/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "tap-assert", - "version": "0.0.10", - "description": "An assertion module that returns TAP result objects", - "main": "./assert.js", - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/tap-assert.git" - }, - "keywords": [ - "assert", - "test", - "tap" - ], - "license": { - "type": "MIT", - "url": "https://github.com/isaacs/tap-assert/raw/master/LICENSE" - }, - "contributors": [ - "Isaac Z. Schlueter (http://blog.izs.me)", - "baudehlo " - ], - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": "*" - } -} diff --git a/node_modules/tap-producer/README.md b/node_modules/tap-producer/README.md deleted file mode 100644 index bd96254f4..000000000 --- a/node_modules/tap-producer/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Sometimes, you need to produce some TAPs. - -Not like when you go to the store, and check to see if the melons are -ripe. That's tapping on produce. This is different. diff --git a/node_modules/tap-producer/node_modules/inherits/README.md b/node_modules/tap-producer/node_modules/inherits/README.md deleted file mode 100644 index b2beaed93..000000000 --- a/node_modules/tap-producer/node_modules/inherits/README.md +++ /dev/null @@ -1,51 +0,0 @@ -A dead simple way to do inheritance in JS. - - var inherits = require("inherits") - - function Animal () { - this.alive = true - } - Animal.prototype.say = function (what) { - console.log(what) - } - - inherits(Dog, Animal) - function Dog () { - Dog.super.apply(this) - } - Dog.prototype.sniff = function () { - this.say("sniff sniff") - } - Dog.prototype.bark = function () { - this.say("woof woof") - } - - inherits(Chihuahua, Dog) - function Chihuahua () { - Chihuahua.super.apply(this) - } - Chihuahua.prototype.bark = function () { - this.say("yip yip") - } - - // also works - function Cat () { - Cat.super.apply(this) - } - Cat.prototype.hiss = function () { - this.say("CHSKKSS!!") - } - inherits(Cat, Animal, { - meow: function () { this.say("miao miao") } - }) - Cat.prototype.purr = function () { - this.say("purr purr") - } - - - var c = new Chihuahua - assert(c instanceof Chihuahua) - assert(c instanceof Dog) - assert(c instanceof Animal) - -The actual function is laughably small. 10-lines small. diff --git a/node_modules/tap-producer/node_modules/inherits/inherits.js b/node_modules/tap-producer/node_modules/inherits/inherits.js deleted file mode 100644 index 061b39620..000000000 --- a/node_modules/tap-producer/node_modules/inherits/inherits.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = inherits - -function inherits (c, p, proto) { - proto = proto || {} - var e = {} - ;[c.prototype, proto].forEach(function (s) { - Object.getOwnPropertyNames(s).forEach(function (k) { - e[k] = Object.getOwnPropertyDescriptor(s, k) - }) - }) - c.prototype = Object.create(p.prototype, e) - c.super = p -} - -//function Child () { -// Child.super.call(this) -// console.error([this -// ,this.constructor -// ,this.constructor === Child -// ,this.constructor.super === Parent -// ,Object.getPrototypeOf(this) === Child.prototype -// ,Object.getPrototypeOf(Object.getPrototypeOf(this)) -// === Parent.prototype -// ,this instanceof Child -// ,this instanceof Parent]) -//} -//function Parent () {} -//inherits(Child, Parent) -//new Child diff --git a/node_modules/tap-producer/node_modules/inherits/package.json b/node_modules/tap-producer/node_modules/inherits/package.json deleted file mode 100644 index 5beb00574..000000000 --- a/node_modules/tap-producer/node_modules/inherits/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ "name" : "inherits" -, "description": "A tiny simple way to do classic inheritance in js" -, "version" : "1.0.0" -, "keywords" : ["inheritance", "class", "klass", "oop", "object-oriented"] -, "main" : "./inherits.js" -, "repository" : "https://github.com/isaacs/inherits" -, "author" : "Isaac Z. Schlueter (http://blog.izs.me/)" } diff --git a/node_modules/tap-producer/node_modules/tap-results/README.md b/node_modules/tap-producer/node_modules/tap-results/README.md deleted file mode 100644 index 6a00fc961..000000000 --- a/node_modules/tap-producer/node_modules/tap-results/README.md +++ /dev/null @@ -1,2 +0,0 @@ -This is a module for keeping track of tap result objects, counting them -up, etc. diff --git a/node_modules/tap-producer/node_modules/tap-results/package.json b/node_modules/tap-producer/node_modules/tap-results/package.json deleted file mode 100644 index 1882b7775..000000000 --- a/node_modules/tap-producer/node_modules/tap-results/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "tap-results", - "version": "0.0.2", - "description": "A util for keeping track of tap result objects", - "main": "./results.js", - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", - "repository": "https://github.com/isaacs/tap-results", - "dependencies": { - "inherits": "~1.0.0" - } -} diff --git a/node_modules/tap-producer/node_modules/tap-results/results.js b/node_modules/tap-producer/node_modules/tap-results/results.js deleted file mode 100644 index 46ef2e5ec..000000000 --- a/node_modules/tap-producer/node_modules/tap-results/results.js +++ /dev/null @@ -1,68 +0,0 @@ -// A class for counting up results in a test harness. - -module.exports = Results - -var inherits = require("inherits") - , EventEmitter = require("events").EventEmitter - -inherits(Results, EventEmitter) - -function Results (r) { - //console.error("result constructor", r) - this.ok = true - this.addSet(r) -} - -Results.prototype.addSet = function (r) { - //console.error("add set of results", r) - r = r || {ok: true} - ; [ "todo" - , "todoPass" - , "todoFail" - , "skip" - , "skipPass" - , "skipFail" - , "pass" - , "passTotal" - , "fail" - , "failTotal" - , "tests" - , "testsTotal" ].forEach(function (k) { - this[k] = (this[k] || 0) + (r[k] || 0) - //console.error([k, this[k]]) - }, this) - - this.ok = this.ok && r.ok && true - this.bailedOut = this.bailedOut || r.bailedOut || false - this.list = (this.list || []).concat(r.list || []) - this.emit("set", this.list) - //console.error("after addSet", this) -} - -Results.prototype.add = function (r, addToList) { - //console.error("add result", r) - var pf = r.ok ? "pass" : "fail" - , PF = r.ok ? "Pass" : "Fail" - - this.testsTotal ++ - this[pf + "Total"] ++ - - if (r.skip) { - this["skip" + PF] ++ - this.skip ++ - } else if (r.todo) { - this["todo" + PF] ++ - this.todo ++ - } else { - this.tests ++ - this[pf] ++ - } - - if (r.bailout || typeof r.bailout === "string") this.bailedOut = true - this.ok = !!(this.ok && r.ok) - - if (addToList === false) return - this.list = this.list || [] - this.list.push(r) - this.emit("result", r) -} diff --git a/node_modules/tap-producer/node_modules/yamlish/LICENSE b/node_modules/tap-producer/node_modules/yamlish/LICENSE deleted file mode 100644 index 187e8db4c..000000000 --- a/node_modules/tap-producer/node_modules/yamlish/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011 Isaac Z. Schlueter - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/tap-producer/node_modules/yamlish/README.md b/node_modules/tap-producer/node_modules/yamlish/README.md deleted file mode 100644 index 954d0636c..000000000 --- a/node_modules/tap-producer/node_modules/yamlish/README.md +++ /dev/null @@ -1,20 +0,0 @@ -This is a thingie to parse the "yamlish" format used to serialize -objects in the TAP format. - -It's like yaml, but just a tiny little bit smaller. - -Usage: - - var yamlish = require("yamlish") - // returns a string like: - /* - some: - object: - - full - - of - pretty: things - */ - yamlish.encode({some:{object:["full", "of"]}, pretty:"things"}) - - // returns the object - yamlish.decode(someYamlishString) diff --git a/node_modules/tap-producer/node_modules/yamlish/package.json b/node_modules/tap-producer/node_modules/yamlish/package.json deleted file mode 100644 index fb24483c1..000000000 --- a/node_modules/tap-producer/node_modules/yamlish/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ "name" : "yamlish" -, "description" : "Parser/encoder for the yamlish format" -, "repository":"https://github.com/isaacs/yamlish" -, "version" : "0.0.2" -, "main" : "yamlish.js" -, "keywords" : [ "yaml", "yamlish", "test", "anything", "protocol", "tap"] -, "license" : { "type" : "MIT" - , "url" : "https://github.com/isaacs/yamlish/raw/master/LICENSE" } -, "author" : "Isaac Z. Schlueter (http://blog.izs.me/)" } diff --git a/node_modules/tap-producer/node_modules/yamlish/yamlish.js b/node_modules/tap-producer/node_modules/yamlish/yamlish.js deleted file mode 100644 index 7aec41fb1..000000000 --- a/node_modules/tap-producer/node_modules/yamlish/yamlish.js +++ /dev/null @@ -1,221 +0,0 @@ -exports.encode = encode -exports.decode = decode - -var seen = [] -function encode (obj, indent) { - var deep = arguments[2] - if (!indent) indent = " " - - // take out the easy ones. - switch (typeof obj) { - case "string": - obj = obj.trim() - if (obj.indexOf("\n") !== -1) { - return "|\n" + indent + obj.split(/\r?\n/).join("\n"+indent) - } else return obj - - case "number": - return obj.toString(10) - - case "function": - return encode(obj.toString(), indent, true) - - case "boolean": - return obj.toString() - - case "undefined": - // fallthrough - case "object": - // at this point we know it types as an object - if (!obj) return "~" - - if (obj instanceof Date) return obj.toISOString() - - if (seen.indexOf(obj) !== -1) { - return "[Circular]" - } - seen.push(obj) - - if (typeof Buffer === "function" && - typeof Buffer.isBuffer === "function" && - Buffer.isBuffer(obj)) return obj.inspect() - - if (obj instanceof Error) { - var o = { name: obj.name - , message: obj.message - , type: obj.type } - - if (obj.code) o.code = obj.code - if (obj.errno) o.errno = obj.errno - if (obj.type) o.type = obj.type - obj = o - } - - var out = "" - - if (Array.isArray(obj)) { - var out = "\n" + indent + "- " +obj.map(function (item) { - return encode(item, indent + " ", true) - }).join("\n"+indent + "- ") - break - } - - // an actual object - var keys = Object.keys(obj) - , niceKeys = keys.map(function (k) { - return (k.match(/^[a-zA-Z0-9_]+$/) ? k : JSON.stringify(k)) + ": " - }) - //console.error(keys, niceKeys, obj) - var maxLength = Math.max.apply(Math, niceKeys.map(function (k) { - return k.length - }).concat(0)) - //console.error(niceKeys, maxLength) - - var spaces = new Array(maxLength + 1).join(" ") - - if (!deep) indent += " " - out = "\n" + indent + keys.map(function (k, i) { - var niceKey = niceKeys[i] - return niceKey + spaces.substr(niceKey.length) - + encode(obj[k], indent + " ", true) - }).join("\n" + indent) - break - - default: return "" - } - if (!deep) seen.length = 0 - return out -} - -function decode (str) { - var v = str.trim() - , d - if (v === "~") return null - if (v.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}/) - && (d = Date.parse(v))) { - return new Date(d) - } - if (v === "true" || v === "false") return JSON.parse(v) - if (v && !isNaN(v)) return parseInt(v, 10) - // something interesting. - var lines = str.split(/\r?\n/) - // check if it's some kind of string or something. - // if the first line is > or | then it's a wrapping indented string. - // if the first line is blank, and there are many lines, - // then it's an array or object. - // otherwise, it's just "" - var first = lines.shift().trim() - if (lines.length) lines = undent(lines) - switch (first) { - case "|": - return lines.join("\n") - case ">": - return lines.join("\n").split(/\n{2,}/).map(function (l) { - return l.split(/\n/).join(" ") - }).join("\n") - default: - if (!lines.length) return first - // array or object. - // the first line will be either "- value" or "key: value" - return lines[0].charAt(0) === "-" ? decodeArr(lines) : decodeObj(lines) - } -} - -function decodeArr (lines) { - var out = [] - , key = 0 - , val = [] - for (var i = 0, l = lines.length; i < l; i ++) { - // if it starts with a -, then it's a new thing - var line = lines[i] - if (line.charAt(0) === "-") { - if (val.length) { - out[key ++] = decode(val.join("\n")) - val.length = 0 - } - val.push(line.substr(1).trim()) - } else if (line.charAt(0) === " ") { - val.push(line) - } else return [] - } - if (val.length) { - out[key ++] = decode(val.join("\n")) - } - return out -} - -function decodeObj (lines) { - var out = {} - , val = [] - , key = null - - for (var i = 0, l = lines.length; i < l; i ++) { - var line = lines[i] - if (line.charAt(0) === " ") { - val.push(line) - continue - } - // some key:val - if (val.length) { - out[key] = decode(val.join("\n")) - val.length = 0 - } - // parse out the quoted key - var first - if (line.charAt(0) === "\"") { - for (var ii = 1, ll = line.length, esc = false; ii < ll; ii ++) { - var c = line.charAt(ii) - if (c === "\\") { - esc = !esc - } else if (c === "\"" && !esc) { - break - } - } - key = JSON.parse(line.substr(0, ii + 1)) - line = line.substr(ii + 1) - first = line.substr(line.indexOf(":") + 1).trim() - } else { - var kv = line.split(":") - key = kv.shift() - first = kv.join(":").trim() - } - // now we've set a key, and "first" has the first line of the value. - val.push(first.trim()) - } - if (val.length) out[key] = decode(val.join("\n")) - return out -} - -function undent (lines) { - var i = lines[0].match(/^\s*/)[0].length - return lines.map(function (line) { - return line.substr(i) - }) -} - - - -if (require.main === module) { -var obj = [{"bigstring":new Error().stack} - ,{ar:[{list:"of"},{some:"objects"}]} - ,{date:new Date()} - ,{"super huge string":new Error().stack} - ] - -Date.prototype.toJSON = function (k, val) { - console.error(k, val, this) - return this.toISOString() + " (it's a date)" -} -var enc = encode(obj) - , dec = decode(enc) - , encDec = encode(dec) - -console.error(JSON.stringify({ obj : obj - , enc : enc.split(/\n/) - , dec : dec }, null, 2), encDec === enc) - -var num = 100 - , encNum = encode(num) - , decEncNum = decode(encNum) -console.error([num, encNum, decEncNum]) -} diff --git a/node_modules/tap-producer/package.json b/node_modules/tap-producer/package.json deleted file mode 100644 index 6e6238f3e..000000000 --- a/node_modules/tap-producer/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ "name" : "tap-producer" -, "version" : "0.0.1" -, "description" : "A module for producing TAP output" -, "main" : "./tap-producer.js" -, "author" : "Isaac Z. Schlueter (http://blog.izs.me/)" -, "repository" : "https://github.com/isaacs/tap-producer" -, "dependencies" : - { "inherits" : "*" - , "tap-results" : "0.x" - , "yamlish" : "*" - } -} diff --git a/node_modules/tap-producer/tap-producer.js b/node_modules/tap-producer/tap-producer.js deleted file mode 100644 index 6aaa8c1af..000000000 --- a/node_modules/tap-producer/tap-producer.js +++ /dev/null @@ -1,113 +0,0 @@ -module.exports = TapProducer - -var Results = require("tap-results") - , inherits = require("inherits") - , yamlish = require("yamlish") - -TapProducer.encode = function (result, diag) { - var tp = new TapProducer(diag) - , out = "" - tp.on("data", function (c) { out += c }) - if (Array.isArray(result)) { - result.forEach(tp.write, tp) - } else tp.write(result) - tp.end() - return out -} - -inherits(TapProducer, require("stream").Stream) -function TapProducer (diag) { - TapProducer.super.call(this) - this.diag = diag - this.count = 0 - this.readable = this.writable = true - this.results = new Results -} - -TapProducer.prototype.trailer = true - -TapProducer.prototype.write = function (res) { - // console.error("TapProducer.write", res) - if (typeof res === "function") throw new Error("wtf?") - if (!this.writable) this.emit("error", new Error("not writable")) - - var diag = res.diag - if (diag === undefined) diag = this.diag - - this.emit("data", encodeResult(res, this.count + 1, diag)) - - if (typeof res === "string") return true - - this.results.add(res, false) - this.count ++ -} - -TapProducer.prototype.end = function (res) { - if (res) this.write(res) - this.emit("data", "\n1.."+this.results.testsTotal+"\n") - if (this.trailer && typeof this.trailer !== "string") { - // summary trailer. - var trailer = "tests "+this.results.testsTotal + "\n" - if (this.results.pass) { - trailer += "pass " + this.results.pass + "\n" - } - if (this.results.fail) { - trailer += "fail " + this.results.fail + "\n" - } - if (this.results.skip) { - trailer += "skip "+this.results.skip + "\n" - } - if (this.results.todo) { - trailer += "todo "+this.results.todo + "\n" - } - if (this.results.bailedOut) { - trailer += "bailed out" + "\n" - } - - if (this.results.testsTotal === this.results.pass) { - trailer += "\nok\n" - } - this.trailer = trailer - } - if (this.trailer) this.write(this.trailer) - this.writable = false - this.emit("end", null, this.count, this.ok) -} - -function encodeResult (res, count, diag) { - if (typeof res === "string") { - res = res.split(/\r?\n/).map(function (l) { - if (!l.trim()) return l.trim() - return "# " + l - }).join("\n") - if (res.substr(-1) !== "\n") res += "\n" - return res - } - - if (!!process.env.TAP_NODIAG) diag = false - else if (!!process.env.TAP_DIAG) diag = true - else if (diag === undefined) diag = !res.ok - - var output = "" - res.name = res.name && res.name.trim() - output += ( !res.ok ? "not " : "") + "ok " + count - + ( !res.name ? "" - : " " + res.name.replace(/[\r\n]/, " ") ) - + ( res.skip ? " # SKIP" - : res.todo ? " # TODO" - : "" ) - + "\n" - - if (!diag) return output - var d = {} - , dc = 0 - Object.keys(res).filter(function (k) { - return k !== "ok" && k !== "name" && k !== "id" - }).forEach(function (k) { - dc ++ - d[k] = res[k] - }) - //console.error(d, "about to encode") - if (dc > 0) output += " ---"+yamlish.encode(d)+"\n ...\n" - return output -} diff --git a/node_modules/tap/.npmignore b/node_modules/tap/.npmignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/node_modules/tap/AUTHORS b/node_modules/tap/AUTHORS deleted file mode 100644 index 898b61327..000000000 --- a/node_modules/tap/AUTHORS +++ /dev/null @@ -1,8 +0,0 @@ -# contributors sorted by whether or not they're me -Isaac Z. Schlueter -baudehlo -James Halliday -Jason Smith (air) -Pedro P. Candel -Stein Martin Hustad -Trent Mick diff --git a/node_modules/tap/LICENSE b/node_modules/tap/LICENSE deleted file mode 100644 index 05a401094..000000000 --- a/node_modules/tap/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/tap/README.md b/node_modules/tap/README.md deleted file mode 100644 index 7e061aa54..000000000 --- a/node_modules/tap/README.md +++ /dev/null @@ -1,82 +0,0 @@ -This is a mix-and-match set of utilities that you can use to write test -harnesses and frameworks that communicate with one another using the -Test Anything Protocol. - -If you don't yet know what TAP is, [you better ask -somebody](http://testanything.org/). - -Default Usage: - -1. Make a directory. Maybe call it 'test'. That'd be nice and obvious. -2. Put a bunch of test scripts in there. If they're node programs, then - they should be ".js". Anything else is assumed to be some kind of shell - script, which should have a shebang line. -3. `npm install tap` -4. `tap ./tests` - -The output will be TAP-compliant. - -For extra special bonus points, you can do something like this: - - var test = require("tap").test - test("make sure the thingie is a thing", function (t) { - t.equal(thingie, "thing", "thingie should be thing") - t.type(thingie, "string", "type of thingie is string") - t.ok(true, "this is always true") - t.notOk(false, "this is never true") - t.test("a child test", function (t) { - t.equal(this, superEasy, "right!?") - t.similar(7, 2, "ever notice 7 is kinda like 2?", {todo: true}) - t.test("so skippable", {skip: true}, function (t) { - t.plan(1) // only one test in this block - t.ok(true, "but when the flag changes, it'll pass") - // no need to end, since we had a plan. - }) - t.end() - }) - t.ok(99, "can also skip individual assertions", {skip: true}) - // end lets it know it's over. - t.end() - }) - test("another one", function (t) { - t.plan(1) - t.ok(true, "It's ok to plan, and also end. Watch.") - t.end() // but it must match the plan! - }) - -Node-tap is actually a collection of several modules, any of which may be -mixed and matched however you please. - -If you don't like this test framework, and think you can do much much -better, *I strongly encourage you to do so!* If you use this library, -however, at least to output TAP-compliant results when `process.env.TAP` -is set, then the data coming out of your framework will be much more -consumable by machines. - -You can also use this to build programs that *consume* the TAP data, so -this is very useful for CI systems and such. - -* tap-assert: A collection of assert functions that return TAP result - objects. -* tap-consumer: A stream interface for consuming TAP data. -* tap-producer: A class that produces a TAP stream by taking in result - objects. -* tap-results: A class for keeping track of TAP result objects as they - pass by, counting up skips, passes, fails, and so on. -* tap-runner: A program that runs through a directory running all the - tests in it. (Tests which may or may not be TAP-outputting tests. But - it's better if they are.) -* tap-test: A class for actually running tests. -* tap-harness: A class that runs tests. (Tests are also Harnesses, - which is how sub-tests run.) -* tap-global-harness: A default harness that provides the top-level - support for running TAP tests. - -## Experimental Code Coverage with runforcover & bunker: - -``` -TAP_COV=1 tap ./tests [--cover=./lib,foo.js] [--cover-dir=./coverage] -``` - -This feature is experimental, and will most likely change somewhat -before being finalized. Feedback welcome. diff --git a/node_modules/tap/bin/tap-http.js b/node_modules/tap/bin/tap-http.js deleted file mode 100644 index 296910f9b..000000000 --- a/node_modules/tap/bin/tap-http.js +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env node - -// just an example, really -// Run with `node tap-http.js path/to/tests/` - -var argv = process.argv.slice(2) - , path = require("path") - , Runner = require("../lib/tap-runner") - - , http = require("http") - , server = http.createServer(function (req, res) { - // it'd be nice to return a non-200 if the tests fail, but we don't - // know the status until it's done, so that would mean not being able - // to pipe the output - res.writeHead(200, {'content-type': 'text/plain'}) - new Runner(argv, null).pipe(res) - }) - -server.listen(1337) diff --git a/node_modules/tap/bin/tap-reader.js b/node_modules/tap/bin/tap-reader.js deleted file mode 100755 index b196cc2a2..000000000 --- a/node_modules/tap/bin/tap-reader.js +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env node - -// read a tap stream from stdin. - -var TapConsumer = require("../lib/tap-consumer") - , TapProducer = require("../lib/tap-producer") - -var tc = new TapConsumer - , tp = new TapProducer - -//process.stdin.pipe(tc) -process.stdin.on("data", function (c) { - c = c + "" - // console.error(JSON.stringify(c).substr(0, 100)) - tc.write(c) -}) -process.stdin.on("end", function () { tc.end() }) -process.stdin.resume() -//tc.pipe(tp) -tc.on("data", function (c) { - tp.write(c) -}) -tc.on("end", function () { tp.end() }) - -tp.on("data", function (c) { - console.error(["output write", c]) - process.stdout.write(c) -}) - -tp.on("end", function (er, total, ok) { - if (er) throw er - process.exit(total - ok) -}) diff --git a/node_modules/tap/bin/tap.js b/node_modules/tap/bin/tap.js deleted file mode 100755 index e6e7c8e6a..000000000 --- a/node_modules/tap/bin/tap.js +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env node - -var argv = process.argv.slice(2) - , path = require("path") - , Runner = require("../lib/tap-runner") - - , nopt = require("nopt") - - , knownOpts = - { cover: [path, false] - , "cover-dir": path - , stderr: Boolean - , stdout: Boolean - , diag: Boolean - , version: Boolean - , tap: Boolean - , timeout: Number - } - - , shorthands = - // debugging 1: show stderr - { d: ["--stderr"] - // debugging 2: show stderr and tap - , dd: ["--stderr", "--tap"] - // debugging 3: show stderr, tap, AND always show diagnostics. - , ddd: ["--stderr", "--tap", "--diag"] - , e: ["--stderr"] - , t: ["--timeout"] - , o: ["--tap"] - , c: ["--cover"] - , v: ["--version"] - , "?": ["--help"] - , h: ["--help"] - } - - , defaults = - { cover: "./lib" - , "cover-dir": "./coverage" - , stderr: process.env.TAP_STDERR - , tap: process.env.TAP - , diag: process.env.TAP_DIAG - , timeout: +process.env.TAP_TIMEOUT || 30 - , version: false - , help: false } - - , options = nopt(knownOpts, shorthands) - -if (options.version) { - console.log(require("../package.json").version) - process.exit(0) -} - -if (options.help) { - console.log(function(){/* - -Usage: - tap - - Run the files as tap tests, parse the output, and report the results - -Options: - - --stderr Print standard error output of tests to standard error. - --tap Print raw tap output. - --diag Print diagnostic output for passed tests, as well as failed. - (Implies --tap) - --timeout Maximum time to wait for a subtest, in seconds. Default: 30 - --version Print the version of node tap - --help Print this help - -Please report bugs! https://github.com/isaacs/node-tap/issues - -*/}.toString().split(/\n/).slice(1, -1).join("\n")) - process.exit(0) -} - - -Object.keys(defaults).forEach(function (k) { - if (!options.hasOwnProperty(k)) options[k] = defaults[k] -}) - -// other tests that might rely on these -if (options.diag) process.env.TAP_DIAG = true -if (options.tap) process.env.TAP = true -if (options.timeout) process.env.TAP_TIMEOUT = options.timeout - -var r = new Runner(options) - , TapProducer = require("../lib/tap-producer") - -if (options.tap || options.diag) { - r.pipe(process.stdout) -} else { - r.on("file", function (file, results, details) { - var s = (details.ok ? "" : "not ") + "ok "+results.name - , n = details.pass + "/" + details.testsTotal - , dots = new Array(Math.max(1, 60 - s.length - n.length)).join(".") - console.log("%s %s %s", s, dots, n) - if (details.ok) { - if (details.skip) { - console.log(" skipped: %s", details.skipTotal) - } - } else { - // console.error(details) - console.log(" Command: %s", results.command) - console.log(" " + TapProducer.encode(details.list) - .split(/\n/).join("\n ")) - } - }) - r.on("end", function () { - //console.log(r) - var s = "total" - , n = r.results.pass + "/" + r.results.testsTotal - , dots = new Array(60 - s.length - n.length).join(".") - , ok = r.results.ok ? "ok" : "not ok" - console.log("%s %s %s\n\n%s", s, dots, n, ok) - if (r.doCoverage) { - console.error( "\nCoverage: %s\n" - , path.resolve(r.coverageOutDir, "index.html") ) - } - }) -} - - - -r.on("end", function () { - process.exit(r.results.tests - r.results.pass) -}) diff --git a/node_modules/tap/coverage-example/lib/bar.js b/node_modules/tap/coverage-example/lib/bar.js deleted file mode 100644 index e7cb7addf..000000000 --- a/node_modules/tap/coverage-example/lib/bar.js +++ /dev/null @@ -1,15 +0,0 @@ -var Bar = module.exports = function(str) { - this.bar = str; - this.str = str; -}; - -Bar.prototype.foo = function() { - var self = this; - return self.bar; -}; - -Bar.prototype.baz = function() { - var self = this; - return self.str; -}; - diff --git a/node_modules/tap/coverage-example/lib/foo.js b/node_modules/tap/coverage-example/lib/foo.js deleted file mode 100644 index cb9ee8f36..000000000 --- a/node_modules/tap/coverage-example/lib/foo.js +++ /dev/null @@ -1,15 +0,0 @@ -var Foo = module.exports = function(str) { - this.foo = str; - this.str = str; -}; - -Foo.prototype.bar = function() { - var self = this; - return self.foo; -}; - -Foo.prototype.baz = function() { - var self = this; - return self.str; -}; - diff --git a/node_modules/tap/coverage-example/test/bar.test.js b/node_modules/tap/coverage-example/test/bar.test.js deleted file mode 100644 index 91e4bc21f..000000000 --- a/node_modules/tap/coverage-example/test/bar.test.js +++ /dev/null @@ -1,20 +0,0 @@ -var test = require('tap').test, - Bar = require('../lib/bar'), - bar; - -test('setup', function(t) { - bar = new Bar('baz'); - t.ok(bar); - t.end(); -}); - -test('bar', function(t) { - t.equal('baz', bar.foo()); - t.end(); -}); - -test('teardown', function(t) { - t.ok(true); - t.end(); -}); - diff --git a/node_modules/tap/coverage-example/test/baz.test.js b/node_modules/tap/coverage-example/test/baz.test.js deleted file mode 100644 index fae22d864..000000000 --- a/node_modules/tap/coverage-example/test/baz.test.js +++ /dev/null @@ -1,29 +0,0 @@ -var test = require('tap').test, - Foo = require('../lib/foo'), - Bar = require('../lib/bar'), - foo, bar; - -test('setup', function(t) { - foo = new Foo('baz'); - t.ok(foo); - bar = new Bar('baz'); - t.ok(bar); - t.end(); -}); - -test('baz from Foo', function(t) { - t.equal('baz', foo.baz()); - t.end(); -}); - -test('baz from Bar', function(t) { - t.equal('baz', bar.baz()); - t.end(); -}); - - -test('teardown', function(t) { - t.ok(true); - t.end(); -}); - diff --git a/node_modules/tap/coverage-example/test/foo.test.js b/node_modules/tap/coverage-example/test/foo.test.js deleted file mode 100644 index 2aed8fda0..000000000 --- a/node_modules/tap/coverage-example/test/foo.test.js +++ /dev/null @@ -1,20 +0,0 @@ -var test = require('tap').test, - Foo = require('../lib/foo'), - foo; - -test('setup', function(t) { - foo = new Foo('baz'); - t.ok(foo); - t.end(); -}); - -test('bar', function(t) { - t.equal('baz', foo.bar()); - t.end(); -}); - -test('teardown', function(t) { - t.ok(true); - t.end(); -}); - diff --git a/node_modules/tap/example/lib/math.js b/node_modules/tap/example/lib/math.js deleted file mode 100644 index f79862602..000000000 --- a/node_modules/tap/example/lib/math.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = Math diff --git a/node_modules/tap/example/test/test-example.js b/node_modules/tap/example/test/test-example.js deleted file mode 100644 index cd2549b2a..000000000 --- a/node_modules/tap/example/test/test-example.js +++ /dev/null @@ -1,237 +0,0 @@ -var tap = require("tap") - , test = tap.test - , plan = tap.plan - , math - -test("load sut", function (t) { - math = require("../lib/math") - t.ok(math, "object loaded") - t.end() -}) - -test("validate constants", function (t) { - t.equal(math.LN10, 2.302585092994046, "ln 10") - t.equal(math.PI, 3.141592653589793, "pi") - t.equal(math.E, 2.718281828459045, "e") - t.equal(math.LOG10E, 0.4342944819032518, "log 10 e") - t.equal(math.SQRT2, 1.4142135623730951, "sqrt 2") - t.equal(math.SQRT1_2, 0.7071067811865476, "sqrt 1/2") - t.equal(math.LN2, 0.6931471805599453, "ln2") - t.end() -}) - -test("using this", function (t) { - // this also works. - this.equal(t, this, "call in scope of test obj") - this.end() -}) - -// test setTimeout, just a trivial example. -test("setTimeout", function (t) { - var start = Date.now() - setTimeout(function () { - t.ok(Date.now() >= start + 50, "timeout fired after delay") - t.end() - }, 50) -}) - -// another way to do the same, using a plan. -// this is more robust, but annoying when you have a long list -// of tests for something. For async stuff, it's generally better, -// since there's a higher risk of the control flowing off to lala land. -test("setTimeout planned", function (t) { - t.plan(1) - var start = Date.now() - setTimeout(function () { - t.ok(Date.now() >= start + 50, "timeout fired after delay") - }, 50) -}) - -// plans also are good for cases where things may fire in a non-deterministic -// order, since it won't be as obvious when everything is done. -test("setTimeout parallel", function (t) { - t.plan(2) - var start = Date.now() - setTimeout(function A () { - t.ok(Date.now() >= start + 50, "timeout A fired after delay") - }, 50) - setTimeout(function B () { - t.ok(Date.now() >= start + 50, "timeout B fired after delay") - }, 50) -}) - -// something slightly less hello worldy -test("async test", function (t) { - t.plan(4) - var fs = require("fs") - t.ok(fs, "fs library should load") - var rs = fs.createReadStream(__filename) - t.ok(rs, "read stream should start fine.") - rs.on("open", function (fd) { - t.type(fd, "number", "file descriptor should be a number") - t.equal(fd, rs.fd, "fd should match stream fd") - }) -}) - -// you can bail out of the entire everything if something is just -// Not Right (db not installed, etc.) -test("tarp", function (parent) { - if (7 === 5) { - parent.bailout("math is broken") - } - // bailout bubbles up a bit like "error" events - // if unhandled, then the parent will bail, as well. - parent.test("child bailouts", function (child) { - child.on("bailout", function (s) { - parent.fail("children shouldn't bail.") - }) - child.bailout("try to bail out, but instead just fail a test") - }) - - parent.test("child bailout 2", function (child) { - child.bailout("this one will bail out") - }) -}) - -// tests marked "todo" can fail without counting against the overall score -// never ever ever write tests to "verify" incorrect behavior! -test("unfinished test", function (t) { - t.equal(math.cos(math.PI), -1, "cos(PI)") - t.equal(math.sin(math.PI), 0, "sin(PI)") - t.equal(math.face, "your face", "math.face should be your face # TODO") - t.end() -}) - -// tests can have children. -test("http server", function (t) { - // one test plus 4 children. - t.plan(5) - - var http = require("http") - , PORT = 12346 - - t.ok(http, "http module should load") - var server - - t.test("set up server", function (t) { - t.plan(2) - server = http.createServer(function (req, res) { - t.comment("Request: "+req.url) - res.writeHead(200, {}) - res.end(req.method + " " + req.url) - }) - t.ok(server, "createServer should create a server") - server.listen(PORT, t.cb("listen should fire callback")) - }) - - // set the "parallel" flag on this one. - // That signals the harness to proceed immediately to the next test, - // and run them in parallel. - // Default behavior is to wait for each test to complete before proceeding - // to the next one. - // The first not-parallel test encountered will cause it to wait for that - // test, as well as all the parallel tests before it. - // A, B', C', D', E (where ' means "parallel") - // Runs A, and then B, C, and D in parallel, and then E. - t.test("testing POST", {parallel: true}, function (t) { - t.plan(1) - http.request("POST", { method: "POST" - , host: "localhost" - , path: "/foo" - , port: PORT }).on("response", function (res) { - t.bufferStream(res, function (s) { t.equal(s, "POST /foo") }) - }).end() - }) - - t.test("testing GET", {parallel: true}, function (t) { - t.plan(1) - http.request("POST", { method: "GET" - , host: "localhost" - , path: "/foo" - , port: PORT }).on("response", function (res) { - t.bufferStream(res, function (s) { t.equal(s, "GET /foo") }) - }).end() - }) - - // wrap in a test so that if this throws, it'll log as a failed test. - t.test("teardown", function (t) { - server.close() - t.end() - }) -}) - -// yo dawg! -test("meta-tests", function (t) { - t.plan(5) - - // t.fails() wraps a child test and succeeds if it fails. - t.fails(t.test("this should fail", function (t) { - t.ok(false, "assert false") - t.end() - })) - - // t.timesOut() wraps a child test and succeeds if it times out. - // if t.end() is called, or if a plan is completed, then it fails. - // set the timeout really low so that it will not take forever. - t.timesOut(t.test("this should timeout", { timeout: 1 }, function (t) { - t.ok(true, "assert true") - // t.end() never called. - })) - - // t.incomplete() wraps a child test and succeeds if it ends before - // the plan is finished. - t.incomplete(t.test("this should be incomplete", function (t) { - t.plan(100) - t.ok(true, "assert true") - // calling end prematurely. - t.end() - })) - - // t.bailsOut() wraps a child test and succeeds if it calls bailout() - t.bailsOut(t.test("this should bailout", function (t) { - t.bailout("oh noes, bailing out!") - })) - - // low-level analysis of subtests - t.test("verifying test success/failure expectations", function (t) { - t.once("end", function () { - var res = t.results - , is = t.equal - // hijack! - t.clear() - is(res.ok, false, "ok") - - is(res.bailedOut, false, "bailed out") - - is(res.skip, 2, "skips") - is(res.skipPass, 1, "skip that passed") - is(res.skipFail, 1, "skip that failed") - - is(res.todo, 2, "todos") - is(res.todoPass, 1, "todo that passed") - is(res.todoFail, 1, "todo that failed") - - is(res.failTotal, 3, "failures total") - is(res.fail, 1, "relevant failure") - - is(res.passTotal, 3, "passes total") - is(res.pass, 1, "relevant pass") - - is(res.testsTotal, 6, "total tests") - is(res.tests, 2, "should be 2 relevant tests") - - t.end() - }) - - // run the metatest. - // *this* is the actual SUT in this case. - t.ok(false, "failing todo #todo") - // can also set #todo or #skip explicitly - t.ok(true, "succeeding todo", {todo: true}) - t.ok(false, "failing skip #skip", {skip: true}) - t.ok(true, "suceeding skip #skip") - t.ok(false, "failing test") - t.ok(true, "succeeding test") - t.end() - }) -}) diff --git a/node_modules/tap/lib/harness.js b/node_modules/tap/lib/harness.js deleted file mode 100644 index eb62b6462..000000000 --- a/node_modules/tap/lib/harness.js +++ /dev/null @@ -1,130 +0,0 @@ -module.exports = Harness - -var TapProducer = require("./tap-producer.js") -, TapTest = require("./tap-test.js") -, TapResults = require("./tap-results.js") -, assert = require("./tap-assert.js") - -// Test is the class to use for new tests -function Harness (Test) { - if (!(this instanceof Harness)) return new Harness(Test) - - var me = this - - this.output = new TapProducer() - this.results = new TapResults() - this.results.on("result", this.emit.bind(this, "result")) - - this._plan = null - this._current = null - this._children = null - this._bailedOut = null - - // count of tests that count towards plan. ie, top-level - this._planCount = 0 - // count of all nested tests at all levels. - this._testCount = 0 - - Harness.super.call(this) -} - -Harness.prototype.bailout = bailout -function bailout (message) { - if (this._bailedOut) return - message = message || true - this.output.end({bailout: message}) - this._ended = true - this._bailedOut = true - process.nextTick(this.process.bind(this)) -} - -Harness.prototype.end = end -function end () { - if (this._ended) return - this._ended = true - process.nextTick(this.process.bind(this)) -} - -function copyObj(o) { - var copied = {} - Object.keys(o).forEach(function (k) { copied[k] = o[k] }) - return copied -} - -Harness.prototype.test = test -function test (name, conf, cb) { - if (this._bailedOut || this._ended) return - - if (typeof conf === "function") cb = conf, conf = null - if (typeof name === "object") conf = name, name = null - if (typeof name === "function") cb = name, name = null - - conf = (conf ? copyObj(conf) : {}) - name = name || "" - - // Set to Infinity to have no timeout. - if (isNaN(conf.timeout)) conf.timeout = 30000 - var t = new this._Test(this, name, conf) - var me = this - - if (cb) { - t.on("ready", function () { - if (!isNaN(conf.timeout) && isFinite(conf.timeout)) { - var timer = setTimeout(t.timeout.bind(t), conf.timeout) - var clear = clearTimeout.bind(null, timer) - t.on("end", clear) - t.on("afterbailout", clear) - } - cb.call(t, t) - }) - } - - this._children.push(t) - - process.nextTick(this.process.bind(this)) - return t -} - -// the tearDown function is *always* guaranteed to happen. -// Even if there's a bailout. -Harness.prototype.tearDown = function (fn) { - this.on("end", fn.bind(this, this)) -} - -Harness.prototype.process = process -function process () { - // if already processing, then just exit. - if (this._processing) return - this._processing = true - - if (this._bailedOut) { - // do not pass go, do not collect $200 - // the bailout result was already written to the output. - return - } - - var current = this._children.shift() - while (current && current.conf.skip) { - this.results.add(assert.fail(current.conf.name, - { skip: true, diag:false })) - } - - // run the current test - // when it's over, handle the child end. - if (current) { - this._planCount ++ - this._current = current - current.on("end", this.childEnd.bind(this)) - current.emit("ready") - return - } - - // no more children. - // either we've ended, ran through the entire plan, - // or we're waiting for more children. - if (this._planCount === this._plan) this._ended = true - if (this._ended) this.harnessEnd() - this._processing = false -} - -Harness.prototype.harnessEnd diff --git a/node_modules/tap/lib/main.js b/node_modules/tap/lib/main.js deleted file mode 100644 index a9a520ab2..000000000 --- a/node_modules/tap/lib/main.js +++ /dev/null @@ -1,16 +0,0 @@ - -var GlobalHarness = require("./tap-global-harness") - -// this lets you do stuff like: -// var test = require("tap").test -// test(...) -// to run stuff in the global harness. -exports = module.exports = new GlobalHarness() - -exports.createProducer = exports.Producer = require("./tap-producer") -exports.createConsumer = exports.Consumer = require("./tap-consumer") -exports.yamlish = require("yamlish") -exports.createTest = exports.Test = require("./tap-test") -exports.createHarness = exports.Harness = require("./tap-harness") -exports.createRunner = exports.Runner = require("./tap-runner") -exports.assert = require("./tap-assert") diff --git a/node_modules/tap/lib/tap-assert.js b/node_modules/tap/lib/tap-assert.js deleted file mode 100644 index a8e747160..000000000 --- a/node_modules/tap/lib/tap-assert.js +++ /dev/null @@ -1,430 +0,0 @@ -// an assert module that returns tappable data for each assertion. -var difflet = require('difflet') - , deepEqual = require('deep-equal') - -module.exports = assert - -var syns = {} - , id = 1 - -function assert (ok, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - - //console.error("assert %j", [ok, message, extra]) - //if (extra && extra.skip) return assert.skip(message, extra) - //console.error("assert", [ok, message, extra]) - ok = !!ok - var res = { id : id ++, ok: ok } - - var caller = getCaller(extra && extra.error) - if (extra && extra.error) { - res.type = extra.error.name - res.message = extra.error.message - res.code = extra.error.code - || extra.error.type - res.errno = extra.error.errno - delete extra.error - } - if (caller.file) { - res.file = caller.file - res.line = +caller.line - res.column = +caller.column - } - res.stack = caller.stack - - res.name = message || "(unnamed assert)" - - if (extra) Object.keys(extra).forEach(function (k) { - if (!res.hasOwnProperty(k)) res[k] = extra[k] - }) - - // strings and objects are hard to diff by eye - if (!ok && - res.hasOwnProperty("found") && - res.hasOwnProperty("wanted") && - res.found !== res.wanted) { - if (typeof res.wanted !== typeof res.found || - typeof res.wanted === "object" && (!res.found || !res.wanted)) { - res.type = { found: typeof found - , wanted: typeof wanted } - } else if (typeof res.wanted === "string") { - res.diff = diffString(res.found, res.wanted) - } else if (typeof res.wanted === "object") { - res.diff = diffObject(res.found, res.wanted) - } - } - - //console.error("assert return", res) - - return res -} -assert.ok = assert -syns.ok = [ "true", "assert" ] - - -function notOk (ok, message, extra) { - return assert(!ok, message, extra) -} -assert.notOk = notOk -syns.notOk = [ "false", "notok" ] - -function error (er, message, extra) { - if (!er) { - // just like notOk(er) - return assert(!er, message, extra) - } - message = message || er.message - extra = extra || {} - extra.error = er - return assert.fail(message, extra) -} -assert.error = error -syns.error = [ "ifError", "ifErr", "iferror" ] - - -function pass (message, extra) { - return assert(true, message, extra) -} -assert.pass = pass - -function fail (message, extra) { - //console.error("assert.fail", [message, extra]) - //if (extra && extra.skip) return assert.skip(message, extra) - return assert(false, message, extra) -} -assert.fail = fail - -function skip (message, extra) { - //console.error("assert.skip", message, extra) - if (!extra) extra = {} - return { id: id ++, skip: true, name: message || "" } -} -assert.skip = skip - -function throws (fn, wanted, message, extra) { - if (typeof wanted === "string") { - extra = message - message = wanted - wanted = null - } - - if (extra && extra.skip) return assert.skip(message, extra) - - var found = null - try { - fn() - } catch (e) { - found = { name: e.name, message: e.message } - } - - extra = extra || {} - - extra.found = found - if (wanted) { - wanted = { name: wanted.name, message: wanted.message } - extra.wanted = wanted - } - - if (!message) { - message = "Expected to throw" - if (wanted) message += ": "+wanted.name + " " + wanted.message - } - - return (wanted) ? assert.similar(found, wanted, message, extra) - : assert.ok(found, message, extra) -} -assert.throws = throws - - -function doesNotThrow (fn, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var found = null - try { - fn() - } catch (e) { - found = {name: e.name, message: e.message} - } - message = message || "Should not throw" - - return assert.equal(found, null, message, extra) -} -assert.doesNotThrow = doesNotThrow - - -function equal (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should be equal" - extra.found = a - extra.wanted = b - return assert(a === b, message, extra) -} -assert.equal = equal -syns.equal = ["equals" - ,"isEqual" - ,"is" - ,"strictEqual" - ,"strictEquals"] - - -function equivalent (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var extra = extra || {} - message = message || "should be equivalent" - extra.found = a - extra.wanted = b - return assert(deepEqual(a, b), message, extra) -} -assert.equivalent = equivalent -syns.equivalent = ["isEquivalent" - ,"looseEqual" - ,"looseEquals" - ,"isDeeply" - ,"same" - ,"deepEqual" - ,"deepEquals"] - - -function inequal (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should not be equal" - extra.found = a - extra.doNotWant = b - return assert(a !== b, message, extra) -} -assert.inequal = inequal -syns.inequal = ["notEqual" - ,"notEquals" - ,"isNotEqual" - ,"isNot" - ,"not" - ,"doesNotEqual" - ,"isInequal"] - - -function inequivalent (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - extra = extra || {} - message = message || "should not be equivalent" - extra.found = a - extra.doNotWant = b - return assert(!deepEqual(a, b), message, extra) -} -assert.inequivalent = inequivalent -syns.inequivalent = ["notEquivalent" - ,"notDeepEqual" - ,"notDeeply" - ,"isNotDeepEqual" - ,"isNotDeeply" - ,"isNotEquivalent" - ,"isInequivalent"] - -function similar (a, b, message, extra, flip) { - if (extra && extra.skip) return assert.skip(message, extra) - // test that a has all the fields in b - message = message || "should be similar" - - if (typeof a === "string" && - (Object.prototype.toString.call(b) === "[object RegExp]")) { - extra = extra || {} - extra.pattern = b - extra.string = a - var ok = a.match(b) - extra.match = ok - if (flip) ok = !ok - return assert.ok(ok, message, extra) - } - - var isObj = assert(a && typeof a === "object", message, extra) - if (!isObj.ok) { - // not an object - if (a === b) isObj.ok = true - if (flip) isObj.ok = !isObj.ok - return isObj - } - - var eq = flip ? inequivalent : equivalent - return eq(selectFields(a, b), b, message, extra) -} -assert.similar = similar -syns.similar = ["isSimilar" - ,"has" - ,"hasFields" - ,"like" - ,"isLike"] - -function dissimilar (a, b, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - message = message || "should be dissimilar" - return similar(a, b, message, extra, true) -} -assert.dissimilar = dissimilar -syns.dissimilar = ["unsimilar" - ,"notSimilar" - ,"unlike" - ,"isUnlike" - ,"notLike" - ,"isNotLike" - ,"doesNotHave" - ,"isNotSimilar" - ,"isDissimilar"] - -function type (thing, t, message, extra) { - if (extra && extra.skip) return assert.skip(message, extra) - var name = t - if (typeof name === "function") name = name.name || "(anonymous ctor)" - //console.error("name=%s", name) - message = message || "type is "+name - var type = typeof thing - //console.error("type=%s", type) - if (!thing && type === "object") type = "null" - if (type === "object" && t !== "object") { - if (typeof t === "function") { - //console.error("it is a function!") - extra = extra || {} - extra.found = Object.getPrototypeOf(thing).constructor.name - extra.wanted = name - //console.error(thing instanceof t, name) - return assert.ok(thing instanceof t, message, extra) - } - - //console.error("check prototype chain") - // check against classnames or objects in prototype chain, as well. - // type(new Error("asdf"), "Error") - // type(Object.create(foo), foo) - var p = thing - while (p = Object.getPrototypeOf(p)) { - if (p === t || p.constructor && p.constructor.name === t) { - type = name - break - } - } - } - //console.error(type, name, type === name) - return assert.equal(type, name, message, extra) -} -assert.type = type -syns.type = ["isa"] - -// synonyms are helpful. -Object.keys(syns).forEach(function (c) { - syns[c].forEach(function (s) { - Object.defineProperty(assert, s, { value: assert[c], enumerable: false }) - }) -}) - -// helpers below - -function selectFields (a, b) { - // get the values in A of the fields in B - var ret = Array.isArray(b) ? [] : {} - Object.keys(b).forEach(function (k) { - if (!a.hasOwnProperty(k)) return - var v = b[k] - , av = a[k] - if (v && av && typeof v === "object" && typeof av === "object" - && !(v instanceof Date) - && !(v instanceof RegExp) - && !(v instanceof String) - && !(v instanceof Boolean) - && !(v instanceof Number) - && !(Array.isArray(v))) { - ret[k] = selectFields(av, v) - } else ret[k] = av - }) - return ret -} - -function sortObject (obj) { - if (typeof obj !== 'object' || Array.isArray(obj) || obj === null) { - return obj - } - - return Object.keys(obj).sort().reduce(function (acc, key) { - acc[key] = sortObject(obj[key]) - return acc - }, {}) -} - -function stringify (a) { - return JSON.stringify(sortObject(a), (function () { - var seen = [] - , keys = [] - return function (key, val) { - var s = seen.indexOf(val) - if (s !== -1) { - return "[Circular: "+keys[s]+"]" - } - if (val && typeof val === "object" || typeof val === "function") { - seen.push(val) - keys.push(val["!"] || val.name || key || "") - if (typeof val === "function") { - return val.toString().split(/\n/)[0] - } else if (typeof val.toUTCString === "function") { - return val.toUTCString() - } - } - return val - }})()) -} - -function diffString (f, w) { - if (w === f) return null - var p = 0 - , l = w.length - while (p < l && w.charAt(p) === f.charAt(p)) p ++ - w = stringify(w).substr(1).replace(/"$/, "") - f = stringify(f).substr(1).replace(/"$/, "") - return diff(f, w, p) -} - -function diffObject (f, w) { - return difflet({ indent : 2, comment : true }).compare(f, w) -} - -function diff (f, w, p) { - if (w === f) return null - var i = p || 0 // it's going to be at least p. JSON can only be bigger. - , l = w.length - while (i < l && w.charAt(i) === f.charAt(i)) i ++ - var pos = Math.max(0, i - 20) - w = w.substr(pos, 40) - f = f.substr(pos, 40) - var pointer = i - pos - return "FOUND: "+f+"\n" - + "WANTED: "+w+"\n" - + (new Array(pointer + 9).join(" ")) - + "^ (at position = "+p+")" -} - -function getCaller (er) { - // get the first file/line that isn't this file. - if (!er) er = new Error - var stack = er.stack || "" - stack = stack.split(/\n/) - for (var i = 1, l = stack.length; i < l; i ++) { - var s = stack[i].match(/\(([^):]+):([0-9]+):([0-9]+)\)$/) - if (!s) continue - var file = s[1] - , line = +s[2] - , col = +s[3] - if (file.indexOf(__dirname) === 0) continue - if (file.match(/tap-test\/test.js$/)) continue - else break - } - var res = {} - if (file && file !== __filename && !file.match(/tap-test\/test.js$/)) { - res.file = file - res.line = line - res.column = col - } - - res.stack = stack.slice(1).map(function (s) { - return s.replace(/^\s*at\s*/, "") - }) - - return res -} - - diff --git a/node_modules/tap/lib/tap-browser-harness.js b/node_modules/tap/lib/tap-browser-harness.js deleted file mode 100644 index 6e6cda7ef..000000000 --- a/node_modules/tap/lib/tap-browser-harness.js +++ /dev/null @@ -1,63 +0,0 @@ -// this is just a harness that pipes to stdout. -// It's the default one. -module.exports = BrowserHarness - -var BrowserHarness = global.TAP_Browser_Harness - , inherits = require("inherits") - , Results = require("./tap-results") - , Harness = require("./tap-harness") - , Test = require("./tap-test") - -inherits(BrowserHarness, Harness) -function BrowserHarness (outPipe) { - //console.error("calling BrowserHarness") - if (browserHarness) return browserHarness - if (!(this instanceof BrowserHarness)) { - return browserHarness = new BrowserHarness - } - browserHarness = global.TAP_Browser_Harness = this - BrowserHarness.super.call(this, Test) - - if (outPipe) this.output.pipe(outPipe) - - this.test = this.test.bind(this) - - this.plan = this.plan.bind(this) - - var output = this.output - this.on("childEnd", function (child) { - //console.error("childEnd in global harness") - //console.error(child.results) - // write out the stuff for this child. - //console.error("child.conf", child.conf) - output.write(child.conf.name || "(unnamed test)") - // maybe write some other stuff about the number of tests in this - // thing, etc. I dunno. - //console.error("child results", child.results) - this.results.list.forEach(function (res) { - //delete res.error - //console.error("child resuilt", res) - output.write(res) - }) - //console.error("wrote child results") - this.results.list.length = 0 - }) - - var streamEnded = false - this.on("end", function () { - //console.error("global ending the stream") - if (!streamEnded) { - this.results.list.forEach(function (res) { - output.write(res) - }) - this.results.list.length = 0 - output.end() - streamEnded = true - } - }) - - // TODO: handle global errors - // process.on("unhandledException", function (e) { - // this.bailout("unhandled exception: " + e.message) - // }) -} diff --git a/node_modules/tap/lib/tap-consumer.js b/node_modules/tap/lib/tap-consumer.js deleted file mode 100644 index 3fd8fea67..000000000 --- a/node_modules/tap/lib/tap-consumer.js +++ /dev/null @@ -1,243 +0,0 @@ -module.exports = TapConsumer - -// pipe a stream into this that's emitting tap-formatted data, -// and it'll emit "data" events with test objects or comment strings -// and an "end" event with the final results. - -var yamlish = require("yamlish") - , Results = require("./tap-results") - , inherits = require("inherits") - -TapConsumer.decode = TapConsumer.parse = function (str) { - var tc = new TapConsumer - , list = [] - tc.on("data", function (res) { - list.push(res) - }) - tc.end(str) - tc.results.list = list - return tc.results -} - -inherits(TapConsumer, require("stream").Stream) -function TapConsumer () { - if (!(this instanceof TapConsumer)) { - return new TapConsumer - } - - TapConsumer.super.call(this) - this.results = new Results - this.readable = this.writable = true - - this.on("data", function (res) { - if (typeof res === "object") this.results.add(res) - }) - - this._plan = null - this._buffer = "" - this._indent = [] - this._current = null - this._actualCount = 0 - this._passed = [] - this._failed = [] - //console.error("TapConsumer ctor done") -} - -TapConsumer.prototype.bailedOut = false - -TapConsumer.prototype.write = function (chunk) { - if (!this.writable) this.emit("error", new Error("not writable")) - if (this.bailedOut) return true - - this._buffer = this._buffer + chunk - // split it up into lines. - var lines = this._buffer.split(/\r?\n/) - // ignore the last line, since it might be incomplete. - this._buffer = lines.pop() - - for (var i = 0, l = lines.length; i < l; i ++) { - //console.error([i, lines[i]]) - // see if it's indented. - var line = lines[i] - , spaces = (this._indent.length && !line.trim()) - || line.match(/^\s/) - // at this level, only interested in fully undented stuff. - if (spaces) { - var c = i - while (c < l && (!lines[c].trim() || lines[c].match(/^\s/))) { - this._indent.push(lines[c++]) - } - //console.error(c-i, "indented", this._indent, this._current) - i = c - 1 - continue - } - // some kind of line. summary, ok, notok, comment, or garbage. - // this also finishes parsing any of the indented lines from before - this._parseLine(line) - } - return true -} - -TapConsumer.prototype.end = function () { - // finish up any hanging indented sections or final buffer - if (this._buffer.match(/^\s/)) this._indent.push(this.buffer) - else this._parseLine(this._buffer) - - if (!this.bailedOut && - this._plan !== null && - this.results.testsTotal !== this._plan) { - while (this._actualCount < this._plan) { - this.emit("data", {ok: false, name:"MISSING TEST", - id:this._actualCount ++ }) - } - } - - this._parseLine("") - this._buffer = "" - this.writable = false - this.emit("end", null, this._actualCount, this._passed) -} - -TapConsumer.prototype._parseLine = function (line) { - if (this.bailedOut) return - //console.error("_parseLine", [line]) - // if there are any indented lines, and there is a - // current object already, then they belong to it. - // if there is not a current object, then they're garbage. - if (this._current && this._indent.length) { - this._parseIndented() - } - this._indent.length = 0 - if (this._current) { - if (this._current.ok) this._passed.push(this._current.id) - else this._failed.push(this._current.id) - this.emit("data", this._current) - } - this._current = null - line = line.trim() - if (!line) return - // try to see what kind of line this is. - - var bo - if (bo = line.match(/^bail out!\s*(.*)$/i)) { - this.bailedOut = true - // this.emit("error", new Error(line)) - this.emit("bailout", bo[1]) - return - } - - if (line.match(/^#/)) { // just a comment - line = line.replace(/^#+/, "").trim() - // console.error("outputting comment", [line]) - if (line) this.emit("data", line) - return - } - - var plan = line.match(/^([0-9]+)\.\.([0-9]+)(?:\s+#(.*))?$/) - if (plan) { - var start = +(plan[1]) - , end = +(plan[2]) - , comment = plan[3] - - // TODO: maybe do something else with this? - // it might be something like: "1..0 #Skip because of reasons" - this._plan = end - this.emit("plan", end, comment) - // plan must come before or after all tests. - if (this._actualCount !== 0) { - this._sawPlan = true - } - return - } - - if (line.match(/^(not )?ok(?:\s+([0-9]+))?/)) { - this._parseResultLine(line) - return - } - - // garbage. emit as a comment. - //console.error("emitting", [line.trim()]) - if (line.trim()) this.emit("data", line.trim()) -} - -TapConsumer.prototype._parseDirective = function (line) { - line = line.trim() - if (line.match(/^TODO\b/i)) { - return { todo:true, explanation: line.replace(/^TODO\s*/i, "") } - } else if (line.match(/^SKIP\b/i)) { - return { skip:true, explanation: line.replace(/^SKIP\s*/i, "") } - } -} - -TapConsumer.prototype._parseResultLine = function (line) { - this._actualCount ++ - if (this._sawPlan) { - this.emit("data", {ok: false, name:"plan in the middle of tests" - ,id:this._actualCount ++}) - } - var parsed = line.match(/^(not )?ok(?: ([0-9]+))?(?:(?: - )?(.*))?$/) - , ok = !parsed[1] - , id = +(parsed[2] || this._actualCount) - , rest = parsed[3] || "" - , name - , res = { id:id, ok:ok } - - // split on un-escaped # characters - - //console.log("# "+JSON.stringify([name, rest])) - rest = rest.replace(/([^\\])((?:\\\\)*)#/g, "$1\n$2").split("\n") - name = rest.shift() - rest = rest.filter(function (r) { return r.trim() }).join("#") - //console.log("# "+JSON.stringify([name, rest])) - - // now, let's see if there's a directive in there. - var dir = this._parseDirective(rest.trim()) - if (!dir) name += rest ? "#" + rest : "" - else { - res.ok = true - if (dir.skip) res.skip = true - else if (dir.todo) res.todo = true - if (dir.explanation) res.explanation = dir.explanation - } - res.name = name - - //console.error(line, [ok, id, name]) - this._current = res -} - -TapConsumer.prototype._parseIndented = function () { - // pull yamlish block out - var ind = this._indent - , ys - , ye - , yind - , diag - //console.error(ind, this._indent) - for (var i = 0, l = ind.length; i < l; i ++) { - var line = ind[i] - , lt = line.trim() - if (!ys) { - ys = line.match(/^(\s*)---(.*)$/) - if (ys) { - yind = ys[1] - diag = [ys[2]] - //console.error([line,ys, diag]) - continue - } else if (lt) this.emit("data", lt) - } else if (ys && !ye) { - if (line === yind + "...") ye = true - else { - diag.push(line.substr(yind.length)) - } - } else if (ys && ye && lt) this.emit("data", lt) - } - if (diag) { - //console.error('about to parse', diag) - diag = yamlish.decode(diag.join("\n")) - //console.error('parsed', diag) - Object.keys(diag).forEach(function (k) { - //console.error(this._current, k) - if (!this._current.hasOwnProperty(k)) this._current[k] = diag[k] - }, this) - } -} diff --git a/node_modules/tap/lib/tap-cov-html.js b/node_modules/tap/lib/tap-cov-html.js deleted file mode 100644 index 3c1c19257..000000000 --- a/node_modules/tap/lib/tap-cov-html.js +++ /dev/null @@ -1,78 +0,0 @@ -var fs = require('fs'), - path = require('path'), - asyncMap = require("slide").asyncMap, - util = require('util'); - -var CovHtml = module.exports = function(cov_stats, cov_dir, cb) { - var index = []; - - asyncMap( - Object.keys(cov_stats), - function(f, cb) { - var st = cov_stats[f], - missing_lines = st.missing.map(function(l) { - return l.number; - }), - out = '\n\n\n ' + - '\n ' + - - f + ' (' + st.loc + ')\n' + - '\n' + - '\n\n' + - '

' + f + ' (' + st.loc + ')' + '

' + - '

Run: ' + (st.missing.length ? st.loc - st.missing.length : st.loc) + ', Missing: ' + - st.missing.length + ', Percentage: ' + st.percentage + '

' + - '

Source:

\n' + - '
    \n' + - st.lines.map(function(line) { - var number = line.number, - color = (missing_lines.indexOf(number) !== -1) ? '#fcc' : '#cfc'; - return '
  1. ' + line.source.replace(/'; - }).join('\n') + - '
\n' + - '

Data

\n'+ - '
' + util.inspect(st, true, Infinity, false).replace(/\n';
-
-      fs.writeFile(
-        cov_dir + '/' + 
-        f.replace(process.cwd() + '/', '').replace(/\//g, '+') + '.html',
-        out,
-        'utf8',
-        function(err) {
-          if (err) {
-            throw err;
-          }
-          index.push(f);
-          cb();
-        });
-    },
-    function(err) {
-      if (err) {
-        throw err;
-      }
-      var out = '\n\n\n  ' +
-          '\n  Coverage Index\n\n' +
-          '\n

Code Coverage Information

\n
    ' + - index.map(function(fname) { - return '
  • ' + fname + '
  • '; - }).join('\n') + '
\n\n'; - - fs.writeFile(cov_dir + '/index.html', out, 'utf8', function(err) { - if (err) { - throw err; - } - cb(); - }); - } - ); -}; - - diff --git a/node_modules/tap/lib/tap-global-harness.js b/node_modules/tap/lib/tap-global-harness.js deleted file mode 100644 index 0bcb3a4e4..000000000 --- a/node_modules/tap/lib/tap-global-harness.js +++ /dev/null @@ -1,68 +0,0 @@ -// this is just a harness that pipes to stdout. -// It's the default one. -module.exports = GlobalHarness - -var globalHarness = global.TAP_Global_Harness - , inherits = require("inherits") - , Results = require("./tap-results") - , Harness = require("./tap-harness") - , Test = require("./tap-test") - -inherits(GlobalHarness, Harness) -function GlobalHarness () { - //console.error("calling GlobalHarness") - if (globalHarness) return globalHarness - if (!(this instanceof GlobalHarness)) { - return globalHarness = new GlobalHarness - } - - globalHarness = global.TAP_Global_Harness = this - GlobalHarness.super.call(this, Test) - - this.output.pipe(process.stdout) - //this.output.on("data", function () { - // process.nextTick(process.stdout.flush.bind(process.stdout)) - //}) - - this.test = this.test.bind(this) - - this.plan = this.plan.bind(this) - - var output = this.output - this.on("childEnd", function (child) { - //console.error("childEnd in global harness") - //console.error(child.results) - // write out the stuff for this child. - //console.error("child.conf", child.conf) - output.write(child.conf.name || "(unnamed test)") - // maybe write some other stuff about the number of tests in this - // thing, etc. I dunno. - //console.error("child results", child.results) - this.results.list.forEach(function (res) { - //delete res.error - //console.error("child resuilt", res) - output.write(res) - }) - //console.error("wrote child results") - this.results.list.length = 0 - }) - - var streamEnded = false - this.on("end", function () { - //console.error("global ending the stream") - if (!streamEnded) { - this.results.list.forEach(function (res) { - output.write(res) - }) - this.results.list.length = 0 - output.end() - streamEnded = true - } - }) - - //this.on("end", this.output.end.bind(this.output)) - - process.on("unhandledException", function (e) { - this.bailout("unhandled exception: " + e.message) - }) -} diff --git a/node_modules/tap/lib/tap-harness.js b/node_modules/tap/lib/tap-harness.js deleted file mode 100644 index 7aa6cd6c2..000000000 --- a/node_modules/tap/lib/tap-harness.js +++ /dev/null @@ -1,219 +0,0 @@ -// a thing that runs tests. -// Every "test" is also a harness. If they do not have a harness, -// then they are attached to the defaut "global harness", -// which writes its results to stdout. - - -// TODO: -// - Bailout should stop running any tests. -// - "skip" in the test config obj should skip it. - -module.exports = Harness -require("inherits")(Harness, require("events").EventEmitter) - -var Results = require("./tap-results") - , TapProducer = require("./tap-producer") - , assert = require("./tap-assert") - -function Harness (Test) { - if (!(this instanceof Harness)) return new Harness(Test) - - //console.error("Test in "+this.constructor.name, Test) - - this._Test = Test - this._plan = null - this._children = [] - this._started = false - - this._testCount = 0 - this._planSum = 0 - - this.results = new Results() - // emit result events on the harness. - //this.results.on("result", function (res) { - // console.error("proxying result ev from res to harness") - // this.emit("result", res) - //}.bind(this)) - var me = this - this.results.on("result", this.emit.bind(this, "result")) - - var p = this.process.bind(this) - this.process = function () { - this._started = true - process.nextTick(p) - } - - this.output = new TapProducer() - Harness.super.call(this) -} - -// this function actually only gets called bound to -// the Harness object, and on process.nextTick. Even if -// passed as an event handler, everything *else* will -// happen before it gets called. -Harness.prototype.process = function () { - //console.error("harness process") - // "end" can emit multiple times, so only actually move on - // to the next test if the current one is actually over. - // TODO: multiple in-process tests, if all are marked "async" - if (this._current) { - if (!this._current._ended) return - // handle the current one before moving onto the next. - this.childEnd(this._current) - } - var skip = true - while (skip) { - //console.error("checking for skips") - var current = this._current = this._children.shift() - if (current) { - skip = current.conf.skip - if (skip) { - //console.error("add a failure for the skipping") - this.results.add(assert.fail(current.conf.name - ,{skip:true, diag:false})) - } - } else skip = false - } - - // keep processing through skipped tests, instead of running them. - if (current && this._bailedOut) { - return this.process() - } - - //console.error("got current?", !!current) - if (current) { - current.on("end", this.process) - current.emit("ready") - //console.error("emitted ready") - //console.error("_plan", this._plan, this.constructor.name) - } else { - //console.error("Harness process: no more left. ending") - if (this._endNice) { - this._endNice() - } else { - this.end() - } - } -} - -Harness.prototype.end = function () { - if (this._children.length) { - return this.process() - } - //console.error("harness end", this.constructor.name) - if (this._bailedOut) return - - // can't call .end() more than once. - if (this._ended) { - //console.error("adding failure for end calling") - this.results.add(assert.fail("end called more than once")) - } - - // see if the plan is completed properly, if there was one. - if (this._plan !== null) { - var total = this._testCount - if (total !== this._plan) { - this.results.add(assert.equal(total, this._plan, "test count != plan")) - } - this._plan = total - } - - //console.error("setting ended true", this.constructor.name) - this._ended = true - this.emit("end") -} - -Harness.prototype.plan = function (p) { - //console.error("setting plan", new Error().stack) - if (this._plan !== null) { - //console.error("about to add failure for calling plan") - return this.results.add(assert.fail("plan set multiple times")) - } - this._plan = p - if (p === 0 || this.results.testsTotal) { - this.end() - } -} - -Harness.prototype.childEnd = function (child) { - //console.error("childEnd") - this._testCount ++ - this._planSum += child._plan - //console.error("adding set of child.results") - this.results.addSet(child.results) - this.emit("childEnd", child) - // was this planned? - if (this._plan === this._testCount) { - //console.error("plan", [this._plan, this._testCount]) - return this.end() - } -} - -function copyObj(o) { - var copied = {} - Object.keys(o).forEach(function (k) { copied[k] = o[k] }) - return copied -} - -Harness.prototype.test = function test (name, conf, cb) { - if (this._bailedOut) return - - if (typeof conf === "function") cb = conf, conf = null - if (typeof name === "object") conf = name, name = null - if (typeof name === "function") cb = name, name = null - - conf = (conf ? copyObj(conf) : {}) - name = name || "" - - //console.error("making test", [name, conf, cb]) - - // timeout: value in milliseconds. Defaults to 30s - // Set to Infinity to have no timeout. - if (isNaN(conf.timeout)) conf.timeout = 30000 - var t = new this._Test(this, name, conf) - var self = this - if (cb) { - //console.error("attaching cb to ready event") - t.on("ready", function () { - if (!isNaN(conf.timeout) && isFinite(conf.timeout)) { - var timer = setTimeout(this.timeout.bind(this), conf.timeout) - var clear = clearTimeout.bind(null, timer) - t.on("end", clear) - t.on("bailout", function (message) { - self.bailout(message) - clear() - }) - } - }) - t.on("ready", cb.bind(t, t)) - // proxy the child results to this object. - //t.on("result", function (res) { - // console.error("in harness, proxying result up") - // t.results.add(res) - //}) - } - return t -} - -Harness.prototype.bailout = function (message) { - // console.error("Harness bailout", this.constructor.name) - message = message || "" - //console.error("adding bailout message result") - this.results.add({bailout: message}) - // console.error(">>> results after bailout" , this.results) - this._bailedOut = true - this.emit("bailout", message) - this.output.end({bailout: message}) -} - -Harness.prototype.add = function (child) { - //console.error("adding child") - this._children.push(child) - if (!this._started) this.process() -} - -// the tearDown function is *always* guaranteed to happen. -// Even if there's a bailout. -Harness.prototype.tearDown = function (fn) { - this.on("end", fn) -} diff --git a/node_modules/tap/lib/tap-producer.js b/node_modules/tap/lib/tap-producer.js deleted file mode 100644 index 14b50c8a8..000000000 --- a/node_modules/tap/lib/tap-producer.js +++ /dev/null @@ -1,125 +0,0 @@ -module.exports = TapProducer - -var Results = require("./tap-results") - , inherits = require("inherits") - , yamlish = require("yamlish") - -TapProducer.encode = function (result, diag) { - var tp = new TapProducer(diag) - , out = "" - tp.on("data", function (c) { out += c }) - if (Array.isArray(result)) { - result.forEach(tp.write, tp) - } else tp.write(result) - tp.end() - return out -} - -inherits(TapProducer, require("stream").Stream) -function TapProducer (diag) { - TapProducer.super.call(this) - this.diag = diag - this.count = 0 - this.readable = this.writable = true - this.results = new Results -} - -TapProducer.prototype.trailer = true - -TapProducer.prototype.write = function (res) { - // console.error("TapProducer.write", res) - if (typeof res === "function") throw new Error("wtf?") - if (!this.writable) this.emit("error", new Error("not writable")) - - var diag = res.diag - if (diag === undefined) diag = this.diag - - this.emit("data", encodeResult(res, this.count + 1, diag)) - - if (typeof res === "string") return true - - if (res.bailout) { - var bo = "bail out!" - if (typeof res.bailout === "string") bo += " " + res.bailout - this.emit("data", bo) - return - } - this.results.add(res, false) - - this.count ++ -} - -TapProducer.prototype.end = function (res) { - if (res) this.write(res) - // console.error("TapProducer end", res, this.results) - this.emit("data", "\n1.."+this.results.testsTotal+"\n") - if (this.trailer && typeof this.trailer !== "string") { - // summary trailer. - var trailer = "tests "+this.results.testsTotal + "\n" - if (this.results.pass) { - trailer += "pass " + this.results.pass + "\n" - } - if (this.results.fail) { - trailer += "fail " + this.results.fail + "\n" - } - if (this.results.skip) { - trailer += "skip "+this.results.skip + "\n" - } - if (this.results.todo) { - trailer += "todo "+this.results.todo + "\n" - } - if (this.results.bailedOut) { - trailer += "bailed out" + "\n" - } - - if (this.results.testsTotal === this.results.pass) { - trailer += "\nok\n" - } - this.trailer = trailer - } - if (this.trailer) this.write(this.trailer) - this.writable = false - this.emit("end", null, this.count, this.ok) -} - -function encodeResult (res, count, diag) { - // console.error(res, count, diag) - if (typeof res === "string") { - res = res.split(/\r?\n/).map(function (l) { - if (!l.trim()) return l.trim() - return "# " + l - }).join("\n") - if (res.substr(-1) !== "\n") res += "\n" - return res - } - - if (res.bailout) return "" - - - if (!!process.env.TAP_NODIAG) diag = false - else if (!!process.env.TAP_DIAG) diag = true - else if (diag === undefined) diag = !res.ok - - var output = "" - res.name = res.name && ("" + res.name).trim() - output += ( !res.ok ? "not " : "") + "ok " + count - + ( !res.name ? "" - : " " + res.name.replace(/[\r\n]/g, " ") ) - + ( res.skip ? " # SKIP" - : res.todo ? " # TODO" - : "" ) - + "\n" - - if (!diag) return output - var d = {} - , dc = 0 - Object.keys(res).filter(function (k) { - return k !== "ok" && k !== "name" && k !== "id" - }).forEach(function (k) { - dc ++ - d[k] = res[k] - }) - //console.error(d, "about to encode") - if (dc > 0) output += " ---"+yamlish.encode(d)+"\n ...\n" - return output -} diff --git a/node_modules/tap/lib/tap-results.js b/node_modules/tap/lib/tap-results.js deleted file mode 100644 index 6fe90e8d5..000000000 --- a/node_modules/tap/lib/tap-results.js +++ /dev/null @@ -1,71 +0,0 @@ -// A class for counting up results in a test harness. - -module.exports = Results - -var inherits = require("inherits") - , EventEmitter = require("events").EventEmitter - -inherits(Results, EventEmitter) - -function Results (r) { - //console.error("result constructor", r) - this.ok = true - this.addSet(r) -} - -Results.prototype.addSet = function (r) { - //console.error("add set of results", r) - r = r || {ok: true} - ; [ "todo" - , "todoPass" - , "todoFail" - , "skip" - , "skipPass" - , "skipFail" - , "pass" - , "passTotal" - , "fail" - , "failTotal" - , "tests" - , "testsTotal" ].forEach(function (k) { - this[k] = (this[k] || 0) + (r[k] || 0) - //console.error([k, this[k]]) - }, this) - - this.ok = this.ok && r.ok && true - this.bailedOut = this.bailedOut || r.bailedOut || false - this.list = (this.list || []).concat(r.list || []) - this.emit("set", this.list) - //console.error("after addSet", this) -} - -Results.prototype.add = function (r, addToList) { - //console.error("add result", r) - var pf = r.ok ? "pass" : "fail" - , PF = r.ok ? "Pass" : "Fail" - - this.testsTotal ++ - this[pf + "Total"] ++ - - if (r.skip) { - this["skip" + PF] ++ - this.skip ++ - } else if (r.todo) { - this["todo" + PF] ++ - this.todo ++ - } else { - this.tests ++ - this[pf] ++ - } - - if (r.bailout || typeof r.bailout === "string") { - // console.error("Bailing out in result") - this.bailedOut = true - } - this.ok = !!(this.ok && r.ok) - - if (addToList === false) return - this.list = this.list || [] - this.list.push(r) - this.emit("result", r) -} diff --git a/node_modules/tap/lib/tap-runner.js b/node_modules/tap/lib/tap-runner.js deleted file mode 100644 index 4f3f1171b..000000000 --- a/node_modules/tap/lib/tap-runner.js +++ /dev/null @@ -1,434 +0,0 @@ -var fs = require("fs") - , child_process = require("child_process") - , path = require("path") - , chain = require("slide").chain - , asyncMap = require("slide").asyncMap - , TapProducer = require("./tap-producer.js") - , TapConsumer = require("./tap-consumer.js") - , assert = require("./tap-assert.js") - , inherits = require("inherits") - , util = require("util") - , CovHtml = require("./tap-cov-html.js") - - // XXX Clean up the coverage options - , doCoverage = process.env.TAP_COV - || process.env.npm_package_config_coverage - || process.env.npm_config_coverage - -module.exports = Runner - -inherits(Runner, TapProducer) - -function Runner (options, cb) { - this.options = options - - var diag = this.options.diag - var dir = this.options.argv.remain - Runner.super.call(this, diag) - - this.doCoverage = doCoverage - // An array of full paths to files to obtain coverage - this.coverageFiles = [] - // The source of these files - this.coverageFilesSource = {} - // Where to write coverage information - this.coverageOutDir = this.options["coverage-dir"] - // Temporary test files bunkerified we'll remove later - this.f2delete = [] - // Raw coverage stats, as read from JSON files - this.rawCovStats = [] - // Processed coverage information, per file to cover: - this.covStats = {} - - if (dir) { - var filesToCover = this.options.cover - - if (doCoverage) { - var mkdirp = require("mkdirp") - this.coverageOutDir = path.resolve(this.coverageOutDir) - this.getFilesToCover(filesToCover) - var self = this - return mkdirp(this.coverageOutDir, 0755, function (er) { - if (er) return self.emit("error", er) - self.run(dir, cb) - }) - } - - this.run(dir, cb) - } -} - - -Runner.prototype.run = function() { - var self = this - , args = Array.prototype.slice.call(arguments) - , cb = args.pop() || finish - - function finish (er) { - if (er) { - self.emit("error", er) - } - - if (!doCoverage) return self.end() - - // Cleanup temporary test files with coverage: - self.f2delete.forEach(function(f) { - fs.unlinkSync(f) - }) - self.getFilesToCoverSource(function(err, data) { - if (err) { - self.emit("error", err) - } - self.getPerFileCovInfo(function(err, data) { - if (err) { - self.emit("error", err) - } - self.mergeCovStats(function(err, data) { - if (err) { - self.emit("error", err) - } - CovHtml(self.covStats, self.coverageOutDir, function() { - self.end() - }) - }) - }) - }) - } - - if (Array.isArray(args[0])) { - args = args[0] - } - self.runFiles(args, "", cb) -} - -Runner.prototype.runDir = function (dir, cb) { - var self = this - fs.readdir(dir, function (er, files) { - if (er) { - self.write(assert.fail("failed to readdir " + dir, { error: er })) - self.end() - return - } - files = files.sort(function(a, b) { - return a > b ? 1 : -1 - }) - files = files.filter(function(f) { - return !f.match(/^\./) - }) - files = files.map(path.resolve.bind(path, dir)) - - self.runFiles(files, path.resolve(dir), cb) - }) -} - - -Runner.prototype.runFiles = function (files, dir, cb) { - - var self = this - chain(files.map(function(f) { - return function (cb) { - if (self._bailedOut) return - var relDir = dir || path.dirname(f) - , fileName = relDir === "." ? f : f.substr(relDir.length + 1) - - self.write(fileName) - fs.lstat(f, function(er, st) { - if (er) { - self.write(assert.fail("failed to stat " + f, {error: er})) - return cb() - } - - var cmd = f, args = [], env = {} - - if (path.extname(f) === ".js") { - cmd = "node" - args = [fileName] - } else if (path.extname(f) === ".coffee") { - cmd = "coffee" - args = [fileName] - } - - if (st.isDirectory()) { - return self.runDir(f, cb) - } - - if (doCoverage && path.extname(f) === ".js") { - var foriginal = fs.readFileSync(f, "utf8") - , fcontents = self.coverHeader() + foriginal + self.coverFooter() - , tmpBaseName = path.basename(f, path.extname(f)) - + ".with-coverage." + process.pid + path.extname(f) - , tmpFname = path.resolve(path.dirname(f), tmpBaseName) - , i - - fs.writeFileSync(tmpFname, fcontents, "utf8") - args = [tmpFname] - } - - for (i in process.env) { - env[i] = process.env[i] - } - env.TAP = 1 - - var cp = child_process.spawn(cmd, args, { env: env, cwd: relDir }) - , out = "" - , err = "" - , tc = new TapConsumer() - , childTests = [f] - - var timeout = setTimeout(function () { - if (!cp._ended) { - cp._timedOut = true - cp.kill() - } - }, self.options.timeout * 1000) - - tc.on("data", function(c) { - self.emit("result", c) - self.write(c) - }) - - tc.on("bailout", function (message) { - clearTimeout(timeout) - console.log("# " + f.substr(process.cwd().length + 1)) - process.stderr.write(err) - process.stdout.write(out + "\n") - self._bailedOut = true - cp._ended = true - cp.kill() - }) - - cp.stdout.pipe(tc) - cp.stdout.on("data", function (c) { out += c }) - cp.stderr.on("data", function (c) { - if (self.options.stderr) process.stderr.write(c) - err += c - }) - - cp.on("exit", function (code) { - if (cp._ended) return - cp._ended = true - var ok = !cp._timedOut && !code - clearTimeout(timeout) - //childTests.forEach(function (c) { self.write(c) }) - var res = { name: path.dirname(f).replace(process.cwd() + "/", "") - + "/" + fileName - , ok: ok - , timedOut: cp._timedOut - , exit: code } - - if (err) { - res.stderr = err - if (tc.results.ok && - tc.results.tests === 0 && - !self.options.stderr) { - // perhaps a compilation error or something else failed. - // no need if stderr is set, since it will have been - // output already anyway. - console.error(err) - } - } - - // tc.results.ok = tc.results.ok && ok - tc.results.add(res) - res.command = [cmd].concat(args).map(JSON.stringify).join(" ") - self.emit("result", res) - self.emit("file", f, res, tc.results) - self.write(res) - self.write("\n") - if (doCoverage) { - self.f2delete.push(tmpFname) - } - cb() - }) - }) - } - }), cb) - - return self -} - - -// Get an array of full paths to files we are interested into obtain -// code coverage. -Runner.prototype.getFilesToCover = function(filesToCover) { - var self = this - filesToCover = filesToCover.split(",").map(function(f) { - return path.resolve(f) - }).filter(function(f) { - return path.existsSync(f) - }) - - function recursive(f) { - if (path.extname(f) === "") { - // Is a directory: - fs.readdirSync(f).forEach(function(p) { - recursive(f + "/" + p) - }) - } else { - self.coverageFiles.push(f) - } - } - filesToCover.forEach(function(f) { - recursive(f) - }) -} - -// Prepend to every test file to run. Note tap.test at the very top due it -// "plays" with include paths. -Runner.prototype.coverHeader = function() { - // semi here since we're injecting it before the first line, - // and don't want to mess up line numbers in the test files. - return "var ___TAP_COVERAGE = require(" - + JSON.stringify(require.resolve("runforcover")) - + ").cover(/.*/g);" -} - -// Append at the end of every test file to run. Actually, the stuff which gets -// the coverage information. -// Maybe it would be better to move into a separate file template so editing -// could be easier. -Runner.prototype.coverFooter = function() { - var self = this - // This needs to be a string with proper interpolations: - return [ "" - , "var ___TAP = require(" + JSON.stringify(require.resolve("./main.js")) + ")" - , "if (typeof ___TAP._plan === 'number') ___TAP._plan ++" - , "___TAP.test(" + JSON.stringify("___coverage") + ", function(t) {" - , " var covFiles = " + JSON.stringify(self.coverageFiles) - , " , covDir = " + JSON.stringify(self.coverageOutDir) - , " , path = require('path')" - , " , fs = require('fs')" - , " , testFnBase = path.basename(__filename, '.js') + '.json'" - , " , testFn = path.resolve(covDir, testFnBase)" - , "" - , " function asyncForEach(arr, fn, callback) {" - , " if (!arr.length) {" - , " return callback()" - , " }" - , " var completed = 0" - , " arr.forEach(function(i) {" - , " fn(i, function (err) {" - , " if (err) {" - , " callback(err)" - , " callback = function () {}" - , " } else {" - , " completed += 1" - , " if (completed === arr.length) {" - , " callback()" - , " }" - , " }" - , " })" - , " })" - , " }" - , "" - , " ___TAP_COVERAGE(function(coverageData) {" - , " var outObj = {}" - , " asyncForEach(covFiles, function(f, cb) {" - , " if (coverageData[f]) {" - , " var stats = coverageData[f].stats()" - , " , stObj = stats" - , " stObj.lines = stats.lines.map(function (l) {" - , " return { number: l.lineno, source: l.source() }" - , " })" - , " outObj[f] = stObj" - , " }" - , " cb()" - , " }, function(err) {" - , " ___TAP_COVERAGE.release()" - , " fs.writeFileSync(testFn, JSON.stringify(outObj))" - , " t.end()" - , " })" - , " })" - , "})" ].join("\n") -} - - -Runner.prototype.getFilesToCoverSource = function(cb) { - var self = this - asyncMap(self.coverageFiles, function(f, cb) { - fs.readFile(f, "utf8", function(err, data) { - var lc = 0 - if (err) { - cb(err) - } - self.coverageFilesSource[f] = data.split("\n").map(function(l) { - lc += 1 - return { number: lc, source: l } - }) - cb() - }) - }, cb) -} - -Runner.prototype.getPerFileCovInfo = function(cb) { - var self = this - , covPath = path.resolve(self.coverageOutDir) - - fs.readdir(covPath, function(err, files) { - if (err) { - self.emit("error", err) - } - var covFiles = files.filter(function(f) { - return path.extname(f) === ".json" - }) - asyncMap(covFiles, function(f, cb) { - fs.readFile(path.resolve(covPath, f), "utf8", function(err, data) { - if (err) { - cb(err) - } - self.rawCovStats.push(JSON.parse(data)) - cb() - }) - }, function(f, cb) { - fs.unlink(path.resolve(covPath, f), cb) - }, cb) - }) -} - -Runner.prototype.mergeCovStats = function(cb) { - var self = this - self.rawCovStats.forEach(function(st) { - Object.keys(st).forEach(function(i) { - // If this is the first time we reach this file, just add the info: - if (!self.covStats[i]) { - self.covStats[i] = { - missing: st[i].lines - } - } else { - // If we already added info for this file before, we need to remove - // from self.covStats any line not duplicated again (since it has - // run on such case) - self.covStats[i].missing = self.covStats[i].missing.filter( - function(l) { - return (st[i].lines.indexOf(l)) - }) - } - }) - }) - - // This is due to a bug into - // chrisdickinson/node-bunker/blob/feature/add-coverage-interface - // which is using array indexes for line numbers instead of the right number - Object.keys(self.covStats).forEach(function(f) { - self.covStats[f].missing = self.covStats[f].missing.map(function(line) { - return { number: line.number, source: line.source } - }) - }) - - Object.keys(self.coverageFilesSource).forEach(function(f) { - if (!self.covStats[f]) { - self.covStats[f] = { missing: self.coverageFilesSource[f] - , percentage: 0 - } - } - self.covStats[f].lines = self.coverageFilesSource[f] - self.covStats[f].loc = self.coverageFilesSource[f].length - - if (!self.covStats[f].percentage) { - self.covStats[f].percentage = - 1 - (self.covStats[f].missing.length / self.covStats[f].loc) - } - - }) - cb() -} diff --git a/node_modules/tap/lib/tap-test.js b/node_modules/tap/lib/tap-test.js deleted file mode 100644 index 3c8f13849..000000000 --- a/node_modules/tap/lib/tap-test.js +++ /dev/null @@ -1,109 +0,0 @@ -// This is a very simple test framework that leverages the tap framework -// to run tests and output tap-parseable results. - -module.exports = Test - -var assert = require("./tap-assert") - , inherits = require("inherits") - , Results = require("./tap-results") - -// tests are also test harnesses -inherits(Test, require("./tap-harness")) - -function Test (harness, name, conf) { - //console.error("test ctor") - if (!(this instanceof Test)) return new Test(harness, name, conf) - - Test.super.call(this, Test) - - conf.name = name || conf.name || "(anonymous)" - this.conf = conf - - this.harness = harness - this.harness.add(this) -} - -// it's taking too long! -Test.prototype.timeout = function () { - // detect false alarms - if (this._ended) return - this.fail("Timeout!") - this.end() -} - -Test.prototype.clear = function () { - this._started = false - this._ended = false - this._plan = null - this._bailedOut = false - this._testCount = 0 - this.results = new Results() -} - -// this gets called if a test throws ever -Test.prototype.threw = function (ex) { - //console.error("threw!", ex.stack) - this.fail(ex.name + ": " + ex.message, { error: ex, thrown: true }) - // may emit further failing tests if the plan is not completed - //console.error("end, because it threw") - this.end() -} - -Test.prototype.comment = function (m) { - if (typeof m !== "string") { - return this.fail("Test.comment argument must be a string") - } - this.result("\n" + m.trim()) -} - -Test.prototype.result = function (res) { - this.results.add(res) - this._testCount ++ - this.emit("result", res) - if (this._plan === this._testCount) { - process.nextTick(this._endNice.bind(this)) - } -} - -Test.prototype._endNice = function () { - if (!this._ended) this.end() -} - -// parasitic -// Who says you can't do multiple inheritance in js? -Object.getOwnPropertyNames(assert).forEach(function (k) { - if (k === "prototype" || k === "name") return - var d = Object.getOwnPropertyDescriptor(assert, k) - , v = d.value - if (!v) return - d.value = assertParasite(v) - Object.defineProperty(Test.prototype, k, d) -}) - -function assertParasite (fn) { return function _testAssert () { - //console.error("_testAssert", fn.name, arguments) - if (this._bailedOut) return - var res = fn.apply(assert, arguments) - this.result(res) - return res -}} - -// a few tweaks on the EE emit function, because -// we want to catch all thrown errors and bubble up "bailout" -Test.prototype.emit = (function (em) { return function (t) { - // bailouts bubble until handled - if (t === "bailout" && - this.listeners(t).length === 0 && - this.harness) { - return this.harness.bailout(arguments[1]) - } - - if (t === "error") return em.apply(this, arguments) - try { - em.apply(this, arguments) - } catch (ex) { - // any exceptions in a test are a failure - //console.error("caught!", ex.stack) - this.threw(ex) - } -}})(Test.super.prototype.emit) diff --git a/node_modules/tap/node_modules/.bin/nopt b/node_modules/tap/node_modules/.bin/nopt deleted file mode 120000 index 6b6566ea7..000000000 --- a/node_modules/tap/node_modules/.bin/nopt +++ /dev/null @@ -1 +0,0 @@ -../nopt/bin/nopt.js \ No newline at end of file diff --git a/node_modules/tap/node_modules/deep-equal/README.markdown b/node_modules/tap/node_modules/deep-equal/README.markdown deleted file mode 100644 index c3293d365..000000000 --- a/node_modules/tap/node_modules/deep-equal/README.markdown +++ /dev/null @@ -1,55 +0,0 @@ -deep-equal -========== - -Node's `assert.deepEqual() algorithm` as a standalone module. - -example -======= - -``` js -var equal = require('deep-equal'); -console.dir([ - equal( - { a : [ 2, 3 ], b : [ 4 ] }, - { a : [ 2, 3 ], b : [ 4 ] } - ), - equal( - { x : 5, y : [6] }, - { x : 5, y : 6 } - ) -]); -``` - -methods -======= - -var deepEqual = require('deep-equal') - -deepEqual(a, b) ---------------- - -Compare objects `a` and `b`, returning whether they are equal according to a -recursive equality algorithm. - -install -======= - -With [npm](http://npmjs.org) do: - -``` -npm install deep-equal -``` - -test -==== - -With [npm](http://npmjs.org) do: - -``` -npm test -``` - -license -======= - -MIT. Derived largely from node's assert module. diff --git a/node_modules/tap/node_modules/deep-equal/example/cmp.js b/node_modules/tap/node_modules/deep-equal/example/cmp.js deleted file mode 100644 index 67014b88d..000000000 --- a/node_modules/tap/node_modules/deep-equal/example/cmp.js +++ /dev/null @@ -1,11 +0,0 @@ -var equal = require('../'); -console.dir([ - equal( - { a : [ 2, 3 ], b : [ 4 ] }, - { a : [ 2, 3 ], b : [ 4 ] } - ), - equal( - { x : 5, y : [6] }, - { x : 5, y : 6 } - ) -]); diff --git a/node_modules/tap/node_modules/deep-equal/index.js b/node_modules/tap/node_modules/deep-equal/index.js deleted file mode 100644 index e4e37beb6..000000000 --- a/node_modules/tap/node_modules/deep-equal/index.js +++ /dev/null @@ -1,84 +0,0 @@ -var pSlice = Array.prototype.slice; -var Object_keys = typeof Object.keys === 'function' - ? Object.keys - : function (obj) { - var keys = []; - for (var key in obj) keys.push(key); - return keys; - } -; - -var deepEqual = module.exports = function (actual, expected) { - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - // 7.3. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual == expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected); - } -} - -function isUndefinedOrNull(value) { - return value === null || value === undefined; -} - -function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; -} - -function objEquiv(a, b) { - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - // an identical 'prototype' property. - if (a.prototype !== b.prototype) return false; - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return deepEqual(a, b); - } - try { - var ka = Object_keys(a), - kb = Object_keys(b), - key, i; - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length != kb.length) - return false; - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!deepEqual(a[key], b[key])) return false; - } - return true; -} diff --git a/node_modules/tap/node_modules/deep-equal/package.json b/node_modules/tap/node_modules/deep-equal/package.json deleted file mode 100644 index 9020c5b83..000000000 --- a/node_modules/tap/node_modules/deep-equal/package.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name" : "deep-equal", - "version" : "0.0.0", - "description" : "node's assert.deepEqual algorithm", - "main" : "index.js", - "directories" : { - "lib" : ".", - "example" : "example", - "test" : "test" - }, - "scripts" : { - "test" : "tap test/*.js" - }, - "devDependencies" : { - "tap" : "0.0.x" - }, - "repository" : { - "type" : "git", - "url" : "https://github.com/substack/node-deep-equal.git" - }, - "keywords" : [ - "equality", - "equal", - "compare" - ], - "author" : { - "name" : "James Halliday", - "email" : "mail@substack.net", - "url" : "http://substack.net" - }, - "license" : "MIT/X11", - "engine" : { "node" : ">=0.4" } -} diff --git a/node_modules/tap/node_modules/deep-equal/test/cmp.js b/node_modules/tap/node_modules/deep-equal/test/cmp.js deleted file mode 100644 index 8418f0f89..000000000 --- a/node_modules/tap/node_modules/deep-equal/test/cmp.js +++ /dev/null @@ -1,18 +0,0 @@ -var test = require('tap').test; -var equal = require('../'); - -test('equal', function (t) { - t.ok(equal( - { a : [ 2, 3 ], b : [ 4 ] }, - { a : [ 2, 3 ], b : [ 4 ] } - )); - t.end(); -}); - -test('not equal', function (t) { - t.notOk(equal( - { x : 5, y : [6] }, - { x : 5, y : 6 } - )); - t.end(); -}); diff --git a/node_modules/tap/node_modules/difflet/.travis.yml b/node_modules/tap/node_modules/difflet/.travis.yml deleted file mode 100644 index f1d0f13c8..000000000 --- a/node_modules/tap/node_modules/difflet/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - 0.4 - - 0.6 diff --git a/node_modules/tap/node_modules/difflet/README.markdown b/node_modules/tap/node_modules/difflet/README.markdown deleted file mode 100644 index 9ad43031d..000000000 --- a/node_modules/tap/node_modules/difflet/README.markdown +++ /dev/null @@ -1,116 +0,0 @@ -difflet -======= - -Create colorful diffs for javascript objects. - -example -======= - -string.js ---------- - -``` js -var difflet = require('difflet'); - -var s = difflet.compare({ a : 2, c : 5 }, { a : 3, b : 4 }); -process.stdout.write(s); -``` - -output: - -![colorful output](http://substack.net/images/screenshots/difflet_string.png) - -colors.js ---------- - -``` js -var diff = require('difflet')({ indent : 2 }); - -var prev = { - yy : 6, - zz : 5, - a : [1,2,3], - fn : 'beep', - c : { x : 7, z : 3 } -}; - -var next = { - a : [ 1, 2, "z", /beep/, new Buffer(3) ], - fn : function qqq () {}, - b : [5,6,7], - c : { x : 8, y : 5 } -}; - -diff(prev, next).pipe(process.stdout); -``` - -output: - -![colorful output](http://substack.net/images/screenshots/difflet_colors.png) - -green for inserts, blue for updates, red for deletes - -methods -======= - -var difflet = require('difflet') - -var diff = difflet(opts={}) ---------------------------- - -Create a difflet from optional options `opts`. - -With `opts.start(type, stream)` and `opts.stop(type, stream)`, -you can write custom handlers for all the types of differences: -`'inserted'`, `'updated'`, and `'deleted'`. -By default green is used for insertions, blue for updates, and red for -deletions. - -If `opts.indent` is set, output will span multiple lines and `opts.indent` -spaces will be used for leading whitespace. - -If `opts.comma === 'first'` then commas will be placed at the start of lines. - -Setting `opts.comment` to `true` will turn on comments with the previous -contents like this: - -![object comments](http://substack.net/images/screenshots/difflet_object_comments.png) - -diff(prev, next) ----------------- - -Return a stream with the colorful changes between objects `prev` and `next`. - -diff.compare(prev, next) ------------------------- - -Return a string with the colorful changes between `prev` and `next`. - -difflet.compare(prev, next) ---------------------------- - -Return a string with the colorful changes between `prev` and `next` with the -default options. - -install -======= - -With [npm](http://npmjs.org) do: - -``` -npm install difflet -``` - -test -==== - -With [npm](http://npmjs.org) do: - -``` -npm test -``` - -license -======= - -MIT/X11 diff --git a/node_modules/tap/node_modules/difflet/example/cmp_array.js b/node_modules/tap/node_modules/difflet/example/cmp_array.js deleted file mode 100644 index bc5733fa9..000000000 --- a/node_modules/tap/node_modules/difflet/example/cmp_array.js +++ /dev/null @@ -1,6 +0,0 @@ -var difflet = require('../'); -var s = difflet({ indent : 2, comment : true }).compare( - [ 1, [2,3,{a:4}], 3 ], - [ 1, [[5],6,7], 4 ] -); -process.stdout.write(s); diff --git a/node_modules/tap/node_modules/difflet/example/cmp_object.js b/node_modules/tap/node_modules/difflet/example/cmp_object.js deleted file mode 100644 index 410289e69..000000000 --- a/node_modules/tap/node_modules/difflet/example/cmp_object.js +++ /dev/null @@ -1,6 +0,0 @@ -var difflet = require('../'); -var s = difflet({ indent : 2, comment : true }).compare( - { z : [6,7], a : 'abcdefgh', b : [ 31, 'xxt' ] }, - { x : 5, a : 'abdcefg', b : [ 51, 'xxs' ] } -); -process.stdout.write(s); diff --git a/node_modules/tap/node_modules/difflet/example/colors.js b/node_modules/tap/node_modules/difflet/example/colors.js deleted file mode 100644 index 332bbae3f..000000000 --- a/node_modules/tap/node_modules/difflet/example/colors.js +++ /dev/null @@ -1,18 +0,0 @@ -var diff = require('../')({ indent : 2 }); - -var prev = { - yy : 6, - zz : 5, - a : [1,2,3], - fn : 'beep', - c : { x : 7, z : 3 } -}; - -var next = { - a : [ 1, 2, "z", /beep/, new Buffer(3) ], - fn : function qqq () {}, - b : [5,6,7], - c : { x : 8, y : 5 } -}; - -diff(prev, next).pipe(process.stdout); diff --git a/node_modules/tap/node_modules/difflet/example/comma_first.js b/node_modules/tap/node_modules/difflet/example/comma_first.js deleted file mode 100644 index 67ece2349..000000000 --- a/node_modules/tap/node_modules/difflet/example/comma_first.js +++ /dev/null @@ -1,12 +0,0 @@ -var diff = require('../')({ - indent : 2, - comma : 'first', -}); - -var prev = { yy : 6, zz : 5, a : [1,2,3] }; -var next = { - a : [ 1, 2, 3, [4], "z", /beep/, new Buffer(3) ], - fn : 8, - b : [5,6,7] -}; -diff(prev, next).pipe(process.stdout); diff --git a/node_modules/tap/node_modules/difflet/example/html.js b/node_modules/tap/node_modules/difflet/example/html.js deleted file mode 100644 index 9ff4a293c..000000000 --- a/node_modules/tap/node_modules/difflet/example/html.js +++ /dev/null @@ -1,34 +0,0 @@ -var difflet = require('../'); -var ent = require('ent'); - -var tags = { - inserted : '', - updated : '', - deleted : '', -}; -var diff = difflet({ - start : function (t, s) { - s.write(tags[t]); - }, - stop : function (t, s) { - s.write(''); - }, - write : function (buf) { - stream.write(ent.encode(buf)) - }, -}); - -var prev = { - yy : 6, - zz : 5, - a : [1,2,3], - fn : function qq () {} -}; -var next = { - a : [ 1, 2, 3, [4], "z", /beep/, new Buffer([0,1,2]) ], - fn : 'I <3 robots', - b : [5,6,7] -}; - -var stream = diff(prev, next); -stream.pipe(process.stdout, { end : false }); diff --git a/node_modules/tap/node_modules/difflet/example/string.js b/node_modules/tap/node_modules/difflet/example/string.js deleted file mode 100644 index 6cff6cb44..000000000 --- a/node_modules/tap/node_modules/difflet/example/string.js +++ /dev/null @@ -1,4 +0,0 @@ -var difflet = require('../'); - -var s = difflet.compare({ a : 2, c : 5 }, { a : 3, b : 4 }); -process.stdout.write(s); diff --git a/node_modules/tap/node_modules/difflet/fail.js b/node_modules/tap/node_modules/difflet/fail.js deleted file mode 100644 index 46eebd213..000000000 --- a/node_modules/tap/node_modules/difflet/fail.js +++ /dev/null @@ -1,9 +0,0 @@ -var test = require('tap').test; - -test('beep', function (t) { - t.deepEqual( - { x : 'abcdefghijklmnopqrstuvwxyz' }, - { x : 'abcdefghijzzznopqrstuvwxyz' } - ); - t.end(); -}); diff --git a/node_modules/tap/node_modules/difflet/index.js b/node_modules/tap/node_modules/difflet/index.js deleted file mode 100644 index b2ad0da6f..000000000 --- a/node_modules/tap/node_modules/difflet/index.js +++ /dev/null @@ -1,357 +0,0 @@ -var traverse = require('traverse'); -var Stream = require('stream').Stream; -var charm = require('charm'); -var deepEqual = require('deep-equal'); - -var exports = module.exports = function (opts_) { - var fn = difflet.bind(null, opts_); - fn.compare = function (prev, next) { - var opts = Object.keys(opts_ || {}).reduce(function (acc, key) { - acc[key] = opts_[key]; - return acc; - }, {}); - var s = opts.stream = new Stream; - var data = ''; - s.write = function (buf) { data += buf }; - s.end = function () {}; - s.readable = true; - s.writable = true; - - difflet(opts, prev, next); - return data; - }; - return fn; -}; - -exports.compare = function (prev, next) { - return exports({}).compare(prev, next); -}; - -function difflet (opts, prev, next) { - var stream = opts.stream || new Stream; - if (!opts.stream) { - stream.readable = true; - stream.writable = true; - stream.write = function (buf) { this.emit('data', buf) }; - stream.end = function () { this.emit('end') }; - } - - if (!opts) opts = {}; - if (opts.start === undefined && opts.stop === undefined) { - var c = charm(stream); - opts.start = function (type) { - c.foreground({ - inserted : 'green', - updated : 'blue', - deleted : 'red', - comment : 'cyan', - }[type]); - c.display('bright'); - }; - opts.stop = function (type) { - c.display('reset'); - }; - } - var write = function (buf) { - if (opts.write) opts.write(buf, stream) - else stream.write(buf) - }; - - var commaFirst = opts.comma === 'first'; - - var stringify = function (node, params) { - return stringifier.call(this, true, node, params || opts); - }; - var plainStringify = function (node, params) { - return stringifier.call(this, false, node, params || opts); - }; - - var levels = 0; - function set (type) { - if (levels === 0) opts.start(type, stream); - levels ++; - } - - function unset (type) { - if (--levels === 0) opts.stop(type, stream); - } - - function stringifier (insertable, node, opts) { - var indent = opts.indent; - - if (insertable) { - var prevNode = traverse.get(prev, this.path || []); - } - var inserted = insertable && prevNode === undefined; - - var indentx = indent && Array( - ((this.path || []).length + 1) * indent + 1 - ).join(' '); - if (commaFirst) indentx = indentx.slice(indent); - - if (Array.isArray(node)) { - var updated = (prevNode || traverse.has(prev, this.path)) - && !Array.isArray(prevNode); - if (updated) { - set('updated'); - } - - if (opts.comment && !Array.isArray(prevNode)) { - indent = 0; - } - - this.before(function () { - if (inserted) set('inserted'); - if (indent && commaFirst) { - if ((this.path || []).length === 0 - || Array.isArray(this.parent.node)) { - write('[ '); - } - else write('\n' + indentx + '[ '); - } - else if (indent) { - write('[\n' + indentx); - } - else { - write('['); - } - }); - - this.post(function (child) { - if (!child.isLast && !(indent && commaFirst)) { - write(','); - } - - var prev = prevNode && prevNode[child.key]; - if (indent && opts.comment && child.node !== prev - && (typeof child.node !== 'object' || typeof prev !== 'object') - ) { - set('comment'); - write(' // != '); - traverse(prev).forEach(function (x) { - plainStringify.call(this, x, { indent : 0 }); - }); - unset('comment'); - } - - if (!child.isLast) { - if (indent && commaFirst) { - write('\n' + indentx + ', '); - } - else if (indent) { - write('\n' + indentx); - } - } - }); - - this.after(function () { - if (indent && commaFirst) write('\n' + indentx); - else if (indent) write('\n' + indentx.slice(indent)); - - write(']'); - if (updated) unset('updated'); - if (inserted) unset('inserted'); - }); - } - else if (isRegExp(node)) { - this.block(); - - if (inserted) { - set('inserted'); - write(node.toString()); - unset('inserted'); - } - else if (insertable && prevNode !== node) { - set('updated'); - write(node.toString()); - unset('updated'); - } - else write(node.toString()); - } - else if (typeof node === 'object' - && node && typeof node.inspect === 'function') { - this.block(); - if (inserted) { - set('inserted'); - write(node.inspect()); - unset('inserted'); - } - else if (!(prevNode && typeof prevNode.inspect === 'function' - && prevNode.inspect() === node.inspect())) { - set('updated'); - write(node.inspect()); - unset('updated'); - } - else write(node.inspect()); - } - else if (typeof node == 'object') { - var insertedKey = false; - var deleted = insertable && typeof prevNode === 'object' - ? Object.keys(prevNode).filter(function (key) { - return !Object.hasOwnProperty.call(node, key); - }) - : [] - ; - - this.before(function () { - if (inserted) set('inserted'); - write(indent && commaFirst && !this.isRoot - ? '\n' + indentx + '{ ' - : '{' - ); - }); - - this.pre(function (x, key) { - if (insertable) { - var obj = traverse.get(prev, this.path.concat(key)); - if (obj === undefined) { - insertedKey = true; - set('inserted'); - } - } - - if (indent && !commaFirst) write('\n' + indentx); - - plainStringify(key); - write(indent ? ' : ' : ':'); - }); - - this.post(function (child) { - if (child.isLast && deleted.length) { - if (insertedKey) unset('inserted'); - insertedKey = false; - - if (indent && commaFirst) { - write('\n' + indentx + ', ') - } - else if (indent) write(',\n' + indentx) - else write(','); - } - else { - if (!child.isLast) { - if (indent && commaFirst) { - write('\n' + indentx + ', '); - } - else write(','); - } - if (insertedKey) unset('inserted'); - insertedKey = false; - } - - var prev = prevNode && prevNode[child.key]; - if (indent && opts.comment && child.node !== prev - && (typeof child.node !== 'object' || typeof prev !== 'object') - ) { - set('comment'); - write(' // != '); - traverse(prev).forEach(function (x) { - plainStringify.call(this, x, { indent : 0 }); - }); - unset('comment'); - } - - }); - - this.after(function () { - if (inserted) unset('inserted'); - - if (deleted.length) { - if (indent && !commaFirst - && Object.keys(node).length === 0) { - write('\n' + indentx); - } - - set('deleted'); - deleted.forEach(function (key, ix) { - if (indent && opts.comment) { - unset('deleted'); - set('comment'); - write('// '); - unset('comment'); - set('deleted'); - } - - plainStringify(key); - write(indent ? ' : ' : ':'); - traverse(prevNode[key]).forEach(function (x) { - plainStringify.call(this, x, { indent : 0 }); - }); - - var last = ix === deleted.length - 1; - if (insertable && !last) { - if (indent && commaFirst) { - write('\n' + indentx + ', '); - } - else if (indent) { - write(',\n' + indentx); - } - else write(','); - } - }); - unset('deleted'); - } - - if (commaFirst && indent) { - write(indentx.slice(indent) + ' }'); - } - else if (indent) { - write('\n' + indentx.slice(indent) + '}'); - } - else write('}'); - }); - } - else { - var changed = false; - - if (inserted) set('inserted'); - else if (insertable && !deepEqual(prevNode, node)) { - changed = true; - set('updated'); - } - - if (typeof node === 'string') { - write('"' + node.toString().replace(/"/g, '\\"') + '"'); - } - else if (isRegExp(node)) { - write(node.toString()); - } - else if (typeof node === 'function') { - write(node.name - ? '[Function: ' + node.name + ']' - : '[Function]' - ); - } - else if (node === undefined) { - write('undefined'); - } - else if (node === null) { - write('null'); - } - else { - write(node.toString()); - } - - if (inserted) unset('inserted'); - else if (changed) unset('updated'); - } - } - - if (opts.stream) { - traverse(next).forEach(stringify); - } - else process.nextTick(function () { - traverse(next).forEach(stringify); - stream.emit('end'); - }); - - return stream; -} - -function isRegExp (node) { - return node instanceof RegExp || (node - && typeof node.test === 'function' - && typeof node.exec === 'function' - && typeof node.compile === 'function' - && node.constructor && node.constructor.name === 'RegExp' - ); -} diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/README.markdown b/node_modules/tap/node_modules/difflet/node_modules/charm/README.markdown deleted file mode 100644 index a1474d69b..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/README.markdown +++ /dev/null @@ -1,199 +0,0 @@ -charm -===== - -Use -[ansi terminal characters](http://www.termsys.demon.co.uk/vtansi.htm) -to write colors and cursor positions. - -![me lucky charms](http://substack.net/images/charms.png) - -example -======= - -lucky ------ - -````javascript -var charm = require('charm')(process); -charm.reset(); - -var colors = [ 'red', 'cyan', 'yellow', 'green', 'blue' ]; -var text = 'Always after me lucky charms.'; - -var offset = 0; -var iv = setInterval(function () { - var y = 0, dy = 1; - for (var i = 0; i < 40; i++) { - var color = colors[(i + offset) % colors.length]; - var c = text[(i + offset) % text.length]; - charm - .move(1, dy) - .foreground(color) - .write(c) - ; - y += dy; - if (y <= 0 || y >= 5) dy *= -1; - } - charm.position(0, 1); - offset ++; -}, 150); - -charm.on('data', function (buf) { - if (buf[0] === 3) { - clearInterval(iv); - charm.destroy(); - } -}); -```` - -events -====== - -Charm objects pass along the data events from their input stream except for -events generated from querying the terminal device. - -Because charm puts stdin into raw mode, charm emits two special events: "^C" and -"^D" when the user types those combos. It's super convenient with these events -to do: - -````javascript -charm.on('^C', process.exit) -```` - -methods -======= - -var charm = require('charm')(param or stream, ...) --------------------------------------------------- - -Create a new `charm` given a `param` with `stdout` and `stdin` streams, such as -`process` or by passing the streams in themselves separately as parameters. - -Protip: you can pass in an http response object as an output stream and it will -just work™. - -charm.reset() -------------- - -Reset the entire screen, like the /usr/bin/reset command. - -charm.destroy() ---------------- - -Destroy the input stream. - -charm.write(msg) ----------------- - -Pass along `msg` to the output stream. - -charm.position(x, y) or charm.position(cb) ------------------------------------------- - -Set the cursor position to the absolute coordinates `x, y` or query the position -and get the response as `cb(x, y)`. - -charm.move(x, y) ----------------- - -Move the cursor position by the relative coordinates `x, y`. - -charm.up(y) ------------ - -Move the cursor up by `y` rows. - -charm.down(y) -------------- - -Move the cursor down by `y` rows. - -charm.left(x) -------------- - -Move the cursor left by `x` columns. - -charm.right(x) -------------- - -Move the cursor right by `x` columns. - -charm.push(withAttributes=false) --------------------------------- - -Push the cursor state and optionally the attribute state. - -charm.pop(withAttributes=false) -------------------------------- - -Pop the cursor state and optionally the attribute state. - -charm.erase(s) --------------- - -Erase a region defined by the string `s`. - -`s` can be: - -* end - erase from the cursor to the end of the line -* start - erase from the cursor to the start of the line -* line - erase the current line -* down - erase everything below the current line -* up - erase everything above the current line -* screen - erase the entire screen - -charm.display(attr) -------------------- - -Set the display mode with the string `attr`. - -`attr` can be: - -* reset -* bright -* dim -* underscore -* blink -* reverse -* hidden - -charm.foreground(color) ------------------------ - -Set the foreground color with the string `color`, which can be: - -* red -* yellow -* green -* blue -* cyan -* magenta -* black -* white - - -charm.background(color) ------------------------ - -Set the background color with the string `color`, which can be: - -* red -* yellow -* green -* blue -* cyan -* magenta -* black -* white - -charm.cursor(visible) ---------------------- - -Set the cursor visibility with a boolean `visible`. - -install -======= - -With [npm](http://npmjs.org) do: - - npm install charm diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/example/column.js b/node_modules/tap/node_modules/difflet/node_modules/charm/example/column.js deleted file mode 100644 index b54af9615..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/example/column.js +++ /dev/null @@ -1,10 +0,0 @@ -var charm = require('charm')(process); - -charm - .column(16) - .write('beep') - .down() - .column(32) - .write('boop\n') - .destroy() -; diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/example/cursor.js b/node_modules/tap/node_modules/difflet/node_modules/charm/example/cursor.js deleted file mode 100644 index 959868ce4..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/example/cursor.js +++ /dev/null @@ -1,22 +0,0 @@ -var charm = require('charm')(process); - -charm.position(5, 10); - -charm.position(function (x, y) { - console.dir([ x, y ]); - - charm.move(7,2); - charm.push(); - process.stdout.write('lul'); - - charm.left(3).up(1).foreground('magenta'); - process.stdout.write('v'); - charm.left(1).up(1).display('reset'); - process.stdout.write('|'); - - charm.down(3); - charm.pop().background('blue'); - process.stdout.write('popped\npow'); - charm.display('reset').erase('line'); - charm.destroy(); -}); diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/example/http_spin.js b/node_modules/tap/node_modules/difflet/node_modules/charm/example/http_spin.js deleted file mode 100644 index 1db87f441..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/example/http_spin.js +++ /dev/null @@ -1,35 +0,0 @@ -var http = require('http'); -var charmer = require('charm'); - -http.createServer(function (req, res) { - res.setHeader('content-type', 'text/ansi'); - - var charm = charmer(res); - charm.reset(); - - var radius = 10; - var theta = 0; - var points = []; - - var iv = setInterval(function () { - var x = 2 + (radius + Math.cos(theta) * radius) * 2; - var y = 2 + radius + Math.sin(theta) * radius; - - points.unshift([ x, y ]); - var colors = [ 'red', 'yellow', 'green', 'cyan', 'blue', 'magenta' ]; - - points.forEach(function (p, i) { - charm.position(p[0], p[1]); - var c = colors[Math.floor(i / 12)]; - charm.background(c).write(' ') - }); - points = points.slice(0, 12 * colors.length - 1); - - theta += Math.PI / 40; - }, 50); - - req.connection.on('end', function () { - clearInterval(iv); - charm.destroy(); - }); -}).listen(8081); diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/example/lucky.js b/node_modules/tap/node_modules/difflet/node_modules/charm/example/lucky.js deleted file mode 100644 index b391b6ff1..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/example/lucky.js +++ /dev/null @@ -1,30 +0,0 @@ -var charm = require('charm')(process); -charm.reset(); - -var colors = [ 'red', 'cyan', 'yellow', 'green', 'blue' ]; -var text = 'Always after me lucky charms.'; - -var offset = 0; -var iv = setInterval(function () { - var y = 0, dy = 1; - for (var i = 0; i < 40; i++) { - var color = colors[(i + offset) % colors.length]; - var c = text[(i + offset) % text.length]; - charm - .move(1, dy) - .foreground(color) - .write(c) - ; - y += dy; - if (y <= 0 || y >= 5) dy *= -1; - } - charm.position(0, 1); - offset ++; -}, 150); - -charm.on('data', function (buf) { - if (buf[0] === 3) { - clearInterval(iv); - charm.destroy(); - } -}); diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/example/position.js b/node_modules/tap/node_modules/difflet/node_modules/charm/example/position.js deleted file mode 100644 index 2c5ae9b7b..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/example/position.js +++ /dev/null @@ -1,7 +0,0 @@ -var charm = require('charm')(process); - -charm.on('^C', process.exit); - -charm.position(function (x, y) { - console.log('(%d, %d)', x, y); -}); diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/example/progress.js b/node_modules/tap/node_modules/difflet/node_modules/charm/example/progress.js deleted file mode 100644 index 9f53dc5d7..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/example/progress.js +++ /dev/null @@ -1,16 +0,0 @@ -var charm = require('charm')(process); - -charm.write("Progress: 0 %"); -var i = 0; - -var increment = function () { - charm.left(i.toString().length + 2); - i = i + 1; - charm.write(i + " %"); - if (i === 100) { - charm.write("\nDone!\n"); - process.exit(); - } -}; - -var loop = setInterval(increment, 50); diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/example/spin.js b/node_modules/tap/node_modules/difflet/node_modules/charm/example/spin.js deleted file mode 100644 index 0ba8a6ed1..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/example/spin.js +++ /dev/null @@ -1,23 +0,0 @@ -var charm = require('charm')(process); -charm.reset(); - -var radius = 10; -var theta = 0; -var points = []; - -var iv = setInterval(function () { - var x = 2 + (radius + Math.cos(theta) * radius) * 2; - var y = 2 + radius + Math.sin(theta) * radius; - - points.unshift([ x, y ]); - var colors = [ 'red', 'yellow', 'green', 'cyan', 'blue', 'magenta' ]; - - points.forEach(function (p, i) { - charm.position(p[0], p[1]); - var c = colors[Math.floor(i / 12)]; - charm.background(c).write(' ') - }); - points = points.slice(0, 12 * colors.length - 1); - - theta += Math.PI / 40; -}, 50); diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/index.js b/node_modules/tap/node_modules/difflet/node_modules/charm/index.js deleted file mode 100644 index b11e9dd88..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/index.js +++ /dev/null @@ -1,267 +0,0 @@ -var tty = require('tty'); -var encode = require('./lib/encode'); -var EventEmitter = require('events').EventEmitter; - -var exports = module.exports = function () { - var input = null; - function setInput (s) { - if (input) throw new Error('multiple inputs specified') - else input = s - } - - var output = null; - function setOutput (s) { - if (output) throw new Error('multiple outputs specified') - else output = s - } - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) continue; - if (arg.readable) setInput(arg) - else if (arg.stdin || arg.input) setInput(arg.stdin || arg.input) - - if (arg.writable) setOutput(arg) - else if (arg.stdout || arg.output) setOutput(arg.stdout || arg.output) - - } - - return new Charm(input, output); -}; - -var Charm = exports.Charm = function (input, output) { - var self = this; - self.input = input; - self.output = output; - self.pending = []; - - if (!output) { - self.emit('error', new Error('output stream required')); - } - - if (input && typeof input.fd === 'number' && tty.isatty(input.fd)) { - tty.setRawMode(true); - input.resume(); - } - - if (input) { - input.on('data', function (buf) { - if (self.pending.length) { - var codes = extractCodes(buf); - var matched = false; - - for (var i = 0; i < codes.length; i++) { - for (var j = 0; j < self.pending.length; j++) { - var cb = self.pending[j]; - if (cb(codes[i])) { - matched = true; - self.pending.splice(j, 1); - break; - } - } - } - - if (matched) return; - } - - self.emit('data', buf) - - if (buf.length === 1) { - if (buf[0] === 3) self.emit('^C'); - if (buf[0] === 4) self.emit('^D'); - } - }); - } -} - -Charm.prototype = new EventEmitter; - -Charm.prototype.destroy = function () { - if (this.input) this.input.destroy() -}; - -Charm.prototype.write = function (msg) { - this.output.write(msg); - return this; -}; - -Charm.prototype.reset = function (cb) { - this.write(encode('c')); - return this; -}; - -Charm.prototype.position = function (x, y) { - // get/set absolute coordinates - if (typeof x === 'function') { - var cb = x; - this.pending.push(function (buf) { - if (buf[0] === 27 && buf[1] === encode.ord('[') - && buf[buf.length-1] === encode.ord('R')) { - var pos = buf.toString() - .slice(2,-1) - .split(';') - .map(Number) - ; - cb(pos[1], pos[0]); - return true; - } - }); - this.write(encode('[6n')); - } - else { - this.write(encode( - '[' + Math.floor(y) + ';' + Math.floor(x) + 'f' - )); - } - return this; -}; - -Charm.prototype.move = function (x, y) { - // set relative coordinates - var bufs = []; - - if (y < 0) this.up(-y) - else if (y > 0) this.down(y) - - if (x > 0) this.right(x) - else if (x < 0) this.left(-x) - - return this; -}; - -Charm.prototype.up = function (y) { - if (y === undefined) y = 1; - this.write(encode('[' + Math.floor(y) + 'A')); - return this; -}; - -Charm.prototype.down = function (y) { - if (y === undefined) y = 1; - this.write(encode('[' + Math.floor(y) + 'B')); - return this; -}; - -Charm.prototype.right = function (x) { - if (x === undefined) x = 1; - this.write(encode('[' + Math.floor(x) + 'C')); - return this; -}; - -Charm.prototype.left = function (x) { - if (x === undefined) x = 1; - this.write(encode('[' + Math.floor(x) + 'D')); - return this; -}; - -Charm.prototype.column = function (x) { - this.write(encode('[' + Math.floor(x) + 'G')); - return this; -}; - -Charm.prototype.push = function (withAttributes) { - this.write(encode(withAttributes ? '7' : '[s')); - return this; -}; - -Charm.prototype.pop = function (withAttributes) { - this.write(encode(withAttributes ? '8' : '[u')); - return this; -}; - -Charm.prototype.erase = function (s) { - if (s === 'end' || s === '$') { - this.write(encode('[K')); - } - else if (s === 'start' || s === '^') { - this.write(encode('[1K')); - } - else if (s === 'line') { - this.write(encode('[2K')); - } - else if (s === 'down') { - this.write(encode('[J')); - } - else if (s === 'up') { - this.write(encode('[1J')); - } - else if (s === 'screen') { - this.write(encode('[1J')); - } - else { - this.emit('error', new Error('Unknown erase type: ' + s)); - } - return this; -}; - -Charm.prototype.display = function (attr) { - var c = { - reset : 0, - bright : 1, - dim : 2, - underscore : 4, - blink : 5, - reverse : 7, - hidden : 8 - }[attr]; - if (c === undefined) { - this.emit('error', new Error('Unknown attribute: ' + attr)); - } - this.write(encode('[' + c + 'm')); - return this; -}; - -Charm.prototype.foreground = function (color) { - var c = { - black : 30, - red : 31, - green : 32, - yellow : 33, - blue : 34, - magenta : 35, - cyan : 36, - white : 37 - }[color.toLowerCase()]; - if (!c) this.emit('error', new Error('Unknown color: ' + color)); - - this.write(encode('[' + c + 'm')); - return this; -}; - -Charm.prototype.background = function (color) { - var c = { - black : 40, - red : 41, - green : 42, - yellow : 43, - blue : 44, - magenta : 45, - cyan : 46, - white : 47 - }[color.toLowerCase()]; - if (!c) this.emit('error', new Error('Unknown color: ' + color)); - - this.write(encode('[' + c + 'm')); - return this; -}; - -Charm.prototype.cursor = function (visible) { - this.write(encode(visible ? '[?25h' : '[?25l')); - return this; -}; - -var extractCodes = exports.extractCodes = function (buf) { - var codes = []; - var start = -1; - - for (var i = 0; i < buf.length; i++) { - if (buf[i] === 27) { - if (start >= 0) codes.push(buf.slice(start, i)); - start = i; - } - else if (start >= 0 && i === buf.length - 1) { - codes.push(buf.slice(start)); - } - } - - return codes; -} diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/lib/encode.js b/node_modules/tap/node_modules/difflet/node_modules/charm/lib/encode.js deleted file mode 100644 index 3b6417a4e..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/lib/encode.js +++ /dev/null @@ -1,18 +0,0 @@ -var encode = module.exports = function (xs) { - function bytes (s) { - if (typeof s === 'string') { - return s.split('').map(ord); - } - else if (Array.isArray(s)) { - return s.reduce(function (acc, c) { - return acc.concat(bytes(c)); - }, []); - } - } - - return new Buffer([ 0x1b ].concat(bytes(xs))); -}; - -var ord = encode.ord = function ord (c) { - return c.charCodeAt(0) -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/charm/package.json b/node_modules/tap/node_modules/difflet/node_modules/charm/package.json deleted file mode 100644 index 5419cbbfe..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/charm/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name" : "charm", - "version" : "0.0.6", - "description" : "ansi control sequences for terminal cursor hopping and colors", - "main" : "index.js", - "directories" : { - "lib" : ".", - "example" : "example", - "test" : "test" - }, - "repository" : { - "type" : "git", - "url" : "https://github.com/substack/node-charm.git" - }, - "keywords" : [ - "terminal", - "ansi", - "cursor", - "color", - "console", - "control", - "escape", - "sequence" - ], - "author" : { - "name" : "James Halliday", - "email" : "mail@substack.net", - "url" : "http://substack.net" - }, - "license" : "MIT/X11", - "engine" : { "node" : ">=0.4" } -} diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/.npmignore b/node_modules/tap/node_modules/difflet/node_modules/traverse/.npmignore deleted file mode 100644 index 3c3629e64..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/LICENSE b/node_modules/tap/node_modules/difflet/node_modules/traverse/LICENSE deleted file mode 100644 index 7b75500c5..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright 2010 James Halliday (mail@substack.net) - -This project is free software released under the MIT/X11 license: -http://www.opensource.org/licenses/mit-license.php - -Copyright 2010 James Halliday (mail@substack.net) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/README.markdown b/node_modules/tap/node_modules/difflet/node_modules/traverse/README.markdown deleted file mode 100644 index 75a0ec1bb..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/README.markdown +++ /dev/null @@ -1,256 +0,0 @@ -traverse -======== - -Traverse and transform objects by visiting every node on a recursive walk. - -examples -======== - -transform negative numbers in-place ------------------------------------ - -negative.js - -````javascript -var traverse = require('traverse'); -var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -traverse(obj).forEach(function (x) { - if (x < 0) this.update(x + 128); -}); - -console.dir(obj); -```` - -Output: - - [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ] - -collect leaf nodes ------------------- - -leaves.js - -````javascript -var traverse = require('traverse'); - -var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 }, -}; - -var leaves = traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; -}, []); - -console.dir(leaves); -```` - -Output: - - [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -scrub circular references -------------------------- - -scrub.js: - -````javascript -var traverse = require('traverse'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); -```` - -output: - - { a: 1, b: 2, c: [ 3, 4 ] } - -methods -======= - -Each method that takes an `fn` uses the context documented below in the context -section. - -.map(fn) --------- - -Execute `fn` for each node in the object and return a new object with the -results of the walk. To update nodes in the result use `this.update(value)`. - -.forEach(fn) ------------- - -Execute `fn` for each node in the object but unlike `.map()`, when -`this.update()` is called it updates the object in-place. - -.reduce(fn, acc) ----------------- - -For each node in the object, perform a -[left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function)) -with the return value of `fn(acc, node)`. - -If `acc` isn't specified, `acc` is set to the root object for the first step -and the root element is skipped. - -.paths() --------- - -Return an `Array` of every possible non-cyclic path in the object. -Paths are `Array`s of string keys. - -.nodes() --------- - -Return an `Array` of every node in the object. - -.clone() --------- - -Create a deep clone of the object. - -.get(path) ----------- - -Get the element at the array `path`. - -.set(path, value) ------------------ - -Set the element at the array `path` to `value`. - -.has(path) ----------- - -Return whether the element at the array `path` exists. - -context -======= - -Each method that takes a callback has a context (its `this` object) with these -attributes: - -this.node ---------- - -The present node on the recursive walk - -this.path ---------- - -An array of string keys from the root to the present node - -this.parent ------------ - -The context of the node's parent. -This is `undefined` for the root node. - -this.key --------- - -The name of the key of the present node in its parent. -This is `undefined` for the root node. - -this.isRoot, this.notRoot -------------------------- - -Whether the present node is the root node - -this.isLeaf, this.notLeaf -------------------------- - -Whether or not the present node is a leaf node (has no children) - -this.level ----------- - -Depth of the node within the traversal - -this.circular -------------- - -If the node equals one of its parents, the `circular` attribute is set to the -context of that parent and the traversal progresses no deeper. - -this.update(value, stopHere=false) ----------------------------------- - -Set a new value for the present node. - -All the elements in `value` will be recursively traversed unless `stopHere` is -true. - -this.remove(stopHere=false) -------------- - -Remove the current element from the output. If the node is in an Array it will -be spliced off. Otherwise it will be deleted from its parent. - -this.delete(stopHere=false) -------------- - -Delete the current element from its parent in the output. Calls `delete` even on -Arrays. - -this.before(fn) ---------------- - -Call this function before any of the children are traversed. - -You can assign into `this.keys` here to traverse in a custom order. - -this.after(fn) --------------- - -Call this function after any of the children are traversed. - -this.pre(fn) ------------- - -Call this function before each of the children are traversed. - -this.post(fn) -------------- - -Call this function after each of the children are traversed. - - -install -======= - -Using [npm](http://npmjs.org) do: - - $ npm install traverse - -test -==== - -Using [expresso](https://github.com/visionmedia/expresso) do: - - $ expresso - - 100% wahoo, your stuff is not broken! - -in the browser -============== - -Use [browserify](https://github.com/substack/node-browserify) to run traverse in -the browser. - -traverse has been tested and works with: - -* Internet Explorer 5.5, 6.0, 7.0, 8.0, 9.0 -* Firefox 3.5 -* Chrome 6.0 -* Opera 10.6 -* Safari 5.0 diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/json.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/json.js deleted file mode 100755 index 50d612e3a..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/json.js +++ /dev/null @@ -1,16 +0,0 @@ -var traverse = require('traverse'); - -var id = 54; -var callbacks = {}; -var obj = { moo : function () {}, foo : [2,3,4, function () {}] }; - -var scrubbed = traverse(obj).map(function (x) { - if (typeof x === 'function') { - callbacks[id] = { id : id, f : x, path : this.path }; - this.update('[Function]'); - id++; - } -}); - -console.dir(scrubbed); -console.dir(callbacks); diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/leaves.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/leaves.js deleted file mode 100755 index c1b310b95..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/leaves.js +++ /dev/null @@ -1,15 +0,0 @@ -var traverse = require('traverse'); - -var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 }, -}; - -var leaves = traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; -}, []); - -console.dir(leaves); diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/negative.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/negative.js deleted file mode 100755 index 78608a059..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/negative.js +++ /dev/null @@ -1,8 +0,0 @@ -var traverse = require('traverse'); -var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -traverse(obj).forEach(function (x) { - if (x < 0) this.update(x + 128); -}); - -console.dir(obj); diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/scrub.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/scrub.js deleted file mode 100755 index 5d15b9161..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/scrub.js +++ /dev/null @@ -1,10 +0,0 @@ -// scrub out circular references -var traverse = require('traverse'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/stringify.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/stringify.js deleted file mode 100755 index 167b68b23..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/examples/stringify.js +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env node -var traverse = require('traverse'); - -var obj = [ 'five', 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -var s = ''; -traverse(obj).forEach(function to_s (node) { - if (Array.isArray(node)) { - this.before(function () { s += '[' }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += ']' }); - } - else if (typeof node == 'object') { - this.before(function () { s += '{' }); - this.pre(function (x, key) { - to_s(key); - s += ':'; - }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += '}' }); - } - else if (typeof node == 'string') { - s += '"' + node.toString().replace(/"/g, '\\"') + '"'; - } - else if (typeof node == 'function') { - s += 'null'; - } - else { - s += node.toString(); - } -}); - -console.log('JSON.stringify: ' + JSON.stringify(obj)); -console.log('this stringify: ' + s); diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/index.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/index.js deleted file mode 100644 index f3076a7c3..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/index.js +++ /dev/null @@ -1,279 +0,0 @@ -module.exports = Traverse; -function Traverse (obj) { - if (!(this instanceof Traverse)) return new Traverse(obj); - this.value = obj; -} - -Traverse.prototype.get = function (ps) { - var node = this.value; - for (var i = 0; i < ps.length; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) { - node = undefined; - break; - } - node = node[key]; - } - return node; -}; - -Traverse.prototype.has = function (ps) { - var node = this.value; - for (var i = 0; i < ps.length; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) { - return false; - } - node = node[key]; - } - return true; -}; - -Traverse.prototype.set = function (ps, value) { - var node = this.value; - for (var i = 0; i < ps.length - 1; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) node[key] = {}; - node = node[key]; - } - node[ps[i]] = value; - return value; -}; - -Traverse.prototype.map = function (cb) { - return walk(this.value, cb, true); -}; - -Traverse.prototype.forEach = function (cb) { - this.value = walk(this.value, cb, false); - return this.value; -}; - -Traverse.prototype.reduce = function (cb, init) { - var skip = arguments.length === 1; - var acc = skip ? this.value : init; - this.forEach(function (x) { - if (!this.isRoot || !skip) { - acc = cb.call(this, acc, x); - } - }); - return acc; -}; - -Traverse.prototype.paths = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.path); - }); - return acc; -}; - -Traverse.prototype.nodes = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.node); - }); - return acc; -}; - -Traverse.prototype.clone = function () { - var parents = [], nodes = []; - - return (function clone (src) { - for (var i = 0; i < parents.length; i++) { - if (parents[i] === src) { - return nodes[i]; - } - } - - if (typeof src === 'object' && src !== null) { - var dst = copy(src); - - parents.push(src); - nodes.push(dst); - - forEach(Object_keys(src), function (key) { - dst[key] = clone(src[key]); - }); - - parents.pop(); - nodes.pop(); - return dst; - } - else { - return src; - } - })(this.value); -}; - -function walk (root, cb, immutable) { - var path = []; - var parents = []; - var alive = true; - - return (function walker (node_) { - var node = immutable ? copy(node_) : node_; - var modifiers = {}; - - var keepGoing = true; - - var state = { - node : node, - node_ : node_, - path : [].concat(path), - parent : parents[parents.length - 1], - parents : parents, - key : path.slice(-1)[0], - isRoot : path.length === 0, - level : path.length, - circular : null, - update : function (x, stopHere) { - if (!state.isRoot) { - state.parent.node[state.key] = x; - } - state.node = x; - if (stopHere) keepGoing = false; - }, - 'delete' : function (stopHere) { - delete state.parent.node[state.key]; - if (stopHere) keepGoing = false; - }, - remove : function (stopHere) { - if (Array_isArray(state.parent.node)) { - state.parent.node.splice(state.key, 1); - } - else { - delete state.parent.node[state.key]; - } - if (stopHere) keepGoing = false; - }, - keys : null, - before : function (f) { modifiers.before = f }, - after : function (f) { modifiers.after = f }, - pre : function (f) { modifiers.pre = f }, - post : function (f) { modifiers.post = f }, - stop : function () { alive = false }, - block : function () { keepGoing = false } - }; - - if (!alive) return state; - - if (typeof node === 'object' && node !== null) { - state.keys = Object_keys(node); - - state.isLeaf = state.keys.length == 0; - - for (var i = 0; i < parents.length; i++) { - if (parents[i].node_ === node_) { - state.circular = parents[i]; - break; - } - } - } - else { - state.isLeaf = true; - } - - state.notLeaf = !state.isLeaf; - state.notRoot = !state.isRoot; - - // use return values to update if defined - var ret = cb.call(state, state.node); - if (ret !== undefined && state.update) state.update(ret); - - if (modifiers.before) modifiers.before.call(state, state.node); - - if (!keepGoing) return state; - - if (typeof state.node == 'object' - && state.node !== null && !state.circular) { - parents.push(state); - - forEach(state.keys, function (key, i) { - path.push(key); - - if (modifiers.pre) modifiers.pre.call(state, state.node[key], key); - - var child = walker(state.node[key]); - if (immutable && Object.hasOwnProperty.call(state.node, key)) { - state.node[key] = child.node; - } - - child.isLast = i == state.keys.length - 1; - child.isFirst = i == 0; - - if (modifiers.post) modifiers.post.call(state, child); - - path.pop(); - }); - parents.pop(); - } - - if (modifiers.after) modifiers.after.call(state, state.node); - - return state; - })(root).node; -} - -function copy (src) { - if (typeof src === 'object' && src !== null) { - var dst; - - if (Array_isArray(src)) { - dst = []; - } - else if (src instanceof Date) { - dst = new Date(src); - } - else if (src instanceof Boolean) { - dst = new Boolean(src); - } - else if (src instanceof Number) { - dst = new Number(src); - } - else if (src instanceof String) { - dst = new String(src); - } - else if (Object.create && Object.getPrototypeOf) { - dst = Object.create(Object.getPrototypeOf(src)); - } - else if (src.__proto__ || src.constructor.prototype) { - var proto = src.__proto__ || src.constructor.prototype || {}; - var T = function () {}; - T.prototype = proto; - dst = new T; - if (!dst.__proto__) dst.__proto__ = proto; - } - - forEach(Object_keys(src), function (key) { - dst[key] = src[key]; - }); - return dst; - } - else return src; -} - -var Object_keys = Object.keys || function keys (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -forEach(Object_keys(Traverse.prototype), function (key) { - Traverse[key] = function (obj) { - var args = [].slice.call(arguments, 1); - var t = Traverse(obj); - return t[key].apply(t, args); - }; -}); diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/package.json b/node_modules/tap/node_modules/difflet/node_modules/traverse/package.json deleted file mode 100644 index 80dabdb5b..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name" : "traverse", - "version" : "0.6.0", - "description" : "Traverse and transform objects by visiting every node on a recursive walk", - "author" : "James Halliday", - "license" : "MIT/X11", - "main" : "./index", - "repository" : { - "type" : "git", - "url" : "https://github.com/substack/js-traverse.git" - }, - "devDependencies" : { - "expresso" : "0.7.x" - }, - "scripts" : { - "test" : "expresso" - } -} diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/circular.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/circular.js deleted file mode 100644 index 916260113..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/circular.js +++ /dev/null @@ -1,115 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); -var util = require('util'); - -exports.circular = function () { - var obj = { x : 3 }; - obj.y = obj; - var foundY = false; - Traverse(obj).forEach(function (x) { - if (this.path.join('') == 'y') { - assert.equal( - util.inspect(this.circular.node), - util.inspect(obj) - ); - foundY = true; - } - }); - assert.ok(foundY); -}; - -exports.deepCirc = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - - var times = 0; - Traverse(obj).forEach(function (x) { - if (this.circular) { - assert.deepEqual(this.circular.path, []); - assert.deepEqual(this.path, [ 'y', 2 ]); - times ++; - } - }); - - assert.deepEqual(times, 1); -}; - -exports.doubleCirc = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var circs = []; - Traverse(obj).forEach(function (x) { - if (this.circular) { - circs.push({ circ : this.circular, self : this, node : x }); - } - }); - - assert.deepEqual(circs[0].self.path, [ 'x', 3, 2 ]); - assert.deepEqual(circs[0].circ.path, []); - - assert.deepEqual(circs[1].self.path, [ 'y', 2 ]); - assert.deepEqual(circs[1].circ.path, []); - - assert.deepEqual(circs.length, 2); -}; - -exports.circDubForEach = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - Traverse(obj).forEach(function (x) { - if (this.circular) this.update('...'); - }); - - assert.deepEqual(obj, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] }); -}; - -exports.circDubMap = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var c = Traverse(obj).map(function (x) { - if (this.circular) { - this.update('...'); - } - }); - - assert.deepEqual(c, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] }); -}; - -exports.circClone = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var clone = Traverse.clone(obj); - assert.ok(obj !== clone); - - assert.ok(clone.y[2] === clone); - assert.ok(clone.y[2] !== obj); - assert.ok(clone.x[3][2] === clone); - assert.ok(clone.x[3][2] !== obj); - assert.deepEqual(clone.x.slice(0,3), [1,2,3]); - assert.deepEqual(clone.y.slice(0,2), [4,5]); -}; - -exports.circMapScrub = function () { - var obj = { a : 1, b : 2 }; - obj.c = obj; - - var scrubbed = Traverse(obj).map(function (node) { - if (this.circular) this.remove(); - }); - assert.deepEqual( - Object.keys(scrubbed).sort(), - [ 'a', 'b' ] - ); - assert.ok(deepEqual(scrubbed, { a : 1, b : 2 })); - - assert.equal(obj.c, obj); -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/date.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/date.js deleted file mode 100644 index 4ca06dc38..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/date.js +++ /dev/null @@ -1,35 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports.dateEach = function () { - var obj = { x : new Date, y : 10, z : 5 }; - - var counts = {}; - - Traverse(obj).forEach(function (node) { - var t = (node instanceof Date && 'Date') || typeof node; - counts[t] = (counts[t] || 0) + 1; - }); - - assert.deepEqual(counts, { - object : 1, - Date : 1, - number : 2, - }); -}; - -exports.dateMap = function () { - var obj = { x : new Date, y : 10, z : 5 }; - - var res = Traverse(obj).map(function (node) { - if (typeof node === 'number') this.update(node + 100); - }); - - assert.ok(obj.x !== res.x); - assert.deepEqual(res, { - x : obj.x, - y : 110, - z : 105, - }); -}; - diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/equal.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/equal.js deleted file mode 100644 index decc75503..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/equal.js +++ /dev/null @@ -1,220 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -exports.deepDates = function () { - assert.ok( - deepEqual( - { d : new Date, x : [ 1, 2, 3 ] }, - { d : new Date, x : [ 1, 2, 3 ] } - ), - 'dates should be equal' - ); - - var d0 = new Date; - setTimeout(function () { - assert.ok( - !deepEqual( - { d : d0, x : [ 1, 2, 3 ], }, - { d : new Date, x : [ 1, 2, 3 ] } - ), - 'microseconds should count in date equality' - ); - }, 5); -}; - -exports.deepCircular = function () { - var a = [1]; - a.push(a); // a = [ 1, *a ] - - var b = [1]; - b.push(a); // b = [ 1, [ 1, *a ] ] - - assert.ok( - !deepEqual(a, b), - 'circular ref mount points count towards equality' - ); - - var c = [1]; - c.push(c); // c = [ 1, *c ] - assert.ok( - deepEqual(a, c), - 'circular refs are structurally the same here' - ); - - var d = [1]; - d.push(a); // c = [ 1, [ 1, *d ] ] - assert.ok( - deepEqual(b, d), - 'non-root circular ref structural comparison' - ); -}; - -exports.deepInstances = function () { - assert.ok( - !deepEqual([ new Boolean(false) ], [ false ]), - 'boolean instances are not real booleans' - ); - - assert.ok( - !deepEqual([ new String('x') ], [ 'x' ]), - 'string instances are not real strings' - ); - - assert.ok( - !deepEqual([ new Number(4) ], [ 4 ]), - 'number instances are not real numbers' - ); - - assert.ok( - deepEqual([ new RegExp('x') ], [ /x/ ]), - 'regexp instances are real regexps' - ); - - assert.ok( - !deepEqual([ new RegExp(/./) ], [ /../ ]), - 'these regexps aren\'t the same' - ); - - assert.ok( - !deepEqual( - [ function (x) { return x * 2 } ], - [ function (x) { return x * 2 } ] - ), - 'functions with the same .toString() aren\'t necessarily the same' - ); - - var f = function (x) { return x * 2 }; - assert.ok( - deepEqual([ f ], [ f ]), - 'these functions are actually equal' - ); -}; - -exports.deepEqual = function () { - assert.ok( - !deepEqual([ 1, 2, 3 ], { 0 : 1, 1 : 2, 2 : 3 }), - 'arrays are not objects' - ); -}; - -exports.falsy = function () { - assert.ok( - !deepEqual([ undefined ], [ null ]), - 'null is not undefined!' - ); - - assert.ok( - !deepEqual([ null ], [ undefined ]), - 'undefined is not null!' - ); - - assert.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'undefined is not null, however deeply!' - ); - - assert.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'null is not undefined, however deeply!' - ); - - assert.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'null is not undefined, however deeply!' - ); -}; - -exports.deletedArrayEqual = function () { - var xs = [ 1, 2, 3, 4 ]; - delete xs[2]; - - var ys = Object.create(Array.prototype); - ys[0] = 1; - ys[1] = 2; - ys[3] = 4; - - assert.ok( - deepEqual(xs, ys), - 'arrays with deleted elements are only equal to' - + ' arrays with similarly deleted elements' - ); - - assert.ok( - !deepEqual(xs, [ 1, 2, undefined, 4 ]), - 'deleted array elements cannot be undefined' - ); - - assert.ok( - !deepEqual(xs, [ 1, 2, null, 4 ]), - 'deleted array elements cannot be null' - ); -}; - -exports.deletedObjectEqual = function () { - var obj = { a : 1, b : 2, c : 3 }; - delete obj.c; - - assert.ok( - deepEqual(obj, { a : 1, b : 2 }), - 'deleted object elements should not show up' - ); - - assert.ok( - !deepEqual(obj, { a : 1, b : 2, c : undefined }), - 'deleted object elements are not undefined' - ); - - assert.ok( - !deepEqual(obj, { a : 1, b : 2, c : null }), - 'deleted object elements are not null' - ); -}; - -exports.emptyKeyEqual = function () { - assert.ok(!deepEqual( - { a : 1 }, { a : 1, '' : 55 } - )); -}; - -exports.deepArguments = function () { - assert.ok( - !deepEqual( - [ 4, 5, 6 ], - (function () { return arguments })(4, 5, 6) - ), - 'arguments are not arrays' - ); - - assert.ok( - deepEqual( - (function () { return arguments })(4, 5, 6), - (function () { return arguments })(4, 5, 6) - ), - 'arguments should equal' - ); -}; - -exports.deepUn = function () { - assert.ok(!deepEqual({ a : 1, b : 2 }, undefined)); - assert.ok(!deepEqual({ a : 1, b : 2 }, {})); - assert.ok(!deepEqual(undefined, { a : 1, b : 2 })); - assert.ok(!deepEqual({}, { a : 1, b : 2 })); - assert.ok(deepEqual(undefined, undefined)); - assert.ok(deepEqual(null, null)); - assert.ok(!deepEqual(undefined, null)); -}; - -exports.deepLevels = function () { - var xs = [ 1, 2, [ 3, 4, [ 5, 6 ] ] ]; - assert.ok(!deepEqual(xs, [])); -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/has.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/has.js deleted file mode 100644 index af0c83cde..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/has.js +++ /dev/null @@ -1,13 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); - -exports.has = function () { - var obj = { a : 2, b : [ 4, 5, { c : 6 } ] }; - - assert.equal(traverse(obj).has([ 'b', 2, 'c' ]), true) - assert.equal(traverse(obj).has([ 'b', 2, 'c', 0 ]), false) - assert.equal(traverse(obj).has([ 'b', 2, 'd' ]), false) - assert.equal(traverse(obj).has([]), true) - assert.equal(traverse(obj).has([ 'a' ]), true) - assert.equal(traverse(obj).has([ 'a', 2 ]), false) -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/instance.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/instance.js deleted file mode 100644 index 8d7352567..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/instance.js +++ /dev/null @@ -1,17 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); -var EventEmitter = require('events').EventEmitter; - -exports['check instanceof on node elems'] = function () { - - var counts = { emitter : 0 }; - - Traverse([ new EventEmitter, 3, 4, { ev : new EventEmitter }]) - .forEach(function (node) { - if (node instanceof EventEmitter) counts.emitter ++; - }) - ; - - assert.equal(counts.emitter, 2); -}; - diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/interface.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/interface.js deleted file mode 100644 index fce5bf9a9..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/interface.js +++ /dev/null @@ -1,42 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['interface map'] = function () { - var obj = { a : [ 5,6,7 ], b : { c : [8] } }; - - assert.deepEqual( - Traverse.paths(obj) - .sort() - .map(function (path) { return path.join('/') }) - .slice(1) - .join(' ') - , - 'a a/0 a/1 a/2 b b/c b/c/0' - ); - - assert.deepEqual( - Traverse.nodes(obj), - [ - { a: [ 5, 6, 7 ], b: { c: [ 8 ] } }, - [ 5, 6, 7 ], 5, 6, 7, - { c: [ 8 ] }, [ 8 ], 8 - ] - ); - - assert.deepEqual( - Traverse.map(obj, function (node) { - if (typeof node == 'number') { - return node + 1000; - } - else if (Array.isArray(node)) { - return node.join(' '); - } - }), - { a: '5 6 7', b: { c: '8' } } - ); - - var nodes = 0; - Traverse.forEach(obj, function (node) { nodes ++ }); - assert.deepEqual(nodes, 8); -}; - diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/json.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/json.js deleted file mode 100644 index 0a045293f..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/json.js +++ /dev/null @@ -1,47 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['json test'] = function () { - var id = 54; - var callbacks = {}; - var obj = { moo : function () {}, foo : [2,3,4, function () {}] }; - - var scrubbed = Traverse(obj).map(function (x) { - if (typeof x === 'function') { - callbacks[id] = { id : id, f : x, path : this.path }; - this.update('[Function]'); - id++; - } - }); - - assert.equal( - scrubbed.moo, '[Function]', - 'obj.moo replaced with "[Function]"' - ); - - assert.equal( - scrubbed.foo[3], '[Function]', - 'obj.foo[3] replaced with "[Function]"' - ); - - assert.deepEqual(scrubbed, { - moo : '[Function]', - foo : [ 2, 3, 4, "[Function]" ] - }, 'Full JSON string matches'); - - assert.deepEqual( - typeof obj.moo, 'function', - 'Original obj.moo still a function' - ); - - assert.deepEqual( - typeof obj.foo[3], 'function', - 'Original obj.foo[3] still a function' - ); - - assert.deepEqual(callbacks, { - 54: { id: 54, f : obj.moo, path: [ 'moo' ] }, - 55: { id: 55, f : obj.foo[3], path: [ 'foo', '3' ] }, - }, 'Check the generated callbacks list'); -}; - diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/keys.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/keys.js deleted file mode 100644 index 7ecd545ef..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/keys.js +++ /dev/null @@ -1,29 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['sort test'] = function () { - var acc = []; - Traverse({ - a: 30, - b: 22, - id: 9 - }).forEach(function (node) { - if ((! Array.isArray(node)) && typeof node === 'object') { - this.before(function(node) { - this.keys = Object.keys(node); - this.keys.sort(function(a, b) { - a = [a === "id" ? 0 : 1, a]; - b = [b === "id" ? 0 : 1, b]; - return a < b ? -1 : a > b ? 1 : 0; - }); - }); - } - if (this.isLeaf) acc.push(node); - }); - - assert.equal( - acc.join(' '), - '9 30 22', - 'Traversal in a custom order' - ); -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/leaves.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/leaves.js deleted file mode 100644 index e520b72e0..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/leaves.js +++ /dev/null @@ -1,21 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['leaves test'] = function () { - var acc = []; - Traverse({ - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 } - }).forEach(function (x) { - if (this.isLeaf) acc.push(x); - }); - - assert.equal( - acc.join(' '), - '1 2 3 4 5 6 7 8 9', - 'Traversal in the right(?) order' - ); -}; - diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/lib/deep_equal.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/lib/deep_equal.js deleted file mode 100644 index 4fa07bb83..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/lib/deep_equal.js +++ /dev/null @@ -1,92 +0,0 @@ -var traverse = require('../../'); - -module.exports = function (a, b) { - if (arguments.length !== 2) { - throw new Error( - 'deepEqual requires exactly two objects to compare against' - ); - } - - var equal = true; - var node = b; - - traverse(a).forEach(function (y) { - var notEqual = (function () { - equal = false; - //this.stop(); - return undefined; - }).bind(this); - - //if (node === undefined || node === null) return notEqual(); - - if (!this.isRoot) { - /* - if (!Object.hasOwnProperty.call(node, this.key)) { - return notEqual(); - } - */ - if (typeof node !== 'object') return notEqual(); - node = node[this.key]; - } - - var x = node; - - this.post(function () { - node = x; - }); - - var toS = function (o) { - return Object.prototype.toString.call(o); - }; - - if (this.circular) { - if (traverse(b).get(this.circular.path) !== x) notEqual(); - } - else if (typeof x !== typeof y) { - notEqual(); - } - else if (x === null || y === null || x === undefined || y === undefined) { - if (x !== y) notEqual(); - } - else if (x.__proto__ !== y.__proto__) { - notEqual(); - } - else if (x === y) { - // nop - } - else if (typeof x === 'function') { - if (x instanceof RegExp) { - // both regexps on account of the __proto__ check - if (x.toString() != y.toString()) notEqual(); - } - else if (x !== y) notEqual(); - } - else if (typeof x === 'object') { - if (toS(y) === '[object Arguments]' - || toS(x) === '[object Arguments]') { - if (toS(x) !== toS(y)) { - notEqual(); - } - } - else if (x instanceof Date || y instanceof Date) { - if (!(x instanceof Date) || !(y instanceof Date) - || x.getTime() !== y.getTime()) { - notEqual(); - } - } - else { - var kx = Object.keys(x); - var ky = Object.keys(y); - if (kx.length !== ky.length) return notEqual(); - for (var i = 0; i < kx.length; i++) { - var k = kx[i]; - if (!Object.hasOwnProperty.call(y, k)) { - notEqual(); - } - } - } - } - }); - - return equal; -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/mutability.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/mutability.js deleted file mode 100644 index 2236f5631..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/mutability.js +++ /dev/null @@ -1,252 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -exports.mutate = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).forEach(function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, res); - assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.mutateT = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse.forEach(obj, function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, res); - assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.map = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).map(function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.mapT = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse.map(obj, function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.clone = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).clone(); - assert.deepEqual(obj, res); - assert.ok(obj !== res); - obj.a ++; - assert.deepEqual(res.a, 1); - obj.c.push(5); - assert.deepEqual(res.c, [ 3, 4 ]); -}; - -exports.cloneT = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse.clone(obj); - assert.deepEqual(obj, res); - assert.ok(obj !== res); - obj.a ++; - assert.deepEqual(res.a, 1); - obj.c.push(5); - assert.deepEqual(res.c, [ 3, 4 ]); -}; - -exports.reduce = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; - }, []); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, [ 1, 2, 3, 4 ]); -}; - -exports.reduceInit = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).reduce(function (acc, x) { - if (this.isRoot) assert.fail('got root'); - return acc; - }); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, obj); -}; - -exports.remove = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - Traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.remove(); - }); - - assert.deepEqual(obj, { a : 1, c : [ 3 ] }); -}; - -exports.removeNoStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.remove(); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e', 'f']) -} - -exports.removeStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.remove(true); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'f']) -} - -exports.removeMap = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.remove(); - }); - - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, { a : 1, c : [ 3 ] }); -}; - -exports.delete = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - Traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, undefined ] } - )); - - assert.ok(deepEqual( - obj, { a : 1, c : [ 3 ] } - )); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, null ] } - )); -}; - -exports.deleteNoStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 } }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.delete(); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e']) -} - -exports.deleteStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 } }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.delete(true); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c']) -} - -exports.deleteRedux = function () { - var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] }; - Traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, undefined, 5 ] } - )); - - assert.ok(deepEqual( - obj, { a : 1, c : [ 3 ,, 5 ] } - )); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, null, 5 ] } - )); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, 5 ] } - )); -}; - -exports.deleteMap = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(deepEqual( - obj, - { a : 1, b : 2, c : [ 3, 4 ] } - )); - - var xs = [ 3, 4 ]; - delete xs[1]; - - assert.ok(deepEqual( - res, { a : 1, c : xs } - )); - - assert.ok(deepEqual( - res, { a : 1, c : [ 3, ] } - )); - - assert.ok(deepEqual( - res, { a : 1, c : [ 3 ] } - )); -}; - -exports.deleteMapRedux = function () { - var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] }; - var res = Traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(deepEqual( - obj, - { a : 1, b : 2, c : [ 3, 4, 5 ] } - )); - - var xs = [ 3, 4, 5 ]; - delete xs[1]; - - assert.ok(deepEqual( - res, { a : 1, c : xs } - )); - - assert.ok(!deepEqual( - res, { a : 1, c : [ 3, 5 ] } - )); - - assert.ok(deepEqual( - res, { a : 1, c : [ 3 ,, 5 ] } - )); -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/negative.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/negative.js deleted file mode 100644 index f92dfb07a..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/negative.js +++ /dev/null @@ -1,20 +0,0 @@ -var Traverse = require('../'); -var assert = require('assert'); - -exports['negative update test'] = function () { - var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - var fixed = Traverse.map(obj, function (x) { - if (x < 0) this.update(x + 128); - }); - - assert.deepEqual(fixed, - [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ], - 'Negative values += 128' - ); - - assert.deepEqual(obj, - [ 5, 6, -3, [ 7, 8, -2, 1 ], { f: 10, g: -13 } ], - 'Original references not modified' - ); -} - diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/obj.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/obj.js deleted file mode 100644 index d46fd38ae..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/obj.js +++ /dev/null @@ -1,15 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['traverse an object with nested functions'] = function () { - var to = setTimeout(function () { - assert.fail('never ran'); - }, 1000); - - function Cons (x) { - clearTimeout(to); - assert.equal(x, 10); - }; - Traverse(new Cons(10)); -}; - diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/siblings.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/siblings.js deleted file mode 100644 index 99c0f1b24..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/siblings.js +++ /dev/null @@ -1,35 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); - -exports.siblings = function () { - var obj = { a : 1, b : 2, c : [ 4, 5, 6 ] }; - - var res = traverse(obj).reduce(function (acc, x) { - var p = '/' + this.path.join('/'); - if (this.parent) { - acc[p] = { - siblings : this.parent.keys, - key : this.key, - index : this.parent.keys.indexOf(this.key) - }; - } - else { - acc[p] = { - siblings : [], - key : this.key, - index : -1 - } - } - return acc; - }, {}); - - assert.deepEqual(res, { - '/' : { siblings : [], key : undefined, index : -1 }, - '/a' : { siblings : [ 'a', 'b', 'c' ], key : 'a', index : 0 }, - '/b' : { siblings : [ 'a', 'b', 'c' ], key : 'b', index : 1 }, - '/c' : { siblings : [ 'a', 'b', 'c' ], key : 'c', index : 2 }, - '/c/0' : { siblings : [ '0', '1', '2' ], key : '0', index : 0 }, - '/c/1' : { siblings : [ '0', '1', '2' ], key : '1', index : 1 }, - '/c/2' : { siblings : [ '0', '1', '2' ], key : '2', index : 2 } - }); -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stop.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stop.js deleted file mode 100644 index 3529847d8..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stop.js +++ /dev/null @@ -1,41 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); - -exports.stop = function () { - var visits = 0; - traverse('abcdefghij'.split('')).forEach(function (node) { - if (typeof node === 'string') { - visits ++; - if (node === 'e') this.stop() - } - }); - - assert.equal(visits, 5); -}; - -exports.stopMap = function () { - var s = traverse('abcdefghij'.split('')).map(function (node) { - if (typeof node === 'string') { - if (node === 'e') this.stop() - return node.toUpperCase(); - } - }).join(''); - - assert.equal(s, 'ABCDEfghij'); -}; - -exports.stopReduce = function () { - var obj = { - a : [ 4, 5 ], - b : [ 6, [ 7, 8, 9 ] ] - }; - var xs = traverse(obj).reduce(function (acc, node) { - if (this.isLeaf) { - if (node === 7) this.stop(); - else acc.push(node) - } - return acc; - }, []); - - assert.deepEqual(xs, [ 4, 5, 6 ]); -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stringify.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stringify.js deleted file mode 100644 index 932f5d3cf..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/stringify.js +++ /dev/null @@ -1,36 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports.stringify = function () { - var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - - var s = ''; - Traverse(obj).forEach(function (node) { - if (Array.isArray(node)) { - this.before(function () { s += '[' }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += ']' }); - } - else if (typeof node == 'object') { - this.before(function () { s += '{' }); - this.pre(function (x, key) { - s += '"' + key + '"' + ':'; - }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += '}' }); - } - else if (typeof node == 'function') { - s += 'null'; - } - else { - s += node.toString(); - } - }); - - assert.equal(s, JSON.stringify(obj)); -} - diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/subexpr.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/subexpr.js deleted file mode 100644 index a217beba9..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/subexpr.js +++ /dev/null @@ -1,34 +0,0 @@ -var traverse = require('../'); -var assert = require('assert'); - -exports.subexpr = function () { - var obj = [ 'a', 4, 'b', 5, 'c', 6 ]; - var r = traverse(obj).map(function (x) { - if (typeof x === 'number') { - this.update([ x - 0.1, x, x + 0.1 ], true); - } - }); - - assert.deepEqual(obj, [ 'a', 4, 'b', 5, 'c', 6 ]); - assert.deepEqual(r, [ - 'a', [ 3.9, 4, 4.1 ], - 'b', [ 4.9, 5, 5.1 ], - 'c', [ 5.9, 6, 6.1 ], - ]); -}; - -exports.block = function () { - var obj = [ [ 1 ], [ 2 ], [ 3 ] ]; - var r = traverse(obj).map(function (x) { - if (Array.isArray(x) && !this.isRoot) { - if (x[0] === 5) this.block() - else this.update([ [ x[0] + 1 ] ]) - } - }); - - assert.deepEqual(r, [ - [ [ [ [ [ 5 ] ] ] ] ], - [ [ [ [ 5 ] ] ] ], - [ [ [ 5 ] ] ], - ]); -}; diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/super_deep.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/test/super_deep.js deleted file mode 100644 index acac2fd9e..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/test/super_deep.js +++ /dev/null @@ -1,55 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -exports.super_deep = function () { - var util = require('util'); - var a0 = make(); - var a1 = make(); - assert.ok(deepEqual(a0, a1)); - - a0.c.d.moo = true; - assert.ok(!deepEqual(a0, a1)); - - a1.c.d.moo = true; - assert.ok(deepEqual(a0, a1)); - - // TODO: this one - //a0.c.a = a1; - //assert.ok(!deepEqual(a0, a1)); -}; - -function make () { - var a = { self : 'a' }; - var b = { self : 'b' }; - var c = { self : 'c' }; - var d = { self : 'd' }; - var e = { self : 'e' }; - - a.a = a; - a.b = b; - a.c = c; - - b.a = a; - b.b = b; - b.c = c; - - c.a = a; - c.b = b; - c.c = c; - c.d = d; - - d.a = a; - d.b = b; - d.c = c; - d.d = d; - d.e = e; - - e.a = a; - e.b = b; - e.c = c; - e.d = d; - e.e = e; - - return a; -} diff --git a/node_modules/tap/node_modules/difflet/node_modules/traverse/testling/leaves.js b/node_modules/tap/node_modules/difflet/node_modules/traverse/testling/leaves.js deleted file mode 100644 index 099a1b9f7..000000000 --- a/node_modules/tap/node_modules/difflet/node_modules/traverse/testling/leaves.js +++ /dev/null @@ -1,22 +0,0 @@ -var traverse = require('traverse'); -var test = require('testling'); - -test('leaves', function (t) { - var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 } - }; - - var acc = []; - traverse(obj).forEach(function (x) { - if (this.isLeaf) acc.push(x); - }); - - t.deepEqual( - acc, [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ], - 'traversal in the proper order' - ); - t.end(); -}); diff --git a/node_modules/tap/node_modules/difflet/package.json b/node_modules/tap/node_modules/difflet/package.json deleted file mode 100644 index 8fce6e3aa..000000000 --- a/node_modules/tap/node_modules/difflet/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name" : "difflet", - "description" : "colorful diffs for javascript objects", - "version" : "0.2.0", - "repository" : { - "type" : "git", - "url" : "git://github.com/substack/difflet.git" - }, - "main" : "index.js", - "keywords" : [ - "diff", - "object", - "compare" - ], - "directories" : { - "lib" : ".", - "example" : "example", - "test" : "test" - }, - "scripts" : { - "test" : "tap test/*.js" - }, - "dependencies" : { - "traverse" : "0.6.x", - "charm" : "0.0.x", - "deep-equal" : "0.0.x" - }, - "devDependencies" : { - "tap" : "0.1.x", - "ent" : "0.0.x" - }, - "engines" : { - "node" : ">=0.4.0" - }, - "license" : "MIT", - "author" : { - "name" : "James Halliday", - "email" : "mail@substack.net", - "url" : "http://substack.net" - } -} diff --git a/node_modules/tap/node_modules/difflet/test/html.js b/node_modules/tap/node_modules/difflet/test/html.js deleted file mode 100644 index 26d2ed418..000000000 --- a/node_modules/tap/node_modules/difflet/test/html.js +++ /dev/null @@ -1,80 +0,0 @@ -var difflet = require('../'); -var test = require('tap').test; -var ent = require('ent'); - -var tags = { - inserted : 'g', - updated : 'b', - deleted : 'r', -}; - -test('html output', function (t) { - t.plan(1); - var diff = difflet({ - start : function (t, s) { - s.write('<' + tags[t] + '>'); - }, - stop : function (t, s) { - s.write(''); - }, - write : function (buf, s) { - s.write(ent.encode(buf)); - } - }); - - var stream = diff( - { yy : 6, zz : 5, a : [1,2,3], fn : function qqq () {} }, - { - a : [ 1, 2, 3, [4], "z", /beep/, new Buffer([0,1,2]) ], - fn : function rrr () {}, - b : [5,6,7] - } - ); - - var data = '' - stream.on('data', function (buf) { data += buf }); - stream.on('end', function () { - t.equal(data, - '{"a":[1,2,3,[4],"z",' - + '/beep/,<Buffer 00 01 02>],' - + '"fn":[Function: rrr],' - + '"b":[5,6,7],"yy":6,' - + '"zz":5}' - ); - t.end(); - }); -}); - -test('compare html output', function (t) { - t.plan(1); - - var diff = difflet({ - start : function (t, s) { - s.write('<' + tags[t] + '>'); - }, - stop : function (t, s) { - s.write(''); - }, - write : function (buf, s) { - s.write(ent.encode(buf)); - } - }); - - var data = diff.compare( - { yy : 6, zz : 5, a : [1,2,3], fn : function qqq () {} }, - { - a : [ 1, 2, 3, [4], "z", /beep/, new Buffer([0,1,2]) ], - fn : function rrr () {}, - b : [5,6,7] - } - ); - - t.equal(data, - '{"a":[1,2,3,[4],"z",' - + '/beep/,<Buffer 00 01 02>],' - + '"fn":[Function: rrr],' - + '"b":[5,6,7],"yy":6,' - + '"zz":5}' - ); - t.end(); -}); diff --git a/node_modules/tap/node_modules/inherits/LICENSE b/node_modules/tap/node_modules/inherits/LICENSE deleted file mode 100644 index c78c4f661..000000000 --- a/node_modules/tap/node_modules/inherits/LICENSE +++ /dev/null @@ -1,26 +0,0 @@ -Copyright 2011 Isaac Z. Schlueter (the "Author") -All rights reserved. - -General Public Obviousness License - -The Author asserts that this software and associated documentation -files (the "Software"), while the Author's original creation, is -nonetheless obvious, trivial, unpatentable, and implied by the -context in which the software was created. If you sat down and -thought about the problem for an hour or less, you'd probably -come up with exactly this solution. - -Permission is granted to use this software in any way -whatsoever, with the following restriction: - -You may not release the Software under a more restrictive license -than this one. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/tap/node_modules/inherits/README.md b/node_modules/tap/node_modules/inherits/README.md deleted file mode 100644 index b2beaed93..000000000 --- a/node_modules/tap/node_modules/inherits/README.md +++ /dev/null @@ -1,51 +0,0 @@ -A dead simple way to do inheritance in JS. - - var inherits = require("inherits") - - function Animal () { - this.alive = true - } - Animal.prototype.say = function (what) { - console.log(what) - } - - inherits(Dog, Animal) - function Dog () { - Dog.super.apply(this) - } - Dog.prototype.sniff = function () { - this.say("sniff sniff") - } - Dog.prototype.bark = function () { - this.say("woof woof") - } - - inherits(Chihuahua, Dog) - function Chihuahua () { - Chihuahua.super.apply(this) - } - Chihuahua.prototype.bark = function () { - this.say("yip yip") - } - - // also works - function Cat () { - Cat.super.apply(this) - } - Cat.prototype.hiss = function () { - this.say("CHSKKSS!!") - } - inherits(Cat, Animal, { - meow: function () { this.say("miao miao") } - }) - Cat.prototype.purr = function () { - this.say("purr purr") - } - - - var c = new Chihuahua - assert(c instanceof Chihuahua) - assert(c instanceof Dog) - assert(c instanceof Animal) - -The actual function is laughably small. 10-lines small. diff --git a/node_modules/tap/node_modules/inherits/inherits-old.js b/node_modules/tap/node_modules/inherits/inherits-old.js deleted file mode 100644 index ef39252dd..000000000 --- a/node_modules/tap/node_modules/inherits/inherits-old.js +++ /dev/null @@ -1,40 +0,0 @@ -// This is a less perfect implementation of the inherits function, -// designed to work in cases where ES5 is not available. -// -// Note that it is a bit longer, and doesn't properly deal with -// getter/setters or property descriptor flags (enumerable, etc.) - -module.exports = inheritsOld - -function inheritsOld (c, p, proto) { - function F () { this.constructor = c } - F.prototype = p.prototype - var e = {} - for (var i in c.prototype) if (c.prototype.hasOwnProperty(i)) { - e[i] = c.prototype[i] - } - if (proto) for (var i in proto) if (proto.hasOwnProperty(i)) { - e[i] = proto[i] - } - c.prototype = new F() - for (var i in e) if (e.hasOwnProperty(i)) { - c.prototype[i] = e[i] - } - c.super = p -} - -// function Child () { -// Child.super.call(this) -// console.error([this -// ,this.constructor -// ,this.constructor === Child -// ,this.constructor.super === Parent -// ,Object.getPrototypeOf(this) === Child.prototype -// ,Object.getPrototypeOf(Object.getPrototypeOf(this)) -// === Parent.prototype -// ,this instanceof Child -// ,this instanceof Parent]) -// } -// function Parent () {} -// inheritsOld(Child, Parent) -// new Child diff --git a/node_modules/tap/node_modules/inherits/inherits.js b/node_modules/tap/node_modules/inherits/inherits.js deleted file mode 100644 index 061b39620..000000000 --- a/node_modules/tap/node_modules/inherits/inherits.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = inherits - -function inherits (c, p, proto) { - proto = proto || {} - var e = {} - ;[c.prototype, proto].forEach(function (s) { - Object.getOwnPropertyNames(s).forEach(function (k) { - e[k] = Object.getOwnPropertyDescriptor(s, k) - }) - }) - c.prototype = Object.create(p.prototype, e) - c.super = p -} - -//function Child () { -// Child.super.call(this) -// console.error([this -// ,this.constructor -// ,this.constructor === Child -// ,this.constructor.super === Parent -// ,Object.getPrototypeOf(this) === Child.prototype -// ,Object.getPrototypeOf(Object.getPrototypeOf(this)) -// === Parent.prototype -// ,this instanceof Child -// ,this instanceof Parent]) -//} -//function Parent () {} -//inherits(Child, Parent) -//new Child diff --git a/node_modules/tap/node_modules/inherits/package.json b/node_modules/tap/node_modules/inherits/package.json deleted file mode 100644 index 7dc32771b..000000000 --- a/node_modules/tap/node_modules/inherits/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ "name" : "inherits" -, "description": "A tiny simple way to do classic inheritance in js" -, "version" : "1.0.0" -, "keywords" : ["inheritance", "class", "klass", "oop", "object-oriented"] -, "main" : "./inherits.js" -, "repository" : "https://github.com/isaacs/inherits" -, "license": { "type": "GPOL", "url": "https://raw.github.com/isaacs/inherits/master/LICENSE" } -, "author" : "Isaac Z. Schlueter (http://blog.izs.me/)" } diff --git a/node_modules/tap/node_modules/mkdirp/.gitignore.orig b/node_modules/tap/node_modules/mkdirp/.gitignore.orig deleted file mode 100644 index 9303c347e..000000000 --- a/node_modules/tap/node_modules/mkdirp/.gitignore.orig +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/ -npm-debug.log \ No newline at end of file diff --git a/node_modules/tap/node_modules/mkdirp/.gitignore.rej b/node_modules/tap/node_modules/mkdirp/.gitignore.rej deleted file mode 100644 index 69244ff87..000000000 --- a/node_modules/tap/node_modules/mkdirp/.gitignore.rej +++ /dev/null @@ -1,5 +0,0 @@ ---- /dev/null -+++ .gitignore -@@ -0,0 +1,2 @@ -+node_modules/ -+npm-debug.log \ No newline at end of file diff --git a/node_modules/tap/node_modules/mkdirp/.npmignore b/node_modules/tap/node_modules/mkdirp/.npmignore deleted file mode 100644 index 9303c347e..000000000 --- a/node_modules/tap/node_modules/mkdirp/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/ -npm-debug.log \ No newline at end of file diff --git a/node_modules/tap/node_modules/mkdirp/LICENSE b/node_modules/tap/node_modules/mkdirp/LICENSE deleted file mode 100644 index 432d1aeb0..000000000 --- a/node_modules/tap/node_modules/mkdirp/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright 2010 James Halliday (mail@substack.net) - -This project is free software released under the MIT/X11 license: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/tap/node_modules/mkdirp/README.markdown b/node_modules/tap/node_modules/mkdirp/README.markdown deleted file mode 100644 index b4dd75fdc..000000000 --- a/node_modules/tap/node_modules/mkdirp/README.markdown +++ /dev/null @@ -1,54 +0,0 @@ -mkdirp -====== - -Like `mkdir -p`, but in node.js! - -example -======= - -pow.js ------- - var mkdirp = require('mkdirp'); - - mkdirp('/tmp/foo/bar/baz', function (err) { - if (err) console.error(err) - else console.log('pow!') - }); - -Output - pow! - -And now /tmp/foo/bar/baz exists, huzzah! - -methods -======= - -var mkdirp = require('mkdirp'); - -mkdirp(dir, mode, cb) ---------------------- - -Create a new directory and any necessary subdirectories at `dir` with octal -permission string `mode`. - -If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. - -mkdirp.sync(dir, mode) ----------------------- - -Synchronously create a new directory and any necessary subdirectories at `dir` -with octal permission string `mode`. - -If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. - -install -======= - -With [npm](http://npmjs.org) do: - - npm install mkdirp - -license -======= - -MIT/X11 diff --git a/node_modules/tap/node_modules/mkdirp/examples/pow.js b/node_modules/tap/node_modules/mkdirp/examples/pow.js deleted file mode 100644 index e6924212e..000000000 --- a/node_modules/tap/node_modules/mkdirp/examples/pow.js +++ /dev/null @@ -1,6 +0,0 @@ -var mkdirp = require('mkdirp'); - -mkdirp('/tmp/foo/bar/baz', function (err) { - if (err) console.error(err) - else console.log('pow!') -}); diff --git a/node_modules/tap/node_modules/mkdirp/examples/pow.js.orig b/node_modules/tap/node_modules/mkdirp/examples/pow.js.orig deleted file mode 100644 index 774146221..000000000 --- a/node_modules/tap/node_modules/mkdirp/examples/pow.js.orig +++ /dev/null @@ -1,6 +0,0 @@ -var mkdirp = require('mkdirp'); - -mkdirp('/tmp/foo/bar/baz', 0755, function (err) { - if (err) console.error(err) - else console.log('pow!') -}); diff --git a/node_modules/tap/node_modules/mkdirp/examples/pow.js.rej b/node_modules/tap/node_modules/mkdirp/examples/pow.js.rej deleted file mode 100644 index 81e7f4311..000000000 --- a/node_modules/tap/node_modules/mkdirp/examples/pow.js.rej +++ /dev/null @@ -1,19 +0,0 @@ ---- examples/pow.js -+++ examples/pow.js -@@ -1,6 +1,15 @@ --var mkdirp = require('mkdirp').mkdirp; -+var mkdirp = require('../').mkdirp, -+ mkdirpSync = require('../').mkdirpSync; - - mkdirp('/tmp/foo/bar/baz', 0755, function (err) { - if (err) console.error(err) - else console.log('pow!') - }); -+ -+try { -+ mkdirpSync('/tmp/bar/foo/baz', 0755); -+ console.log('double pow!'); -+} -+catch (ex) { -+ console.log(ex); -+} \ No newline at end of file diff --git a/node_modules/tap/node_modules/mkdirp/index.js b/node_modules/tap/node_modules/mkdirp/index.js deleted file mode 100644 index 371bf080e..000000000 --- a/node_modules/tap/node_modules/mkdirp/index.js +++ /dev/null @@ -1,90 +0,0 @@ -var path = require('path'); -var fs = require('fs'); - -module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP; - -function mkdirP (p, mode, f) { - if (typeof mode === 'function' || mode === undefined) { - f = mode; - mode = 0777 & (~process.umask()); - } - - var cb = f || function () {}; - if (typeof mode === 'string') mode = parseInt(mode, 8); - p = path.resolve(p); - - fs.mkdir(p, mode, function (er) { - if (!er) return cb(); - switch (er.code) { - case 'ENOENT': - mkdirP(path.dirname(p), mode, function (er) { - if (er) cb(er); - else mkdirP(p, mode, cb); - }); - break; - - case 'EEXIST': - fs.stat(p, function (er2, stat) { - // if the stat fails, then that's super weird. - // let the original EEXIST be the failure reason. - if (er2 || !stat.isDirectory()) cb(er) - else if ((stat.mode & 0777) !== mode) fs.chmod(p, mode, cb); - else cb(); - }); - break; - - default: - cb(er); - break; - } - }); -} - -mkdirP.sync = function sync (p, mode) { - if (mode === undefined) { - mode = 0777 & (~process.umask()); - } - - if (typeof mode === 'string') mode = parseInt(mode, 8); - p = path.resolve(p); - - try { - fs.mkdirSync(p, mode) - } - catch (err0) { - switch (err0.code) { - case 'ENOENT' : - var err1 = sync(path.dirname(p), mode) - if (err1) throw err1; - else return sync(p, mode); - break; - - case 'EEXIST' : - var stat; - try { - stat = fs.statSync(p); - } - catch (err1) { - throw err0 - } - if (!stat.isDirectory()) throw err0; - else if ((stat.mode & 0777) !== mode) { - try { - fs.chmodSync(p, mode); - } - catch (err) { - if (err && err.code === 'EPERM') return null; - else throw err; - } - return null; - } - else return null; - break; - default : - throw err0 - break; - } - } - - return null; -}; diff --git a/node_modules/tap/node_modules/mkdirp/package.json b/node_modules/tap/node_modules/mkdirp/package.json deleted file mode 100644 index 9fc8d326a..000000000 --- a/node_modules/tap/node_modules/mkdirp/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name" : "mkdirp", - "description" : "Recursively mkdir, like `mkdir -p`", - "version" : "0.2.2", - "author" : "James Halliday (http://substack.net)", - "main" : "./index", - "keywords" : [ - "mkdir", - "directory" - ], - "repository" : { - "type" : "git", - "url" : "https://github.com/substack/node-mkdirp.git" - }, - "scripts" : { - "test" : "tap test/*.js" - }, - "devDependencies" : { - "tap" : "0.0.x" - }, - "license" : "MIT/X11", - "engines": { "node": "*" } -} diff --git a/node_modules/tap/node_modules/mkdirp/test/chmod.js b/node_modules/tap/node_modules/mkdirp/test/chmod.js deleted file mode 100644 index 0609694e3..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/chmod.js +++ /dev/null @@ -1,39 +0,0 @@ -var mkdirp = require('../').mkdirp; -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -var ps = [ '', 'tmp' ]; - -for (var i = 0; i < 25; i++) { - var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - ps.push(dir); -} - -var file = ps.join('/'); - -test('chmod-pre', function (t) { - var mode = 0744 - mkdirp(file, mode, function (er) { - t.ifError(er, 'should not error'); - fs.stat(file, function (er, stat) { - t.ifError(er, 'should exist'); - t.ok(stat && stat.isDirectory(), 'should be directory'); - t.equal(stat && stat.mode & 0777, mode, 'should be 0744'); - t.end(); - }); - }); -}); - -test('chmod', function (t) { - var mode = 0755 - mkdirp(file, mode, function (er) { - t.ifError(er, 'should not error'); - fs.stat(file, function (er, stat) { - t.ifError(er, 'should exist'); - t.ok(stat && stat.isDirectory(), 'should be directory'); - t.equal(stat && stat.mode & 0777, mode, 'should be 0755'); - t.end(); - }); - }); -}); diff --git a/node_modules/tap/node_modules/mkdirp/test/clobber.js b/node_modules/tap/node_modules/mkdirp/test/clobber.js deleted file mode 100644 index 0eb709987..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/clobber.js +++ /dev/null @@ -1,37 +0,0 @@ -var mkdirp = require('../').mkdirp; -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -var ps = [ '', 'tmp' ]; - -for (var i = 0; i < 25; i++) { - var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - ps.push(dir); -} - -var file = ps.join('/'); - -// a file in the way -var itw = ps.slice(0, 3).join('/'); - - -test('clobber-pre', function (t) { - console.error("about to write to "+itw) - fs.writeFileSync(itw, 'I AM IN THE WAY, THE TRUTH, AND THE LIGHT.'); - - fs.stat(itw, function (er, stat) { - t.ifError(er) - t.ok(stat && stat.isFile(), 'should be file') - t.end() - }) -}) - -test('clobber', function (t) { - t.plan(2); - mkdirp(file, 0755, function (err) { - t.ok(err); - t.equal(err.code, 'ENOTDIR'); - t.end(); - }); -}); diff --git a/node_modules/tap/node_modules/mkdirp/test/mkdirp.js b/node_modules/tap/node_modules/mkdirp/test/mkdirp.js deleted file mode 100644 index b07cd70c1..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/mkdirp.js +++ /dev/null @@ -1,28 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('woo', function (t) { - t.plan(2); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - mkdirp(file, 0755, function (err) { - if (err) t.fail(err); - else path.exists(file, function (ex) { - if (!ex) t.fail('file not created') - else fs.stat(file, function (err, stat) { - if (err) t.fail(err) - else { - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - t.end(); - } - }) - }) - }); -}); diff --git a/node_modules/tap/node_modules/mkdirp/test/perm.js b/node_modules/tap/node_modules/mkdirp/test/perm.js deleted file mode 100644 index 23a7abbd2..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/perm.js +++ /dev/null @@ -1,32 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('async perm', function (t) { - t.plan(2); - var file = '/tmp/' + (Math.random() * (1<<30)).toString(16); - - mkdirp(file, 0755, function (err) { - if (err) t.fail(err); - else path.exists(file, function (ex) { - if (!ex) t.fail('file not created') - else fs.stat(file, function (err, stat) { - if (err) t.fail(err) - else { - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - t.end(); - } - }) - }) - }); -}); - -test('async root perm', function (t) { - mkdirp('/tmp', 0755, function (err) { - if (err) t.fail(err); - t.end(); - }); - t.end(); -}); diff --git a/node_modules/tap/node_modules/mkdirp/test/perm_sync.js b/node_modules/tap/node_modules/mkdirp/test/perm_sync.js deleted file mode 100644 index f685f6090..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/perm_sync.js +++ /dev/null @@ -1,39 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('sync perm', function (t) { - t.plan(2); - var file = '/tmp/' + (Math.random() * (1<<30)).toString(16) + '.json'; - - mkdirp.sync(file, 0755); - path.exists(file, function (ex) { - if (!ex) t.fail('file not created') - else fs.stat(file, function (err, stat) { - if (err) t.fail(err) - else { - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - t.end(); - } - }) - }); -}); - -test('sync root perm', function (t) { - t.plan(1); - - var file = '/tmp'; - mkdirp.sync(file, 0755); - path.exists(file, function (ex) { - if (!ex) t.fail('file not created') - else fs.stat(file, function (err, stat) { - if (err) t.fail(err) - else { - t.ok(stat.isDirectory(), 'target not a directory'); - t.end(); - } - }) - }); -}); diff --git a/node_modules/tap/node_modules/mkdirp/test/race.js b/node_modules/tap/node_modules/mkdirp/test/race.js deleted file mode 100644 index 96a044763..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/race.js +++ /dev/null @@ -1,41 +0,0 @@ -var mkdirp = require('../').mkdirp; -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('race', function (t) { - t.plan(4); - var ps = [ '', 'tmp' ]; - - for (var i = 0; i < 25; i++) { - var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - ps.push(dir); - } - var file = ps.join('/'); - - var res = 2; - mk(file, function () { - if (--res === 0) t.end(); - }); - - mk(file, function () { - if (--res === 0) t.end(); - }); - - function mk (file, cb) { - mkdirp(file, 0755, function (err) { - if (err) t.fail(err); - else path.exists(file, function (ex) { - if (!ex) t.fail('file not created') - else fs.stat(file, function (err, stat) { - if (err) t.fail(err) - else { - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - if (cb) cb(); - } - }) - }) - }); - } -}); diff --git a/node_modules/tap/node_modules/mkdirp/test/rel.js b/node_modules/tap/node_modules/mkdirp/test/rel.js deleted file mode 100644 index 79858243a..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/rel.js +++ /dev/null @@ -1,32 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('rel', function (t) { - t.plan(2); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var cwd = process.cwd(); - process.chdir('/tmp'); - - var file = [x,y,z].join('/'); - - mkdirp(file, 0755, function (err) { - if (err) t.fail(err); - else path.exists(file, function (ex) { - if (!ex) t.fail('file not created') - else fs.stat(file, function (err, stat) { - if (err) t.fail(err) - else { - process.chdir(cwd); - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - t.end(); - } - }) - }) - }); -}); diff --git a/node_modules/tap/node_modules/mkdirp/test/sync.js b/node_modules/tap/node_modules/mkdirp/test/sync.js deleted file mode 100644 index e0e389dea..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/sync.js +++ /dev/null @@ -1,27 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('sync', function (t) { - t.plan(2); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - var err = mkdirp.sync(file, 0755); - if (err) t.fail(err); - else path.exists(file, function (ex) { - if (!ex) t.fail('file not created') - else fs.stat(file, function (err, stat) { - if (err) t.fail(err) - else { - t.equal(stat.mode & 0777, 0755); - t.ok(stat.isDirectory(), 'target not a directory'); - t.end(); - } - }) - }) -}); diff --git a/node_modules/tap/node_modules/mkdirp/test/umask.js b/node_modules/tap/node_modules/mkdirp/test/umask.js deleted file mode 100644 index 64ccafe22..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/umask.js +++ /dev/null @@ -1,28 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('implicit mode from umask', function (t) { - t.plan(2); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - mkdirp(file, function (err) { - if (err) t.fail(err); - else path.exists(file, function (ex) { - if (!ex) t.fail('file not created') - else fs.stat(file, function (err, stat) { - if (err) t.fail(err) - else { - t.equal(stat.mode & 0777, 0777 & (~process.umask())); - t.ok(stat.isDirectory(), 'target not a directory'); - t.end(); - } - }) - }) - }); -}); diff --git a/node_modules/tap/node_modules/mkdirp/test/umask_sync.js b/node_modules/tap/node_modules/mkdirp/test/umask_sync.js deleted file mode 100644 index 83cba560f..000000000 --- a/node_modules/tap/node_modules/mkdirp/test/umask_sync.js +++ /dev/null @@ -1,27 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('umask sync modes', function (t) { - t.plan(2); - var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16); - - var file = '/tmp/' + [x,y,z].join('/'); - - var err = mkdirp.sync(file); - if (err) t.fail(err); - else path.exists(file, function (ex) { - if (!ex) t.fail('file not created') - else fs.stat(file, function (err, stat) { - if (err) t.fail(err) - else { - t.equal(stat.mode & 0777, (0777 & (~process.umask()))); - t.ok(stat.isDirectory(), 'target not a directory'); - t.end(); - } - }) - }) -}); diff --git a/node_modules/tap/node_modules/nopt/.npmignore b/node_modules/tap/node_modules/nopt/.npmignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/node_modules/tap/node_modules/nopt/LICENSE b/node_modules/tap/node_modules/nopt/LICENSE deleted file mode 100644 index 05a401094..000000000 --- a/node_modules/tap/node_modules/nopt/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/tap/node_modules/nopt/README.md b/node_modules/tap/node_modules/nopt/README.md deleted file mode 100644 index eeddfd4fe..000000000 --- a/node_modules/tap/node_modules/nopt/README.md +++ /dev/null @@ -1,208 +0,0 @@ -If you want to write an option parser, and have it be good, there are -two ways to do it. The Right Way, and the Wrong Way. - -The Wrong Way is to sit down and write an option parser. We've all done -that. - -The Right Way is to write some complex configurable program with so many -options that you go half-insane just trying to manage them all, and put -it off with duct-tape solutions until you see exactly to the core of the -problem, and finally snap and write an awesome option parser. - -If you want to write an option parser, don't write an option parser. -Write a package manager, or a source control system, or a service -restarter, or an operating system. You probably won't end up with a -good one of those, but if you don't give up, and you are relentless and -diligent enough in your procrastination, you may just end up with a very -nice option parser. - -## USAGE - - // my-program.js - var nopt = require("nopt") - , Stream = require("stream").Stream - , path = require("path") - , knownOpts = { "foo" : [String, null] - , "bar" : [Stream, Number] - , "baz" : path - , "bloo" : [ "big", "medium", "small" ] - , "flag" : Boolean - , "pick" : Boolean - , "many" : [String, Array] - } - , shortHands = { "foofoo" : ["--foo", "Mr. Foo"] - , "b7" : ["--bar", "7"] - , "m" : ["--bloo", "medium"] - , "p" : ["--pick"] - , "f" : ["--flag"] - } - // everything is optional. - // knownOpts and shorthands default to {} - // arg list defaults to process.argv - // slice defaults to 2 - , parsed = nopt(knownOpts, shortHands, process.argv, 2) - console.log(parsed) - -This would give you support for any of the following: - -```bash -$ node my-program.js --foo "blerp" --no-flag -{ "foo" : "blerp", "flag" : false } - -$ node my-program.js ---bar 7 --foo "Mr. Hand" --flag -{ bar: 7, foo: "Mr. Hand", flag: true } - -$ node my-program.js --foo "blerp" -f -----p -{ foo: "blerp", flag: true, pick: true } - -$ node my-program.js -fp --foofoo -{ foo: "Mr. Foo", flag: true, pick: true } - -$ node my-program.js --foofoo -- -fp # -- stops the flag parsing. -{ foo: "Mr. Foo", argv: { remain: ["-fp"] } } - -$ node my-program.js --blatzk 1000 -fp # unknown opts are ok. -{ blatzk: 1000, flag: true, pick: true } - -$ node my-program.js --blatzk true -fp # but they need a value -{ blatzk: true, flag: true, pick: true } - -$ node my-program.js --no-blatzk -fp # unless they start with "no-" -{ blatzk: false, flag: true, pick: true } - -$ node my-program.js --baz b/a/z # known paths are resolved. -{ baz: "/Users/isaacs/b/a/z" } - -# if Array is one of the types, then it can take many -# values, and will always be an array. The other types provided -# specify what types are allowed in the list. - -$ node my-program.js --many 1 --many null --many foo -{ many: ["1", "null", "foo"] } - -$ node my-program.js --many foo -{ many: ["foo"] } -``` - -Read the tests at the bottom of `lib/nopt.js` for more examples of -what this puppy can do. - -## Types - -The following types are supported, and defined on `nopt.typeDefs` - -* String: A normal string. No parsing is done. -* path: A file system path. Gets resolved against cwd if not absolute. -* url: A url. If it doesn't parse, it isn't accepted. -* Number: Must be numeric. -* Date: Must parse as a date. If it does, and `Date` is one of the options, - then it will return a Date object, not a string. -* Boolean: Must be either `true` or `false`. If an option is a boolean, - then it does not need a value, and its presence will imply `true` as - the value. To negate boolean flags, do `--no-whatever` or `--whatever - false` -* NaN: Means that the option is strictly not allowed. Any value will - fail. -* Stream: An object matching the "Stream" class in node. Valuable - for use when validating programmatically. (npm uses this to let you - supply any WriteStream on the `outfd` and `logfd` config options.) -* Array: If `Array` is specified as one of the types, then the value - will be parsed as a list of options. This means that multiple values - can be specified, and that the value will always be an array. - -If a type is an array of values not on this list, then those are -considered valid values. For instance, in the example above, the -`--bloo` option can only be one of `"big"`, `"medium"`, or `"small"`, -and any other value will be rejected. - -When parsing unknown fields, `"true"`, `"false"`, and `"null"` will be -interpreted as their JavaScript equivalents, and numeric values will be -interpreted as a number. - -You can also mix types and values, or multiple types, in a list. For -instance `{ blah: [Number, null] }` would allow a value to be set to -either a Number or null. - -To define a new type, add it to `nopt.typeDefs`. Each item in that -hash is an object with a `type` member and a `validate` method. The -`type` member is an object that matches what goes in the type list. The -`validate` method is a function that gets called with `validate(data, -key, val)`. Validate methods should assign `data[key]` to the valid -value of `val` if it can be handled properly, or return boolean -`false` if it cannot. - -You can also call `nopt.clean(data, types, typeDefs)` to clean up a -config object and remove its invalid properties. - -## Error Handling - -By default, nopt outputs a warning to standard error when invalid -options are found. You can change this behavior by assigning a method -to `nopt.invalidHandler`. This method will be called with -the offending `nopt.invalidHandler(key, val, types)`. - -If no `nopt.invalidHandler` is assigned, then it will console.error -its whining. If it is assigned to boolean `false` then the warning is -suppressed. - -## Abbreviations - -Yes, they are supported. If you define options like this: - -```javascript -{ "foolhardyelephants" : Boolean -, "pileofmonkeys" : Boolean } -``` - -Then this will work: - -```bash -node program.js --foolhar --pil -node program.js --no-f --pileofmon -# etc. -``` - -## Shorthands - -Shorthands are a hash of shorter option names to a snippet of args that -they expand to. - -If multiple one-character shorthands are all combined, and the -combination does not unambiguously match any other option or shorthand, -then they will be broken up into their constituent parts. For example: - -```json -{ "s" : ["--loglevel", "silent"] -, "g" : "--global" -, "f" : "--force" -, "p" : "--parseable" -, "l" : "--long" -} -``` - -```bash -npm ls -sgflp -# just like doing this: -npm ls --loglevel silent --global --force --long --parseable -``` - -## The Rest of the args - -The config object returned by nopt is given a special member called -`argv`, which is an object with the following fields: - -* `remain`: The remaining args after all the parsing has occurred. -* `original`: The args as they originally appeared. -* `cooked`: The args after flags and shorthands are expanded. - -## Slicing - -Node programs are called with more or less the exact argv as it appears -in C land, after the v8 and node-specific options have been plucked off. -As such, `argv[0]` is always `node` and `argv[1]` is always the -JavaScript program being run. - -That's usually not very useful to you. So they're sliced off by -default. If you want them, then you can pass in `0` as the last -argument, or any other number that you'd like to slice off the start of -the list. diff --git a/node_modules/tap/node_modules/nopt/bin/nopt.js b/node_modules/tap/node_modules/nopt/bin/nopt.js deleted file mode 100755 index df90c729a..000000000 --- a/node_modules/tap/node_modules/nopt/bin/nopt.js +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env node -var nopt = require("../lib/nopt") - , types = { num: Number - , bool: Boolean - , help: Boolean - , list: Array - , "num-list": [Number, Array] - , "str-list": [String, Array] - , "bool-list": [Boolean, Array] - , str: String } - , shorthands = { s: [ "--str", "astring" ] - , b: [ "--bool" ] - , nb: [ "--no-bool" ] - , tft: [ "--bool-list", "--no-bool-list", "--bool-list", "true" ] - , "?": ["--help"] - , h: ["--help"] - , H: ["--help"] - , n: [ "--num", "125" ] } - , parsed = nopt( types - , shorthands - , process.argv - , 2 ) - -console.log("parsed", parsed) - -if (parsed.help) { - console.log("") - console.log("nopt cli tester") - console.log("") - console.log("types") - console.log(Object.keys(types).map(function M (t) { - var type = types[t] - if (Array.isArray(type)) { - return [t, type.map(function (type) { return type.name })] - } - return [t, type && type.name] - }).reduce(function (s, i) { - s[i[0]] = i[1] - return s - }, {})) - console.log("") - console.log("shorthands") - console.log(shorthands) -} diff --git a/node_modules/tap/node_modules/nopt/examples/my-program.js b/node_modules/tap/node_modules/nopt/examples/my-program.js deleted file mode 100755 index 142447e18..000000000 --- a/node_modules/tap/node_modules/nopt/examples/my-program.js +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env node - -//process.env.DEBUG_NOPT = 1 - -// my-program.js -var nopt = require("../lib/nopt") - , Stream = require("stream").Stream - , path = require("path") - , knownOpts = { "foo" : [String, null] - , "bar" : [Stream, Number] - , "baz" : path - , "bloo" : [ "big", "medium", "small" ] - , "flag" : Boolean - , "pick" : Boolean - } - , shortHands = { "foofoo" : ["--foo", "Mr. Foo"] - , "b7" : ["--bar", "7"] - , "m" : ["--bloo", "medium"] - , "p" : ["--pick"] - , "f" : ["--flag", "true"] - , "g" : ["--flag"] - , "s" : "--flag" - } - // everything is optional. - // knownOpts and shorthands default to {} - // arg list defaults to process.argv - // slice defaults to 2 - , parsed = nopt(knownOpts, shortHands, process.argv, 2) - -console.log("parsed =\n"+ require("util").inspect(parsed)) diff --git a/node_modules/tap/node_modules/nopt/lib/nopt.js b/node_modules/tap/node_modules/nopt/lib/nopt.js deleted file mode 100644 index ff802dafe..000000000 --- a/node_modules/tap/node_modules/nopt/lib/nopt.js +++ /dev/null @@ -1,552 +0,0 @@ -// info about each config option. - -var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG - ? function () { console.error.apply(console, arguments) } - : function () {} - -var url = require("url") - , path = require("path") - , Stream = require("stream").Stream - , abbrev = require("abbrev") - -module.exports = exports = nopt -exports.clean = clean - -exports.typeDefs = - { String : { type: String, validate: validateString } - , Boolean : { type: Boolean, validate: validateBoolean } - , url : { type: url, validate: validateUrl } - , Number : { type: Number, validate: validateNumber } - , path : { type: path, validate: validatePath } - , Stream : { type: Stream, validate: validateStream } - , Date : { type: Date, validate: validateDate } - } - -function nopt (types, shorthands, args, slice) { - args = args || process.argv - types = types || {} - shorthands = shorthands || {} - if (typeof slice !== "number") slice = 2 - - debug(types, shorthands, args, slice) - - args = args.slice(slice) - var data = {} - , key - , remain = [] - , cooked = args - , original = args.slice(0) - - parse(args, data, remain, types, shorthands) - // now data is full - clean(data, types, exports.typeDefs) - data.argv = {remain:remain,cooked:cooked,original:original} - data.argv.toString = function () { - return this.original.map(JSON.stringify).join(" ") - } - return data -} - -function clean (data, types, typeDefs) { - typeDefs = typeDefs || exports.typeDefs - var remove = {} - , typeDefault = [false, true, null, String, Number] - - Object.keys(data).forEach(function (k) { - if (k === "argv") return - var val = data[k] - , isArray = Array.isArray(val) - , type = types[k] - if (!isArray) val = [val] - if (!type) type = typeDefault - if (type === Array) type = typeDefault.concat(Array) - if (!Array.isArray(type)) type = [type] - - debug("val=%j", val) - debug("types=", type) - val = val.map(function (val) { - // if it's an unknown value, then parse false/true/null/numbers/dates - if (typeof val === "string") { - debug("string %j", val) - val = val.trim() - if ((val === "null" && ~type.indexOf(null)) - || (val === "true" && - (~type.indexOf(true) || ~type.indexOf(Boolean))) - || (val === "false" && - (~type.indexOf(false) || ~type.indexOf(Boolean)))) { - val = JSON.parse(val) - debug("jsonable %j", val) - } else if (~type.indexOf(Number) && !isNaN(val)) { - debug("convert to number", val) - val = +val - } else if (~type.indexOf(Date) && !isNaN(Date.parse(val))) { - debug("convert to date", val) - val = new Date(val) - } - } - - if (!types.hasOwnProperty(k)) { - return val - } - - // allow `--no-blah` to set 'blah' to null if null is allowed - if (val === false && ~type.indexOf(null) && - !(~type.indexOf(false) || ~type.indexOf(Boolean))) { - val = null - } - - var d = {} - d[k] = val - debug("prevalidated val", d, val, types[k]) - if (!validate(d, k, val, types[k], typeDefs)) { - if (exports.invalidHandler) { - exports.invalidHandler(k, val, types[k], data) - } else if (exports.invalidHandler !== false) { - debug("invalid: "+k+"="+val, types[k]) - } - return remove - } - debug("validated val", d, val, types[k]) - return d[k] - }).filter(function (val) { return val !== remove }) - - if (!val.length) delete data[k] - else if (isArray) { - debug(isArray, data[k], val) - data[k] = val - } else data[k] = val[0] - - debug("k=%s val=%j", k, val, data[k]) - }) -} - -function validateString (data, k, val) { - data[k] = String(val) -} - -function validatePath (data, k, val) { - data[k] = path.resolve(String(val)) - return true -} - -function validateNumber (data, k, val) { - debug("validate Number %j %j %j", k, val, isNaN(val)) - if (isNaN(val)) return false - data[k] = +val -} - -function validateDate (data, k, val) { - debug("validate Date %j %j %j", k, val, Date.parse(val)) - var s = Date.parse(val) - if (isNaN(s)) return false - data[k] = new Date(val) -} - -function validateBoolean (data, k, val) { - if (val instanceof Boolean) val = val.valueOf() - else if (typeof val === "string") { - if (!isNaN(val)) val = !!(+val) - else if (val === "null" || val === "false") val = false - else val = true - } else val = !!val - data[k] = val -} - -function validateUrl (data, k, val) { - val = url.parse(String(val)) - if (!val.host) return false - data[k] = val.href -} - -function validateStream (data, k, val) { - if (!(val instanceof Stream)) return false - data[k] = val -} - -function validate (data, k, val, type, typeDefs) { - // arrays are lists of types. - if (Array.isArray(type)) { - for (var i = 0, l = type.length; i < l; i ++) { - if (type[i] === Array) continue - if (validate(data, k, val, type[i], typeDefs)) return true - } - delete data[k] - return false - } - - // an array of anything? - if (type === Array) return true - - // NaN is poisonous. Means that something is not allowed. - if (type !== type) { - debug("Poison NaN", k, val, type) - delete data[k] - return false - } - - // explicit list of values - if (val === type) { - debug("Explicitly allowed %j", val) - // if (isArray) (data[k] = data[k] || []).push(val) - // else data[k] = val - data[k] = val - return true - } - - // now go through the list of typeDefs, validate against each one. - var ok = false - , types = Object.keys(typeDefs) - for (var i = 0, l = types.length; i < l; i ++) { - debug("test type %j %j %j", k, val, types[i]) - var t = typeDefs[types[i]] - if (t && type === t.type) { - var d = {} - ok = false !== t.validate(d, k, val) - val = d[k] - if (ok) { - // if (isArray) (data[k] = data[k] || []).push(val) - // else data[k] = val - data[k] = val - break - } - } - } - debug("OK? %j (%j %j %j)", ok, k, val, types[i]) - - if (!ok) delete data[k] - return ok -} - -function parse (args, data, remain, types, shorthands) { - debug("parse", args, data, remain) - - var key = null - , abbrevs = abbrev(Object.keys(types)) - , shortAbbr = abbrev(Object.keys(shorthands)) - - for (var i = 0; i < args.length; i ++) { - var arg = args[i] - debug("arg", arg) - - if (arg.match(/^-{2,}$/)) { - // done with keys. - // the rest are args. - remain.push.apply(remain, args.slice(i + 1)) - args[i] = "--" - break - } - if (arg.charAt(0) === "-") { - if (arg.indexOf("=") !== -1) { - var v = arg.split("=") - arg = v.shift() - v = v.join("=") - args.splice.apply(args, [i, 1].concat([arg, v])) - } - // see if it's a shorthand - // if so, splice and back up to re-parse it. - var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs) - debug("arg=%j shRes=%j", arg, shRes) - if (shRes) { - debug(arg, shRes) - args.splice.apply(args, [i, 1].concat(shRes)) - if (arg !== shRes[0]) { - i -- - continue - } - } - arg = arg.replace(/^-+/, "") - var no = false - while (arg.toLowerCase().indexOf("no-") === 0) { - no = !no - arg = arg.substr(3) - } - - if (abbrevs[arg]) arg = abbrevs[arg] - - var isArray = types[arg] === Array || - Array.isArray(types[arg]) && types[arg].indexOf(Array) !== -1 - - var val - , la = args[i + 1] - - var isBool = no || - types[arg] === Boolean || - Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 || - (la === "false" && - (types[arg] === null || - Array.isArray(types[arg]) && ~types[arg].indexOf(null))) - - if (isBool) { - // just set and move along - val = !no - // however, also support --bool true or --bool false - if (la === "true" || la === "false") { - val = JSON.parse(la) - la = null - if (no) val = !val - i ++ - } - - // also support "foo":[Boolean, "bar"] and "--foo bar" - if (Array.isArray(types[arg]) && la) { - if (~types[arg].indexOf(la)) { - // an explicit type - val = la - i ++ - } else if ( la === "null" && ~types[arg].indexOf(null) ) { - // null allowed - val = null - i ++ - } else if ( !la.match(/^-{2,}[^-]/) && - !isNaN(la) && - ~types[arg].indexOf(Number) ) { - // number - val = +la - i ++ - } else if ( !la.match(/^-[^-]/) && ~types[arg].indexOf(String) ) { - // string - val = la - i ++ - } - } - - if (isArray) (data[arg] = data[arg] || []).push(val) - else data[arg] = val - - continue - } - - if (la && la.match(/^-{2,}$/)) { - la = undefined - i -- - } - - val = la === undefined ? true : la - if (isArray) (data[arg] = data[arg] || []).push(val) - else data[arg] = val - - i ++ - continue - } - remain.push(arg) - } -} - -function resolveShort (arg, shorthands, shortAbbr, abbrevs) { - // handle single-char shorthands glommed together, like - // npm ls -glp, but only if there is one dash, and only if - // all of the chars are single-char shorthands, and it's - // not a match to some other abbrev. - arg = arg.replace(/^-+/, '') - if (abbrevs[arg] && !shorthands[arg]) { - return null - } - if (shortAbbr[arg]) { - arg = shortAbbr[arg] - } else { - var singles = shorthands.___singles - if (!singles) { - singles = Object.keys(shorthands).filter(function (s) { - return s.length === 1 - }).reduce(function (l,r) { l[r] = true ; return l }, {}) - shorthands.___singles = singles - } - var chrs = arg.split("").filter(function (c) { - return singles[c] - }) - if (chrs.join("") === arg) return chrs.map(function (c) { - return shorthands[c] - }).reduce(function (l, r) { - return l.concat(r) - }, []) - } - - if (shorthands[arg] && !Array.isArray(shorthands[arg])) { - shorthands[arg] = shorthands[arg].split(/\s+/) - } - return shorthands[arg] -} - -if (module === require.main) { -var assert = require("assert") - , util = require("util") - - , shorthands = - { s : ["--loglevel", "silent"] - , d : ["--loglevel", "info"] - , dd : ["--loglevel", "verbose"] - , ddd : ["--loglevel", "silly"] - , noreg : ["--no-registry"] - , reg : ["--registry"] - , "no-reg" : ["--no-registry"] - , silent : ["--loglevel", "silent"] - , verbose : ["--loglevel", "verbose"] - , h : ["--usage"] - , H : ["--usage"] - , "?" : ["--usage"] - , help : ["--usage"] - , v : ["--version"] - , f : ["--force"] - , desc : ["--description"] - , "no-desc" : ["--no-description"] - , "local" : ["--no-global"] - , l : ["--long"] - , p : ["--parseable"] - , porcelain : ["--parseable"] - , g : ["--global"] - } - - , types = - { aoa: Array - , nullstream: [null, Stream] - , date: Date - , str: String - , browser : String - , cache : path - , color : ["always", Boolean] - , depth : Number - , description : Boolean - , dev : Boolean - , editor : path - , force : Boolean - , global : Boolean - , globalconfig : path - , group : [String, Number] - , gzipbin : String - , logfd : [Number, Stream] - , loglevel : ["silent","win","error","warn","info","verbose","silly"] - , long : Boolean - , "node-version" : [false, String] - , npaturl : url - , npat : Boolean - , "onload-script" : [false, String] - , outfd : [Number, Stream] - , parseable : Boolean - , pre: Boolean - , prefix: path - , proxy : url - , "rebuild-bundle" : Boolean - , registry : url - , searchopts : String - , searchexclude: [null, String] - , shell : path - , t: [Array, String] - , tag : String - , tar : String - , tmp : path - , "unsafe-perm" : Boolean - , usage : Boolean - , user : String - , username : String - , userconfig : path - , version : Boolean - , viewer: path - , _exit : Boolean - } - -; [["-v", {version:true}, []] - ,["---v", {version:true}, []] - ,["ls -s --no-reg connect -d", - {loglevel:"info",registry:null},["ls","connect"]] - ,["ls ---s foo",{loglevel:"silent"},["ls","foo"]] - ,["ls --registry blargle", {}, ["ls"]] - ,["--no-registry", {registry:null}, []] - ,["--no-color true", {color:false}, []] - ,["--no-color false", {color:true}, []] - ,["--no-color", {color:false}, []] - ,["--color false", {color:false}, []] - ,["--color --logfd 7", {logfd:7,color:true}, []] - ,["--color=true", {color:true}, []] - ,["--logfd=10", {logfd:10}, []] - ,["--tmp=/tmp -tar=gtar",{tmp:"/tmp",tar:"gtar"},[]] - ,["--tmp=tmp -tar=gtar", - {tmp:path.resolve(process.cwd(), "tmp"),tar:"gtar"},[]] - ,["--logfd x", {}, []] - ,["a -true -- -no-false", {true:true},["a","-no-false"]] - ,["a -no-false", {false:false},["a"]] - ,["a -no-no-true", {true:true}, ["a"]] - ,["a -no-no-no-false", {false:false}, ["a"]] - ,["---NO-no-No-no-no-no-nO-no-no"+ - "-No-no-no-no-no-no-no-no-no"+ - "-no-no-no-no-NO-NO-no-no-no-no-no-no"+ - "-no-body-can-do-the-boogaloo-like-I-do" - ,{"body-can-do-the-boogaloo-like-I-do":false}, []] - ,["we are -no-strangers-to-love "+ - "--you-know the-rules --and so-do-i "+ - "---im-thinking-of=a-full-commitment "+ - "--no-you-would-get-this-from-any-other-guy "+ - "--no-gonna-give-you-up "+ - "-no-gonna-let-you-down=true "+ - "--no-no-gonna-run-around false "+ - "--desert-you=false "+ - "--make-you-cry false "+ - "--no-tell-a-lie "+ - "--no-no-and-hurt-you false" - ,{"strangers-to-love":false - ,"you-know":"the-rules" - ,"and":"so-do-i" - ,"you-would-get-this-from-any-other-guy":false - ,"gonna-give-you-up":false - ,"gonna-let-you-down":false - ,"gonna-run-around":false - ,"desert-you":false - ,"make-you-cry":false - ,"tell-a-lie":false - ,"and-hurt-you":false - },["we", "are"]] - ,["-t one -t two -t three" - ,{t: ["one", "two", "three"]} - ,[]] - ,["-t one -t null -t three four five null" - ,{t: ["one", "null", "three"]} - ,["four", "five", "null"]] - ,["-t foo" - ,{t:["foo"]} - ,[]] - ,["--no-t" - ,{t:["false"]} - ,[]] - ,["-no-no-t" - ,{t:["true"]} - ,[]] - ,["-aoa one -aoa null -aoa 100" - ,{aoa:["one", null, 100]} - ,[]] - ,["-str 100" - ,{str:"100"} - ,[]] - ,["--color always" - ,{color:"always"} - ,[]] - ,["--no-nullstream" - ,{nullstream:null} - ,[]] - ,["--nullstream false" - ,{nullstream:null} - ,[]] - ,["--notadate 2011-01-25" - ,{notadate: "2011-01-25"} - ,[]] - ,["--date 2011-01-25" - ,{date: new Date("2011-01-25")} - ,[]] - ].forEach(function (test) { - var argv = test[0].split(/\s+/) - , opts = test[1] - , rem = test[2] - , actual = nopt(types, shorthands, argv, 0) - , parsed = actual.argv - delete actual.argv - console.log(util.inspect(actual, false, 2, true), parsed.remain) - for (var i in opts) { - var e = JSON.stringify(opts[i]) - , a = JSON.stringify(actual[i] === undefined ? null : actual[i]) - if (e && typeof e === "object") { - assert.deepEqual(e, a) - } else { - assert.equal(e, a) - } - } - assert.deepEqual(rem, parsed.remain) - }) -} diff --git a/node_modules/tap/node_modules/nopt/node_modules/abbrev/README.md b/node_modules/tap/node_modules/nopt/node_modules/abbrev/README.md deleted file mode 100644 index 99746fe67..000000000 --- a/node_modules/tap/node_modules/nopt/node_modules/abbrev/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# abbrev-js - -Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev). - -Usage: - - var abbrev = require("abbrev"); - abbrev("foo", "fool", "folding", "flop"); - - // returns: - { fl: 'flop' - , flo: 'flop' - , flop: 'flop' - , fol: 'folding' - , fold: 'folding' - , foldi: 'folding' - , foldin: 'folding' - , folding: 'folding' - , foo: 'foo' - , fool: 'fool' - } - -This is handy for command-line scripts, or other cases where you want to be able to accept shorthands. diff --git a/node_modules/tap/node_modules/nopt/node_modules/abbrev/lib/abbrev.js b/node_modules/tap/node_modules/nopt/node_modules/abbrev/lib/abbrev.js deleted file mode 100644 index 037de2d8d..000000000 --- a/node_modules/tap/node_modules/nopt/node_modules/abbrev/lib/abbrev.js +++ /dev/null @@ -1,106 +0,0 @@ - -module.exports = exports = abbrev.abbrev = abbrev - -abbrev.monkeyPatch = monkeyPatch - -function monkeyPatch () { - Array.prototype.abbrev = function () { return abbrev(this) } - Object.prototype.abbrev = function () { return abbrev(Object.keys(this)) } -} - -function abbrev (list) { - if (arguments.length !== 1 || !Array.isArray(list)) { - list = Array.prototype.slice.call(arguments, 0) - } - for (var i = 0, l = list.length, args = [] ; i < l ; i ++) { - args[i] = typeof list[i] === "string" ? list[i] : String(list[i]) - } - - // sort them lexicographically, so that they're next to their nearest kin - args = args.sort(lexSort) - - // walk through each, seeing how much it has in common with the next and previous - var abbrevs = {} - , prev = "" - for (var i = 0, l = args.length ; i < l ; i ++) { - var current = args[i] - , next = args[i + 1] || "" - , nextMatches = true - , prevMatches = true - if (current === next) continue - for (var j = 0, cl = current.length ; j < cl ; j ++) { - var curChar = current.charAt(j) - nextMatches = nextMatches && curChar === next.charAt(j) - prevMatches = prevMatches && curChar === prev.charAt(j) - if (nextMatches || prevMatches) continue - else { - j ++ - break - } - } - prev = current - if (j === cl) { - abbrevs[current] = current - continue - } - for (var a = current.substr(0, j) ; j <= cl ; j ++) { - abbrevs[a] = current - a += current.charAt(j) - } - } - return abbrevs -} - -function lexSort (a, b) { - return a === b ? 0 : a > b ? 1 : -1 -} - - -// tests -if (module === require.main) { - -var assert = require("assert") - , sys -sys = require("util") - -console.log("running tests") -function test (list, expect) { - var actual = abbrev(list) - assert.deepEqual(actual, expect, - "abbrev("+sys.inspect(list)+") === " + sys.inspect(expect) + "\n"+ - "actual: "+sys.inspect(actual)) - actual = abbrev.apply(exports, list) - assert.deepEqual(abbrev.apply(exports, list), expect, - "abbrev("+list.map(JSON.stringify).join(",")+") === " + sys.inspect(expect) + "\n"+ - "actual: "+sys.inspect(actual)) -} - -test([ "ruby", "ruby", "rules", "rules", "rules" ], -{ rub: 'ruby' -, ruby: 'ruby' -, rul: 'rules' -, rule: 'rules' -, rules: 'rules' -}) -test(["fool", "foom", "pool", "pope"], -{ fool: 'fool' -, foom: 'foom' -, poo: 'pool' -, pool: 'pool' -, pop: 'pope' -, pope: 'pope' -}) -test(["a", "ab", "abc", "abcd", "abcde", "acde"], -{ a: 'a' -, ab: 'ab' -, abc: 'abc' -, abcd: 'abcd' -, abcde: 'abcde' -, ac: 'acde' -, acd: 'acde' -, acde: 'acde' -}) - -console.log("pass") - -} diff --git a/node_modules/tap/node_modules/nopt/node_modules/abbrev/package.json b/node_modules/tap/node_modules/nopt/node_modules/abbrev/package.json deleted file mode 100644 index ebd082f5d..000000000 --- a/node_modules/tap/node_modules/nopt/node_modules/abbrev/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ "name" : "abbrev" -, "version" : "1.0.3" -, "description" : "Like ruby's abbrev module, but in js" -, "author" : "Isaac Z. Schlueter " -, "main" : "./lib/abbrev.js" -, "scripts" : { "test" : "node lib/abbrev.js" } -, "repository" : "https://github.com/isaacs/abbrev-js" -} diff --git a/node_modules/tap/node_modules/nopt/package.json b/node_modules/tap/node_modules/nopt/package.json deleted file mode 100644 index d1118e399..000000000 --- a/node_modules/tap/node_modules/nopt/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ "name" : "nopt" -, "version" : "1.0.10" -, "description" : "Option parsing for Node, supporting types, shorthands, etc. Used by npm." -, "author" : "Isaac Z. Schlueter (http://blog.izs.me/)" -, "main" : "lib/nopt.js" -, "scripts" : { "test" : "node lib/nopt.js" } -, "repository" : "https://github.com/isaacs/nopt" -, "bin" : "./bin/nopt.js" -, "license" : - { "type" : "MIT" - , "url" : "https://github.com/isaacs/nopt/raw/master/LICENSE" } -, "dependencies" : { "abbrev" : "1" }} diff --git a/node_modules/tap/node_modules/runforcover/README.markdown b/node_modules/tap/node_modules/runforcover/README.markdown deleted file mode 100644 index 1e56ebd68..000000000 --- a/node_modules/tap/node_modules/runforcover/README.markdown +++ /dev/null @@ -1,56 +0,0 @@ -runforcover -====== - -Runforcover is a require-hook library that uses node-bunker to provide code coverage data -for your unit test library, whatever it might be. - -methods -======= -var runforcover = require('runforcover'); - -var coverage = runforcover.cover([RegExp | path]); -------- - -Attach runforcover to the global `require` object and patch `require.extensions['.js']` to -provide coverage metadata for all files required after this point. Returns a function -object that can be called to obtain a object keying files to `CoverageData` objects, with -a method for releasing control back to vanilla `require`. Usage: - -````javascript - -var coverage = runforcover.cover(/.*/g); - -require('some/library'); - -coverage(function(coverageData) { - // coverageData is an object keyed by filename. - var stats = coverageData['/full/path/to/file.js'].stats() - - // the percentage of lines run versus total lines in file - console.log(stats.percentage); - - // the number of missing lines - console.log(stats.missing); - - // the number of lines run (seen) - console.log(stats.seen); - - // an array of line objects representing 'missed' lines - stats.lines; - - stats.lines.forEach(function(line) { - // the line number of the line: - console.log(line.number); - - // returns a string containing the source data for the line: - console.log(line.source()); - }); - - // return control back to the original require function - coverage.release(); -}); -```` - -license -======= -new BSD. diff --git a/node_modules/tap/node_modules/runforcover/index.js b/node_modules/tap/node_modules/runforcover/index.js deleted file mode 100644 index b5318ac66..000000000 --- a/node_modules/tap/node_modules/runforcover/index.js +++ /dev/null @@ -1,127 +0,0 @@ -var bunker = require('bunker'), - Module = require('module').Module, - path = require('path'), - fs = require('fs'), - vm = require('vm'); - -function CoverageData (filename, bunker) { - this.bunker = bunker; - this.filename = filename; - this.nodes = {}; -}; - -CoverageData.prototype.visit = function(node) { - ++(this.nodes[node.id] = this.nodes[node.id] || {node:node, count:0}).count; -}; - -CoverageData.prototype.missing = function() { - var nodes = this.nodes, - missing = this.bunker.nodes.filter(function(node) { - return !nodes[node.id]; - }); - - return missing; -}; - -CoverageData.prototype.stats = function() { - var missing = this.missing(), - filedata = fs.readFileSync(this.filename, 'utf8').split('\n'); - - var seenLines = [], - lines = - missing.sort(function(lhs, rhs) { - return lhs.node[0].start.line < rhs.node[0].start.line ? -1 : - lhs.node[0].start.line > rhs.node[0].start.line ? 1 : - 0; - }).filter(function(node) { - - var okay = (seenLines.indexOf(node.node[0].start.line) < 0); - if(okay) - seenLines.push(node.node[0].start.line); - return okay; - - }).map(function(node, idx, all) { - return { - lineno:node.node[0].start.line + 1, - source:function() { return filedata[node.node[0].start.line]; } - }; - }); - - return { - percentage:(filedata.length-seenLines.length)/filedata.length, - lines:lines, - missing:seenLines.length, - seen:(filedata.length-seenLines.length) - }; -}; - -module.exports.createEnvironment = function(module, filename) { - var req = function(path) { - return Module._load(path, module); - }; - req.resolve = function(request) { - return Module._resolveFilename(request, module)[1]; - } - req.paths = Module._paths; - req.main = process.mainModule; - req.extensions = Module._extensions; - req.registerExtension = function() { - throw new Error('require.registerExtension() removed. Use ' + - 'require.extensions instead.'); - } - require.cache = Module._cache; - - var ctxt = {}; - for(var k in global) - ctxt[k] = global[k]; - - ctxt.require = req; - ctxt.exports = module.exports; - ctxt.__filename = filename; - ctxt.__dirname = path.dirname(filename); - ctxt.process = process; - ctxt.console = console; - ctxt.module = module; - ctxt.global = ctxt; - - return ctxt; -}; - -module.exports.cover = function(fileRegex) { - var originalRequire = require.extensions['.js'], - coverageData = {}, - match = fileRegex instanceof RegExp ? - fileRegex : new RegExp( - fileRegex ? fileRegex.replace(/\//g, '\\/').replace(/\./g, '\\.') : '.*' - , 'g'), - target = this; - - require.extensions['.js'] = function(module, filename) { - if(!match.test(filename)) return originalRequire(module, filename); - - var context = target.createEnvironment(module, filename), - data = fs.readFileSync(filename, 'utf8'), - bunkerized = bunker(data), - coverage = coverageData[filename] = new CoverageData(filename, bunkerized); - - bunkerized.on('node', coverage.visit.bind(coverage)); - bunkerized.assign(context); - - var wrapper = '(function(ctxt) { with(ctxt) { return '+Module.wrap(bunkerized.compile())+'; } })', - compiledWrapper = vm.runInThisContext(wrapper, filename, true)(context); - - var args = [context.exports, context.require, module, filename, context.__dirname]; - return compiledWrapper.apply(module.exports, args); - }; - - var retval = function(ready) { - ready(coverageData); - }; - - retval.release = function() { - require.extensions['.js'] = originalRequire; - }; - - return retval; -}; - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/.npmignore b/node_modules/tap/node_modules/runforcover/node_modules/bunker/.npmignore deleted file mode 100644 index 3c3629e64..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/README.markdown b/node_modules/tap/node_modules/runforcover/node_modules/bunker/README.markdown deleted file mode 100644 index e11e72a14..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/README.markdown +++ /dev/null @@ -1,80 +0,0 @@ -bunker -====== - -Bunker is a module to calculate code coverage using native javascript -[burrito](https://github.com/substack/node-burrito) AST trickery. - -![code coverage](http://substack.net/images/code_coverage.png) - -examples -======== - -tiny ----- - -````javascript -var bunker = require('bunker'); -var b = bunker('var x = 0; for (var i = 0; i < 30; i++) { x++ }'); - -var counts = {}; - -b.on('node', function (node) { - if (!counts[node.id]) { - counts[node.id] = { times : 0, node : node }; - } - counts[node.id].times ++; -}); - -b.run(); - -Object.keys(counts).forEach(function (key) { - var count = counts[key]; - console.log(count.times + ' : ' + count.node.source()); -}); -```` - -output: - - $ node example/tiny.js - 1 : var x=0; - 31 : i<30 - 30 : i++ - 30 : x++; - 30 : x++ - -methods -======= - -var bunker = require('bunker'); - -var b = bunker(src) -------------------- - -Create a new bunker code coverageifier with some source `src`. - -The bunker object `b` is an `EventEmitter` that emits `'node'` events with two -parameters: - -* `node` - the [burrito](https://github.com/substack/node-burrito) node object -* `stack` - the stack, [stackedy](https://github.com/substack/node-stackedy) style - -b.include(src) --------------- - -Include some source into the bunker. - -b.compile() ------------ - -Return the source wrapped with burrito. - -b.assign(context={}) --------------------- - -Assign the statement-tracking functions into `context`. - -b.run(context={}) ------------------ - -Run the source using `vm.runInNewContext()` with some `context`. -The statement-tracking functions will be added to `context` by `assign()`. diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/prof.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/prof.js deleted file mode 100644 index 5cac4ccc2..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/prof.js +++ /dev/null @@ -1,51 +0,0 @@ -var bunker = require('bunker'); -var b = bunker('(' + function () { - function beep () { - var x = 0; - for (var i = 0; i < 1000; i++) { - for (var j = 0; j < 100; j++) { - x += j; - } - } - return x; - } - - beep(); - -} + ')()'); - -var counts = {}; - -b.on('node', function (node) { - if (!counts[node.id]) { - counts[node.id] = { times : 0, node : node, elapsed : 0 }; - } - counts[node.id].times ++; - - var now = Date.now(); - - if (last.id !== undefined) { - counts[last.id].elapsed += last. - } - - if (node.name === 'call') { - var start = now; - - last.id = node.id; - counts[node.id].elapsed += Date.now() - start; - } - else { - counts[node.id].elapsed += now - last; - last = now; - } -}); - -b.run(); - -Object.keys(counts).forEach(function (key) { - var count = counts[key]; - console.log( - [ count.times, count.node.source(), count.elapsed ] - .join(' : ') - ); -}); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/tiny.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/tiny.js deleted file mode 100644 index aa5b034a4..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/tiny.js +++ /dev/null @@ -1,18 +0,0 @@ -var bunker = require('bunker'); -var b = bunker('var x = 0; for (var i = 0; i < 30; i++) { x++ }'); - -var counts = {}; - -b.on('node', function (node) { - if (!counts[node.id]) { - counts[node.id] = { times : 0, node : node }; - } - counts[node.id].times ++; -}); - -b.run(); - -Object.keys(counts).forEach(function (key) { - var count = counts[key]; - console.log(count.times + ' : ' + count.node.source()); -}); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/run.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/run.js deleted file mode 100644 index d9eaa1055..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/run.js +++ /dev/null @@ -1,31 +0,0 @@ -var bunker = require('bunker'); -var fs = require('fs'); -var src = fs.readFileSync(__dirname + '/src.js', 'utf8'); - -var counts = {}; - -var b = bunker(src); -b.on('node', function (node) { - if (!counts[node.id]) { - counts[node.id] = { times : 0, node : node }; - } - counts[node.id].times ++; -}); - -b.run({ - setInterval : setInterval, - clearInterval : clearInterval, - end : function () { - Object.keys(counts) - .sort(function (a, b) { - return counts[b].times - counts[a].times - }) - .forEach(function (key) { - var count = counts[key]; - console.log( - count.times + ' : ' + count.node.source() - ); - }) - ; - } -}); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/src.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/src.js deleted file mode 100644 index 0c92e4811..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/example/top/src.js +++ /dev/null @@ -1,18 +0,0 @@ -function boop () { - for (var i = 0; i < 30; i++) { - nop(); - } -} - -function nop () { - return undefined; -} - -var times = 0; -var iv = setInterval(function () { - if (++times === 10) { - clearInterval(iv); - end(); - } - else boop() -}, 100); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/index.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/index.js deleted file mode 100644 index db4fdb798..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/index.js +++ /dev/null @@ -1,101 +0,0 @@ -var burrito = require('burrito'); -var vm = require('vm'); -var EventEmitter = require('events').EventEmitter; - -module.exports = function (src) { - var b = new Bunker(); - if (src) b.include(src); - return b; -}; - -function Bunker () { - this.sources = []; - this.nodes = []; - - this.names = { - call : burrito.generateName(6), - expr : burrito.generateName(6), - stat : burrito.generateName(6) - }; -} - -Bunker.prototype = new EventEmitter; - -Bunker.prototype.include = function (src) { - this.sources.push(src); - this.source = null; - return this; -}; - -Bunker.prototype.compile = function () { - var src = this.sources.join('\n'); - var nodes = this.nodes; - var names = this.names; - - return burrito(src, function (node) { - var i = nodes.length; - - if (node.name === 'call') { - nodes.push(node); - node.wrap(names.call + '(' + i + ')(%s)'); - } - else if (node.name === 'stat' || node.name === 'throw' - || node.name === 'var') { - nodes.push(node); - node.wrap('{' + names.stat + '(' + i + ');%s}'); - } - else if (node.name === 'binary') { - nodes.push(node); - node.wrap(names.expr + '(' + i + ')(%s)'); - } - else if (node.name === 'unary-postfix' || node.name === 'unary-prefix') { - nodes.push(node); - node.wrap(names.expr + '(' + i + ')(%s)'); - } - - if (i !== nodes.length) { - node.id = i; - } - }); -}; - -Bunker.prototype.assign = function (context) { - if (!context) context = {}; - - var self = this; - var stack = []; - - context[self.names.call] = function (i) { - var node = self.nodes[i]; - stack.unshift(node); - self.emit('node', node, stack); - - return function (expr) { - stack.shift(); - return expr; - }; - }; - - context[self.names.expr] = function (i) { - var node = self.nodes[i]; - self.emit('node', node, stack); - - return function (expr) { - return expr; - }; - }; - - context[self.names.stat] = function (i) { - var node = self.nodes[i]; - self.emit('node', node, stack); - }; - - return context; -}; - -Bunker.prototype.run = function (context) { - var src = this.compile(); - vm.runInNewContext(src, this.assign(context)); - - return this; -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.npmignore b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.npmignore deleted file mode 100644 index 3c3629e64..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/README.markdown b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/README.markdown deleted file mode 100644 index 5c32cd29d..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/README.markdown +++ /dev/null @@ -1,185 +0,0 @@ -burrito -======= - -Burrito makes it easy to do crazy stuff with the javascript AST. - -This is super useful if you want to roll your own stack traces or build a code -coverage tool. - -![node.wrap("burrito")](http://substack.net/images/burrito.png) - -examples -======== - -microwave ---------- - -examples/microwave.js - -````javascript -var burrito = require('burrito'); - -var res = burrito.microwave('Math.sin(2)', function (node) { - if (node.name === 'num') node.wrap('Math.PI / %s'); -}); - -console.log(res); // sin(pi / 2) == 1 -```` - -output: - - 1 - -wrap ----- - -examples/wrap.js - -````javascript -var burrito = require('burrito'); - -var src = burrito('f() && g(h())\nfoo()', function (node) { - if (node.name === 'call') node.wrap('qqq(%s)'); -}); - -console.log(src); -```` - -output: - - qqq(f()) && qqq(g(qqq(h()))); - - qqq(foo()); - -methods -======= - - var burrito = require('burrito'); - -burrito(code, cb) ------------------ - -Given some source `code` and a function `trace`, walk the ast by expression. - -The `cb` gets called with a node object described below. - -If `code` is an Array then it is assumbed to be an AST which you can generate -yourself with `burrito.parse()`. The AST must be annotated, so make sure to -`burrito.parse(src, false, true)`. - -burrito.microwave(code, context={}, cb) ---------------------------------------- - -Like `burrito()` except the result is run using -`vm.runInNewContext(res, context)`. - -node object -=========== - -node.name ---------- - -Name is a string that contains the type of the expression as named by uglify. - -node.wrap(s) ------------- - -Wrap the current expression in `s`. - -If `s` is a string, `"%s"` will be replaced with the stringified current -expression. - -If `s` is a function, it is called with the stringified current expression and -should return a new stringified expression. - -If the `node.name === "binary"`, you get the subterms "%a" and "%b" to play with -too. These subterms are applied if `s` is a function too: `s(expr, a, b)`. - -Protip: to insert multiple statements you can use javascript's lesser-known block -syntax that it gets from C: - -````javascript -if (node.name === 'stat') node.wrap('{ foo(); %s }') -```` - -node.node ---------- - -raw ast data generated by uglify - -node.value ----------- - -`node.node.slice(1)` to skip the annotations - -node.start ----------- - -The start location of the expression, like this: - -````javascript -{ type: 'name', - value: 'b', - line: 0, - col: 3, - pos: 3, - nlb: false, - comments_before: [] } -```` - -node.end --------- - -The end location of the expression, formatted the same as `node.start`. - -node.state ----------- - -The state of the traversal using traverse. - -node.source() -------------- - -Returns a stringified version of the expression. - -node.parent() -------------- - -Returns the parent `node` or `null` if the node is the root element. - -node.label() ------------- - -Return the label of the present node or `null` if there is no label. - -Labels are returned for "call", "var", "defun", and "function" nodes. - -Returns an array for "var" nodes since `var` statements can -contain multiple labels in assignment. - -install -======= - -With [npm](http://npmjs.org) you can just: - - npm install burrito - -in the browser -============== - -Burrito works in browser with -[browserify](https://github.com/substack/node-browserify). - -It has been tested against: - -* Internet Explorer 5.5, 6.0, 7.0, 8.0, 9.0 -* Firefox 3.5 -* Chrome 6.0 -* Opera 10.6 -* Safari 5.0 - -kudos -===== - -Heavily inspired by (and previously mostly lifted outright from) isaacs's nifty -tmp/instrument.js thingy from uglify-js. diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/browserify.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/browserify.js deleted file mode 100644 index e2b847a47..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/browserify.js +++ /dev/null @@ -1,4296 +0,0 @@ -var require = function (file, cwd) { - var resolved = require.resolve(file, cwd || '/'); - var mod = require.modules[resolved]; - if (!mod) throw new Error( - 'Failed to resolve module ' + file + ', tried ' + resolved - ); - var res = mod._cached ? mod._cached : mod(); - return res; -} -var __require = require; - -require.paths = []; -require.modules = {}; -require.extensions = [".js",".coffee"]; - -require.resolve = (function () { - var core = { - 'assert': true, - 'events': true, - 'fs': true, - 'path': true, - 'vm': true - }; - - return function (x, cwd) { - if (!cwd) cwd = '/'; - - if (core[x]) return x; - var path = require.modules.path(); - var y = cwd || '.'; - - if (x.match(/^(?:\.\.?\/|\/)/)) { - var m = loadAsFileSync(path.resolve(y, x)) - || loadAsDirectorySync(path.resolve(y, x)); - if (m) return m; - } - - var n = loadNodeModulesSync(x, y); - if (n) return n; - - throw new Error("Cannot find module '" + x + "'"); - - function loadAsFileSync (x) { - if (require.modules[x]) { - return x; - } - - for (var i = 0; i < require.extensions.length; i++) { - var ext = require.extensions[i]; - if (require.modules[x + ext]) return x + ext; - } - } - - function loadAsDirectorySync (x) { - x = x.replace(/\/+$/, ''); - var pkgfile = x + '/package.json'; - if (require.modules[pkgfile]) { - var pkg = require.modules[pkgfile](); - var b = pkg.browserify; - if (typeof b === 'object' && b.main) { - var m = loadAsFileSync(path.resolve(x, b.main)); - if (m) return m; - } - else if (typeof b === 'string') { - var m = loadAsFileSync(path.resolve(x, b)); - if (m) return m; - } - else if (pkg.main) { - var m = loadAsFileSync(path.resolve(x, pkg.main)); - if (m) return m; - } - } - - return loadAsFileSync(x + '/index'); - } - - function loadNodeModulesSync (x, start) { - var dirs = nodeModulesPathsSync(start); - for (var i = 0; i < dirs.length; i++) { - var dir = dirs[i]; - var m = loadAsFileSync(dir + '/' + x); - if (m) return m; - var n = loadAsDirectorySync(dir + '/' + x); - if (n) return n; - } - - var m = loadAsFileSync(x); - if (m) return m; - } - - function nodeModulesPathsSync (start) { - var parts; - if (start === '/') parts = [ '' ]; - else parts = path.normalize(start).split('/'); - - var dirs = []; - for (var i = parts.length - 1; i >= 0; i--) { - if (parts[i] === 'node_modules') continue; - var dir = parts.slice(0, i + 1).join('/') + '/node_modules'; - dirs.push(dir); - } - - return dirs; - } - }; -})(); - -require.alias = function (from, to) { - var path = require.modules.path(); - var res = null; - try { - res = require.resolve(from + '/package.json', '/'); - } - catch (err) { - res = require.resolve(from, '/'); - } - var basedir = path.dirname(res); - - var keys = Object_keys(require.modules); - - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (key.slice(0, basedir.length + 1) === basedir + '/') { - var f = key.slice(basedir.length); - require.modules[to + f] = require.modules[basedir + f]; - } - else if (key === basedir) { - require.modules[to] = require.modules[basedir]; - } - } -}; - -var Object_keys = Object.keys || function (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -if (typeof process === 'undefined') process = {}; - -if (!process.nextTick) process.nextTick = function (fn) { - setTimeout(fn, 0); -}; - -if (!process.title) process.title = 'browser'; - -if (!process.binding) process.binding = function (name) { - if (name === 'evals') return require('vm') - else throw new Error('No such module') -}; - -if (!process.cwd) process.cwd = function () { return '.' }; - -require.modules["path"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "."; - var __filename = "path"; - - var require = function (file) { - return __require(file, "."); - }; - - require.resolve = function (file) { - return __require.resolve(name, "."); - }; - - require.modules = __require.modules; - __require.modules["path"]._cached = module.exports; - - (function () { - function filter (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - if (fn(xs[i], i, xs)) res.push(xs[i]); - } - return res; -} - -// resolves . and .. elements in a path array with directory names there -// must be no slashes, empty elements, or device names (c:\) in the array -// (so also no leading and trailing slashes - it does not distinguish -// relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = parts.length; i >= 0; i--) { - var last = parts[i]; - if (last == '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); - } - } - - return parts; -} - -// Regex to split a filename into [*, dir, basename, ext] -// posix version -var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/; - -// path.resolve([from ...], to) -// posix version -exports.resolve = function() { -var resolvedPath = '', - resolvedAbsolute = false; - -for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) { - var path = (i >= 0) - ? arguments[i] - : process.cwd(); - - // Skip empty and invalid entries - if (typeof path !== 'string' || !path) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charAt(0) === '/'; -} - -// At this point the path should be resolved to a full absolute path, but -// handle relative paths to be safe (might happen when process.cwd() fails) - -// Normalize the path -resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { - return !!p; - }), !resolvedAbsolute).join('/'); - - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; -}; - -// path.normalize(path) -// posix version -exports.normalize = function(path) { -var isAbsolute = path.charAt(0) === '/', - trailingSlash = path.slice(-1) === '/'; - -// Normalize the path -path = normalizeArray(filter(path.split('/'), function(p) { - return !!p; - }), !isAbsolute).join('/'); - - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } - - return (isAbsolute ? '/' : '') + path; -}; - - -// posix version -exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(filter(paths, function(p, index) { - return p && typeof p === 'string'; - }).join('/')); -}; - - -exports.dirname = function(path) { - var dir = splitPathRe.exec(path)[1] || ''; - var isWindows = false; - if (!dir) { - // No dirname - return '.'; - } else if (dir.length === 1 || - (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) { - // It is just a slash or a drive letter with a slash - return dir; - } else { - // It is a full dirname, strip trailing slash - return dir.substring(0, dir.length - 1); - } -}; - - -exports.basename = function(path, ext) { - var f = splitPathRe.exec(path)[2] || ''; - // TODO: make this comparison case-insensitive on windows? - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); - } - return f; -}; - - -exports.extname = function(path) { - return splitPathRe.exec(path)[3] || ''; -}; -; - }).call(module.exports); - - __require.modules["path"]._cached = module.exports; - return module.exports; -}; - -require.modules["/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/"; - var __filename = "/package.json"; - - var require = function (file) { - return __require(file, "/"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/"); - }; - - require.modules = __require.modules; - __require.modules["/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"burrito","description":"Wrap up expressions with a trace function while walking the AST with rice and beans on the side","version":"0.2.7","repository":{"type":"git","url":"git://github.com/substack/node-burrito.git"},"main":"./index.js","keywords":["trace","ast","walk","syntax","source","tree","uglify"],"directories":{"lib":".","example":"example","test":"test"},"scripts":{"test":"expresso"},"dependencies":{"traverse":"0.5.x","uglify-js":"1.0.4"},"devDependencies":{"expresso":"=0.7.x"},"engines":{"node":">=0.4.0"},"license":"BSD","author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"}}; - }).call(module.exports); - - __require.modules["/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/index.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/"; - var __filename = "/index.js"; - - var require = function (file) { - return __require(file, "/"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/"); - }; - - require.modules = __require.modules; - __require.modules["/index.js"]._cached = module.exports; - - (function () { - var uglify = require('uglify-js'); -var parser = uglify.parser; -var parse = function (expr) { - if (typeof expr !== 'string') throw 'expression should be a string'; - - try { - var ast = parser.parse.apply(null, arguments); - } - catch (err) { - if (err.message === undefined - || err.line === undefined - || err.col === undefined - || err.pos === undefined - ) { throw err } - - var e = new SyntaxError( - err.message - + '\n at line ' + err.line + ':' + err.col + ' in expression:\n\n' - + ' ' + expr.split(/\r?\n/)[err.line] - ); - - e.original = err; - e.line = err.line; - e.col = err.col; - e.pos = err.pos; - throw e; - } - return ast; -}; - -var deparse = function (ast, b) { - return uglify.uglify.gen_code(ast, { beautify : b }); -}; - -var traverse = require('traverse'); -var vm = require('vm'); - -var burrito = module.exports = function (code, cb) { - var ast = Array_isArray(code) - ? code // already an ast - : parse(code.toString(), false, true) - ; - - var ast_ = traverse(ast).map(function mapper () { - wrapNode(this, cb); - }); - - return deparse(parse(deparse(ast_)), true); -}; - -var wrapNode = burrito.wrapNode = function (state, cb) { - var node = state.node; - - var ann = Array_isArray(node) && node[0] - && typeof node[0] === 'object' && node[0].name - ? node[0] - : null - ; - - if (!ann) return undefined; - - var self = { - name : ann.name, - node : node, - start : node[0].start, - end : node[0].end, - value : node.slice(1), - state : state - }; - - self.wrap = function (s) { - var subsrc = deparse( - traverse(node).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - }) - ); - - if (self.name === 'binary') { - var a = deparse(traverse(node[2]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - var b = deparse(traverse(node[3]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - } - - var src = ''; - - if (typeof s === 'function') { - if (self.name === 'binary') { - src = s(subsrc, a, b); - } - else { - src = s(subsrc); - } - } - else { - src = s.toString() - .replace(/undefined/g, function () { - return subsrc - }) - ; - - if (self.name === 'binary') { - src = src - .replace(/%a/g, function () { return a }) - .replace(/%b/g, function () { return b }) - ; - } - } - - var expr = parse(src); - state.update(expr, true); - }; - - var cache = {}; - - self.parent = state.isRoot ? null : function () { - if (!cache.parent) { - var s = state; - var x; - do { - s = s.parent; - if (s) x = wrapNode(s); - } while (s && !x); - - cache.parent = x; - } - - return cache.parent; - }; - - self.source = function () { - if (!cache.source) cache.source = deparse(node); - return cache.source; - }; - - self.label = function () { - return burrito.label(self); - }; - - if (cb) cb.call(state, self); - - if (self.node[0].name === 'conditional') { - self.wrap('[undefined][0]'); - } - - return self; -} - -burrito.microwave = function (code, context, cb) { - if (!cb) { cb = context; context = {} }; - if (!context) context = {}; - - var src = burrito(code, cb); - return vm.runInNewContext(src, context); -}; - -burrito.generateName = function (len) { - var name = ''; - var lower = '$'.charCodeAt(0); - var upper = 'z'.charCodeAt(0); - - while (name.length < len) { - var c = String.fromCharCode(Math.floor( - Math.random() * (upper - lower + 1) + lower - )); - if ((name + c).match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) name += c; - } - - return name; -}; - -burrito.parse = parse; -burrito.deparse = deparse; - -burrito.label = function (node) { - if (node.name === 'call') { - if (typeof node.value[0] === 'string') { - return node.value[0]; - } - else if (node.value[0] && typeof node.value[0][1] === 'string') { - return node.value[0][1]; - } - else { - return null; - } - } - else if (node.name === 'var') { - return node.value[0].map(function (x) { return x[0] }); - } - else if (node.name === 'defun') { - return node.value[0]; - } - else if (node.name === 'function') { - return node.value[0]; - } - else { - return null; - } -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; -; - }).call(module.exports); - - __require.modules["/index.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/uglify-js/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/uglify-js"; - var __filename = "/node_modules/uglify-js/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/uglify-js"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/uglify-js"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/uglify-js/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"uglify-js","author":{"name":"Mihai Bazon","email":"mihai.bazon@gmail.com","url":"http://mihai.bazon.net/blog"},"version":"1.0.4","main":"./uglify-js.js","bin":{"uglifyjs":"./bin/uglifyjs"},"repository":{"type":"git","url":"git@github.com:mishoo/UglifyJS.git"}}; - }).call(module.exports); - - __require.modules["/node_modules/uglify-js/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/uglify-js/uglify-js.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/uglify-js"; - var __filename = "/node_modules/uglify-js/uglify-js.js"; - - var require = function (file) { - return __require(file, "/node_modules/uglify-js"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/uglify-js"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/uglify-js/uglify-js.js"]._cached = module.exports; - - (function () { - //convienence function(src, [options]); -function uglify(orig_code, options){ - options || (options = {}); - var jsp = uglify.parser; - var pro = uglify.uglify; - - var ast = jsp.parse(orig_code, options.strict_semicolons); // parse code and get the initial AST - ast = pro.ast_mangle(ast, options.mangle_options); // get a new AST with mangled names - ast = pro.ast_squeeze(ast, options.squeeze_options); // get an AST with compression optimizations - var final_code = pro.gen_code(ast, options.gen_options); // compressed code here - return final_code; -}; - -uglify.parser = require("./lib/parse-js"); -uglify.uglify = require("./lib/process"); - -module.exports = uglify; - }).call(module.exports); - - __require.modules["/node_modules/uglify-js/uglify-js.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/uglify-js/lib/parse-js.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/uglify-js/lib"; - var __filename = "/node_modules/uglify-js/lib/parse-js.js"; - - var require = function (file) { - return __require(file, "/node_modules/uglify-js/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/uglify-js/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/uglify-js/lib/parse-js.js"]._cached = module.exports; - - (function () { - /*********************************************************************** - - A JavaScript tokenizer / parser / beautifier / compressor. - - This version is suitable for Node.js. With minimal changes (the - exports stuff) it should work on any JS platform. - - This file contains the tokenizer/parser. It is a port to JavaScript - of parse-js [1], a JavaScript parser library written in Common Lisp - by Marijn Haverbeke. Thank you Marijn! - - [1] http://marijn.haverbeke.nl/parse-js/ - - Exported functions: - - - tokenizer(code) -- returns a function. Call the returned - function to fetch the next token. - - - parse(code) -- returns an AST of the given JavaScript code. - - -------------------------------- (C) --------------------------------- - - Author: Mihai Bazon - - http://mihai.bazon.net/blog - - Distributed under the BSD license: - - Copyright 2010 (c) Mihai Bazon - Based on parse-js (http://marijn.haverbeke.nl/parse-js/). - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - - ***********************************************************************/ - -/* -----[ Tokenizer (constants) ]----- */ - -var KEYWORDS = array_to_hash([ - "break", - "case", - "catch", - "const", - "continue", - "default", - "delete", - "do", - "else", - "finally", - "for", - "function", - "if", - "in", - "instanceof", - "new", - "return", - "switch", - "throw", - "try", - "typeof", - "var", - "void", - "while", - "with" -]); - -var RESERVED_WORDS = array_to_hash([ - "abstract", - "boolean", - "byte", - "char", - "class", - "debugger", - "double", - "enum", - "export", - "extends", - "final", - "float", - "goto", - "implements", - "import", - "int", - "interface", - "long", - "native", - "package", - "private", - "protected", - "public", - "short", - "static", - "super", - "synchronized", - "throws", - "transient", - "volatile" -]); - -var KEYWORDS_BEFORE_EXPRESSION = array_to_hash([ - "return", - "new", - "delete", - "throw", - "else", - "case" -]); - -var KEYWORDS_ATOM = array_to_hash([ - "false", - "null", - "true", - "undefined" -]); - -var OPERATOR_CHARS = array_to_hash(characters("+-*&%=<>!?|~^")); - -var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i; -var RE_OCT_NUMBER = /^0[0-7]+$/; -var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i; - -var OPERATORS = array_to_hash([ - "in", - "instanceof", - "typeof", - "new", - "void", - "delete", - "++", - "--", - "+", - "-", - "!", - "~", - "&", - "|", - "^", - "*", - "/", - "%", - ">>", - "<<", - ">>>", - "<", - ">", - "<=", - ">=", - "==", - "===", - "!=", - "!==", - "?", - "=", - "+=", - "-=", - "/=", - "*=", - "%=", - ">>=", - "<<=", - ">>>=", - "|=", - "^=", - "&=", - "&&", - "||" -]); - -var WHITESPACE_CHARS = array_to_hash(characters(" \u00a0\n\r\t\f\v\u200b")); - -var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:")); - -var PUNC_CHARS = array_to_hash(characters("[]{}(),;:")); - -var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy")); - -/* -----[ Tokenizer ]----- */ - -// regexps adapted from http://xregexp.com/plugins/#unicode -var UNICODE = { - letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"), - non_spacing_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"), - space_combining_mark: new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"), - connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]") -}; - -function is_letter(ch) { - return UNICODE.letter.test(ch); -}; - -function is_digit(ch) { - ch = ch.charCodeAt(0); - return ch >= 48 && ch <= 57; //XXX: find out if "UnicodeDigit" means something else than 0..9 -}; - -function is_alphanumeric_char(ch) { - return is_digit(ch) || is_letter(ch); -}; - -function is_unicode_combining_mark(ch) { - return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch); -}; - -function is_unicode_connector_punctuation(ch) { - return UNICODE.connector_punctuation.test(ch); -}; - -function is_identifier_start(ch) { - return ch == "$" || ch == "_" || is_letter(ch); -}; - -function is_identifier_char(ch) { - return is_identifier_start(ch) - || is_unicode_combining_mark(ch) - || is_digit(ch) - || is_unicode_connector_punctuation(ch) - || ch == "\u200c" // zero-width non-joiner - || ch == "\u200d" // zero-width joiner (in my ECMA-262 PDF, this is also 200c) - ; -}; - -function parse_js_number(num) { - if (RE_HEX_NUMBER.test(num)) { - return parseInt(num.substr(2), 16); - } else if (RE_OCT_NUMBER.test(num)) { - return parseInt(num.substr(1), 8); - } else if (RE_DEC_NUMBER.test(num)) { - return parseFloat(num); - } -}; - -function JS_Parse_Error(message, line, col, pos) { - this.message = message; - this.line = line; - this.col = col; - this.pos = pos; - try { - ({})(); - } catch(ex) { - this.stack = ex.stack; - }; -}; - -JS_Parse_Error.prototype.toString = function() { - return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack; -}; - -function js_error(message, line, col, pos) { - throw new JS_Parse_Error(message, line, col, pos); -}; - -function is_token(token, type, val) { - return token.type == type && (val == null || token.value == val); -}; - -var EX_EOF = {}; - -function tokenizer($TEXT) { - - var S = { - text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''), - pos : 0, - tokpos : 0, - line : 0, - tokline : 0, - col : 0, - tokcol : 0, - newline_before : false, - regex_allowed : false, - comments_before : [] - }; - - function peek() { return S.text.charAt(S.pos); }; - - function next(signal_eof) { - var ch = S.text.charAt(S.pos++); - if (signal_eof && !ch) - throw EX_EOF; - if (ch == "\n") { - S.newline_before = true; - ++S.line; - S.col = 0; - } else { - ++S.col; - } - return ch; - }; - - function eof() { - return !S.peek(); - }; - - function find(what, signal_eof) { - var pos = S.text.indexOf(what, S.pos); - if (signal_eof && pos == -1) throw EX_EOF; - return pos; - }; - - function start_token() { - S.tokline = S.line; - S.tokcol = S.col; - S.tokpos = S.pos; - }; - - function token(type, value, is_comment) { - S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) || - (type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) || - (type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value))); - var ret = { - type : type, - value : value, - line : S.tokline, - col : S.tokcol, - pos : S.tokpos, - nlb : S.newline_before - }; - if (!is_comment) { - ret.comments_before = S.comments_before; - S.comments_before = []; - } - S.newline_before = false; - return ret; - }; - - function skip_whitespace() { - while (HOP(WHITESPACE_CHARS, peek())) - next(); - }; - - function read_while(pred) { - var ret = "", ch = peek(), i = 0; - while (ch && pred(ch, i++)) { - ret += next(); - ch = peek(); - } - return ret; - }; - - function parse_error(err) { - js_error(err, S.tokline, S.tokcol, S.tokpos); - }; - - function read_num(prefix) { - var has_e = false, after_e = false, has_x = false, has_dot = prefix == "."; - var num = read_while(function(ch, i){ - if (ch == "x" || ch == "X") { - if (has_x) return false; - return has_x = true; - } - if (!has_x && (ch == "E" || ch == "e")) { - if (has_e) return false; - return has_e = after_e = true; - } - if (ch == "-") { - if (after_e || (i == 0 && !prefix)) return true; - return false; - } - if (ch == "+") return after_e; - after_e = false; - if (ch == ".") { - if (!has_dot && !has_x) - return has_dot = true; - return false; - } - return is_alphanumeric_char(ch); - }); - if (prefix) - num = prefix + num; - var valid = parse_js_number(num); - if (!isNaN(valid)) { - return token("num", valid); - } else { - parse_error("Invalid syntax: " + num); - } - }; - - function read_escaped_char() { - var ch = next(true); - switch (ch) { - case "n" : return "\n"; - case "r" : return "\r"; - case "t" : return "\t"; - case "b" : return "\b"; - case "v" : return "\v"; - case "f" : return "\f"; - case "0" : return "\0"; - case "x" : return String.fromCharCode(hex_bytes(2)); - case "u" : return String.fromCharCode(hex_bytes(4)); - default : return ch; - } - }; - - function hex_bytes(n) { - var num = 0; - for (; n > 0; --n) { - var digit = parseInt(next(true), 16); - if (isNaN(digit)) - parse_error("Invalid hex-character pattern in string"); - num = (num << 4) | digit; - } - return num; - }; - - function read_string() { - return with_eof_error("Unterminated string constant", function(){ - var quote = next(), ret = ""; - for (;;) { - var ch = next(true); - if (ch == "\\") ch = read_escaped_char(); - else if (ch == quote) break; - ret += ch; - } - return token("string", ret); - }); - }; - - function read_line_comment() { - next(); - var i = find("\n"), ret; - if (i == -1) { - ret = S.text.substr(S.pos); - S.pos = S.text.length; - } else { - ret = S.text.substring(S.pos, i); - S.pos = i; - } - return token("comment1", ret, true); - }; - - function read_multiline_comment() { - next(); - return with_eof_error("Unterminated multiline comment", function(){ - var i = find("*/", true), - text = S.text.substring(S.pos, i), - tok = token("comment2", text, true); - S.pos = i + 2; - S.line += text.split("\n").length - 1; - S.newline_before = text.indexOf("\n") >= 0; - - // https://github.com/mishoo/UglifyJS/issues/#issue/100 - if (/^@cc_on/i.test(text)) { - warn("WARNING: at line " + S.line); - warn("*** Found \"conditional comment\": " + text); - warn("*** UglifyJS DISCARDS ALL COMMENTS. This means your code might no longer work properly in Internet Explorer."); - } - - return tok; - }); - }; - - function read_name() { - var backslash = false, name = "", ch; - while ((ch = peek()) != null) { - if (!backslash) { - if (ch == "\\") backslash = true, next(); - else if (is_identifier_char(ch)) name += next(); - else break; - } - else { - if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX"); - ch = read_escaped_char(); - if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier"); - name += ch; - backslash = false; - } - } - return name; - }; - - function read_regexp() { - return with_eof_error("Unterminated regular expression", function(){ - var prev_backslash = false, regexp = "", ch, in_class = false; - while ((ch = next(true))) if (prev_backslash) { - regexp += "\\" + ch; - prev_backslash = false; - } else if (ch == "[") { - in_class = true; - regexp += ch; - } else if (ch == "]" && in_class) { - in_class = false; - regexp += ch; - } else if (ch == "/" && !in_class) { - break; - } else if (ch == "\\") { - prev_backslash = true; - } else { - regexp += ch; - } - var mods = read_name(); - return token("regexp", [ regexp, mods ]); - }); - }; - - function read_operator(prefix) { - function grow(op) { - if (!peek()) return op; - var bigger = op + peek(); - if (HOP(OPERATORS, bigger)) { - next(); - return grow(bigger); - } else { - return op; - } - }; - return token("operator", grow(prefix || next())); - }; - - function handle_slash() { - next(); - var regex_allowed = S.regex_allowed; - switch (peek()) { - case "/": - S.comments_before.push(read_line_comment()); - S.regex_allowed = regex_allowed; - return next_token(); - case "*": - S.comments_before.push(read_multiline_comment()); - S.regex_allowed = regex_allowed; - return next_token(); - } - return S.regex_allowed ? read_regexp() : read_operator("/"); - }; - - function handle_dot() { - next(); - return is_digit(peek()) - ? read_num(".") - : token("punc", "."); - }; - - function read_word() { - var word = read_name(); - return !HOP(KEYWORDS, word) - ? token("name", word) - : HOP(OPERATORS, word) - ? token("operator", word) - : HOP(KEYWORDS_ATOM, word) - ? token("atom", word) - : token("keyword", word); - }; - - function with_eof_error(eof_error, cont) { - try { - return cont(); - } catch(ex) { - if (ex === EX_EOF) parse_error(eof_error); - else throw ex; - } - }; - - function next_token(force_regexp) { - if (force_regexp) - return read_regexp(); - skip_whitespace(); - start_token(); - var ch = peek(); - if (!ch) return token("eof"); - if (is_digit(ch)) return read_num(); - if (ch == '"' || ch == "'") return read_string(); - if (HOP(PUNC_CHARS, ch)) return token("punc", next()); - if (ch == ".") return handle_dot(); - if (ch == "/") return handle_slash(); - if (HOP(OPERATOR_CHARS, ch)) return read_operator(); - if (ch == "\\" || is_identifier_start(ch)) return read_word(); - parse_error("Unexpected character '" + ch + "'"); - }; - - next_token.context = function(nc) { - if (nc) S = nc; - return S; - }; - - return next_token; - -}; - -/* -----[ Parser (constants) ]----- */ - -var UNARY_PREFIX = array_to_hash([ - "typeof", - "void", - "delete", - "--", - "++", - "!", - "~", - "-", - "+" -]); - -var UNARY_POSTFIX = array_to_hash([ "--", "++" ]); - -var ASSIGNMENT = (function(a, ret, i){ - while (i < a.length) { - ret[a[i]] = a[i].substr(0, a[i].length - 1); - i++; - } - return ret; -})( - ["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&="], - { "=": true }, - 0 -); - -var PRECEDENCE = (function(a, ret){ - for (var i = 0, n = 1; i < a.length; ++i, ++n) { - var b = a[i]; - for (var j = 0; j < b.length; ++j) { - ret[b[j]] = n; - } - } - return ret; -})( - [ - ["||"], - ["&&"], - ["|"], - ["^"], - ["&"], - ["==", "===", "!=", "!=="], - ["<", ">", "<=", ">=", "in", "instanceof"], - [">>", "<<", ">>>"], - ["+", "-"], - ["*", "/", "%"] - ], - {} -); - -var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]); - -var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]); - -/* -----[ Parser ]----- */ - -function NodeWithToken(str, start, end) { - this.name = str; - this.start = start; - this.end = end; -}; - -NodeWithToken.prototype.toString = function() { return this.name; }; - -function parse($TEXT, exigent_mode, embed_tokens) { - - var S = { - input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT, - token : null, - prev : null, - peeked : null, - in_function : 0, - in_loop : 0, - labels : [] - }; - - S.token = next(); - - function is(type, value) { - return is_token(S.token, type, value); - }; - - function peek() { return S.peeked || (S.peeked = S.input()); }; - - function next() { - S.prev = S.token; - if (S.peeked) { - S.token = S.peeked; - S.peeked = null; - } else { - S.token = S.input(); - } - return S.token; - }; - - function prev() { - return S.prev; - }; - - function croak(msg, line, col, pos) { - var ctx = S.input.context(); - js_error(msg, - line != null ? line : ctx.tokline, - col != null ? col : ctx.tokcol, - pos != null ? pos : ctx.tokpos); - }; - - function token_error(token, msg) { - croak(msg, token.line, token.col); - }; - - function unexpected(token) { - if (token == null) - token = S.token; - token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")"); - }; - - function expect_token(type, val) { - if (is(type, val)) { - return next(); - } - token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type); - }; - - function expect(punc) { return expect_token("punc", punc); }; - - function can_insert_semicolon() { - return !exigent_mode && ( - S.token.nlb || is("eof") || is("punc", "}") - ); - }; - - function semicolon() { - if (is("punc", ";")) next(); - else if (!can_insert_semicolon()) unexpected(); - }; - - function as() { - return slice(arguments); - }; - - function parenthesised() { - expect("("); - var ex = expression(); - expect(")"); - return ex; - }; - - function add_tokens(str, start, end) { - return str instanceof NodeWithToken ? str : new NodeWithToken(str, start, end); - }; - - function maybe_embed_tokens(parser) { - if (embed_tokens) return function() { - var start = S.token; - var ast = parser.apply(this, arguments); - ast[0] = add_tokens(ast[0], start, prev()); - return ast; - }; - else return parser; - }; - - var statement = maybe_embed_tokens(function() { - if (is("operator", "/")) { - S.peeked = null; - S.token = S.input(true); // force regexp - } - switch (S.token.type) { - case "num": - case "string": - case "regexp": - case "operator": - case "atom": - return simple_statement(); - - case "name": - return is_token(peek(), "punc", ":") - ? labeled_statement(prog1(S.token.value, next, next)) - : simple_statement(); - - case "punc": - switch (S.token.value) { - case "{": - return as("block", block_()); - case "[": - case "(": - return simple_statement(); - case ";": - next(); - return as("block"); - default: - unexpected(); - } - - case "keyword": - switch (prog1(S.token.value, next)) { - case "break": - return break_cont("break"); - - case "continue": - return break_cont("continue"); - - case "debugger": - semicolon(); - return as("debugger"); - - case "do": - return (function(body){ - expect_token("keyword", "while"); - return as("do", prog1(parenthesised, semicolon), body); - })(in_loop(statement)); - - case "for": - return for_(); - - case "function": - return function_(true); - - case "if": - return if_(); - - case "return": - if (S.in_function == 0) - croak("'return' outside of function"); - return as("return", - is("punc", ";") - ? (next(), null) - : can_insert_semicolon() - ? null - : prog1(expression, semicolon)); - - case "switch": - return as("switch", parenthesised(), switch_block_()); - - case "throw": - return as("throw", prog1(expression, semicolon)); - - case "try": - return try_(); - - case "var": - return prog1(var_, semicolon); - - case "const": - return prog1(const_, semicolon); - - case "while": - return as("while", parenthesised(), in_loop(statement)); - - case "with": - return as("with", parenthesised(), statement()); - - default: - unexpected(); - } - } - }); - - function labeled_statement(label) { - S.labels.push(label); - var start = S.token, stat = statement(); - if (exigent_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0])) - unexpected(start); - S.labels.pop(); - return as("label", label, stat); - }; - - function simple_statement() { - return as("stat", prog1(expression, semicolon)); - }; - - function break_cont(type) { - var name; - if (!can_insert_semicolon()) { - name = is("name") ? S.token.value : null; - } - if (name != null) { - next(); - if (!member(name, S.labels)) - croak("Label " + name + " without matching loop or statement"); - } - else if (S.in_loop == 0) - croak(type + " not inside a loop or switch"); - semicolon(); - return as(type, name); - }; - - function for_() { - expect("("); - var init = null; - if (!is("punc", ";")) { - init = is("keyword", "var") - ? (next(), var_(true)) - : expression(true, true); - if (is("operator", "in")) - return for_in(init); - } - return regular_for(init); - }; - - function regular_for(init) { - expect(";"); - var test = is("punc", ";") ? null : expression(); - expect(";"); - var step = is("punc", ")") ? null : expression(); - expect(")"); - return as("for", init, test, step, in_loop(statement)); - }; - - function for_in(init) { - var lhs = init[0] == "var" ? as("name", init[1][0]) : init; - next(); - var obj = expression(); - expect(")"); - return as("for-in", init, lhs, obj, in_loop(statement)); - }; - - var function_ = maybe_embed_tokens(function(in_statement) { - var name = is("name") ? prog1(S.token.value, next) : null; - if (in_statement && !name) - unexpected(); - expect("("); - return as(in_statement ? "defun" : "function", - name, - // arguments - (function(first, a){ - while (!is("punc", ")")) { - if (first) first = false; else expect(","); - if (!is("name")) unexpected(); - a.push(S.token.value); - next(); - } - next(); - return a; - })(true, []), - // body - (function(){ - ++S.in_function; - var loop = S.in_loop; - S.in_loop = 0; - var a = block_(); - --S.in_function; - S.in_loop = loop; - return a; - })()); - }); - - function if_() { - var cond = parenthesised(), body = statement(), belse; - if (is("keyword", "else")) { - next(); - belse = statement(); - } - return as("if", cond, body, belse); - }; - - function block_() { - expect("{"); - var a = []; - while (!is("punc", "}")) { - if (is("eof")) unexpected(); - a.push(statement()); - } - next(); - return a; - }; - - var switch_block_ = curry(in_loop, function(){ - expect("{"); - var a = [], cur = null; - while (!is("punc", "}")) { - if (is("eof")) unexpected(); - if (is("keyword", "case")) { - next(); - cur = []; - a.push([ expression(), cur ]); - expect(":"); - } - else if (is("keyword", "default")) { - next(); - expect(":"); - cur = []; - a.push([ null, cur ]); - } - else { - if (!cur) unexpected(); - cur.push(statement()); - } - } - next(); - return a; - }); - - function try_() { - var body = block_(), bcatch, bfinally; - if (is("keyword", "catch")) { - next(); - expect("("); - if (!is("name")) - croak("Name expected"); - var name = S.token.value; - next(); - expect(")"); - bcatch = [ name, block_() ]; - } - if (is("keyword", "finally")) { - next(); - bfinally = block_(); - } - if (!bcatch && !bfinally) - croak("Missing catch/finally blocks"); - return as("try", body, bcatch, bfinally); - }; - - function vardefs(no_in) { - var a = []; - for (;;) { - if (!is("name")) - unexpected(); - var name = S.token.value; - next(); - if (is("operator", "=")) { - next(); - a.push([ name, expression(false, no_in) ]); - } else { - a.push([ name ]); - } - if (!is("punc", ",")) - break; - next(); - } - return a; - }; - - function var_(no_in) { - return as("var", vardefs(no_in)); - }; - - function const_() { - return as("const", vardefs()); - }; - - function new_() { - var newexp = expr_atom(false), args; - if (is("punc", "(")) { - next(); - args = expr_list(")"); - } else { - args = []; - } - return subscripts(as("new", newexp, args), true); - }; - - var expr_atom = maybe_embed_tokens(function(allow_calls) { - if (is("operator", "new")) { - next(); - return new_(); - } - if (is("operator") && HOP(UNARY_PREFIX, S.token.value)) { - return make_unary("unary-prefix", - prog1(S.token.value, next), - expr_atom(allow_calls)); - } - if (is("punc")) { - switch (S.token.value) { - case "(": - next(); - return subscripts(prog1(expression, curry(expect, ")")), allow_calls); - case "[": - next(); - return subscripts(array_(), allow_calls); - case "{": - next(); - return subscripts(object_(), allow_calls); - } - unexpected(); - } - if (is("keyword", "function")) { - next(); - return subscripts(function_(false), allow_calls); - } - if (HOP(ATOMIC_START_TOKEN, S.token.type)) { - var atom = S.token.type == "regexp" - ? as("regexp", S.token.value[0], S.token.value[1]) - : as(S.token.type, S.token.value); - return subscripts(prog1(atom, next), allow_calls); - } - unexpected(); - }); - - function expr_list(closing, allow_trailing_comma, allow_empty) { - var first = true, a = []; - while (!is("punc", closing)) { - if (first) first = false; else expect(","); - if (allow_trailing_comma && is("punc", closing)) break; - if (is("punc", ",") && allow_empty) { - a.push([ "atom", "undefined" ]); - } else { - a.push(expression(false)); - } - } - next(); - return a; - }; - - function array_() { - return as("array", expr_list("]", !exigent_mode, true)); - }; - - function object_() { - var first = true, a = []; - while (!is("punc", "}")) { - if (first) first = false; else expect(","); - if (!exigent_mode && is("punc", "}")) - // allow trailing comma - break; - var type = S.token.type; - var name = as_property_name(); - if (type == "name" && (name == "get" || name == "set") && !is("punc", ":")) { - a.push([ as_name(), function_(false), name ]); - } else { - expect(":"); - a.push([ name, expression(false) ]); - } - } - next(); - return as("object", a); - }; - - function as_property_name() { - switch (S.token.type) { - case "num": - case "string": - return prog1(S.token.value, next); - } - return as_name(); - }; - - function as_name() { - switch (S.token.type) { - case "name": - case "operator": - case "keyword": - case "atom": - return prog1(S.token.value, next); - default: - unexpected(); - } - }; - - function subscripts(expr, allow_calls) { - if (is("punc", ".")) { - next(); - return subscripts(as("dot", expr, as_name()), allow_calls); - } - if (is("punc", "[")) { - next(); - return subscripts(as("sub", expr, prog1(expression, curry(expect, "]"))), allow_calls); - } - if (allow_calls && is("punc", "(")) { - next(); - return subscripts(as("call", expr, expr_list(")")), true); - } - if (allow_calls && is("operator") && HOP(UNARY_POSTFIX, S.token.value)) { - return prog1(curry(make_unary, "unary-postfix", S.token.value, expr), - next); - } - return expr; - }; - - function make_unary(tag, op, expr) { - if ((op == "++" || op == "--") && !is_assignable(expr)) - croak("Invalid use of " + op + " operator"); - return as(tag, op, expr); - }; - - function expr_op(left, min_prec, no_in) { - var op = is("operator") ? S.token.value : null; - if (op && op == "in" && no_in) op = null; - var prec = op != null ? PRECEDENCE[op] : null; - if (prec != null && prec > min_prec) { - next(); - var right = expr_op(expr_atom(true), prec, no_in); - return expr_op(as("binary", op, left, right), min_prec, no_in); - } - return left; - }; - - function expr_ops(no_in) { - return expr_op(expr_atom(true), 0, no_in); - }; - - function maybe_conditional(no_in) { - var expr = expr_ops(no_in); - if (is("operator", "?")) { - next(); - var yes = expression(false); - expect(":"); - return as("conditional", expr, yes, expression(false, no_in)); - } - return expr; - }; - - function is_assignable(expr) { - if (!exigent_mode) return true; - switch (expr[0]) { - case "dot": - case "sub": - case "new": - case "call": - return true; - case "name": - return expr[1] != "this"; - } - }; - - function maybe_assign(no_in) { - var left = maybe_conditional(no_in), val = S.token.value; - if (is("operator") && HOP(ASSIGNMENT, val)) { - if (is_assignable(left)) { - next(); - return as("assign", ASSIGNMENT[val], left, maybe_assign(no_in)); - } - croak("Invalid assignment"); - } - return left; - }; - - var expression = maybe_embed_tokens(function(commas, no_in) { - if (arguments.length == 0) - commas = true; - var expr = maybe_assign(no_in); - if (commas && is("punc", ",")) { - next(); - return as("seq", expr, expression(true, no_in)); - } - return expr; - }); - - function in_loop(cont) { - try { - ++S.in_loop; - return cont(); - } finally { - --S.in_loop; - } - }; - - return as("toplevel", (function(a){ - while (!is("eof")) - a.push(statement()); - return a; - })([])); - -}; - -/* -----[ Utilities ]----- */ - -function curry(f) { - var args = slice(arguments, 1); - return function() { return f.apply(this, args.concat(slice(arguments))); }; -}; - -function prog1(ret) { - if (ret instanceof Function) - ret = ret(); - for (var i = 1, n = arguments.length; --n > 0; ++i) - arguments[i](); - return ret; -}; - -function array_to_hash(a) { - var ret = {}; - for (var i = 0; i < a.length; ++i) - ret[a[i]] = true; - return ret; -}; - -function slice(a, start) { - return Array.prototype.slice.call(a, start == null ? 0 : start); -}; - -function characters(str) { - return str.split(""); -}; - -function member(name, array) { - for (var i = array.length; --i >= 0;) - if (array[i] === name) - return true; - return false; -}; - -function HOP(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - -var warn = function() {}; - -/* -----[ Exports ]----- */ - -exports.tokenizer = tokenizer; -exports.parse = parse; -exports.slice = slice; -exports.curry = curry; -exports.member = member; -exports.array_to_hash = array_to_hash; -exports.PRECEDENCE = PRECEDENCE; -exports.KEYWORDS_ATOM = KEYWORDS_ATOM; -exports.RESERVED_WORDS = RESERVED_WORDS; -exports.KEYWORDS = KEYWORDS; -exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN; -exports.OPERATORS = OPERATORS; -exports.is_alphanumeric_char = is_alphanumeric_char; -exports.set_logger = function(logger) { - warn = logger; -}; -; - }).call(module.exports); - - __require.modules["/node_modules/uglify-js/lib/parse-js.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/uglify-js/lib/process.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/uglify-js/lib"; - var __filename = "/node_modules/uglify-js/lib/process.js"; - - var require = function (file) { - return __require(file, "/node_modules/uglify-js/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/uglify-js/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/uglify-js/lib/process.js"]._cached = module.exports; - - (function () { - /*********************************************************************** - - A JavaScript tokenizer / parser / beautifier / compressor. - - This version is suitable for Node.js. With minimal changes (the - exports stuff) it should work on any JS platform. - - This file implements some AST processors. They work on data built - by parse-js. - - Exported functions: - - - ast_mangle(ast, options) -- mangles the variable/function names - in the AST. Returns an AST. - - - ast_squeeze(ast) -- employs various optimizations to make the - final generated code even smaller. Returns an AST. - - - gen_code(ast, options) -- generates JS code from the AST. Pass - true (or an object, see the code for some options) as second - argument to get "pretty" (indented) code. - - -------------------------------- (C) --------------------------------- - - Author: Mihai Bazon - - http://mihai.bazon.net/blog - - Distributed under the BSD license: - - Copyright 2010 (c) Mihai Bazon - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - - ***********************************************************************/ - -var jsp = require("./parse-js"), - slice = jsp.slice, - member = jsp.member, - PRECEDENCE = jsp.PRECEDENCE, - OPERATORS = jsp.OPERATORS; - -/* -----[ helper for AST traversal ]----- */ - -function ast_walker(ast) { - function _vardefs(defs) { - return [ this[0], MAP(defs, function(def){ - var a = [ def[0] ]; - if (def.length > 1) - a[1] = walk(def[1]); - return a; - }) ]; - }; - function _block(statements) { - var out = [ this[0] ]; - if (statements != null) - out.push(MAP(statements, walk)); - return out; - }; - var walkers = { - "string": function(str) { - return [ this[0], str ]; - }, - "num": function(num) { - return [ this[0], num ]; - }, - "name": function(name) { - return [ this[0], name ]; - }, - "toplevel": function(statements) { - return [ this[0], MAP(statements, walk) ]; - }, - "block": _block, - "splice": _block, - "var": _vardefs, - "const": _vardefs, - "try": function(t, c, f) { - return [ - this[0], - MAP(t, walk), - c != null ? [ c[0], MAP(c[1], walk) ] : null, - f != null ? MAP(f, walk) : null - ]; - }, - "throw": function(expr) { - return [ this[0], walk(expr) ]; - }, - "new": function(ctor, args) { - return [ this[0], walk(ctor), MAP(args, walk) ]; - }, - "switch": function(expr, body) { - return [ this[0], walk(expr), MAP(body, function(branch){ - return [ branch[0] ? walk(branch[0]) : null, - MAP(branch[1], walk) ]; - }) ]; - }, - "break": function(label) { - return [ this[0], label ]; - }, - "continue": function(label) { - return [ this[0], label ]; - }, - "conditional": function(cond, t, e) { - return [ this[0], walk(cond), walk(t), walk(e) ]; - }, - "assign": function(op, lvalue, rvalue) { - return [ this[0], op, walk(lvalue), walk(rvalue) ]; - }, - "dot": function(expr) { - return [ this[0], walk(expr) ].concat(slice(arguments, 1)); - }, - "call": function(expr, args) { - return [ this[0], walk(expr), MAP(args, walk) ]; - }, - "function": function(name, args, body) { - return [ this[0], name, args.slice(), MAP(body, walk) ]; - }, - "defun": function(name, args, body) { - return [ this[0], name, args.slice(), MAP(body, walk) ]; - }, - "if": function(conditional, t, e) { - return [ this[0], walk(conditional), walk(t), walk(e) ]; - }, - "for": function(init, cond, step, block) { - return [ this[0], walk(init), walk(cond), walk(step), walk(block) ]; - }, - "for-in": function(vvar, key, hash, block) { - return [ this[0], walk(vvar), walk(key), walk(hash), walk(block) ]; - }, - "while": function(cond, block) { - return [ this[0], walk(cond), walk(block) ]; - }, - "do": function(cond, block) { - return [ this[0], walk(cond), walk(block) ]; - }, - "return": function(expr) { - return [ this[0], walk(expr) ]; - }, - "binary": function(op, left, right) { - return [ this[0], op, walk(left), walk(right) ]; - }, - "unary-prefix": function(op, expr) { - return [ this[0], op, walk(expr) ]; - }, - "unary-postfix": function(op, expr) { - return [ this[0], op, walk(expr) ]; - }, - "sub": function(expr, subscript) { - return [ this[0], walk(expr), walk(subscript) ]; - }, - "object": function(props) { - return [ this[0], MAP(props, function(p){ - return p.length == 2 - ? [ p[0], walk(p[1]) ] - : [ p[0], walk(p[1]), p[2] ]; // get/set-ter - }) ]; - }, - "regexp": function(rx, mods) { - return [ this[0], rx, mods ]; - }, - "array": function(elements) { - return [ this[0], MAP(elements, walk) ]; - }, - "stat": function(stat) { - return [ this[0], walk(stat) ]; - }, - "seq": function() { - return [ this[0] ].concat(MAP(slice(arguments), walk)); - }, - "label": function(name, block) { - return [ this[0], name, walk(block) ]; - }, - "with": function(expr, block) { - return [ this[0], walk(expr), walk(block) ]; - }, - "atom": function(name) { - return [ this[0], name ]; - } - }; - - var user = {}; - var stack = []; - function walk(ast) { - if (ast == null) - return null; - try { - stack.push(ast); - var type = ast[0]; - var gen = user[type]; - if (gen) { - var ret = gen.apply(ast, ast.slice(1)); - if (ret != null) - return ret; - } - gen = walkers[type]; - return gen.apply(ast, ast.slice(1)); - } finally { - stack.pop(); - } - }; - - function with_walkers(walkers, cont){ - var save = {}, i; - for (i in walkers) if (HOP(walkers, i)) { - save[i] = user[i]; - user[i] = walkers[i]; - } - var ret = cont(); - for (i in save) if (HOP(save, i)) { - if (!save[i]) delete user[i]; - else user[i] = save[i]; - } - return ret; - }; - - return { - walk: walk, - with_walkers: with_walkers, - parent: function() { - return stack[stack.length - 2]; // last one is current node - }, - stack: function() { - return stack; - } - }; -}; - -/* -----[ Scope and mangling ]----- */ - -function Scope(parent) { - this.names = {}; // names defined in this scope - this.mangled = {}; // mangled names (orig.name => mangled) - this.rev_mangled = {}; // reverse lookup (mangled => orig.name) - this.cname = -1; // current mangled name - this.refs = {}; // names referenced from this scope - this.uses_with = false; // will become TRUE if with() is detected in this or any subscopes - this.uses_eval = false; // will become TRUE if eval() is detected in this or any subscopes - this.parent = parent; // parent scope - this.children = []; // sub-scopes - if (parent) { - this.level = parent.level + 1; - parent.children.push(this); - } else { - this.level = 0; - } -}; - -var base54 = (function(){ - var DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_"; - return function(num) { - var ret = ""; - do { - ret = DIGITS.charAt(num % 54) + ret; - num = Math.floor(num / 54); - } while (num > 0); - return ret; - }; -})(); - -Scope.prototype = { - has: function(name) { - for (var s = this; s; s = s.parent) - if (HOP(s.names, name)) - return s; - }, - has_mangled: function(mname) { - for (var s = this; s; s = s.parent) - if (HOP(s.rev_mangled, mname)) - return s; - }, - toJSON: function() { - return { - names: this.names, - uses_eval: this.uses_eval, - uses_with: this.uses_with - }; - }, - - next_mangled: function() { - // we must be careful that the new mangled name: - // - // 1. doesn't shadow a mangled name from a parent - // scope, unless we don't reference the original - // name from this scope OR from any sub-scopes! - // This will get slow. - // - // 2. doesn't shadow an original name from a parent - // scope, in the event that the name is not mangled - // in the parent scope and we reference that name - // here OR IN ANY SUBSCOPES! - // - // 3. doesn't shadow a name that is referenced but not - // defined (possibly global defined elsewhere). - for (;;) { - var m = base54(++this.cname), prior; - - // case 1. - prior = this.has_mangled(m); - if (prior && this.refs[prior.rev_mangled[m]] === prior) - continue; - - // case 2. - prior = this.has(m); - if (prior && prior !== this && this.refs[m] === prior && !prior.has_mangled(m)) - continue; - - // case 3. - if (HOP(this.refs, m) && this.refs[m] == null) - continue; - - // I got "do" once. :-/ - if (!is_identifier(m)) - continue; - - return m; - } - }, - set_mangle: function(name, m) { - this.rev_mangled[m] = name; - return this.mangled[name] = m; - }, - get_mangled: function(name, newMangle) { - if (this.uses_eval || this.uses_with) return name; // no mangle if eval or with is in use - var s = this.has(name); - if (!s) return name; // not in visible scope, no mangle - if (HOP(s.mangled, name)) return s.mangled[name]; // already mangled in this scope - if (!newMangle) return name; // not found and no mangling requested - return s.set_mangle(name, s.next_mangled()); - }, - define: function(name) { - if (name != null) - return this.names[name] = name; - } -}; - -function ast_add_scope(ast) { - - var current_scope = null; - var w = ast_walker(), walk = w.walk; - var having_eval = []; - - function with_new_scope(cont) { - current_scope = new Scope(current_scope); - var ret = current_scope.body = cont(); - ret.scope = current_scope; - current_scope = current_scope.parent; - return ret; - }; - - function define(name) { - return current_scope.define(name); - }; - - function reference(name) { - current_scope.refs[name] = true; - }; - - function _lambda(name, args, body) { - var is_defun = this[0] == "defun"; - return [ this[0], is_defun ? define(name) : name, args, with_new_scope(function(){ - if (!is_defun) define(name); - MAP(args, define); - return MAP(body, walk); - })]; - }; - - return with_new_scope(function(){ - // process AST - var ret = w.with_walkers({ - "function": _lambda, - "defun": _lambda, - "with": function(expr, block) { - for (var s = current_scope; s; s = s.parent) - s.uses_with = true; - }, - "var": function(defs) { - MAP(defs, function(d){ define(d[0]) }); - }, - "const": function(defs) { - MAP(defs, function(d){ define(d[0]) }); - }, - "try": function(t, c, f) { - if (c != null) return [ - this[0], - MAP(t, walk), - [ define(c[0]), MAP(c[1], walk) ], - f != null ? MAP(f, walk) : null - ]; - }, - "name": function(name) { - if (name == "eval") - having_eval.push(current_scope); - reference(name); - } - }, function(){ - return walk(ast); - }); - - // the reason why we need an additional pass here is - // that names can be used prior to their definition. - - // scopes where eval was detected and their parents - // are marked with uses_eval, unless they define the - // "eval" name. - MAP(having_eval, function(scope){ - if (!scope.has("eval")) while (scope) { - scope.uses_eval = true; - scope = scope.parent; - } - }); - - // for referenced names it might be useful to know - // their origin scope. current_scope here is the - // toplevel one. - function fixrefs(scope, i) { - // do children first; order shouldn't matter - for (i = scope.children.length; --i >= 0;) - fixrefs(scope.children[i]); - for (i in scope.refs) if (HOP(scope.refs, i)) { - // find origin scope and propagate the reference to origin - for (var origin = scope.has(i), s = scope; s; s = s.parent) { - s.refs[i] = origin; - if (s === origin) break; - } - } - }; - fixrefs(current_scope); - - return ret; - }); - -}; - -/* -----[ mangle names ]----- */ - -function ast_mangle(ast, options) { - var w = ast_walker(), walk = w.walk, scope; - options = options || {}; - - function get_mangled(name, newMangle) { - if (!options.toplevel && !scope.parent) return name; // don't mangle toplevel - if (options.except && member(name, options.except)) - return name; - return scope.get_mangled(name, newMangle); - }; - - function get_define(name) { - if (options.defines) { - // we always lookup a defined symbol for the current scope FIRST, so declared - // vars trump a DEFINE symbol, but if no such var is found, then match a DEFINE value - if (!scope.has(name)) { - if (HOP(options.defines, name)) { - return options.defines[name]; - } - } - return null; - } - }; - - function _lambda(name, args, body) { - var is_defun = this[0] == "defun", extra; - if (name) { - if (is_defun) name = get_mangled(name); - else { - extra = {}; - name = extra[name] = scope.next_mangled(); - } - } - body = with_scope(body.scope, function(){ - args = MAP(args, function(name){ return get_mangled(name) }); - return MAP(body, walk); - }, extra); - return [ this[0], name, args, body ]; - }; - - function with_scope(s, cont, extra) { - var _scope = scope; - scope = s; - if (extra) for (var i in extra) if (HOP(extra, i)) { - s.set_mangle(i, extra[i]); - } - for (var i in s.names) if (HOP(s.names, i)) { - get_mangled(i, true); - } - var ret = cont(); - ret.scope = s; - scope = _scope; - return ret; - }; - - function _vardefs(defs) { - return [ this[0], MAP(defs, function(d){ - return [ get_mangled(d[0]), walk(d[1]) ]; - }) ]; - }; - - return w.with_walkers({ - "function": _lambda, - "defun": function() { - // move function declarations to the top when - // they are not in some block. - var ast = _lambda.apply(this, arguments); - switch (w.parent()[0]) { - case "toplevel": - case "function": - case "defun": - return MAP.at_top(ast); - } - return ast; - }, - "var": _vardefs, - "const": _vardefs, - "name": function(name) { - return get_define(name) || [ this[0], get_mangled(name) ]; - }, - "try": function(t, c, f) { - return [ this[0], - MAP(t, walk), - c != null ? [ get_mangled(c[0]), MAP(c[1], walk) ] : null, - f != null ? MAP(f, walk) : null ]; - }, - "toplevel": function(body) { - var self = this; - return with_scope(self.scope, function(){ - return [ self[0], MAP(body, walk) ]; - }); - } - }, function() { - return walk(ast_add_scope(ast)); - }); -}; - -/* -----[ - - compress foo["bar"] into foo.bar, - - remove block brackets {} where possible - - join consecutive var declarations - - various optimizations for IFs: - - if (cond) foo(); else bar(); ==> cond?foo():bar(); - - if (cond) foo(); ==> cond&&foo(); - - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); // also for throw - - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} - ]----- */ - -var warn = function(){}; - -function best_of(ast1, ast2) { - return gen_code(ast1).length > gen_code(ast2[0] == "stat" ? ast2[1] : ast2).length ? ast2 : ast1; -}; - -function last_stat(b) { - if (b[0] == "block" && b[1] && b[1].length > 0) - return b[1][b[1].length - 1]; - return b; -} - -function aborts(t) { - if (t) { - t = last_stat(t); - if (t[0] == "return" || t[0] == "break" || t[0] == "continue" || t[0] == "throw") - return true; - } -}; - -function boolean_expr(expr) { - return ( (expr[0] == "unary-prefix" - && member(expr[1], [ "!", "delete" ])) || - - (expr[0] == "binary" - && member(expr[1], [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ])) || - - (expr[0] == "binary" - && member(expr[1], [ "&&", "||" ]) - && boolean_expr(expr[2]) - && boolean_expr(expr[3])) || - - (expr[0] == "conditional" - && boolean_expr(expr[2]) - && boolean_expr(expr[3])) || - - (expr[0] == "assign" - && expr[1] === true - && boolean_expr(expr[3])) || - - (expr[0] == "seq" - && boolean_expr(expr[expr.length - 1])) - ); -}; - -function make_conditional(c, t, e) { - var make_real_conditional = function() { - if (c[0] == "unary-prefix" && c[1] == "!") { - return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ]; - } else { - return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ]; - } - }; - // shortcut the conditional if the expression has a constant value - return when_constant(c, function(ast, val){ - warn_unreachable(val ? e : t); - return (val ? t : e); - }, make_real_conditional); -}; - -function empty(b) { - return !b || (b[0] == "block" && (!b[1] || b[1].length == 0)); -}; - -function is_string(node) { - return (node[0] == "string" || - node[0] == "unary-prefix" && node[1] == "typeof" || - node[0] == "binary" && node[1] == "+" && - (is_string(node[2]) || is_string(node[3]))); -}; - -var when_constant = (function(){ - - var $NOT_CONSTANT = {}; - - // this can only evaluate constant expressions. If it finds anything - // not constant, it throws $NOT_CONSTANT. - function evaluate(expr) { - switch (expr[0]) { - case "string": - case "num": - return expr[1]; - case "name": - case "atom": - switch (expr[1]) { - case "true": return true; - case "false": return false; - } - break; - case "unary-prefix": - switch (expr[1]) { - case "!": return !evaluate(expr[2]); - case "typeof": return typeof evaluate(expr[2]); - case "~": return ~evaluate(expr[2]); - case "-": return -evaluate(expr[2]); - case "+": return +evaluate(expr[2]); - } - break; - case "binary": - var left = expr[2], right = expr[3]; - switch (expr[1]) { - case "&&" : return evaluate(left) && evaluate(right); - case "||" : return evaluate(left) || evaluate(right); - case "|" : return evaluate(left) | evaluate(right); - case "&" : return evaluate(left) & evaluate(right); - case "^" : return evaluate(left) ^ evaluate(right); - case "+" : return evaluate(left) + evaluate(right); - case "*" : return evaluate(left) * evaluate(right); - case "/" : return evaluate(left) / evaluate(right); - case "-" : return evaluate(left) - evaluate(right); - case "<<" : return evaluate(left) << evaluate(right); - case ">>" : return evaluate(left) >> evaluate(right); - case ">>>" : return evaluate(left) >>> evaluate(right); - case "==" : return evaluate(left) == evaluate(right); - case "===" : return evaluate(left) === evaluate(right); - case "!=" : return evaluate(left) != evaluate(right); - case "!==" : return evaluate(left) !== evaluate(right); - case "<" : return evaluate(left) < evaluate(right); - case "<=" : return evaluate(left) <= evaluate(right); - case ">" : return evaluate(left) > evaluate(right); - case ">=" : return evaluate(left) >= evaluate(right); - case "in" : return evaluate(left) in evaluate(right); - case "instanceof" : return evaluate(left) instanceof evaluate(right); - } - } - throw $NOT_CONSTANT; - }; - - return function(expr, yes, no) { - try { - var val = evaluate(expr), ast; - switch (typeof val) { - case "string": ast = [ "string", val ]; break; - case "number": ast = [ "num", val ]; break; - case "boolean": ast = [ "name", String(val) ]; break; - default: throw new Error("Can't handle constant of type: " + (typeof val)); - } - return yes.call(expr, ast, val); - } catch(ex) { - if (ex === $NOT_CONSTANT) { - if (expr[0] == "binary" - && (expr[1] == "===" || expr[1] == "!==") - && ((is_string(expr[2]) && is_string(expr[3])) - || (boolean_expr(expr[2]) && boolean_expr(expr[3])))) { - expr[1] = expr[1].substr(0, 2); - } - else if (no && expr[0] == "binary" - && (expr[1] == "||" || expr[1] == "&&")) { - // the whole expression is not constant but the lval may be... - try { - var lval = evaluate(expr[2]); - expr = ((expr[1] == "&&" && (lval ? expr[3] : lval)) || - (expr[1] == "||" && (lval ? lval : expr[3])) || - expr); - } catch(ex2) { - // IGNORE... lval is not constant - } - } - return no ? no.call(expr, expr) : null; - } - else throw ex; - } - }; - -})(); - -function warn_unreachable(ast) { - if (!empty(ast)) - warn("Dropping unreachable code: " + gen_code(ast, true)); -}; - -function prepare_ifs(ast) { - var w = ast_walker(), walk = w.walk; - // In this first pass, we rewrite ifs which abort with no else with an - // if-else. For example: - // - // if (x) { - // blah(); - // return y; - // } - // foobar(); - // - // is rewritten into: - // - // if (x) { - // blah(); - // return y; - // } else { - // foobar(); - // } - function redo_if(statements) { - statements = MAP(statements, walk); - - for (var i = 0; i < statements.length; ++i) { - var fi = statements[i]; - if (fi[0] != "if") continue; - - if (fi[3] && walk(fi[3])) continue; - - var t = walk(fi[2]); - if (!aborts(t)) continue; - - var conditional = walk(fi[1]); - - var e_body = statements.slice(i + 1); - var e; - if (e_body.length == 1) e = e_body[0]; - else e = [ "block", e_body ]; - - var ret = statements.slice(0, i).concat([ [ - fi[0], // "if" - conditional, // conditional - t, // then - e // else - ] ]); - - return redo_if(ret); - } - - return statements; - }; - - function redo_if_lambda(name, args, body) { - body = redo_if(body); - return [ this[0], name, args.slice(), body ]; - }; - - function redo_if_block(statements) { - var out = [ this[0] ]; - if (statements != null) - out.push(redo_if(statements)); - return out; - }; - - return w.with_walkers({ - "defun": redo_if_lambda, - "function": redo_if_lambda, - "block": redo_if_block, - "splice": redo_if_block, - "toplevel": function(statements) { - return [ this[0], redo_if(statements) ]; - }, - "try": function(t, c, f) { - return [ - this[0], - redo_if(t), - c != null ? [ c[0], redo_if(c[1]) ] : null, - f != null ? redo_if(f) : null - ]; - }, - "with": function(expr, block) { - return [ this[0], walk(expr), redo_if(block) ]; - } - }, function() { - return walk(ast); - }); -}; - -function ast_squeeze(ast, options) { - options = defaults(options, { - make_seqs : true, - dead_code : true, - keep_comps : true, - no_warnings : false - }); - - var w = ast_walker(), walk = w.walk, scope; - - function negate(c) { - var not_c = [ "unary-prefix", "!", c ]; - switch (c[0]) { - case "unary-prefix": - return c[1] == "!" && boolean_expr(c[2]) ? c[2] : not_c; - case "seq": - c = slice(c); - c[c.length - 1] = negate(c[c.length - 1]); - return c; - case "conditional": - return best_of(not_c, [ "conditional", c[1], negate(c[2]), negate(c[3]) ]); - case "binary": - var op = c[1], left = c[2], right = c[3]; - if (!options.keep_comps) switch (op) { - case "<=" : return [ "binary", ">", left, right ]; - case "<" : return [ "binary", ">=", left, right ]; - case ">=" : return [ "binary", "<", left, right ]; - case ">" : return [ "binary", "<=", left, right ]; - } - switch (op) { - case "==" : return [ "binary", "!=", left, right ]; - case "!=" : return [ "binary", "==", left, right ]; - case "===" : return [ "binary", "!==", left, right ]; - case "!==" : return [ "binary", "===", left, right ]; - case "&&" : return best_of(not_c, [ "binary", "||", negate(left), negate(right) ]); - case "||" : return best_of(not_c, [ "binary", "&&", negate(left), negate(right) ]); - } - break; - } - return not_c; - }; - - function with_scope(s, cont) { - var _scope = scope; - scope = s; - var ret = cont(); - ret.scope = s; - scope = _scope; - return ret; - }; - - function rmblock(block) { - if (block != null && block[0] == "block" && block[1]) { - if (block[1].length == 1) - block = block[1][0]; - else if (block[1].length == 0) - block = [ "block" ]; - } - return block; - }; - - function _lambda(name, args, body) { - var is_defun = this[0] == "defun"; - body = with_scope(body.scope, function(){ - var ret = tighten(MAP(body, walk), "lambda"); - if (!is_defun && name && !HOP(scope.refs, name)) - name = null; - return ret; - }); - return [ this[0], name, args, body ]; - }; - - // we get here for blocks that have been already transformed. - // this function does a few things: - // 1. discard useless blocks - // 2. join consecutive var declarations - // 3. remove obviously dead code - // 4. transform consecutive statements using the comma operator - // 5. if block_type == "lambda" and it detects constructs like if(foo) return ... - rewrite like if (!foo) { ... } - function tighten(statements, block_type) { - statements = statements.reduce(function(a, stat){ - if (stat[0] == "block") { - if (stat[1]) { - a.push.apply(a, stat[1]); - } - } else { - a.push(stat); - } - return a; - }, []); - - statements = (function(a, prev){ - statements.forEach(function(cur){ - if (prev && ((cur[0] == "var" && prev[0] == "var") || - (cur[0] == "const" && prev[0] == "const"))) { - prev[1] = prev[1].concat(cur[1]); - } else { - a.push(cur); - prev = cur; - } - }); - return a; - })([]); - - if (options.dead_code) statements = (function(a, has_quit){ - statements.forEach(function(st){ - if (has_quit) { - if (member(st[0], [ "function", "defun" , "var", "const" ])) { - a.push(st); - } - else if (!options.no_warnings) - warn_unreachable(st); - } - else { - a.push(st); - if (member(st[0], [ "return", "throw", "break", "continue" ])) - has_quit = true; - } - }); - return a; - })([]); - - if (options.make_seqs) statements = (function(a, prev) { - statements.forEach(function(cur){ - if (prev && prev[0] == "stat" && cur[0] == "stat") { - prev[1] = [ "seq", prev[1], cur[1] ]; - } else { - a.push(cur); - prev = cur; - } - }); - return a; - })([]); - - if (block_type == "lambda") statements = (function(i, a, stat){ - while (i < statements.length) { - stat = statements[i++]; - if (stat[0] == "if" && !stat[3]) { - if (stat[2][0] == "return" && stat[2][1] == null) { - a.push(make_if(negate(stat[1]), [ "block", statements.slice(i) ])); - break; - } - var last = last_stat(stat[2]); - if (last[0] == "return" && last[1] == null) { - a.push(make_if(stat[1], [ "block", stat[2][1].slice(0, -1) ], [ "block", statements.slice(i) ])); - break; - } - } - a.push(stat); - } - return a; - })(0, []); - - return statements; - }; - - function make_if(c, t, e) { - return when_constant(c, function(ast, val){ - if (val) { - warn_unreachable(e); - return t; - } else { - warn_unreachable(t); - return e; - } - }, function() { - return make_real_if(c, t, e); - }); - }; - - function make_real_if(c, t, e) { - c = walk(c); - t = walk(t); - e = walk(e); - - if (empty(t)) { - c = negate(c); - t = e; - e = null; - } else if (empty(e)) { - e = null; - } else { - // if we have both else and then, maybe it makes sense to switch them? - (function(){ - var a = gen_code(c); - var n = negate(c); - var b = gen_code(n); - if (b.length < a.length) { - var tmp = t; - t = e; - e = tmp; - c = n; - } - })(); - } - if (empty(e) && empty(t)) - return [ "stat", c ]; - var ret = [ "if", c, t, e ]; - if (t[0] == "if" && empty(t[3]) && empty(e)) { - ret = best_of(ret, walk([ "if", [ "binary", "&&", c, t[1] ], t[2] ])); - } - else if (t[0] == "stat") { - if (e) { - if (e[0] == "stat") { - ret = best_of(ret, [ "stat", make_conditional(c, t[1], e[1]) ]); - } - } - else { - ret = best_of(ret, [ "stat", make_conditional(c, t[1]) ]); - } - } - else if (e && t[0] == e[0] && (t[0] == "return" || t[0] == "throw") && t[1] && e[1]) { - ret = best_of(ret, [ t[0], make_conditional(c, t[1], e[1] ) ]); - } - else if (e && aborts(t)) { - ret = [ [ "if", c, t ] ]; - if (e[0] == "block") { - if (e[1]) ret = ret.concat(e[1]); - } - else { - ret.push(e); - } - ret = walk([ "block", ret ]); - } - else if (t && aborts(e)) { - ret = [ [ "if", negate(c), e ] ]; - if (t[0] == "block") { - if (t[1]) ret = ret.concat(t[1]); - } else { - ret.push(t); - } - ret = walk([ "block", ret ]); - } - return ret; - }; - - function _do_while(cond, body) { - return when_constant(cond, function(cond, val){ - if (!val) { - warn_unreachable(body); - return [ "block" ]; - } else { - return [ "for", null, null, null, walk(body) ]; - } - }); - }; - - ast = prepare_ifs(ast); - ast = ast_add_scope(ast); - - return w.with_walkers({ - "sub": function(expr, subscript) { - if (subscript[0] == "string") { - var name = subscript[1]; - if (is_identifier(name)) - return [ "dot", walk(expr), name ]; - else if (/^[1-9][0-9]*$/.test(name) || name === "0") - return [ "sub", walk(expr), [ "num", parseInt(name, 10) ] ]; - } - }, - "if": make_if, - "toplevel": function(body) { - return [ "toplevel", with_scope(this.scope, function(){ - return tighten(MAP(body, walk)); - }) ]; - }, - "switch": function(expr, body) { - var last = body.length - 1; - return [ "switch", walk(expr), MAP(body, function(branch, i){ - var block = tighten(MAP(branch[1], walk)); - if (i == last && block.length > 0) { - var node = block[block.length - 1]; - if (node[0] == "break" && !node[1]) - block.pop(); - } - return [ branch[0] ? walk(branch[0]) : null, block ]; - }) ]; - }, - "function": _lambda, - "defun": _lambda, - "block": function(body) { - if (body) return rmblock([ "block", tighten(MAP(body, walk)) ]); - }, - "binary": function(op, left, right) { - return when_constant([ "binary", op, walk(left), walk(right) ], function yes(c){ - return best_of(walk(c), this); - }, function no() { - return this; - }); - }, - "conditional": function(c, t, e) { - return make_conditional(walk(c), walk(t), walk(e)); - }, - "try": function(t, c, f) { - return [ - "try", - tighten(MAP(t, walk)), - c != null ? [ c[0], tighten(MAP(c[1], walk)) ] : null, - f != null ? tighten(MAP(f, walk)) : null - ]; - }, - "unary-prefix": function(op, expr) { - expr = walk(expr); - var ret = [ "unary-prefix", op, expr ]; - if (op == "!") - ret = best_of(ret, negate(expr)); - return when_constant(ret, function(ast, val){ - return walk(ast); // it's either true or false, so minifies to !0 or !1 - }, function() { return ret }); - }, - "name": function(name) { - switch (name) { - case "true": return [ "unary-prefix", "!", [ "num", 0 ]]; - case "false": return [ "unary-prefix", "!", [ "num", 1 ]]; - } - }, - "new": function(ctor, args) { - if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) { - if (args.length != 1) { - return [ "array", args ]; - } else { - return [ "call", [ "name", "Array" ], args ]; - } - } - }, - "call": function(expr, args) { - if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) { - return [ "array", args ]; - } - }, - "while": _do_while - }, function() { - return walk(ast); - }); -}; - -/* -----[ re-generate code from the AST ]----- */ - -var DOT_CALL_NO_PARENS = jsp.array_to_hash([ - "name", - "array", - "object", - "string", - "dot", - "sub", - "call", - "regexp" -]); - -function make_string(str, ascii_only) { - var dq = 0, sq = 0; - str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029]/g, function(s){ - switch (s) { - case "\\": return "\\\\"; - case "\b": return "\\b"; - case "\f": return "\\f"; - case "\n": return "\\n"; - case "\r": return "\\r"; - case "\t": return "\\t"; - case "\u2028": return "\\u2028"; - case "\u2029": return "\\u2029"; - case '"': ++dq; return '"'; - case "'": ++sq; return "'"; - } - return s; - }); - if (ascii_only) str = to_ascii(str); - if (dq > sq) return "'" + str.replace(/\x27/g, "\\'") + "'"; - else return '"' + str.replace(/\x22/g, '\\"') + '"'; -}; - -function to_ascii(str) { - return str.replace(/[\u0080-\uffff]/g, function(ch) { - var code = ch.charCodeAt(0).toString(16); - while (code.length < 4) code = "0" + code; - return "\\u" + code; - }); -}; - -var SPLICE_NEEDS_BRACKETS = jsp.array_to_hash([ "if", "while", "do", "for", "for-in", "with" ]); - -function gen_code(ast, options) { - options = defaults(options, { - indent_start : 0, - indent_level : 4, - quote_keys : false, - space_colon : false, - beautify : false, - ascii_only : false - }); - var beautify = !!options.beautify; - var indentation = 0, - newline = beautify ? "\n" : "", - space = beautify ? " " : ""; - - function encode_string(str) { - return make_string(str, options.ascii_only); - }; - - function make_name(name) { - name = name.toString(); - if (options.ascii_only) - name = to_ascii(name); - return name; - }; - - function indent(line) { - if (line == null) - line = ""; - if (beautify) - line = repeat_string(" ", options.indent_start + indentation * options.indent_level) + line; - return line; - }; - - function with_indent(cont, incr) { - if (incr == null) incr = 1; - indentation += incr; - try { return cont.apply(null, slice(arguments, 1)); } - finally { indentation -= incr; } - }; - - function add_spaces(a) { - if (beautify) - return a.join(" "); - var b = []; - for (var i = 0; i < a.length; ++i) { - var next = a[i + 1]; - b.push(a[i]); - if (next && - ((/[a-z0-9_\x24]$/i.test(a[i].toString()) && /^[a-z0-9_\x24]/i.test(next.toString())) || - (/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) { - b.push(" "); - } - } - return b.join(""); - }; - - function add_commas(a) { - return a.join("," + space); - }; - - function parenthesize(expr) { - var gen = make(expr); - for (var i = 1; i < arguments.length; ++i) { - var el = arguments[i]; - if ((el instanceof Function && el(expr)) || expr[0] == el) - return "(" + gen + ")"; - } - return gen; - }; - - function best_of(a) { - if (a.length == 1) { - return a[0]; - } - if (a.length == 2) { - var b = a[1]; - a = a[0]; - return a.length <= b.length ? a : b; - } - return best_of([ a[0], best_of(a.slice(1)) ]); - }; - - function needs_parens(expr) { - if (expr[0] == "function" || expr[0] == "object") { - // dot/call on a literal function requires the - // function literal itself to be parenthesized - // only if it's the first "thing" in a - // statement. This means that the parent is - // "stat", but it could also be a "seq" and - // we're the first in this "seq" and the - // parent is "stat", and so on. Messy stuff, - // but it worths the trouble. - var a = slice($stack), self = a.pop(), p = a.pop(); - while (p) { - if (p[0] == "stat") return true; - if (((p[0] == "seq" || p[0] == "call" || p[0] == "dot" || p[0] == "sub" || p[0] == "conditional") && p[1] === self) || - ((p[0] == "binary" || p[0] == "assign" || p[0] == "unary-postfix") && p[2] === self)) { - self = p; - p = a.pop(); - } else { - return false; - } - } - } - return !HOP(DOT_CALL_NO_PARENS, expr[0]); - }; - - function make_num(num) { - var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m; - if (Math.floor(num) === num) { - a.push("0x" + num.toString(16).toLowerCase(), // probably pointless - "0" + num.toString(8)); // same. - if ((m = /^(.*?)(0+)$/.exec(num))) { - a.push(m[1] + "e" + m[2].length); - } - } else if ((m = /^0?\.(0+)(.*)$/.exec(num))) { - a.push(m[2] + "e-" + (m[1].length + m[2].length), - str.substr(str.indexOf("."))); - } - return best_of(a); - }; - - var generators = { - "string": encode_string, - "num": make_num, - "name": make_name, - "toplevel": function(statements) { - return make_block_statements(statements) - .join(newline + newline); - }, - "splice": function(statements) { - var parent = $stack[$stack.length - 2][0]; - if (HOP(SPLICE_NEEDS_BRACKETS, parent)) { - // we need block brackets in this case - return make_block.apply(this, arguments); - } else { - return MAP(make_block_statements(statements, true), - function(line, i) { - // the first line is already indented - return i > 0 ? indent(line) : line; - }).join(newline); - } - }, - "block": make_block, - "var": function(defs) { - return "var " + add_commas(MAP(defs, make_1vardef)) + ";"; - }, - "const": function(defs) { - return "const " + add_commas(MAP(defs, make_1vardef)) + ";"; - }, - "try": function(tr, ca, fi) { - var out = [ "try", make_block(tr) ]; - if (ca) out.push("catch", "(" + ca[0] + ")", make_block(ca[1])); - if (fi) out.push("finally", make_block(fi)); - return add_spaces(out); - }, - "throw": function(expr) { - return add_spaces([ "throw", make(expr) ]) + ";"; - }, - "new": function(ctor, args) { - args = args.length > 0 ? "(" + add_commas(MAP(args, make)) + ")" : ""; - return add_spaces([ "new", parenthesize(ctor, "seq", "binary", "conditional", "assign", function(expr){ - var w = ast_walker(), has_call = {}; - try { - w.with_walkers({ - "call": function() { throw has_call }, - "function": function() { return this } - }, function(){ - w.walk(expr); - }); - } catch(ex) { - if (ex === has_call) - return true; - throw ex; - } - }) + args ]); - }, - "switch": function(expr, body) { - return add_spaces([ "switch", "(" + make(expr) + ")", make_switch_block(body) ]); - }, - "break": function(label) { - var out = "break"; - if (label != null) - out += " " + make_name(label); - return out + ";"; - }, - "continue": function(label) { - var out = "continue"; - if (label != null) - out += " " + make_name(label); - return out + ";"; - }, - "conditional": function(co, th, el) { - return add_spaces([ parenthesize(co, "assign", "seq", "conditional"), "?", - parenthesize(th, "seq"), ":", - parenthesize(el, "seq") ]); - }, - "assign": function(op, lvalue, rvalue) { - if (op && op !== true) op += "="; - else op = "="; - return add_spaces([ make(lvalue), op, parenthesize(rvalue, "seq") ]); - }, - "dot": function(expr) { - var out = make(expr), i = 1; - if (expr[0] == "num") { - if (!/\./.test(expr[1])) - out += "."; - } else if (needs_parens(expr)) - out = "(" + out + ")"; - while (i < arguments.length) - out += "." + make_name(arguments[i++]); - return out; - }, - "call": function(func, args) { - var f = make(func); - if (needs_parens(func)) - f = "(" + f + ")"; - return f + "(" + add_commas(MAP(args, function(expr){ - return parenthesize(expr, "seq"); - })) + ")"; - }, - "function": make_function, - "defun": make_function, - "if": function(co, th, el) { - var out = [ "if", "(" + make(co) + ")", el ? make_then(th) : make(th) ]; - if (el) { - out.push("else", make(el)); - } - return add_spaces(out); - }, - "for": function(init, cond, step, block) { - var out = [ "for" ]; - init = (init != null ? make(init) : "").replace(/;*\s*$/, ";" + space); - cond = (cond != null ? make(cond) : "").replace(/;*\s*$/, ";" + space); - step = (step != null ? make(step) : "").replace(/;*\s*$/, ""); - var args = init + cond + step; - if (args == "; ; ") args = ";;"; - out.push("(" + args + ")", make(block)); - return add_spaces(out); - }, - "for-in": function(vvar, key, hash, block) { - return add_spaces([ "for", "(" + - (vvar ? make(vvar).replace(/;+$/, "") : make(key)), - "in", - make(hash) + ")", make(block) ]); - }, - "while": function(condition, block) { - return add_spaces([ "while", "(" + make(condition) + ")", make(block) ]); - }, - "do": function(condition, block) { - return add_spaces([ "do", make(block), "while", "(" + make(condition) + ")" ]) + ";"; - }, - "return": function(expr) { - var out = [ "return" ]; - if (expr != null) out.push(make(expr)); - return add_spaces(out) + ";"; - }, - "binary": function(operator, lvalue, rvalue) { - var left = make(lvalue), right = make(rvalue); - // XXX: I'm pretty sure other cases will bite here. - // we need to be smarter. - // adding parens all the time is the safest bet. - if (member(lvalue[0], [ "assign", "conditional", "seq" ]) || - lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]]) { - left = "(" + left + ")"; - } - if (member(rvalue[0], [ "assign", "conditional", "seq" ]) || - rvalue[0] == "binary" && PRECEDENCE[operator] >= PRECEDENCE[rvalue[1]] && - !(rvalue[1] == operator && member(operator, [ "&&", "||", "*" ]))) { - right = "(" + right + ")"; - } - return add_spaces([ left, operator, right ]); - }, - "unary-prefix": function(operator, expr) { - var val = make(expr); - if (!(expr[0] == "num" || (expr[0] == "unary-prefix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr))) - val = "(" + val + ")"; - return operator + (jsp.is_alphanumeric_char(operator.charAt(0)) ? " " : "") + val; - }, - "unary-postfix": function(operator, expr) { - var val = make(expr); - if (!(expr[0] == "num" || (expr[0] == "unary-postfix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr))) - val = "(" + val + ")"; - return val + operator; - }, - "sub": function(expr, subscript) { - var hash = make(expr); - if (needs_parens(expr)) - hash = "(" + hash + ")"; - return hash + "[" + make(subscript) + "]"; - }, - "object": function(props) { - if (props.length == 0) - return "{}"; - return "{" + newline + with_indent(function(){ - return MAP(props, function(p){ - if (p.length == 3) { - // getter/setter. The name is in p[0], the arg.list in p[1][2], the - // body in p[1][3] and type ("get" / "set") in p[2]. - return indent(make_function(p[0], p[1][2], p[1][3], p[2])); - } - var key = p[0], val = make(p[1]); - if (options.quote_keys) { - key = encode_string(key); - } else if ((typeof key == "number" || !beautify && +key + "" == key) - && parseFloat(key) >= 0) { - key = make_num(+key); - } else if (!is_identifier(key)) { - key = encode_string(key); - } - return indent(add_spaces(beautify && options.space_colon - ? [ key, ":", val ] - : [ key + ":", val ])); - }).join("," + newline); - }) + newline + indent("}"); - }, - "regexp": function(rx, mods) { - return "/" + rx + "/" + mods; - }, - "array": function(elements) { - if (elements.length == 0) return "[]"; - return add_spaces([ "[", add_commas(MAP(elements, function(el){ - if (!beautify && el[0] == "atom" && el[1] == "undefined") return ""; - return parenthesize(el, "seq"); - })), "]" ]); - }, - "stat": function(stmt) { - return make(stmt).replace(/;*\s*$/, ";"); - }, - "seq": function() { - return add_commas(MAP(slice(arguments), make)); - }, - "label": function(name, block) { - return add_spaces([ make_name(name), ":", make(block) ]); - }, - "with": function(expr, block) { - return add_spaces([ "with", "(" + make(expr) + ")", make(block) ]); - }, - "atom": function(name) { - return make_name(name); - } - }; - - // The squeezer replaces "block"-s that contain only a single - // statement with the statement itself; technically, the AST - // is correct, but this can create problems when we output an - // IF having an ELSE clause where the THEN clause ends in an - // IF *without* an ELSE block (then the outer ELSE would refer - // to the inner IF). This function checks for this case and - // adds the block brackets if needed. - function make_then(th) { - if (th[0] == "do") { - // https://github.com/mishoo/UglifyJS/issues/#issue/57 - // IE croaks with "syntax error" on code like this: - // if (foo) do ... while(cond); else ... - // we need block brackets around do/while - return make([ "block", [ th ]]); - } - var b = th; - while (true) { - var type = b[0]; - if (type == "if") { - if (!b[3]) - // no else, we must add the block - return make([ "block", [ th ]]); - b = b[3]; - } - else if (type == "while" || type == "do") b = b[2]; - else if (type == "for" || type == "for-in") b = b[4]; - else break; - } - return make(th); - }; - - function make_function(name, args, body, keyword) { - var out = keyword || "function"; - if (name) { - out += " " + make_name(name); - } - out += "(" + add_commas(MAP(args, make_name)) + ")"; - return add_spaces([ out, make_block(body) ]); - }; - - function make_block_statements(statements, noindent) { - for (var a = [], last = statements.length - 1, i = 0; i <= last; ++i) { - var stat = statements[i]; - var code = make(stat); - if (code != ";") { - if (!beautify && i == last) { - if ((stat[0] == "while" && empty(stat[2])) || - (member(stat[0], [ "for", "for-in"] ) && empty(stat[4])) || - (stat[0] == "if" && empty(stat[2]) && !stat[3]) || - (stat[0] == "if" && stat[3] && empty(stat[3]))) { - code = code.replace(/;*\s*$/, ";"); - } else { - code = code.replace(/;+\s*$/, ""); - } - } - a.push(code); - } - } - return noindent ? a : MAP(a, indent); - }; - - function make_switch_block(body) { - var n = body.length; - if (n == 0) return "{}"; - return "{" + newline + MAP(body, function(branch, i){ - var has_body = branch[1].length > 0, code = with_indent(function(){ - return indent(branch[0] - ? add_spaces([ "case", make(branch[0]) + ":" ]) - : "default:"); - }, 0.5) + (has_body ? newline + with_indent(function(){ - return make_block_statements(branch[1]).join(newline); - }) : ""); - if (!beautify && has_body && i < n - 1) - code += ";"; - return code; - }).join(newline) + newline + indent("}"); - }; - - function make_block(statements) { - if (!statements) return ";"; - if (statements.length == 0) return "{}"; - return "{" + newline + with_indent(function(){ - return make_block_statements(statements).join(newline); - }) + newline + indent("}"); - }; - - function make_1vardef(def) { - var name = def[0], val = def[1]; - if (val != null) - name = add_spaces([ make_name(name), "=", parenthesize(val, "seq") ]); - return name; - }; - - var $stack = []; - - function make(node) { - var type = node[0]; - var gen = generators[type]; - if (!gen) - throw new Error("Can't find generator for \"" + type + "\""); - $stack.push(node); - var ret = gen.apply(type, node.slice(1)); - $stack.pop(); - return ret; - }; - - return make(ast); -}; - -function split_lines(code, max_line_length) { - var splits = [ 0 ]; - jsp.parse(function(){ - var next_token = jsp.tokenizer(code); - var last_split = 0; - var prev_token; - function current_length(tok) { - return tok.pos - last_split; - }; - function split_here(tok) { - last_split = tok.pos; - splits.push(last_split); - }; - function custom(){ - var tok = next_token.apply(this, arguments); - out: { - if (prev_token) { - if (prev_token.type == "keyword") break out; - } - if (current_length(tok) > max_line_length) { - switch (tok.type) { - case "keyword": - case "atom": - case "name": - case "punc": - split_here(tok); - break out; - } - } - } - prev_token = tok; - return tok; - }; - custom.context = function() { - return next_token.context.apply(this, arguments); - }; - return custom; - }()); - return splits.map(function(pos, i){ - return code.substring(pos, splits[i + 1] || code.length); - }).join("\n"); -}; - -/* -----[ Utilities ]----- */ - -function repeat_string(str, i) { - if (i <= 0) return ""; - if (i == 1) return str; - var d = repeat_string(str, i >> 1); - d += d; - if (i & 1) d += str; - return d; -}; - -function defaults(args, defs) { - var ret = {}; - if (args === true) - args = {}; - for (var i in defs) if (HOP(defs, i)) { - ret[i] = (args && HOP(args, i)) ? args[i] : defs[i]; - } - return ret; -}; - -function is_identifier(name) { - return /^[a-z_$][a-z0-9_$]*$/i.test(name) - && name != "this" - && !HOP(jsp.KEYWORDS_ATOM, name) - && !HOP(jsp.RESERVED_WORDS, name) - && !HOP(jsp.KEYWORDS, name); -}; - -function HOP(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - -// some utilities - -var MAP; - -(function(){ - MAP = function(a, f, o) { - var ret = []; - for (var i = 0; i < a.length; ++i) { - var val = f.call(o, a[i], i); - if (val instanceof AtTop) ret.unshift(val.v); - else ret.push(val); - } - return ret; - }; - MAP.at_top = function(val) { return new AtTop(val) }; - function AtTop(val) { this.v = val }; -})(); - -/* -----[ Exports ]----- */ - -exports.ast_walker = ast_walker; -exports.ast_mangle = ast_mangle; -exports.ast_squeeze = ast_squeeze; -exports.gen_code = gen_code; -exports.ast_add_scope = ast_add_scope; -exports.set_logger = function(logger) { warn = logger }; -exports.make_string = make_string; -exports.split_lines = split_lines; -exports.MAP = MAP; - -// keep this last! -exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more; -; - }).call(module.exports); - - __require.modules["/node_modules/uglify-js/lib/process.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/uglify-js/lib/squeeze-more.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/uglify-js/lib"; - var __filename = "/node_modules/uglify-js/lib/squeeze-more.js"; - - var require = function (file) { - return __require(file, "/node_modules/uglify-js/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/uglify-js/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/uglify-js/lib/squeeze-more.js"]._cached = module.exports; - - (function () { - var jsp = require("./parse-js"), - pro = require("./process"), - slice = jsp.slice, - member = jsp.member, - PRECEDENCE = jsp.PRECEDENCE, - OPERATORS = jsp.OPERATORS; - -function ast_squeeze_more(ast) { - var w = pro.ast_walker(), walk = w.walk; - return w.with_walkers({ - "call": function(expr, args) { - if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) { - // foo.toString() ==> foo+"" - return [ "binary", "+", expr[1], [ "string", "" ]]; - } - } - }, function() { - return walk(ast); - }); -}; - -exports.ast_squeeze_more = ast_squeeze_more; -; - }).call(module.exports); - - __require.modules["/node_modules/uglify-js/lib/squeeze-more.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/traverse/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/traverse"; - var __filename = "/node_modules/traverse/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/traverse"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/traverse"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/traverse/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"traverse","version":"0.5.0","description":"Traverse and transform objects by visiting every node on a recursive walk","author":"James Halliday","license":"MIT/X11","main":"./index","repository":{"type":"git","url":"https://github.com/substack/js-traverse.git"},"devDependencies":{"expresso":"0.7.x"},"scripts":{"test":"expresso"}}; - }).call(module.exports); - - __require.modules["/node_modules/traverse/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/traverse/index.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/traverse"; - var __filename = "/node_modules/traverse/index.js"; - - var require = function (file) { - return __require(file, "/node_modules/traverse"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/traverse"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/traverse/index.js"]._cached = module.exports; - - (function () { - module.exports = Traverse; -function Traverse (obj) { - if (!(this instanceof Traverse)) return new Traverse(obj); - this.value = obj; -} - -Traverse.prototype.get = function (ps) { - var node = this.value; - for (var i = 0; i < ps.length; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) { - node = undefined; - break; - } - node = node[key]; - } - return node; -}; - -Traverse.prototype.set = function (ps, value) { - var node = this.value; - for (var i = 0; i < ps.length - 1; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) node[key] = {}; - node = node[key]; - } - node[ps[i]] = value; - return value; -}; - -Traverse.prototype.map = function (cb) { - return walk(this.value, cb, true); -}; - -Traverse.prototype.forEach = function (cb) { - this.value = walk(this.value, cb, false); - return this.value; -}; - -Traverse.prototype.reduce = function (cb, init) { - var skip = arguments.length === 1; - var acc = skip ? this.value : init; - this.forEach(function (x) { - if (!this.isRoot || !skip) { - acc = cb.call(this, acc, x); - } - }); - return acc; -}; - -Traverse.prototype.paths = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.path); - }); - return acc; -}; - -Traverse.prototype.nodes = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.node); - }); - return acc; -}; - -Traverse.prototype.clone = function () { - var parents = [], nodes = []; - - return (function clone (src) { - for (var i = 0; i < parents.length; i++) { - if (parents[i] === src) { - return nodes[i]; - } - } - - if (typeof src === 'object' && src !== null) { - var dst = copy(src); - - parents.push(src); - nodes.push(dst); - - forEach(Object_keys(src), function (key) { - dst[key] = clone(src[key]); - }); - - parents.pop(); - nodes.pop(); - return dst; - } - else { - return src; - } - })(this.value); -}; - -function walk (root, cb, immutable) { - var path = []; - var parents = []; - var alive = true; - - return (function walker (node_) { - var node = immutable ? copy(node_) : node_; - var modifiers = {}; - - var keepGoing = true; - - var state = { - node : node, - node_ : node_, - path : [].concat(path), - parent : parents[parents.length - 1], - parents : parents, - key : path.slice(-1)[0], - isRoot : path.length === 0, - level : path.length, - circular : null, - update : function (x, stopHere) { - if (!state.isRoot) { - state.parent.node[state.key] = x; - } - state.node = x; - if (stopHere) keepGoing = false; - }, - 'delete' : function () { - delete state.parent.node[state.key]; - }, - remove : function () { - if (Array_isArray(state.parent.node)) { - state.parent.node.splice(state.key, 1); - } - else { - delete state.parent.node[state.key]; - } - }, - keys : null, - before : function (f) { modifiers.before = f }, - after : function (f) { modifiers.after = f }, - pre : function (f) { modifiers.pre = f }, - post : function (f) { modifiers.post = f }, - stop : function () { alive = false }, - block : function () { keepGoing = false } - }; - - if (!alive) return state; - - if (typeof node === 'object' && node !== null) { - state.keys = Object_keys(node); - - state.isLeaf = state.keys.length == 0; - - for (var i = 0; i < parents.length; i++) { - if (parents[i].node_ === node_) { - state.circular = parents[i]; - break; - } - } - } - else { - state.isLeaf = true; - } - - state.notLeaf = !state.isLeaf; - state.notRoot = !state.isRoot; - - // use return values to update if defined - var ret = cb.call(state, state.node); - if (ret !== undefined && state.update) state.update(ret); - - if (modifiers.before) modifiers.before.call(state, state.node); - - if (!keepGoing) return state; - - if (typeof state.node == 'object' - && state.node !== null && !state.circular) { - parents.push(state); - - forEach(state.keys, function (key, i) { - path.push(key); - - if (modifiers.pre) modifiers.pre.call(state, state.node[key], key); - - var child = walker(state.node[key]); - if (immutable && Object.hasOwnProperty.call(state.node, key)) { - state.node[key] = child.node; - } - - child.isLast = i == state.keys.length - 1; - child.isFirst = i == 0; - - if (modifiers.post) modifiers.post.call(state, child); - - path.pop(); - }); - parents.pop(); - } - - if (modifiers.after) modifiers.after.call(state, state.node); - - return state; - })(root).node; -} - -function copy (src) { - if (typeof src === 'object' && src !== null) { - var dst; - - if (Array_isArray(src)) { - dst = []; - } - else if (src instanceof Date) { - dst = new Date(src); - } - else if (src instanceof Boolean) { - dst = new Boolean(src); - } - else if (src instanceof Number) { - dst = new Number(src); - } - else if (src instanceof String) { - dst = new String(src); - } - else if (Object.create && Object.getPrototypeOf) { - dst = Object.create(Object.getPrototypeOf(src)); - } - else if (src.__proto__ || src.constructor.prototype) { - var proto = src.__proto__ || src.constructor.prototype || {}; - var T = function () {}; - T.prototype = proto; - dst = new T; - if (!dst.__proto__) dst.__proto__ = proto; - } - - forEach(Object_keys(src), function (key) { - dst[key] = src[key]; - }); - return dst; - } - else return src; -} - -var Object_keys = Object.keys || function keys (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -forEach(Object_keys(Traverse.prototype), function (key) { - Traverse[key] = function (obj) { - var args = [].slice.call(arguments, 1); - var t = Traverse(obj); - return t[key].apply(t, args); - }; -}); -; - }).call(module.exports); - - __require.modules["/node_modules/traverse/index.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["vm"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "."; - var __filename = "vm"; - - var require = function (file) { - return __require(file, "."); - }; - - require.resolve = function (file) { - return __require.resolve(name, "."); - }; - - require.modules = __require.modules; - __require.modules["vm"]._cached = module.exports; - - (function () { - var Object_keys = function (obj) { - if (Object.keys) return Object.keys(obj) - else { - var res = []; - for (var key in obj) res.push(key) - return res; - } -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -var Script = exports.Script = function NodeScript (code) { - if (!(this instanceof Script)) return new Script(code); - this.code = code; -}; - -var iframe = document.createElement('iframe'); -if (!iframe.style) iframe.style = {}; -iframe.style.display = 'none'; - -var iframeCapable = true; // until proven otherwise -if (navigator.appName === 'Microsoft Internet Explorer') { - var m = navigator.appVersion.match(/\bMSIE (\d+\.\d+);/); - if (m && parseFloat(m[1]) < 9.0) { - iframeCapable = false; - } -} - -Script.prototype.runInNewContext = function (context) { - if (!context) context = {}; - - if (!iframeCapable) { - var keys = Object_keys(context); - var args = []; - for (var i = 0; i < keys.length; i++) { - args.push(context[keys[i]]); - } - - var fn = new Function(keys, 'return ' + this.code); - return fn.apply(null, args); - } - - document.body.appendChild(iframe); - - var win = iframe.contentWindow - || (window.frames && window.frames[window.frames.length - 1]) - || window[window.length - 1] - ; - - forEach(Object_keys(context), function (key) { - win[key] = context[key]; - iframe[key] = context[key]; - }); - - if (win.eval) { - // chrome and ff can just .eval() - var res = win.eval(this.code); - } - else { - // this works in IE9 but not anything newer - iframe.setAttribute('src', - 'javascript:__browserifyVmResult=(' + this.code + ')' - ); - if ('__browserifyVmResult' in win) { - var res = win.__browserifyVmResult; - } - else { - iframeCapable = false; - res = this.runInThisContext(context); - } - } - - forEach(Object_keys(win), function (key) { - context[key] = win[key]; - }); - - document.body.removeChild(iframe); - - return res; -}; - -Script.prototype.runInThisContext = function () { - return eval(this.code); // maybe... -}; - -Script.prototype.runInContext = function (context) { - // seems to be just runInNewContext on magical context objects which are - // otherwise indistinguishable from objects except plain old objects - // for the parameter segfaults node - return this.runInNewContext(context); -}; - -forEach(Object_keys(Script.prototype), function (name) { - exports[name] = Script[name] = function (code) { - var s = Script(code); - return s[name].apply(s, [].slice.call(arguments, 1)); - }; -}); - -exports.createScript = function (code) { - return exports.Script(code); -}; - -exports.createContext = Script.createContext = function (context) { - // not really sure what this one does - // seems to just make a shallow copy - var copy = {}; - forEach(Object_keys(context), function (key) { - copy[key] = context[key]; - }); - return copy; -}; -; - }).call(module.exports); - - __require.modules["vm"]._cached = module.exports; - return module.exports; -}; - -process.nextTick(function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/"; - var __filename = "//home/substack/projects/node-burrito"; - - var require = function (file) { - return __require(file, "/"); - }; - require.modules = __require.modules; - - var burrito = require('./'); - -window.onload = function () { - var res = burrito.microwave('Math.sin(2)', function (node) { - if (node.name === 'num') node.wrap('Math.PI / undefined'); - }); - - document.body.innerHTML += res; -}; - -if (document.readyState === 'complete') window.onload(); -; -}); - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/microwave.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/microwave.js deleted file mode 100644 index 2e4fee2f6..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/microwave.js +++ /dev/null @@ -1,7 +0,0 @@ -var burrito = require('burrito'); - -var res = burrito.microwave('Math.sin(2)', function (node) { - if (node.name === 'num') node.wrap('Math.PI / %s'); -}); - -console.log(res); // sin(pi / 2) == 1 diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/bs.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/bs.js deleted file mode 100644 index 3583c7f6d..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/bs.js +++ /dev/null @@ -1,4832 +0,0 @@ -var require = function (file, cwd) { - var resolved = require.resolve(file, cwd || '/'); - var mod = require.modules[resolved]; - if (!mod) throw new Error( - 'Failed to resolve module ' + file + ', tried ' + resolved - ); - var res = mod._cached ? mod._cached : mod(); - return res; -} -var __require = require; - -require.paths = []; -require.modules = {}; -require.extensions = [".js",".coffee"]; - -require.resolve = (function () { - var core = { - 'assert': true, - 'events': true, - 'fs': true, - 'path': true, - 'vm': true - }; - - return function (x, cwd) { - if (!cwd) cwd = '/'; - - if (core[x]) return x; - var path = require.modules.path(); - var y = cwd || '.'; - - if (x.match(/^(?:\.\.?\/|\/)/)) { - var m = loadAsFileSync(path.resolve(y, x)) - || loadAsDirectorySync(path.resolve(y, x)); - if (m) return m; - } - - var n = loadNodeModulesSync(x, y); - if (n) return n; - - throw new Error("Cannot find module '" + x + "'"); - - function loadAsFileSync (x) { - if (require.modules[x]) { - return x; - } - - for (var i = 0; i < require.extensions.length; i++) { - var ext = require.extensions[i]; - if (require.modules[x + ext]) return x + ext; - } - } - - function loadAsDirectorySync (x) { - x = x.replace(/\/+$/, ''); - var pkgfile = x + '/package.json'; - if (require.modules[pkgfile]) { - var pkg = require.modules[pkgfile](); - var b = pkg.browserify; - if (typeof b === 'object' && b.main) { - var m = loadAsFileSync(path.resolve(x, b.main)); - if (m) return m; - } - else if (typeof b === 'string') { - var m = loadAsFileSync(path.resolve(x, b)); - if (m) return m; - } - else if (pkg.main) { - var m = loadAsFileSync(path.resolve(x, pkg.main)); - if (m) return m; - } - } - - return loadAsFileSync(x + '/index'); - } - - function loadNodeModulesSync (x, start) { - var dirs = nodeModulesPathsSync(start); - for (var i = 0; i < dirs.length; i++) { - var dir = dirs[i]; - var m = loadAsFileSync(dir + '/' + x); - if (m) return m; - var n = loadAsDirectorySync(dir + '/' + x); - if (n) return n; - } - - var m = loadAsFileSync(x); - if (m) return m; - } - - function nodeModulesPathsSync (start) { - var parts; - if (start === '/') parts = [ '' ]; - else parts = path.normalize(start).split('/'); - - var dirs = []; - for (var i = parts.length - 1; i >= 0; i--) { - if (parts[i] === 'node_modules') continue; - var dir = parts.slice(0, i + 1).join('/') + '/node_modules'; - dirs.push(dir); - } - - return dirs; - } - }; -})(); - -require.alias = function (from, to) { - var path = require.modules.path(); - var res = null; - try { - res = require.resolve(from + '/package.json', '/'); - } - catch (err) { - res = require.resolve(from, '/'); - } - var basedir = path.dirname(res); - - var keys = Object_keys(require.modules); - - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (key.slice(0, basedir.length + 1) === basedir + '/') { - var f = key.slice(basedir.length); - require.modules[to + f] = require.modules[basedir + f]; - } - else if (key === basedir) { - require.modules[to] = require.modules[basedir]; - } - } -}; - -var Object_keys = Object.keys || function (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -if (typeof process === 'undefined') process = {}; - -if (!process.nextTick) process.nextTick = function (fn) { - setTimeout(fn, 0); -}; - -if (!process.title) process.title = 'browser'; - -if (!process.binding) process.binding = function (name) { - if (name === 'evals') return require('vm') - else throw new Error('No such module') -}; - -if (!process.cwd) process.cwd = function () { return '.' }; - -require.modules["path"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "."; - var __filename = "path"; - - var require = function (file) { - return __require(file, "."); - }; - - require.resolve = function (file) { - return __require.resolve(name, "."); - }; - - require.modules = __require.modules; - __require.modules["path"]._cached = module.exports; - - (function () { - function filter (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - if (fn(xs[i], i, xs)) res.push(xs[i]); - } - return res; -} - -// resolves . and .. elements in a path array with directory names there -// must be no slashes, empty elements, or device names (c:\) in the array -// (so also no leading and trailing slashes - it does not distinguish -// relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = parts.length; i >= 0; i--) { - var last = parts[i]; - if (last == '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); - } - } - - return parts; -} - -// Regex to split a filename into [*, dir, basename, ext] -// posix version -var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/; - -// path.resolve([from ...], to) -// posix version -exports.resolve = function() { -var resolvedPath = '', - resolvedAbsolute = false; - -for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) { - var path = (i >= 0) - ? arguments[i] - : process.cwd(); - - // Skip empty and invalid entries - if (typeof path !== 'string' || !path) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charAt(0) === '/'; -} - -// At this point the path should be resolved to a full absolute path, but -// handle relative paths to be safe (might happen when process.cwd() fails) - -// Normalize the path -resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { - return !!p; - }), !resolvedAbsolute).join('/'); - - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; -}; - -// path.normalize(path) -// posix version -exports.normalize = function(path) { -var isAbsolute = path.charAt(0) === '/', - trailingSlash = path.slice(-1) === '/'; - -// Normalize the path -path = normalizeArray(filter(path.split('/'), function(p) { - return !!p; - }), !isAbsolute).join('/'); - - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } - - return (isAbsolute ? '/' : '') + path; -}; - - -// posix version -exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(filter(paths, function(p, index) { - return p && typeof p === 'string'; - }).join('/')); -}; - - -exports.dirname = function(path) { - var dir = splitPathRe.exec(path)[1] || ''; - var isWindows = false; - if (!dir) { - // No dirname - return '.'; - } else if (dir.length === 1 || - (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) { - // It is just a slash or a drive letter with a slash - return dir; - } else { - // It is a full dirname, strip trailing slash - return dir.substring(0, dir.length - 1); - } -}; - - -exports.basename = function(path, ext) { - var f = splitPathRe.exec(path)[2] || ''; - // TODO: make this comparison case-insensitive on windows? - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); - } - return f; -}; - - -exports.extname = function(path) { - return splitPathRe.exec(path)[3] || ''; -}; -; - }).call(module.exports); - - __require.modules["path"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito"; - var __filename = "/node_modules/burrito/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/burrito"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"burrito","description":"Wrap up expressions with a trace function while walking the AST with rice and beans on the side","version":"0.2.8","repository":{"type":"git","url":"git://github.com/substack/node-burrito.git"},"main":"./index.js","keywords":["trace","ast","walk","syntax","source","tree","uglify"],"directories":{"lib":".","example":"example","test":"test"},"scripts":{"test":"expresso"},"dependencies":{"traverse":">=0.5.1 <0.6","uglify-js":"1.0.4"},"devDependencies":{"expresso":"=0.7.x"},"engines":{"node":">=0.4.0"},"license":"BSD","author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"}}; - }).call(module.exports); - - __require.modules["/node_modules/burrito/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"uglify-js","author":{"name":"Mihai Bazon","email":"mihai.bazon@gmail.com","url":"http://mihai.bazon.net/blog"},"version":"1.0.4","main":"./uglify-js.js","bin":{"uglifyjs":"./bin/uglifyjs"},"repository":{"type":"git","url":"git@github.com:mishoo/UglifyJS.git"}}; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/uglify-js.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/uglify-js.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/uglify-js.js"]._cached = module.exports; - - (function () { - //convienence function(src, [options]); -function uglify(orig_code, options){ - options || (options = {}); - var jsp = uglify.parser; - var pro = uglify.uglify; - - var ast = jsp.parse(orig_code, options.strict_semicolons); // parse code and get the initial AST - ast = pro.ast_mangle(ast, options.mangle_options); // get a new AST with mangled names - ast = pro.ast_squeeze(ast, options.squeeze_options); // get an AST with compression optimizations - var final_code = pro.gen_code(ast, options.gen_options); // compressed code here - return final_code; -}; - -uglify.parser = require("./lib/parse-js"); -uglify.uglify = require("./lib/process"); - -module.exports = uglify; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/uglify-js.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js/lib"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js"]._cached = module.exports; - - (function () { - /*********************************************************************** - - A JavaScript tokenizer / parser / beautifier / compressor. - - This version is suitable for Node.js. With minimal changes (the - exports stuff) it should work on any JS platform. - - This file contains the tokenizer/parser. It is a port to JavaScript - of parse-js [1], a JavaScript parser library written in Common Lisp - by Marijn Haverbeke. Thank you Marijn! - - [1] http://marijn.haverbeke.nl/parse-js/ - - Exported functions: - - - tokenizer(code) -- returns a function. Call the returned - function to fetch the next token. - - - parse(code) -- returns an AST of the given JavaScript code. - - -------------------------------- (C) --------------------------------- - - Author: Mihai Bazon - - http://mihai.bazon.net/blog - - Distributed under the BSD license: - - Copyright 2010 (c) Mihai Bazon - Based on parse-js (http://marijn.haverbeke.nl/parse-js/). - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - - ***********************************************************************/ - -/* -----[ Tokenizer (constants) ]----- */ - -var KEYWORDS = array_to_hash([ - "break", - "case", - "catch", - "const", - "continue", - "default", - "delete", - "do", - "else", - "finally", - "for", - "function", - "if", - "in", - "instanceof", - "new", - "return", - "switch", - "throw", - "try", - "typeof", - "var", - "void", - "while", - "with" -]); - -var RESERVED_WORDS = array_to_hash([ - "abstract", - "boolean", - "byte", - "char", - "class", - "debugger", - "double", - "enum", - "export", - "extends", - "final", - "float", - "goto", - "implements", - "import", - "int", - "interface", - "long", - "native", - "package", - "private", - "protected", - "public", - "short", - "static", - "super", - "synchronized", - "throws", - "transient", - "volatile" -]); - -var KEYWORDS_BEFORE_EXPRESSION = array_to_hash([ - "return", - "new", - "delete", - "throw", - "else", - "case" -]); - -var KEYWORDS_ATOM = array_to_hash([ - "false", - "null", - "true", - "undefined" -]); - -var OPERATOR_CHARS = array_to_hash(characters("+-*&%=<>!?|~^")); - -var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i; -var RE_OCT_NUMBER = /^0[0-7]+$/; -var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i; - -var OPERATORS = array_to_hash([ - "in", - "instanceof", - "typeof", - "new", - "void", - "delete", - "++", - "--", - "+", - "-", - "!", - "~", - "&", - "|", - "^", - "*", - "/", - "%", - ">>", - "<<", - ">>>", - "<", - ">", - "<=", - ">=", - "==", - "===", - "!=", - "!==", - "?", - "=", - "+=", - "-=", - "/=", - "*=", - "%=", - ">>=", - "<<=", - ">>>=", - "|=", - "^=", - "&=", - "&&", - "||" -]); - -var WHITESPACE_CHARS = array_to_hash(characters(" \u00a0\n\r\t\f\v\u200b")); - -var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:")); - -var PUNC_CHARS = array_to_hash(characters("[]{}(),;:")); - -var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy")); - -/* -----[ Tokenizer ]----- */ - -// regexps adapted from http://xregexp.com/plugins/#unicode -var UNICODE = { - letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"), - non_spacing_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"), - space_combining_mark: new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"), - connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]") -}; - -function is_letter(ch) { - return UNICODE.letter.test(ch); -}; - -function is_digit(ch) { - ch = ch.charCodeAt(0); - return ch >= 48 && ch <= 57; //XXX: find out if "UnicodeDigit" means something else than 0..9 -}; - -function is_alphanumeric_char(ch) { - return is_digit(ch) || is_letter(ch); -}; - -function is_unicode_combining_mark(ch) { - return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch); -}; - -function is_unicode_connector_punctuation(ch) { - return UNICODE.connector_punctuation.test(ch); -}; - -function is_identifier_start(ch) { - return ch == "$" || ch == "_" || is_letter(ch); -}; - -function is_identifier_char(ch) { - return is_identifier_start(ch) - || is_unicode_combining_mark(ch) - || is_digit(ch) - || is_unicode_connector_punctuation(ch) - || ch == "\u200c" // zero-width non-joiner - || ch == "\u200d" // zero-width joiner (in my ECMA-262 PDF, this is also 200c) - ; -}; - -function parse_js_number(num) { - if (RE_HEX_NUMBER.test(num)) { - return parseInt(num.substr(2), 16); - } else if (RE_OCT_NUMBER.test(num)) { - return parseInt(num.substr(1), 8); - } else if (RE_DEC_NUMBER.test(num)) { - return parseFloat(num); - } -}; - -function JS_Parse_Error(message, line, col, pos) { - this.message = message; - this.line = line; - this.col = col; - this.pos = pos; - try { - ({})(); - } catch(ex) { - this.stack = ex.stack; - }; -}; - -JS_Parse_Error.prototype.toString = function() { - return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack; -}; - -function js_error(message, line, col, pos) { - throw new JS_Parse_Error(message, line, col, pos); -}; - -function is_token(token, type, val) { - return token.type == type && (val == null || token.value == val); -}; - -var EX_EOF = {}; - -function tokenizer($TEXT) { - - var S = { - text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''), - pos : 0, - tokpos : 0, - line : 0, - tokline : 0, - col : 0, - tokcol : 0, - newline_before : false, - regex_allowed : false, - comments_before : [] - }; - - function peek() { return S.text.charAt(S.pos); }; - - function next(signal_eof) { - var ch = S.text.charAt(S.pos++); - if (signal_eof && !ch) - throw EX_EOF; - if (ch == "\n") { - S.newline_before = true; - ++S.line; - S.col = 0; - } else { - ++S.col; - } - return ch; - }; - - function eof() { - return !S.peek(); - }; - - function find(what, signal_eof) { - var pos = S.text.indexOf(what, S.pos); - if (signal_eof && pos == -1) throw EX_EOF; - return pos; - }; - - function start_token() { - S.tokline = S.line; - S.tokcol = S.col; - S.tokpos = S.pos; - }; - - function token(type, value, is_comment) { - S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) || - (type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) || - (type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value))); - var ret = { - type : type, - value : value, - line : S.tokline, - col : S.tokcol, - pos : S.tokpos, - nlb : S.newline_before - }; - if (!is_comment) { - ret.comments_before = S.comments_before; - S.comments_before = []; - } - S.newline_before = false; - return ret; - }; - - function skip_whitespace() { - while (HOP(WHITESPACE_CHARS, peek())) - next(); - }; - - function read_while(pred) { - var ret = "", ch = peek(), i = 0; - while (ch && pred(ch, i++)) { - ret += next(); - ch = peek(); - } - return ret; - }; - - function parse_error(err) { - js_error(err, S.tokline, S.tokcol, S.tokpos); - }; - - function read_num(prefix) { - var has_e = false, after_e = false, has_x = false, has_dot = prefix == "."; - var num = read_while(function(ch, i){ - if (ch == "x" || ch == "X") { - if (has_x) return false; - return has_x = true; - } - if (!has_x && (ch == "E" || ch == "e")) { - if (has_e) return false; - return has_e = after_e = true; - } - if (ch == "-") { - if (after_e || (i == 0 && !prefix)) return true; - return false; - } - if (ch == "+") return after_e; - after_e = false; - if (ch == ".") { - if (!has_dot && !has_x) - return has_dot = true; - return false; - } - return is_alphanumeric_char(ch); - }); - if (prefix) - num = prefix + num; - var valid = parse_js_number(num); - if (!isNaN(valid)) { - return token("num", valid); - } else { - parse_error("Invalid syntax: " + num); - } - }; - - function read_escaped_char() { - var ch = next(true); - switch (ch) { - case "n" : return "\n"; - case "r" : return "\r"; - case "t" : return "\t"; - case "b" : return "\b"; - case "v" : return "\v"; - case "f" : return "\f"; - case "0" : return "\0"; - case "x" : return String.fromCharCode(hex_bytes(2)); - case "u" : return String.fromCharCode(hex_bytes(4)); - default : return ch; - } - }; - - function hex_bytes(n) { - var num = 0; - for (; n > 0; --n) { - var digit = parseInt(next(true), 16); - if (isNaN(digit)) - parse_error("Invalid hex-character pattern in string"); - num = (num << 4) | digit; - } - return num; - }; - - function read_string() { - return with_eof_error("Unterminated string constant", function(){ - var quote = next(), ret = ""; - for (;;) { - var ch = next(true); - if (ch == "\\") ch = read_escaped_char(); - else if (ch == quote) break; - ret += ch; - } - return token("string", ret); - }); - }; - - function read_line_comment() { - next(); - var i = find("\n"), ret; - if (i == -1) { - ret = S.text.substr(S.pos); - S.pos = S.text.length; - } else { - ret = S.text.substring(S.pos, i); - S.pos = i; - } - return token("comment1", ret, true); - }; - - function read_multiline_comment() { - next(); - return with_eof_error("Unterminated multiline comment", function(){ - var i = find("*/", true), - text = S.text.substring(S.pos, i), - tok = token("comment2", text, true); - S.pos = i + 2; - S.line += text.split("\n").length - 1; - S.newline_before = text.indexOf("\n") >= 0; - - // https://github.com/mishoo/UglifyJS/issues/#issue/100 - if (/^@cc_on/i.test(text)) { - warn("WARNING: at line " + S.line); - warn("*** Found \"conditional comment\": " + text); - warn("*** UglifyJS DISCARDS ALL COMMENTS. This means your code might no longer work properly in Internet Explorer."); - } - - return tok; - }); - }; - - function read_name() { - var backslash = false, name = "", ch; - while ((ch = peek()) != null) { - if (!backslash) { - if (ch == "\\") backslash = true, next(); - else if (is_identifier_char(ch)) name += next(); - else break; - } - else { - if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX"); - ch = read_escaped_char(); - if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier"); - name += ch; - backslash = false; - } - } - return name; - }; - - function read_regexp() { - return with_eof_error("Unterminated regular expression", function(){ - var prev_backslash = false, regexp = "", ch, in_class = false; - while ((ch = next(true))) if (prev_backslash) { - regexp += "\\" + ch; - prev_backslash = false; - } else if (ch == "[") { - in_class = true; - regexp += ch; - } else if (ch == "]" && in_class) { - in_class = false; - regexp += ch; - } else if (ch == "/" && !in_class) { - break; - } else if (ch == "\\") { - prev_backslash = true; - } else { - regexp += ch; - } - var mods = read_name(); - return token("regexp", [ regexp, mods ]); - }); - }; - - function read_operator(prefix) { - function grow(op) { - if (!peek()) return op; - var bigger = op + peek(); - if (HOP(OPERATORS, bigger)) { - next(); - return grow(bigger); - } else { - return op; - } - }; - return token("operator", grow(prefix || next())); - }; - - function handle_slash() { - next(); - var regex_allowed = S.regex_allowed; - switch (peek()) { - case "/": - S.comments_before.push(read_line_comment()); - S.regex_allowed = regex_allowed; - return next_token(); - case "*": - S.comments_before.push(read_multiline_comment()); - S.regex_allowed = regex_allowed; - return next_token(); - } - return S.regex_allowed ? read_regexp() : read_operator("/"); - }; - - function handle_dot() { - next(); - return is_digit(peek()) - ? read_num(".") - : token("punc", "."); - }; - - function read_word() { - var word = read_name(); - return !HOP(KEYWORDS, word) - ? token("name", word) - : HOP(OPERATORS, word) - ? token("operator", word) - : HOP(KEYWORDS_ATOM, word) - ? token("atom", word) - : token("keyword", word); - }; - - function with_eof_error(eof_error, cont) { - try { - return cont(); - } catch(ex) { - if (ex === EX_EOF) parse_error(eof_error); - else throw ex; - } - }; - - function next_token(force_regexp) { - if (force_regexp) - return read_regexp(); - skip_whitespace(); - start_token(); - var ch = peek(); - if (!ch) return token("eof"); - if (is_digit(ch)) return read_num(); - if (ch == '"' || ch == "'") return read_string(); - if (HOP(PUNC_CHARS, ch)) return token("punc", next()); - if (ch == ".") return handle_dot(); - if (ch == "/") return handle_slash(); - if (HOP(OPERATOR_CHARS, ch)) return read_operator(); - if (ch == "\\" || is_identifier_start(ch)) return read_word(); - parse_error("Unexpected character '" + ch + "'"); - }; - - next_token.context = function(nc) { - if (nc) S = nc; - return S; - }; - - return next_token; - -}; - -/* -----[ Parser (constants) ]----- */ - -var UNARY_PREFIX = array_to_hash([ - "typeof", - "void", - "delete", - "--", - "++", - "!", - "~", - "-", - "+" -]); - -var UNARY_POSTFIX = array_to_hash([ "--", "++" ]); - -var ASSIGNMENT = (function(a, ret, i){ - while (i < a.length) { - ret[a[i]] = a[i].substr(0, a[i].length - 1); - i++; - } - return ret; -})( - ["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&="], - { "=": true }, - 0 -); - -var PRECEDENCE = (function(a, ret){ - for (var i = 0, n = 1; i < a.length; ++i, ++n) { - var b = a[i]; - for (var j = 0; j < b.length; ++j) { - ret[b[j]] = n; - } - } - return ret; -})( - [ - ["||"], - ["&&"], - ["|"], - ["^"], - ["&"], - ["==", "===", "!=", "!=="], - ["<", ">", "<=", ">=", "in", "instanceof"], - [">>", "<<", ">>>"], - ["+", "-"], - ["*", "/", "%"] - ], - {} -); - -var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]); - -var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]); - -/* -----[ Parser ]----- */ - -function NodeWithToken(str, start, end) { - this.name = str; - this.start = start; - this.end = end; -}; - -NodeWithToken.prototype.toString = function() { return this.name; }; - -function parse($TEXT, exigent_mode, embed_tokens) { - - var S = { - input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT, - token : null, - prev : null, - peeked : null, - in_function : 0, - in_loop : 0, - labels : [] - }; - - S.token = next(); - - function is(type, value) { - return is_token(S.token, type, value); - }; - - function peek() { return S.peeked || (S.peeked = S.input()); }; - - function next() { - S.prev = S.token; - if (S.peeked) { - S.token = S.peeked; - S.peeked = null; - } else { - S.token = S.input(); - } - return S.token; - }; - - function prev() { - return S.prev; - }; - - function croak(msg, line, col, pos) { - var ctx = S.input.context(); - js_error(msg, - line != null ? line : ctx.tokline, - col != null ? col : ctx.tokcol, - pos != null ? pos : ctx.tokpos); - }; - - function token_error(token, msg) { - croak(msg, token.line, token.col); - }; - - function unexpected(token) { - if (token == null) - token = S.token; - token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")"); - }; - - function expect_token(type, val) { - if (is(type, val)) { - return next(); - } - token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type); - }; - - function expect(punc) { return expect_token("punc", punc); }; - - function can_insert_semicolon() { - return !exigent_mode && ( - S.token.nlb || is("eof") || is("punc", "}") - ); - }; - - function semicolon() { - if (is("punc", ";")) next(); - else if (!can_insert_semicolon()) unexpected(); - }; - - function as() { - return slice(arguments); - }; - - function parenthesised() { - expect("("); - var ex = expression(); - expect(")"); - return ex; - }; - - function add_tokens(str, start, end) { - return str instanceof NodeWithToken ? str : new NodeWithToken(str, start, end); - }; - - function maybe_embed_tokens(parser) { - if (embed_tokens) return function() { - var start = S.token; - var ast = parser.apply(this, arguments); - ast[0] = add_tokens(ast[0], start, prev()); - return ast; - }; - else return parser; - }; - - var statement = maybe_embed_tokens(function() { - if (is("operator", "/")) { - S.peeked = null; - S.token = S.input(true); // force regexp - } - switch (S.token.type) { - case "num": - case "string": - case "regexp": - case "operator": - case "atom": - return simple_statement(); - - case "name": - return is_token(peek(), "punc", ":") - ? labeled_statement(prog1(S.token.value, next, next)) - : simple_statement(); - - case "punc": - switch (S.token.value) { - case "{": - return as("block", block_()); - case "[": - case "(": - return simple_statement(); - case ";": - next(); - return as("block"); - default: - unexpected(); - } - - case "keyword": - switch (prog1(S.token.value, next)) { - case "break": - return break_cont("break"); - - case "continue": - return break_cont("continue"); - - case "debugger": - semicolon(); - return as("debugger"); - - case "do": - return (function(body){ - expect_token("keyword", "while"); - return as("do", prog1(parenthesised, semicolon), body); - })(in_loop(statement)); - - case "for": - return for_(); - - case "function": - return function_(true); - - case "if": - return if_(); - - case "return": - if (S.in_function == 0) - croak("'return' outside of function"); - return as("return", - is("punc", ";") - ? (next(), null) - : can_insert_semicolon() - ? null - : prog1(expression, semicolon)); - - case "switch": - return as("switch", parenthesised(), switch_block_()); - - case "throw": - return as("throw", prog1(expression, semicolon)); - - case "try": - return try_(); - - case "var": - return prog1(var_, semicolon); - - case "const": - return prog1(const_, semicolon); - - case "while": - return as("while", parenthesised(), in_loop(statement)); - - case "with": - return as("with", parenthesised(), statement()); - - default: - unexpected(); - } - } - }); - - function labeled_statement(label) { - S.labels.push(label); - var start = S.token, stat = statement(); - if (exigent_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0])) - unexpected(start); - S.labels.pop(); - return as("label", label, stat); - }; - - function simple_statement() { - return as("stat", prog1(expression, semicolon)); - }; - - function break_cont(type) { - var name; - if (!can_insert_semicolon()) { - name = is("name") ? S.token.value : null; - } - if (name != null) { - next(); - if (!member(name, S.labels)) - croak("Label " + name + " without matching loop or statement"); - } - else if (S.in_loop == 0) - croak(type + " not inside a loop or switch"); - semicolon(); - return as(type, name); - }; - - function for_() { - expect("("); - var init = null; - if (!is("punc", ";")) { - init = is("keyword", "var") - ? (next(), var_(true)) - : expression(true, true); - if (is("operator", "in")) - return for_in(init); - } - return regular_for(init); - }; - - function regular_for(init) { - expect(";"); - var test = is("punc", ";") ? null : expression(); - expect(";"); - var step = is("punc", ")") ? null : expression(); - expect(")"); - return as("for", init, test, step, in_loop(statement)); - }; - - function for_in(init) { - var lhs = init[0] == "var" ? as("name", init[1][0]) : init; - next(); - var obj = expression(); - expect(")"); - return as("for-in", init, lhs, obj, in_loop(statement)); - }; - - var function_ = maybe_embed_tokens(function(in_statement) { - var name = is("name") ? prog1(S.token.value, next) : null; - if (in_statement && !name) - unexpected(); - expect("("); - return as(in_statement ? "defun" : "function", - name, - // arguments - (function(first, a){ - while (!is("punc", ")")) { - if (first) first = false; else expect(","); - if (!is("name")) unexpected(); - a.push(S.token.value); - next(); - } - next(); - return a; - })(true, []), - // body - (function(){ - ++S.in_function; - var loop = S.in_loop; - S.in_loop = 0; - var a = block_(); - --S.in_function; - S.in_loop = loop; - return a; - })()); - }); - - function if_() { - var cond = parenthesised(), body = statement(), belse; - if (is("keyword", "else")) { - next(); - belse = statement(); - } - return as("if", cond, body, belse); - }; - - function block_() { - expect("{"); - var a = []; - while (!is("punc", "}")) { - if (is("eof")) unexpected(); - a.push(statement()); - } - next(); - return a; - }; - - var switch_block_ = curry(in_loop, function(){ - expect("{"); - var a = [], cur = null; - while (!is("punc", "}")) { - if (is("eof")) unexpected(); - if (is("keyword", "case")) { - next(); - cur = []; - a.push([ expression(), cur ]); - expect(":"); - } - else if (is("keyword", "default")) { - next(); - expect(":"); - cur = []; - a.push([ null, cur ]); - } - else { - if (!cur) unexpected(); - cur.push(statement()); - } - } - next(); - return a; - }); - - function try_() { - var body = block_(), bcatch, bfinally; - if (is("keyword", "catch")) { - next(); - expect("("); - if (!is("name")) - croak("Name expected"); - var name = S.token.value; - next(); - expect(")"); - bcatch = [ name, block_() ]; - } - if (is("keyword", "finally")) { - next(); - bfinally = block_(); - } - if (!bcatch && !bfinally) - croak("Missing catch/finally blocks"); - return as("try", body, bcatch, bfinally); - }; - - function vardefs(no_in) { - var a = []; - for (;;) { - if (!is("name")) - unexpected(); - var name = S.token.value; - next(); - if (is("operator", "=")) { - next(); - a.push([ name, expression(false, no_in) ]); - } else { - a.push([ name ]); - } - if (!is("punc", ",")) - break; - next(); - } - return a; - }; - - function var_(no_in) { - return as("var", vardefs(no_in)); - }; - - function const_() { - return as("const", vardefs()); - }; - - function new_() { - var newexp = expr_atom(false), args; - if (is("punc", "(")) { - next(); - args = expr_list(")"); - } else { - args = []; - } - return subscripts(as("new", newexp, args), true); - }; - - var expr_atom = maybe_embed_tokens(function(allow_calls) { - if (is("operator", "new")) { - next(); - return new_(); - } - if (is("operator") && HOP(UNARY_PREFIX, S.token.value)) { - return make_unary("unary-prefix", - prog1(S.token.value, next), - expr_atom(allow_calls)); - } - if (is("punc")) { - switch (S.token.value) { - case "(": - next(); - return subscripts(prog1(expression, curry(expect, ")")), allow_calls); - case "[": - next(); - return subscripts(array_(), allow_calls); - case "{": - next(); - return subscripts(object_(), allow_calls); - } - unexpected(); - } - if (is("keyword", "function")) { - next(); - return subscripts(function_(false), allow_calls); - } - if (HOP(ATOMIC_START_TOKEN, S.token.type)) { - var atom = S.token.type == "regexp" - ? as("regexp", S.token.value[0], S.token.value[1]) - : as(S.token.type, S.token.value); - return subscripts(prog1(atom, next), allow_calls); - } - unexpected(); - }); - - function expr_list(closing, allow_trailing_comma, allow_empty) { - var first = true, a = []; - while (!is("punc", closing)) { - if (first) first = false; else expect(","); - if (allow_trailing_comma && is("punc", closing)) break; - if (is("punc", ",") && allow_empty) { - a.push([ "atom", "undefined" ]); - } else { - a.push(expression(false)); - } - } - next(); - return a; - }; - - function array_() { - return as("array", expr_list("]", !exigent_mode, true)); - }; - - function object_() { - var first = true, a = []; - while (!is("punc", "}")) { - if (first) first = false; else expect(","); - if (!exigent_mode && is("punc", "}")) - // allow trailing comma - break; - var type = S.token.type; - var name = as_property_name(); - if (type == "name" && (name == "get" || name == "set") && !is("punc", ":")) { - a.push([ as_name(), function_(false), name ]); - } else { - expect(":"); - a.push([ name, expression(false) ]); - } - } - next(); - return as("object", a); - }; - - function as_property_name() { - switch (S.token.type) { - case "num": - case "string": - return prog1(S.token.value, next); - } - return as_name(); - }; - - function as_name() { - switch (S.token.type) { - case "name": - case "operator": - case "keyword": - case "atom": - return prog1(S.token.value, next); - default: - unexpected(); - } - }; - - function subscripts(expr, allow_calls) { - if (is("punc", ".")) { - next(); - return subscripts(as("dot", expr, as_name()), allow_calls); - } - if (is("punc", "[")) { - next(); - return subscripts(as("sub", expr, prog1(expression, curry(expect, "]"))), allow_calls); - } - if (allow_calls && is("punc", "(")) { - next(); - return subscripts(as("call", expr, expr_list(")")), true); - } - if (allow_calls && is("operator") && HOP(UNARY_POSTFIX, S.token.value)) { - return prog1(curry(make_unary, "unary-postfix", S.token.value, expr), - next); - } - return expr; - }; - - function make_unary(tag, op, expr) { - if ((op == "++" || op == "--") && !is_assignable(expr)) - croak("Invalid use of " + op + " operator"); - return as(tag, op, expr); - }; - - function expr_op(left, min_prec, no_in) { - var op = is("operator") ? S.token.value : null; - if (op && op == "in" && no_in) op = null; - var prec = op != null ? PRECEDENCE[op] : null; - if (prec != null && prec > min_prec) { - next(); - var right = expr_op(expr_atom(true), prec, no_in); - return expr_op(as("binary", op, left, right), min_prec, no_in); - } - return left; - }; - - function expr_ops(no_in) { - return expr_op(expr_atom(true), 0, no_in); - }; - - function maybe_conditional(no_in) { - var expr = expr_ops(no_in); - if (is("operator", "?")) { - next(); - var yes = expression(false); - expect(":"); - return as("conditional", expr, yes, expression(false, no_in)); - } - return expr; - }; - - function is_assignable(expr) { - if (!exigent_mode) return true; - switch (expr[0]) { - case "dot": - case "sub": - case "new": - case "call": - return true; - case "name": - return expr[1] != "this"; - } - }; - - function maybe_assign(no_in) { - var left = maybe_conditional(no_in), val = S.token.value; - if (is("operator") && HOP(ASSIGNMENT, val)) { - if (is_assignable(left)) { - next(); - return as("assign", ASSIGNMENT[val], left, maybe_assign(no_in)); - } - croak("Invalid assignment"); - } - return left; - }; - - var expression = maybe_embed_tokens(function(commas, no_in) { - if (arguments.length == 0) - commas = true; - var expr = maybe_assign(no_in); - if (commas && is("punc", ",")) { - next(); - return as("seq", expr, expression(true, no_in)); - } - return expr; - }); - - function in_loop(cont) { - try { - ++S.in_loop; - return cont(); - } finally { - --S.in_loop; - } - }; - - return as("toplevel", (function(a){ - while (!is("eof")) - a.push(statement()); - return a; - })([])); - -}; - -/* -----[ Utilities ]----- */ - -function curry(f) { - var args = slice(arguments, 1); - return function() { return f.apply(this, args.concat(slice(arguments))); }; -}; - -function prog1(ret) { - if (ret instanceof Function) - ret = ret(); - for (var i = 1, n = arguments.length; --n > 0; ++i) - arguments[i](); - return ret; -}; - -function array_to_hash(a) { - var ret = {}; - for (var i = 0; i < a.length; ++i) - ret[a[i]] = true; - return ret; -}; - -function slice(a, start) { - return Array.prototype.slice.call(a, start == null ? 0 : start); -}; - -function characters(str) { - return str.split(""); -}; - -function member(name, array) { - for (var i = array.length; --i >= 0;) - if (array[i] === name) - return true; - return false; -}; - -function HOP(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - -var warn = function() {}; - -/* -----[ Exports ]----- */ - -exports.tokenizer = tokenizer; -exports.parse = parse; -exports.slice = slice; -exports.curry = curry; -exports.member = member; -exports.array_to_hash = array_to_hash; -exports.PRECEDENCE = PRECEDENCE; -exports.KEYWORDS_ATOM = KEYWORDS_ATOM; -exports.RESERVED_WORDS = RESERVED_WORDS; -exports.KEYWORDS = KEYWORDS; -exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN; -exports.OPERATORS = OPERATORS; -exports.is_alphanumeric_char = is_alphanumeric_char; -exports.set_logger = function(logger) { - warn = logger; -}; -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/parse-js.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/lib/process.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js/lib"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/lib/process.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/process.js"]._cached = module.exports; - - (function () { - /*********************************************************************** - - A JavaScript tokenizer / parser / beautifier / compressor. - - This version is suitable for Node.js. With minimal changes (the - exports stuff) it should work on any JS platform. - - This file implements some AST processors. They work on data built - by parse-js. - - Exported functions: - - - ast_mangle(ast, options) -- mangles the variable/function names - in the AST. Returns an AST. - - - ast_squeeze(ast) -- employs various optimizations to make the - final generated code even smaller. Returns an AST. - - - gen_code(ast, options) -- generates JS code from the AST. Pass - true (or an object, see the code for some options) as second - argument to get "pretty" (indented) code. - - -------------------------------- (C) --------------------------------- - - Author: Mihai Bazon - - http://mihai.bazon.net/blog - - Distributed under the BSD license: - - Copyright 2010 (c) Mihai Bazon - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above - copyright notice, this list of conditions and the following - disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. - - ***********************************************************************/ - -var jsp = require("./parse-js"), - slice = jsp.slice, - member = jsp.member, - PRECEDENCE = jsp.PRECEDENCE, - OPERATORS = jsp.OPERATORS; - -/* -----[ helper for AST traversal ]----- */ - -function ast_walker(ast) { - function _vardefs(defs) { - return [ this[0], MAP(defs, function(def){ - var a = [ def[0] ]; - if (def.length > 1) - a[1] = walk(def[1]); - return a; - }) ]; - }; - function _block(statements) { - var out = [ this[0] ]; - if (statements != null) - out.push(MAP(statements, walk)); - return out; - }; - var walkers = { - "string": function(str) { - return [ this[0], str ]; - }, - "num": function(num) { - return [ this[0], num ]; - }, - "name": function(name) { - return [ this[0], name ]; - }, - "toplevel": function(statements) { - return [ this[0], MAP(statements, walk) ]; - }, - "block": _block, - "splice": _block, - "var": _vardefs, - "const": _vardefs, - "try": function(t, c, f) { - return [ - this[0], - MAP(t, walk), - c != null ? [ c[0], MAP(c[1], walk) ] : null, - f != null ? MAP(f, walk) : null - ]; - }, - "throw": function(expr) { - return [ this[0], walk(expr) ]; - }, - "new": function(ctor, args) { - return [ this[0], walk(ctor), MAP(args, walk) ]; - }, - "switch": function(expr, body) { - return [ this[0], walk(expr), MAP(body, function(branch){ - return [ branch[0] ? walk(branch[0]) : null, - MAP(branch[1], walk) ]; - }) ]; - }, - "break": function(label) { - return [ this[0], label ]; - }, - "continue": function(label) { - return [ this[0], label ]; - }, - "conditional": function(cond, t, e) { - return [ this[0], walk(cond), walk(t), walk(e) ]; - }, - "assign": function(op, lvalue, rvalue) { - return [ this[0], op, walk(lvalue), walk(rvalue) ]; - }, - "dot": function(expr) { - return [ this[0], walk(expr) ].concat(slice(arguments, 1)); - }, - "call": function(expr, args) { - return [ this[0], walk(expr), MAP(args, walk) ]; - }, - "function": function(name, args, body) { - return [ this[0], name, args.slice(), MAP(body, walk) ]; - }, - "defun": function(name, args, body) { - return [ this[0], name, args.slice(), MAP(body, walk) ]; - }, - "if": function(conditional, t, e) { - return [ this[0], walk(conditional), walk(t), walk(e) ]; - }, - "for": function(init, cond, step, block) { - return [ this[0], walk(init), walk(cond), walk(step), walk(block) ]; - }, - "for-in": function(vvar, key, hash, block) { - return [ this[0], walk(vvar), walk(key), walk(hash), walk(block) ]; - }, - "while": function(cond, block) { - return [ this[0], walk(cond), walk(block) ]; - }, - "do": function(cond, block) { - return [ this[0], walk(cond), walk(block) ]; - }, - "return": function(expr) { - return [ this[0], walk(expr) ]; - }, - "binary": function(op, left, right) { - return [ this[0], op, walk(left), walk(right) ]; - }, - "unary-prefix": function(op, expr) { - return [ this[0], op, walk(expr) ]; - }, - "unary-postfix": function(op, expr) { - return [ this[0], op, walk(expr) ]; - }, - "sub": function(expr, subscript) { - return [ this[0], walk(expr), walk(subscript) ]; - }, - "object": function(props) { - return [ this[0], MAP(props, function(p){ - return p.length == 2 - ? [ p[0], walk(p[1]) ] - : [ p[0], walk(p[1]), p[2] ]; // get/set-ter - }) ]; - }, - "regexp": function(rx, mods) { - return [ this[0], rx, mods ]; - }, - "array": function(elements) { - return [ this[0], MAP(elements, walk) ]; - }, - "stat": function(stat) { - return [ this[0], walk(stat) ]; - }, - "seq": function() { - return [ this[0] ].concat(MAP(slice(arguments), walk)); - }, - "label": function(name, block) { - return [ this[0], name, walk(block) ]; - }, - "with": function(expr, block) { - return [ this[0], walk(expr), walk(block) ]; - }, - "atom": function(name) { - return [ this[0], name ]; - } - }; - - var user = {}; - var stack = []; - function walk(ast) { - if (ast == null) - return null; - try { - stack.push(ast); - var type = ast[0]; - var gen = user[type]; - if (gen) { - var ret = gen.apply(ast, ast.slice(1)); - if (ret != null) - return ret; - } - gen = walkers[type]; - return gen.apply(ast, ast.slice(1)); - } finally { - stack.pop(); - } - }; - - function with_walkers(walkers, cont){ - var save = {}, i; - for (i in walkers) if (HOP(walkers, i)) { - save[i] = user[i]; - user[i] = walkers[i]; - } - var ret = cont(); - for (i in save) if (HOP(save, i)) { - if (!save[i]) delete user[i]; - else user[i] = save[i]; - } - return ret; - }; - - return { - walk: walk, - with_walkers: with_walkers, - parent: function() { - return stack[stack.length - 2]; // last one is current node - }, - stack: function() { - return stack; - } - }; -}; - -/* -----[ Scope and mangling ]----- */ - -function Scope(parent) { - this.names = {}; // names defined in this scope - this.mangled = {}; // mangled names (orig.name => mangled) - this.rev_mangled = {}; // reverse lookup (mangled => orig.name) - this.cname = -1; // current mangled name - this.refs = {}; // names referenced from this scope - this.uses_with = false; // will become TRUE if with() is detected in this or any subscopes - this.uses_eval = false; // will become TRUE if eval() is detected in this or any subscopes - this.parent = parent; // parent scope - this.children = []; // sub-scopes - if (parent) { - this.level = parent.level + 1; - parent.children.push(this); - } else { - this.level = 0; - } -}; - -var base54 = (function(){ - var DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_"; - return function(num) { - var ret = ""; - do { - ret = DIGITS.charAt(num % 54) + ret; - num = Math.floor(num / 54); - } while (num > 0); - return ret; - }; -})(); - -Scope.prototype = { - has: function(name) { - for (var s = this; s; s = s.parent) - if (HOP(s.names, name)) - return s; - }, - has_mangled: function(mname) { - for (var s = this; s; s = s.parent) - if (HOP(s.rev_mangled, mname)) - return s; - }, - toJSON: function() { - return { - names: this.names, - uses_eval: this.uses_eval, - uses_with: this.uses_with - }; - }, - - next_mangled: function() { - // we must be careful that the new mangled name: - // - // 1. doesn't shadow a mangled name from a parent - // scope, unless we don't reference the original - // name from this scope OR from any sub-scopes! - // This will get slow. - // - // 2. doesn't shadow an original name from a parent - // scope, in the event that the name is not mangled - // in the parent scope and we reference that name - // here OR IN ANY SUBSCOPES! - // - // 3. doesn't shadow a name that is referenced but not - // defined (possibly global defined elsewhere). - for (;;) { - var m = base54(++this.cname), prior; - - // case 1. - prior = this.has_mangled(m); - if (prior && this.refs[prior.rev_mangled[m]] === prior) - continue; - - // case 2. - prior = this.has(m); - if (prior && prior !== this && this.refs[m] === prior && !prior.has_mangled(m)) - continue; - - // case 3. - if (HOP(this.refs, m) && this.refs[m] == null) - continue; - - // I got "do" once. :-/ - if (!is_identifier(m)) - continue; - - return m; - } - }, - set_mangle: function(name, m) { - this.rev_mangled[m] = name; - return this.mangled[name] = m; - }, - get_mangled: function(name, newMangle) { - if (this.uses_eval || this.uses_with) return name; // no mangle if eval or with is in use - var s = this.has(name); - if (!s) return name; // not in visible scope, no mangle - if (HOP(s.mangled, name)) return s.mangled[name]; // already mangled in this scope - if (!newMangle) return name; // not found and no mangling requested - return s.set_mangle(name, s.next_mangled()); - }, - define: function(name) { - if (name != null) - return this.names[name] = name; - } -}; - -function ast_add_scope(ast) { - - var current_scope = null; - var w = ast_walker(), walk = w.walk; - var having_eval = []; - - function with_new_scope(cont) { - current_scope = new Scope(current_scope); - var ret = current_scope.body = cont(); - ret.scope = current_scope; - current_scope = current_scope.parent; - return ret; - }; - - function define(name) { - return current_scope.define(name); - }; - - function reference(name) { - current_scope.refs[name] = true; - }; - - function _lambda(name, args, body) { - var is_defun = this[0] == "defun"; - return [ this[0], is_defun ? define(name) : name, args, with_new_scope(function(){ - if (!is_defun) define(name); - MAP(args, define); - return MAP(body, walk); - })]; - }; - - return with_new_scope(function(){ - // process AST - var ret = w.with_walkers({ - "function": _lambda, - "defun": _lambda, - "with": function(expr, block) { - for (var s = current_scope; s; s = s.parent) - s.uses_with = true; - }, - "var": function(defs) { - MAP(defs, function(d){ define(d[0]) }); - }, - "const": function(defs) { - MAP(defs, function(d){ define(d[0]) }); - }, - "try": function(t, c, f) { - if (c != null) return [ - this[0], - MAP(t, walk), - [ define(c[0]), MAP(c[1], walk) ], - f != null ? MAP(f, walk) : null - ]; - }, - "name": function(name) { - if (name == "eval") - having_eval.push(current_scope); - reference(name); - } - }, function(){ - return walk(ast); - }); - - // the reason why we need an additional pass here is - // that names can be used prior to their definition. - - // scopes where eval was detected and their parents - // are marked with uses_eval, unless they define the - // "eval" name. - MAP(having_eval, function(scope){ - if (!scope.has("eval")) while (scope) { - scope.uses_eval = true; - scope = scope.parent; - } - }); - - // for referenced names it might be useful to know - // their origin scope. current_scope here is the - // toplevel one. - function fixrefs(scope, i) { - // do children first; order shouldn't matter - for (i = scope.children.length; --i >= 0;) - fixrefs(scope.children[i]); - for (i in scope.refs) if (HOP(scope.refs, i)) { - // find origin scope and propagate the reference to origin - for (var origin = scope.has(i), s = scope; s; s = s.parent) { - s.refs[i] = origin; - if (s === origin) break; - } - } - }; - fixrefs(current_scope); - - return ret; - }); - -}; - -/* -----[ mangle names ]----- */ - -function ast_mangle(ast, options) { - var w = ast_walker(), walk = w.walk, scope; - options = options || {}; - - function get_mangled(name, newMangle) { - if (!options.toplevel && !scope.parent) return name; // don't mangle toplevel - if (options.except && member(name, options.except)) - return name; - return scope.get_mangled(name, newMangle); - }; - - function get_define(name) { - if (options.defines) { - // we always lookup a defined symbol for the current scope FIRST, so declared - // vars trump a DEFINE symbol, but if no such var is found, then match a DEFINE value - if (!scope.has(name)) { - if (HOP(options.defines, name)) { - return options.defines[name]; - } - } - return null; - } - }; - - function _lambda(name, args, body) { - var is_defun = this[0] == "defun", extra; - if (name) { - if (is_defun) name = get_mangled(name); - else { - extra = {}; - name = extra[name] = scope.next_mangled(); - } - } - body = with_scope(body.scope, function(){ - args = MAP(args, function(name){ return get_mangled(name) }); - return MAP(body, walk); - }, extra); - return [ this[0], name, args, body ]; - }; - - function with_scope(s, cont, extra) { - var _scope = scope; - scope = s; - if (extra) for (var i in extra) if (HOP(extra, i)) { - s.set_mangle(i, extra[i]); - } - for (var i in s.names) if (HOP(s.names, i)) { - get_mangled(i, true); - } - var ret = cont(); - ret.scope = s; - scope = _scope; - return ret; - }; - - function _vardefs(defs) { - return [ this[0], MAP(defs, function(d){ - return [ get_mangled(d[0]), walk(d[1]) ]; - }) ]; - }; - - return w.with_walkers({ - "function": _lambda, - "defun": function() { - // move function declarations to the top when - // they are not in some block. - var ast = _lambda.apply(this, arguments); - switch (w.parent()[0]) { - case "toplevel": - case "function": - case "defun": - return MAP.at_top(ast); - } - return ast; - }, - "var": _vardefs, - "const": _vardefs, - "name": function(name) { - return get_define(name) || [ this[0], get_mangled(name) ]; - }, - "try": function(t, c, f) { - return [ this[0], - MAP(t, walk), - c != null ? [ get_mangled(c[0]), MAP(c[1], walk) ] : null, - f != null ? MAP(f, walk) : null ]; - }, - "toplevel": function(body) { - var self = this; - return with_scope(self.scope, function(){ - return [ self[0], MAP(body, walk) ]; - }); - } - }, function() { - return walk(ast_add_scope(ast)); - }); -}; - -/* -----[ - - compress foo["bar"] into foo.bar, - - remove block brackets {} where possible - - join consecutive var declarations - - various optimizations for IFs: - - if (cond) foo(); else bar(); ==> cond?foo():bar(); - - if (cond) foo(); ==> cond&&foo(); - - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); // also for throw - - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} - ]----- */ - -var warn = function(){}; - -function best_of(ast1, ast2) { - return gen_code(ast1).length > gen_code(ast2[0] == "stat" ? ast2[1] : ast2).length ? ast2 : ast1; -}; - -function last_stat(b) { - if (b[0] == "block" && b[1] && b[1].length > 0) - return b[1][b[1].length - 1]; - return b; -} - -function aborts(t) { - if (t) { - t = last_stat(t); - if (t[0] == "return" || t[0] == "break" || t[0] == "continue" || t[0] == "throw") - return true; - } -}; - -function boolean_expr(expr) { - return ( (expr[0] == "unary-prefix" - && member(expr[1], [ "!", "delete" ])) || - - (expr[0] == "binary" - && member(expr[1], [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ])) || - - (expr[0] == "binary" - && member(expr[1], [ "&&", "||" ]) - && boolean_expr(expr[2]) - && boolean_expr(expr[3])) || - - (expr[0] == "conditional" - && boolean_expr(expr[2]) - && boolean_expr(expr[3])) || - - (expr[0] == "assign" - && expr[1] === true - && boolean_expr(expr[3])) || - - (expr[0] == "seq" - && boolean_expr(expr[expr.length - 1])) - ); -}; - -function make_conditional(c, t, e) { - var make_real_conditional = function() { - if (c[0] == "unary-prefix" && c[1] == "!") { - return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ]; - } else { - return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ]; - } - }; - // shortcut the conditional if the expression has a constant value - return when_constant(c, function(ast, val){ - warn_unreachable(val ? e : t); - return (val ? t : e); - }, make_real_conditional); -}; - -function empty(b) { - return !b || (b[0] == "block" && (!b[1] || b[1].length == 0)); -}; - -function is_string(node) { - return (node[0] == "string" || - node[0] == "unary-prefix" && node[1] == "typeof" || - node[0] == "binary" && node[1] == "+" && - (is_string(node[2]) || is_string(node[3]))); -}; - -var when_constant = (function(){ - - var $NOT_CONSTANT = {}; - - // this can only evaluate constant expressions. If it finds anything - // not constant, it throws $NOT_CONSTANT. - function evaluate(expr) { - switch (expr[0]) { - case "string": - case "num": - return expr[1]; - case "name": - case "atom": - switch (expr[1]) { - case "true": return true; - case "false": return false; - } - break; - case "unary-prefix": - switch (expr[1]) { - case "!": return !evaluate(expr[2]); - case "typeof": return typeof evaluate(expr[2]); - case "~": return ~evaluate(expr[2]); - case "-": return -evaluate(expr[2]); - case "+": return +evaluate(expr[2]); - } - break; - case "binary": - var left = expr[2], right = expr[3]; - switch (expr[1]) { - case "&&" : return evaluate(left) && evaluate(right); - case "||" : return evaluate(left) || evaluate(right); - case "|" : return evaluate(left) | evaluate(right); - case "&" : return evaluate(left) & evaluate(right); - case "^" : return evaluate(left) ^ evaluate(right); - case "+" : return evaluate(left) + evaluate(right); - case "*" : return evaluate(left) * evaluate(right); - case "/" : return evaluate(left) / evaluate(right); - case "-" : return evaluate(left) - evaluate(right); - case "<<" : return evaluate(left) << evaluate(right); - case ">>" : return evaluate(left) >> evaluate(right); - case ">>>" : return evaluate(left) >>> evaluate(right); - case "==" : return evaluate(left) == evaluate(right); - case "===" : return evaluate(left) === evaluate(right); - case "!=" : return evaluate(left) != evaluate(right); - case "!==" : return evaluate(left) !== evaluate(right); - case "<" : return evaluate(left) < evaluate(right); - case "<=" : return evaluate(left) <= evaluate(right); - case ">" : return evaluate(left) > evaluate(right); - case ">=" : return evaluate(left) >= evaluate(right); - case "in" : return evaluate(left) in evaluate(right); - case "instanceof" : return evaluate(left) instanceof evaluate(right); - } - } - throw $NOT_CONSTANT; - }; - - return function(expr, yes, no) { - try { - var val = evaluate(expr), ast; - switch (typeof val) { - case "string": ast = [ "string", val ]; break; - case "number": ast = [ "num", val ]; break; - case "boolean": ast = [ "name", String(val) ]; break; - default: throw new Error("Can't handle constant of type: " + (typeof val)); - } - return yes.call(expr, ast, val); - } catch(ex) { - if (ex === $NOT_CONSTANT) { - if (expr[0] == "binary" - && (expr[1] == "===" || expr[1] == "!==") - && ((is_string(expr[2]) && is_string(expr[3])) - || (boolean_expr(expr[2]) && boolean_expr(expr[3])))) { - expr[1] = expr[1].substr(0, 2); - } - else if (no && expr[0] == "binary" - && (expr[1] == "||" || expr[1] == "&&")) { - // the whole expression is not constant but the lval may be... - try { - var lval = evaluate(expr[2]); - expr = ((expr[1] == "&&" && (lval ? expr[3] : lval)) || - (expr[1] == "||" && (lval ? lval : expr[3])) || - expr); - } catch(ex2) { - // IGNORE... lval is not constant - } - } - return no ? no.call(expr, expr) : null; - } - else throw ex; - } - }; - -})(); - -function warn_unreachable(ast) { - if (!empty(ast)) - warn("Dropping unreachable code: " + gen_code(ast, true)); -}; - -function prepare_ifs(ast) { - var w = ast_walker(), walk = w.walk; - // In this first pass, we rewrite ifs which abort with no else with an - // if-else. For example: - // - // if (x) { - // blah(); - // return y; - // } - // foobar(); - // - // is rewritten into: - // - // if (x) { - // blah(); - // return y; - // } else { - // foobar(); - // } - function redo_if(statements) { - statements = MAP(statements, walk); - - for (var i = 0; i < statements.length; ++i) { - var fi = statements[i]; - if (fi[0] != "if") continue; - - if (fi[3] && walk(fi[3])) continue; - - var t = walk(fi[2]); - if (!aborts(t)) continue; - - var conditional = walk(fi[1]); - - var e_body = statements.slice(i + 1); - var e; - if (e_body.length == 1) e = e_body[0]; - else e = [ "block", e_body ]; - - var ret = statements.slice(0, i).concat([ [ - fi[0], // "if" - conditional, // conditional - t, // then - e // else - ] ]); - - return redo_if(ret); - } - - return statements; - }; - - function redo_if_lambda(name, args, body) { - body = redo_if(body); - return [ this[0], name, args.slice(), body ]; - }; - - function redo_if_block(statements) { - var out = [ this[0] ]; - if (statements != null) - out.push(redo_if(statements)); - return out; - }; - - return w.with_walkers({ - "defun": redo_if_lambda, - "function": redo_if_lambda, - "block": redo_if_block, - "splice": redo_if_block, - "toplevel": function(statements) { - return [ this[0], redo_if(statements) ]; - }, - "try": function(t, c, f) { - return [ - this[0], - redo_if(t), - c != null ? [ c[0], redo_if(c[1]) ] : null, - f != null ? redo_if(f) : null - ]; - }, - "with": function(expr, block) { - return [ this[0], walk(expr), redo_if(block) ]; - } - }, function() { - return walk(ast); - }); -}; - -function ast_squeeze(ast, options) { - options = defaults(options, { - make_seqs : true, - dead_code : true, - keep_comps : true, - no_warnings : false - }); - - var w = ast_walker(), walk = w.walk, scope; - - function negate(c) { - var not_c = [ "unary-prefix", "!", c ]; - switch (c[0]) { - case "unary-prefix": - return c[1] == "!" && boolean_expr(c[2]) ? c[2] : not_c; - case "seq": - c = slice(c); - c[c.length - 1] = negate(c[c.length - 1]); - return c; - case "conditional": - return best_of(not_c, [ "conditional", c[1], negate(c[2]), negate(c[3]) ]); - case "binary": - var op = c[1], left = c[2], right = c[3]; - if (!options.keep_comps) switch (op) { - case "<=" : return [ "binary", ">", left, right ]; - case "<" : return [ "binary", ">=", left, right ]; - case ">=" : return [ "binary", "<", left, right ]; - case ">" : return [ "binary", "<=", left, right ]; - } - switch (op) { - case "==" : return [ "binary", "!=", left, right ]; - case "!=" : return [ "binary", "==", left, right ]; - case "===" : return [ "binary", "!==", left, right ]; - case "!==" : return [ "binary", "===", left, right ]; - case "&&" : return best_of(not_c, [ "binary", "||", negate(left), negate(right) ]); - case "||" : return best_of(not_c, [ "binary", "&&", negate(left), negate(right) ]); - } - break; - } - return not_c; - }; - - function with_scope(s, cont) { - var _scope = scope; - scope = s; - var ret = cont(); - ret.scope = s; - scope = _scope; - return ret; - }; - - function rmblock(block) { - if (block != null && block[0] == "block" && block[1]) { - if (block[1].length == 1) - block = block[1][0]; - else if (block[1].length == 0) - block = [ "block" ]; - } - return block; - }; - - function _lambda(name, args, body) { - var is_defun = this[0] == "defun"; - body = with_scope(body.scope, function(){ - var ret = tighten(MAP(body, walk), "lambda"); - if (!is_defun && name && !HOP(scope.refs, name)) - name = null; - return ret; - }); - return [ this[0], name, args, body ]; - }; - - // we get here for blocks that have been already transformed. - // this function does a few things: - // 1. discard useless blocks - // 2. join consecutive var declarations - // 3. remove obviously dead code - // 4. transform consecutive statements using the comma operator - // 5. if block_type == "lambda" and it detects constructs like if(foo) return ... - rewrite like if (!foo) { ... } - function tighten(statements, block_type) { - statements = statements.reduce(function(a, stat){ - if (stat[0] == "block") { - if (stat[1]) { - a.push.apply(a, stat[1]); - } - } else { - a.push(stat); - } - return a; - }, []); - - statements = (function(a, prev){ - statements.forEach(function(cur){ - if (prev && ((cur[0] == "var" && prev[0] == "var") || - (cur[0] == "const" && prev[0] == "const"))) { - prev[1] = prev[1].concat(cur[1]); - } else { - a.push(cur); - prev = cur; - } - }); - return a; - })([]); - - if (options.dead_code) statements = (function(a, has_quit){ - statements.forEach(function(st){ - if (has_quit) { - if (member(st[0], [ "function", "defun" , "var", "const" ])) { - a.push(st); - } - else if (!options.no_warnings) - warn_unreachable(st); - } - else { - a.push(st); - if (member(st[0], [ "return", "throw", "break", "continue" ])) - has_quit = true; - } - }); - return a; - })([]); - - if (options.make_seqs) statements = (function(a, prev) { - statements.forEach(function(cur){ - if (prev && prev[0] == "stat" && cur[0] == "stat") { - prev[1] = [ "seq", prev[1], cur[1] ]; - } else { - a.push(cur); - prev = cur; - } - }); - return a; - })([]); - - if (block_type == "lambda") statements = (function(i, a, stat){ - while (i < statements.length) { - stat = statements[i++]; - if (stat[0] == "if" && !stat[3]) { - if (stat[2][0] == "return" && stat[2][1] == null) { - a.push(make_if(negate(stat[1]), [ "block", statements.slice(i) ])); - break; - } - var last = last_stat(stat[2]); - if (last[0] == "return" && last[1] == null) { - a.push(make_if(stat[1], [ "block", stat[2][1].slice(0, -1) ], [ "block", statements.slice(i) ])); - break; - } - } - a.push(stat); - } - return a; - })(0, []); - - return statements; - }; - - function make_if(c, t, e) { - return when_constant(c, function(ast, val){ - if (val) { - warn_unreachable(e); - return t; - } else { - warn_unreachable(t); - return e; - } - }, function() { - return make_real_if(c, t, e); - }); - }; - - function make_real_if(c, t, e) { - c = walk(c); - t = walk(t); - e = walk(e); - - if (empty(t)) { - c = negate(c); - t = e; - e = null; - } else if (empty(e)) { - e = null; - } else { - // if we have both else and then, maybe it makes sense to switch them? - (function(){ - var a = gen_code(c); - var n = negate(c); - var b = gen_code(n); - if (b.length < a.length) { - var tmp = t; - t = e; - e = tmp; - c = n; - } - })(); - } - if (empty(e) && empty(t)) - return [ "stat", c ]; - var ret = [ "if", c, t, e ]; - if (t[0] == "if" && empty(t[3]) && empty(e)) { - ret = best_of(ret, walk([ "if", [ "binary", "&&", c, t[1] ], t[2] ])); - } - else if (t[0] == "stat") { - if (e) { - if (e[0] == "stat") { - ret = best_of(ret, [ "stat", make_conditional(c, t[1], e[1]) ]); - } - } - else { - ret = best_of(ret, [ "stat", make_conditional(c, t[1]) ]); - } - } - else if (e && t[0] == e[0] && (t[0] == "return" || t[0] == "throw") && t[1] && e[1]) { - ret = best_of(ret, [ t[0], make_conditional(c, t[1], e[1] ) ]); - } - else if (e && aborts(t)) { - ret = [ [ "if", c, t ] ]; - if (e[0] == "block") { - if (e[1]) ret = ret.concat(e[1]); - } - else { - ret.push(e); - } - ret = walk([ "block", ret ]); - } - else if (t && aborts(e)) { - ret = [ [ "if", negate(c), e ] ]; - if (t[0] == "block") { - if (t[1]) ret = ret.concat(t[1]); - } else { - ret.push(t); - } - ret = walk([ "block", ret ]); - } - return ret; - }; - - function _do_while(cond, body) { - return when_constant(cond, function(cond, val){ - if (!val) { - warn_unreachable(body); - return [ "block" ]; - } else { - return [ "for", null, null, null, walk(body) ]; - } - }); - }; - - ast = prepare_ifs(ast); - ast = ast_add_scope(ast); - - return w.with_walkers({ - "sub": function(expr, subscript) { - if (subscript[0] == "string") { - var name = subscript[1]; - if (is_identifier(name)) - return [ "dot", walk(expr), name ]; - else if (/^[1-9][0-9]*$/.test(name) || name === "0") - return [ "sub", walk(expr), [ "num", parseInt(name, 10) ] ]; - } - }, - "if": make_if, - "toplevel": function(body) { - return [ "toplevel", with_scope(this.scope, function(){ - return tighten(MAP(body, walk)); - }) ]; - }, - "switch": function(expr, body) { - var last = body.length - 1; - return [ "switch", walk(expr), MAP(body, function(branch, i){ - var block = tighten(MAP(branch[1], walk)); - if (i == last && block.length > 0) { - var node = block[block.length - 1]; - if (node[0] == "break" && !node[1]) - block.pop(); - } - return [ branch[0] ? walk(branch[0]) : null, block ]; - }) ]; - }, - "function": _lambda, - "defun": _lambda, - "block": function(body) { - if (body) return rmblock([ "block", tighten(MAP(body, walk)) ]); - }, - "binary": function(op, left, right) { - return when_constant([ "binary", op, walk(left), walk(right) ], function yes(c){ - return best_of(walk(c), this); - }, function no() { - return this; - }); - }, - "conditional": function(c, t, e) { - return make_conditional(walk(c), walk(t), walk(e)); - }, - "try": function(t, c, f) { - return [ - "try", - tighten(MAP(t, walk)), - c != null ? [ c[0], tighten(MAP(c[1], walk)) ] : null, - f != null ? tighten(MAP(f, walk)) : null - ]; - }, - "unary-prefix": function(op, expr) { - expr = walk(expr); - var ret = [ "unary-prefix", op, expr ]; - if (op == "!") - ret = best_of(ret, negate(expr)); - return when_constant(ret, function(ast, val){ - return walk(ast); // it's either true or false, so minifies to !0 or !1 - }, function() { return ret }); - }, - "name": function(name) { - switch (name) { - case "true": return [ "unary-prefix", "!", [ "num", 0 ]]; - case "false": return [ "unary-prefix", "!", [ "num", 1 ]]; - } - }, - "new": function(ctor, args) { - if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) { - if (args.length != 1) { - return [ "array", args ]; - } else { - return [ "call", [ "name", "Array" ], args ]; - } - } - }, - "call": function(expr, args) { - if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) { - return [ "array", args ]; - } - }, - "while": _do_while - }, function() { - return walk(ast); - }); -}; - -/* -----[ re-generate code from the AST ]----- */ - -var DOT_CALL_NO_PARENS = jsp.array_to_hash([ - "name", - "array", - "object", - "string", - "dot", - "sub", - "call", - "regexp" -]); - -function make_string(str, ascii_only) { - var dq = 0, sq = 0; - str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029]/g, function(s){ - switch (s) { - case "\\": return "\\\\"; - case "\b": return "\\b"; - case "\f": return "\\f"; - case "\n": return "\\n"; - case "\r": return "\\r"; - case "\t": return "\\t"; - case "\u2028": return "\\u2028"; - case "\u2029": return "\\u2029"; - case '"': ++dq; return '"'; - case "'": ++sq; return "'"; - } - return s; - }); - if (ascii_only) str = to_ascii(str); - if (dq > sq) return "'" + str.replace(/\x27/g, "\\'") + "'"; - else return '"' + str.replace(/\x22/g, '\\"') + '"'; -}; - -function to_ascii(str) { - return str.replace(/[\u0080-\uffff]/g, function(ch) { - var code = ch.charCodeAt(0).toString(16); - while (code.length < 4) code = "0" + code; - return "\\u" + code; - }); -}; - -var SPLICE_NEEDS_BRACKETS = jsp.array_to_hash([ "if", "while", "do", "for", "for-in", "with" ]); - -function gen_code(ast, options) { - options = defaults(options, { - indent_start : 0, - indent_level : 4, - quote_keys : false, - space_colon : false, - beautify : false, - ascii_only : false - }); - var beautify = !!options.beautify; - var indentation = 0, - newline = beautify ? "\n" : "", - space = beautify ? " " : ""; - - function encode_string(str) { - return make_string(str, options.ascii_only); - }; - - function make_name(name) { - name = name.toString(); - if (options.ascii_only) - name = to_ascii(name); - return name; - }; - - function indent(line) { - if (line == null) - line = ""; - if (beautify) - line = repeat_string(" ", options.indent_start + indentation * options.indent_level) + line; - return line; - }; - - function with_indent(cont, incr) { - if (incr == null) incr = 1; - indentation += incr; - try { return cont.apply(null, slice(arguments, 1)); } - finally { indentation -= incr; } - }; - - function add_spaces(a) { - if (beautify) - return a.join(" "); - var b = []; - for (var i = 0; i < a.length; ++i) { - var next = a[i + 1]; - b.push(a[i]); - if (next && - ((/[a-z0-9_\x24]$/i.test(a[i].toString()) && /^[a-z0-9_\x24]/i.test(next.toString())) || - (/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) { - b.push(" "); - } - } - return b.join(""); - }; - - function add_commas(a) { - return a.join("," + space); - }; - - function parenthesize(expr) { - var gen = make(expr); - for (var i = 1; i < arguments.length; ++i) { - var el = arguments[i]; - if ((el instanceof Function && el(expr)) || expr[0] == el) - return "(" + gen + ")"; - } - return gen; - }; - - function best_of(a) { - if (a.length == 1) { - return a[0]; - } - if (a.length == 2) { - var b = a[1]; - a = a[0]; - return a.length <= b.length ? a : b; - } - return best_of([ a[0], best_of(a.slice(1)) ]); - }; - - function needs_parens(expr) { - if (expr[0] == "function" || expr[0] == "object") { - // dot/call on a literal function requires the - // function literal itself to be parenthesized - // only if it's the first "thing" in a - // statement. This means that the parent is - // "stat", but it could also be a "seq" and - // we're the first in this "seq" and the - // parent is "stat", and so on. Messy stuff, - // but it worths the trouble. - var a = slice($stack), self = a.pop(), p = a.pop(); - while (p) { - if (p[0] == "stat") return true; - if (((p[0] == "seq" || p[0] == "call" || p[0] == "dot" || p[0] == "sub" || p[0] == "conditional") && p[1] === self) || - ((p[0] == "binary" || p[0] == "assign" || p[0] == "unary-postfix") && p[2] === self)) { - self = p; - p = a.pop(); - } else { - return false; - } - } - } - return !HOP(DOT_CALL_NO_PARENS, expr[0]); - }; - - function make_num(num) { - var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m; - if (Math.floor(num) === num) { - a.push("0x" + num.toString(16).toLowerCase(), // probably pointless - "0" + num.toString(8)); // same. - if ((m = /^(.*?)(0+)$/.exec(num))) { - a.push(m[1] + "e" + m[2].length); - } - } else if ((m = /^0?\.(0+)(.*)$/.exec(num))) { - a.push(m[2] + "e-" + (m[1].length + m[2].length), - str.substr(str.indexOf("."))); - } - return best_of(a); - }; - - var generators = { - "string": encode_string, - "num": make_num, - "name": make_name, - "toplevel": function(statements) { - return make_block_statements(statements) - .join(newline + newline); - }, - "splice": function(statements) { - var parent = $stack[$stack.length - 2][0]; - if (HOP(SPLICE_NEEDS_BRACKETS, parent)) { - // we need block brackets in this case - return make_block.apply(this, arguments); - } else { - return MAP(make_block_statements(statements, true), - function(line, i) { - // the first line is already indented - return i > 0 ? indent(line) : line; - }).join(newline); - } - }, - "block": make_block, - "var": function(defs) { - return "var " + add_commas(MAP(defs, make_1vardef)) + ";"; - }, - "const": function(defs) { - return "const " + add_commas(MAP(defs, make_1vardef)) + ";"; - }, - "try": function(tr, ca, fi) { - var out = [ "try", make_block(tr) ]; - if (ca) out.push("catch", "(" + ca[0] + ")", make_block(ca[1])); - if (fi) out.push("finally", make_block(fi)); - return add_spaces(out); - }, - "throw": function(expr) { - return add_spaces([ "throw", make(expr) ]) + ";"; - }, - "new": function(ctor, args) { - args = args.length > 0 ? "(" + add_commas(MAP(args, make)) + ")" : ""; - return add_spaces([ "new", parenthesize(ctor, "seq", "binary", "conditional", "assign", function(expr){ - var w = ast_walker(), has_call = {}; - try { - w.with_walkers({ - "call": function() { throw has_call }, - "function": function() { return this } - }, function(){ - w.walk(expr); - }); - } catch(ex) { - if (ex === has_call) - return true; - throw ex; - } - }) + args ]); - }, - "switch": function(expr, body) { - return add_spaces([ "switch", "(" + make(expr) + ")", make_switch_block(body) ]); - }, - "break": function(label) { - var out = "break"; - if (label != null) - out += " " + make_name(label); - return out + ";"; - }, - "continue": function(label) { - var out = "continue"; - if (label != null) - out += " " + make_name(label); - return out + ";"; - }, - "conditional": function(co, th, el) { - return add_spaces([ parenthesize(co, "assign", "seq", "conditional"), "?", - parenthesize(th, "seq"), ":", - parenthesize(el, "seq") ]); - }, - "assign": function(op, lvalue, rvalue) { - if (op && op !== true) op += "="; - else op = "="; - return add_spaces([ make(lvalue), op, parenthesize(rvalue, "seq") ]); - }, - "dot": function(expr) { - var out = make(expr), i = 1; - if (expr[0] == "num") { - if (!/\./.test(expr[1])) - out += "."; - } else if (needs_parens(expr)) - out = "(" + out + ")"; - while (i < arguments.length) - out += "." + make_name(arguments[i++]); - return out; - }, - "call": function(func, args) { - var f = make(func); - if (needs_parens(func)) - f = "(" + f + ")"; - return f + "(" + add_commas(MAP(args, function(expr){ - return parenthesize(expr, "seq"); - })) + ")"; - }, - "function": make_function, - "defun": make_function, - "if": function(co, th, el) { - var out = [ "if", "(" + make(co) + ")", el ? make_then(th) : make(th) ]; - if (el) { - out.push("else", make(el)); - } - return add_spaces(out); - }, - "for": function(init, cond, step, block) { - var out = [ "for" ]; - init = (init != null ? make(init) : "").replace(/;*\s*$/, ";" + space); - cond = (cond != null ? make(cond) : "").replace(/;*\s*$/, ";" + space); - step = (step != null ? make(step) : "").replace(/;*\s*$/, ""); - var args = init + cond + step; - if (args == "; ; ") args = ";;"; - out.push("(" + args + ")", make(block)); - return add_spaces(out); - }, - "for-in": function(vvar, key, hash, block) { - return add_spaces([ "for", "(" + - (vvar ? make(vvar).replace(/;+$/, "") : make(key)), - "in", - make(hash) + ")", make(block) ]); - }, - "while": function(condition, block) { - return add_spaces([ "while", "(" + make(condition) + ")", make(block) ]); - }, - "do": function(condition, block) { - return add_spaces([ "do", make(block), "while", "(" + make(condition) + ")" ]) + ";"; - }, - "return": function(expr) { - var out = [ "return" ]; - if (expr != null) out.push(make(expr)); - return add_spaces(out) + ";"; - }, - "binary": function(operator, lvalue, rvalue) { - var left = make(lvalue), right = make(rvalue); - // XXX: I'm pretty sure other cases will bite here. - // we need to be smarter. - // adding parens all the time is the safest bet. - if (member(lvalue[0], [ "assign", "conditional", "seq" ]) || - lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]]) { - left = "(" + left + ")"; - } - if (member(rvalue[0], [ "assign", "conditional", "seq" ]) || - rvalue[0] == "binary" && PRECEDENCE[operator] >= PRECEDENCE[rvalue[1]] && - !(rvalue[1] == operator && member(operator, [ "&&", "||", "*" ]))) { - right = "(" + right + ")"; - } - return add_spaces([ left, operator, right ]); - }, - "unary-prefix": function(operator, expr) { - var val = make(expr); - if (!(expr[0] == "num" || (expr[0] == "unary-prefix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr))) - val = "(" + val + ")"; - return operator + (jsp.is_alphanumeric_char(operator.charAt(0)) ? " " : "") + val; - }, - "unary-postfix": function(operator, expr) { - var val = make(expr); - if (!(expr[0] == "num" || (expr[0] == "unary-postfix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr))) - val = "(" + val + ")"; - return val + operator; - }, - "sub": function(expr, subscript) { - var hash = make(expr); - if (needs_parens(expr)) - hash = "(" + hash + ")"; - return hash + "[" + make(subscript) + "]"; - }, - "object": function(props) { - if (props.length == 0) - return "{}"; - return "{" + newline + with_indent(function(){ - return MAP(props, function(p){ - if (p.length == 3) { - // getter/setter. The name is in p[0], the arg.list in p[1][2], the - // body in p[1][3] and type ("get" / "set") in p[2]. - return indent(make_function(p[0], p[1][2], p[1][3], p[2])); - } - var key = p[0], val = make(p[1]); - if (options.quote_keys) { - key = encode_string(key); - } else if ((typeof key == "number" || !beautify && +key + "" == key) - && parseFloat(key) >= 0) { - key = make_num(+key); - } else if (!is_identifier(key)) { - key = encode_string(key); - } - return indent(add_spaces(beautify && options.space_colon - ? [ key, ":", val ] - : [ key + ":", val ])); - }).join("," + newline); - }) + newline + indent("}"); - }, - "regexp": function(rx, mods) { - return "/" + rx + "/" + mods; - }, - "array": function(elements) { - if (elements.length == 0) return "[]"; - return add_spaces([ "[", add_commas(MAP(elements, function(el){ - if (!beautify && el[0] == "atom" && el[1] == "undefined") return ""; - return parenthesize(el, "seq"); - })), "]" ]); - }, - "stat": function(stmt) { - return make(stmt).replace(/;*\s*$/, ";"); - }, - "seq": function() { - return add_commas(MAP(slice(arguments), make)); - }, - "label": function(name, block) { - return add_spaces([ make_name(name), ":", make(block) ]); - }, - "with": function(expr, block) { - return add_spaces([ "with", "(" + make(expr) + ")", make(block) ]); - }, - "atom": function(name) { - return make_name(name); - } - }; - - // The squeezer replaces "block"-s that contain only a single - // statement with the statement itself; technically, the AST - // is correct, but this can create problems when we output an - // IF having an ELSE clause where the THEN clause ends in an - // IF *without* an ELSE block (then the outer ELSE would refer - // to the inner IF). This function checks for this case and - // adds the block brackets if needed. - function make_then(th) { - if (th[0] == "do") { - // https://github.com/mishoo/UglifyJS/issues/#issue/57 - // IE croaks with "syntax error" on code like this: - // if (foo) do ... while(cond); else ... - // we need block brackets around do/while - return make([ "block", [ th ]]); - } - var b = th; - while (true) { - var type = b[0]; - if (type == "if") { - if (!b[3]) - // no else, we must add the block - return make([ "block", [ th ]]); - b = b[3]; - } - else if (type == "while" || type == "do") b = b[2]; - else if (type == "for" || type == "for-in") b = b[4]; - else break; - } - return make(th); - }; - - function make_function(name, args, body, keyword) { - var out = keyword || "function"; - if (name) { - out += " " + make_name(name); - } - out += "(" + add_commas(MAP(args, make_name)) + ")"; - return add_spaces([ out, make_block(body) ]); - }; - - function make_block_statements(statements, noindent) { - for (var a = [], last = statements.length - 1, i = 0; i <= last; ++i) { - var stat = statements[i]; - var code = make(stat); - if (code != ";") { - if (!beautify && i == last) { - if ((stat[0] == "while" && empty(stat[2])) || - (member(stat[0], [ "for", "for-in"] ) && empty(stat[4])) || - (stat[0] == "if" && empty(stat[2]) && !stat[3]) || - (stat[0] == "if" && stat[3] && empty(stat[3]))) { - code = code.replace(/;*\s*$/, ";"); - } else { - code = code.replace(/;+\s*$/, ""); - } - } - a.push(code); - } - } - return noindent ? a : MAP(a, indent); - }; - - function make_switch_block(body) { - var n = body.length; - if (n == 0) return "{}"; - return "{" + newline + MAP(body, function(branch, i){ - var has_body = branch[1].length > 0, code = with_indent(function(){ - return indent(branch[0] - ? add_spaces([ "case", make(branch[0]) + ":" ]) - : "default:"); - }, 0.5) + (has_body ? newline + with_indent(function(){ - return make_block_statements(branch[1]).join(newline); - }) : ""); - if (!beautify && has_body && i < n - 1) - code += ";"; - return code; - }).join(newline) + newline + indent("}"); - }; - - function make_block(statements) { - if (!statements) return ";"; - if (statements.length == 0) return "{}"; - return "{" + newline + with_indent(function(){ - return make_block_statements(statements).join(newline); - }) + newline + indent("}"); - }; - - function make_1vardef(def) { - var name = def[0], val = def[1]; - if (val != null) - name = add_spaces([ make_name(name), "=", parenthesize(val, "seq") ]); - return name; - }; - - var $stack = []; - - function make(node) { - var type = node[0]; - var gen = generators[type]; - if (!gen) - throw new Error("Can't find generator for \"" + type + "\""); - $stack.push(node); - var ret = gen.apply(type, node.slice(1)); - $stack.pop(); - return ret; - }; - - return make(ast); -}; - -function split_lines(code, max_line_length) { - var splits = [ 0 ]; - jsp.parse(function(){ - var next_token = jsp.tokenizer(code); - var last_split = 0; - var prev_token; - function current_length(tok) { - return tok.pos - last_split; - }; - function split_here(tok) { - last_split = tok.pos; - splits.push(last_split); - }; - function custom(){ - var tok = next_token.apply(this, arguments); - out: { - if (prev_token) { - if (prev_token.type == "keyword") break out; - } - if (current_length(tok) > max_line_length) { - switch (tok.type) { - case "keyword": - case "atom": - case "name": - case "punc": - split_here(tok); - break out; - } - } - } - prev_token = tok; - return tok; - }; - custom.context = function() { - return next_token.context.apply(this, arguments); - }; - return custom; - }()); - return splits.map(function(pos, i){ - return code.substring(pos, splits[i + 1] || code.length); - }).join("\n"); -}; - -/* -----[ Utilities ]----- */ - -function repeat_string(str, i) { - if (i <= 0) return ""; - if (i == 1) return str; - var d = repeat_string(str, i >> 1); - d += d; - if (i & 1) d += str; - return d; -}; - -function defaults(args, defs) { - var ret = {}; - if (args === true) - args = {}; - for (var i in defs) if (HOP(defs, i)) { - ret[i] = (args && HOP(args, i)) ? args[i] : defs[i]; - } - return ret; -}; - -function is_identifier(name) { - return /^[a-z_$][a-z0-9_$]*$/i.test(name) - && name != "this" - && !HOP(jsp.KEYWORDS_ATOM, name) - && !HOP(jsp.RESERVED_WORDS, name) - && !HOP(jsp.KEYWORDS, name); -}; - -function HOP(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -}; - -// some utilities - -var MAP; - -(function(){ - MAP = function(a, f, o) { - var ret = []; - for (var i = 0; i < a.length; ++i) { - var val = f.call(o, a[i], i); - if (val instanceof AtTop) ret.unshift(val.v); - else ret.push(val); - } - return ret; - }; - MAP.at_top = function(val) { return new AtTop(val) }; - function AtTop(val) { this.v = val }; -})(); - -/* -----[ Exports ]----- */ - -exports.ast_walker = ast_walker; -exports.ast_mangle = ast_mangle; -exports.ast_squeeze = ast_squeeze; -exports.gen_code = gen_code; -exports.ast_add_scope = ast_add_scope; -exports.set_logger = function(logger) { warn = logger }; -exports.make_string = make_string; -exports.split_lines = split_lines; -exports.MAP = MAP; - -// keep this last! -exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more; -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/process.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/uglify-js/lib"; - var __filename = "/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/uglify-js/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js"]._cached = module.exports; - - (function () { - var jsp = require("./parse-js"), - pro = require("./process"), - slice = jsp.slice, - member = jsp.member, - PRECEDENCE = jsp.PRECEDENCE, - OPERATORS = jsp.OPERATORS; - -function ast_squeeze_more(ast) { - var w = pro.ast_walker(), walk = w.walk; - return w.with_walkers({ - "call": function(expr, args) { - if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) { - // foo.toString() ==> foo+"" - return [ "binary", "+", expr[1], [ "string", "" ]]; - } - } - }, function() { - return walk(ast); - }); -}; - -exports.ast_squeeze_more = ast_squeeze_more; -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/uglify-js/lib/squeeze-more.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/traverse/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/traverse"; - var __filename = "/node_modules/burrito/node_modules/traverse/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/traverse"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/traverse"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/traverse/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"traverse","version":"0.5.0","description":"Traverse and transform objects by visiting every node on a recursive walk","author":"James Halliday","license":"MIT/X11","main":"./index","repository":{"type":"git","url":"https://github.com/substack/js-traverse.git"},"devDependencies":{"expresso":"0.7.x"},"scripts":{"test":"expresso"}}; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/traverse/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/node_modules/traverse/index.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito/node_modules/traverse"; - var __filename = "/node_modules/burrito/node_modules/traverse/index.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito/node_modules/traverse"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito/node_modules/traverse"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/node_modules/traverse/index.js"]._cached = module.exports; - - (function () { - module.exports = Traverse; -function Traverse (obj) { - if (!(this instanceof Traverse)) return new Traverse(obj); - this.value = obj; -} - -Traverse.prototype.get = function (ps) { - var node = this.value; - for (var i = 0; i < ps.length; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) { - node = undefined; - break; - } - node = node[key]; - } - return node; -}; - -Traverse.prototype.set = function (ps, value) { - var node = this.value; - for (var i = 0; i < ps.length - 1; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) node[key] = {}; - node = node[key]; - } - node[ps[i]] = value; - return value; -}; - -Traverse.prototype.map = function (cb) { - return walk(this.value, cb, true); -}; - -Traverse.prototype.forEach = function (cb) { - this.value = walk(this.value, cb, false); - return this.value; -}; - -Traverse.prototype.reduce = function (cb, init) { - var skip = arguments.length === 1; - var acc = skip ? this.value : init; - this.forEach(function (x) { - if (!this.isRoot || !skip) { - acc = cb.call(this, acc, x); - } - }); - return acc; -}; - -Traverse.prototype.paths = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.path); - }); - return acc; -}; - -Traverse.prototype.nodes = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.node); - }); - return acc; -}; - -Traverse.prototype.clone = function () { - var parents = [], nodes = []; - - return (function clone (src) { - for (var i = 0; i < parents.length; i++) { - if (parents[i] === src) { - return nodes[i]; - } - } - - if (typeof src === 'object' && src !== null) { - var dst = copy(src); - - parents.push(src); - nodes.push(dst); - - forEach(Object_keys(src), function (key) { - dst[key] = clone(src[key]); - }); - - parents.pop(); - nodes.pop(); - return dst; - } - else { - return src; - } - })(this.value); -}; - -function walk (root, cb, immutable) { - var path = []; - var parents = []; - var alive = true; - - return (function walker (node_) { - var node = immutable ? copy(node_) : node_; - var modifiers = {}; - - var keepGoing = true; - - var state = { - node : node, - node_ : node_, - path : [].concat(path), - parent : parents[parents.length - 1], - parents : parents, - key : path.slice(-1)[0], - isRoot : path.length === 0, - level : path.length, - circular : null, - update : function (x, stopHere) { - if (!state.isRoot) { - state.parent.node[state.key] = x; - } - state.node = x; - if (stopHere) keepGoing = false; - }, - 'delete' : function () { - delete state.parent.node[state.key]; - }, - remove : function () { - if (Array_isArray(state.parent.node)) { - state.parent.node.splice(state.key, 1); - } - else { - delete state.parent.node[state.key]; - } - }, - keys : null, - before : function (f) { modifiers.before = f }, - after : function (f) { modifiers.after = f }, - pre : function (f) { modifiers.pre = f }, - post : function (f) { modifiers.post = f }, - stop : function () { alive = false }, - block : function () { keepGoing = false } - }; - - if (!alive) return state; - - if (typeof node === 'object' && node !== null) { - state.keys = Object_keys(node); - - state.isLeaf = state.keys.length == 0; - - for (var i = 0; i < parents.length; i++) { - if (parents[i].node_ === node_) { - state.circular = parents[i]; - break; - } - } - } - else { - state.isLeaf = true; - } - - state.notLeaf = !state.isLeaf; - state.notRoot = !state.isRoot; - - // use return values to update if defined - var ret = cb.call(state, state.node); - if (ret !== undefined && state.update) state.update(ret); - - if (modifiers.before) modifiers.before.call(state, state.node); - - if (!keepGoing) return state; - - if (typeof state.node == 'object' - && state.node !== null && !state.circular) { - parents.push(state); - - forEach(state.keys, function (key, i) { - path.push(key); - - if (modifiers.pre) modifiers.pre.call(state, state.node[key], key); - - var child = walker(state.node[key]); - if (immutable && Object.hasOwnProperty.call(state.node, key)) { - state.node[key] = child.node; - } - - child.isLast = i == state.keys.length - 1; - child.isFirst = i == 0; - - if (modifiers.post) modifiers.post.call(state, child); - - path.pop(); - }); - parents.pop(); - } - - if (modifiers.after) modifiers.after.call(state, state.node); - - return state; - })(root).node; -} - -function copy (src) { - if (typeof src === 'object' && src !== null) { - var dst; - - if (Array_isArray(src)) { - dst = []; - } - else if (src instanceof Date) { - dst = new Date(src); - } - else if (src instanceof Boolean) { - dst = new Boolean(src); - } - else if (src instanceof Number) { - dst = new Number(src); - } - else if (src instanceof String) { - dst = new String(src); - } - else if (Object.create && Object.getPrototypeOf) { - dst = Object.create(Object.getPrototypeOf(src)); - } - else if (src.__proto__ || src.constructor.prototype) { - var proto = src.__proto__ || src.constructor.prototype || {}; - var T = function () {}; - T.prototype = proto; - dst = new T; - if (!dst.__proto__) dst.__proto__ = proto; - } - - forEach(Object_keys(src), function (key) { - dst[key] = src[key]; - }); - return dst; - } - else return src; -} - -var Object_keys = Object.keys || function keys (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -forEach(Object_keys(Traverse.prototype), function (key) { - Traverse[key] = function (obj) { - var args = [].slice.call(arguments, 1); - var t = Traverse(obj); - return t[key].apply(t, args); - }; -}); -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/node_modules/traverse/index.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["vm"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "."; - var __filename = "vm"; - - var require = function (file) { - return __require(file, "."); - }; - - require.resolve = function (file) { - return __require.resolve(name, "."); - }; - - require.modules = __require.modules; - __require.modules["vm"]._cached = module.exports; - - (function () { - var Object_keys = function (obj) { - if (Object.keys) return Object.keys(obj) - else { - var res = []; - for (var key in obj) res.push(key) - return res; - } -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -var Script = exports.Script = function NodeScript (code) { - if (!(this instanceof Script)) return new Script(code); - this.code = code; -}; - -var iframe = document.createElement('iframe'); -if (!iframe.style) iframe.style = {}; -iframe.style.display = 'none'; - -var iframeCapable = true; // until proven otherwise -if (navigator.appName === 'Microsoft Internet Explorer') { - var m = navigator.appVersion.match(/\bMSIE (\d+\.\d+);/); - if (m && parseFloat(m[1]) <= 9.0) { - iframeCapable = false; - } -} - -Script.prototype.runInNewContext = function (context) { - if (!context) context = {}; - - if (!iframeCapable) { - var keys = Object_keys(context); - var args = []; - for (var i = 0; i < keys.length; i++) { - args.push(context[keys[i]]); - } - - var fn = Function(keys, this.code); - return fn.apply(null, args); - } - - document.body.appendChild(iframe); - - var win = iframe.contentWindow - || (window.frames && window.frames[window.frames.length - 1]) - || window[window.length - 1] - ; - - forEach(Object_keys(context), function (key) { - win[key] = context[key]; - iframe[key] = context[key]; - }); - - if (win.eval) { - // chrome and ff can just .eval() - var res = win.eval(this.code); - } - else { - // this works in IE9 but not anything newer - iframe.setAttribute('src', - 'javascript:__browserifyVmResult=(' + this.code + ')' - ); - if ('__browserifyVmResult' in win) { - var res = win.__browserifyVmResult; - } - else { - iframeCapable = false; - res = this.runInThisContext(context); - } - } - - forEach(Object_keys(win), function (key) { - context[key] = win[key]; - }); - - document.body.removeChild(iframe); - - return res; -}; - -Script.prototype.runInThisContext = function () { - return eval(this.code); // maybe... -}; - -Script.prototype.runInContext = function (context) { - // seems to be just runInNewContext on magical context objects which are - // otherwise indistinguishable from objects except plain old objects - // for the parameter segfaults node - return this.runInNewContext(context); -}; - -forEach(Object_keys(Script.prototype), function (name) { - exports[name] = Script[name] = function (code) { - var s = Script(code); - return s[name].apply(s, [].slice.call(arguments, 1)); - }; -}); - -exports.createScript = function (code) { - return exports.Script(code); -}; - -exports.createContext = Script.createContext = function (context) { - // not really sure what this one does - // seems to just make a shallow copy - var copy = {}; - forEach(Object_keys(context), function (key) { - copy[key] = context[key]; - }); - return copy; -}; -; - }).call(module.exports); - - __require.modules["vm"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/jsonify/package.json"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/jsonify"; - var __filename = "/node_modules/jsonify/package.json"; - - var require = function (file) { - return __require(file, "/node_modules/jsonify"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/jsonify"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/jsonify/package.json"]._cached = module.exports; - - (function () { - module.exports = {"name":"jsonify","version":"0.0.0","description":"JSON without touching any globals","main":"index.js","directories":{"lib":".","test":"test"},"devDependencies":{"tap":"0.0.x","garbage":"0.0.x"},"scripts":{"test":"tap test"},"repository":{"type":"git","url":"https://github.com/substack/jsonify.git"},"keywords":["json","browser"],"author":{"name":"Douglas Crockford","url":"http://crockford.com/"},"license":"Public Domain"}; - }).call(module.exports); - - __require.modules["/node_modules/jsonify/package.json"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/jsonify/index.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/jsonify"; - var __filename = "/node_modules/jsonify/index.js"; - - var require = function (file) { - return __require(file, "/node_modules/jsonify"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/jsonify"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/jsonify/index.js"]._cached = module.exports; - - (function () { - exports.parse = require('./lib/parse'); -exports.stringify = require('./lib/stringify'); -; - }).call(module.exports); - - __require.modules["/node_modules/jsonify/index.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/jsonify/lib/parse.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/jsonify/lib"; - var __filename = "/node_modules/jsonify/lib/parse.js"; - - var require = function (file) { - return __require(file, "/node_modules/jsonify/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/jsonify/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/jsonify/lib/parse.js"]._cached = module.exports; - - (function () { - var at, // The index of the current character - ch, // The current character - escapee = { - '"': '"', - '\\': '\\', - '/': '/', - b: '\b', - f: '\f', - n: '\n', - r: '\r', - t: '\t' - }, - text, - - error = function (m) { - // Call error when something is wrong. - throw { - name: 'SyntaxError', - message: m, - at: at, - text: text - }; - }, - - next = function (c) { - // If a c parameter is provided, verify that it matches the current character. - if (c && c !== ch) { - error("Expected '" + c + "' instead of '" + ch + "'"); - } - - // Get the next character. When there are no more characters, - // return the empty string. - - ch = text.charAt(at); - at += 1; - return ch; - }, - - number = function () { - // Parse a number value. - var number, - string = ''; - - if (ch === '-') { - string = '-'; - next('-'); - } - while (ch >= '0' && ch <= '9') { - string += ch; - next(); - } - if (ch === '.') { - string += '.'; - while (next() && ch >= '0' && ch <= '9') { - string += ch; - } - } - if (ch === 'e' || ch === 'E') { - string += ch; - next(); - if (ch === '-' || ch === '+') { - string += ch; - next(); - } - while (ch >= '0' && ch <= '9') { - string += ch; - next(); - } - } - number = +string; - if (!isFinite(number)) { - error("Bad number"); - } else { - return number; - } - }, - - string = function () { - // Parse a string value. - var hex, - i, - string = '', - uffff; - - // When parsing for string values, we must look for " and \ characters. - if (ch === '"') { - while (next()) { - if (ch === '"') { - next(); - return string; - } else if (ch === '\\') { - next(); - if (ch === 'u') { - uffff = 0; - for (i = 0; i < 4; i += 1) { - hex = parseInt(next(), 16); - if (!isFinite(hex)) { - break; - } - uffff = uffff * 16 + hex; - } - string += String.fromCharCode(uffff); - } else if (typeof escapee[ch] === 'string') { - string += escapee[ch]; - } else { - break; - } - } else { - string += ch; - } - } - } - error("Bad string"); - }, - - white = function () { - -// Skip whitespace. - - while (ch && ch <= ' ') { - next(); - } - }, - - word = function () { - -// true, false, or null. - - switch (ch) { - case 't': - next('t'); - next('r'); - next('u'); - next('e'); - return true; - case 'f': - next('f'); - next('a'); - next('l'); - next('s'); - next('e'); - return false; - case 'n': - next('n'); - next('u'); - next('l'); - next('l'); - return null; - } - error("Unexpected '" + ch + "'"); - }, - - value, // Place holder for the value function. - - array = function () { - -// Parse an array value. - - var array = []; - - if (ch === '[') { - next('['); - white(); - if (ch === ']') { - next(']'); - return array; // empty array - } - while (ch) { - array.push(value()); - white(); - if (ch === ']') { - next(']'); - return array; - } - next(','); - white(); - } - } - error("Bad array"); - }, - - object = function () { - -// Parse an object value. - - var key, - object = {}; - - if (ch === '{') { - next('{'); - white(); - if (ch === '}') { - next('}'); - return object; // empty object - } - while (ch) { - key = string(); - white(); - next(':'); - if (Object.hasOwnProperty.call(object, key)) { - error('Duplicate key "' + key + '"'); - } - object[key] = value(); - white(); - if (ch === '}') { - next('}'); - return object; - } - next(','); - white(); - } - } - error("Bad object"); - }; - -value = function () { - -// Parse a JSON value. It could be an object, an array, a string, a number, -// or a word. - - white(); - switch (ch) { - case '{': - return object(); - case '[': - return array(); - case '"': - return string(); - case '-': - return number(); - default: - return ch >= '0' && ch <= '9' ? number() : word(); - } -}; - -// Return the json_parse function. It will have access to all of the above -// functions and variables. - -module.exports = function (source, reviver) { - var result; - - text = source; - at = 0; - ch = ' '; - result = value(); - white(); - if (ch) { - error("Syntax error"); - } - - // If there is a reviver function, we recursively walk the new structure, - // passing each name/value pair to the reviver function for possible - // transformation, starting with a temporary root object that holds the result - // in an empty key. If there is not a reviver function, we simply return the - // result. - - return typeof reviver === 'function' ? (function walk(holder, key) { - var k, v, value = holder[key]; - if (value && typeof value === 'object') { - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = walk(value, k); - if (v !== undefined) { - value[k] = v; - } else { - delete value[k]; - } - } - } - } - return reviver.call(holder, key, value); - }({'': result}, '')) : result; -}; -; - }).call(module.exports); - - __require.modules["/node_modules/jsonify/lib/parse.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/jsonify/lib/stringify.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/jsonify/lib"; - var __filename = "/node_modules/jsonify/lib/stringify.js"; - - var require = function (file) { - return __require(file, "/node_modules/jsonify/lib"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/jsonify/lib"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/jsonify/lib/stringify.js"]._cached = module.exports; - - (function () { - var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, - gap, - indent, - meta = { // table of character substitutions - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '"' : '\\"', - '\\': '\\\\' - }, - rep; - -function quote(string) { - // If the string contains no control characters, no quote characters, and no - // backslash characters, then we can safely slap some quotes around it. - // Otherwise we must also replace the offending characters with safe escape - // sequences. - - escapable.lastIndex = 0; - return escapable.test(string) ? '"' + string.replace(escapable, function (a) { - var c = meta[a]; - return typeof c === 'string' ? c : - '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); - }) + '"' : '"' + string + '"'; -} - -function str(key, holder) { - // Produce a string from holder[key]. - var i, // The loop counter. - k, // The member key. - v, // The member value. - length, - mind = gap, - partial, - value = holder[key]; - - // If the value has a toJSON method, call it to obtain a replacement value. - if (value && typeof value === 'object' && - typeof value.toJSON === 'function') { - value = value.toJSON(key); - } - - // If we were called with a replacer function, then call the replacer to - // obtain a replacement value. - if (typeof rep === 'function') { - value = rep.call(holder, key, value); - } - - // What happens next depends on the value's type. - switch (typeof value) { - case 'string': - return quote(value); - - case 'number': - // JSON numbers must be finite. Encode non-finite numbers as null. - return isFinite(value) ? String(value) : 'null'; - - case 'boolean': - case 'null': - // If the value is a boolean or null, convert it to a string. Note: - // typeof null does not produce 'null'. The case is included here in - // the remote chance that this gets fixed someday. - return String(value); - - case 'object': - if (!value) return 'null'; - gap += indent; - partial = []; - - // Array.isArray - if (Object.prototype.toString.apply(value) === '[object Array]') { - length = value.length; - for (i = 0; i < length; i += 1) { - partial[i] = str(i, value) || 'null'; - } - - // Join all of the elements together, separated with commas, and - // wrap them in brackets. - v = partial.length === 0 ? '[]' : gap ? - '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : - '[' + partial.join(',') + ']'; - gap = mind; - return v; - } - - // If the replacer is an array, use it to select the members to be - // stringified. - if (rep && typeof rep === 'object') { - length = rep.length; - for (i = 0; i < length; i += 1) { - k = rep[i]; - if (typeof k === 'string') { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } - else { - // Otherwise, iterate through all of the keys in the object. - for (k in value) { - if (Object.prototype.hasOwnProperty.call(value, k)) { - v = str(k, value); - if (v) { - partial.push(quote(k) + (gap ? ': ' : ':') + v); - } - } - } - } - - // Join all of the member texts together, separated with commas, - // and wrap them in braces. - - v = partial.length === 0 ? '{}' : gap ? - '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : - '{' + partial.join(',') + '}'; - gap = mind; - return v; - } -} - -module.exports = function (value, replacer, space) { - var i; - gap = ''; - indent = ''; - - // If the space parameter is a number, make an indent string containing that - // many spaces. - if (typeof space === 'number') { - for (i = 0; i < space; i += 1) { - indent += ' '; - } - } - // If the space parameter is a string, it will be used as the indent string. - else if (typeof space === 'string') { - indent = space; - } - - // If there is a replacer, it must be a function or an array. - // Otherwise, throw an error. - rep = replacer; - if (replacer && typeof replacer !== 'function' - && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { - throw new Error('JSON.stringify'); - } - - // Make a fake root object containing our value under the key of ''. - // Return the result of stringifying the value. - return str('', {'': value}); -}; -; - }).call(module.exports); - - __require.modules["/node_modules/jsonify/lib/stringify.js"]._cached = module.exports; - return module.exports; -}; - -require.modules["/node_modules/burrito/index.js"] = function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/node_modules/burrito"; - var __filename = "/node_modules/burrito/index.js"; - - var require = function (file) { - return __require(file, "/node_modules/burrito"); - }; - - require.resolve = function (file) { - return __require.resolve(name, "/node_modules/burrito"); - }; - - require.modules = __require.modules; - __require.modules["/node_modules/burrito/index.js"]._cached = module.exports; - - (function () { - var uglify = require('uglify-js'); -var parser = uglify.parser; -var parse = function (expr) { - if (typeof expr !== 'string') throw 'expression should be a string'; - - //try { - var args = [].slice.call(arguments); - var ast = parser.parse.apply(null, args); - /* } - catch (err) { - if (err.message === undefined - || err.line === undefined - || err.col === undefined - || err.pos === undefined - ) { throw err } - - var e = new SyntaxError( - err.message - + '\n at line ' + err.line + ':' + err.col + ' in expression:\n\n' - + ' ' + expr.split(/\r?\n/)[err.line] - ); - - e.original = err; - e.line = err.line; - e.col = err.col; - e.pos = err.pos; - throw e; - } - */ - return ast; -}; - -var deparse = function (ast, b) { - return uglify.uglify.gen_code(ast, { beautify : b }); -}; - -var traverse = require('traverse'); -var vm = require('vm'); - -var burrito = module.exports = function (code, cb) { - var ast = Array_isArray(code) - ? code // already an ast - : parse(code.toString(), false, true) - ; - - var ast_ = traverse(ast).map(function mapper () { - wrapNode(this, cb); - }); - - return deparse(parse(deparse(ast_)), true); -}; - -var wrapNode = burrito.wrapNode = function (state, cb) { - var node = state.node; - - var ann = Array_isArray(node) && node[0] - && typeof node[0] === 'object' && node[0].name - ? node[0] - : null - ; - - if (!ann) return undefined; - - var self = { - name : ann.name, - node : node, - start : node[0].start, - end : node[0].end, - value : node.slice(1), - state : state - }; - - self.wrap = function (s) { - var subsrc = deparse( - traverse(node).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - }) - ); - - if (self.name === 'binary') { - var a = deparse(traverse(node[2]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - var b = deparse(traverse(node[3]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - } - - var src = ''; - - if (typeof s === 'function') { - if (self.name === 'binary') { - src = s(subsrc, a, b); - } - else { - src = s(subsrc); - } - } - else { - src = s.toString() - .replace(/%s/g, function () { - return subsrc - }) - ; - - if (self.name === 'binary') { - src = src - .replace(/%a/g, function () { return a }) - .replace(/%b/g, function () { return b }) - ; - } - } - - var expr = parse(src); - state.update(expr, true); - }; - - var cache = {}; - - self.parent = state.isRoot ? null : function () { - if (!cache.parent) { - var s = state; - var x; - do { - s = s.parent; - if (s) x = wrapNode(s); - } while (s && !x); - - cache.parent = x; - } - - return cache.parent; - }; - - self.source = function () { - if (!cache.source) cache.source = deparse(node); - return cache.source; - }; - - self.label = function () { - return burrito.label(self); - }; - - if (cb) cb.call(state, self); - - if (self.node[0].name === 'conditional') { - self.wrap('[%s][0]'); - } - - return self; -} - -burrito.microwave = function (code, context, cb) { - if (!cb) { cb = context; context = {} }; - if (!context) context = {}; - - var src = burrito(code, cb); - return vm.runInNewContext(src, context); -}; - -burrito.generateName = function (len) { - var name = ''; - var lower = '$'.charCodeAt(0); - var upper = 'z'.charCodeAt(0); - - while (name.length < len) { - var c = String.fromCharCode(Math.floor( - Math.random() * (upper - lower + 1) + lower - )); - if ((name + c).match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) name += c; - } - - return name; -}; - -burrito.parse = parse; -burrito.deparse = deparse; - -burrito.label = function (node) { - if (node.name === 'call') { - if (typeof node.value[0] === 'string') { - return node.value[0]; - } - else if (node.value[0] && typeof node.value[0][1] === 'string') { - return node.value[0][1]; - } - else { - return null; - } - } - else if (node.name === 'var') { - return node.value[0].map(function (x) { return x[0] }); - } - else if (node.name === 'defun') { - return node.value[0]; - } - else if (node.name === 'function') { - return node.value[0]; - } - else { - return null; - } -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; -; - }).call(module.exports); - - __require.modules["/node_modules/burrito/index.js"]._cached = module.exports; - return module.exports; -}; - -process.nextTick(function () { - var module = { exports : {} }; - var exports = module.exports; - var __dirname = "/"; - var __filename = "//home/substack/projects/node-burrito/example/web"; - - var require = function (file) { - return __require(file, "/"); - }; - require.modules = __require.modules; - - var burrito = require('burrito'); -var json = require('jsonify'); - -var src = [ - 'function f () { g() }', - 'function g () { h() }', - 'function h () { throw "moo" + Array(x).join("!") }', - 'var x = 4', - 'f()' -].join('\r\n'); - -window.onload = function () { - burrito(src, function (node) { - document.body.innerHTML += node.name + '
\n'; - }); -}; -if (document.readyState === 'complete') window.onload(); -; -}); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/index.html b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/index.html deleted file mode 100644 index 66804fba4..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - -

-
-
diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/main.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/main.js
deleted file mode 100644
index cc81a8b76..000000000
--- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/main.js
+++ /dev/null
@@ -1,17 +0,0 @@
-var burrito = require('burrito');
-var json = require('jsonify');
-
-var src = [
-    'function f () { g() }',
-    'function g () { h() }',
-    'function h () { throw "moo" + Array(x).join("!") }',
-    'var x = 4',
-    'f()'
-].join('\r\n');
-
-window.onload = function () {
-    burrito(src, function (node) {
-        document.body.innerHTML += node.name + '
\n'; - }); -}; -if (document.readyState === 'complete') window.onload(); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/server.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/server.js deleted file mode 100644 index 6bce0206d..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/web/server.js +++ /dev/null @@ -1,12 +0,0 @@ -var express = require('express'); -var browserify = require('browserify'); - -var app = express.createServer(); -app.use(express.static(__dirname)); -app.use(browserify({ - entry : __dirname + '/main.js', - watch : true, -})); - -app.listen(8081); -console.log('Listening on :8081'); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/wrap.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/wrap.js deleted file mode 100644 index 16424012b..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/example/wrap.js +++ /dev/null @@ -1,7 +0,0 @@ -var burrito = require('burrito'); - -var src = burrito('f() && g(h())\nfoo()', function (node) { - if (node.name === 'call') node.wrap('qqq(%s)'); -}); - -console.log(src); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.html b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.html deleted file mode 100644 index c69d5885d..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - -

results

- - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.js deleted file mode 100644 index 60ef56989..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/index.js +++ /dev/null @@ -1,208 +0,0 @@ -var uglify = require('uglify-js'); -var parser = uglify.parser; -var parse = function (expr) { - if (typeof expr !== 'string') throw 'expression should be a string'; - - try { - var ast = parser.parse.apply(null, arguments); - } - catch (err) { - if (err.message === undefined - || err.line === undefined - || err.col === undefined - || err.pos === undefined - ) { throw err } - - var e = new SyntaxError( - err.message - + '\n at line ' + err.line + ':' + err.col + ' in expression:\n\n' - + ' ' + expr.split(/\r?\n/)[err.line] - ); - - e.original = err; - e.line = err.line; - e.col = err.col; - e.pos = err.pos; - throw e; - } - return ast; -}; - -var deparse = function (ast, b) { - return uglify.uglify.gen_code(ast, { beautify : b }); -}; - -var traverse = require('traverse'); -var vm = require('vm'); - -var burrito = module.exports = function (code, cb) { - var ast = Array_isArray(code) - ? code // already an ast - : parse(code.toString(), false, true) - ; - - var ast_ = traverse(ast).map(function mapper () { - wrapNode(this, cb); - }); - - return deparse(parse(deparse(ast_)), true); -}; - -var wrapNode = burrito.wrapNode = function (state, cb) { - var node = state.node; - - var ann = Array_isArray(node) && node[0] - && typeof node[0] === 'object' && node[0].name - ? node[0] - : null - ; - - if (!ann) return undefined; - - var self = { - name : ann.name, - node : node, - start : node[0].start, - end : node[0].end, - value : node.slice(1), - state : state - }; - - self.wrap = function (s) { - var subsrc = deparse( - traverse(node).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - }) - ); - - if (self.name === 'binary') { - var a = deparse(traverse(node[2]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - var b = deparse(traverse(node[3]).map(function (x) { - if (!this.isRoot) wrapNode(this, cb) - })); - } - - var src = ''; - - if (typeof s === 'function') { - if (self.name === 'binary') { - src = s(subsrc, a, b); - } - else { - src = s(subsrc); - } - } - else { - src = s.toString() - .replace(/%s/g, function () { - return subsrc - }) - ; - - if (self.name === 'binary') { - src = src - .replace(/%a/g, function () { return a }) - .replace(/%b/g, function () { return b }) - ; - } - } - - var expr = parse(src); - state.update(expr, true); - }; - - var cache = {}; - - self.parent = state.isRoot ? null : function () { - if (!cache.parent) { - var s = state; - var x; - do { - s = s.parent; - if (s) x = wrapNode(s); - } while (s && !x); - - cache.parent = x; - } - - return cache.parent; - }; - - self.source = function () { - if (!cache.source) cache.source = deparse(node); - return cache.source; - }; - - self.label = function () { - return burrito.label(self); - }; - - if (cb) cb.call(state, self); - - if (self.node[0].name === 'conditional') { - self.wrap('[%s][0]'); - } - - return self; -} - -burrito.microwave = function (code, context, cb) { - if (!cb) { cb = context; context = {} }; - if (!context) context = {}; - - var src = burrito(code, cb); - return vm.runInNewContext(src, context); -}; - -burrito.generateName = function (len) { - var name = ''; - var lower = '$'.charCodeAt(0); - var upper = 'z'.charCodeAt(0); - - while (name.length < len) { - var c = String.fromCharCode(Math.floor( - Math.random() * (upper - lower + 1) + lower - )); - if ((name + c).match(/^[A-Za-z_$][A-Za-z0-9_$]*$/)) name += c; - } - - return name; -}; - -burrito.parse = parse; -burrito.deparse = deparse; - -burrito.label = function (node) { - if (node.name === 'call') { - if (typeof node.value[0] === 'string') { - return node.value[0]; - } - else if (node.value[0] && typeof node.value[0][1] === 'string') { - return node.value[0][1]; - } - else if (node.value[0][0] === 'dot') { - return node.value[0][node.value[0].length - 1]; - } - else { - return null; - } - } - else if (node.name === 'var') { - return node.value[0].map(function (x) { return x[0] }); - } - else if (node.name === 'defun') { - return node.value[0]; - } - else if (node.name === 'function') { - return node.value[0]; - } - else { - return null; - } -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/main.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/main.js deleted file mode 100644 index a8449f22d..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/main.js +++ /dev/null @@ -1,11 +0,0 @@ -var burrito = require('./'); - -window.onload = function () { - var res = burrito.microwave('Math.sin(2)', function (node) { - if (node.name === 'num') node.wrap('Math.PI / %s'); - }); - - document.body.innerHTML += res; -}; - -if (document.readyState === 'complete') window.onload(); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/.bin/uglifyjs b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/.bin/uglifyjs deleted file mode 120000 index fef3468b6..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/.bin/uglifyjs +++ /dev/null @@ -1 +0,0 @@ -../uglify-js/bin/uglifyjs \ No newline at end of file diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/.npmignore b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/.npmignore deleted file mode 100644 index 3c3629e64..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/LICENSE b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/LICENSE deleted file mode 100644 index 7b75500c5..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -Copyright 2010 James Halliday (mail@substack.net) - -This project is free software released under the MIT/X11 license: -http://www.opensource.org/licenses/mit-license.php - -Copyright 2010 James Halliday (mail@substack.net) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/README.markdown b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/README.markdown deleted file mode 100644 index f86ef7695..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/README.markdown +++ /dev/null @@ -1,237 +0,0 @@ -traverse -======== - -Traverse and transform objects by visiting every node on a recursive walk. - -examples -======== - -transform negative numbers in-place ------------------------------------ - -negative.js - -````javascript -var traverse = require('traverse'); -var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -traverse(obj).forEach(function (x) { - if (x < 0) this.update(x + 128); -}); - -console.dir(obj); -```` - -Output: - - [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ] - -collect leaf nodes ------------------- - -leaves.js - -````javascript -var traverse = require('traverse'); - -var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 }, -}; - -var leaves = traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; -}, []); - -console.dir(leaves); -```` - -Output: - - [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -scrub circular references -------------------------- - -scrub.js: - -````javascript -var traverse = require('traverse'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); -```` - -output: - - { a: 1, b: 2, c: [ 3, 4 ] } - -context -======= - -Each method that takes a callback has a context (its `this` object) with these -attributes: - -this.node ---------- - -The present node on the recursive walk - -this.path ---------- - -An array of string keys from the root to the present node - -this.parent ------------ - -The context of the node's parent. -This is `undefined` for the root node. - -this.key --------- - -The name of the key of the present node in its parent. -This is `undefined` for the root node. - -this.isRoot, this.notRoot -------------------------- - -Whether the present node is the root node - -this.isLeaf, this.notLeaf -------------------------- - -Whether or not the present node is a leaf node (has no children) - -this.level ----------- - -Depth of the node within the traversal - -this.circular -------------- - -If the node equals one of its parents, the `circular` attribute is set to the -context of that parent and the traversal progresses no deeper. - -this.update(value, stopHere=false) ----------------------------------- - -Set a new value for the present node. - -All the elements in `value` will be recursively traversed unless `stopHere` is -true. - -this.remove(stopHere=false) -------------- - -Remove the current element from the output. If the node is in an Array it will -be spliced off. Otherwise it will be deleted from its parent. - -this.delete(stopHere=false) -------------- - -Delete the current element from its parent in the output. Calls `delete` even on -Arrays. - -this.before(fn) ---------------- - -Call this function before any of the children are traversed. - -You can assign into `this.keys` here to traverse in a custom order. - -this.after(fn) --------------- - -Call this function after any of the children are traversed. - -this.pre(fn) ------------- - -Call this function before each of the children are traversed. - -this.post(fn) -------------- - -Call this function after each of the children are traversed. - -methods -======= - -.map(fn) --------- - -Execute `fn` for each node in the object and return a new object with the -results of the walk. To update nodes in the result use `this.update(value)`. - -.forEach(fn) ------------- - -Execute `fn` for each node in the object but unlike `.map()`, when -`this.update()` is called it updates the object in-place. - -.reduce(fn, acc) ----------------- - -For each node in the object, perform a -[left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function)) -with the return value of `fn(acc, node)`. - -If `acc` isn't specified, `acc` is set to the root object for the first step -and the root element is skipped. - -.paths() --------- - -Return an `Array` of every possible non-cyclic path in the object. -Paths are `Array`s of string keys. - -.nodes() --------- - -Return an `Array` of every node in the object. - -.clone() --------- - -Create a deep clone of the object. - -install -======= - -Using [npm](http://npmjs.org) do: - - $ npm install traverse - -test -==== - -Using [expresso](https://github.com/visionmedia/expresso) do: - - $ expresso - - 100% wahoo, your stuff is not broken! - -in the browser -============== - -Use [browserify](https://github.com/substack/node-browserify) to run traverse in -the browser. - -traverse has been tested and works with: - -* Internet Explorer 5.5, 6.0, 7.0, 8.0, 9.0 -* Firefox 3.5 -* Chrome 6.0 -* Opera 10.6 -* Safari 5.0 diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/json.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/json.js deleted file mode 100755 index 50d612e3a..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/json.js +++ /dev/null @@ -1,16 +0,0 @@ -var traverse = require('traverse'); - -var id = 54; -var callbacks = {}; -var obj = { moo : function () {}, foo : [2,3,4, function () {}] }; - -var scrubbed = traverse(obj).map(function (x) { - if (typeof x === 'function') { - callbacks[id] = { id : id, f : x, path : this.path }; - this.update('[Function]'); - id++; - } -}); - -console.dir(scrubbed); -console.dir(callbacks); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/leaves.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/leaves.js deleted file mode 100755 index c1b310b95..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/leaves.js +++ /dev/null @@ -1,15 +0,0 @@ -var traverse = require('traverse'); - -var obj = { - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 }, -}; - -var leaves = traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; -}, []); - -console.dir(leaves); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/negative.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/negative.js deleted file mode 100755 index 78608a059..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/negative.js +++ /dev/null @@ -1,8 +0,0 @@ -var traverse = require('traverse'); -var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -traverse(obj).forEach(function (x) { - if (x < 0) this.update(x + 128); -}); - -console.dir(obj); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/scrub.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/scrub.js deleted file mode 100755 index 5d15b9161..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/scrub.js +++ /dev/null @@ -1,10 +0,0 @@ -// scrub out circular references -var traverse = require('traverse'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/stringify.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/stringify.js deleted file mode 100755 index 167b68b23..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/examples/stringify.js +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env node -var traverse = require('traverse'); - -var obj = [ 'five', 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - -var s = ''; -traverse(obj).forEach(function to_s (node) { - if (Array.isArray(node)) { - this.before(function () { s += '[' }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += ']' }); - } - else if (typeof node == 'object') { - this.before(function () { s += '{' }); - this.pre(function (x, key) { - to_s(key); - s += ':'; - }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += '}' }); - } - else if (typeof node == 'string') { - s += '"' + node.toString().replace(/"/g, '\\"') + '"'; - } - else if (typeof node == 'function') { - s += 'null'; - } - else { - s += node.toString(); - } -}); - -console.log('JSON.stringify: ' + JSON.stringify(obj)); -console.log('this stringify: ' + s); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/index.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/index.js deleted file mode 100644 index 038a1ada3..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/index.js +++ /dev/null @@ -1,267 +0,0 @@ -module.exports = Traverse; -function Traverse (obj) { - if (!(this instanceof Traverse)) return new Traverse(obj); - this.value = obj; -} - -Traverse.prototype.get = function (ps) { - var node = this.value; - for (var i = 0; i < ps.length; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) { - node = undefined; - break; - } - node = node[key]; - } - return node; -}; - -Traverse.prototype.set = function (ps, value) { - var node = this.value; - for (var i = 0; i < ps.length - 1; i ++) { - var key = ps[i]; - if (!Object.hasOwnProperty.call(node, key)) node[key] = {}; - node = node[key]; - } - node[ps[i]] = value; - return value; -}; - -Traverse.prototype.map = function (cb) { - return walk(this.value, cb, true); -}; - -Traverse.prototype.forEach = function (cb) { - this.value = walk(this.value, cb, false); - return this.value; -}; - -Traverse.prototype.reduce = function (cb, init) { - var skip = arguments.length === 1; - var acc = skip ? this.value : init; - this.forEach(function (x) { - if (!this.isRoot || !skip) { - acc = cb.call(this, acc, x); - } - }); - return acc; -}; - -Traverse.prototype.paths = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.path); - }); - return acc; -}; - -Traverse.prototype.nodes = function () { - var acc = []; - this.forEach(function (x) { - acc.push(this.node); - }); - return acc; -}; - -Traverse.prototype.clone = function () { - var parents = [], nodes = []; - - return (function clone (src) { - for (var i = 0; i < parents.length; i++) { - if (parents[i] === src) { - return nodes[i]; - } - } - - if (typeof src === 'object' && src !== null) { - var dst = copy(src); - - parents.push(src); - nodes.push(dst); - - forEach(Object_keys(src), function (key) { - dst[key] = clone(src[key]); - }); - - parents.pop(); - nodes.pop(); - return dst; - } - else { - return src; - } - })(this.value); -}; - -function walk (root, cb, immutable) { - var path = []; - var parents = []; - var alive = true; - - return (function walker (node_) { - var node = immutable ? copy(node_) : node_; - var modifiers = {}; - - var keepGoing = true; - - var state = { - node : node, - node_ : node_, - path : [].concat(path), - parent : parents[parents.length - 1], - parents : parents, - key : path.slice(-1)[0], - isRoot : path.length === 0, - level : path.length, - circular : null, - update : function (x, stopHere) { - if (!state.isRoot) { - state.parent.node[state.key] = x; - } - state.node = x; - if (stopHere) keepGoing = false; - }, - 'delete' : function (stopHere) { - delete state.parent.node[state.key]; - if (stopHere) keepGoing = false; - }, - remove : function (stopHere) { - if (Array_isArray(state.parent.node)) { - state.parent.node.splice(state.key, 1); - } - else { - delete state.parent.node[state.key]; - } - if (stopHere) keepGoing = false; - }, - keys : null, - before : function (f) { modifiers.before = f }, - after : function (f) { modifiers.after = f }, - pre : function (f) { modifiers.pre = f }, - post : function (f) { modifiers.post = f }, - stop : function () { alive = false }, - block : function () { keepGoing = false } - }; - - if (!alive) return state; - - if (typeof node === 'object' && node !== null) { - state.keys = Object_keys(node); - - state.isLeaf = state.keys.length == 0; - - for (var i = 0; i < parents.length; i++) { - if (parents[i].node_ === node_) { - state.circular = parents[i]; - break; - } - } - } - else { - state.isLeaf = true; - } - - state.notLeaf = !state.isLeaf; - state.notRoot = !state.isRoot; - - // use return values to update if defined - var ret = cb.call(state, state.node); - if (ret !== undefined && state.update) state.update(ret); - - if (modifiers.before) modifiers.before.call(state, state.node); - - if (!keepGoing) return state; - - if (typeof state.node == 'object' - && state.node !== null && !state.circular) { - parents.push(state); - - forEach(state.keys, function (key, i) { - path.push(key); - - if (modifiers.pre) modifiers.pre.call(state, state.node[key], key); - - var child = walker(state.node[key]); - if (immutable && Object.hasOwnProperty.call(state.node, key)) { - state.node[key] = child.node; - } - - child.isLast = i == state.keys.length - 1; - child.isFirst = i == 0; - - if (modifiers.post) modifiers.post.call(state, child); - - path.pop(); - }); - parents.pop(); - } - - if (modifiers.after) modifiers.after.call(state, state.node); - - return state; - })(root).node; -} - -function copy (src) { - if (typeof src === 'object' && src !== null) { - var dst; - - if (Array_isArray(src)) { - dst = []; - } - else if (src instanceof Date) { - dst = new Date(src); - } - else if (src instanceof Boolean) { - dst = new Boolean(src); - } - else if (src instanceof Number) { - dst = new Number(src); - } - else if (src instanceof String) { - dst = new String(src); - } - else if (Object.create && Object.getPrototypeOf) { - dst = Object.create(Object.getPrototypeOf(src)); - } - else if (src.__proto__ || src.constructor.prototype) { - var proto = src.__proto__ || src.constructor.prototype || {}; - var T = function () {}; - T.prototype = proto; - dst = new T; - if (!dst.__proto__) dst.__proto__ = proto; - } - - forEach(Object_keys(src), function (key) { - dst[key] = src[key]; - }); - return dst; - } - else return src; -} - -var Object_keys = Object.keys || function keys (obj) { - var res = []; - for (var key in obj) res.push(key) - return res; -}; - -var Array_isArray = Array.isArray || function isArray (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -forEach(Object_keys(Traverse.prototype), function (key) { - Traverse[key] = function (obj) { - var args = [].slice.call(arguments, 1); - var t = Traverse(obj); - return t[key].apply(t, args); - }; -}); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/main.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/main.js deleted file mode 100755 index d562d379a..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/main.js +++ /dev/null @@ -1,10 +0,0 @@ -// scrub out circular references -var traverse = require('./index.js'); - -var obj = { a : 1, b : 2, c : [ 3, 4 ] }; -obj.c.push(obj); - -var scrubbed = traverse(obj).map(function (x) { - if (this.circular) this.remove() -}); -console.dir(scrubbed); diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/package.json b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/package.json deleted file mode 100644 index f86322a83..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name" : "traverse", - "version" : "0.5.2", - "description" : "Traverse and transform objects by visiting every node on a recursive walk", - "author" : "James Halliday", - "license" : "MIT/X11", - "main" : "./index", - "repository" : { - "type" : "git", - "url" : "https://github.com/substack/js-traverse.git" - }, - "devDependencies" : { - "expresso" : "0.7.x" - }, - "scripts" : { - "test" : "expresso" - } -} diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/circular.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/circular.js deleted file mode 100644 index 916260113..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/circular.js +++ /dev/null @@ -1,115 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); -var util = require('util'); - -exports.circular = function () { - var obj = { x : 3 }; - obj.y = obj; - var foundY = false; - Traverse(obj).forEach(function (x) { - if (this.path.join('') == 'y') { - assert.equal( - util.inspect(this.circular.node), - util.inspect(obj) - ); - foundY = true; - } - }); - assert.ok(foundY); -}; - -exports.deepCirc = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - - var times = 0; - Traverse(obj).forEach(function (x) { - if (this.circular) { - assert.deepEqual(this.circular.path, []); - assert.deepEqual(this.path, [ 'y', 2 ]); - times ++; - } - }); - - assert.deepEqual(times, 1); -}; - -exports.doubleCirc = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var circs = []; - Traverse(obj).forEach(function (x) { - if (this.circular) { - circs.push({ circ : this.circular, self : this, node : x }); - } - }); - - assert.deepEqual(circs[0].self.path, [ 'x', 3, 2 ]); - assert.deepEqual(circs[0].circ.path, []); - - assert.deepEqual(circs[1].self.path, [ 'y', 2 ]); - assert.deepEqual(circs[1].circ.path, []); - - assert.deepEqual(circs.length, 2); -}; - -exports.circDubForEach = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - Traverse(obj).forEach(function (x) { - if (this.circular) this.update('...'); - }); - - assert.deepEqual(obj, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] }); -}; - -exports.circDubMap = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var c = Traverse(obj).map(function (x) { - if (this.circular) { - this.update('...'); - } - }); - - assert.deepEqual(c, { x : [ 1, 2, 3, [ 4, 5, '...' ] ], y : [ 4, 5, '...' ] }); -}; - -exports.circClone = function () { - var obj = { x : [ 1, 2, 3 ], y : [ 4, 5 ] }; - obj.y[2] = obj; - obj.x.push(obj.y); - - var clone = Traverse.clone(obj); - assert.ok(obj !== clone); - - assert.ok(clone.y[2] === clone); - assert.ok(clone.y[2] !== obj); - assert.ok(clone.x[3][2] === clone); - assert.ok(clone.x[3][2] !== obj); - assert.deepEqual(clone.x.slice(0,3), [1,2,3]); - assert.deepEqual(clone.y.slice(0,2), [4,5]); -}; - -exports.circMapScrub = function () { - var obj = { a : 1, b : 2 }; - obj.c = obj; - - var scrubbed = Traverse(obj).map(function (node) { - if (this.circular) this.remove(); - }); - assert.deepEqual( - Object.keys(scrubbed).sort(), - [ 'a', 'b' ] - ); - assert.ok(deepEqual(scrubbed, { a : 1, b : 2 })); - - assert.equal(obj.c, obj); -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/date.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/date.js deleted file mode 100644 index 4ca06dc38..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/date.js +++ /dev/null @@ -1,35 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports.dateEach = function () { - var obj = { x : new Date, y : 10, z : 5 }; - - var counts = {}; - - Traverse(obj).forEach(function (node) { - var t = (node instanceof Date && 'Date') || typeof node; - counts[t] = (counts[t] || 0) + 1; - }); - - assert.deepEqual(counts, { - object : 1, - Date : 1, - number : 2, - }); -}; - -exports.dateMap = function () { - var obj = { x : new Date, y : 10, z : 5 }; - - var res = Traverse(obj).map(function (node) { - if (typeof node === 'number') this.update(node + 100); - }); - - assert.ok(obj.x !== res.x); - assert.deepEqual(res, { - x : obj.x, - y : 110, - z : 105, - }); -}; - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/equal.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/equal.js deleted file mode 100644 index decc75503..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/equal.js +++ /dev/null @@ -1,220 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -exports.deepDates = function () { - assert.ok( - deepEqual( - { d : new Date, x : [ 1, 2, 3 ] }, - { d : new Date, x : [ 1, 2, 3 ] } - ), - 'dates should be equal' - ); - - var d0 = new Date; - setTimeout(function () { - assert.ok( - !deepEqual( - { d : d0, x : [ 1, 2, 3 ], }, - { d : new Date, x : [ 1, 2, 3 ] } - ), - 'microseconds should count in date equality' - ); - }, 5); -}; - -exports.deepCircular = function () { - var a = [1]; - a.push(a); // a = [ 1, *a ] - - var b = [1]; - b.push(a); // b = [ 1, [ 1, *a ] ] - - assert.ok( - !deepEqual(a, b), - 'circular ref mount points count towards equality' - ); - - var c = [1]; - c.push(c); // c = [ 1, *c ] - assert.ok( - deepEqual(a, c), - 'circular refs are structurally the same here' - ); - - var d = [1]; - d.push(a); // c = [ 1, [ 1, *d ] ] - assert.ok( - deepEqual(b, d), - 'non-root circular ref structural comparison' - ); -}; - -exports.deepInstances = function () { - assert.ok( - !deepEqual([ new Boolean(false) ], [ false ]), - 'boolean instances are not real booleans' - ); - - assert.ok( - !deepEqual([ new String('x') ], [ 'x' ]), - 'string instances are not real strings' - ); - - assert.ok( - !deepEqual([ new Number(4) ], [ 4 ]), - 'number instances are not real numbers' - ); - - assert.ok( - deepEqual([ new RegExp('x') ], [ /x/ ]), - 'regexp instances are real regexps' - ); - - assert.ok( - !deepEqual([ new RegExp(/./) ], [ /../ ]), - 'these regexps aren\'t the same' - ); - - assert.ok( - !deepEqual( - [ function (x) { return x * 2 } ], - [ function (x) { return x * 2 } ] - ), - 'functions with the same .toString() aren\'t necessarily the same' - ); - - var f = function (x) { return x * 2 }; - assert.ok( - deepEqual([ f ], [ f ]), - 'these functions are actually equal' - ); -}; - -exports.deepEqual = function () { - assert.ok( - !deepEqual([ 1, 2, 3 ], { 0 : 1, 1 : 2, 2 : 3 }), - 'arrays are not objects' - ); -}; - -exports.falsy = function () { - assert.ok( - !deepEqual([ undefined ], [ null ]), - 'null is not undefined!' - ); - - assert.ok( - !deepEqual([ null ], [ undefined ]), - 'undefined is not null!' - ); - - assert.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'undefined is not null, however deeply!' - ); - - assert.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'null is not undefined, however deeply!' - ); - - assert.ok( - !deepEqual( - { a : 1, b : 2, c : [ 3, undefined, 5 ] }, - { a : 1, b : 2, c : [ 3, null, 5 ] } - ), - 'null is not undefined, however deeply!' - ); -}; - -exports.deletedArrayEqual = function () { - var xs = [ 1, 2, 3, 4 ]; - delete xs[2]; - - var ys = Object.create(Array.prototype); - ys[0] = 1; - ys[1] = 2; - ys[3] = 4; - - assert.ok( - deepEqual(xs, ys), - 'arrays with deleted elements are only equal to' - + ' arrays with similarly deleted elements' - ); - - assert.ok( - !deepEqual(xs, [ 1, 2, undefined, 4 ]), - 'deleted array elements cannot be undefined' - ); - - assert.ok( - !deepEqual(xs, [ 1, 2, null, 4 ]), - 'deleted array elements cannot be null' - ); -}; - -exports.deletedObjectEqual = function () { - var obj = { a : 1, b : 2, c : 3 }; - delete obj.c; - - assert.ok( - deepEqual(obj, { a : 1, b : 2 }), - 'deleted object elements should not show up' - ); - - assert.ok( - !deepEqual(obj, { a : 1, b : 2, c : undefined }), - 'deleted object elements are not undefined' - ); - - assert.ok( - !deepEqual(obj, { a : 1, b : 2, c : null }), - 'deleted object elements are not null' - ); -}; - -exports.emptyKeyEqual = function () { - assert.ok(!deepEqual( - { a : 1 }, { a : 1, '' : 55 } - )); -}; - -exports.deepArguments = function () { - assert.ok( - !deepEqual( - [ 4, 5, 6 ], - (function () { return arguments })(4, 5, 6) - ), - 'arguments are not arrays' - ); - - assert.ok( - deepEqual( - (function () { return arguments })(4, 5, 6), - (function () { return arguments })(4, 5, 6) - ), - 'arguments should equal' - ); -}; - -exports.deepUn = function () { - assert.ok(!deepEqual({ a : 1, b : 2 }, undefined)); - assert.ok(!deepEqual({ a : 1, b : 2 }, {})); - assert.ok(!deepEqual(undefined, { a : 1, b : 2 })); - assert.ok(!deepEqual({}, { a : 1, b : 2 })); - assert.ok(deepEqual(undefined, undefined)); - assert.ok(deepEqual(null, null)); - assert.ok(!deepEqual(undefined, null)); -}; - -exports.deepLevels = function () { - var xs = [ 1, 2, [ 3, 4, [ 5, 6 ] ] ]; - assert.ok(!deepEqual(xs, [])); -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/instance.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/instance.js deleted file mode 100644 index 8d7352567..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/instance.js +++ /dev/null @@ -1,17 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); -var EventEmitter = require('events').EventEmitter; - -exports['check instanceof on node elems'] = function () { - - var counts = { emitter : 0 }; - - Traverse([ new EventEmitter, 3, 4, { ev : new EventEmitter }]) - .forEach(function (node) { - if (node instanceof EventEmitter) counts.emitter ++; - }) - ; - - assert.equal(counts.emitter, 2); -}; - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/interface.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/interface.js deleted file mode 100644 index fce5bf9a9..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/interface.js +++ /dev/null @@ -1,42 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['interface map'] = function () { - var obj = { a : [ 5,6,7 ], b : { c : [8] } }; - - assert.deepEqual( - Traverse.paths(obj) - .sort() - .map(function (path) { return path.join('/') }) - .slice(1) - .join(' ') - , - 'a a/0 a/1 a/2 b b/c b/c/0' - ); - - assert.deepEqual( - Traverse.nodes(obj), - [ - { a: [ 5, 6, 7 ], b: { c: [ 8 ] } }, - [ 5, 6, 7 ], 5, 6, 7, - { c: [ 8 ] }, [ 8 ], 8 - ] - ); - - assert.deepEqual( - Traverse.map(obj, function (node) { - if (typeof node == 'number') { - return node + 1000; - } - else if (Array.isArray(node)) { - return node.join(' '); - } - }), - { a: '5 6 7', b: { c: '8' } } - ); - - var nodes = 0; - Traverse.forEach(obj, function (node) { nodes ++ }); - assert.deepEqual(nodes, 8); -}; - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/json.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/json.js deleted file mode 100644 index 0a045293f..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/json.js +++ /dev/null @@ -1,47 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['json test'] = function () { - var id = 54; - var callbacks = {}; - var obj = { moo : function () {}, foo : [2,3,4, function () {}] }; - - var scrubbed = Traverse(obj).map(function (x) { - if (typeof x === 'function') { - callbacks[id] = { id : id, f : x, path : this.path }; - this.update('[Function]'); - id++; - } - }); - - assert.equal( - scrubbed.moo, '[Function]', - 'obj.moo replaced with "[Function]"' - ); - - assert.equal( - scrubbed.foo[3], '[Function]', - 'obj.foo[3] replaced with "[Function]"' - ); - - assert.deepEqual(scrubbed, { - moo : '[Function]', - foo : [ 2, 3, 4, "[Function]" ] - }, 'Full JSON string matches'); - - assert.deepEqual( - typeof obj.moo, 'function', - 'Original obj.moo still a function' - ); - - assert.deepEqual( - typeof obj.foo[3], 'function', - 'Original obj.foo[3] still a function' - ); - - assert.deepEqual(callbacks, { - 54: { id: 54, f : obj.moo, path: [ 'moo' ] }, - 55: { id: 55, f : obj.foo[3], path: [ 'foo', '3' ] }, - }, 'Check the generated callbacks list'); -}; - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/keys.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/keys.js deleted file mode 100644 index 7ecd545ef..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/keys.js +++ /dev/null @@ -1,29 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['sort test'] = function () { - var acc = []; - Traverse({ - a: 30, - b: 22, - id: 9 - }).forEach(function (node) { - if ((! Array.isArray(node)) && typeof node === 'object') { - this.before(function(node) { - this.keys = Object.keys(node); - this.keys.sort(function(a, b) { - a = [a === "id" ? 0 : 1, a]; - b = [b === "id" ? 0 : 1, b]; - return a < b ? -1 : a > b ? 1 : 0; - }); - }); - } - if (this.isLeaf) acc.push(node); - }); - - assert.equal( - acc.join(' '), - '9 30 22', - 'Traversal in a custom order' - ); -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/leaves.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/leaves.js deleted file mode 100644 index e520b72e0..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/leaves.js +++ /dev/null @@ -1,21 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['leaves test'] = function () { - var acc = []; - Traverse({ - a : [1,2,3], - b : 4, - c : [5,6], - d : { e : [7,8], f : 9 } - }).forEach(function (x) { - if (this.isLeaf) acc.push(x); - }); - - assert.equal( - acc.join(' '), - '1 2 3 4 5 6 7 8 9', - 'Traversal in the right(?) order' - ); -}; - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js deleted file mode 100644 index 4fa07bb83..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/lib/deep_equal.js +++ /dev/null @@ -1,92 +0,0 @@ -var traverse = require('../../'); - -module.exports = function (a, b) { - if (arguments.length !== 2) { - throw new Error( - 'deepEqual requires exactly two objects to compare against' - ); - } - - var equal = true; - var node = b; - - traverse(a).forEach(function (y) { - var notEqual = (function () { - equal = false; - //this.stop(); - return undefined; - }).bind(this); - - //if (node === undefined || node === null) return notEqual(); - - if (!this.isRoot) { - /* - if (!Object.hasOwnProperty.call(node, this.key)) { - return notEqual(); - } - */ - if (typeof node !== 'object') return notEqual(); - node = node[this.key]; - } - - var x = node; - - this.post(function () { - node = x; - }); - - var toS = function (o) { - return Object.prototype.toString.call(o); - }; - - if (this.circular) { - if (traverse(b).get(this.circular.path) !== x) notEqual(); - } - else if (typeof x !== typeof y) { - notEqual(); - } - else if (x === null || y === null || x === undefined || y === undefined) { - if (x !== y) notEqual(); - } - else if (x.__proto__ !== y.__proto__) { - notEqual(); - } - else if (x === y) { - // nop - } - else if (typeof x === 'function') { - if (x instanceof RegExp) { - // both regexps on account of the __proto__ check - if (x.toString() != y.toString()) notEqual(); - } - else if (x !== y) notEqual(); - } - else if (typeof x === 'object') { - if (toS(y) === '[object Arguments]' - || toS(x) === '[object Arguments]') { - if (toS(x) !== toS(y)) { - notEqual(); - } - } - else if (x instanceof Date || y instanceof Date) { - if (!(x instanceof Date) || !(y instanceof Date) - || x.getTime() !== y.getTime()) { - notEqual(); - } - } - else { - var kx = Object.keys(x); - var ky = Object.keys(y); - if (kx.length !== ky.length) return notEqual(); - for (var i = 0; i < kx.length; i++) { - var k = kx[i]; - if (!Object.hasOwnProperty.call(y, k)) { - notEqual(); - } - } - } - } - }); - - return equal; -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/mutability.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/mutability.js deleted file mode 100644 index 2236f5631..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/mutability.js +++ /dev/null @@ -1,252 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -exports.mutate = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).forEach(function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, res); - assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.mutateT = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse.forEach(obj, function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, res); - assert.deepEqual(obj, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.map = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).map(function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.mapT = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse.map(obj, function (x) { - if (typeof x === 'number' && x % 2 === 0) { - this.update(x * 10); - } - }); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, { a : 1, b : 20, c : [ 3, 40 ] }); -}; - -exports.clone = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).clone(); - assert.deepEqual(obj, res); - assert.ok(obj !== res); - obj.a ++; - assert.deepEqual(res.a, 1); - obj.c.push(5); - assert.deepEqual(res.c, [ 3, 4 ]); -}; - -exports.cloneT = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse.clone(obj); - assert.deepEqual(obj, res); - assert.ok(obj !== res); - obj.a ++; - assert.deepEqual(res.a, 1); - obj.c.push(5); - assert.deepEqual(res.c, [ 3, 4 ]); -}; - -exports.reduce = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).reduce(function (acc, x) { - if (this.isLeaf) acc.push(x); - return acc; - }, []); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, [ 1, 2, 3, 4 ]); -}; - -exports.reduceInit = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).reduce(function (acc, x) { - if (this.isRoot) assert.fail('got root'); - return acc; - }); - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, obj); -}; - -exports.remove = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - Traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.remove(); - }); - - assert.deepEqual(obj, { a : 1, c : [ 3 ] }); -}; - -exports.removeNoStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.remove(); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e', 'f']) -} - -exports.removeStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.remove(true); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'f']) -} - -exports.removeMap = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.remove(); - }); - - assert.deepEqual(obj, { a : 1, b : 2, c : [ 3, 4 ] }); - assert.deepEqual(res, { a : 1, c : [ 3 ] }); -}; - -exports.delete = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - Traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, undefined ] } - )); - - assert.ok(deepEqual( - obj, { a : 1, c : [ 3 ] } - )); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, null ] } - )); -}; - -exports.deleteNoStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 } }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.delete(); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e']) -} - -exports.deleteStop = function() { - var obj = { a : 1, b : 2, c : { d: 3, e: 4 } }; - - var keys = []; - Traverse(obj).forEach(function (x) { - keys.push(this.key) - if (this.key == 'c') this.delete(true); - }); - - assert.deepEqual(keys, [undefined, 'a', 'b', 'c']) -} - -exports.deleteRedux = function () { - var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] }; - Traverse(obj).forEach(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, undefined, 5 ] } - )); - - assert.ok(deepEqual( - obj, { a : 1, c : [ 3 ,, 5 ] } - )); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, null, 5 ] } - )); - - assert.ok(!deepEqual( - obj, { a : 1, c : [ 3, 5 ] } - )); -}; - -exports.deleteMap = function () { - var obj = { a : 1, b : 2, c : [ 3, 4 ] }; - var res = Traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(deepEqual( - obj, - { a : 1, b : 2, c : [ 3, 4 ] } - )); - - var xs = [ 3, 4 ]; - delete xs[1]; - - assert.ok(deepEqual( - res, { a : 1, c : xs } - )); - - assert.ok(deepEqual( - res, { a : 1, c : [ 3, ] } - )); - - assert.ok(deepEqual( - res, { a : 1, c : [ 3 ] } - )); -}; - -exports.deleteMapRedux = function () { - var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] }; - var res = Traverse(obj).map(function (x) { - if (this.isLeaf && x % 2 == 0) this.delete(); - }); - - assert.ok(deepEqual( - obj, - { a : 1, b : 2, c : [ 3, 4, 5 ] } - )); - - var xs = [ 3, 4, 5 ]; - delete xs[1]; - - assert.ok(deepEqual( - res, { a : 1, c : xs } - )); - - assert.ok(!deepEqual( - res, { a : 1, c : [ 3, 5 ] } - )); - - assert.ok(deepEqual( - res, { a : 1, c : [ 3 ,, 5 ] } - )); -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/negative.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/negative.js deleted file mode 100644 index f92dfb07a..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/negative.js +++ /dev/null @@ -1,20 +0,0 @@ -var Traverse = require('../'); -var assert = require('assert'); - -exports['negative update test'] = function () { - var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - var fixed = Traverse.map(obj, function (x) { - if (x < 0) this.update(x + 128); - }); - - assert.deepEqual(fixed, - [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ], - 'Negative values += 128' - ); - - assert.deepEqual(obj, - [ 5, 6, -3, [ 7, 8, -2, 1 ], { f: 10, g: -13 } ], - 'Original references not modified' - ); -} - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/obj.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/obj.js deleted file mode 100644 index d46fd38ae..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/obj.js +++ /dev/null @@ -1,15 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports['traverse an object with nested functions'] = function () { - var to = setTimeout(function () { - assert.fail('never ran'); - }, 1000); - - function Cons (x) { - clearTimeout(to); - assert.equal(x, 10); - }; - Traverse(new Cons(10)); -}; - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/siblings.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/siblings.js deleted file mode 100644 index 99c0f1b24..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/siblings.js +++ /dev/null @@ -1,35 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); - -exports.siblings = function () { - var obj = { a : 1, b : 2, c : [ 4, 5, 6 ] }; - - var res = traverse(obj).reduce(function (acc, x) { - var p = '/' + this.path.join('/'); - if (this.parent) { - acc[p] = { - siblings : this.parent.keys, - key : this.key, - index : this.parent.keys.indexOf(this.key) - }; - } - else { - acc[p] = { - siblings : [], - key : this.key, - index : -1 - } - } - return acc; - }, {}); - - assert.deepEqual(res, { - '/' : { siblings : [], key : undefined, index : -1 }, - '/a' : { siblings : [ 'a', 'b', 'c' ], key : 'a', index : 0 }, - '/b' : { siblings : [ 'a', 'b', 'c' ], key : 'b', index : 1 }, - '/c' : { siblings : [ 'a', 'b', 'c' ], key : 'c', index : 2 }, - '/c/0' : { siblings : [ '0', '1', '2' ], key : '0', index : 0 }, - '/c/1' : { siblings : [ '0', '1', '2' ], key : '1', index : 1 }, - '/c/2' : { siblings : [ '0', '1', '2' ], key : '2', index : 2 } - }); -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stop.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stop.js deleted file mode 100644 index 3529847d8..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stop.js +++ /dev/null @@ -1,41 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); - -exports.stop = function () { - var visits = 0; - traverse('abcdefghij'.split('')).forEach(function (node) { - if (typeof node === 'string') { - visits ++; - if (node === 'e') this.stop() - } - }); - - assert.equal(visits, 5); -}; - -exports.stopMap = function () { - var s = traverse('abcdefghij'.split('')).map(function (node) { - if (typeof node === 'string') { - if (node === 'e') this.stop() - return node.toUpperCase(); - } - }).join(''); - - assert.equal(s, 'ABCDEfghij'); -}; - -exports.stopReduce = function () { - var obj = { - a : [ 4, 5 ], - b : [ 6, [ 7, 8, 9 ] ] - }; - var xs = traverse(obj).reduce(function (acc, node) { - if (this.isLeaf) { - if (node === 7) this.stop(); - else acc.push(node) - } - return acc; - }, []); - - assert.deepEqual(xs, [ 4, 5, 6 ]); -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stringify.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stringify.js deleted file mode 100644 index 932f5d3cf..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/stringify.js +++ /dev/null @@ -1,36 +0,0 @@ -var assert = require('assert'); -var Traverse = require('../'); - -exports.stringify = function () { - var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; - - var s = ''; - Traverse(obj).forEach(function (node) { - if (Array.isArray(node)) { - this.before(function () { s += '[' }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += ']' }); - } - else if (typeof node == 'object') { - this.before(function () { s += '{' }); - this.pre(function (x, key) { - s += '"' + key + '"' + ':'; - }); - this.post(function (child) { - if (!child.isLast) s += ','; - }); - this.after(function () { s += '}' }); - } - else if (typeof node == 'function') { - s += 'null'; - } - else { - s += node.toString(); - } - }); - - assert.equal(s, JSON.stringify(obj)); -} - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/subexpr.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/subexpr.js deleted file mode 100644 index a217beba9..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/subexpr.js +++ /dev/null @@ -1,34 +0,0 @@ -var traverse = require('../'); -var assert = require('assert'); - -exports.subexpr = function () { - var obj = [ 'a', 4, 'b', 5, 'c', 6 ]; - var r = traverse(obj).map(function (x) { - if (typeof x === 'number') { - this.update([ x - 0.1, x, x + 0.1 ], true); - } - }); - - assert.deepEqual(obj, [ 'a', 4, 'b', 5, 'c', 6 ]); - assert.deepEqual(r, [ - 'a', [ 3.9, 4, 4.1 ], - 'b', [ 4.9, 5, 5.1 ], - 'c', [ 5.9, 6, 6.1 ], - ]); -}; - -exports.block = function () { - var obj = [ [ 1 ], [ 2 ], [ 3 ] ]; - var r = traverse(obj).map(function (x) { - if (Array.isArray(x) && !this.isRoot) { - if (x[0] === 5) this.block() - else this.update([ [ x[0] + 1 ] ]) - } - }); - - assert.deepEqual(r, [ - [ [ [ [ [ 5 ] ] ] ] ], - [ [ [ [ 5 ] ] ] ], - [ [ [ 5 ] ] ], - ]); -}; diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/super_deep.js b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/super_deep.js deleted file mode 100644 index acac2fd9e..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/traverse/test/super_deep.js +++ /dev/null @@ -1,55 +0,0 @@ -var assert = require('assert'); -var traverse = require('../'); -var deepEqual = require('./lib/deep_equal'); - -exports.super_deep = function () { - var util = require('util'); - var a0 = make(); - var a1 = make(); - assert.ok(deepEqual(a0, a1)); - - a0.c.d.moo = true; - assert.ok(!deepEqual(a0, a1)); - - a1.c.d.moo = true; - assert.ok(deepEqual(a0, a1)); - - // TODO: this one - //a0.c.a = a1; - //assert.ok(!deepEqual(a0, a1)); -}; - -function make () { - var a = { self : 'a' }; - var b = { self : 'b' }; - var c = { self : 'c' }; - var d = { self : 'd' }; - var e = { self : 'e' }; - - a.a = a; - a.b = b; - a.c = c; - - b.a = a; - b.b = b; - b.c = c; - - c.a = a; - c.b = b; - c.c = c; - c.d = d; - - d.a = a; - d.b = b; - d.c = c; - d.d = d; - d.e = e; - - e.a = a; - e.b = b; - e.c = c; - e.d = d; - e.e = e; - - return a; -} diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/.npmignore b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/.npmignore deleted file mode 100644 index d97eaa09b..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -.tmp*~ -*.local.* -.pinf-* \ No newline at end of file diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.html b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.html deleted file mode 100644 index bd69e63e6..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.html +++ /dev/null @@ -1,888 +0,0 @@ - - - - -UglifyJS -- a JavaScript parser/compressor/beautifier - - - - - - - - - - - - -
- -

UglifyJS – a JavaScript parser/compressor/beautifier

- - - - -
-

1 UglifyJS — a JavaScript parser/compressor/beautifier

-
- - -

-This package implements a general-purpose JavaScript -parser/compressor/beautifier toolkit. It is developed on NodeJS, but it -should work on any JavaScript platform supporting the CommonJS module system -(and if your platform of choice doesn't support CommonJS, you can easily -implement it, or discard the exports.* lines from UglifyJS sources). -

-

-The tokenizer/parser generates an abstract syntax tree from JS code. You -can then traverse the AST to learn more about the code, or do various -manipulations on it. This part is implemented in parse-js.js and it's a -port to JavaScript of the excellent parse-js Common Lisp library from Marijn Haverbeke. -

-

-( See cl-uglify-js if you're looking for the Common Lisp version of -UglifyJS. ) -

-

-The second part of this package, implemented in process.js, inspects and -manipulates the AST generated by the parser to provide the following: -

-
    -
  • -ability to re-generate JavaScript code from the AST. Optionally -indented—you can use this if you want to “beautify” a program that has -been compressed, so that you can inspect the source. But you can also run -our code generator to print out an AST without any whitespace, so you -achieve compression as well. - -
  • -
  • -shorten variable names (usually to single characters). Our mangler will -analyze the code and generate proper variable names, depending on scope -and usage, and is smart enough to deal with globals defined elsewhere, or -with eval() calls or with{} statements. In short, if eval() or -with{} are used in some scope, then all variables in that scope and any -variables in the parent scopes will remain unmangled, and any references -to such variables remain unmangled as well. - -
  • -
  • -various small optimizations that may lead to faster code but certainly -lead to smaller code. Where possible, we do the following: - -
      -
    • -foo["bar"] ==> foo.bar - -
    • -
    • -remove block brackets {} - -
    • -
    • -join consecutive var declarations: -var a = 10; var b = 20; ==> var a=10,b=20; - -
    • -
    • -resolve simple constant expressions: 1 +2 * 3 ==> 7. We only do the -replacement if the result occupies less bytes; for example 1/3 would -translate to 0.333333333333, so in this case we don't replace it. - -
    • -
    • -consecutive statements in blocks are merged into a sequence; in many -cases, this leaves blocks with a single statement, so then we can remove -the block brackets. - -
    • -
    • -various optimizations for IF statements: - -
        -
      • -if (foo) bar(); else baz(); ==> foo?bar():baz(); -
      • -
      • -if (!foo) bar(); else baz(); ==> foo?baz():bar(); -
      • -
      • -if (foo) bar(); ==> foo&&bar(); -
      • -
      • -if (!foo) bar(); ==> foo||bar(); -
      • -
      • -if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); -
      • -
      • -if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} - -
      • -
      -
    • -
    • -remove some unreachable code and warn about it (code that follows a -return, throw, break or continue statement, except -function/variable declarations). -
    • -
    -
  • -
- - - -
- -
-

1.1 Unsafe transformations

-
- - -

-The following transformations can in theory break code, although they're -probably safe in most practical cases. To enable them you need to pass the ---unsafe flag. -

- -
- -
-

1.1.1 Calls involving the global Array constructor

-
- - -

-The following transformations occur: -

- - - -
new Array(1, 2, 3, 4)  => [1,2,3,4]
-Array(a, b, c)         => [a,b,c]
-new Array(5)           => Array(5)
-new Array(a)           => Array(a)
-
- - - -

-These are all safe if the Array name isn't redefined. JavaScript does allow -one to globally redefine Array (and pretty much everything, in fact) but I -personally don't see why would anyone do that. -

-

-UglifyJS does handle the case where Array is redefined locally, or even -globally but with a function or var declaration. Therefore, in the -following cases UglifyJS doesn't touch calls or instantiations of Array: -

- - - -
// case 1.  globally declared variable
-  var Array;
-  new Array(1, 2, 3);
-  Array(a, b);
-
-  // or (can be declared later)
-  new Array(1, 2, 3);
-  var Array;
-
-  // or (can be a function)
-  new Array(1, 2, 3);
-  function Array() { ... }
-
-// case 2.  declared in a function
-  (function(){
-    a = new Array(1, 2, 3);
-    b = Array(5, 6);
-    var Array;
-  })();
-
-  // or
-  (function(Array){
-    return Array(5, 6, 7);
-  })();
-
-  // or
-  (function(){
-    return new Array(1, 2, 3, 4);
-    function Array() { ... }
-  })();
-
-  // etc.
-
- - - -
- -
- -
-

1.1.2 obj.toString() ==> obj+“”

-
- - -
-
- -
- -
-

1.2 Install (NPM)

-
- - -

-UglifyJS is now available through NPM — npm install uglify-js should do -the job. -

-
- -
- -
-

1.3 Install latest code from GitHub

-
- - - - - -
## clone the repository
-mkdir -p /where/you/wanna/put/it
-cd /where/you/wanna/put/it
-git clone git://github.com/mishoo/UglifyJS.git
-
-## make the module available to Node
-mkdir -p ~/.node_libraries/
-cd ~/.node_libraries/
-ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js
-
-## and if you want the CLI script too:
-mkdir -p ~/bin
-cd ~/bin
-ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs
-  # (then add ~/bin to your $PATH if it's not there already)
-
- - - -
- -
- -
-

1.4 Usage

-
- - -

-There is a command-line tool that exposes the functionality of this library -for your shell-scripting needs: -

- - - -
uglifyjs [ options... ] [ filename ]
-
- - - -

-filename should be the last argument and should name the file from which -to read the JavaScript code. If you don't specify it, it will read code -from STDIN. -

-

-Supported options: -

-
    -
  • --b or --beautify — output indented code; when passed, additional -options control the beautifier: - -
      -
    • --i N or --indent N — indentation level (number of spaces) - -
    • -
    • --q or --quote-keys — quote keys in literal objects (by default, -only keys that cannot be identifier names will be quotes). - -
    • -
    -
  • -
  • ---ascii — pass this argument to encode non-ASCII characters as -\uXXXX sequences. By default UglifyJS won't bother to do it and will -output Unicode characters instead. (the output is always encoded in UTF8, -but if you pass this option you'll only get ASCII). - -
  • -
  • --nm or --no-mangle — don't mangle variable names - -
  • -
  • --ns or --no-squeeze — don't call ast_squeeze() (which does various -optimizations that result in smaller, less readable code). - -
  • -
  • --mt or --mangle-toplevel — mangle names in the toplevel scope too -(by default we don't do this). - -
  • -
  • ---no-seqs — when ast_squeeze() is called (thus, unless you pass ---no-squeeze) it will reduce consecutive statements in blocks into a -sequence. For example, "a = 10; b = 20; foo();" will be written as -"a=10,b=20,foo();". In various occasions, this allows us to discard the -block brackets (since the block becomes a single statement). This is ON -by default because it seems safe and saves a few hundred bytes on some -libs that I tested it on, but pass --no-seqs to disable it. - -
  • -
  • ---no-dead-code — by default, UglifyJS will remove code that is -obviously unreachable (code that follows a return, throw, break or -continue statement and is not a function/variable declaration). Pass -this option to disable this optimization. - -
  • -
  • --nc or --no-copyright — by default, uglifyjs will keep the initial -comment tokens in the generated code (assumed to be copyright information -etc.). If you pass this it will discard it. - -
  • -
  • --o filename or --output filename — put the result in filename. If -this isn't given, the result goes to standard output (or see next one). - -
  • -
  • ---overwrite — if the code is read from a file (not from STDIN) and you -pass --overwrite then the output will be written in the same file. - -
  • -
  • ---ast — pass this if you want to get the Abstract Syntax Tree instead -of JavaScript as output. Useful for debugging or learning more about the -internals. - -
  • -
  • --v or --verbose — output some notes on STDERR (for now just how long -each operation takes). - -
  • -
  • ---unsafe — enable other additional optimizations that are known to be -unsafe in some contrived situations, but could still be generally useful. -For now only this: - -
      -
    • -foo.toString() ==> foo+"" - -
    • -
    -
  • -
  • ---max-line-len (default 32K characters) — add a newline after around -32K characters. I've seen both FF and Chrome croak when all the code was -on a single line of around 670K. Pass –max-line-len 0 to disable this -safety feature. - -
  • -
  • ---reserved-names — some libraries rely on certain names to be used, as -pointed out in issue #92 and #81, so this option allow you to exclude such -names from the mangler. For example, to keep names require and $super -intact you'd specify –reserved-names "require,$super". - -
  • -
  • ---inline-script – when you want to include the output literally in an -HTML <script> tag you can use this option to prevent </script from -showing up in the output. - -
  • -
  • ---lift-vars – when you pass this, UglifyJS will apply the following -transformations (see the notes in API, ast_lift_variables): - -
      -
    • -put all var declarations at the start of the scope -
    • -
    • -make sure a variable is declared only once -
    • -
    • -discard unused function arguments -
    • -
    • -discard unused inner (named) functions -
    • -
    • -finally, try to merge assignments into that one var declaration, if -possible. -
    • -
    -
  • -
- - - -
- -
-

1.4.1 API

-
- - -

-To use the library from JavaScript, you'd do the following (example for -NodeJS): -

- - - -
var jsp = require("uglify-js").parser;
-var pro = require("uglify-js").uglify;
-
-var orig_code = "... JS code here";
-var ast = jsp.parse(orig_code); // parse code and get the initial AST
-ast = pro.ast_mangle(ast); // get a new AST with mangled names
-ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
-var final_code = pro.gen_code(ast); // compressed code here
-
- - - -

-The above performs the full compression that is possible right now. As you -can see, there are a sequence of steps which you can apply. For example if -you want compressed output but for some reason you don't want to mangle -variable names, you would simply skip the line that calls -pro.ast_mangle(ast). -

-

-Some of these functions take optional arguments. Here's a description: -

-
    -
  • -jsp.parse(code, strict_semicolons) – parses JS code and returns an AST. -strict_semicolons is optional and defaults to false. If you pass -true then the parser will throw an error when it expects a semicolon and -it doesn't find it. For most JS code you don't want that, but it's useful -if you want to strictly sanitize your code. - -
  • -
  • -pro.ast_lift_variables(ast) – merge and move var declarations to the -scop of the scope; discard unused function arguments or variables; discard -unused (named) inner functions. It also tries to merge assignments -following the var declaration into it. - -

    -If your code is very hand-optimized concerning var declarations, this -lifting variable declarations might actually increase size. For me it -helps out. On jQuery it adds 865 bytes (243 after gzip). YMMV. Also -note that (since it's not enabled by default) this operation isn't yet -heavily tested (please report if you find issues!). -

    -

    -Note that although it might increase the image size (on jQuery it gains -865 bytes, 243 after gzip) it's technically more correct: in certain -situations, dead code removal might drop variable declarations, which -would not happen if the variables are lifted in advance. -

    -

    -Here's an example of what it does: -

    -
  • -
- - - - -
function f(a, b, c, d, e) {
-    var q;
-    var w;
-    w = 10;
-    q = 20;
-    for (var i = 1; i < 10; ++i) {
-        var boo = foo(a);
-    }
-    for (var i = 0; i < 1; ++i) {
-        var boo = bar(c);
-    }
-    function foo(){ ... }
-    function bar(){ ... }
-    function baz(){ ... }
-}
-
-// transforms into ==>
-
-function f(a, b, c) {
-    var i, boo, w = 10, q = 20;
-    for (i = 1; i < 10; ++i) {
-        boo = foo(a);
-    }
-    for (i = 0; i < 1; ++i) {
-        boo = bar(c);
-    }
-    function foo() { ... }
-    function bar() { ... }
-}
-
- - - -
    -
  • -pro.ast_mangle(ast, options) – generates a new AST containing mangled -(compressed) variable and function names. It supports the following -options: - -
      -
    • -toplevel – mangle toplevel names (by default we don't touch them). -
    • -
    • -except – an array of names to exclude from compression. - -
    • -
    -
  • -
  • -pro.ast_squeeze(ast, options) – employs further optimizations designed -to reduce the size of the code that gen_code would generate from the -AST. Returns a new AST. options can be a hash; the supported options -are: - -
      -
    • -make_seqs (default true) which will cause consecutive statements in a -block to be merged using the "sequence" (comma) operator - -
    • -
    • -dead_code (default true) which will remove unreachable code. - -
    • -
    -
  • -
  • -pro.gen_code(ast, options) – generates JS code from the AST. By -default it's minified, but using the options argument you can get nicely -formatted output. options is, well, optional :-) and if you pass it it -must be an object and supports the following properties (below you can see -the default values): - -
      -
    • -beautify: false – pass true if you want indented output -
    • -
    • -indent_start: 0 (only applies when beautify is true) – initial -indentation in spaces -
    • -
    • -indent_level: 4 (only applies when beautify is true) -- -indentation level, in spaces (pass an even number) -
    • -
    • -quote_keys: false – if you pass true it will quote all keys in -literal objects -
    • -
    • -space_colon: false (only applies when beautify is true) – wether -to put a space before the colon in object literals -
    • -
    • -ascii_only: false – pass true if you want to encode non-ASCII -characters as \uXXXX. -
    • -
    • -inline_script: false – pass true to escape occurrences of -</script in strings -
    • -
    -
  • -
- - -
- -
- -
-

1.4.2 Beautifier shortcoming – no more comments

-
- - -

-The beautifier can be used as a general purpose indentation tool. It's -useful when you want to make a minified file readable. One limitation, -though, is that it discards all comments, so you don't really want to use it -to reformat your code, unless you don't have, or don't care about, comments. -

-

-In fact it's not the beautifier who discards comments — they are dumped at -the parsing stage, when we build the initial AST. Comments don't really -make sense in the AST, and while we could add nodes for them, it would be -inconvenient because we'd have to add special rules to ignore them at all -the processing stages. -

-
-
- -
- -
-

1.5 Compression – how good is it?

-
- - -

-Here are updated statistics. (I also updated my Google Closure and YUI -installations). -

-

-We're still a lot better than YUI in terms of compression, though slightly -slower. We're still a lot faster than Closure, and compression after gzip -is comparable. -

- - -- - - - - - - - - - -
FileUglifyJSUglifyJS+gzipClosureClosure+gzipYUIYUI+gzip
jquery-1.6.2.js91001 (0:01.59)3189690678 (0:07.40)31979101527 (0:01.82)34646
paper.js142023 (0:01.65)43334134301 (0:07.42)42495173383 (0:01.58)48785
prototype.js88544 (0:01.09)2668086955 (0:06.97)2632692130 (0:00.79)28624
thelib-full.js (DynarchLIB)251939 (0:02.55)72535249911 (0:09.05)72696258869 (0:01.94)76584
- - -
- -
- -
-

1.6 Bugs?

-
- - -

-Unfortunately, for the time being there is no automated test suite. But I -ran the compressor manually on non-trivial code, and then I tested that the -generated code works as expected. A few hundred times. -

-

-DynarchLIB was started in times when there was no good JS minifier. -Therefore I was quite religious about trying to write short code manually, -and as such DL contains a lot of syntactic hacks1 such as “foo == bar ? a -= 10 : b = 20”, though the more readable version would clearly be to use -“if/else”. -

-

-Since the parser/compressor runs fine on DL and jQuery, I'm quite confident -that it's solid enough for production use. If you can identify any bugs, -I'd love to hear about them (use the Google Group or email me directly). -

-
- -
- -
-

1.7 Links

-
- - - - - -
- -
- -
-

1.8 License

-
- - -

-UglifyJS is released under the BSD license: -

- - - -
Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com>
-Based on parse-js (http://marijn.haverbeke.nl/parse-js/).
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-    * Redistributions of source code must retain the above
-      copyright notice, this list of conditions and the following
-      disclaimer.
-
-    * Redistributions in binary form must reproduce the above
-      copyright notice, this list of conditions and the following
-      disclaimer in the documentation and/or other materials
-      provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
-THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
- - - - -
-
-
-
-

Footnotes:

-
-

1 I even reported a few bugs and suggested some fixes in the original -parse-js library, and Marijn pushed fixes literally in minutes. -

-
-
-
-

Author: Mihai Bazon -

-

Date: 2011-08-20 10:08:28 EEST

-

HTML generated by org-mode 7.01trans in emacs 23

-
-
- - diff --git a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.org b/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.org deleted file mode 100644 index 93b119514..000000000 --- a/node_modules/tap/node_modules/runforcover/node_modules/bunker/node_modules/burrito/node_modules/uglify-js/README.org +++ /dev/null @@ -1,463 +0,0 @@ -#+TITLE: UglifyJS -- a JavaScript parser/compressor/beautifier -#+KEYWORDS: javascript, js, parser, compiler, compressor, mangle, minify, minifier -#+DESCRIPTION: a JavaScript parser/compressor/beautifier in JavaScript -#+STYLE: -#+AUTHOR: Mihai Bazon -#+EMAIL: mihai.bazon@gmail.com - -* UglifyJS --- a JavaScript parser/compressor/beautifier - -This package implements a general-purpose JavaScript -parser/compressor/beautifier toolkit. It is developed on [[http://nodejs.org/][NodeJS]], but it -should work on any JavaScript platform supporting the CommonJS module system -(and if your platform of choice doesn't support CommonJS, you can easily -implement it, or discard the =exports.*= lines from UglifyJS sources). - -The tokenizer/parser generates an abstract syntax tree from JS code. You -can then traverse the AST to learn more about the code, or do various -manipulations on it. This part is implemented in [[../lib/parse-js.js][parse-js.js]] and it's a -port to JavaScript of the excellent [[http://marijn.haverbeke.nl/parse-js/][parse-js]] Common Lisp library from [[http://marijn.haverbeke.nl/][Marijn -Haverbeke]]. - -( See [[https://github.com/mishoo/cl-uglify-js][cl-uglify-js]] if you're looking for the Common Lisp version of -UglifyJS. ) - -The second part of this package, implemented in [[../lib/process.js][process.js]], inspects and -manipulates the AST generated by the parser to provide the following: - -- ability to re-generate JavaScript code from the AST. Optionally - indented---you can use this if you want to “beautify” a program that has - been compressed, so that you can inspect the source. But you can also run - our code generator to print out an AST without any whitespace, so you - achieve compression as well. - -- shorten variable names (usually to single characters). Our mangler will - analyze the code and generate proper variable names, depending on scope - and usage, and is smart enough to deal with globals defined elsewhere, or - with =eval()= calls or =with{}= statements. In short, if =eval()= or - =with{}= are used in some scope, then all variables in that scope and any - variables in the parent scopes will remain unmangled, and any references - to such variables remain unmangled as well. - -- various small optimizations that may lead to faster code but certainly - lead to smaller code. Where possible, we do the following: - - - foo["bar"] ==> foo.bar - - - remove block brackets ={}= - - - join consecutive var declarations: - var a = 10; var b = 20; ==> var a=10,b=20; - - - resolve simple constant expressions: 1 +2 * 3 ==> 7. We only do the - replacement if the result occupies less bytes; for example 1/3 would - translate to 0.333333333333, so in this case we don't replace it. - - - consecutive statements in blocks are merged into a sequence; in many - cases, this leaves blocks with a single statement, so then we can remove - the block brackets. - - - various optimizations for IF statements: - - - if (foo) bar(); else baz(); ==> foo?bar():baz(); - - if (!foo) bar(); else baz(); ==> foo?baz():bar(); - - if (foo) bar(); ==> foo&&bar(); - - if (!foo) bar(); ==> foo||bar(); - - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); - - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} - - - remove some unreachable code and warn about it (code that follows a - =return=, =throw=, =break= or =continue= statement, except - function/variable declarations). - -** <> - -The following transformations can in theory break code, although they're -probably safe in most practical cases. To enable them you need to pass the -=--unsafe= flag. - -*** Calls involving the global Array constructor - -The following transformations occur: - -#+BEGIN_SRC js -new Array(1, 2, 3, 4) => [1,2,3,4] -Array(a, b, c) => [a,b,c] -new Array(5) => Array(5) -new Array(a) => Array(a) -#+END_SRC - -These are all safe if the Array name isn't redefined. JavaScript does allow -one to globally redefine Array (and pretty much everything, in fact) but I -personally don't see why would anyone do that. - -UglifyJS does handle the case where Array is redefined locally, or even -globally but with a =function= or =var= declaration. Therefore, in the -following cases UglifyJS *doesn't touch* calls or instantiations of Array: - -#+BEGIN_SRC js -// case 1. globally declared variable - var Array; - new Array(1, 2, 3); - Array(a, b); - - // or (can be declared later) - new Array(1, 2, 3); - var Array; - - // or (can be a function) - new Array(1, 2, 3); - function Array() { ... } - -// case 2. declared in a function - (function(){ - a = new Array(1, 2, 3); - b = Array(5, 6); - var Array; - })(); - - // or - (function(Array){ - return Array(5, 6, 7); - })(); - - // or - (function(){ - return new Array(1, 2, 3, 4); - function Array() { ... } - })(); - - // etc. -#+END_SRC - -*** =obj.toString()= ==> =obj+“”= - -** Install (NPM) - -UglifyJS is now available through NPM --- =npm install uglify-js= should do -the job. - -** Install latest code from GitHub - -#+BEGIN_SRC sh -## clone the repository -mkdir -p /where/you/wanna/put/it -cd /where/you/wanna/put/it -git clone git://github.com/mishoo/UglifyJS.git - -## make the module available to Node -mkdir -p ~/.node_libraries/ -cd ~/.node_libraries/ -ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js - -## and if you want the CLI script too: -mkdir -p ~/bin -cd ~/bin -ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs - # (then add ~/bin to your $PATH if it's not there already) -#+END_SRC - -** Usage - -There is a command-line tool that exposes the functionality of this library -for your shell-scripting needs: - -#+BEGIN_SRC sh -uglifyjs [ options... ] [ filename ] -#+END_SRC - -=filename= should be the last argument and should name the file from which -to read the JavaScript code. If you don't specify it, it will read code -from STDIN. - -Supported options: - -- =-b= or =--beautify= --- output indented code; when passed, additional - options control the beautifier: - - - =-i N= or =--indent N= --- indentation level (number of spaces) - - - =-q= or =--quote-keys= --- quote keys in literal objects (by default, - only keys that cannot be identifier names will be quotes). - -- =--ascii= --- pass this argument to encode non-ASCII characters as - =\uXXXX= sequences. By default UglifyJS won't bother to do it and will - output Unicode characters instead. (the output is always encoded in UTF8, - but if you pass this option you'll only get ASCII). - -- =-nm= or =--no-mangle= --- don't mangle variable names - -- =-ns= or =--no-squeeze= --- don't call =ast_squeeze()= (which does various - optimizations that result in smaller, less readable code). - -- =-mt= or =--mangle-toplevel= --- mangle names in the toplevel scope too - (by default we don't do this). - -- =--no-seqs= --- when =ast_squeeze()= is called (thus, unless you pass - =--no-squeeze=) it will reduce consecutive statements in blocks into a - sequence. For example, "a = 10; b = 20; foo();" will be written as - "a=10,b=20,foo();". In various occasions, this allows us to discard the - block brackets (since the block becomes a single statement). This is ON - by default because it seems safe and saves a few hundred bytes on some - libs that I tested it on, but pass =--no-seqs= to disable it. - -- =--no-dead-code= --- by default, UglifyJS will remove code that is - obviously unreachable (code that follows a =return=, =throw=, =break= or - =continue= statement and is not a function/variable declaration). Pass - this option to disable this optimization. - -- =-nc= or =--no-copyright= --- by default, =uglifyjs= will keep the initial - comment tokens in the generated code (assumed to be copyright information - etc.). If you pass this it will discard it. - -- =-o filename= or =--output filename= --- put the result in =filename=. If - this isn't given, the result goes to standard output (or see next one). - -- =--overwrite= --- if the code is read from a file (not from STDIN) and you - pass =--overwrite= then the output will be written in the same file. - -- =--ast= --- pass this if you want to get the Abstract Syntax Tree instead - of JavaScript as output. Useful for debugging or learning more about the - internals. - -- =-v= or =--verbose= --- output some notes on STDERR (for now just how long - each operation takes). - -- =--unsafe= --- enable other additional optimizations that are known to be - unsafe in some contrived situations, but could still be generally useful. - For now only this: - - - foo.toString() ==> foo+"" - -- =--max-line-len= (default 32K characters) --- add a newline after around - 32K characters. I've seen both FF and Chrome croak when all the code was - on a single line of around 670K. Pass --max-line-len 0 to disable this - safety feature. - -- =--reserved-names= --- some libraries rely on certain names to be used, as - pointed out in issue #92 and #81, so this option allow you to exclude such - names from the mangler. For example, to keep names =require= and =$super= - intact you'd specify --reserved-names "require,$super". - -- =--inline-script= -- when you want to include the output literally in an - HTML = - - - -
- -

UglifyJS – a JavaScript parser/compressor/beautifier

- - - - -
-

1 UglifyJS — a JavaScript parser/compressor/beautifier

-
- - -

-This package implements a general-purpose JavaScript -parser/compressor/beautifier toolkit. It is developed on NodeJS, but it -should work on any JavaScript platform supporting the CommonJS module system -(and if your platform of choice doesn't support CommonJS, you can easily -implement it, or discard the exports.* lines from UglifyJS sources). -

-

-The tokenizer/parser generates an abstract syntax tree from JS code. You -can then traverse the AST to learn more about the code, or do various -manipulations on it. This part is implemented in parse-js.js and it's a -port to JavaScript of the excellent parse-js Common Lisp library from Marijn Haverbeke. -

-

-( See cl-uglify-js if you're looking for the Common Lisp version of -UglifyJS. ) -

-

-The second part of this package, implemented in process.js, inspects and -manipulates the AST generated by the parser to provide the following: -

-
    -
  • -ability to re-generate JavaScript code from the AST. Optionally -indented—you can use this if you want to “beautify” a program that has -been compressed, so that you can inspect the source. But you can also run -our code generator to print out an AST without any whitespace, so you -achieve compression as well. - -
  • -
  • -shorten variable names (usually to single characters). Our mangler will -analyze the code and generate proper variable names, depending on scope -and usage, and is smart enough to deal with globals defined elsewhere, or -with eval() calls or with{} statements. In short, if eval() or -with{} are used in some scope, then all variables in that scope and any -variables in the parent scopes will remain unmangled, and any references -to such variables remain unmangled as well. - -
  • -
  • -various small optimizations that may lead to faster code but certainly -lead to smaller code. Where possible, we do the following: - -
      -
    • -foo["bar"] ==> foo.bar - -
    • -
    • -remove block brackets {} - -
    • -
    • -join consecutive var declarations: -var a = 10; var b = 20; ==> var a=10,b=20; - -
    • -
    • -resolve simple constant expressions: 1 +2 * 3 ==> 7. We only do the -replacement if the result occupies less bytes; for example 1/3 would -translate to 0.333333333333, so in this case we don't replace it. - -
    • -
    • -consecutive statements in blocks are merged into a sequence; in many -cases, this leaves blocks with a single statement, so then we can remove -the block brackets. - -
    • -
    • -various optimizations for IF statements: - -
        -
      • -if (foo) bar(); else baz(); ==> foo?bar():baz(); -
      • -
      • -if (!foo) bar(); else baz(); ==> foo?baz():bar(); -
      • -
      • -if (foo) bar(); ==> foo&&bar(); -
      • -
      • -if (!foo) bar(); ==> foo||bar(); -
      • -
      • -if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); -
      • -
      • -if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} - -
      • -
      -
    • -
    • -remove some unreachable code and warn about it (code that follows a -return, throw, break or continue statement, except -function/variable declarations). - -
    • -
    • -act a limited version of a pre-processor (c.f. the pre-processor of -C/C++) to allow you to safely replace selected global symbols with -specified values. When combined with the optimisations above this can -make UglifyJS operate slightly more like a compilation process, in -that when certain symbols are replaced by constant values, entire code -blocks may be optimised away as unreachable. -
    • -
    -
  • -
- - - -
- -
-

1.1 Unsafe transformations

-
- - -

-The following transformations can in theory break code, although they're -probably safe in most practical cases. To enable them you need to pass the ---unsafe flag. -

- -
- -
-

1.1.1 Calls involving the global Array constructor

-
- - -

-The following transformations occur: -

- - - -
new Array(1, 2, 3, 4)  => [1,2,3,4]
-Array(a, b, c)         => [a,b,c]
-new Array(5)           => Array(5)
-new Array(a)           => Array(a)
-
- - - -

-These are all safe if the Array name isn't redefined. JavaScript does allow -one to globally redefine Array (and pretty much everything, in fact) but I -personally don't see why would anyone do that. -

-

-UglifyJS does handle the case where Array is redefined locally, or even -globally but with a function or var declaration. Therefore, in the -following cases UglifyJS doesn't touch calls or instantiations of Array: -

- - - -
// case 1.  globally declared variable
-  var Array;
-  new Array(1, 2, 3);
-  Array(a, b);
-
-  // or (can be declared later)
-  new Array(1, 2, 3);
-  var Array;
-
-  // or (can be a function)
-  new Array(1, 2, 3);
-  function Array() { ... }
-
-// case 2.  declared in a function
-  (function(){
-    a = new Array(1, 2, 3);
-    b = Array(5, 6);
-    var Array;
-  })();
-
-  // or
-  (function(Array){
-    return Array(5, 6, 7);
-  })();
-
-  // or
-  (function(){
-    return new Array(1, 2, 3, 4);
-    function Array() { ... }
-  })();
-
-  // etc.
-
- - - -
- -
- -
-

1.1.2 obj.toString() ==> obj+“”

-
- - -
-
- -
- -
-

1.2 Install (NPM)

-
- - -

-UglifyJS is now available through NPM — npm install uglify-js should do -the job. -

-
- -
- -
-

1.3 Install latest code from GitHub

-
- - - - - -
## clone the repository
-mkdir -p /where/you/wanna/put/it
-cd /where/you/wanna/put/it
-git clone git://github.com/mishoo/UglifyJS.git
-
-## make the module available to Node
-mkdir -p ~/.node_libraries/
-cd ~/.node_libraries/
-ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js
-
-## and if you want the CLI script too:
-mkdir -p ~/bin
-cd ~/bin
-ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs
-  # (then add ~/bin to your $PATH if it's not there already)
-
- - - -
- -
- -
-

1.4 Usage

-
- - -

-There is a command-line tool that exposes the functionality of this library -for your shell-scripting needs: -

- - - -
uglifyjs [ options... ] [ filename ]
-
- - - -

-filename should be the last argument and should name the file from which -to read the JavaScript code. If you don't specify it, it will read code -from STDIN. -

-

-Supported options: -

-
    -
  • --b or --beautify — output indented code; when passed, additional -options control the beautifier: - -
      -
    • --i N or --indent N — indentation level (number of spaces) - -
    • -
    • --q or --quote-keys — quote keys in literal objects (by default, -only keys that cannot be identifier names will be quotes). - -
    • -
    -
  • -
  • ---ascii — pass this argument to encode non-ASCII characters as -\uXXXX sequences. By default UglifyJS won't bother to do it and will -output Unicode characters instead. (the output is always encoded in UTF8, -but if you pass this option you'll only get ASCII). - -
  • -
  • --nm or --no-mangle — don't mangle variable names - -
  • -
  • --ns or --no-squeeze — don't call ast_squeeze() (which does various -optimizations that result in smaller, less readable code). - -
  • -
  • --mt or --mangle-toplevel — mangle names in the toplevel scope too -(by default we don't do this). - -
  • -
  • ---no-seqs — when ast_squeeze() is called (thus, unless you pass ---no-squeeze) it will reduce consecutive statements in blocks into a -sequence. For example, "a = 10; b = 20; foo();" will be written as -"a=10,b=20,foo();". In various occasions, this allows us to discard the -block brackets (since the block becomes a single statement). This is ON -by default because it seems safe and saves a few hundred bytes on some -libs that I tested it on, but pass --no-seqs to disable it. - -
  • -
  • ---no-dead-code — by default, UglifyJS will remove code that is -obviously unreachable (code that follows a return, throw, break or -continue statement and is not a function/variable declaration). Pass -this option to disable this optimization. - -
  • -
  • --nc or --no-copyright — by default, uglifyjs will keep the initial -comment tokens in the generated code (assumed to be copyright information -etc.). If you pass this it will discard it. - -
  • -
  • --o filename or --output filename — put the result in filename. If -this isn't given, the result goes to standard output (or see next one). - -
  • -
  • ---overwrite — if the code is read from a file (not from STDIN) and you -pass --overwrite then the output will be written in the same file. - -
  • -
  • ---ast — pass this if you want to get the Abstract Syntax Tree instead -of JavaScript as output. Useful for debugging or learning more about the -internals. - -
  • -
  • --v or --verbose — output some notes on STDERR (for now just how long -each operation takes). - -
  • -
  • --d SYMBOL[=VALUE] or --define SYMBOL[=VALUE] — will replace -all instances of the specified symbol where used as an identifier -(except where symbol has properly declared by a var declaration or -use as function parameter or similar) with the specified value. This -argument may be specified multiple times to define multiple -symbols - if no value is specified the symbol will be replaced with -the value true, or you can specify a numeric value (such as -1024), a quoted string value (such as ="object"= or -='https://github.com'), or the name of another symbol or keyword (such as =null or document). -This allows you, for example, to assign meaningful names to key -constant values but discard the symbolic names in the uglified -version for brevity/efficiency, or when used wth care, allows -UglifyJS to operate as a form of conditional compilation -whereby defining appropriate values may, by dint of the constant -folding and dead code removal features above, remove entire -superfluous code blocks (e.g. completely remove instrumentation or -trace code for production use). -Where string values are being defined, the handling of quotes are -likely to be subject to the specifics of your command shell -environment, so you may need to experiment with quoting styles -depending on your platform, or you may find the option ---define-from-module more suitable for use. - -
  • -
  • --define-from-module SOMEMODULE — will load the named module (as -per the NodeJS require() function) and iterate all the exported -properties of the module defining them as symbol names to be defined -(as if by the --define option) per the name of each property -(i.e. without the module name prefix) and given the value of the -property. This is a much easier way to handle and document groups of -symbols to be defined rather than a large number of --define -options. - -
  • -
  • ---unsafe — enable other additional optimizations that are known to be -unsafe in some contrived situations, but could still be generally useful. -For now only these: - -
      -
    • -foo.toString() ==> foo+"" -
    • -
    • -new Array(x,…) ==> [x,…] -
    • -
    • -new Array(x) ==> Array(x) - -
    • -
    -
  • -
  • ---max-line-len (default 32K characters) — add a newline after around -32K characters. I've seen both FF and Chrome croak when all the code was -on a single line of around 670K. Pass –max-line-len 0 to disable this -safety feature. - -
  • -
  • ---reserved-names — some libraries rely on certain names to be used, as -pointed out in issue #92 and #81, so this option allow you to exclude such -names from the mangler. For example, to keep names require and $super -intact you'd specify –reserved-names "require,$super". - -
  • -
  • ---inline-script – when you want to include the output literally in an -HTML <script> tag you can use this option to prevent </script from -showing up in the output. - -
  • -
  • ---lift-vars – when you pass this, UglifyJS will apply the following -transformations (see the notes in API, ast_lift_variables): - -
      -
    • -put all var declarations at the start of the scope -
    • -
    • -make sure a variable is declared only once -
    • -
    • -discard unused function arguments -
    • -
    • -discard unused inner (named) functions -
    • -
    • -finally, try to merge assignments into that one var declaration, if -possible. -
    • -
    -
  • -
- - - -
- -
-

1.4.1 API

-
- - -

-To use the library from JavaScript, you'd do the following (example for -NodeJS): -

- - - -
var jsp = require("uglify-js").parser;
-var pro = require("uglify-js").uglify;
-
-var orig_code = "... JS code here";
-var ast = jsp.parse(orig_code); // parse code and get the initial AST
-ast = pro.ast_mangle(ast); // get a new AST with mangled names
-ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
-var final_code = pro.gen_code(ast); // compressed code here
-
- - - -

-The above performs the full compression that is possible right now. As you -can see, there are a sequence of steps which you can apply. For example if -you want compressed output but for some reason you don't want to mangle -variable names, you would simply skip the line that calls -pro.ast_mangle(ast). -

-

-Some of these functions take optional arguments. Here's a description: -

-
    -
  • -jsp.parse(code, strict_semicolons) – parses JS code and returns an AST. -strict_semicolons is optional and defaults to false. If you pass -true then the parser will throw an error when it expects a semicolon and -it doesn't find it. For most JS code you don't want that, but it's useful -if you want to strictly sanitize your code. - -
  • -
  • -pro.ast_lift_variables(ast) – merge and move var declarations to the -scop of the scope; discard unused function arguments or variables; discard -unused (named) inner functions. It also tries to merge assignments -following the var declaration into it. - -

    -If your code is very hand-optimized concerning var declarations, this -lifting variable declarations might actually increase size. For me it -helps out. On jQuery it adds 865 bytes (243 after gzip). YMMV. Also -note that (since it's not enabled by default) this operation isn't yet -heavily tested (please report if you find issues!). -

    -

    -Note that although it might increase the image size (on jQuery it gains -865 bytes, 243 after gzip) it's technically more correct: in certain -situations, dead code removal might drop variable declarations, which -would not happen if the variables are lifted in advance. -

    -

    -Here's an example of what it does: -

    -
  • -
- - - - -
function f(a, b, c, d, e) {
-    var q;
-    var w;
-    w = 10;
-    q = 20;
-    for (var i = 1; i < 10; ++i) {
-        var boo = foo(a);
-    }
-    for (var i = 0; i < 1; ++i) {
-        var boo = bar(c);
-    }
-    function foo(){ ... }
-    function bar(){ ... }
-    function baz(){ ... }
-}
-
-// transforms into ==>
-
-function f(a, b, c) {
-    var i, boo, w = 10, q = 20;
-    for (i = 1; i < 10; ++i) {
-        boo = foo(a);
-    }
-    for (i = 0; i < 1; ++i) {
-        boo = bar(c);
-    }
-    function foo() { ... }
-    function bar() { ... }
-}
-
- - - -
    -
  • -pro.ast_mangle(ast, options) – generates a new AST containing mangled -(compressed) variable and function names. It supports the following -options: - -
      -
    • -toplevel – mangle toplevel names (by default we don't touch them). -
    • -
    • -except – an array of names to exclude from compression. -
    • -
    • -defines – an object with properties named after symbols to -replace (see the --define option for the script) and the values -representing the AST replacement value. - -
    • -
    -
  • -
  • -pro.ast_squeeze(ast, options) – employs further optimizations designed -to reduce the size of the code that gen_code would generate from the -AST. Returns a new AST. options can be a hash; the supported options -are: - -
      -
    • -make_seqs (default true) which will cause consecutive statements in a -block to be merged using the "sequence" (comma) operator - -
    • -
    • -dead_code (default true) which will remove unreachable code. - -
    • -
    -
  • -
  • -pro.gen_code(ast, options) – generates JS code from the AST. By -default it's minified, but using the options argument you can get nicely -formatted output. options is, well, optional :-) and if you pass it it -must be an object and supports the following properties (below you can see -the default values): - -
      -
    • -beautify: false – pass true if you want indented output -
    • -
    • -indent_start: 0 (only applies when beautify is true) – initial -indentation in spaces -
    • -
    • -indent_level: 4 (only applies when beautify is true) -- -indentation level, in spaces (pass an even number) -
    • -
    • -quote_keys: false – if you pass true it will quote all keys in -literal objects -
    • -
    • -space_colon: false (only applies when beautify is true) – wether -to put a space before the colon in object literals -
    • -
    • -ascii_only: false – pass true if you want to encode non-ASCII -characters as \uXXXX. -
    • -
    • -inline_script: false – pass true to escape occurrences of -</script in strings -
    • -
    -
  • -
- - -
- -
- -
-

1.4.2 Beautifier shortcoming – no more comments

-
- - -

-The beautifier can be used as a general purpose indentation tool. It's -useful when you want to make a minified file readable. One limitation, -though, is that it discards all comments, so you don't really want to use it -to reformat your code, unless you don't have, or don't care about, comments. -

-

-In fact it's not the beautifier who discards comments — they are dumped at -the parsing stage, when we build the initial AST. Comments don't really -make sense in the AST, and while we could add nodes for them, it would be -inconvenient because we'd have to add special rules to ignore them at all -the processing stages. -

-
- -
- -
-

1.4.3 Use as a code pre-processor

-
- - -

-The --define option can be used, particularly when combined with the -constant folding logic, as a form of pre-processor to enable or remove -particular constructions, such as might be used for instrumenting -development code, or to produce variations aimed at a specific -platform. -

-

-The code below illustrates the way this can be done, and how the -symbol replacement is performed. -

- - - -
CLAUSE1: if (typeof DEVMODE === 'undefined') {
-    DEVMODE = true;
-}
-
-CLAUSE2: function init() {
-    if (DEVMODE) {
-        console.log("init() called");
-    }
-    ....
-    DEVMODE &amp;&amp; console.log("init() complete");
-}
-
-CLAUSE3: function reportDeviceStatus(device) {
-    var DEVMODE = device.mode, DEVNAME = device.name;
-    if (DEVMODE === 'open') {
-        ....
-    }
-}
-
- - - -

-When the above code is normally executed, the undeclared global -variable DEVMODE will be assigned the value true (see CLAUSE1) -and so the init() function (CLAUSE2) will write messages to the -console log when executed, but in CLAUSE3 a locally declared -variable will mask access to the DEVMODE global symbol. -

-

-If the above code is processed by UglifyJS with an argument of ---define DEVMODE=false then UglifyJS will replace DEVMODE with the -boolean constant value false within CLAUSE1 and CLAUSE2, but it -will leave CLAUSE3 as it stands because there DEVMODE resolves to -a validly declared variable. -

-

-And more so, the constant-folding features of UglifyJS will recognise -that the if condition of CLAUSE1 is thus always false, and so will -remove the test and body of CLAUSE1 altogether (including the -otherwise slightly problematical statement false = true; which it -will have formed by replacing DEVMODE in the body). Similarly, -within CLAUSE2 both calls to console.log() will be removed -altogether. -

-

-In this way you can mimic, to a limited degree, the functionality of -the C/C++ pre-processor to enable or completely remove blocks -depending on how certain symbols are defined - perhaps using UglifyJS -to generate different versions of source aimed at different -environments -

-

-It is recommmended (but not made mandatory) that symbols designed for -this purpose are given names consisting of UPPER_CASE_LETTERS to -distinguish them from other (normal) symbols and avoid the sort of -clash that CLAUSE3 above illustrates. -

-
-
- -
- -
-

1.5 Compression – how good is it?

-
- - -

-Here are updated statistics. (I also updated my Google Closure and YUI -installations). -

-

-We're still a lot better than YUI in terms of compression, though slightly -slower. We're still a lot faster than Closure, and compression after gzip -is comparable. -

- - -- - - - - - - - - - -
FileUglifyJSUglifyJS+gzipClosureClosure+gzipYUIYUI+gzip
jquery-1.6.2.js91001 (0:01.59)3189690678 (0:07.40)31979101527 (0:01.82)34646
paper.js142023 (0:01.65)43334134301 (0:07.42)42495173383 (0:01.58)48785
prototype.js88544 (0:01.09)2668086955 (0:06.97)2632692130 (0:00.79)28624
thelib-full.js (DynarchLIB)251939 (0:02.55)72535249911 (0:09.05)72696258869 (0:01.94)76584
- - -
- -
- -
-

1.6 Bugs?

-
- - -

-Unfortunately, for the time being there is no automated test suite. But I -ran the compressor manually on non-trivial code, and then I tested that the -generated code works as expected. A few hundred times. -

-

-DynarchLIB was started in times when there was no good JS minifier. -Therefore I was quite religious about trying to write short code manually, -and as such DL contains a lot of syntactic hacks1 such as “foo == bar ? a -= 10 : b = 20”, though the more readable version would clearly be to use -“if/else”. -

-

-Since the parser/compressor runs fine on DL and jQuery, I'm quite confident -that it's solid enough for production use. If you can identify any bugs, -I'd love to hear about them (use the Google Group or email me directly). -

-
- -
- -
-

1.7 Links

-
- - - - - -
- -
- -
-

1.8 License

-
- - -

-UglifyJS is released under the BSD license: -

- - - -
Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com>
-Based on parse-js (http://marijn.haverbeke.nl/parse-js/).
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-    * Redistributions of source code must retain the above
-      copyright notice, this list of conditions and the following
-      disclaimer.
-
-    * Redistributions in binary form must reproduce the above
-      copyright notice, this list of conditions and the following
-      disclaimer in the documentation and/or other materials
-      provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
-THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
- - - - -
-
-
-
-

Footnotes:

-
-

1 I even reported a few bugs and suggested some fixes in the original -parse-js library, and Marijn pushed fixes literally in minutes. -

-
-
-
-

Author: Mihai Bazon -

-

Date: 2011-08-29 19:17:55 EEST

-

HTML generated by org-mode 7.01trans in emacs 23

-
-
- - diff --git a/node_modules/uglify-js/README.org b/node_modules/uglify-js/README.org deleted file mode 100644 index 50c9c2731..000000000 --- a/node_modules/uglify-js/README.org +++ /dev/null @@ -1,571 +0,0 @@ -#+TITLE: UglifyJS -- a JavaScript parser/compressor/beautifier -#+KEYWORDS: javascript, js, parser, compiler, compressor, mangle, minify, minifier -#+DESCRIPTION: a JavaScript parser/compressor/beautifier in JavaScript -#+STYLE: -#+AUTHOR: Mihai Bazon -#+EMAIL: mihai.bazon@gmail.com - -* UglifyJS --- a JavaScript parser/compressor/beautifier - -This package implements a general-purpose JavaScript -parser/compressor/beautifier toolkit. It is developed on [[http://nodejs.org/][NodeJS]], but it -should work on any JavaScript platform supporting the CommonJS module system -(and if your platform of choice doesn't support CommonJS, you can easily -implement it, or discard the =exports.*= lines from UglifyJS sources). - -The tokenizer/parser generates an abstract syntax tree from JS code. You -can then traverse the AST to learn more about the code, or do various -manipulations on it. This part is implemented in [[../lib/parse-js.js][parse-js.js]] and it's a -port to JavaScript of the excellent [[http://marijn.haverbeke.nl/parse-js/][parse-js]] Common Lisp library from [[http://marijn.haverbeke.nl/][Marijn -Haverbeke]]. - -( See [[https://github.com/mishoo/cl-uglify-js][cl-uglify-js]] if you're looking for the Common Lisp version of -UglifyJS. ) - -The second part of this package, implemented in [[../lib/process.js][process.js]], inspects and -manipulates the AST generated by the parser to provide the following: - -- ability to re-generate JavaScript code from the AST. Optionally - indented---you can use this if you want to “beautify” a program that has - been compressed, so that you can inspect the source. But you can also run - our code generator to print out an AST without any whitespace, so you - achieve compression as well. - -- shorten variable names (usually to single characters). Our mangler will - analyze the code and generate proper variable names, depending on scope - and usage, and is smart enough to deal with globals defined elsewhere, or - with =eval()= calls or =with{}= statements. In short, if =eval()= or - =with{}= are used in some scope, then all variables in that scope and any - variables in the parent scopes will remain unmangled, and any references - to such variables remain unmangled as well. - -- various small optimizations that may lead to faster code but certainly - lead to smaller code. Where possible, we do the following: - - - foo["bar"] ==> foo.bar - - - remove block brackets ={}= - - - join consecutive var declarations: - var a = 10; var b = 20; ==> var a=10,b=20; - - - resolve simple constant expressions: 1 +2 * 3 ==> 7. We only do the - replacement if the result occupies less bytes; for example 1/3 would - translate to 0.333333333333, so in this case we don't replace it. - - - consecutive statements in blocks are merged into a sequence; in many - cases, this leaves blocks with a single statement, so then we can remove - the block brackets. - - - various optimizations for IF statements: - - - if (foo) bar(); else baz(); ==> foo?bar():baz(); - - if (!foo) bar(); else baz(); ==> foo?baz():bar(); - - if (foo) bar(); ==> foo&&bar(); - - if (!foo) bar(); ==> foo||bar(); - - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); - - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()} - - - remove some unreachable code and warn about it (code that follows a - =return=, =throw=, =break= or =continue= statement, except - function/variable declarations). - - - act a limited version of a pre-processor (c.f. the pre-processor of - C/C++) to allow you to safely replace selected global symbols with - specified values. When combined with the optimisations above this can - make UglifyJS operate slightly more like a compilation process, in - that when certain symbols are replaced by constant values, entire code - blocks may be optimised away as unreachable. - -** <> - -The following transformations can in theory break code, although they're -probably safe in most practical cases. To enable them you need to pass the -=--unsafe= flag. - -*** Calls involving the global Array constructor - -The following transformations occur: - -#+BEGIN_SRC js -new Array(1, 2, 3, 4) => [1,2,3,4] -Array(a, b, c) => [a,b,c] -new Array(5) => Array(5) -new Array(a) => Array(a) -#+END_SRC - -These are all safe if the Array name isn't redefined. JavaScript does allow -one to globally redefine Array (and pretty much everything, in fact) but I -personally don't see why would anyone do that. - -UglifyJS does handle the case where Array is redefined locally, or even -globally but with a =function= or =var= declaration. Therefore, in the -following cases UglifyJS *doesn't touch* calls or instantiations of Array: - -#+BEGIN_SRC js -// case 1. globally declared variable - var Array; - new Array(1, 2, 3); - Array(a, b); - - // or (can be declared later) - new Array(1, 2, 3); - var Array; - - // or (can be a function) - new Array(1, 2, 3); - function Array() { ... } - -// case 2. declared in a function - (function(){ - a = new Array(1, 2, 3); - b = Array(5, 6); - var Array; - })(); - - // or - (function(Array){ - return Array(5, 6, 7); - })(); - - // or - (function(){ - return new Array(1, 2, 3, 4); - function Array() { ... } - })(); - - // etc. -#+END_SRC - -*** =obj.toString()= ==> =obj+“”= - -** Install (NPM) - -UglifyJS is now available through NPM --- =npm install uglify-js= should do -the job. - -** Install latest code from GitHub - -#+BEGIN_SRC sh -## clone the repository -mkdir -p /where/you/wanna/put/it -cd /where/you/wanna/put/it -git clone git://github.com/mishoo/UglifyJS.git - -## make the module available to Node -mkdir -p ~/.node_libraries/ -cd ~/.node_libraries/ -ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js - -## and if you want the CLI script too: -mkdir -p ~/bin -cd ~/bin -ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs - # (then add ~/bin to your $PATH if it's not there already) -#+END_SRC - -** Usage - -There is a command-line tool that exposes the functionality of this library -for your shell-scripting needs: - -#+BEGIN_SRC sh -uglifyjs [ options... ] [ filename ] -#+END_SRC - -=filename= should be the last argument and should name the file from which -to read the JavaScript code. If you don't specify it, it will read code -from STDIN. - -Supported options: - -- =-b= or =--beautify= --- output indented code; when passed, additional - options control the beautifier: - - - =-i N= or =--indent N= --- indentation level (number of spaces) - - - =-q= or =--quote-keys= --- quote keys in literal objects (by default, - only keys that cannot be identifier names will be quotes). - -- =--ascii= --- pass this argument to encode non-ASCII characters as - =\uXXXX= sequences. By default UglifyJS won't bother to do it and will - output Unicode characters instead. (the output is always encoded in UTF8, - but if you pass this option you'll only get ASCII). - -- =-nm= or =--no-mangle= --- don't mangle variable names - -- =-ns= or =--no-squeeze= --- don't call =ast_squeeze()= (which does various - optimizations that result in smaller, less readable code). - -- =-mt= or =--mangle-toplevel= --- mangle names in the toplevel scope too - (by default we don't do this). - -- =--no-seqs= --- when =ast_squeeze()= is called (thus, unless you pass - =--no-squeeze=) it will reduce consecutive statements in blocks into a - sequence. For example, "a = 10; b = 20; foo();" will be written as - "a=10,b=20,foo();". In various occasions, this allows us to discard the - block brackets (since the block becomes a single statement). This is ON - by default because it seems safe and saves a few hundred bytes on some - libs that I tested it on, but pass =--no-seqs= to disable it. - -- =--no-dead-code= --- by default, UglifyJS will remove code that is - obviously unreachable (code that follows a =return=, =throw=, =break= or - =continue= statement and is not a function/variable declaration). Pass - this option to disable this optimization. - -- =-nc= or =--no-copyright= --- by default, =uglifyjs= will keep the initial - comment tokens in the generated code (assumed to be copyright information - etc.). If you pass this it will discard it. - -- =-o filename= or =--output filename= --- put the result in =filename=. If - this isn't given, the result goes to standard output (or see next one). - -- =--overwrite= --- if the code is read from a file (not from STDIN) and you - pass =--overwrite= then the output will be written in the same file. - -- =--ast= --- pass this if you want to get the Abstract Syntax Tree instead - of JavaScript as output. Useful for debugging or learning more about the - internals. - -- =-v= or =--verbose= --- output some notes on STDERR (for now just how long - each operation takes). - -- =-d SYMBOL[=VALUE]= or =--define SYMBOL[=VALUE]= --- will replace - all instances of the specified symbol where used as an identifier - (except where symbol has properly declared by a var declaration or - use as function parameter or similar) with the specified value. This - argument may be specified multiple times to define multiple - symbols - if no value is specified the symbol will be replaced with - the value =true=, or you can specify a numeric value (such as - =1024=), a quoted string value (such as ="object"= or - ='https://github.com'=), or the name of another symbol or keyword - (such as =null= or =document=). - This allows you, for example, to assign meaningful names to key - constant values but discard the symbolic names in the uglified - version for brevity/efficiency, or when used wth care, allows - UglifyJS to operate as a form of *conditional compilation* - whereby defining appropriate values may, by dint of the constant - folding and dead code removal features above, remove entire - superfluous code blocks (e.g. completely remove instrumentation or - trace code for production use). - Where string values are being defined, the handling of quotes are - likely to be subject to the specifics of your command shell - environment, so you may need to experiment with quoting styles - depending on your platform, or you may find the option - =--define-from-module= more suitable for use. - -- =-define-from-module SOMEMODULE= --- will load the named module (as - per the NodeJS =require()= function) and iterate all the exported - properties of the module defining them as symbol names to be defined - (as if by the =--define= option) per the name of each property - (i.e. without the module name prefix) and given the value of the - property. This is a much easier way to handle and document groups of - symbols to be defined rather than a large number of =--define= - options. - -- =--unsafe= --- enable other additional optimizations that are known to be - unsafe in some contrived situations, but could still be generally useful. - For now only these: - - - foo.toString() ==> foo+"" - - new Array(x,...) ==> [x,...] - - new Array(x) ==> Array(x) - -- =--max-line-len= (default 32K characters) --- add a newline after around - 32K characters. I've seen both FF and Chrome croak when all the code was - on a single line of around 670K. Pass --max-line-len 0 to disable this - safety feature. - -- =--reserved-names= --- some libraries rely on certain names to be used, as - pointed out in issue #92 and #81, so this option allow you to exclude such - names from the mangler. For example, to keep names =require= and =$super= - intact you'd specify --reserved-names "require,$super". - -- =--inline-script= -- when you want to include the output literally in an - HTML =