postdoc 0.1.2 → 0.2.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/pdf.js +27 -0
- data/lib/postdoc.rb +3 -7
- data/node_modules/agent-base/History.md +113 -0
- data/node_modules/agent-base/README.md +145 -0
- data/node_modules/agent-base/index.js +160 -0
- data/node_modules/agent-base/package.json +35 -0
- data/node_modules/agent-base/patch-core.js +37 -0
- data/node_modules/agent-base/test/ssl-cert-snakeoil.key +15 -0
- data/node_modules/agent-base/test/ssl-cert-snakeoil.pem +12 -0
- data/node_modules/agent-base/test/test.js +673 -0
- data/node_modules/async-limiter/LICENSE +8 -0
- data/node_modules/async-limiter/coverage/coverage.json +1 -0
- data/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.html +73 -0
- data/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.js.html +246 -0
- data/node_modules/async-limiter/coverage/lcov-report/base.css +182 -0
- data/node_modules/async-limiter/coverage/lcov-report/index.html +73 -0
- data/node_modules/async-limiter/coverage/lcov-report/prettify.css +1 -0
- data/node_modules/async-limiter/coverage/lcov-report/prettify.js +1 -0
- data/node_modules/async-limiter/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- data/node_modules/async-limiter/coverage/lcov-report/sorter.js +156 -0
- data/node_modules/async-limiter/coverage/lcov.info +74 -0
- data/node_modules/async-limiter/index.js +67 -0
- data/node_modules/async-limiter/package.json +35 -0
- data/node_modules/async-limiter/readme.md +132 -0
- data/node_modules/balanced-match/LICENSE.md +21 -0
- data/node_modules/balanced-match/README.md +91 -0
- data/node_modules/balanced-match/index.js +59 -0
- data/node_modules/balanced-match/package.json +49 -0
- data/node_modules/brace-expansion/LICENSE +21 -0
- data/node_modules/brace-expansion/README.md +129 -0
- data/node_modules/brace-expansion/index.js +201 -0
- data/node_modules/brace-expansion/package.json +47 -0
- data/node_modules/buffer-from/index.js +69 -0
- data/node_modules/buffer-from/package.json +16 -0
- data/node_modules/buffer-from/readme.md +69 -0
- data/node_modules/buffer-from/test.js +12 -0
- data/node_modules/concat-map/LICENSE +18 -0
- data/node_modules/concat-map/README.markdown +62 -0
- data/node_modules/concat-map/example/map.js +6 -0
- data/node_modules/concat-map/index.js +13 -0
- data/node_modules/concat-map/package.json +43 -0
- data/node_modules/concat-map/test/map.js +39 -0
- data/node_modules/concat-stream/LICENSE +24 -0
- data/node_modules/concat-stream/index.js +144 -0
- data/node_modules/concat-stream/package.json +55 -0
- data/node_modules/concat-stream/readme.md +102 -0
- data/node_modules/core-util-is/LICENSE +19 -0
- data/node_modules/core-util-is/README.md +3 -0
- data/node_modules/core-util-is/float.patch +604 -0
- data/node_modules/core-util-is/lib/util.js +107 -0
- data/node_modules/core-util-is/package.json +32 -0
- data/node_modules/core-util-is/test.js +68 -0
- data/node_modules/debug/CHANGELOG.md +395 -0
- data/node_modules/debug/LICENSE +19 -0
- data/node_modules/debug/Makefile +58 -0
- data/node_modules/debug/README.md +368 -0
- data/node_modules/debug/karma.conf.js +70 -0
- data/node_modules/debug/node.js +1 -0
- data/node_modules/debug/package.json +43 -0
- data/node_modules/debug/src/browser.js +195 -0
- data/node_modules/debug/src/debug.js +225 -0
- data/node_modules/debug/src/index.js +10 -0
- data/node_modules/debug/src/node.js +186 -0
- data/node_modules/es6-promise/CHANGELOG.md +151 -0
- data/node_modules/es6-promise/LICENSE +19 -0
- data/node_modules/es6-promise/README.md +97 -0
- data/node_modules/es6-promise/auto.js +4 -0
- data/node_modules/es6-promise/dist/es6-promise.auto.js +1181 -0
- data/node_modules/es6-promise/dist/es6-promise.auto.map +1 -0
- data/node_modules/es6-promise/dist/es6-promise.auto.min.js +1 -0
- data/node_modules/es6-promise/dist/es6-promise.auto.min.map +1 -0
- data/node_modules/es6-promise/dist/es6-promise.js +1179 -0
- data/node_modules/es6-promise/dist/es6-promise.map +1 -0
- data/node_modules/es6-promise/dist/es6-promise.min.js +1 -0
- data/node_modules/es6-promise/dist/es6-promise.min.map +1 -0
- data/node_modules/es6-promise/es6-promise.d.ts +81 -0
- data/node_modules/es6-promise/lib/es6-promise/-internal.js +266 -0
- data/node_modules/es6-promise/lib/es6-promise/asap.js +119 -0
- data/node_modules/es6-promise/lib/es6-promise/enumerator.js +113 -0
- data/node_modules/es6-promise/lib/es6-promise/polyfill.js +35 -0
- data/node_modules/es6-promise/lib/es6-promise/promise/all.js +52 -0
- data/node_modules/es6-promise/lib/es6-promise/promise/race.js +84 -0
- data/node_modules/es6-promise/lib/es6-promise/promise/reject.js +46 -0
- data/node_modules/es6-promise/lib/es6-promise/promise/resolve.js +48 -0
- data/node_modules/es6-promise/lib/es6-promise/promise.js +427 -0
- data/node_modules/es6-promise/lib/es6-promise/then.js +32 -0
- data/node_modules/es6-promise/lib/es6-promise/utils.js +21 -0
- data/node_modules/es6-promise/lib/es6-promise.auto.js +3 -0
- data/node_modules/es6-promise/lib/es6-promise.js +7 -0
- data/node_modules/es6-promise/package.json +75 -0
- data/node_modules/es6-promisify/README.md +89 -0
- data/node_modules/es6-promisify/dist/promise.js +73 -0
- data/node_modules/es6-promisify/dist/promisify.js +85 -0
- data/node_modules/es6-promisify/package.json +41 -0
- data/node_modules/extract-zip/CONTRIBUTING.md +1 -0
- data/node_modules/extract-zip/LICENSE +23 -0
- data/node_modules/extract-zip/cli.js +20 -0
- data/node_modules/extract-zip/index.js +205 -0
- data/node_modules/extract-zip/node_modules/debug/CHANGELOG.md +362 -0
- data/node_modules/extract-zip/node_modules/debug/LICENSE +19 -0
- data/node_modules/extract-zip/node_modules/debug/Makefile +50 -0
- data/node_modules/extract-zip/node_modules/debug/README.md +312 -0
- data/node_modules/extract-zip/node_modules/debug/component.json +19 -0
- data/node_modules/extract-zip/node_modules/debug/karma.conf.js +70 -0
- data/node_modules/extract-zip/node_modules/debug/node.js +1 -0
- data/node_modules/extract-zip/node_modules/debug/package.json +49 -0
- data/node_modules/extract-zip/node_modules/debug/src/browser.js +185 -0
- data/node_modules/extract-zip/node_modules/debug/src/debug.js +202 -0
- data/node_modules/extract-zip/node_modules/debug/src/index.js +10 -0
- data/node_modules/extract-zip/node_modules/debug/src/inspector-log.js +15 -0
- data/node_modules/extract-zip/node_modules/debug/src/node.js +248 -0
- data/node_modules/extract-zip/package.json +35 -0
- data/node_modules/extract-zip/readme.md +49 -0
- data/node_modules/fd-slicer/CHANGELOG.md +49 -0
- data/node_modules/fd-slicer/LICENSE +21 -0
- data/node_modules/fd-slicer/README.md +189 -0
- data/node_modules/fd-slicer/index.js +277 -0
- data/node_modules/fd-slicer/package.json +36 -0
- data/node_modules/fd-slicer/test/test.js +350 -0
- data/node_modules/fs.realpath/LICENSE +43 -0
- data/node_modules/fs.realpath/README.md +33 -0
- data/node_modules/fs.realpath/index.js +66 -0
- data/node_modules/fs.realpath/old.js +303 -0
- data/node_modules/fs.realpath/package.json +26 -0
- data/node_modules/glob/LICENSE +15 -0
- data/node_modules/glob/README.md +368 -0
- data/node_modules/glob/changelog.md +67 -0
- data/node_modules/glob/common.js +240 -0
- data/node_modules/glob/glob.js +790 -0
- data/node_modules/glob/package.json +43 -0
- data/node_modules/glob/sync.js +486 -0
- data/node_modules/https-proxy-agent/History.md +124 -0
- data/node_modules/https-proxy-agent/README.md +137 -0
- data/node_modules/https-proxy-agent/index.js +229 -0
- data/node_modules/https-proxy-agent/package.json +35 -0
- data/node_modules/https-proxy-agent/test/ssl-cert-snakeoil.key +15 -0
- data/node_modules/https-proxy-agent/test/ssl-cert-snakeoil.pem +12 -0
- data/node_modules/https-proxy-agent/test/test.js +342 -0
- data/node_modules/inflight/LICENSE +15 -0
- data/node_modules/inflight/README.md +37 -0
- data/node_modules/inflight/inflight.js +54 -0
- data/node_modules/inflight/package.json +29 -0
- data/node_modules/inherits/LICENSE +16 -0
- data/node_modules/inherits/README.md +42 -0
- data/node_modules/inherits/inherits.js +7 -0
- data/node_modules/inherits/inherits_browser.js +23 -0
- data/node_modules/inherits/package.json +29 -0
- data/node_modules/isarray/Makefile +6 -0
- data/node_modules/isarray/README.md +60 -0
- data/node_modules/isarray/component.json +19 -0
- data/node_modules/isarray/index.js +5 -0
- data/node_modules/isarray/package.json +45 -0
- data/node_modules/isarray/test.js +20 -0
- data/node_modules/mime/CHANGELOG.md +225 -0
- data/node_modules/mime/CONTRIBUTING.md +5 -0
- data/node_modules/mime/LICENSE +21 -0
- data/node_modules/mime/Mime.js +89 -0
- data/node_modules/mime/README.md +188 -0
- data/node_modules/mime/cli.js +10 -0
- data/node_modules/mime/index.js +4 -0
- data/node_modules/mime/lite.js +4 -0
- data/node_modules/mime/package.json +43 -0
- data/node_modules/mime/src/README_js.md +179 -0
- data/node_modules/mime/src/build.js +71 -0
- data/node_modules/mime/src/test.js +257 -0
- data/node_modules/mime/types/other.json +1 -0
- data/node_modules/mime/types/standard.json +1 -0
- data/node_modules/minimatch/LICENSE +15 -0
- data/node_modules/minimatch/README.md +209 -0
- data/node_modules/minimatch/minimatch.js +923 -0
- data/node_modules/minimatch/package.json +30 -0
- data/node_modules/minimist/LICENSE +18 -0
- data/node_modules/minimist/example/parse.js +2 -0
- data/node_modules/minimist/index.js +187 -0
- data/node_modules/minimist/package.json +40 -0
- data/node_modules/minimist/readme.markdown +73 -0
- data/node_modules/minimist/test/dash.js +24 -0
- data/node_modules/minimist/test/default_bool.js +20 -0
- data/node_modules/minimist/test/dotted.js +16 -0
- data/node_modules/minimist/test/long.js +31 -0
- data/node_modules/minimist/test/parse.js +318 -0
- data/node_modules/minimist/test/parse_modified.js +9 -0
- data/node_modules/minimist/test/short.js +67 -0
- data/node_modules/minimist/test/whitespace.js +8 -0
- data/node_modules/mkdirp/LICENSE +21 -0
- data/node_modules/mkdirp/bin/cmd.js +33 -0
- data/node_modules/mkdirp/bin/usage.txt +12 -0
- data/node_modules/mkdirp/examples/pow.js +6 -0
- data/node_modules/mkdirp/index.js +98 -0
- data/node_modules/mkdirp/package.json +27 -0
- data/node_modules/mkdirp/readme.markdown +100 -0
- data/node_modules/mkdirp/test/chmod.js +41 -0
- data/node_modules/mkdirp/test/clobber.js +38 -0
- data/node_modules/mkdirp/test/mkdirp.js +28 -0
- data/node_modules/mkdirp/test/opts_fs.js +29 -0
- data/node_modules/mkdirp/test/opts_fs_sync.js +27 -0
- data/node_modules/mkdirp/test/perm.js +32 -0
- data/node_modules/mkdirp/test/perm_sync.js +36 -0
- data/node_modules/mkdirp/test/race.js +37 -0
- data/node_modules/mkdirp/test/rel.js +32 -0
- data/node_modules/mkdirp/test/return.js +25 -0
- data/node_modules/mkdirp/test/return_sync.js +24 -0
- data/node_modules/mkdirp/test/root.js +19 -0
- data/node_modules/mkdirp/test/sync.js +32 -0
- data/node_modules/mkdirp/test/umask.js +28 -0
- data/node_modules/mkdirp/test/umask_sync.js +32 -0
- data/node_modules/ms/index.js +152 -0
- data/node_modules/ms/license.md +21 -0
- data/node_modules/ms/package.json +37 -0
- data/node_modules/ms/readme.md +51 -0
- data/node_modules/once/LICENSE +15 -0
- data/node_modules/once/README.md +79 -0
- data/node_modules/once/once.js +42 -0
- data/node_modules/once/package.json +33 -0
- data/node_modules/path-is-absolute/index.js +20 -0
- data/node_modules/path-is-absolute/license +21 -0
- data/node_modules/path-is-absolute/package.json +43 -0
- data/node_modules/path-is-absolute/readme.md +59 -0
- data/node_modules/pend/LICENSE +23 -0
- data/node_modules/pend/README.md +41 -0
- data/node_modules/pend/index.js +55 -0
- data/node_modules/pend/package.json +18 -0
- data/node_modules/pend/test.js +137 -0
- data/node_modules/process-nextick-args/index.js +44 -0
- data/node_modules/process-nextick-args/license.md +19 -0
- data/node_modules/process-nextick-args/package.json +25 -0
- data/node_modules/process-nextick-args/readme.md +18 -0
- data/node_modules/progress/CHANGELOG.md +115 -0
- data/node_modules/progress/LICENSE +22 -0
- data/node_modules/progress/Makefile +8 -0
- data/node_modules/progress/README.md +146 -0
- data/node_modules/progress/index.js +1 -0
- data/node_modules/progress/lib/node-progress.js +231 -0
- data/node_modules/progress/package.json +25 -0
- data/node_modules/proxy-from-env/README.md +131 -0
- data/node_modules/proxy-from-env/index.js +103 -0
- data/node_modules/proxy-from-env/package.json +35 -0
- data/node_modules/proxy-from-env/test.js +393 -0
- data/node_modules/puppeteer/CONTRIBUTING.md +206 -0
- data/node_modules/puppeteer/DeviceDescriptors.js +704 -0
- data/node_modules/puppeteer/LICENSE +202 -0
- data/node_modules/puppeteer/README.md +306 -0
- data/node_modules/puppeteer/index.js +28 -0
- data/node_modules/puppeteer/install.js +122 -0
- data/node_modules/puppeteer/lib/Browser.js +186 -0
- data/node_modules/puppeteer/lib/BrowserFetcher.js +279 -0
- data/node_modules/puppeteer/lib/Connection.js +246 -0
- data/node_modules/puppeteer/lib/Coverage.js +301 -0
- data/node_modules/puppeteer/lib/Dialog.js +84 -0
- data/node_modules/puppeteer/lib/ElementHandle.js +328 -0
- data/node_modules/puppeteer/lib/EmulationManager.js +89 -0
- data/node_modules/puppeteer/lib/ExecutionContext.js +232 -0
- data/node_modules/puppeteer/lib/FrameManager.js +997 -0
- data/node_modules/puppeteer/lib/Input.js +309 -0
- data/node_modules/puppeteer/lib/Launcher.js +310 -0
- data/node_modules/puppeteer/lib/Multimap.js +95 -0
- data/node_modules/puppeteer/lib/NavigatorWatcher.js +137 -0
- data/node_modules/puppeteer/lib/NetworkManager.js +796 -0
- data/node_modules/puppeteer/lib/Page.js +1098 -0
- data/node_modules/puppeteer/lib/Pipe.js +69 -0
- data/node_modules/puppeteer/lib/Puppeteer.js +60 -0
- data/node_modules/puppeteer/lib/Target.js +88 -0
- data/node_modules/puppeteer/lib/TaskQueue.js +17 -0
- data/node_modules/puppeteer/lib/Tracing.js +99 -0
- data/node_modules/puppeteer/lib/USKeyboardLayout.js +281 -0
- data/node_modules/puppeteer/lib/helper.js +248 -0
- data/node_modules/puppeteer/node6/lib/Browser.js +394 -0
- data/node_modules/puppeteer/node6/lib/BrowserFetcher.js +357 -0
- data/node_modules/puppeteer/node6/lib/Connection.js +350 -0
- data/node_modules/puppeteer/node6/lib/Coverage.js +561 -0
- data/node_modules/puppeteer/node6/lib/Dialog.js +136 -0
- data/node_modules/puppeteer/node6/lib/ElementHandle.js +796 -0
- data/node_modules/puppeteer/node6/lib/EmulationManager.js +115 -0
- data/node_modules/puppeteer/node6/lib/ExecutionContext.js +414 -0
- data/node_modules/puppeteer/node6/lib/FrameManager.js +1621 -0
- data/node_modules/puppeteer/node6/lib/Input.js +569 -0
- data/node_modules/puppeteer/node6/lib/Launcher.js +362 -0
- data/node_modules/puppeteer/node6/lib/Multimap.js +95 -0
- data/node_modules/puppeteer/node6/lib/NavigatorWatcher.js +163 -0
- data/node_modules/puppeteer/node6/lib/NetworkManager.js +1108 -0
- data/node_modules/puppeteer/node6/lib/Page.js +2242 -0
- data/node_modules/puppeteer/node6/lib/Pipe.js +69 -0
- data/node_modules/puppeteer/node6/lib/Puppeteer.js +60 -0
- data/node_modules/puppeteer/node6/lib/Target.js +114 -0
- data/node_modules/puppeteer/node6/lib/TaskQueue.js +17 -0
- data/node_modules/puppeteer/node6/lib/Tracing.js +177 -0
- data/node_modules/puppeteer/node6/lib/USKeyboardLayout.js +281 -0
- data/node_modules/puppeteer/node6/lib/helper.js +274 -0
- data/node_modules/puppeteer/package.json +61 -0
- data/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- data/node_modules/readable-stream/GOVERNANCE.md +136 -0
- data/node_modules/readable-stream/LICENSE +47 -0
- data/node_modules/readable-stream/README.md +58 -0
- data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- data/node_modules/readable-stream/duplex-browser.js +1 -0
- data/node_modules/readable-stream/duplex.js +1 -0
- data/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- data/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- data/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- data/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- data/node_modules/readable-stream/lib/_stream_writable.js +687 -0
- data/node_modules/readable-stream/lib/internal/streams/BufferList.js +79 -0
- data/node_modules/readable-stream/lib/internal/streams/destroy.js +74 -0
- data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- data/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- data/node_modules/readable-stream/package.json +52 -0
- data/node_modules/readable-stream/passthrough.js +1 -0
- data/node_modules/readable-stream/readable-browser.js +7 -0
- data/node_modules/readable-stream/readable.js +19 -0
- data/node_modules/readable-stream/transform.js +1 -0
- data/node_modules/readable-stream/writable-browser.js +1 -0
- data/node_modules/readable-stream/writable.js +8 -0
- data/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/rimraf/README.md +101 -0
- data/node_modules/rimraf/bin.js +50 -0
- data/node_modules/rimraf/package.json +26 -0
- data/node_modules/rimraf/rimraf.js +364 -0
- data/node_modules/safe-buffer/LICENSE +21 -0
- data/node_modules/safe-buffer/README.md +584 -0
- data/node_modules/safe-buffer/index.d.ts +187 -0
- data/node_modules/safe-buffer/index.js +62 -0
- data/node_modules/safe-buffer/package.json +37 -0
- data/node_modules/string_decoder/LICENSE +48 -0
- data/node_modules/string_decoder/README.md +47 -0
- data/node_modules/string_decoder/lib/string_decoder.js +296 -0
- data/node_modules/string_decoder/package.json +31 -0
- data/node_modules/typedarray/LICENSE +35 -0
- data/node_modules/typedarray/example/tarray.js +4 -0
- data/node_modules/typedarray/index.js +630 -0
- data/node_modules/typedarray/package.json +55 -0
- data/node_modules/typedarray/readme.markdown +61 -0
- data/node_modules/typedarray/test/server/undef_globals.js +19 -0
- data/node_modules/typedarray/test/tarray.js +10 -0
- data/node_modules/ultron/LICENSE +22 -0
- data/node_modules/ultron/README.md +113 -0
- data/node_modules/ultron/index.js +136 -0
- data/node_modules/ultron/package.json +41 -0
- data/node_modules/util-deprecate/History.md +16 -0
- data/node_modules/util-deprecate/LICENSE +24 -0
- data/node_modules/util-deprecate/README.md +53 -0
- data/node_modules/util-deprecate/browser.js +67 -0
- data/node_modules/util-deprecate/node.js +6 -0
- data/node_modules/util-deprecate/package.json +27 -0
- data/node_modules/wrappy/LICENSE +15 -0
- data/node_modules/wrappy/README.md +36 -0
- data/node_modules/wrappy/package.json +29 -0
- data/node_modules/wrappy/wrappy.js +33 -0
- data/node_modules/ws/LICENSE +21 -0
- data/node_modules/ws/README.md +341 -0
- data/node_modules/ws/index.js +15 -0
- data/node_modules/ws/lib/BufferUtil.js +71 -0
- data/node_modules/ws/lib/Constants.js +10 -0
- data/node_modules/ws/lib/ErrorCodes.js +28 -0
- data/node_modules/ws/lib/EventTarget.js +151 -0
- data/node_modules/ws/lib/Extensions.js +203 -0
- data/node_modules/ws/lib/PerMessageDeflate.js +507 -0
- data/node_modules/ws/lib/Receiver.js +553 -0
- data/node_modules/ws/lib/Sender.js +412 -0
- data/node_modules/ws/lib/Validation.js +17 -0
- data/node_modules/ws/lib/WebSocket.js +717 -0
- data/node_modules/ws/lib/WebSocketServer.js +326 -0
- data/node_modules/ws/package.json +46 -0
- data/node_modules/yauzl/LICENSE +21 -0
- data/node_modules/yauzl/README.md +467 -0
- data/node_modules/yauzl/index.js +626 -0
- data/node_modules/yauzl/package.json +36 -0
- data/package.json +5 -0
- data/yarn.lock +240 -0
- metadata +372 -7
- data/app/assets/stylesheets/default.css +0 -4
- data/lib/postdoc/postdoc_view_helper.rb +0 -22
@@ -0,0 +1,156 @@
|
|
1
|
+
var addSorting = (function () {
|
2
|
+
"use strict";
|
3
|
+
var cols,
|
4
|
+
currentSort = {
|
5
|
+
index: 0,
|
6
|
+
desc: false
|
7
|
+
};
|
8
|
+
|
9
|
+
// returns the summary table element
|
10
|
+
function getTable() { return document.querySelector('.coverage-summary table'); }
|
11
|
+
// returns the thead element of the summary table
|
12
|
+
function getTableHeader() { return getTable().querySelector('thead tr'); }
|
13
|
+
// returns the tbody element of the summary table
|
14
|
+
function getTableBody() { return getTable().querySelector('tbody'); }
|
15
|
+
// returns the th element for nth column
|
16
|
+
function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; }
|
17
|
+
|
18
|
+
// loads all columns
|
19
|
+
function loadColumns() {
|
20
|
+
var colNodes = getTableHeader().querySelectorAll('th'),
|
21
|
+
colNode,
|
22
|
+
cols = [],
|
23
|
+
col,
|
24
|
+
i;
|
25
|
+
|
26
|
+
for (i = 0; i < colNodes.length; i += 1) {
|
27
|
+
colNode = colNodes[i];
|
28
|
+
col = {
|
29
|
+
key: colNode.getAttribute('data-col'),
|
30
|
+
sortable: !colNode.getAttribute('data-nosort'),
|
31
|
+
type: colNode.getAttribute('data-type') || 'string'
|
32
|
+
};
|
33
|
+
cols.push(col);
|
34
|
+
if (col.sortable) {
|
35
|
+
col.defaultDescSort = col.type === 'number';
|
36
|
+
colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>';
|
37
|
+
}
|
38
|
+
}
|
39
|
+
return cols;
|
40
|
+
}
|
41
|
+
// attaches a data attribute to every tr element with an object
|
42
|
+
// of data values keyed by column name
|
43
|
+
function loadRowData(tableRow) {
|
44
|
+
var tableCols = tableRow.querySelectorAll('td'),
|
45
|
+
colNode,
|
46
|
+
col,
|
47
|
+
data = {},
|
48
|
+
i,
|
49
|
+
val;
|
50
|
+
for (i = 0; i < tableCols.length; i += 1) {
|
51
|
+
colNode = tableCols[i];
|
52
|
+
col = cols[i];
|
53
|
+
val = colNode.getAttribute('data-value');
|
54
|
+
if (col.type === 'number') {
|
55
|
+
val = Number(val);
|
56
|
+
}
|
57
|
+
data[col.key] = val;
|
58
|
+
}
|
59
|
+
return data;
|
60
|
+
}
|
61
|
+
// loads all row data
|
62
|
+
function loadData() {
|
63
|
+
var rows = getTableBody().querySelectorAll('tr'),
|
64
|
+
i;
|
65
|
+
|
66
|
+
for (i = 0; i < rows.length; i += 1) {
|
67
|
+
rows[i].data = loadRowData(rows[i]);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
// sorts the table using the data for the ith column
|
71
|
+
function sortByIndex(index, desc) {
|
72
|
+
var key = cols[index].key,
|
73
|
+
sorter = function (a, b) {
|
74
|
+
a = a.data[key];
|
75
|
+
b = b.data[key];
|
76
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
77
|
+
},
|
78
|
+
finalSorter = sorter,
|
79
|
+
tableBody = document.querySelector('.coverage-summary tbody'),
|
80
|
+
rowNodes = tableBody.querySelectorAll('tr'),
|
81
|
+
rows = [],
|
82
|
+
i;
|
83
|
+
|
84
|
+
if (desc) {
|
85
|
+
finalSorter = function (a, b) {
|
86
|
+
return -1 * sorter(a, b);
|
87
|
+
};
|
88
|
+
}
|
89
|
+
|
90
|
+
for (i = 0; i < rowNodes.length; i += 1) {
|
91
|
+
rows.push(rowNodes[i]);
|
92
|
+
tableBody.removeChild(rowNodes[i]);
|
93
|
+
}
|
94
|
+
|
95
|
+
rows.sort(finalSorter);
|
96
|
+
|
97
|
+
for (i = 0; i < rows.length; i += 1) {
|
98
|
+
tableBody.appendChild(rows[i]);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
// removes sort indicators for current column being sorted
|
102
|
+
function removeSortIndicators() {
|
103
|
+
var col = getNthColumn(currentSort.index),
|
104
|
+
cls = col.className;
|
105
|
+
|
106
|
+
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
107
|
+
col.className = cls;
|
108
|
+
}
|
109
|
+
// adds sort indicators for current column being sorted
|
110
|
+
function addSortIndicators() {
|
111
|
+
getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted';
|
112
|
+
}
|
113
|
+
// adds event listeners for all sorter widgets
|
114
|
+
function enableUI() {
|
115
|
+
var i,
|
116
|
+
el,
|
117
|
+
ithSorter = function ithSorter(i) {
|
118
|
+
var col = cols[i];
|
119
|
+
|
120
|
+
return function () {
|
121
|
+
var desc = col.defaultDescSort;
|
122
|
+
|
123
|
+
if (currentSort.index === i) {
|
124
|
+
desc = !currentSort.desc;
|
125
|
+
}
|
126
|
+
sortByIndex(i, desc);
|
127
|
+
removeSortIndicators();
|
128
|
+
currentSort.index = i;
|
129
|
+
currentSort.desc = desc;
|
130
|
+
addSortIndicators();
|
131
|
+
};
|
132
|
+
};
|
133
|
+
for (i =0 ; i < cols.length; i += 1) {
|
134
|
+
if (cols[i].sortable) {
|
135
|
+
el = getNthColumn(i).querySelector('.sorter');
|
136
|
+
if (el.addEventListener) {
|
137
|
+
el.addEventListener('click', ithSorter(i));
|
138
|
+
} else {
|
139
|
+
el.attachEvent('onclick', ithSorter(i));
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
// adds sorting functionality to the UI
|
145
|
+
return function () {
|
146
|
+
if (!getTable()) {
|
147
|
+
return;
|
148
|
+
}
|
149
|
+
cols = loadColumns();
|
150
|
+
loadData(cols);
|
151
|
+
addSortIndicators();
|
152
|
+
enableUI();
|
153
|
+
};
|
154
|
+
})();
|
155
|
+
|
156
|
+
window.addEventListener('load', addSorting);
|
@@ -0,0 +1,74 @@
|
|
1
|
+
TN:
|
2
|
+
SF:/Users/samuelreed/git/forks/async-throttle/index.js
|
3
|
+
FN:3,Queue
|
4
|
+
FN:22,(anonymous_2)
|
5
|
+
FN:23,(anonymous_3)
|
6
|
+
FN:31,(anonymous_4)
|
7
|
+
FN:36,(anonymous_5)
|
8
|
+
FN:55,(anonymous_6)
|
9
|
+
FN:62,done
|
10
|
+
FNF:7
|
11
|
+
FNH:7
|
12
|
+
FNDA:7,Queue
|
13
|
+
FNDA:3,(anonymous_2)
|
14
|
+
FNDA:13,(anonymous_3)
|
15
|
+
FNDA:19,(anonymous_4)
|
16
|
+
FNDA:45,(anonymous_5)
|
17
|
+
FNDA:6,(anonymous_6)
|
18
|
+
FNDA:13,done
|
19
|
+
DA:3,1
|
20
|
+
DA:4,7
|
21
|
+
DA:5,1
|
22
|
+
DA:8,6
|
23
|
+
DA:9,6
|
24
|
+
DA:10,6
|
25
|
+
DA:11,6
|
26
|
+
DA:12,6
|
27
|
+
DA:13,6
|
28
|
+
DA:16,1
|
29
|
+
DA:22,1
|
30
|
+
DA:23,3
|
31
|
+
DA:24,13
|
32
|
+
DA:25,13
|
33
|
+
DA:26,13
|
34
|
+
DA:30,1
|
35
|
+
DA:32,19
|
36
|
+
DA:36,1
|
37
|
+
DA:37,45
|
38
|
+
DA:38,6
|
39
|
+
DA:40,39
|
40
|
+
DA:41,13
|
41
|
+
DA:42,13
|
42
|
+
DA:43,13
|
43
|
+
DA:44,13
|
44
|
+
DA:47,39
|
45
|
+
DA:48,18
|
46
|
+
DA:49,6
|
47
|
+
DA:50,6
|
48
|
+
DA:55,1
|
49
|
+
DA:56,6
|
50
|
+
DA:57,6
|
51
|
+
DA:58,6
|
52
|
+
DA:62,1
|
53
|
+
DA:63,13
|
54
|
+
DA:64,13
|
55
|
+
DA:67,1
|
56
|
+
LF:37
|
57
|
+
LH:37
|
58
|
+
BRDA:4,1,0,1
|
59
|
+
BRDA:4,1,1,6
|
60
|
+
BRDA:8,2,0,6
|
61
|
+
BRDA:8,2,1,5
|
62
|
+
BRDA:9,3,0,6
|
63
|
+
BRDA:9,3,1,5
|
64
|
+
BRDA:37,4,0,6
|
65
|
+
BRDA:37,4,1,39
|
66
|
+
BRDA:40,5,0,13
|
67
|
+
BRDA:40,5,1,26
|
68
|
+
BRDA:47,6,0,18
|
69
|
+
BRDA:47,6,1,21
|
70
|
+
BRDA:56,7,0,6
|
71
|
+
BRDA:56,7,1,0
|
72
|
+
BRF:14
|
73
|
+
BRH:13
|
74
|
+
end_of_record
|
@@ -0,0 +1,67 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
function Queue(options) {
|
4
|
+
if (!(this instanceof Queue)) {
|
5
|
+
return new Queue(options);
|
6
|
+
}
|
7
|
+
|
8
|
+
options = options || {};
|
9
|
+
this.concurrency = options.concurrency || Infinity;
|
10
|
+
this.pending = 0;
|
11
|
+
this.jobs = [];
|
12
|
+
this.cbs = [];
|
13
|
+
this._done = done.bind(this);
|
14
|
+
}
|
15
|
+
|
16
|
+
var arrayAddMethods = [
|
17
|
+
'push',
|
18
|
+
'unshift',
|
19
|
+
'splice'
|
20
|
+
];
|
21
|
+
|
22
|
+
arrayAddMethods.forEach(function(method) {
|
23
|
+
Queue.prototype[method] = function() {
|
24
|
+
var methodResult = Array.prototype[method].apply(this.jobs, arguments);
|
25
|
+
this._run();
|
26
|
+
return methodResult;
|
27
|
+
};
|
28
|
+
});
|
29
|
+
|
30
|
+
Object.defineProperty(Queue.prototype, 'length', {
|
31
|
+
get: function() {
|
32
|
+
return this.pending + this.jobs.length;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
Queue.prototype._run = function() {
|
37
|
+
if (this.pending === this.concurrency) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
if (this.jobs.length) {
|
41
|
+
var job = this.jobs.shift();
|
42
|
+
this.pending++;
|
43
|
+
job(this._done);
|
44
|
+
this._run();
|
45
|
+
}
|
46
|
+
|
47
|
+
if (this.pending === 0) {
|
48
|
+
while (this.cbs.length !== 0) {
|
49
|
+
var cb = this.cbs.pop();
|
50
|
+
process.nextTick(cb);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
};
|
54
|
+
|
55
|
+
Queue.prototype.onDone = function(cb) {
|
56
|
+
if (typeof cb === 'function') {
|
57
|
+
this.cbs.push(cb);
|
58
|
+
this._run();
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
function done() {
|
63
|
+
this.pending--;
|
64
|
+
this._run();
|
65
|
+
}
|
66
|
+
|
67
|
+
module.exports = Queue;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"name": "async-limiter",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "asynchronous function queue with adjustable concurrency",
|
5
|
+
"keywords": [
|
6
|
+
"throttle",
|
7
|
+
"async",
|
8
|
+
"limiter",
|
9
|
+
"asynchronous",
|
10
|
+
"job",
|
11
|
+
"task",
|
12
|
+
"concurrency",
|
13
|
+
"concurrent"
|
14
|
+
],
|
15
|
+
"dependencies": {},
|
16
|
+
"devDependencies": {
|
17
|
+
"coveralls": "^2.11.2",
|
18
|
+
"eslint": "^4.6.1",
|
19
|
+
"eslint-plugin-mocha": "^4.11.0",
|
20
|
+
"intelli-espower-loader": "^1.0.1",
|
21
|
+
"istanbul": "^0.3.2",
|
22
|
+
"mocha": "^3.5.2",
|
23
|
+
"power-assert": "^1.4.4"
|
24
|
+
},
|
25
|
+
"scripts": {
|
26
|
+
"test": "mocha --R intelli-espower-loader test/",
|
27
|
+
"travis": "npm run lint && npm run coverage",
|
28
|
+
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls",
|
29
|
+
"example": "node example",
|
30
|
+
"lint": "eslint ."
|
31
|
+
},
|
32
|
+
"repository": "https://github.com/strml/async-limiter.git",
|
33
|
+
"author": "Samuel Reed <samuel.trace.reed@gmail.com",
|
34
|
+
"license": "MIT"
|
35
|
+
}
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# Async-Limiter
|
2
|
+
|
3
|
+
A module for limiting concurrent asynchronous actions in flight. Forked from [queue](https://github.com/jessetane/queue).
|
4
|
+
|
5
|
+
[![npm](http://img.shields.io/npm/v/async-limiter.svg?style=flat-square)](http://www.npmjs.org/async-limiter)
|
6
|
+
[![tests](https://img.shields.io/travis/STRML/async-limiter.svg?style=flat-square&branch=master)](https://travis-ci.org/STRML/async-limiter)
|
7
|
+
[![coverage](https://img.shields.io/coveralls/STRML/async-limiter.svg?style=flat-square&branch=master)](https://coveralls.io/r/STRML/async-limiter)
|
8
|
+
|
9
|
+
This module exports a class `Limiter` that implements some of the `Array` API.
|
10
|
+
Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods.
|
11
|
+
|
12
|
+
## Motivation
|
13
|
+
|
14
|
+
Certain functions, like `zlib`, have [undesirable behavior](https://github.com/nodejs/node/issues/8871#issuecomment-250915913) when
|
15
|
+
run at infinite concurrency.
|
16
|
+
|
17
|
+
In this case, it is actually faster, and takes far less memory, to limit concurrency.
|
18
|
+
|
19
|
+
This module should do the absolute minimum work necessary to queue up functions. PRs are welcome that would
|
20
|
+
make this module faster or lighter, but new functionality is not desired.
|
21
|
+
|
22
|
+
Style should confirm to nodejs/node style.
|
23
|
+
|
24
|
+
## Example
|
25
|
+
|
26
|
+
``` javascript
|
27
|
+
var Limiter = require('async-limiter')
|
28
|
+
|
29
|
+
var t = new Limiter({concurrency: 2});
|
30
|
+
var results = []
|
31
|
+
|
32
|
+
// add jobs using the familiar Array API
|
33
|
+
t.push(function (cb) {
|
34
|
+
results.push('two')
|
35
|
+
cb()
|
36
|
+
})
|
37
|
+
|
38
|
+
t.push(
|
39
|
+
function (cb) {
|
40
|
+
results.push('four')
|
41
|
+
cb()
|
42
|
+
},
|
43
|
+
function (cb) {
|
44
|
+
results.push('five')
|
45
|
+
cb()
|
46
|
+
}
|
47
|
+
)
|
48
|
+
|
49
|
+
t.unshift(function (cb) {
|
50
|
+
results.push('one')
|
51
|
+
cb()
|
52
|
+
})
|
53
|
+
|
54
|
+
t.splice(2, 0, function (cb) {
|
55
|
+
results.push('three')
|
56
|
+
cb()
|
57
|
+
})
|
58
|
+
|
59
|
+
// Jobs run automatically. If you want a callback when all are done,
|
60
|
+
// call 'onDone()'.
|
61
|
+
t.onDone(function () {
|
62
|
+
console.log('all done:', results)
|
63
|
+
})
|
64
|
+
```
|
65
|
+
|
66
|
+
## Zlib Example
|
67
|
+
|
68
|
+
```js
|
69
|
+
const zlib = require('zlib');
|
70
|
+
const Limiter = require('async-limiter');
|
71
|
+
|
72
|
+
const message = {some: "data"};
|
73
|
+
const payload = new Buffer(JSON.stringify(message));
|
74
|
+
|
75
|
+
// Try with different concurrency values to see how this actually
|
76
|
+
// slows significantly with higher concurrency!
|
77
|
+
//
|
78
|
+
// 5: 1398.607ms
|
79
|
+
// 10: 1375.668ms
|
80
|
+
// Infinity: 4423.300ms
|
81
|
+
//
|
82
|
+
const t = new Limiter({concurrency: 5});
|
83
|
+
function deflate(payload, cb) {
|
84
|
+
t.push(function(done) {
|
85
|
+
zlib.deflate(payload, function(err, buffer) {
|
86
|
+
done();
|
87
|
+
cb(err, buffer);
|
88
|
+
});
|
89
|
+
});
|
90
|
+
}
|
91
|
+
|
92
|
+
console.time('deflate');
|
93
|
+
for(let i = 0; i < 30000; ++i) {
|
94
|
+
deflate(payload, function (err, buffer) {});
|
95
|
+
}
|
96
|
+
q.onDone(function() {
|
97
|
+
console.timeEnd('deflate');
|
98
|
+
});
|
99
|
+
```
|
100
|
+
|
101
|
+
## Install
|
102
|
+
|
103
|
+
`npm install async-limiter`
|
104
|
+
|
105
|
+
## Test
|
106
|
+
|
107
|
+
`npm test`
|
108
|
+
|
109
|
+
## API
|
110
|
+
|
111
|
+
### `var t = new Limiter([opts])`
|
112
|
+
Constructor. `opts` may contain inital values for:
|
113
|
+
* `q.concurrency`
|
114
|
+
|
115
|
+
## Instance methods
|
116
|
+
|
117
|
+
### `q.onDone(fn)`
|
118
|
+
`fn` will be called once and only once, when the queue is empty.
|
119
|
+
|
120
|
+
## Instance methods mixed in from `Array`
|
121
|
+
Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
|
122
|
+
### `q.push(element1, ..., elementN)`
|
123
|
+
### `q.unshift(element1, ..., elementN)`
|
124
|
+
### `q.splice(index , howMany[, element1[, ...[, elementN]]])`
|
125
|
+
|
126
|
+
## Properties
|
127
|
+
### `q.concurrency`
|
128
|
+
Max number of jobs the queue should process concurrently, defaults to `Infinity`.
|
129
|
+
|
130
|
+
### `q.length`
|
131
|
+
Jobs pending + jobs to process (readonly).
|
132
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
(MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
10
|
+
so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# balanced-match
|
2
|
+
|
3
|
+
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
|
4
|
+
|
5
|
+
[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
|
6
|
+
[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
|
7
|
+
|
8
|
+
[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
|
9
|
+
|
10
|
+
## Example
|
11
|
+
|
12
|
+
Get the first matching pair of braces:
|
13
|
+
|
14
|
+
```js
|
15
|
+
var balanced = require('balanced-match');
|
16
|
+
|
17
|
+
console.log(balanced('{', '}', 'pre{in{nested}}post'));
|
18
|
+
console.log(balanced('{', '}', 'pre{first}between{second}post'));
|
19
|
+
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
|
20
|
+
```
|
21
|
+
|
22
|
+
The matches are:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
$ node example.js
|
26
|
+
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
|
27
|
+
{ start: 3,
|
28
|
+
end: 9,
|
29
|
+
pre: 'pre',
|
30
|
+
body: 'first',
|
31
|
+
post: 'between{second}post' }
|
32
|
+
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
|
33
|
+
```
|
34
|
+
|
35
|
+
## API
|
36
|
+
|
37
|
+
### var m = balanced(a, b, str)
|
38
|
+
|
39
|
+
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
40
|
+
object with those keys:
|
41
|
+
|
42
|
+
* **start** the index of the first match of `a`
|
43
|
+
* **end** the index of the matching `b`
|
44
|
+
* **pre** the preamble, `a` and `b` not included
|
45
|
+
* **body** the match, `a` and `b` not included
|
46
|
+
* **post** the postscript, `a` and `b` not included
|
47
|
+
|
48
|
+
If there's no match, `undefined` will be returned.
|
49
|
+
|
50
|
+
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
|
51
|
+
|
52
|
+
### var r = balanced.range(a, b, str)
|
53
|
+
|
54
|
+
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
55
|
+
array with indexes: `[ <a index>, <b index> ]`.
|
56
|
+
|
57
|
+
If there's no match, `undefined` will be returned.
|
58
|
+
|
59
|
+
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
|
60
|
+
|
61
|
+
## Installation
|
62
|
+
|
63
|
+
With [npm](https://npmjs.org) do:
|
64
|
+
|
65
|
+
```bash
|
66
|
+
npm install balanced-match
|
67
|
+
```
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
(MIT)
|
72
|
+
|
73
|
+
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
74
|
+
|
75
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
76
|
+
this software and associated documentation files (the "Software"), to deal in
|
77
|
+
the Software without restriction, including without limitation the rights to
|
78
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
79
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
80
|
+
so, subject to the following conditions:
|
81
|
+
|
82
|
+
The above copyright notice and this permission notice shall be included in all
|
83
|
+
copies or substantial portions of the Software.
|
84
|
+
|
85
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
86
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
87
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
88
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
89
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
90
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
91
|
+
SOFTWARE.
|
@@ -0,0 +1,59 @@
|
|
1
|
+
'use strict';
|
2
|
+
module.exports = balanced;
|
3
|
+
function balanced(a, b, str) {
|
4
|
+
if (a instanceof RegExp) a = maybeMatch(a, str);
|
5
|
+
if (b instanceof RegExp) b = maybeMatch(b, str);
|
6
|
+
|
7
|
+
var r = range(a, b, str);
|
8
|
+
|
9
|
+
return r && {
|
10
|
+
start: r[0],
|
11
|
+
end: r[1],
|
12
|
+
pre: str.slice(0, r[0]),
|
13
|
+
body: str.slice(r[0] + a.length, r[1]),
|
14
|
+
post: str.slice(r[1] + b.length)
|
15
|
+
};
|
16
|
+
}
|
17
|
+
|
18
|
+
function maybeMatch(reg, str) {
|
19
|
+
var m = str.match(reg);
|
20
|
+
return m ? m[0] : null;
|
21
|
+
}
|
22
|
+
|
23
|
+
balanced.range = range;
|
24
|
+
function range(a, b, str) {
|
25
|
+
var begs, beg, left, right, result;
|
26
|
+
var ai = str.indexOf(a);
|
27
|
+
var bi = str.indexOf(b, ai + 1);
|
28
|
+
var i = ai;
|
29
|
+
|
30
|
+
if (ai >= 0 && bi > 0) {
|
31
|
+
begs = [];
|
32
|
+
left = str.length;
|
33
|
+
|
34
|
+
while (i >= 0 && !result) {
|
35
|
+
if (i == ai) {
|
36
|
+
begs.push(i);
|
37
|
+
ai = str.indexOf(a, i + 1);
|
38
|
+
} else if (begs.length == 1) {
|
39
|
+
result = [ begs.pop(), bi ];
|
40
|
+
} else {
|
41
|
+
beg = begs.pop();
|
42
|
+
if (beg < left) {
|
43
|
+
left = beg;
|
44
|
+
right = bi;
|
45
|
+
}
|
46
|
+
|
47
|
+
bi = str.indexOf(b, i + 1);
|
48
|
+
}
|
49
|
+
|
50
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
51
|
+
}
|
52
|
+
|
53
|
+
if (begs.length) {
|
54
|
+
result = [ left, right ];
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
return result;
|
59
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
{
|
2
|
+
"name": "balanced-match",
|
3
|
+
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
4
|
+
"version": "1.0.0",
|
5
|
+
"repository": {
|
6
|
+
"type": "git",
|
7
|
+
"url": "git://github.com/juliangruber/balanced-match.git"
|
8
|
+
},
|
9
|
+
"homepage": "https://github.com/juliangruber/balanced-match",
|
10
|
+
"main": "index.js",
|
11
|
+
"scripts": {
|
12
|
+
"test": "make test",
|
13
|
+
"bench": "make bench"
|
14
|
+
},
|
15
|
+
"dependencies": {},
|
16
|
+
"devDependencies": {
|
17
|
+
"matcha": "^0.7.0",
|
18
|
+
"tape": "^4.6.0"
|
19
|
+
},
|
20
|
+
"keywords": [
|
21
|
+
"match",
|
22
|
+
"regexp",
|
23
|
+
"test",
|
24
|
+
"balanced",
|
25
|
+
"parse"
|
26
|
+
],
|
27
|
+
"author": {
|
28
|
+
"name": "Julian Gruber",
|
29
|
+
"email": "mail@juliangruber.com",
|
30
|
+
"url": "http://juliangruber.com"
|
31
|
+
},
|
32
|
+
"license": "MIT",
|
33
|
+
"testling": {
|
34
|
+
"files": "test/*.js",
|
35
|
+
"browsers": [
|
36
|
+
"ie/8..latest",
|
37
|
+
"firefox/20..latest",
|
38
|
+
"firefox/nightly",
|
39
|
+
"chrome/25..latest",
|
40
|
+
"chrome/canary",
|
41
|
+
"opera/12..latest",
|
42
|
+
"opera/next",
|
43
|
+
"safari/5.1..latest",
|
44
|
+
"ipad/6.0..latest",
|
45
|
+
"iphone/6.0..latest",
|
46
|
+
"android-browser/4.2..latest"
|
47
|
+
]
|
48
|
+
}
|
49
|
+
}
|