diff options
author | isaacs <i@izs.me> | 2014-07-25 04:51:29 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2014-07-25 04:52:02 +0400 |
commit | ea547e29f1245e516fc67641875841c10f04e1ee (patch) | |
tree | d4ee0d8a6c49f20ce4a402f17bd4e350136c1a7b | |
parent | 33ccd13d161ff185d9c9c545013e0775f86c13ac (diff) |
Bump semver to version 3
This makes the '^' operator stricter for 0.x.y versions, even if 'x' is
not 0.
As a direct result, several *other* deps had to be updated, because they
either depended on semver 2.x, or because the new stricter rules meant
that they (or their deps) were no longer valid.
The update to 'read-installed', in particular, causes a test failure.
That update must be rolled back, or the test made to pass, prior to a
stable npm 2.0.0 release going out.
147 files changed, 19922 insertions, 1377 deletions
diff --git a/doc/misc/semver.md b/doc/misc/semver.md index 6c7d28061..67ba52e95 100644 --- a/doc/misc/semver.md +++ b/doc/misc/semver.md @@ -66,11 +66,11 @@ The following range styles are supported: prerelease) will be supported up to, but not including, the next major version (or its prereleases). `1.5.1` will satisfy `^1.2.3`, while `1.2.2` and `2.0.0-beta` will not. -* `^0.1.3` := `>=0.1.3-0 <0.2.0-0` "Compatible with `0.1.3`". `0.x.x` versions are - special: the first non-zero component indicates potentially breaking changes, - meaning the caret operator matches any version with the same first non-zero - component starting at the specified version. -* `^0.0.2` := `=0.0.2` "Only the version `0.0.2` is considered compatible" +* `^0.1.3` := `0.1.3` "Compatible with `0.1.3`". `0.x.x` versions are + special: since the semver spec specifies that `0.x.x` versions make + no stability guarantees, only the version specified is considered + valid. +* `^0.0.2` := `0.0.2` "Only the version `0.0.2` is considered compatible" * `~1.2` := `>=1.2.0-0 <1.3.0-0` "Any version starting with `1.2`" * `^1.2` := `>=1.2.0-0 <2.0.0-0` "Any version compatible with `1.2`" * `1.2.x` := `>=1.2.0-0 <1.3.0-0` "Any version starting with `1.2`" diff --git a/node_modules/columnify/node_modules/strip-ansi/cli.js b/node_modules/columnify/node_modules/strip-ansi/cli.js index 602ae00e8..f8019cdae 100755 --- a/node_modules/columnify/node_modules/strip-ansi/cli.js +++ b/node_modules/columnify/node_modules/strip-ansi/cli.js @@ -1,30 +1,18 @@ #!/usr/bin/env node 'use strict'; var fs = require('fs'); -var pkg = require('./package.json'); -var strip = require('./'); +var strip = require('./index'); var input = process.argv[2]; -function help() { - console.log([ - pkg.description, - '', - 'Usage', - ' $ strip-ansi <input-file> > <output-file>', - ' $ cat <input-file> | strip-ansi > <output-file>', - '', - 'Example', - ' $ strip-ansi unicorn.txt > unicorn-stripped.txt' - ].join('\n')); -} - -if (process.argv.indexOf('--help') !== -1) { - help(); +if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) { + console.log('strip-ansi <input file> > <output file>'); + console.log('or'); + console.log('cat <input file> | strip-ansi > <output file>'); return; } -if (process.argv.indexOf('--version') !== -1) { - console.log(pkg.version); +if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) { + console.log(require('./package').version); return; } diff --git a/node_modules/columnify/node_modules/strip-ansi/index.js b/node_modules/columnify/node_modules/strip-ansi/index.js index 11e072e4e..9ce2f3d48 100644 --- a/node_modules/columnify/node_modules/strip-ansi/index.js +++ b/node_modules/columnify/node_modules/strip-ansi/index.js @@ -1,6 +1,4 @@ 'use strict'; -var ansiRegex = require('ansi-regex'); - module.exports = function (str) { - return typeof str === 'string' ? str.replace(ansiRegex, '') : str; + return typeof str === 'string' ? str.replace(/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[m|K]/g, '') : str; }; diff --git a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/index.js b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/index.js deleted file mode 100644 index 182e43457..000000000 --- a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/index.js +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = /\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[m|K]/g; diff --git a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/package.json b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/package.json deleted file mode 100644 index 6b53e50dc..000000000 --- a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "ansi-regex", - "version": "0.1.0", - "description": "Regular expression for matching ANSI escape codes", - "license": "MIT", - "repository": { - "type": "git", - "url": "git://github.com/sindresorhus/ansi-regex" - }, - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "http://sindresorhus.com" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, - "files": [ - "index.js" - ], - "keywords": [ - "ansi", - "styles", - "color", - "colour", - "colors", - "terminal", - "console", - "cli", - "string", - "tty", - "escape", - "formatting", - "rgb", - "256", - "shell", - "xterm", - "command-line", - "text", - "regex", - "regexp", - "re" - ], - "devDependencies": { - "mocha": "*" - }, - "bugs": { - "url": "https://github.com/sindresorhus/ansi-regex/issues" - }, - "homepage": "https://github.com/sindresorhus/ansi-regex", - "_id": "ansi-regex@0.1.0", - "_shasum": "55ca60db6900857c423ae9297980026f941ed903", - "_from": "ansi-regex@^0.1.0", - "_npmVersion": "1.4.9", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "dist": { - "shasum": "55ca60db6900857c423ae9297980026f941ed903", - "tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.1.0.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.1.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/readme.md b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/readme.md deleted file mode 100644 index 72c248cd7..000000000 --- a/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +++ /dev/null @@ -1,28 +0,0 @@ -# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex) - -> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) - - -## Install - -```sh -$ npm install --save ansi-regex -``` - - -## Usage - -```js -var ansiRegex = require('ansi-regex'); - -ansiRegex.test('\x1b[4mcake\x1b[0m'); -//=> true - -ansiRegex.test('cake'); -//=> false -``` - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/columnify/node_modules/strip-ansi/package.json b/node_modules/columnify/node_modules/strip-ansi/package.json index ea6a22fe2..e0c5bc43f 100644 --- a/node_modules/columnify/node_modules/strip-ansi/package.json +++ b/node_modules/columnify/node_modules/strip-ansi/package.json @@ -1,7 +1,7 @@ { "name": "strip-ansi", - "version": "0.2.2", - "description": "Strip ANSI escape codes", + "version": "0.2.1", + "description": "Strip ANSI escape codes (used for colorizing strings in the terminal)", "license": "MIT", "bin": { "strip-ansi": "cli.js" @@ -50,9 +50,6 @@ "command-line", "text" ], - "dependencies": { - "ansi-regex": "^0.1.0" - }, "devDependencies": { "mocha": "*" }, @@ -60,10 +57,13 @@ "url": "https://github.com/sindresorhus/strip-ansi/issues" }, "homepage": "https://github.com/sindresorhus/strip-ansi", - "_id": "strip-ansi@0.2.2", - "_shasum": "854d290c981525fc8c397a910b025ae2d54ffc08", - "_from": "strip-ansi@^0.2.1", - "_npmVersion": "1.4.9", + "_id": "strip-ansi@0.2.1", + "dist": { + "shasum": "09218505ccf1083a41460150571355efabaa126e", + "tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-0.2.1.tgz" + }, + "_from": "strip-ansi@0.2.1", + "_npmVersion": "1.4.6", "_npmUser": { "name": "sindresorhus", "email": "sindresorhus@gmail.com" @@ -74,11 +74,7 @@ "email": "sindresorhus@gmail.com" } ], - "dist": { - "shasum": "854d290c981525fc8c397a910b025ae2d54ffc08", - "tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-0.2.2.tgz" - }, "directories": {}, - "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.2.2.tgz", - "readme": "ERROR: No README data found!" + "_shasum": "09218505ccf1083a41460150571355efabaa126e", + "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.2.1.tgz" } diff --git a/node_modules/columnify/node_modules/strip-ansi/readme.md b/node_modules/columnify/node_modules/strip-ansi/readme.md index 5477079d0..c6a0634fa 100644 --- a/node_modules/columnify/node_modules/strip-ansi/readme.md +++ b/node_modules/columnify/node_modules/strip-ansi/readme.md @@ -1,11 +1,13 @@ # strip-ansi [![Build Status](https://travis-ci.org/sindresorhus/strip-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-ansi) -> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) +> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) (used for colorizing strings in the terminal) + +Used in the terminal color module [chalk](https://github.com/sindresorhus/chalk). ## Install -```sh +```bash $ npm install --save strip-ansi ``` @@ -22,22 +24,23 @@ stripAnsi('\x1b[4mcake\x1b[0m'); ## CLI -```sh +You can also use it as a CLI app by installing it globally: + +```bash $ npm install --global strip-ansi ``` -```sh -$ strip-ansi --help +#### Usage -Usage - $ strip-ansi <input-file> > <output-file> - $ cat <input-file> | strip-ansi > <output-file> +```bash +$ strip-ansi --help -Example - $ strip-ansi unicorn.txt > unicorn-stripped.txt +strip-ansi <input-file> +or +cat <input-file> | strip-ansi ``` ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.editorconfig b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.editorconfig new file mode 100644 index 000000000..8e920719d --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.editorconfig @@ -0,0 +1,14 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[**.{js,json,html}] +indent_style = space +indent_size = 2 diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.gitignore b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.gitignore new file mode 100644 index 000000000..029616c3c --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.gitignore @@ -0,0 +1,2 @@ +raw +node_modules diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.travis.yml b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.travis.yml new file mode 100644 index 000000000..dbf89b3a4 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - 0.8 + - '0.10' +before_install: + - 'npm install npm -g' +notifications: + email: false diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CNAME b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CNAME new file mode 100644 index 000000000..a007e65c4 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CNAME @@ -0,0 +1 @@ +underscorejs.org diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CONTRIBUTING.md b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CONTRIBUTING.md new file mode 100644 index 000000000..8b22557d1 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CONTRIBUTING.md @@ -0,0 +1,11 @@ +## How to contribute to Underscore.js + +* Before you open a ticket or send a pull request, [search](https://github.com/jashkenas/underscore/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one. + +* If you're proposing a new feature, make sure it isn't already implemented in [Underscore-Contrib](https://github.com/documentcloud/underscore-contrib). + +* Before sending a pull request for a feature, be sure to have [tests](http://underscorejs.org/test/). + +* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/underscore/blob/master/underscore.js). + +* In your pull request, do not add documentation or re-build the minified `underscore-min.js` file. We'll do those things before cutting a new release. diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/bower.json b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/bower.json new file mode 100644 index 000000000..2d3e0291c --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/bower.json @@ -0,0 +1,7 @@ +{ + "name": "underscore", + "version": "1.6.0", + "main": "underscore.js", + "keywords": ["util", "functional", "server", "client", "browser"], + "ignore" : ["docs", "test", "*.yml", "CNAME", "index.html", "favicon.ico", "CONTRIBUTING.md"] +} diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/component.json b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/component.json new file mode 100644 index 000000000..bb1775e70 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/component.json @@ -0,0 +1,10 @@ +{ + "name" : "underscore", + "description" : "JavaScript's functional programming helper library.", + "keywords" : ["util", "functional", "server", "client", "browser"], + "repo" : "jashkenas/underscore", + "main" : "underscore.js", + "scripts" : ["underscore.js"], + "version" : "1.6.0", + "license" : "MIT" +} diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/docco.css b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/docco.css new file mode 100644 index 000000000..a2899ac87 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/docco.css @@ -0,0 +1,506 @@ +/*--------------------- Typography ----------------------------*/ + +@font-face { + font-family: 'aller-light'; + src: url('public/fonts/aller-light.eot'); + src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'), + url('public/fonts/aller-light.woff') format('woff'), + url('public/fonts/aller-light.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: 'aller-bold'; + src: url('public/fonts/aller-bold.eot'); + src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'), + url('public/fonts/aller-bold.woff') format('woff'), + url('public/fonts/aller-bold.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: 'novecento-bold'; + src: url('public/fonts/novecento-bold.eot'); + src: url('public/fonts/novecento-bold.eot?#iefix') format('embedded-opentype'), + url('public/fonts/novecento-bold.woff') format('woff'), + url('public/fonts/novecento-bold.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +/*--------------------- Layout ----------------------------*/ +html { height: 100%; } +body { + font-family: "aller-light"; + font-size: 14px; + line-height: 18px; + color: #30404f; + margin: 0; padding: 0; + height:100%; +} +#container { min-height: 100%; } + +a { + color: #000; +} + +b, strong { + font-weight: normal; + font-family: "aller-bold"; +} + +p { + margin: 15px 0 0px; +} + .annotation ul, .annotation ol { + margin: 25px 0; + } + .annotation ul li, .annotation ol li { + font-size: 14px; + line-height: 18px; + margin: 10px 0; + } + +h1, h2, h3, h4, h5, h6 { + color: #112233; + line-height: 1em; + font-weight: normal; + font-family: "novecento-bold"; + text-transform: uppercase; + margin: 30px 0 15px 0; +} + +h1 { + margin-top: 40px; +} + +hr { + border: 0; + background: 1px #ddd; + height: 1px; + margin: 20px 0; +} + +pre, tt, code { + font-size: 12px; line-height: 16px; + font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace; + margin: 0; padding: 0; +} + .annotation pre { + display: block; + margin: 0; + padding: 7px 10px; + background: #fcfcfc; + -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); + -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); + box-shadow: inset 0 0 10px rgba(0,0,0,0.1); + overflow-x: auto; + } + .annotation pre code { + border: 0; + padding: 0; + background: transparent; + } + + +blockquote { + border-left: 5px solid #ccc; + margin: 0; + padding: 1px 0 1px 1em; +} + .sections blockquote p { + font-family: Menlo, Consolas, Monaco, monospace; + font-size: 12px; line-height: 16px; + color: #999; + margin: 10px 0 0; + white-space: pre-wrap; + } + +ul.sections { + list-style: none; + padding:0 0 5px 0;; + margin:0; +} + +/* + Force border-box so that % widths fit the parent + container without overlap because of margin/padding. + + More Info : http://www.quirksmode.org/css/box.html +*/ +ul.sections > li > div { + -moz-box-sizing: border-box; /* firefox */ + -ms-box-sizing: border-box; /* ie */ + -webkit-box-sizing: border-box; /* webkit */ + -khtml-box-sizing: border-box; /* konqueror */ + box-sizing: border-box; /* css3 */ +} + + +/*---------------------- Jump Page -----------------------------*/ +#jump_to, #jump_page { + margin: 0; + background: white; + -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777; + -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; + font: 16px Arial; + cursor: pointer; + text-align: right; + list-style: none; +} + +#jump_to a { + text-decoration: none; +} + +#jump_to a.large { + display: none; +} +#jump_to a.small { + font-size: 22px; + font-weight: bold; + color: #676767; +} + +#jump_to, #jump_wrapper { + position: fixed; + right: 0; top: 0; + padding: 10px 15px; + margin:0; +} + +#jump_wrapper { + display: none; + padding:0; +} + +#jump_to:hover #jump_wrapper { + display: block; +} + +#jump_page { + padding: 5px 0 3px; + margin: 0 0 25px 25px; +} + +#jump_page .source { + display: block; + padding: 15px; + text-decoration: none; + border-top: 1px solid #eee; +} + +#jump_page .source:hover { + background: #f5f5ff; +} + +#jump_page .source:first-child { +} + +/*---------------------- Low resolutions (> 320px) ---------------------*/ +@media only screen and (min-width: 320px) { + .pilwrap { display: none; } + + ul.sections > li > div { + display: block; + padding:5px 10px 0 10px; + } + + ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { + padding-left: 30px; + } + + ul.sections > li > div.content { + overflow-x:auto; + -webkit-box-shadow: inset 0 0 5px #e5e5ee; + box-shadow: inset 0 0 5px #e5e5ee; + border: 1px solid #dedede; + margin:5px 10px 5px 10px; + padding-bottom: 5px; + } + + ul.sections > li > div.annotation pre { + margin: 7px 0 7px; + padding-left: 15px; + } + + ul.sections > li > div.annotation p tt, .annotation code { + background: #f8f8ff; + border: 1px solid #dedede; + font-size: 12px; + padding: 0 0.2em; + } +} + +/*---------------------- (> 481px) ---------------------*/ +@media only screen and (min-width: 481px) { + #container { + position: relative; + } + body { + background-color: #F5F5FF; + font-size: 15px; + line-height: 21px; + } + pre, tt, code { + line-height: 18px; + } + p, ul, ol { + margin: 0 0 15px; + } + + + #jump_to { + padding: 5px 10px; + } + #jump_wrapper { + padding: 0; + } + #jump_to, #jump_page { + font: 10px Arial; + text-transform: uppercase; + } + #jump_page .source { + padding: 5px 10px; + } + #jump_to a.large { + display: inline-block; + } + #jump_to a.small { + display: none; + } + + + + #background { + position: absolute; + top: 0; bottom: 0; + width: 350px; + background: #fff; + border-right: 1px solid #e5e5ee; + z-index: -1; + } + + ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { + padding-left: 40px; + } + + ul.sections > li { + white-space: nowrap; + } + + ul.sections > li > div { + display: inline-block; + } + + ul.sections > li > div.annotation { + max-width: 350px; + min-width: 350px; + min-height: 5px; + padding: 13px; + overflow-x: hidden; + white-space: normal; + vertical-align: top; + text-align: left; + } + ul.sections > li > div.annotation pre { + margin: 15px 0 15px; + padding-left: 15px; + } + + ul.sections > li > div.content { + padding: 13px; + vertical-align: top; + border: none; + -webkit-box-shadow: none; + box-shadow: none; + } + + .pilwrap { + position: relative; + display: inline; + } + + .pilcrow { + font: 12px Arial; + text-decoration: none; + color: #454545; + position: absolute; + top: 3px; left: -20px; + padding: 1px 2px; + opacity: 0; + -webkit-transition: opacity 0.2s linear; + } + .for-h1 .pilcrow { + top: 47px; + } + .for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow { + top: 35px; + } + + ul.sections > li > div.annotation:hover .pilcrow { + opacity: 1; + } +} + +/*---------------------- (> 1025px) ---------------------*/ +@media only screen and (min-width: 1025px) { + + body { + font-size: 16px; + line-height: 24px; + } + + #background { + width: 525px; + } + ul.sections > li > div.annotation { + max-width: 525px; + min-width: 525px; + padding: 10px 25px 1px 50px; + } + ul.sections > li > div.content { + padding: 9px 15px 16px 25px; + } +} + +/*---------------------- Syntax Highlighting -----------------------------*/ + +td.linenos { background-color: #f0f0f0; padding-right: 10px; } +span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } +/* + +github.com style (c) Vasily Polovnyov <vast@whiteants.net> + +*/ + +pre code { + display: block; padding: 0.5em; + color: #000; + background: #f8f8ff +} + +pre .hljs-comment, +pre .hljs-template_comment, +pre .hljs-diff .hljs-header, +pre .hljs-javadoc { + color: #408080; + font-style: italic +} + +pre .hljs-keyword, +pre .hljs-assignment, +pre .hljs-literal, +pre .hljs-css .hljs-rule .hljs-keyword, +pre .hljs-winutils, +pre .hljs-javascript .hljs-title, +pre .hljs-lisp .hljs-title, +pre .hljs-subst { + color: #954121; + /*font-weight: bold*/ +} + +pre .hljs-number, +pre .hljs-hexcolor { + color: #40a070 +} + +pre .hljs-string, +pre .hljs-tag .hljs-value, +pre .hljs-phpdoc, +pre .hljs-tex .hljs-formula { + color: #219161; +} + +pre .hljs-title, +pre .hljs-id { + color: #19469D; +} +pre .hljs-params { + color: #00F; +} + +pre .hljs-javascript .hljs-title, +pre .hljs-lisp .hljs-title, +pre .hljs-subst { + font-weight: normal +} + +pre .hljs-class .hljs-title, +pre .hljs-haskell .hljs-label, +pre .hljs-tex .hljs-command { + color: #458; + font-weight: bold +} + +pre .hljs-tag, +pre .hljs-tag .hljs-title, +pre .hljs-rules .hljs-property, +pre .hljs-django .hljs-tag .hljs-keyword { + color: #000080; + font-weight: normal +} + +pre .hljs-attribute, +pre .hljs-variable, +pre .hljs-instancevar, +pre .hljs-lisp .hljs-body { + color: #008080 +} + +pre .hljs-regexp { + color: #B68 +} + +pre .hljs-class { + color: #458; + font-weight: bold +} + +pre .hljs-symbol, +pre .hljs-ruby .hljs-symbol .hljs-string, +pre .hljs-ruby .hljs-symbol .hljs-keyword, +pre .hljs-ruby .hljs-symbol .hljs-keymethods, +pre .hljs-lisp .hljs-keyword, +pre .hljs-tex .hljs-special, +pre .hljs-input_number { + color: #990073 +} + +pre .hljs-builtin, +pre .hljs-constructor, +pre .hljs-built_in, +pre .hljs-lisp .hljs-title { + color: #0086b3 +} + +pre .hljs-preprocessor, +pre .hljs-pi, +pre .hljs-doctype, +pre .hljs-shebang, +pre .hljs-cdata { + color: #999; + font-weight: bold +} + +pre .hljs-deletion { + background: #fdd +} + +pre .hljs-addition { + background: #dfd +} + +pre .hljs-diff .hljs-change { + background: #0086b3 +} + +pre .hljs-chunk { + color: #aaa +} + +pre .hljs-tex .hljs-formula { + opacity: 0.5; +} diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/favicon.ico b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/favicon.ico Binary files differnew file mode 100644 index 000000000..030496838 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/favicon.ico diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/background.png b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/background.png Binary files differnew file mode 100644 index 000000000..90ee6934d --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/background.png diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/underscore.png b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/underscore.png Binary files differnew file mode 100644 index 000000000..3449cbe2a --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/underscore.png diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.eot b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.eot Binary files differnew file mode 100644 index 000000000..1b32532a8 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.eot diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.ttf b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.ttf Binary files differnew file mode 100644 index 000000000..dc4cc9c27 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.ttf diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.woff b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.woff Binary files differnew file mode 100644 index 000000000..fa16fd0ab --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.woff diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.eot b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.eot Binary files differnew file mode 100644 index 000000000..40bd654b5 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.eot diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.ttf b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.ttf Binary files differnew file mode 100644 index 000000000..c2c72902a --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.ttf diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.woff b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.woff Binary files differnew file mode 100644 index 000000000..81a09d18e --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.woff diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.eot b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.eot Binary files differnew file mode 100644 index 000000000..98a9a7fba --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.eot diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.ttf b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.ttf Binary files differnew file mode 100644 index 000000000..2af39b08b --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.ttf diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.woff b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.woff Binary files differnew file mode 100644 index 000000000..de558b5a2 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.woff diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/stylesheets/normalize.css b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/stylesheets/normalize.css new file mode 100644 index 000000000..73abb76fa --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/stylesheets/normalize.css @@ -0,0 +1,375 @@ +/*! normalize.css v2.0.1 | MIT License | git.io/normalize */ + +/* ========================================================================== + HTML5 display definitions + ========================================================================== */ + +/* + * Corrects `block` display not defined in IE 8/9. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section, +summary { + display: block; +} + +/* + * Corrects `inline-block` display not defined in IE 8/9. + */ + +audio, +canvas, +video { + display: inline-block; +} + +/* + * Prevents modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/* + * Addresses styling for `hidden` attribute not present in IE 8/9. + */ + +[hidden] { + display: none; +} + +/* ========================================================================== + Base + ========================================================================== */ + +/* + * 1. Sets default font family to sans-serif. + * 2. Prevents iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -webkit-text-size-adjust: 100%; /* 2 */ + -ms-text-size-adjust: 100%; /* 2 */ +} + +/* + * Removes default margin. + */ + +body { + margin: 0; +} + +/* ========================================================================== + Links + ========================================================================== */ + +/* + * Addresses `outline` inconsistency between Chrome and other browsers. + */ + +a:focus { + outline: thin dotted; +} + +/* + * Improves readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* ========================================================================== + Typography + ========================================================================== */ + +/* + * Addresses `h1` font sizes within `section` and `article` in Firefox 4+, + * Safari 5, and Chrome. + */ + +h1 { + font-size: 2em; +} + +/* + * Addresses styling not present in IE 8/9, Safari 5, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/* + * Addresses style set to `bolder` in Firefox 4+, Safari 5, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/* + * Addresses styling not present in Safari 5 and Chrome. + */ + +dfn { + font-style: italic; +} + +/* + * Addresses styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + + +/* + * Corrects font family set oddly in Safari 5 and Chrome. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, serif; + font-size: 1em; +} + +/* + * Improves readability of pre-formatted text in all browsers. + */ + +pre { + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +/* + * Sets consistent quote types. + */ + +q { + quotes: "\201C" "\201D" "\2018" "\2019"; +} + +/* + * Addresses inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/* + * Prevents `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* ========================================================================== + Embedded content + ========================================================================== */ + +/* + * Removes border when inside `a` element in IE 8/9. + */ + +img { + border: 0; +} + +/* + * Corrects overflow displayed oddly in IE 9. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* ========================================================================== + Figures + ========================================================================== */ + +/* + * Addresses margin not present in IE 8/9 and Safari 5. + */ + +figure { + margin: 0; +} + +/* ========================================================================== + Forms + ========================================================================== */ + +/* + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/* + * 1. Corrects color not being inherited in IE 8/9. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/* + * 1. Corrects font family not being inherited in all browsers. + * 2. Corrects font size not being inherited in all browsers. + * 3. Addresses margins set differently in Firefox 4+, Safari 5, and Chrome + */ + +button, +input, +select, +textarea { + font-family: inherit; /* 1 */ + font-size: 100%; /* 2 */ + margin: 0; /* 3 */ +} + +/* + * Addresses Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +button, +input { + line-height: normal; +} + +/* + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Corrects inability to style clickable `input` types in iOS. + * 3. Improves usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/* + * Re-set default cursor for disabled elements. + */ + +button[disabled], +input[disabled] { + cursor: default; +} + +/* + * 1. Addresses box sizing set to `content-box` in IE 8/9. + * 2. Removes excess padding in IE 8/9. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/* + * 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome. + * 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/* + * Removes inner padding and search cancel button in Safari 5 and Chrome + * on OS X. + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/* + * Removes inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/* + * 1. Removes default vertical scrollbar in IE 8/9. + * 2. Improves readability and alignment in all browsers. + */ + +textarea { + overflow: auto; /* 1 */ + vertical-align: top; /* 2 */ +} + +/* ========================================================================== + Tables + ========================================================================== */ + +/* + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +}
\ No newline at end of file diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/underscore.html b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/underscore.html new file mode 100644 index 000000000..014d5dece --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/underscore.html @@ -0,0 +1,3261 @@ +<!DOCTYPE html> + +<html> +<head> + <title>underscore.js</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8"> + <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> + <link rel="stylesheet" media="all" href="docco.css" /> +</head> +<body> + <div id="container"> + <div id="background"></div> + + <ul class="sections"> + + <li id="title"> + <div class="annotation"> + <h1>underscore.js</h1> + </div> + </li> + + + + <li id="section-1"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-1">¶</a> + </div> + <pre><code>Underscore.js <span class="hljs-number">1.6</span><span class="hljs-number">.0</span> +http:<span class="hljs-comment">//underscorejs.org</span> +(c) <span class="hljs-number">2009</span>-<span class="hljs-number">2014</span> Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +Underscore may be freely distributed under the MIT license. +</code></pre> + </div> + + <div class="content"><div class='highlight'><pre> +(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span></pre></div></div> + + </li> + + + <li id="section-2"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-2">¶</a> + </div> + <h2 id="baseline-setup">Baseline setup</h2> + + </div> + + </li> + + + <li id="section-3"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-3">¶</a> + </div> + + </div> + + </li> + + + <li id="section-4"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-4">¶</a> + </div> + <p>Establish the root object, <code>window</code> in the browser, or <code>exports</code> on the server.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> root = <span class="hljs-keyword">this</span>;</pre></div></div> + + </li> + + + <li id="section-5"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-5">¶</a> + </div> + <p>Save the previous value of the <code>_</code> variable.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> previousUnderscore = root._;</pre></div></div> + + </li> + + + <li id="section-6"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-6">¶</a> + </div> + <p>Establish the object that gets returned to break out of a loop iteration.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> breaker = {};</pre></div></div> + + </li> + + + <li id="section-7"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-7">¶</a> + </div> + <p>Save bytes in the minified (but not gzipped) version:</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> ArrayProto = <span class="hljs-built_in">Array</span>.prototype, ObjProto = <span class="hljs-built_in">Object</span>.prototype, FuncProto = <span class="hljs-built_in">Function</span>.prototype;</pre></div></div> + + </li> + + + <li id="section-8"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-8">¶</a> + </div> + <p>Create quick reference variables for speed access to core prototypes.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> + push = ArrayProto.push, + slice = ArrayProto.slice, + concat = ArrayProto.concat, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty;</pre></div></div> + + </li> + + + <li id="section-9"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-9">¶</a> + </div> + <p>All <strong>ECMAScript 5</strong> native function implementations that we hope to use +are declared here.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> + nativeForEach = ArrayProto.forEach, + nativeMap = ArrayProto.map, + nativeReduce = ArrayProto.reduce, + nativeReduceRight = ArrayProto.reduceRight, + nativeFilter = ArrayProto.filter, + nativeEvery = ArrayProto.every, + nativeSome = ArrayProto.some, + nativeIndexOf = ArrayProto.indexOf, + nativeLastIndexOf = ArrayProto.lastIndexOf, + nativeIsArray = <span class="hljs-built_in">Array</span>.isArray, + nativeKeys = <span class="hljs-built_in">Object</span>.keys, + nativeBind = FuncProto.bind;</pre></div></div> + + </li> + + + <li id="section-10"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-10">¶</a> + </div> + <p>Create a safe reference to the Underscore object for use below.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> _ = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">if</span> (obj <span class="hljs-keyword">instanceof</span> _) <span class="hljs-keyword">return</span> obj; + <span class="hljs-keyword">if</span> (!(<span class="hljs-keyword">this</span> <span class="hljs-keyword">instanceof</span> _)) <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> _(obj); + <span class="hljs-keyword">this</span>._wrapped = obj; + };</pre></div></div> + + </li> + + + <li id="section-11"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-11">¶</a> + </div> + <p>Export the Underscore object for <strong>Node.js</strong>, with +backwards-compatibility for the old <code>require()</code> API. If we’re in +the browser, add <code>_</code> as a global object via a string identifier, +for Closure Compiler “advanced” mode.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> exports !== <span class="hljs-string">'undefined'</span>) { + <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> module !== <span class="hljs-string">'undefined'</span> && module.exports) { + exports = module.exports = _; + } + exports._ = _; + } <span class="hljs-keyword">else</span> { + root._ = _; + }</pre></div></div> + + </li> + + + <li id="section-12"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-12">¶</a> + </div> + <p>Current version.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.VERSION = <span class="hljs-string">'1.6.0'</span>;</pre></div></div> + + </li> + + + <li id="section-13"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-13">¶</a> + </div> + <h2 id="collection-functions">Collection Functions</h2> + + </div> + + </li> + + + <li id="section-14"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-14">¶</a> + </div> + + </div> + + </li> + + + <li id="section-15"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-15">¶</a> + </div> + <p>The cornerstone, an <code>each</code> implementation, aka <code>forEach</code>. +Handles objects with the built-in <code>forEach</code>, arrays, and raw objects. +Delegates to <strong>ECMAScript 5</strong>‘s native <code>forEach</code> if available.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> each = _.each = _.forEach = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, iterator, context)</span> {</span> + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> obj; + <span class="hljs-keyword">if</span> (nativeForEach && obj.forEach === nativeForEach) { + obj.forEach(iterator, context); + } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (obj.length === +obj.length) { + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, length = obj.length; i < length; i++) { + <span class="hljs-keyword">if</span> (iterator.call(context, obj[i], i, obj) === breaker) <span class="hljs-keyword">return</span>; + } + } <span class="hljs-keyword">else</span> { + <span class="hljs-keyword">var</span> keys = _.keys(obj); + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, length = keys.length; i < length; i++) { + <span class="hljs-keyword">if</span> (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) <span class="hljs-keyword">return</span>; + } + } + <span class="hljs-keyword">return</span> obj; + };</pre></div></div> + + </li> + + + <li id="section-16"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-16">¶</a> + </div> + <p>Return the results of applying the iterator to each element. +Delegates to <strong>ECMAScript 5</strong>‘s native <code>map</code> if available.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.map = _.collect = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, iterator, context)</span> {</span> + <span class="hljs-keyword">var</span> results = []; + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> results; + <span class="hljs-keyword">if</span> (nativeMap && obj.map === nativeMap) <span class="hljs-keyword">return</span> obj.map(iterator, context); + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + results.push(iterator.call(context, value, index, list)); + }); + <span class="hljs-keyword">return</span> results; + }; + + <span class="hljs-keyword">var</span> reduceError = <span class="hljs-string">'Reduce of empty array with no initial value'</span>;</pre></div></div> + + </li> + + + <li id="section-17"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-17">¶</a> + </div> + <p><strong>Reduce</strong> builds up a single result from a list of values, aka <code>inject</code>, +or <code>foldl</code>. Delegates to <strong>ECMAScript 5</strong>‘s native <code>reduce</code> if available.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.reduce = _.foldl = _.inject = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, iterator, memo, context)</span> {</span> + <span class="hljs-keyword">var</span> initial = <span class="hljs-built_in">arguments</span>.length > <span class="hljs-number">2</span>; + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) obj = []; + <span class="hljs-keyword">if</span> (nativeReduce && obj.reduce === nativeReduce) { + <span class="hljs-keyword">if</span> (context) iterator = _.bind(iterator, context); + <span class="hljs-keyword">return</span> initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); + } + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + <span class="hljs-keyword">if</span> (!initial) { + memo = value; + initial = <span class="hljs-literal">true</span>; + } <span class="hljs-keyword">else</span> { + memo = iterator.call(context, memo, value, index, list); + } + }); + <span class="hljs-keyword">if</span> (!initial) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">TypeError</span>(reduceError); + <span class="hljs-keyword">return</span> memo; + };</pre></div></div> + + </li> + + + <li id="section-18"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-18">¶</a> + </div> + <p>The right-associative version of reduce, also known as <code>foldr</code>. +Delegates to <strong>ECMAScript 5</strong>‘s native <code>reduceRight</code> if available.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.reduceRight = _.foldr = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, iterator, memo, context)</span> {</span> + <span class="hljs-keyword">var</span> initial = <span class="hljs-built_in">arguments</span>.length > <span class="hljs-number">2</span>; + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) obj = []; + <span class="hljs-keyword">if</span> (nativeReduceRight && obj.reduceRight === nativeReduceRight) { + <span class="hljs-keyword">if</span> (context) iterator = _.bind(iterator, context); + <span class="hljs-keyword">return</span> initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); + } + <span class="hljs-keyword">var</span> length = obj.length; + <span class="hljs-keyword">if</span> (length !== +length) { + <span class="hljs-keyword">var</span> keys = _.keys(obj); + length = keys.length; + } + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + index = keys ? keys[--length] : --length; + <span class="hljs-keyword">if</span> (!initial) { + memo = obj[index]; + initial = <span class="hljs-literal">true</span>; + } <span class="hljs-keyword">else</span> { + memo = iterator.call(context, memo, obj[index], index, list); + } + }); + <span class="hljs-keyword">if</span> (!initial) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">TypeError</span>(reduceError); + <span class="hljs-keyword">return</span> memo; + };</pre></div></div> + + </li> + + + <li id="section-19"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-19">¶</a> + </div> + <p>Return the first value which passes a truth test. Aliased as <code>detect</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.find = _.detect = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, predicate, context)</span> {</span> + <span class="hljs-keyword">var</span> result; + any(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + <span class="hljs-keyword">if</span> (predicate.call(context, value, index, list)) { + result = value; + <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>; + } + }); + <span class="hljs-keyword">return</span> result; + };</pre></div></div> + + </li> + + + <li id="section-20"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-20">¶</a> + </div> + <p>Return all the elements that pass a truth test. +Delegates to <strong>ECMAScript 5</strong>‘s native <code>filter</code> if available. +Aliased as <code>select</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.filter = _.select = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, predicate, context)</span> {</span> + <span class="hljs-keyword">var</span> results = []; + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> results; + <span class="hljs-keyword">if</span> (nativeFilter && obj.filter === nativeFilter) <span class="hljs-keyword">return</span> obj.filter(predicate, context); + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + <span class="hljs-keyword">if</span> (predicate.call(context, value, index, list)) results.push(value); + }); + <span class="hljs-keyword">return</span> results; + };</pre></div></div> + + </li> + + + <li id="section-21"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-21">¶</a> + </div> + <p>Return all the elements for which a truth test fails.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.reject = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, predicate, context)</span> {</span> + <span class="hljs-keyword">return</span> _.filter(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + <span class="hljs-keyword">return</span> !predicate.call(context, value, index, list); + }, context); + };</pre></div></div> + + </li> + + + <li id="section-22"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-22">¶</a> + </div> + <p>Determine whether all of the elements match a truth test. +Delegates to <strong>ECMAScript 5</strong>‘s native <code>every</code> if available. +Aliased as <code>all</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.every = _.all = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, predicate, context)</span> {</span> + predicate || (predicate = _.identity); + <span class="hljs-keyword">var</span> result = <span class="hljs-literal">true</span>; + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> result; + <span class="hljs-keyword">if</span> (nativeEvery && obj.every === nativeEvery) <span class="hljs-keyword">return</span> obj.every(predicate, context); + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + <span class="hljs-keyword">if</span> (!(result = result && predicate.call(context, value, index, list))) <span class="hljs-keyword">return</span> breaker; + }); + <span class="hljs-keyword">return</span> !!result; + };</pre></div></div> + + </li> + + + <li id="section-23"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-23">¶</a> + </div> + <p>Determine if at least one element in the object matches a truth test. +Delegates to <strong>ECMAScript 5</strong>‘s native <code>some</code> if available. +Aliased as <code>any</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> any = _.some = _.any = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, predicate, context)</span> {</span> + predicate || (predicate = _.identity); + <span class="hljs-keyword">var</span> result = <span class="hljs-literal">false</span>; + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> result; + <span class="hljs-keyword">if</span> (nativeSome && obj.some === nativeSome) <span class="hljs-keyword">return</span> obj.some(predicate, context); + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + <span class="hljs-keyword">if</span> (result || (result = predicate.call(context, value, index, list))) <span class="hljs-keyword">return</span> breaker; + }); + <span class="hljs-keyword">return</span> !!result; + };</pre></div></div> + + </li> + + + <li id="section-24"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-24">¶</a> + </div> + <p>Determine if the array or object contains a given value (using <code>===</code>). +Aliased as <code>include</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.contains = _.include = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, target)</span> {</span> + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>; + <span class="hljs-keyword">if</span> (nativeIndexOf && obj.indexOf === nativeIndexOf) <span class="hljs-keyword">return</span> obj.indexOf(target) != -<span class="hljs-number">1</span>; + <span class="hljs-keyword">return</span> any(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value)</span> {</span> + <span class="hljs-keyword">return</span> value === target; + }); + };</pre></div></div> + + </li> + + + <li id="section-25"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-25">¶</a> + </div> + <p>Invoke a method (with arguments) on every item in a collection.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.invoke = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, method)</span> {</span> + <span class="hljs-keyword">var</span> args = slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">2</span>); + <span class="hljs-keyword">var</span> isFunc = _.isFunction(method); + <span class="hljs-keyword">return</span> _.map(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value)</span> {</span> + <span class="hljs-keyword">return</span> (isFunc ? method : value[method]).apply(value, args); + }); + };</pre></div></div> + + </li> + + + <li id="section-26"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-26">¶</a> + </div> + <p>Convenience version of a common use case of <code>map</code>: fetching a property.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.pluck = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, key)</span> {</span> + <span class="hljs-keyword">return</span> _.map(obj, _.property(key)); + };</pre></div></div> + + </li> + + + <li id="section-27"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-27">¶</a> + </div> + <p>Convenience version of a common use case of <code>filter</code>: selecting only objects +containing specific <code>key:value</code> pairs.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.where = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, attrs)</span> {</span> + <span class="hljs-keyword">return</span> _.filter(obj, _.matches(attrs)); + };</pre></div></div> + + </li> + + + <li id="section-28"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-28">¶</a> + </div> + <p>Convenience version of a common use case of <code>find</code>: getting the first object +containing specific <code>key:value</code> pairs.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.findWhere = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, attrs)</span> {</span> + <span class="hljs-keyword">return</span> _.find(obj, _.matches(attrs)); + };</pre></div></div> + + </li> + + + <li id="section-29"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-29">¶</a> + </div> + <p>Return the maximum element or (element-based computation). +Can’t optimize arrays of integers longer than 65,535 elements. +See <a href="https://bugs.webkit.org/show_bug.cgi?id=80797">WebKit Bug 80797</a></p> + + </div> + + <div class="content"><div class='highlight'><pre> _.max = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, iterator, context)</span> {</span> + <span class="hljs-keyword">if</span> (!iterator && _.isArray(obj) && obj[<span class="hljs-number">0</span>] === +obj[<span class="hljs-number">0</span>] && obj.length < <span class="hljs-number">65535</span>) { + <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.max.apply(<span class="hljs-built_in">Math</span>, obj); + } + <span class="hljs-keyword">var</span> result = -<span class="hljs-literal">Infinity</span>, lastComputed = -<span class="hljs-literal">Infinity</span>; + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + <span class="hljs-keyword">var</span> computed = iterator ? iterator.call(context, value, index, list) : value; + <span class="hljs-keyword">if</span> (computed > lastComputed) { + result = value; + lastComputed = computed; + } + }); + <span class="hljs-keyword">return</span> result; + };</pre></div></div> + + </li> + + + <li id="section-30"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-30">¶</a> + </div> + <p>Return the minimum element (or element-based computation).</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.min = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, iterator, context)</span> {</span> + <span class="hljs-keyword">if</span> (!iterator && _.isArray(obj) && obj[<span class="hljs-number">0</span>] === +obj[<span class="hljs-number">0</span>] && obj.length < <span class="hljs-number">65535</span>) { + <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.min.apply(<span class="hljs-built_in">Math</span>, obj); + } + <span class="hljs-keyword">var</span> result = <span class="hljs-literal">Infinity</span>, lastComputed = <span class="hljs-literal">Infinity</span>; + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + <span class="hljs-keyword">var</span> computed = iterator ? iterator.call(context, value, index, list) : value; + <span class="hljs-keyword">if</span> (computed < lastComputed) { + result = value; + lastComputed = computed; + } + }); + <span class="hljs-keyword">return</span> result; + };</pre></div></div> + + </li> + + + <li id="section-31"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-31">¶</a> + </div> + <p>Shuffle an array, using the modern version of the +<a href="http://en.wikipedia.org/wiki/Fisher–Yates_shuffle">Fisher-Yates shuffle</a>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.shuffle = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">var</span> rand; + <span class="hljs-keyword">var</span> index = <span class="hljs-number">0</span>; + <span class="hljs-keyword">var</span> shuffled = []; + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value)</span> {</span> + rand = _.random(index++); + shuffled[index - <span class="hljs-number">1</span>] = shuffled[rand]; + shuffled[rand] = value; + }); + <span class="hljs-keyword">return</span> shuffled; + };</pre></div></div> + + </li> + + + <li id="section-32"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-32">¶</a> + </div> + <p>Sample <strong>n</strong> random values from a collection. +If <strong>n</strong> is not specified, returns a single random element. +The internal <code>guard</code> argument allows it to work with <code>map</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.sample = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, n, guard)</span> {</span> + <span class="hljs-keyword">if</span> (n == <span class="hljs-literal">null</span> || guard) { + <span class="hljs-keyword">if</span> (obj.length !== +obj.length) obj = _.values(obj); + <span class="hljs-keyword">return</span> obj[_.random(obj.length - <span class="hljs-number">1</span>)]; + } + <span class="hljs-keyword">return</span> _.shuffle(obj).slice(<span class="hljs-number">0</span>, <span class="hljs-built_in">Math</span>.max(<span class="hljs-number">0</span>, n)); + };</pre></div></div> + + </li> + + + <li id="section-33"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-33">¶</a> + </div> + <p>An internal function to generate lookup iterators.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> lookupIterator = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value)</span> {</span> + <span class="hljs-keyword">if</span> (value == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> _.identity; + <span class="hljs-keyword">if</span> (_.isFunction(value)) <span class="hljs-keyword">return</span> value; + <span class="hljs-keyword">return</span> _.property(value); + };</pre></div></div> + + </li> + + + <li id="section-34"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-34">¶</a> + </div> + <p>Sort the object’s values by a criterion produced by an iterator.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.sortBy = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, iterator, context)</span> {</span> + iterator = lookupIterator(iterator); + <span class="hljs-keyword">return</span> _.pluck(_.map(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index, list)</span> {</span> + <span class="hljs-keyword">return</span> { + value: value, + index: index, + criteria: iterator.call(context, value, index, list) + }; + }).sort(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(left, right)</span> {</span> + <span class="hljs-keyword">var</span> a = left.criteria; + <span class="hljs-keyword">var</span> b = right.criteria; + <span class="hljs-keyword">if</span> (a !== b) { + <span class="hljs-keyword">if</span> (a > b || a === <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>) <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>; + <span class="hljs-keyword">if</span> (a < b || b === <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>) <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>; + } + <span class="hljs-keyword">return</span> left.index - right.index; + }), <span class="hljs-string">'value'</span>); + };</pre></div></div> + + </li> + + + <li id="section-35"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-35">¶</a> + </div> + <p>An internal function used for aggregate “group by” operations.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> group = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(behavior)</span> {</span> + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, iterator, context)</span> {</span> + <span class="hljs-keyword">var</span> result = {}; + iterator = lookupIterator(iterator); + each(obj, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index)</span> {</span> + <span class="hljs-keyword">var</span> key = iterator.call(context, value, index, obj); + behavior(result, key, value); + }); + <span class="hljs-keyword">return</span> result; + }; + };</pre></div></div> + + </li> + + + <li id="section-36"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-36">¶</a> + </div> + <p>Groups the object’s values by a criterion. Pass either a string attribute +to group by, or a function that returns the criterion.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.groupBy = group(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(result, key, value)</span> {</span> + _.has(result, key) ? result[key].push(value) : result[key] = [value]; + });</pre></div></div> + + </li> + + + <li id="section-37"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-37">¶</a> + </div> + <p>Indexes the object’s values by a criterion, similar to <code>groupBy</code>, but for +when you know that your index values will be unique.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.indexBy = group(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(result, key, value)</span> {</span> + result[key] = value; + });</pre></div></div> + + </li> + + + <li id="section-38"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-38">¶</a> + </div> + <p>Counts instances of an object that group by a certain criterion. Pass +either a string attribute to count by, or a function that returns the +criterion.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.countBy = group(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(result, key)</span> {</span> + _.has(result, key) ? result[key]++ : result[key] = <span class="hljs-number">1</span>; + });</pre></div></div> + + </li> + + + <li id="section-39"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-39">¶</a> + </div> + <p>Use a comparator function to figure out the smallest index at which +an object should be inserted so as to maintain order. Uses binary search.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.sortedIndex = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, obj, iterator, context)</span> {</span> + iterator = lookupIterator(iterator); + <span class="hljs-keyword">var</span> value = iterator.call(context, obj); + <span class="hljs-keyword">var</span> low = <span class="hljs-number">0</span>, high = array.length; + <span class="hljs-keyword">while</span> (low < high) { + <span class="hljs-keyword">var</span> mid = (low + high) >>> <span class="hljs-number">1</span>; + iterator.call(context, array[mid]) < value ? low = mid + <span class="hljs-number">1</span> : high = mid; + } + <span class="hljs-keyword">return</span> low; + };</pre></div></div> + + </li> + + + <li id="section-40"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-40">¶</a> + </div> + <p>Safely create a real, live array from anything iterable.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.toArray = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">if</span> (!obj) <span class="hljs-keyword">return</span> []; + <span class="hljs-keyword">if</span> (_.isArray(obj)) <span class="hljs-keyword">return</span> slice.call(obj); + <span class="hljs-keyword">if</span> (obj.length === +obj.length) <span class="hljs-keyword">return</span> _.map(obj, _.identity); + <span class="hljs-keyword">return</span> _.values(obj); + };</pre></div></div> + + </li> + + + <li id="section-41"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-41">¶</a> + </div> + <p>Return the number of elements in an object.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.size = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>; + <span class="hljs-keyword">return</span> (obj.length === +obj.length) ? obj.length : _.keys(obj).length; + };</pre></div></div> + + </li> + + + <li id="section-42"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-42">¶</a> + </div> + <h2 id="array-functions">Array Functions</h2> + + </div> + + </li> + + + <li id="section-43"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-43">¶</a> + </div> + + </div> + + </li> + + + <li id="section-44"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-44">¶</a> + </div> + <p>Get the first element of an array. Passing <strong>n</strong> will return the first N +values in the array. Aliased as <code>head</code> and <code>take</code>. The <strong>guard</strong> check +allows it to work with <code>_.map</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.first = _.head = _.take = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, n, guard)</span> {</span> + <span class="hljs-keyword">if</span> (array == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>; + <span class="hljs-keyword">if</span> ((n == <span class="hljs-literal">null</span>) || guard) <span class="hljs-keyword">return</span> array[<span class="hljs-number">0</span>]; + <span class="hljs-keyword">if</span> (n < <span class="hljs-number">0</span>) <span class="hljs-keyword">return</span> []; + <span class="hljs-keyword">return</span> slice.call(array, <span class="hljs-number">0</span>, n); + };</pre></div></div> + + </li> + + + <li id="section-45"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-45">¶</a> + </div> + <p>Returns everything but the last entry of the array. Especially useful on +the arguments object. Passing <strong>n</strong> will return all the values in +the array, excluding the last N. The <strong>guard</strong> check allows it to work with +<code>_.map</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.initial = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, n, guard)</span> {</span> + <span class="hljs-keyword">return</span> slice.call(array, <span class="hljs-number">0</span>, array.length - ((n == <span class="hljs-literal">null</span>) || guard ? <span class="hljs-number">1</span> : n)); + };</pre></div></div> + + </li> + + + <li id="section-46"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-46">¶</a> + </div> + <p>Get the last element of an array. Passing <strong>n</strong> will return the last N +values in the array. The <strong>guard</strong> check allows it to work with <code>_.map</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.last = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, n, guard)</span> {</span> + <span class="hljs-keyword">if</span> (array == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>; + <span class="hljs-keyword">if</span> ((n == <span class="hljs-literal">null</span>) || guard) <span class="hljs-keyword">return</span> array[array.length - <span class="hljs-number">1</span>]; + <span class="hljs-keyword">return</span> slice.call(array, <span class="hljs-built_in">Math</span>.max(array.length - n, <span class="hljs-number">0</span>)); + };</pre></div></div> + + </li> + + + <li id="section-47"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-47">¶</a> + </div> + <p>Returns everything but the first entry of the array. Aliased as <code>tail</code> and <code>drop</code>. +Especially useful on the arguments object. Passing an <strong>n</strong> will return +the rest N values in the array. The <strong>guard</strong> +check allows it to work with <code>_.map</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.rest = _.tail = _.drop = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, n, guard)</span> {</span> + <span class="hljs-keyword">return</span> slice.call(array, (n == <span class="hljs-literal">null</span>) || guard ? <span class="hljs-number">1</span> : n); + };</pre></div></div> + + </li> + + + <li id="section-48"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-48">¶</a> + </div> + <p>Trim out all falsy values from an array.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.compact = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array)</span> {</span> + <span class="hljs-keyword">return</span> _.filter(array, _.identity); + };</pre></div></div> + + </li> + + + <li id="section-49"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-49">¶</a> + </div> + <p>Internal implementation of a recursive <code>flatten</code> function.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> flatten = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(input, shallow, output)</span> {</span> + <span class="hljs-keyword">if</span> (shallow && _.every(input, _.isArray)) { + <span class="hljs-keyword">return</span> concat.apply(output, input); + } + each(input, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value)</span> {</span> + <span class="hljs-keyword">if</span> (_.isArray(value) || _.isArguments(value)) { + shallow ? push.apply(output, value) : flatten(value, shallow, output); + } <span class="hljs-keyword">else</span> { + output.push(value); + } + }); + <span class="hljs-keyword">return</span> output; + };</pre></div></div> + + </li> + + + <li id="section-50"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-50">¶</a> + </div> + <p>Flatten out an array, either recursively (by default), or just one level.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.flatten = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, shallow)</span> {</span> + <span class="hljs-keyword">return</span> flatten(array, shallow, []); + };</pre></div></div> + + </li> + + + <li id="section-51"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-51">¶</a> + </div> + <p>Return a version of the array that does not contain the specified value(s).</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.without = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array)</span> {</span> + <span class="hljs-keyword">return</span> _.difference(array, slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>)); + };</pre></div></div> + + </li> + + + <li id="section-52"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-52">¶</a> + </div> + <p>Split an array into two arrays: one whose elements all satisfy the given +predicate, and one whose elements all do not satisfy the predicate.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.partition = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, predicate)</span> {</span> + <span class="hljs-keyword">var</span> pass = [], fail = []; + each(array, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(elem)</span> {</span> + (predicate(elem) ? pass : fail).push(elem); + }); + <span class="hljs-keyword">return</span> [pass, fail]; + };</pre></div></div> + + </li> + + + <li id="section-53"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-53">¶</a> + </div> + <p>Produce a duplicate-free version of the array. If the array has already +been sorted, you have the option of using a faster algorithm. +Aliased as <code>unique</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.uniq = _.unique = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, isSorted, iterator, context)</span> {</span> + <span class="hljs-keyword">if</span> (_.isFunction(isSorted)) { + context = iterator; + iterator = isSorted; + isSorted = <span class="hljs-literal">false</span>; + } + <span class="hljs-keyword">var</span> initial = iterator ? _.map(array, iterator, context) : array; + <span class="hljs-keyword">var</span> results = []; + <span class="hljs-keyword">var</span> seen = []; + each(initial, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value, index)</span> {</span> + <span class="hljs-keyword">if</span> (isSorted ? (!index || seen[seen.length - <span class="hljs-number">1</span>] !== value) : !_.contains(seen, value)) { + seen.push(value); + results.push(array[index]); + } + }); + <span class="hljs-keyword">return</span> results; + };</pre></div></div> + + </li> + + + <li id="section-54"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-54">¶</a> + </div> + <p>Produce an array that contains the union: each distinct element from all of +the passed-in arrays.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.union = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">return</span> _.uniq(_.flatten(<span class="hljs-built_in">arguments</span>, <span class="hljs-literal">true</span>)); + };</pre></div></div> + + </li> + + + <li id="section-55"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-55">¶</a> + </div> + <p>Produce an array that contains every item shared between all the +passed-in arrays.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.intersection = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array)</span> {</span> + <span class="hljs-keyword">var</span> rest = slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>); + <span class="hljs-keyword">return</span> _.filter(_.uniq(array), <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(item)</span> {</span> + <span class="hljs-keyword">return</span> _.every(rest, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(other)</span> {</span> + <span class="hljs-keyword">return</span> _.contains(other, item); + }); + }); + };</pre></div></div> + + </li> + + + <li id="section-56"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-56">¶</a> + </div> + <p>Take the difference between one array and a number of other arrays. +Only the elements present in just the first array will remain.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.difference = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array)</span> {</span> + <span class="hljs-keyword">var</span> rest = concat.apply(ArrayProto, slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>)); + <span class="hljs-keyword">return</span> _.filter(array, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value)</span>{</span> <span class="hljs-keyword">return</span> !_.contains(rest, value); }); + };</pre></div></div> + + </li> + + + <li id="section-57"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-57">¶</a> + </div> + <p>Zip together multiple lists into a single array — elements that share +an index go together.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.zip = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">var</span> length = _.max(_.pluck(<span class="hljs-built_in">arguments</span>, <span class="hljs-string">'length'</span>).concat(<span class="hljs-number">0</span>)); + <span class="hljs-keyword">var</span> results = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(length); + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i < length; i++) { + results[i] = _.pluck(<span class="hljs-built_in">arguments</span>, <span class="hljs-string">''</span> + i); + } + <span class="hljs-keyword">return</span> results; + };</pre></div></div> + + </li> + + + <li id="section-58"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-58">¶</a> + </div> + <p>Converts lists into objects. Pass either a single array of <code>[key, value]</code> +pairs, or two parallel arrays of the same length — one of keys, and one of +the corresponding values.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.object = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(list, values)</span> {</span> + <span class="hljs-keyword">if</span> (list == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> {}; + <span class="hljs-keyword">var</span> result = {}; + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, length = list.length; i < length; i++) { + <span class="hljs-keyword">if</span> (values) { + result[list[i]] = values[i]; + } <span class="hljs-keyword">else</span> { + result[list[i][<span class="hljs-number">0</span>]] = list[i][<span class="hljs-number">1</span>]; + } + } + <span class="hljs-keyword">return</span> result; + };</pre></div></div> + + </li> + + + <li id="section-59"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-59">¶</a> + </div> + <p>If the browser doesn’t supply us with indexOf (I’m looking at you, <strong>MSIE</strong>), +we need this function. Return the position of the first occurrence of an +item in an array, or -1 if the item is not included in the array. +Delegates to <strong>ECMAScript 5</strong>‘s native <code>indexOf</code> if available. +If the array is large and already in sort order, pass <code>true</code> +for <strong>isSorted</strong> to use binary search.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.indexOf = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, item, isSorted)</span> {</span> + <span class="hljs-keyword">if</span> (array == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>; + <span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, length = array.length; + <span class="hljs-keyword">if</span> (isSorted) { + <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> isSorted == <span class="hljs-string">'number'</span>) { + i = (isSorted < <span class="hljs-number">0</span> ? <span class="hljs-built_in">Math</span>.max(<span class="hljs-number">0</span>, length + isSorted) : isSorted); + } <span class="hljs-keyword">else</span> { + i = _.sortedIndex(array, item); + <span class="hljs-keyword">return</span> array[i] === item ? i : -<span class="hljs-number">1</span>; + } + } + <span class="hljs-keyword">if</span> (nativeIndexOf && array.indexOf === nativeIndexOf) <span class="hljs-keyword">return</span> array.indexOf(item, isSorted); + <span class="hljs-keyword">for</span> (; i < length; i++) <span class="hljs-keyword">if</span> (array[i] === item) <span class="hljs-keyword">return</span> i; + <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>; + };</pre></div></div> + + </li> + + + <li id="section-60"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-60">¶</a> + </div> + <p>Delegates to <strong>ECMAScript 5</strong>‘s native <code>lastIndexOf</code> if available.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.lastIndexOf = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(array, item, from)</span> {</span> + <span class="hljs-keyword">if</span> (array == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>; + <span class="hljs-keyword">var</span> hasIndex = from != <span class="hljs-literal">null</span>; + <span class="hljs-keyword">if</span> (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { + <span class="hljs-keyword">return</span> hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); + } + <span class="hljs-keyword">var</span> i = (hasIndex ? from : array.length); + <span class="hljs-keyword">while</span> (i--) <span class="hljs-keyword">if</span> (array[i] === item) <span class="hljs-keyword">return</span> i; + <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>; + };</pre></div></div> + + </li> + + + <li id="section-61"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-61">¶</a> + </div> + <p>Generate an integer Array containing an arithmetic progression. A port of +the native Python <code>range()</code> function. See +<a href="http://docs.python.org/library/functions.html#range">the Python documentation</a>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.range = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(start, stop, step)</span> {</span> + <span class="hljs-keyword">if</span> (<span class="hljs-built_in">arguments</span>.length <= <span class="hljs-number">1</span>) { + stop = start || <span class="hljs-number">0</span>; + start = <span class="hljs-number">0</span>; + } + step = <span class="hljs-built_in">arguments</span>[<span class="hljs-number">2</span>] || <span class="hljs-number">1</span>; + + <span class="hljs-keyword">var</span> length = <span class="hljs-built_in">Math</span>.max(<span class="hljs-built_in">Math</span>.ceil((stop - start) / step), <span class="hljs-number">0</span>); + <span class="hljs-keyword">var</span> idx = <span class="hljs-number">0</span>; + <span class="hljs-keyword">var</span> range = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(length); + + <span class="hljs-keyword">while</span>(idx < length) { + range[idx++] = start; + start += step; + } + + <span class="hljs-keyword">return</span> range; + };</pre></div></div> + + </li> + + + <li id="section-62"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-62">¶</a> + </div> + <h2 id="function-ahem-functions">Function (ahem) Functions</h2> + + </div> + + </li> + + + <li id="section-63"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-63">¶</a> + </div> + + </div> + + </li> + + + <li id="section-64"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-64">¶</a> + </div> + <p>Reusable constructor function for prototype setting.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> ctor = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span>{</span>};</pre></div></div> + + </li> + + + <li id="section-65"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-65">¶</a> + </div> + <p>Create a function bound to a given object (assigning <code>this</code>, and arguments, +optionally). Delegates to <strong>ECMAScript 5</strong>‘s native <code>Function.bind</code> if +available.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.bind = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(func, context)</span> {</span> + <span class="hljs-keyword">var</span> args, bound; + <span class="hljs-keyword">if</span> (nativeBind && func.bind === nativeBind) <span class="hljs-keyword">return</span> nativeBind.apply(func, slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>)); + <span class="hljs-keyword">if</span> (!_.isFunction(func)) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">TypeError</span>; + args = slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">2</span>); + <span class="hljs-keyword">return</span> bound = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">if</span> (!(<span class="hljs-keyword">this</span> <span class="hljs-keyword">instanceof</span> bound)) <span class="hljs-keyword">return</span> func.apply(context, args.concat(slice.call(<span class="hljs-built_in">arguments</span>))); + ctor.prototype = func.prototype; + <span class="hljs-keyword">var</span> self = <span class="hljs-keyword">new</span> ctor; + ctor.prototype = <span class="hljs-literal">null</span>; + <span class="hljs-keyword">var</span> result = func.apply(self, args.concat(slice.call(<span class="hljs-built_in">arguments</span>))); + <span class="hljs-keyword">if</span> (<span class="hljs-built_in">Object</span>(result) === result) <span class="hljs-keyword">return</span> result; + <span class="hljs-keyword">return</span> self; + }; + };</pre></div></div> + + </li> + + + <li id="section-66"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-66">¶</a> + </div> + <p>Partially apply a function by creating a version that has had some of its +arguments pre-filled, without changing its dynamic <code>this</code> context. _ acts +as a placeholder, allowing any combination of arguments to be pre-filled.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.partial = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(func)</span> {</span> + <span class="hljs-keyword">var</span> boundArgs = slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>); + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">var</span> position = <span class="hljs-number">0</span>; + <span class="hljs-keyword">var</span> args = boundArgs.slice(); + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, length = args.length; i < length; i++) { + <span class="hljs-keyword">if</span> (args[i] === _) args[i] = <span class="hljs-built_in">arguments</span>[position++]; + } + <span class="hljs-keyword">while</span> (position < <span class="hljs-built_in">arguments</span>.length) args.push(<span class="hljs-built_in">arguments</span>[position++]); + <span class="hljs-keyword">return</span> func.apply(<span class="hljs-keyword">this</span>, args); + }; + };</pre></div></div> + + </li> + + + <li id="section-67"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-67">¶</a> + </div> + <p>Bind a number of an object’s methods to that object. Remaining arguments +are the method names to be bound. Useful for ensuring that all callbacks +defined on an object belong to it.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.bindAll = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">var</span> funcs = slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>); + <span class="hljs-keyword">if</span> (funcs.length === <span class="hljs-number">0</span>) <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">'bindAll must be passed function names'</span>); + each(funcs, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(f)</span> {</span> obj[f] = _.bind(obj[f], obj); }); + <span class="hljs-keyword">return</span> obj; + };</pre></div></div> + + </li> + + + <li id="section-68"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-68">¶</a> + </div> + <p>Memoize an expensive function by storing its results.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.memoize = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(func, hasher)</span> {</span> + <span class="hljs-keyword">var</span> memo = {}; + hasher || (hasher = _.identity); + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">var</span> key = hasher.apply(<span class="hljs-keyword">this</span>, <span class="hljs-built_in">arguments</span>); + <span class="hljs-keyword">return</span> _.has(memo, key) ? memo[key] : (memo[key] = func.apply(<span class="hljs-keyword">this</span>, <span class="hljs-built_in">arguments</span>)); + }; + };</pre></div></div> + + </li> + + + <li id="section-69"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-69">¶</a> + </div> + <p>Delays a function for the given number of milliseconds, and then calls +it with the arguments supplied.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.delay = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(func, wait)</span> {</span> + <span class="hljs-keyword">var</span> args = slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">2</span>); + <span class="hljs-keyword">return</span> setTimeout(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span>{</span> <span class="hljs-keyword">return</span> func.apply(<span class="hljs-literal">null</span>, args); }, wait); + };</pre></div></div> + + </li> + + + <li id="section-70"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-70">¶</a> + </div> + <p>Defers a function, scheduling it to run after the current call stack has +cleared.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.defer = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(func)</span> {</span> + <span class="hljs-keyword">return</span> _.delay.apply(_, [func, <span class="hljs-number">1</span>].concat(slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>))); + };</pre></div></div> + + </li> + + + <li id="section-71"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-71">¶</a> + </div> + <p>Returns a function, that, when invoked, will only be triggered at most once +during a given window of time. Normally, the throttled function will run +as much as it can, without ever going more than once per <code>wait</code> duration; +but if you’d like to disable the execution on the leading edge, pass +<code>{leading: false}</code>. To disable execution on the trailing edge, ditto.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.throttle = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(func, wait, options)</span> {</span> + <span class="hljs-keyword">var</span> context, args, result; + <span class="hljs-keyword">var</span> timeout = <span class="hljs-literal">null</span>; + <span class="hljs-keyword">var</span> previous = <span class="hljs-number">0</span>; + options || (options = {}); + <span class="hljs-keyword">var</span> later = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + previous = options.leading === <span class="hljs-literal">false</span> ? <span class="hljs-number">0</span> : _.now(); + timeout = <span class="hljs-literal">null</span>; + result = func.apply(context, args); + context = args = <span class="hljs-literal">null</span>; + }; + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">var</span> now = _.now(); + <span class="hljs-keyword">if</span> (!previous && options.leading === <span class="hljs-literal">false</span>) previous = now; + <span class="hljs-keyword">var</span> remaining = wait - (now - previous); + context = <span class="hljs-keyword">this</span>; + args = <span class="hljs-built_in">arguments</span>; + <span class="hljs-keyword">if</span> (remaining <= <span class="hljs-number">0</span>) { + clearTimeout(timeout); + timeout = <span class="hljs-literal">null</span>; + previous = now; + result = func.apply(context, args); + context = args = <span class="hljs-literal">null</span>; + } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (!timeout && options.trailing !== <span class="hljs-literal">false</span>) { + timeout = setTimeout(later, remaining); + } + <span class="hljs-keyword">return</span> result; + }; + };</pre></div></div> + + </li> + + + <li id="section-72"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-72">¶</a> + </div> + <p>Returns a function, that, as long as it continues to be invoked, will not +be triggered. The function will be called after it stops being called for +N milliseconds. If <code>immediate</code> is passed, trigger the function on the +leading edge, instead of the trailing.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.debounce = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(func, wait, immediate)</span> {</span> + <span class="hljs-keyword">var</span> timeout, args, context, timestamp, result; + + <span class="hljs-keyword">var</span> later = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">var</span> last = _.now() - timestamp; + <span class="hljs-keyword">if</span> (last < wait) { + timeout = setTimeout(later, wait - last); + } <span class="hljs-keyword">else</span> { + timeout = <span class="hljs-literal">null</span>; + <span class="hljs-keyword">if</span> (!immediate) { + result = func.apply(context, args); + context = args = <span class="hljs-literal">null</span>; + } + } + }; + + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + context = <span class="hljs-keyword">this</span>; + args = <span class="hljs-built_in">arguments</span>; + timestamp = _.now(); + <span class="hljs-keyword">var</span> callNow = immediate && !timeout; + <span class="hljs-keyword">if</span> (!timeout) { + timeout = setTimeout(later, wait); + } + <span class="hljs-keyword">if</span> (callNow) { + result = func.apply(context, args); + context = args = <span class="hljs-literal">null</span>; + } + + <span class="hljs-keyword">return</span> result; + }; + };</pre></div></div> + + </li> + + + <li id="section-73"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-73">¶</a> + </div> + <p>Returns a function that will be executed at most one time, no matter how +often you call it. Useful for lazy initialization.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.once = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(func)</span> {</span> + <span class="hljs-keyword">var</span> ran = <span class="hljs-literal">false</span>, memo; + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">if</span> (ran) <span class="hljs-keyword">return</span> memo; + ran = <span class="hljs-literal">true</span>; + memo = func.apply(<span class="hljs-keyword">this</span>, <span class="hljs-built_in">arguments</span>); + func = <span class="hljs-literal">null</span>; + <span class="hljs-keyword">return</span> memo; + }; + };</pre></div></div> + + </li> + + + <li id="section-74"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-74">¶</a> + </div> + <p>Returns the first function passed as an argument to the second, +allowing you to adjust arguments, run code before and after, and +conditionally execute the original function.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.wrap = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(func, wrapper)</span> {</span> + <span class="hljs-keyword">return</span> _.partial(wrapper, func); + };</pre></div></div> + + </li> + + + <li id="section-75"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-75">¶</a> + </div> + <p>Returns a function that is the composition of a list of functions, each +consuming the return value of the function that follows.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.compose = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">var</span> funcs = <span class="hljs-built_in">arguments</span>; + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">var</span> args = <span class="hljs-built_in">arguments</span>; + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = funcs.length - <span class="hljs-number">1</span>; i >= <span class="hljs-number">0</span>; i--) { + args = [funcs[i].apply(<span class="hljs-keyword">this</span>, args)]; + } + <span class="hljs-keyword">return</span> args[<span class="hljs-number">0</span>]; + }; + };</pre></div></div> + + </li> + + + <li id="section-76"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-76">¶</a> + </div> + <p>Returns a function that will only be executed after being called N times.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.after = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(times, func)</span> {</span> + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">if</span> (--times < <span class="hljs-number">1</span>) { + <span class="hljs-keyword">return</span> func.apply(<span class="hljs-keyword">this</span>, <span class="hljs-built_in">arguments</span>); + } + }; + };</pre></div></div> + + </li> + + + <li id="section-77"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-77">¶</a> + </div> + <h2 id="object-functions">Object Functions</h2> + + </div> + + </li> + + + <li id="section-78"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-78">¶</a> + </div> + + </div> + + </li> + + + <li id="section-79"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-79">¶</a> + </div> + <p>Retrieve the names of an object’s properties. +Delegates to <strong>ECMAScript 5</strong>‘s native <code>Object.keys</code></p> + + </div> + + <div class="content"><div class='highlight'><pre> _.keys = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">if</span> (!_.isObject(obj)) <span class="hljs-keyword">return</span> []; + <span class="hljs-keyword">if</span> (nativeKeys) <span class="hljs-keyword">return</span> nativeKeys(obj); + <span class="hljs-keyword">var</span> keys = []; + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> key <span class="hljs-keyword">in</span> obj) <span class="hljs-keyword">if</span> (_.has(obj, key)) keys.push(key); + <span class="hljs-keyword">return</span> keys; + };</pre></div></div> + + </li> + + + <li id="section-80"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-80">¶</a> + </div> + <p>Retrieve the values of an object’s properties.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.values = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">var</span> keys = _.keys(obj); + <span class="hljs-keyword">var</span> length = keys.length; + <span class="hljs-keyword">var</span> values = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(length); + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i < length; i++) { + values[i] = obj[keys[i]]; + } + <span class="hljs-keyword">return</span> values; + };</pre></div></div> + + </li> + + + <li id="section-81"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-81">¶</a> + </div> + <p>Convert an object into a list of <code>[key, value]</code> pairs.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.pairs = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">var</span> keys = _.keys(obj); + <span class="hljs-keyword">var</span> length = keys.length; + <span class="hljs-keyword">var</span> pairs = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Array</span>(length); + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i < length; i++) { + pairs[i] = [keys[i], obj[keys[i]]]; + } + <span class="hljs-keyword">return</span> pairs; + };</pre></div></div> + + </li> + + + <li id="section-82"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-82">¶</a> + </div> + <p>Invert the keys and values of an object. The values must be serializable.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.invert = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">var</span> result = {}; + <span class="hljs-keyword">var</span> keys = _.keys(obj); + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, length = keys.length; i < length; i++) { + result[obj[keys[i]]] = keys[i]; + } + <span class="hljs-keyword">return</span> result; + };</pre></div></div> + + </li> + + + <li id="section-83"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-83">¶</a> + </div> + <p>Return a sorted list of the function names available on the object. +Aliased as <code>methods</code></p> + + </div> + + <div class="content"><div class='highlight'><pre> _.functions = _.methods = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">var</span> names = []; + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> key <span class="hljs-keyword">in</span> obj) { + <span class="hljs-keyword">if</span> (_.isFunction(obj[key])) names.push(key); + } + <span class="hljs-keyword">return</span> names.sort(); + };</pre></div></div> + + </li> + + + <li id="section-84"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-84">¶</a> + </div> + <p>Extend a given object with all the properties in passed-in object(s).</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.extend = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + each(slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>), <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(source)</span> {</span> + <span class="hljs-keyword">if</span> (source) { + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> prop <span class="hljs-keyword">in</span> source) { + obj[prop] = source[prop]; + } + } + }); + <span class="hljs-keyword">return</span> obj; + };</pre></div></div> + + </li> + + + <li id="section-85"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-85">¶</a> + </div> + <p>Return a copy of the object only containing the whitelisted properties.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.pick = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">var</span> copy = {}; + <span class="hljs-keyword">var</span> keys = concat.apply(ArrayProto, slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>)); + each(keys, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(key)</span> {</span> + <span class="hljs-keyword">if</span> (key <span class="hljs-keyword">in</span> obj) copy[key] = obj[key]; + }); + <span class="hljs-keyword">return</span> copy; + };</pre></div></div> + + </li> + + + <li id="section-86"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-86">¶</a> + </div> + <p>Return a copy of the object without the blacklisted properties.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.omit = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">var</span> copy = {}; + <span class="hljs-keyword">var</span> keys = concat.apply(ArrayProto, slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>)); + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> key <span class="hljs-keyword">in</span> obj) { + <span class="hljs-keyword">if</span> (!_.contains(keys, key)) copy[key] = obj[key]; + } + <span class="hljs-keyword">return</span> copy; + };</pre></div></div> + + </li> + + + <li id="section-87"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-87">¶</a> + </div> + <p>Fill in a given object with default properties.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.defaults = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + each(slice.call(<span class="hljs-built_in">arguments</span>, <span class="hljs-number">1</span>), <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(source)</span> {</span> + <span class="hljs-keyword">if</span> (source) { + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> prop <span class="hljs-keyword">in</span> source) { + <span class="hljs-keyword">if</span> (obj[prop] === <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>) obj[prop] = source[prop]; + } + } + }); + <span class="hljs-keyword">return</span> obj; + };</pre></div></div> + + </li> + + + <li id="section-88"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-88">¶</a> + </div> + <p>Create a (shallow-cloned) duplicate of an object.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.clone = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">if</span> (!_.isObject(obj)) <span class="hljs-keyword">return</span> obj; + <span class="hljs-keyword">return</span> _.isArray(obj) ? obj.slice() : _.extend({}, obj); + };</pre></div></div> + + </li> + + + <li id="section-89"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-89">¶</a> + </div> + <p>Invokes interceptor with the obj, and then returns obj. +The primary purpose of this method is to “tap into” a method chain, in +order to perform operations on intermediate results within the chain.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.tap = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, interceptor)</span> {</span> + interceptor(obj); + <span class="hljs-keyword">return</span> obj; + };</pre></div></div> + + </li> + + + <li id="section-90"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-90">¶</a> + </div> + <p>Internal recursive comparison function for <code>isEqual</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> eq = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(a, b, aStack, bStack)</span> {</span></pre></div></div> + + </li> + + + <li id="section-91"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-91">¶</a> + </div> + <p>Identical objects are equal. <code>0 === -0</code>, but they aren’t identical. +See the <a href="http://wiki.ecmascript.org/doku.php?id=harmony:egal">Harmony <code>egal</code> proposal</a>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (a === b) <span class="hljs-keyword">return</span> a !== <span class="hljs-number">0</span> || <span class="hljs-number">1</span> / a == <span class="hljs-number">1</span> / b;</pre></div></div> + + </li> + + + <li id="section-92"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-92">¶</a> + </div> + <p>A strict comparison is necessary because <code>null == undefined</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (a == <span class="hljs-literal">null</span> || b == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> a === b;</pre></div></div> + + </li> + + + <li id="section-93"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-93">¶</a> + </div> + <p>Unwrap any wrapped objects.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (a <span class="hljs-keyword">instanceof</span> _) a = a._wrapped; + <span class="hljs-keyword">if</span> (b <span class="hljs-keyword">instanceof</span> _) b = b._wrapped;</pre></div></div> + + </li> + + + <li id="section-94"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-94">¶</a> + </div> + <p>Compare <code>[[Class]]</code> names.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> className = toString.call(a); + <span class="hljs-keyword">if</span> (className != toString.call(b)) <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>; + <span class="hljs-keyword">switch</span> (className) {</pre></div></div> + + </li> + + + <li id="section-95"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-95">¶</a> + </div> + <p>Strings, numbers, dates, and booleans are compared by value.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">case</span> <span class="hljs-string">'[object String]'</span>:</pre></div></div> + + </li> + + + <li id="section-96"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-96">¶</a> + </div> + <p>Primitives and their corresponding object wrappers are equivalent; thus, <code>"5"</code> is +equivalent to <code>new String("5")</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> a == <span class="hljs-built_in">String</span>(b); + <span class="hljs-keyword">case</span> <span class="hljs-string">'[object Number]'</span>:</pre></div></div> + + </li> + + + <li id="section-97"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-97">¶</a> + </div> + <p><code>NaN</code>s are equivalent, but non-reflexive. An <code>egal</code> comparison is performed for +other numeric values.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> a != +a ? b != +b : (a == <span class="hljs-number">0</span> ? <span class="hljs-number">1</span> / a == <span class="hljs-number">1</span> / b : a == +b); + <span class="hljs-keyword">case</span> <span class="hljs-string">'[object Date]'</span>: + <span class="hljs-keyword">case</span> <span class="hljs-string">'[object Boolean]'</span>:</pre></div></div> + + </li> + + + <li id="section-98"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-98">¶</a> + </div> + <p>Coerce dates and booleans to numeric primitive values. Dates are compared by their +millisecond representations. Note that invalid dates with millisecond representations +of <code>NaN</code> are not equivalent.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> +a == +b;</pre></div></div> + + </li> + + + <li id="section-99"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-99">¶</a> + </div> + <p>RegExps are compared by their source patterns and flags.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">case</span> <span class="hljs-string">'[object RegExp]'</span>: + <span class="hljs-keyword">return</span> a.source == b.source && + a.global == b.global && + a.multiline == b.multiline && + a.ignoreCase == b.ignoreCase; + } + <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> a != <span class="hljs-string">'object'</span> || <span class="hljs-keyword">typeof</span> b != <span class="hljs-string">'object'</span>) <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;</pre></div></div> + + </li> + + + <li id="section-100"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-100">¶</a> + </div> + <p>Assume equality for cyclic structures. The algorithm for detecting cyclic +structures is adapted from ES 5.1 section 15.12.3, abstract operation <code>JO</code>.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> length = aStack.length; + <span class="hljs-keyword">while</span> (length--) {</pre></div></div> + + </li> + + + <li id="section-101"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-101">¶</a> + </div> + <p>Linear search. Performance is inversely proportional to the number of +unique nested structures.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (aStack[length] == a) <span class="hljs-keyword">return</span> bStack[length] == b; + }</pre></div></div> + + </li> + + + <li id="section-102"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-102">¶</a> + </div> + <p>Objects with different constructors are not equivalent, but <code>Object</code>s +from different frames are.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> aCtor = a.constructor, bCtor = b.constructor; + <span class="hljs-keyword">if</span> (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor <span class="hljs-keyword">instanceof</span> aCtor) && + _.isFunction(bCtor) && (bCtor <span class="hljs-keyword">instanceof</span> bCtor)) + && (<span class="hljs-string">'constructor'</span> <span class="hljs-keyword">in</span> a && <span class="hljs-string">'constructor'</span> <span class="hljs-keyword">in</span> b)) { + <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>; + }</pre></div></div> + + </li> + + + <li id="section-103"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-103">¶</a> + </div> + <p>Add the first object to the stack of traversed objects.</p> + + </div> + + <div class="content"><div class='highlight'><pre> aStack.push(a); + bStack.push(b); + <span class="hljs-keyword">var</span> size = <span class="hljs-number">0</span>, result = <span class="hljs-literal">true</span>;</pre></div></div> + + </li> + + + <li id="section-104"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-104">¶</a> + </div> + <p>Recursively compare objects and arrays.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (className == <span class="hljs-string">'[object Array]'</span>) {</pre></div></div> + + </li> + + + <li id="section-105"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-105">¶</a> + </div> + <p>Compare array lengths to determine if a deep comparison is necessary.</p> + + </div> + + <div class="content"><div class='highlight'><pre> size = a.length; + result = size == b.length; + <span class="hljs-keyword">if</span> (result) {</pre></div></div> + + </li> + + + <li id="section-106"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-106">¶</a> + </div> + <p>Deep compare the contents, ignoring non-numeric properties.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">while</span> (size--) { + <span class="hljs-keyword">if</span> (!(result = eq(a[size], b[size], aStack, bStack))) <span class="hljs-keyword">break</span>; + } + } + } <span class="hljs-keyword">else</span> {</pre></div></div> + + </li> + + + <li id="section-107"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-107">¶</a> + </div> + <p>Deep compare objects.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> key <span class="hljs-keyword">in</span> a) { + <span class="hljs-keyword">if</span> (_.has(a, key)) {</pre></div></div> + + </li> + + + <li id="section-108"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-108">¶</a> + </div> + <p>Count the expected number of properties.</p> + + </div> + + <div class="content"><div class='highlight'><pre> size++;</pre></div></div> + + </li> + + + <li id="section-109"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-109">¶</a> + </div> + <p>Deep compare each member.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) <span class="hljs-keyword">break</span>; + } + }</pre></div></div> + + </li> + + + <li id="section-110"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-110">¶</a> + </div> + <p>Ensure that both objects contain the same number of properties.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (result) { + <span class="hljs-keyword">for</span> (key <span class="hljs-keyword">in</span> b) { + <span class="hljs-keyword">if</span> (_.has(b, key) && !(size--)) <span class="hljs-keyword">break</span>; + } + result = !size; + } + }</pre></div></div> + + </li> + + + <li id="section-111"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-111">¶</a> + </div> + <p>Remove the first object from the stack of traversed objects.</p> + + </div> + + <div class="content"><div class='highlight'><pre> aStack.pop(); + bStack.pop(); + <span class="hljs-keyword">return</span> result; + };</pre></div></div> + + </li> + + + <li id="section-112"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-112">¶</a> + </div> + <p>Perform a deep comparison to check if two objects are equal.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isEqual = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(a, b)</span> {</span> + <span class="hljs-keyword">return</span> eq(a, b, [], []); + };</pre></div></div> + + </li> + + + <li id="section-113"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-113">¶</a> + </div> + <p>Is a given array, string, or object empty? +An “empty” object has no enumerable own-properties.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isEmpty = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">if</span> (obj == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>; + <span class="hljs-keyword">if</span> (_.isArray(obj) || _.isString(obj)) <span class="hljs-keyword">return</span> obj.length === <span class="hljs-number">0</span>; + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> key <span class="hljs-keyword">in</span> obj) <span class="hljs-keyword">if</span> (_.has(obj, key)) <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>; + <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>; + };</pre></div></div> + + </li> + + + <li id="section-114"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-114">¶</a> + </div> + <p>Is a given value a DOM element?</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isElement = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> !!(obj && obj.nodeType === <span class="hljs-number">1</span>); + };</pre></div></div> + + </li> + + + <li id="section-115"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-115">¶</a> + </div> + <p>Is a given value an array? +Delegates to ECMA5’s native Array.isArray</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isArray = nativeIsArray || <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> toString.call(obj) == <span class="hljs-string">'[object Array]'</span>; + };</pre></div></div> + + </li> + + + <li id="section-116"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-116">¶</a> + </div> + <p>Is a given variable an object?</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isObject = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> obj === <span class="hljs-built_in">Object</span>(obj); + };</pre></div></div> + + </li> + + + <li id="section-117"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-117">¶</a> + </div> + <p>Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.</p> + + </div> + + <div class="content"><div class='highlight'><pre> each([<span class="hljs-string">'Arguments'</span>, <span class="hljs-string">'Function'</span>, <span class="hljs-string">'String'</span>, <span class="hljs-string">'Number'</span>, <span class="hljs-string">'Date'</span>, <span class="hljs-string">'RegExp'</span>], <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(name)</span> {</span> + _[<span class="hljs-string">'is'</span> + name] = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> toString.call(obj) == <span class="hljs-string">'[object '</span> + name + <span class="hljs-string">']'</span>; + }; + });</pre></div></div> + + </li> + + + <li id="section-118"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-118">¶</a> + </div> + <p>Define a fallback version of the method in browsers (ahem, IE), where +there isn’t any inspectable “Arguments” type.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (!_.isArguments(<span class="hljs-built_in">arguments</span>)) { + _.isArguments = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> !!(obj && _.has(obj, <span class="hljs-string">'callee'</span>)); + }; + }</pre></div></div> + + </li> + + + <li id="section-119"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-119">¶</a> + </div> + <p>Optimize <code>isFunction</code> if appropriate.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> (<span class="hljs-regexp">/./</span>) !== <span class="hljs-string">'function'</span>) { + _.isFunction = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> <span class="hljs-keyword">typeof</span> obj === <span class="hljs-string">'function'</span>; + }; + }</pre></div></div> + + </li> + + + <li id="section-120"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-120">¶</a> + </div> + <p>Is a given object a finite number?</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isFinite = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> <span class="hljs-built_in">isFinite</span>(obj) && !<span class="hljs-built_in">isNaN</span>(<span class="hljs-built_in">parseFloat</span>(obj)); + };</pre></div></div> + + </li> + + + <li id="section-121"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-121">¶</a> + </div> + <p>Is the given value <code>NaN</code>? (NaN is the only number which does not equal itself).</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isNaN = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> _.isNumber(obj) && obj != +obj; + };</pre></div></div> + + </li> + + + <li id="section-122"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-122">¶</a> + </div> + <p>Is a given value a boolean?</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isBoolean = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> obj === <span class="hljs-literal">true</span> || obj === <span class="hljs-literal">false</span> || toString.call(obj) == <span class="hljs-string">'[object Boolean]'</span>; + };</pre></div></div> + + </li> + + + <li id="section-123"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-123">¶</a> + </div> + <p>Is a given value equal to null?</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isNull = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> obj === <span class="hljs-literal">null</span>; + };</pre></div></div> + + </li> + + + <li id="section-124"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-124">¶</a> + </div> + <p>Is a given variable undefined?</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.isUndefined = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> obj === <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>; + };</pre></div></div> + + </li> + + + <li id="section-125"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-125">¶</a> + </div> + <p>Shortcut function for checking if an object has a given property directly +on itself (in other words, not on a prototype).</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.has = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj, key)</span> {</span> + <span class="hljs-keyword">return</span> hasOwnProperty.call(obj, key); + };</pre></div></div> + + </li> + + + <li id="section-126"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-126">¶</a> + </div> + <h2 id="utility-functions">Utility Functions</h2> + + </div> + + </li> + + + <li id="section-127"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-127">¶</a> + </div> + + </div> + + </li> + + + <li id="section-128"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-128">¶</a> + </div> + <p>Run Underscore.js in <em>noConflict</em> mode, returning the <code>_</code> variable to its +previous owner. Returns a reference to the Underscore object.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.noConflict = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + root._ = previousUnderscore; + <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>; + };</pre></div></div> + + </li> + + + <li id="section-129"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-129">¶</a> + </div> + <p>Keep the identity function around for default iterators.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.identity = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value)</span> {</span> + <span class="hljs-keyword">return</span> value; + }; + + _.constant = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(value)</span> {</span> + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">return</span> value; + }; + }; + + _.property = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(key)</span> {</span> + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> obj[key]; + }; + };</pre></div></div> + + </li> + + + <li id="section-130"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-130">¶</a> + </div> + <p>Returns a predicate for checking whether an object has a given set of <code>key:value</code> pairs.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.matches = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(attrs)</span> {</span> + <span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">if</span> (obj === attrs) <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>; <span class="hljs-comment">//avoid comparing an object to itself.</span> + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> key <span class="hljs-keyword">in</span> attrs) { + <span class="hljs-keyword">if</span> (attrs[key] !== obj[key]) + <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>; + } + <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>; + } + };</pre></div></div> + + </li> + + + <li id="section-131"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-131">¶</a> + </div> + <p>Run a function <strong>n</strong> times.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.times = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(n, iterator, context)</span> {</span> + <span class="hljs-keyword">var</span> accum = <span class="hljs-built_in">Array</span>(<span class="hljs-built_in">Math</span>.max(<span class="hljs-number">0</span>, n)); + <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i < n; i++) accum[i] = iterator.call(context, i); + <span class="hljs-keyword">return</span> accum; + };</pre></div></div> + + </li> + + + <li id="section-132"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-132">¶</a> + </div> + <p>Return a random integer between min and max (inclusive).</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.random = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(min, max)</span> {</span> + <span class="hljs-keyword">if</span> (max == <span class="hljs-literal">null</span>) { + max = min; + min = <span class="hljs-number">0</span>; + } + <span class="hljs-keyword">return</span> min + <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * (max - min + <span class="hljs-number">1</span>)); + };</pre></div></div> + + </li> + + + <li id="section-133"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-133">¶</a> + </div> + <p>A (possibly faster) way to get the current timestamp as an integer.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.now = <span class="hljs-built_in">Date</span>.now || <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>().getTime(); };</pre></div></div> + + </li> + + + <li id="section-134"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-134">¶</a> + </div> + <p>List of HTML entities for escaping.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> entityMap = { + <span class="hljs-built_in">escape</span>: { + <span class="hljs-string">'&'</span>: <span class="hljs-string">'&amp;'</span>, + <span class="hljs-string">'<'</span>: <span class="hljs-string">'&lt;'</span>, + <span class="hljs-string">'>'</span>: <span class="hljs-string">'&gt;'</span>, + <span class="hljs-string">'"'</span>: <span class="hljs-string">'&quot;'</span>, + <span class="hljs-string">"'"</span>: <span class="hljs-string">'&#x27;'</span> + } + }; + entityMap.unescape = _.invert(entityMap.escape);</pre></div></div> + + </li> + + + <li id="section-135"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-135">¶</a> + </div> + <p>Regexes containing the keys and values listed immediately above.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> entityRegexes = { + <span class="hljs-built_in">escape</span>: <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">'['</span> + _.keys(entityMap.escape).join(<span class="hljs-string">''</span>) + <span class="hljs-string">']'</span>, <span class="hljs-string">'g'</span>), + <span class="hljs-built_in">unescape</span>: <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>(<span class="hljs-string">'('</span> + _.keys(entityMap.unescape).join(<span class="hljs-string">'|'</span>) + <span class="hljs-string">')'</span>, <span class="hljs-string">'g'</span>) + };</pre></div></div> + + </li> + + + <li id="section-136"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-136">¶</a> + </div> + <p>Functions for escaping and unescaping strings to/from HTML interpolation.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.each([<span class="hljs-string">'escape'</span>, <span class="hljs-string">'unescape'</span>], <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(method)</span> {</span> + _[method] = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(string)</span> {</span> + <span class="hljs-keyword">if</span> (string == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-string">''</span>; + <span class="hljs-keyword">return</span> (<span class="hljs-string">''</span> + string).replace(entityRegexes[method], <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(match)</span> {</span> + <span class="hljs-keyword">return</span> entityMap[method][match]; + }); + }; + });</pre></div></div> + + </li> + + + <li id="section-137"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-137">¶</a> + </div> + <p>If the value of the named <code>property</code> is a function then invoke it with the +<code>object</code> as context; otherwise, return it.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.result = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(object, property)</span> {</span> + <span class="hljs-keyword">if</span> (object == <span class="hljs-literal">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>; + <span class="hljs-keyword">var</span> value = object[property]; + <span class="hljs-keyword">return</span> _.isFunction(value) ? value.call(object) : value; + };</pre></div></div> + + </li> + + + <li id="section-138"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-138">¶</a> + </div> + <p>Add your own custom functions to the Underscore object.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.mixin = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + each(_.functions(obj), <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(name)</span> {</span> + <span class="hljs-keyword">var</span> func = _[name] = obj[name]; + _.prototype[name] = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">var</span> args = [<span class="hljs-keyword">this</span>._wrapped]; + push.apply(args, <span class="hljs-built_in">arguments</span>); + <span class="hljs-keyword">return</span> result.call(<span class="hljs-keyword">this</span>, func.apply(_, args)); + }; + }); + };</pre></div></div> + + </li> + + + <li id="section-139"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-139">¶</a> + </div> + <p>Generate a unique integer id (unique within the entire client session). +Useful for temporary DOM ids.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> idCounter = <span class="hljs-number">0</span>; + _.uniqueId = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(prefix)</span> {</span> + <span class="hljs-keyword">var</span> id = ++idCounter + <span class="hljs-string">''</span>; + <span class="hljs-keyword">return</span> prefix ? prefix + id : id; + };</pre></div></div> + + </li> + + + <li id="section-140"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-140">¶</a> + </div> + <p>By default, Underscore uses ERB-style template delimiters, change the +following template settings to use alternative delimiters.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.templateSettings = { + evaluate : <span class="hljs-regexp">/<%([\s\S]+?)%>/g</span>, + interpolate : <span class="hljs-regexp">/<%=([\s\S]+?)%>/g</span>, + <span class="hljs-built_in">escape</span> : <span class="hljs-regexp">/<%-([\s\S]+?)%>/g</span> + };</pre></div></div> + + </li> + + + <li id="section-141"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-141">¶</a> + </div> + <p>When customizing <code>templateSettings</code>, if you don’t want to define an +interpolation, evaluation or escaping regex, we need one that is +guaranteed not to match.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> noMatch = <span class="hljs-regexp">/(.)^/</span>;</pre></div></div> + + </li> + + + <li id="section-142"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-142">¶</a> + </div> + <p>Certain characters need to be escaped so that they can be put into a +string literal.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> escapes = { + <span class="hljs-string">"'"</span>: <span class="hljs-string">"'"</span>, + <span class="hljs-string">'\\'</span>: <span class="hljs-string">'\\'</span>, + <span class="hljs-string">'\r'</span>: <span class="hljs-string">'r'</span>, + <span class="hljs-string">'\n'</span>: <span class="hljs-string">'n'</span>, + <span class="hljs-string">'\t'</span>: <span class="hljs-string">'t'</span>, + <span class="hljs-string">'\u2028'</span>: <span class="hljs-string">'u2028'</span>, + <span class="hljs-string">'\u2029'</span>: <span class="hljs-string">'u2029'</span> + }; + + <span class="hljs-keyword">var</span> escaper = <span class="hljs-regexp">/\\|'|\r|\n|\t|\u2028|\u2029/g</span>;</pre></div></div> + + </li> + + + <li id="section-143"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-143">¶</a> + </div> + <p>JavaScript micro-templating, similar to John Resig’s implementation. +Underscore templating handles arbitrary delimiters, preserves whitespace, +and correctly escapes quotes within interpolated code.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.template = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(text, data, settings)</span> {</span> + <span class="hljs-keyword">var</span> render; + settings = _.defaults({}, settings, _.templateSettings);</pre></div></div> + + </li> + + + <li id="section-144"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-144">¶</a> + </div> + <p>Combine delimiters into one regular expression via alternation.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> matcher = <span class="hljs-keyword">new</span> <span class="hljs-built_in">RegExp</span>([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join(<span class="hljs-string">'|'</span>) + <span class="hljs-string">'|$'</span>, <span class="hljs-string">'g'</span>);</pre></div></div> + + </li> + + + <li id="section-145"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-145">¶</a> + </div> + <p>Compile the template source, escaping string literals appropriately.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> index = <span class="hljs-number">0</span>; + <span class="hljs-keyword">var</span> source = <span class="hljs-string">"__p+='"</span>; + text.replace(matcher, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(match, escape, interpolate, evaluate, offset)</span> {</span> + source += text.slice(index, offset) + .replace(escaper, <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(match)</span> {</span> <span class="hljs-keyword">return</span> <span class="hljs-string">'\\'</span> + escapes[match]; }); + + <span class="hljs-keyword">if</span> (<span class="hljs-built_in">escape</span>) { + source += <span class="hljs-string">"'+\n((__t=("</span> + <span class="hljs-built_in">escape</span> + <span class="hljs-string">"))==null?'':_.escape(__t))+\n'"</span>; + } + <span class="hljs-keyword">if</span> (interpolate) { + source += <span class="hljs-string">"'+\n((__t=("</span> + interpolate + <span class="hljs-string">"))==null?'':__t)+\n'"</span>; + } + <span class="hljs-keyword">if</span> (evaluate) { + source += <span class="hljs-string">"';\n"</span> + evaluate + <span class="hljs-string">"\n__p+='"</span>; + } + index = offset + match.length; + <span class="hljs-keyword">return</span> match; + }); + source += <span class="hljs-string">"';\n"</span>;</pre></div></div> + + </li> + + + <li id="section-146"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-146">¶</a> + </div> + <p>If a variable is not specified, place data values in local scope.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (!settings.variable) source = <span class="hljs-string">'with(obj||{}){\n'</span> + source + <span class="hljs-string">'}\n'</span>; + + source = <span class="hljs-string">"var __t,__p='',__j=Array.prototype.join,"</span> + + <span class="hljs-string">"print=function(){__p+=__j.call(arguments,'');};\n"</span> + + source + <span class="hljs-string">"return __p;\n"</span>; + + <span class="hljs-keyword">try</span> { + render = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Function</span>(settings.variable || <span class="hljs-string">'obj'</span>, <span class="hljs-string">'_'</span>, source); + } <span class="hljs-keyword">catch</span> (e) { + e.source = source; + <span class="hljs-keyword">throw</span> e; + } + + <span class="hljs-keyword">if</span> (data) <span class="hljs-keyword">return</span> render(data, _); + <span class="hljs-keyword">var</span> template = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(data)</span> {</span> + <span class="hljs-keyword">return</span> render.call(<span class="hljs-keyword">this</span>, data, _); + };</pre></div></div> + + </li> + + + <li id="section-147"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-147">¶</a> + </div> + <p>Provide the compiled function source as a convenience for precompilation.</p> + + </div> + + <div class="content"><div class='highlight'><pre> template.source = <span class="hljs-string">'function('</span> + (settings.variable || <span class="hljs-string">'obj'</span>) + <span class="hljs-string">'){\n'</span> + source + <span class="hljs-string">'}'</span>; + + <span class="hljs-keyword">return</span> template; + };</pre></div></div> + + </li> + + + <li id="section-148"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-148">¶</a> + </div> + <p>Add a “chain” function, which will delegate to the wrapper.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.chain = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> _(obj).chain(); + };</pre></div></div> + + </li> + + + <li id="section-149"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-149">¶</a> + </div> + <h2 id="oop">OOP</h2> + + </div> + + </li> + + + <li id="section-150"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-150">¶</a> + </div> + <p>If Underscore is called as a function, it returns a wrapped object that +can be used OO-style. This wrapper holds altered versions of all the +underscore functions. Wrapped objects may be chained.</p> + + </div> + + </li> + + + <li id="section-151"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-151">¶</a> + </div> + <p>Helper function to continue chaining intermediate results.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">var</span> result = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(obj)</span> {</span> + <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>._chain ? _(obj).chain() : obj; + };</pre></div></div> + + </li> + + + <li id="section-152"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-152">¶</a> + </div> + <p>Add all of the Underscore functions to the wrapper object.</p> + + </div> + + <div class="content"><div class='highlight'><pre> _.mixin(_);</pre></div></div> + + </li> + + + <li id="section-153"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-153">¶</a> + </div> + <p>Add all mutator Array functions to the wrapper.</p> + + </div> + + <div class="content"><div class='highlight'><pre> each([<span class="hljs-string">'pop'</span>, <span class="hljs-string">'push'</span>, <span class="hljs-string">'reverse'</span>, <span class="hljs-string">'shift'</span>, <span class="hljs-string">'sort'</span>, <span class="hljs-string">'splice'</span>, <span class="hljs-string">'unshift'</span>], <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(name)</span> {</span> + <span class="hljs-keyword">var</span> method = ArrayProto[name]; + _.prototype[name] = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">var</span> obj = <span class="hljs-keyword">this</span>._wrapped; + method.apply(obj, <span class="hljs-built_in">arguments</span>); + <span class="hljs-keyword">if</span> ((name == <span class="hljs-string">'shift'</span> || name == <span class="hljs-string">'splice'</span>) && obj.length === <span class="hljs-number">0</span>) <span class="hljs-keyword">delete</span> obj[<span class="hljs-number">0</span>]; + <span class="hljs-keyword">return</span> result.call(<span class="hljs-keyword">this</span>, obj); + }; + });</pre></div></div> + + </li> + + + <li id="section-154"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-154">¶</a> + </div> + <p>Add all accessor Array functions to the wrapper.</p> + + </div> + + <div class="content"><div class='highlight'><pre> each([<span class="hljs-string">'concat'</span>, <span class="hljs-string">'join'</span>, <span class="hljs-string">'slice'</span>], <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(name)</span> {</span> + <span class="hljs-keyword">var</span> method = ArrayProto[name]; + _.prototype[name] = <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">return</span> result.call(<span class="hljs-keyword">this</span>, method.apply(<span class="hljs-keyword">this</span>._wrapped, <span class="hljs-built_in">arguments</span>)); + }; + }); + + _.extend(_.prototype, {</pre></div></div> + + </li> + + + <li id="section-155"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-155">¶</a> + </div> + <p>Start chaining a wrapped Underscore object.</p> + + </div> + + <div class="content"><div class='highlight'><pre> chain: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">this</span>._chain = <span class="hljs-literal">true</span>; + <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>; + },</pre></div></div> + + </li> + + + <li id="section-156"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-156">¶</a> + </div> + <p>Extracts the result from a wrapped and chained object.</p> + + </div> + + <div class="content"><div class='highlight'><pre> value: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>._wrapped; + } + + });</pre></div></div> + + </li> + + + <li id="section-157"> + <div class="annotation"> + + <div class="pilwrap "> + <a class="pilcrow" href="#section-157">¶</a> + </div> + <p>AMD registration happens at the end for compatibility with AMD loaders +that may not enforce next-turn semantics on modules. Even though general +practice for AMD registration is to be anonymous, underscore registers +as a named module because, like jQuery, it is a base library that is +popular enough to be bundled in a third party lib, but not be part of +an AMD load request. Those cases could generate an error when an +anonymous define() is called outside of a loader request.</p> + + </div> + + <div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> define === <span class="hljs-string">'function'</span> && define.amd) { + define(<span class="hljs-string">'underscore'</span>, [], <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> {</span> + <span class="hljs-keyword">return</span> _; + }); + } +}).call(<span class="hljs-keyword">this</span>);</pre></div></div> + + </li> + + </ul> + </div> +</body> +</html> diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/favicon.ico b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/favicon.ico Binary files differnew file mode 100644 index 000000000..030496838 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/favicon.ico diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/index.html b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/index.html new file mode 100644 index 000000000..785750f3e --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/index.html @@ -0,0 +1,2777 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> + <meta http-equiv="X-UA-Compatible" content="chrome=1" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0"/> + <meta name="viewport" content="target-densitydpi=device-dpi" /> + <meta name="HandheldFriendly" content="true"/> + <link rel="canonical" href="http://underscorejs.org/" /> + <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> + <title>Underscore.js</title> + <style> + body { + font-size: 14px; + line-height: 22px; + background: #f4f4f4 url(docs/images/background.png); + color: #000; + font-family: Helvetica Neue, Helvetica, Arial; + } + .interface { + font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif !important; + } + div#sidebar { + background: #fff; + position: fixed; + top: 0; left: 0; bottom: 0; + width: 200px; + overflow-y: auto; + overflow-x: hidden; + -webkit-overflow-scrolling: touch; + padding: 15px 0 30px 30px; + border-right: 1px solid #bbb; + box-shadow: 0 0 20px #ccc; -webkit-box-shadow: 0 0 20px #ccc; -moz-box-shadow: 0 0 20px #ccc; + } + a.toc_title, a.toc_title:visited { + display: block; + color: black; + font-weight: bold; + margin-top: 15px; + } + a.toc_title:hover { + text-decoration: underline; + } + #sidebar .version { + font-size: 10px; + font-weight: normal; + } + ul.toc_section { + font-size: 11px; + line-height: 14px; + margin: 5px 0 0 0; + padding-left: 0px; + list-style-type: none; + font-family: Lucida Grande; + } + .toc_section li { + cursor: pointer; + margin: 0 0 3px 0; + } + .toc_section li a { + text-decoration: none; + color: black; + } + .toc_section li a:hover { + text-decoration: underline; + } + div.container { + width: 550px; + margin: 40px 0 50px 260px; + } + img#logo { + width: 396px; + height: 69px; + } + div.warning { + margin-top: 15px; + font: bold 11px Arial; + color: #770000; + } + p { + margin: 20px 0; + width: 550px; + } + a, a:visited { + color: #444; + } + a:active, a:hover { + color: #000; + } + h1, h2, h3, h4, h5, h6 { + padding-top: 20px; + } + h2 { + font-size: 20px; + } + b.header { + font-size: 16px; + line-height: 30px; + } + span.alias { + font-size: 14px; + font-style: italic; + margin-left: 20px; + } + table, tr, td { + margin: 0; padding: 0; + } + td { + padding: 2px 12px 2px 0; + } + table .rule { + height: 1px; + background: #ccc; + margin: 5px 0; + } + ul { + list-style-type: circle; + padding: 0 0 0 20px; + } + li { + margin-bottom: 10px; + } + code, pre, tt { + font-family: Monaco, Consolas, "Lucida Console", monospace; + font-size: 12px; + line-height: 18px; + font-style: normal; + } + tt { + padding: 0px 3px; + background: #fff; + border: 1px solid #ddd; + zoom: 1; + } + code { + margin-left: 20px; + } + pre { + font-size: 12px; + padding: 2px 0 2px 15px; + border-left: 5px solid #bbb; + margin: 0px 0 30px; + } + @media only screen and (-webkit-min-device-pixel-ratio: 1.5) and (max-width: 640px), + only screen and (-o-min-device-pixel-ratio: 3/2) and (max-width: 640px), + only screen and (min-device-pixel-ratio: 1.5) and (max-width: 640px) { + img { + max-width: 100%; + } + div#sidebar { + -webkit-overflow-scrolling: initial; + position: relative; + width: 90%; + height: 120px; + left: 0; + top: -7px; + padding: 10px 0 10px 30px; + border: 0; + } + img#logo { + width: auto; + height: auto; + } + div.container { + margin: 0; + width: 100%; + } + p, div.container ul { + max-width: 98%; + overflow-x: scroll; + } + pre { + overflow: scroll; + } + } + </style> +</head> +<body> + + <div id="sidebar" class="interface"> + + <a class="toc_title" href="#"> + Underscore.js <span class="version">(1.6.0)</span> + </a> + <ul class="toc_section"> + <li>» <a href="https://github.com/jashkenas/underscore">GitHub Repository</a></li> + <li>» <a href="docs/underscore.html">Annotated Source</a></li> + <li>» <a href="http://documentcloud.github.io/underscore-contrib/">Underscore-contrib</a></li> + </ul> + + <a class="toc_title" href="#"> + Introduction + </a> + + <a class="toc_title" href="#collections"> + Collections + </a> + <ul class="toc_section"> + <li>- <a href="#each">each</a></li> + <li>- <a href="#map">map</a></li> + <li>- <a href="#reduce">reduce</a></li> + <li>- <a href="#reduceRight">reduceRight</a></li> + <li>- <a href="#find">find</a></li> + <li>- <a href="#filter">filter</a></li> + <li>- <a href="#where">where</a></li> + <li>- <a href="#findWhere">findWhere</a></li> + <li>- <a href="#reject">reject</a></li> + <li>- <a href="#every">every</a></li> + <li>- <a href="#some">some</a></li> + <li>- <a href="#contains">contains</a></li> + <li>- <a href="#invoke">invoke</a></li> + <li>- <a href="#pluck">pluck</a></li> + <li>- <a href="#max">max</a></li> + <li>- <a href="#min">min</a></li> + <li>- <a href="#sortBy">sortBy</a></li> + <li>- <a href="#groupBy">groupBy</a></li> + <li>- <a href="#indexBy">indexBy</a></li> + <li>- <a href="#countBy">countBy</a></li> + <li>- <a href="#shuffle">shuffle</a></li> + <li>- <a href="#sample">sample</a></li> + <li>- <a href="#toArray">toArray</a></li> + <li>- <a href="#size">size</a></li> + <li>- <a href="#partition">partition</a></li> + </ul> + + <a class="toc_title" href="#arrays"> + Arrays + </a> + <ul class="toc_section"> + <li>- <a href="#first">first</a></li> + <li>- <a href="#initial">initial</a></li> + <li>- <a href="#last">last</a></li> + <li>- <a href="#rest">rest</a></li> + <li>- <a href="#compact">compact</a></li> + <li>- <a href="#flatten">flatten</a></li> + <li>- <a href="#without">without</a></li> + <li>- <a href="#union">union</a></li> + <li>- <a href="#intersection">intersection</a></li> + <li>- <a href="#difference">difference</a></li> + <li>- <a href="#uniq">uniq</a></li> + <li>- <a href="#zip">zip</a></li> + <li>- <a href="#object">object</a></li> + <li>- <a href="#indexOf">indexOf</a></li> + <li>- <a href="#lastIndexOf">lastIndexOf</a></li> + <li>- <a href="#sortedIndex">sortedIndex</a></li> + <li>- <a href="#range">range</a></li> + </ul> + + <a class="toc_title" href="#functions"> + Functions + </a> + <ul class="toc_section"> + <li>- <a href="#bind">bind</a></li> + <li>- <a href="#bindAll">bindAll</a></li> + <li>- <a href="#partial">partial</a></li> + <li>- <a href="#memoize">memoize</a></li> + <li>- <a href="#delay">delay</a></li> + <li>- <a href="#defer">defer</a></li> + <li>- <a href="#throttle">throttle</a></li> + <li>- <a href="#debounce">debounce</a></li> + <li>- <a href="#once">once</a></li> + <li>- <a href="#after">after</a></li> + <li>- <a href="#wrap">wrap</a></li> + <li>- <a href="#negate">negate</a></li> + <li>- <a href="#compose">compose</a></li> + </ul> + + <a class="toc_title" href="#objects"> + Objects + </a> + <ul class="toc_section"> + <li>- <a href="#keys">keys</a></li> + <li>- <a href="#values">values</a></li> + <li>- <a href="#pairs">pairs</a></li> + <li>- <a href="#invert">invert</a></li> + <li>- <a href="#object-functions">functions</a></li> + <li>- <a href="#extend">extend</a></li> + <li>- <a href="#pick">pick</a></li> + <li>- <a href="#omit">omit</a></li> + <li>- <a href="#defaults">defaults</a></li> + <li>- <a href="#clone">clone</a></li> + <li>- <a href="#tap">tap</a></li> + <li>- <a href="#has">has</a></li> + <li>- <a href="#matches">matches</a></li> + <li>- <a href="#property">property</a></li> + <li>- <a href="#isEqual">isEqual</a></li> + <li>- <a href="#isEmpty">isEmpty</a></li> + <li>- <a href="#isElement">isElement</a></li> + <li>- <a href="#isArray">isArray</a></li> + <li>- <a href="#isObject">isObject</a></li> + <li>- <a href="#isArguments">isArguments</a></li> + <li>- <a href="#isFunction">isFunction</a></li> + <li>- <a href="#isString">isString</a></li> + <li>- <a href="#isNumber">isNumber</a></li> + <li>- <a href="#isFinite">isFinite</a></li> + <li>- <a href="#isBoolean">isBoolean</a></li> + <li>- <a href="#isDate">isDate</a></li> + <li>- <a href="#isRegExp">isRegExp</a></li> + <li>- <a href="#isNaN">isNaN</a></li> + <li>- <a href="#isNull">isNull</a></li> + <li>- <a href="#isUndefined">isUndefined</a></li> + </ul> + + <a class="toc_title" href="#utility"> + Utility + </a> + <ul class="toc_section"> + <li>- <a href="#noConflict">noConflict</a></li> + <li>- <a href="#identity">identity</a></li> + <li>- <a href="#constant">constant</a></li> + <li>- <a href="#times">times</a></li> + <li>- <a href="#random">random</a></li> + <li>- <a href="#mixin">mixin</a></li> + <li>- <a href="#uniqueId">uniqueId</a></li> + <li>- <a href="#escape">escape</a></li> + <li>- <a href="#unescape">unescape</a></li> + <li>- <a href="#result">result</a></li> + <li>- <a href="#now">now</a></li> + <li>- <a href="#template">template</a></li> + </ul> + + <a class="toc_title" href="#chaining"> + Chaining + </a> + <ul class="toc_section"> + <li>- <a href="#chain">chain</a></li> + <li>- <a href="#value">value</a></li> + </ul> + + <a class="toc_title" href="#links"> + Links + </a> + + <a class="toc_title" href="#changelog"> + Change Log + </a> + + </div> + + <div class="container"> + + <p id="introduction"> + <img id="logo" src="docs/images/underscore.png" alt="Underscore.js" /> + </p> + + <p> + <a href="http://github.com/jashkenas/underscore/">Underscore</a> + is a JavaScript library that provides a whole mess of useful functional + programming helpers without extending any built-in objects. + It’s the answer to the question: “If I sit down in front of a + blank HTML page, and want to start being productive immediately, what do I need?” + … and the tie to go along with + <a href="http://jquery.com">jQuery</a>'s tux and + <a href="http://backbonejs.org">Backbone</a>'s suspenders. + </p> + + <p> + Underscore provides 80-odd functions that support both the usual + functional suspects: <b>map</b>, <b>filter</b>, <b>invoke</b> — + as well as more specialized helpers: function binding, javascript + templating, deep equality testing, and so on. + </p> + + <p> + A complete <a href="test/">Test & Benchmark Suite</a> + is included for your perusal. + </p> + + <p> + You may also read through the <a href="docs/underscore.html">annotated source code</a>. + </p> + + <p> + Enjoying Underscore, and want to turn it up to 11? Try <a href="http://documentcloud.github.io/underscore-contrib/">Underscore-contrib</a>. + </p> + + <p> + The project is + <a href="https://github.com/jashkenas/underscore">hosted on GitHub</a>. + You can report bugs and discuss features on the + <a href="https://github.com/jashkenas/underscore/issues">issues page</a>, + on Freenode in the <tt>#documentcloud</tt> channel, + or send tweets to <a href="https://twitter.com/documentcloud">@documentcloud</a>. + </p> + + <p> + <i>Underscore is an open-source component of <a href="http://documentcloud.org/">DocumentCloud</a>.</i> + </p> + + <h2>Downloads <i style="padding-left: 12px; font-size:12px;">(Right-click, and use "Save As")</i></h2> + + <table> + <tr> + <td><a href="underscore.js">Development Version (1.6.0)</a></td> + <td><i>44kb, Uncompressed with Plentiful Comments</i></td> + </tr> + <tr> + <td><a href="underscore-min.js">Production Version (1.6.0)</a></td> + <td> + <i>5.0kb, Minified and Gzipped</i> + <small>(<a href="underscore-min.map">Source Map</a>)</small> + </td> + </tr> + <tr> + <td colspan="2"><div class="rule"></div></td> + </tr> + <tr> + <td><a href="https://raw.github.com/jashkenas/underscore/master/underscore.js">Edge Version</a></td> + <td><i>Unreleased, current <tt>master</tt>, use at your own risk</i></td> + </tr> + </table> + + <h2>Installation</h2> + + <ul> + <li> + <b>Node.js</b> <tt>npm install underscore</tt> + </li> + <li> + <b>Require.js</b> <tt>require(["underscore"], ...</tt> + </li> + <li> + <b>Bower</b> <tt>bower install underscore</tt> + </li> + <li> + <b>Component</b> <tt>component install jashkenas/underscore</tt> + </li> + </ul> + + <div id="documentation"> + + <h2 id="collections">Collection Functions (Arrays or Objects)</h2> + + <p id="each"> + <b class="header">each</b><code>_.each(list, iterator, [context])</code> + <span class="alias">Alias: <b>forEach</b></span> + <br /> + Iterates over a <b>list</b> of elements, yielding each in turn to an <b>iterator</b> + function. The <b>iterator</b> is bound to the <b>context</b> object, if one is + passed. Each invocation of <b>iterator</b> is called with three arguments: + <tt>(element, index, list)</tt>. If <b>list</b> is a JavaScript object, <b>iterator</b>'s + arguments will be <tt>(value, key, list)</tt>. Returns the <b>list</b> for chaining. + </p> + <pre> +_.each([1, 2, 3], alert); +=> alerts each number in turn... +_.each({one: 1, two: 2, three: 3}, alert); +=> alerts each number value in turn...</pre> + + <p> + <i> + Note: Collection functions work on arrays, objects, and + array-like objects such as</i> <tt>arguments</tt>, <tt>NodeList</tt><i> + and similar. But it works by duck-typing, so avoid passing objects with + a numeric <tt>length</tt> property. It's also good to note that an + <tt>each</tt> loop cannot be broken out of — to break, use <b>_.find</b> + instead. + </i> + </p> + + <p id="map"> + <b class="header">map</b><code>_.map(list, iterator, [context])</code> + <span class="alias">Alias: <b>collect</b></span> + <br /> + Produces a new array of values by mapping each value in <b>list</b> + through a transformation function (<b>iterator</b>). If <b>list</b> + is a JavaScript object, <b>iterator</b>'s arguments will be + <tt>(value, key, list)</tt>. + </p> + <pre> +_.map([1, 2, 3], function(num){ return num * 3; }); +=> [3, 6, 9] +_.map({one: 1, two: 2, three: 3}, function(num, key){ return num * 3; }); +=> [3, 6, 9]</pre> + + <p id="reduce"> + <b class="header">reduce</b><code>_.reduce(list, iterator, memo, [context])</code> + <span class="alias">Aliases: <b>inject, foldl</b></span> + <br /> + Also known as <b>inject</b> and <b>foldl</b>, <b>reduce</b> boils down a + <b>list</b> of values into a single value. <b>Memo</b> is the initial state + of the reduction, and each successive step of it should be returned by + <b>iterator</b>. The iterator is passed four arguments: the <tt>memo</tt>, + then the <tt>value</tt> and <tt>index</tt> (or key) of the iteration, + and finally a reference to the entire <tt>list</tt>. + </p> + <pre> +var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0); +=> 6 +</pre> + + <p id="reduceRight"> + <b class="header">reduceRight</b><code>_.reduceRight(list, iterator, memo, [context])</code> + <span class="alias">Alias: <b>foldr</b></span> + <br /> + The right-associative version of <b>reduce</b>. Delegates to the + JavaScript 1.8 version of <b>reduceRight</b>, if it exists. <b>Foldr</b> + is not as useful in JavaScript as it would be in a language with lazy + evaluation. + </p> + <pre> +var list = [[0, 1], [2, 3], [4, 5]]; +var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); +=> [4, 5, 2, 3, 0, 1] +</pre> + + <p id="find"> + <b class="header">find</b><code>_.find(list, predicate, [context])</code> + <span class="alias">Alias: <b>detect</b></span> + <br /> + Looks through each value in the <b>list</b>, returning the first one that + passes a truth test (<b>predicate</b>), or <tt>undefined</tt> if no value + passes the test. The function returns as + soon as it finds an acceptable element, and doesn't traverse the + entire list. + </p> + <pre> +var even = _.find([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; }); +=> 2 +</pre> + + <p id="filter"> + <b class="header">filter</b><code>_.filter(list, predicate, [context])</code> + <span class="alias">Alias: <b>select</b></span> + <br /> + Looks through each value in the <b>list</b>, returning an array of all + the values that pass a truth test (<b>predicate</b>). + </p> + <pre> +var evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; }); +=> [2, 4, 6] +</pre> + + <p id="where"> + <b class="header">where</b><code>_.where(list, properties)</code> + <br /> + Looks through each value in the <b>list</b>, returning an array of all + the values that contain all of the key-value pairs listed in <b>properties</b>. + </p> + <pre> +_.where(listOfPlays, {author: "Shakespeare", year: 1611}); +=> [{title: "Cymbeline", author: "Shakespeare", year: 1611}, + {title: "The Tempest", author: "Shakespeare", year: 1611}] +</pre> + + <p id="findWhere"> + <b class="header">findWhere</b><code>_.findWhere(list, properties)</code> + <br /> + Looks through the <b>list</b> and returns the <i>first</i> value that matches + all of the key-value pairs listed in <b>properties</b>. + </p> + <p> + If no match is found, or if <b>list</b> is empty, <i>undefined</i> will be + returned. + </p> + <pre> +_.findWhere(publicServicePulitzers, {newsroom: "The New York Times"}); +=> {year: 1918, newsroom: "The New York Times", + reason: "For its public service in publishing in full so many official reports, + documents and speeches by European statesmen relating to the progress and + conduct of the war."} +</pre> + + <p id="reject"> + <b class="header">reject</b><code>_.reject(list, predicate, [context])</code> + <br /> + Returns the values in <b>list</b> without the elements that the truth + test (<b>predicate</b>) passes. The opposite of <b>filter</b>. + </p> + <pre> +var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; }); +=> [1, 3, 5] +</pre> + + <p id="every"> + <b class="header">every</b><code>_.every(list, [predicate], [context])</code> + <span class="alias">Alias: <b>all</b></span> + <br /> + Returns <i>true</i> if all of the values in the <b>list</b> pass the + <b>predicate</b> truth test. + </p> + <pre> +_.every([true, 1, null, 'yes'], _.identity); +=> false +</pre> + + <p id="some"> + <b class="header">some</b><code>_.some(list, [predicate], [context])</code> + <span class="alias">Alias: <b>any</b></span> + <br /> + Returns <i>true</i> if any of the values in the <b>list</b> pass the + <b>predicate</b> truth test. Short-circuits and stops traversing the list + if a true element is found. + </p> + <pre> +_.some([null, 0, 'yes', false]); +=> true +</pre> + + <p id="contains"> + <b class="header">contains</b><code>_.contains(list, value)</code> + <span class="alias">Alias: <b>include</b></span> + <br /> + Returns <i>true</i> if the <b>value</b> is present in the <b>list</b>. + Uses <b>indexOf</b> internally, if <b>list</b> is an Array. + </p> + <pre> +_.contains([1, 2, 3], 3); +=> true +</pre> + + <p id="invoke"> + <b class="header">invoke</b><code>_.invoke(list, methodName, *arguments)</code> + <br /> + Calls the method named by <b>methodName</b> on each value in the <b>list</b>. + Any extra arguments passed to <b>invoke</b> will be forwarded on to the + method invocation. + </p> + <pre> +_.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); +=> [[1, 5, 7], [1, 2, 3]] +</pre> + + <p id="pluck"> + <b class="header">pluck</b><code>_.pluck(list, propertyName)</code> + <br /> + A convenient version of what is perhaps the most common use-case for + <b>map</b>: extracting a list of property values. + </p> + <pre> +var stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}]; +_.pluck(stooges, 'name'); +=> ["moe", "larry", "curly"] +</pre> + + <p id="max"> + <b class="header">max</b><code>_.max(list, [iterator], [context])</code> + <br /> + Returns the maximum value in <b>list</b>. If an <b>iterator</b> + function is provided, it will be used on each value to generate the + criterion by which the value is ranked. <i>-Infinity</i> is returned + if <b>list</b> is empty, so an <a href="#isEmpty">isEmpty</a> guard + may be required. + </p> + <pre> +var stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}]; +_.max(stooges, function(stooge){ return stooge.age; }); +=> {name: 'curly', age: 60}; +</pre> + + <p id="min"> + <b class="header">min</b><code>_.min(list, [iterator], [context])</code> + <br /> + Returns the minimum value in <b>list</b>. If an <b>iterator</b> + function is provided, it will be used on each value to generate the + criterion by which the value is ranked. <i>Infinity</i> is returned + if <b>list</b> is empty, so an <a href="#isEmpty">isEmpty</a> guard + may be required. + </p> + <pre> +var numbers = [10, 5, 100, 2, 1000]; +_.min(numbers); +=> 2 +</pre> + + <p id="sortBy"> + <b class="header">sortBy</b><code>_.sortBy(list, iterator, [context])</code> + <br /> + Returns a (stably) sorted copy of <b>list</b>, ranked in ascending + order by the results of running each value through <b>iterator</b>. + Iterator may also be the string name of the property to sort by (eg. + <tt>length</tt>). + </p> + <pre> +_.sortBy([1, 2, 3, 4, 5, 6], function(num){ return Math.sin(num); }); +=> [5, 4, 6, 3, 1, 2] +</pre> + + <p id="groupBy"> + <b class="header">groupBy</b><code>_.groupBy(list, iterator, [context])</code> + <br /> + Splits a collection into sets, grouped by the result of running each + value through <b>iterator</b>. If <b>iterator</b> is a string instead of + a function, groups by the property named by <b>iterator</b> on each of + the values. + </p> + <pre> +_.groupBy([1.3, 2.1, 2.4], function(num){ return Math.floor(num); }); +=> {1: [1.3], 2: [2.1, 2.4]} + +_.groupBy(['one', 'two', 'three'], 'length'); +=> {3: ["one", "two"], 5: ["three"]} +</pre> + + <p id="indexBy"> + <b class="header">indexBy</b><code>_.indexBy(list, iterator, [context])</code> + <br /> + Given a <b>list</b>, and an <b>iterator</b> function that returns a + key for each element in the list (or a property name), + returns an object with an index of each item. + Just like <a href="#groupBy">groupBy</a>, but for when you know your + keys are unique. + </p> + <pre> +var stooges = [{name: 'moe', age: 40}, {name: 'larry', age: 50}, {name: 'curly', age: 60}]; +_.indexBy(stooges, 'age'); +=> { + "40": {name: 'moe', age: 40}, + "50": {name: 'larry', age: 50}, + "60": {name: 'curly', age: 60} +} +</pre> + + <p id="countBy"> + <b class="header">countBy</b><code>_.countBy(list, iterator, [context])</code> + <br /> + Sorts a list into groups and returns a count for the number of objects + in each group. + Similar to <tt>groupBy</tt>, but instead of returning a list of values, + returns a count for the number of values in that group. + </p> + <pre> +_.countBy([1, 2, 3, 4, 5], function(num) { + return num % 2 == 0 ? 'even': 'odd'; +}); +=> {odd: 3, even: 2} +</pre> + + <p id="shuffle"> + <b class="header">shuffle</b><code>_.shuffle(list)</code> + <br /> + Returns a shuffled copy of the <b>list</b>, using a version of the + <a href="http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle</a>. + </p> + <pre> +_.shuffle([1, 2, 3, 4, 5, 6]); +=> [4, 1, 6, 3, 5, 2] +</pre> + + <p id="sample"> + <b class="header">sample</b><code>_.sample(list, [n])</code> + <br /> + Produce a random sample from the <b>list</b>. Pass a number to + return <b>n</b> random elements from the list. Otherwise a single random + item will be returned. + </p> + <pre> +_.sample([1, 2, 3, 4, 5, 6]); +=> 4 + +_.sample([1, 2, 3, 4, 5, 6], 3); +=> [1, 6, 2] +</pre> + + <p id="toArray"> + <b class="header">toArray</b><code>_.toArray(list)</code> + <br /> + Creates a real Array from the <b>list</b> (anything that can be + iterated over). Useful for transmuting the <b>arguments</b> object. + </p> + <pre> +(function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +=> [2, 3, 4] +</pre> + + <p id="size"> + <b class="header">size</b><code>_.size(list)</code> + <br /> + Return the number of values in the <b>list</b>. + </p> + <pre> +_.size({one: 1, two: 2, three: 3}); +=> 3 +</pre> + + <p id="partition"> + <b class="header">partition</b><code>_.partition(array, predicate)</code> + <br /> + Split <b>array</b> into two arrays: one whose elements all satisfy + <b>predicate</b> and one whose elements all do not satisfy <b>predicate</b>. + </p> + <pre> +_.partition([0, 1, 2, 3, 4, 5], isOdd); +=> [[1, 3, 5], [0, 2, 4]] +</pre> + + <h2 id="arrays">Array Functions</h2> + + <p> + <i> + Note: All array functions will also work on the <b>arguments</b> object. + However, Underscore functions are not designed to work on "sparse" arrays. + </i> + </p> + + <p id="first"> + <b class="header">first</b><code>_.first(array, [n])</code> + <span class="alias">Alias: <b>head</b>, <b>take</b></span> + <br /> + Returns the first element of an <b>array</b>. Passing <b>n</b> will + return the first <b>n</b> elements of the array. + </p> + <pre> +_.first([5, 4, 3, 2, 1]); +=> 5 +</pre> + + <p id="initial"> + <b class="header">initial</b><code>_.initial(array, [n])</code> + <br /> + Returns everything but the last entry of the array. Especially useful on + the arguments object. Pass <b>n</b> to exclude the last <b>n</b> elements + from the result. + </p> + <pre> +_.initial([5, 4, 3, 2, 1]); +=> [5, 4, 3, 2] +</pre> + + <p id="last"> + <b class="header">last</b><code>_.last(array, [n])</code> + <br /> + Returns the last element of an <b>array</b>. Passing <b>n</b> will return + the last <b>n</b> elements of the array. + </p> + <pre> +_.last([5, 4, 3, 2, 1]); +=> 1 +</pre> + + <p id="rest"> + <b class="header">rest</b><code>_.rest(array, [index])</code> + <span class="alias">Alias: <b>tail, drop</b></span> + <br /> + Returns the <b>rest</b> of the elements in an array. Pass an <b>index</b> + to return the values of the array from that index onward. + </p> + <pre> +_.rest([5, 4, 3, 2, 1]); +=> [4, 3, 2, 1] +</pre> + + <p id="compact"> + <b class="header">compact</b><code>_.compact(array)</code> + <br /> + Returns a copy of the <b>array</b> with all falsy values removed. + In JavaScript, <i>false</i>, <i>null</i>, <i>0</i>, <i>""</i>, + <i>undefined</i> and <i>NaN</i> are all falsy. + </p> + <pre> +_.compact([0, 1, false, 2, '', 3]); +=> [1, 2, 3] +</pre> + + <p id="flatten"> + <b class="header">flatten</b><code>_.flatten(array, [shallow])</code> + <br /> + Flattens a nested <b>array</b> (the nesting can be to any depth). If you + pass <b>shallow</b>, the array will only be flattened a single level. + </p> + <pre> +_.flatten([1, [2], [3, [[4]]]]); +=> [1, 2, 3, 4]; + +_.flatten([1, [2], [3, [[4]]]], true); +=> [1, 2, 3, [[4]]]; +</pre> + + <p id="without"> + <b class="header">without</b><code>_.without(array, *values)</code> + <br /> + Returns a copy of the <b>array</b> with all instances of the <b>values</b> + removed. + </p> + <pre> +_.without([1, 2, 1, 0, 3, 1, 4], 0, 1); +=> [2, 3, 4] +</pre> + + <p id="union"> + <b class="header">union</b><code>_.union(*arrays)</code> + <br /> + Computes the union of the passed-in <b>arrays</b>: the list of unique items, + in order, that are present in one or more of the <b>arrays</b>. + </p> + <pre> +_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); +=> [1, 2, 3, 101, 10] +</pre> + + <p id="intersection"> + <b class="header">intersection</b><code>_.intersection(*arrays)</code> + <br /> + Computes the list of values that are the intersection of all the <b>arrays</b>. + Each value in the result is present in each of the <b>arrays</b>. + </p> + <pre> +_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); +=> [1, 2] +</pre> + + <p id="difference"> + <b class="header">difference</b><code>_.difference(array, *others)</code> + <br /> + Similar to <b>without</b>, but returns the values from <b>array</b> that + are not present in the <b>other</b> arrays. + </p> + <pre> +_.difference([1, 2, 3, 4, 5], [5, 2, 10]); +=> [1, 3, 4] +</pre> + + <p id="uniq"> + <b class="header">uniq</b><code>_.uniq(array, [isSorted], [iterator])</code> + <span class="alias">Alias: <b>unique</b></span> + <br /> + Produces a duplicate-free version of the <b>array</b>, using <i>===</i> to test + object equality. If you know in advance that the <b>array</b> is sorted, + passing <i>true</i> for <b>isSorted</b> will run a much faster algorithm. + If you want to compute unique items based on a transformation, pass an + <b>iterator</b> function. + </p> + <pre> +_.uniq([1, 2, 1, 3, 1, 4]); +=> [1, 2, 3, 4] +</pre> + + <p id="zip"> + <b class="header">zip</b><code>_.zip(*arrays)</code> + <br /> + Merges together the values of each of the <b>arrays</b> with the + values at the corresponding position. Useful when you have separate + data sources that are coordinated through matching array indexes. + If you're working with a matrix of nested arrays, <tt>_.zip.apply</tt> + can transpose the matrix in a similar fashion. + </p> + <pre> +_.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); +=> [["moe", 30, true], ["larry", 40, false], ["curly", 50, false]] + +_.zip.apply(_, arrayOfRowsOfData); +=> arrayOfColumnsOfData +</pre> + + <p id="object"> + <b class="header">object</b><code>_.object(list, [values])</code> + <br /> + Converts arrays into objects. Pass either a single list of + <tt>[key, value]</tt> pairs, or a list of keys, and a list of values. + If duplicate keys exist, the last value wins. + </p> + <pre> +_.object(['moe', 'larry', 'curly'], [30, 40, 50]); +=> {moe: 30, larry: 40, curly: 50} + +_.object([['moe', 30], ['larry', 40], ['curly', 50]]); +=> {moe: 30, larry: 40, curly: 50} +</pre> + + <p id="indexOf"> + <b class="header">indexOf</b><code>_.indexOf(array, value, [isSorted])</code> + <br /> + Returns the index at which <b>value</b> can be found in the <b>array</b>, + or <i>-1</i> if value is not present in the <b>array</b>. If you're working with a + large array, and you know that the array is already sorted, pass <tt>true</tt> + for <b>isSorted</b> to use a faster binary search ... or, pass a number as + the third argument in order to look for the first matching value in the + array after the given index. + </p> + <pre> +_.indexOf([1, 2, 3], 2); +=> 1 +</pre> + + <p id="lastIndexOf"> + <b class="header">lastIndexOf</b><code>_.lastIndexOf(array, value, [fromIndex])</code> + <br /> + Returns the index of the last occurrence of <b>value</b> in the <b>array</b>, + or <i>-1</i> if value is not present. Pass <b>fromIndex</b> to start your search at a + given index. + </p> + <pre> +_.lastIndexOf([1, 2, 3, 1, 2, 3], 2); +=> 4 +</pre> + + <p id="sortedIndex"> + <b class="header">sortedIndex</b><code>_.sortedIndex(list, value, [iterator], [context])</code> + <br /> + Uses a binary search to determine the index at which the <b>value</b> + <i>should</i> be inserted into the <b>list</b> in order to maintain the <b>list</b>'s + sorted order. If an <b>iterator</b> function is provided, it will be used to compute + the sort ranking of each value, including the <b>value</b> you pass. + Iterator may also be the string name of the property to sort by (eg. <tt>length</tt>). + </p> + <pre> +_.sortedIndex([10, 20, 30, 40, 50], 35); +=> 3 + +var stooges = [{name: 'moe', age: 40}, {name: 'curly', age: 60}]; +_.sortedIndex(stooges, {name: 'larry', age: 50}, 'age'); +=> 1 +</pre> + + <p id="range"> + <b class="header">range</b><code>_.range([start], stop, [step])</code> + <br /> + A function to create flexibly-numbered lists of integers, handy for + <tt>each</tt> and <tt>map</tt> loops. <b>start</b>, if omitted, defaults + to <i>0</i>; <b>step</b> defaults to <i>1</i>. Returns a list of integers + from <b>start</b> to <b>stop</b>, incremented (or decremented) by <b>step</b>, + exclusive. Note that ranges that <b>stop</b> before they <b>start</b> + are considered to be zero-length instead of negative — if you'd like a + negative range, use a negative <b>step</b>. + </p> + <pre> +_.range(10); +=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +_.range(1, 11); +=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +_.range(0, 30, 5); +=> [0, 5, 10, 15, 20, 25] +_.range(0, -10, -1); +=> [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] +_.range(0); +=> [] +</pre> + + <h2 id="functions">Function (uh, ahem) Functions</h2> + + <p id="bind"> + <b class="header">bind</b><code>_.bind(function, object, *arguments)</code> + <br /> + Bind a <b>function</b> to an <b>object</b>, meaning that whenever + the function is called, the value of <i>this</i> will be the <b>object</b>. + Optionally, pass <b>arguments</b> to the <b>function</b> to pre-fill them, + also known as <b>partial application</b>. For partial application without + context binding, use <a href="#partial">partial</a>. + </p> + <pre> +var func = function(greeting){ return greeting + ': ' + this.name }; +func = _.bind(func, {name: 'moe'}, 'hi'); +func(); +=> 'hi: moe' +</pre> + + <p id="bindAll"> + <b class="header">bindAll</b><code>_.bindAll(object, *methodNames)</code> + <br /> + Binds a number of methods on the <b>object</b>, specified by + <b>methodNames</b>, to be run in the context of that object whenever they + are invoked. Very handy for binding functions that are going to be used + as event handlers, which would otherwise be invoked with a fairly useless + <i>this</i>. <b>methodNames</b> are required. + </p> + <pre> +var buttonView = { + label : 'underscore', + onClick: function(){ alert('clicked: ' + this.label); }, + onHover: function(){ console.log('hovering: ' + this.label); } +}; +_.bindAll(buttonView, 'onClick', 'onHover'); +// When the button is clicked, this.label will have the correct value. +jQuery('#underscore_button').bind('click', buttonView.onClick); +</pre> + + <p id="partial"> + <b class="header">partial</b><code>_.partial(function, *arguments)</code> + <br /> + Partially apply a function by filling in any number of its <b>arguments</b>, + <i>without</i> changing its dynamic <tt>this</tt> value. A close cousin + of <a href="#bind">bind</a>. You may pass <tt>_</tt> in your list of + <b>arguments</b> to specify an argument that should not be pre-filled, but + left open to supply at call-time. + </p> + <pre> +var add = function(a, b) { return a + b; }; +add5 = _.partial(add, 5); +add5(10); +=> 15 +</pre> + + <p id="memoize"> + <b class="header">memoize</b><code>_.memoize(function, [hashFunction])</code> + <br /> + Memoizes a given <b>function</b> by caching the computed result. Useful + for speeding up slow-running computations. If passed an optional + <b>hashFunction</b>, it will be used to compute the hash key for storing + the result, based on the arguments to the original function. The default + <b>hashFunction</b> just uses the first argument to the memoized function + as the key. + </p> + <pre> +var fibonacci = _.memoize(function(n) { + return n < 2 ? n: fibonacci(n - 1) + fibonacci(n - 2); +}); +</pre> + + <p id="delay"> + <b class="header">delay</b><code>_.delay(function, wait, *arguments)</code> + <br /> + Much like <b>setTimeout</b>, invokes <b>function</b> after <b>wait</b> + milliseconds. If you pass the optional <b>arguments</b>, they will be + forwarded on to the <b>function</b> when it is invoked. + </p> + <pre> +var log = _.bind(console.log, console); +_.delay(log, 1000, 'logged later'); +=> 'logged later' // Appears after one second. +</pre> + + <p id="defer"> + <b class="header">defer</b><code>_.defer(function, *arguments)</code> + <br /> + Defers invoking the <b>function</b> until the current call stack has cleared, + similar to using <b>setTimeout</b> with a delay of 0. Useful for performing + expensive computations or HTML rendering in chunks without blocking the UI thread + from updating. If you pass the optional <b>arguments</b>, they will be + forwarded on to the <b>function</b> when it is invoked. + </p> + <pre> +_.defer(function(){ alert('deferred'); }); +// Returns from the function before the alert runs. +</pre> + + <p id="throttle"> + <b class="header">throttle</b><code>_.throttle(function, wait, [options])</code> + <br /> + Creates and returns a new, throttled version of the passed function, + that, when invoked repeatedly, will only actually call the original function + at most once per every <b>wait</b> + milliseconds. Useful for rate-limiting events that occur faster than you + can keep up with. + </p> + <p> + By default, <b>throttle</b> will execute the function as soon as you call it + for the first time, and, if you call it again any number of times + during the <b>wait</b> period, as soon as that period is over. + If you'd like to disable the leading-edge + call, pass <tt>{leading: false}</tt>, and if you'd like to disable the + execution on the trailing-edge, pass <br /> <tt>{trailing: false}</tt>. + </p> + <pre> +var throttled = _.throttle(updatePosition, 100); +$(window).scroll(throttled); +</pre> + + <p id="debounce"> + <b class="header">debounce</b><code>_.debounce(function, wait, [immediate])</code> + <br /> + Creates and returns a new debounced version of the passed function which + will postpone its execution until after + <b>wait</b> milliseconds have elapsed since the last time it + was invoked. Useful for implementing behavior that should only happen + <i>after</i> the input has stopped arriving. For example: rendering a + preview of a Markdown comment, recalculating a layout after the window + has stopped being resized, and so on. + </p> + + <p> + Pass <tt>true</tt> for the <b>immediate</b> parameter to cause + <b>debounce</b> to trigger the function on the leading instead of the + trailing edge of the <b>wait</b> interval. Useful in circumstances like + preventing accidental double-clicks on a "submit" button from firing a + second time. + </p> + + <pre> +var lazyLayout = _.debounce(calculateLayout, 300); +$(window).resize(lazyLayout); +</pre> + + <p id="once"> + <b class="header">once</b><code>_.once(function)</code> + <br /> + Creates a version of the function that can only be called one time. + Repeated calls to the modified function will have no effect, returning + the value from the original call. Useful for initialization functions, + instead of having to set a boolean flag and then check it later. + </p> + <pre> +var initialize = _.once(createApplication); +initialize(); +initialize(); +// Application is only created once. +</pre> + + <p id="after"> + <b class="header">after</b><code>_.after(count, function)</code> + <br /> + Creates a version of the function that will only be run after first + being called <b>count</b> times. Useful for grouping asynchronous responses, + where you want to be sure that all the async calls have finished, before + proceeding. + </p> + <pre> +var renderNotes = _.after(notes.length, render); +_.each(notes, function(note) { + note.asyncSave({success: renderNotes}); +}); +// renderNotes is run once, after all notes have saved. +</pre> + + <p id="wrap"> + <b class="header">wrap</b><code>_.wrap(function, wrapper)</code> + <br /> + Wraps the first <b>function</b> inside of the <b>wrapper</b> function, + passing it as the first argument. This allows the <b>wrapper</b> to + execute code before and after the <b>function</b> runs, adjust the arguments, + and execute it conditionally. + </p> + <pre> +var hello = function(name) { return "hello: " + name; }; +hello = _.wrap(hello, function(func) { + return "before, " + func("moe") + ", after"; +}); +hello(); +=> 'before, hello: moe, after' +</pre> + + <p id="negate"> + <b class="header">negate</b><code>_.negate(predicate)</code> + <br /> + Returns a new negated version of the <b>predicate</b> function. + </p> + <pre> +var isFalsy = _.negate(Boolean); +_.find([-2, -1, 0, 1, 2], isFalsy); +=> 0 +</pre> + + <p id="compose"> + <b class="header">compose</b><code>_.compose(*functions)</code> + <br /> + Returns the composition of a list of <b>functions</b>, where each function + consumes the return value of the function that follows. In math terms, + composing the functions <i>f()</i>, <i>g()</i>, and <i>h()</i> produces + <i>f(g(h()))</i>. + </p> + <pre> +var greet = function(name){ return "hi: " + name; }; +var exclaim = function(statement){ return statement.toUpperCase() + "!"; }; +var welcome = _.compose(greet, exclaim); +welcome('moe'); +=> 'hi: MOE!' +</pre> + + <h2 id="objects">Object Functions</h2> + + <p id="keys"> + <b class="header">keys</b><code>_.keys(object)</code> + <br /> + Retrieve all the names of the <b>object</b>'s properties. + </p> + <pre> +_.keys({one: 1, two: 2, three: 3}); +=> ["one", "two", "three"] +</pre> + + <p id="values"> + <b class="header">values</b><code>_.values(object)</code> + <br /> + Return all of the values of the <b>object</b>'s properties. + </p> + <pre> +_.values({one: 1, two: 2, three: 3}); +=> [1, 2, 3] +</pre> + + <p id="pairs"> + <b class="header">pairs</b><code>_.pairs(object)</code> + <br /> + Convert an object into a list of <tt>[key, value]</tt> pairs. + </p> + <pre> +_.pairs({one: 1, two: 2, three: 3}); +=> [["one", 1], ["two", 2], ["three", 3]] +</pre> + + <p id="invert"> + <b class="header">invert</b><code>_.invert(object)</code> + <br /> + Returns a copy of the <b>object</b> where the keys have become the values + and the values the keys. For this to work, all of your object's values + should be unique and string serializable. + </p> + <pre> +_.invert({Moe: "Moses", Larry: "Louis", Curly: "Jerome"}); +=> {Moses: "Moe", Louis: "Larry", Jerome: "Curly"}; +</pre> + + <p id="object-functions"> + <b class="header">functions</b><code>_.functions(object)</code> + <span class="alias">Alias: <b>methods</b></span> + <br /> + Returns a sorted list of the names of every method in an object — + that is to say, the name of every function property of the object. + </p> + <pre> +_.functions(_); +=> ["all", "any", "bind", "bindAll", "clone", "compact", "compose" ... +</pre> + + <p id="extend"> + <b class="header">extend</b><code>_.extend(destination, *sources)</code> + <br /> + Copy all of the properties in the <b>source</b> objects over to the + <b>destination</b> object, and return the <b>destination</b> object. + It's in-order, so the last source will override properties of the same + name in previous arguments. + </p> + <pre> +_.extend({name: 'moe'}, {age: 50}); +=> {name: 'moe', age: 50} +</pre> + + <p id="pick"> + <b class="header">pick</b><code>_.pick(object, *keys)</code> + <br /> + Return a copy of the <b>object</b>, filtered to only have values for + the whitelisted <b>keys</b> (or array of valid keys). Alternatively + accepts a predicate indicating which keys to pick. + </p> + <pre> +_.pick({name: 'moe', age: 50, userid: 'moe1'}, 'name', 'age'); +=> {name: 'moe', age: 50} +_.pick({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) { + return _.isNumber(value); +}); +=> {age: 50} +</pre> + + <p id="omit"> + <b class="header">omit</b><code>_.omit(object, *keys)</code> + <br /> + Return a copy of the <b>object</b>, filtered to omit the blacklisted + <b>keys</b> (or array of keys). Alternatively accepts a predicate + indicating which keys to omit. + </p> + <pre> +_.omit({name: 'moe', age: 50, userid: 'moe1'}, 'userid'); +=> {name: 'moe', age: 50} +_.omit({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) { + return _.isNumber(value); +}); +=> {name: 'moe', userid: 'moe1'} +</pre> + + <p id="defaults"> + <b class="header">defaults</b><code>_.defaults(object, *defaults)</code> + <br /> + Fill in <tt>undefined</tt> properties in <b>object</b> with the first + value present in the following list of <b>defaults</b> objects. + </p> + <pre> +var iceCream = {flavor: "chocolate"}; +_.defaults(iceCream, {flavor: "vanilla", sprinkles: "lots"}); +=> {flavor: "chocolate", sprinkles: "lots"} +</pre> + + <p id="clone"> + <b class="header">clone</b><code>_.clone(object)</code> + <br /> + Create a shallow-copied clone of the <b>object</b>. Any nested objects + or arrays will be copied by reference, not duplicated. + </p> + <pre> +_.clone({name: 'moe'}); +=> {name: 'moe'}; +</pre> + + <p id="tap"> + <b class="header">tap</b><code>_.tap(object, interceptor)</code> + <br /> + Invokes <b>interceptor</b> with the <b>object</b>, and then returns <b>object</b>. + The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. + </p> + <pre> +_.chain([1,2,3,200]) + .filter(function(num) { return num % 2 == 0; }) + .tap(alert) + .map(function(num) { return num * num }) + .value(); +=> // [2, 200] (alerted) +=> [4, 40000] +</pre> + + <p id="has"> + <b class="header">has</b><code>_.has(object, key)</code> + <br /> + Does the object contain the given key? Identical to + <tt>object.hasOwnProperty(key)</tt>, but uses a safe reference to the + <tt>hasOwnProperty</tt> function, in case it's been + <a href="http://www.devthought.com/2012/01/18/an-object-is-not-a-hash/">overridden accidentally</a>. + </p> + <pre> +_.has({a: 1, b: 2, c: 3}, "b"); +=> true +</pre> + + <p id="property"> + <b class="header">property</b><code>_.property(key)</code> + <br /> + Returns a function that will itself return the <tt>key</tt> + property of any passed-in object. + </p> + <pre> +var moe = {name: 'moe'}; +'moe' === _.property('name')(moe); +=> true</pre> + + <p id="matches"> + <b class="header">matches</b><code>_.matches(attrs)</code> + <br /> + Returns a predicate function that will tell you if a passed in object + contains all of the key/value properties present in <b>attrs</b>. + </p> + <pre> +var ready = _.matches({selected: true, visible: true}); +var readyToGoList = _.filter(list, ready);</pre> + + <p id="isEqual"> + <b class="header">isEqual</b><code>_.isEqual(object, other)</code> + <br /> + Performs an optimized deep comparison between the two objects, to determine + if they should be considered equal. + </p> + <pre> +var moe = {name: 'moe', luckyNumbers: [13, 27, 34]}; +var clone = {name: 'moe', luckyNumbers: [13, 27, 34]}; +moe == clone; +=> false +_.isEqual(moe, clone); +=> true +</pre> + + <p id="isEmpty"> + <b class="header">isEmpty</b><code>_.isEmpty(object)</code> + <br /> + Returns <i>true</i> if an enumerable <b>object</b> contains no + values (no enumerable own-properties). For strings and array-like + objects <tt>_.isEmpty</tt> checks if the length property is 0. + </p> + <pre> +_.isEmpty([1, 2, 3]); +=> false +_.isEmpty({}); +=> true +</pre> + + <p id="isElement"> + <b class="header">isElement</b><code>_.isElement(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is a DOM element. + </p> + <pre> +_.isElement(jQuery('body')[0]); +=> true +</pre> + + <p id="isArray"> + <b class="header">isArray</b><code>_.isArray(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is an Array. + </p> + <pre> +(function(){ return _.isArray(arguments); })(); +=> false +_.isArray([1,2,3]); +=> true +</pre> + + <p id="isObject"> + <b class="header">isObject</b><code>_.isObject(value)</code> + <br /> + Returns <i>true</i> if <b>value</b> is an Object. Note that JavaScript + arrays and functions are objects, while (normal) strings and numbers are not. + </p> + <pre> +_.isObject({}); +=> true +_.isObject(1); +=> false +</pre> + + <p id="isArguments"> + <b class="header">isArguments</b><code>_.isArguments(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is an Arguments object. + </p> + <pre> +(function(){ return _.isArguments(arguments); })(1, 2, 3); +=> true +_.isArguments([1,2,3]); +=> false +</pre> + + <p id="isFunction"> + <b class="header">isFunction</b><code>_.isFunction(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is a Function. + </p> + <pre> +_.isFunction(alert); +=> true +</pre> + + <p id="isString"> + <b class="header">isString</b><code>_.isString(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is a String. + </p> + <pre> +_.isString("moe"); +=> true +</pre> + + <p id="isNumber"> + <b class="header">isNumber</b><code>_.isNumber(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is a Number (including <tt>NaN</tt>). + </p> + <pre> +_.isNumber(8.4 * 5); +=> true +</pre> + + <p id="isFinite"> + <b class="header">isFinite</b><code>_.isFinite(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is a finite Number. + </p> + <pre> +_.isFinite(-101); +=> true + +_.isFinite(-Infinity); +=> false +</pre> + + <p id="isBoolean"> + <b class="header">isBoolean</b><code>_.isBoolean(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is either <i>true</i> or <i>false</i>. + </p> + <pre> +_.isBoolean(null); +=> false +</pre> + + <p id="isDate"> + <b class="header">isDate</b><code>_.isDate(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is a Date. + </p> + <pre> +_.isDate(new Date()); +=> true +</pre> + + <p id="isRegExp"> + <b class="header">isRegExp</b><code>_.isRegExp(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is a RegExp. + </p> + <pre> +_.isRegExp(/moe/); +=> true +</pre> + + <p id="isNaN"> + <b class="header">isNaN</b><code>_.isNaN(object)</code> + <br /> + Returns <i>true</i> if <b>object</b> is <i>NaN</i>.<br /> Note: this is not + the same as the native <b>isNaN</b> function, which will also return + true for many other not-number values, such as <tt>undefined</tt>. + </p> + <pre> +_.isNaN(NaN); +=> true +isNaN(undefined); +=> true +_.isNaN(undefined); +=> false +</pre> + + <p id="isNull"> + <b class="header">isNull</b><code>_.isNull(object)</code> + <br /> + Returns <i>true</i> if the value of <b>object</b> is <i>null</i>. + </p> + <pre> +_.isNull(null); +=> true +_.isNull(undefined); +=> false +</pre> + + <p id="isUndefined"> + <b class="header">isUndefined</b><code>_.isUndefined(value)</code> + <br /> + Returns <i>true</i> if <b>value</b> is <i>undefined</i>. + </p> + <pre> +_.isUndefined(window.missingVariable); +=> true +</pre> + + <h2 id="utility">Utility Functions</h2> + + <p id="noConflict"> + <b class="header">noConflict</b><code>_.noConflict()</code> + <br /> + Give control of the "_" variable back to its previous owner. Returns + a reference to the <b>Underscore</b> object. + </p> + <pre> +var underscore = _.noConflict();</pre> + + <p id="identity"> + <b class="header">identity</b><code>_.identity(value)</code> + <br /> + Returns the same value that is used as the argument. In math: + <tt>f(x) = x</tt><br /> + This function looks useless, but is used throughout Underscore as + a default iterator. + </p> + <pre> +var moe = {name: 'moe'}; +moe === _.identity(moe); +=> true</pre> + + <p id="constant"> + <b class="header">constant</b><code>_.constant(value)</code> + <br /> + Creates a function that returns the same value that is used as the + argument of <tt>_.constant</tt>. + </p> + <pre> +var moe = {name: 'moe'}; +moe === _.constant(moe)(); +=> true</pre> + + <p id="noop"> + <b class="header">noop</b><code>_.noop()</code> + <br /> + Returns <tt>undefined</tt> irrespective of the arguments passed to it. + Useful as the default for optional callback arguments. + </p> + + <p id="times"> + <b class="header">times</b><code>_.times(n, iterator, [context])</code> + <br /> + Invokes the given iterator function <b>n</b> times. Each invocation of + <b>iterator</b> is called with an <tt>index</tt> argument. Produces an + array of the returned values. + <br /> + <i>Note: this example uses the <a href="#chaining">chaining syntax</a></i>. + </p> + <pre> +_(3).times(function(n){ genie.grantWishNumber(n); });</pre> + + <p id="random"> + <b class="header">random</b><code>_.random(min, max)</code> + <br /> + Returns a random integer between <b>min</b> and <b>max</b>, inclusive. + If you only pass one argument, it will return a number between <tt>0</tt> + and that number. + </p> + <pre> +_.random(0, 100); +=> 42</pre> + + <p id="mixin"> + <b class="header">mixin</b><code>_.mixin(object)</code> + <br /> + Allows you to extend Underscore with your own utility functions. Pass + a hash of <tt>{name: function}</tt> definitions to have your functions + added to the Underscore object, as well as the OOP wrapper. + </p> + <pre> +_.mixin({ + capitalize: function(string) { + return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase(); + } +}); +_("fabio").capitalize(); +=> "Fabio" +</pre> + + <p id="uniqueId"> + <b class="header">uniqueId</b><code>_.uniqueId([prefix])</code> + <br /> + Generate a globally-unique id for client-side models or DOM elements + that need one. If <b>prefix</b> is passed, the id will be appended to it. + </p> + <pre> +_.uniqueId('contact_'); +=> 'contact_104'</pre> + + <p id="escape"> + <b class="header">escape</b><code>_.escape(string)</code> + <br /> + Escapes a string for insertion into HTML, replacing + <tt>&</tt>, <tt><</tt>, <tt>></tt>, <tt>"</tt>, and <tt>'</tt> characters. + </p> + <pre> +_.escape('Curly, Larry & Moe'); +=> "Curly, Larry &amp; Moe"</pre> + + <p id="unescape"> + <b class="header">unescape</b><code>_.unescape(string)</code> + <br /> + The opposite of <a href="#escape"><b>escape</b></a>, replaces + <tt>&amp;</tt>, <tt>&lt;</tt>, <tt>&gt;</tt>, + <tt>&quot;</tt>, and <tt>&#x27;</tt> + with their unescaped counterparts. + </p> + <pre> +_.unescape('Curly, Larry &amp; Moe'); +=> "Curly, Larry & Moe"</pre> + + <p id="result"> + <b class="header">result</b><code>_.result(object, property)</code> + <br /> + If the value of the named <b>property</b> is a function then invoke it + with the <b>object</b> as context; otherwise, return it. + </p> + <pre> +var object = {cheese: 'crumpets', stuff: function(){ return 'nonsense'; }}; +_.result(object, 'cheese'); +=> "crumpets" +_.result(object, 'stuff'); +=> "nonsense"</pre> + + <p id="now"> + <b class="header">now</b><code>_.now()</code> + <br /> + Returns an integer timestamp for the current time, using the fastest + method available in the runtime. Useful for implementing timing/animation + functions. + </p> + <pre> +_.now(); +=> 1392066795351 +</pre> + + <p id="template"> + <b class="header">template</b><code>_.template(templateString, [data], [settings])</code> + <br /> + Compiles JavaScript templates into functions that can be evaluated + for rendering. Useful for rendering complicated bits of HTML from JSON + data sources. Template functions can both interpolate variables, using + <tt><%= … %></tt>, as well as execute arbitrary JavaScript code, with + <tt><% … %></tt>. If you wish to interpolate a value, and have + it be HTML-escaped, use <tt><%- … %></tt> When you evaluate a template function, pass in a + <b>data</b> object that has properties corresponding to the template's free + variables. If you're writing a one-off, you can pass the <b>data</b> + object as the second parameter to <b>template</b> in order to render + immediately instead of returning a template function. The <b>settings</b> argument + should be a hash containing any <tt>_.templateSettings</tt> that should be overridden. + </p> + + <pre> +var compiled = _.template("hello: <%= name %>"); +compiled({name: 'moe'}); +=> "hello: moe" + +var list = "<% _.each(people, function(name) { %> <li><%= name %></li> <% }); %>"; +_.template(list, {people: ['moe', 'curly', 'larry']}); +=> "<li>moe</li><li>curly</li><li>larry</li>" + +var template = _.template("<b><%- value %></b>"); +template({value: '<script>'}); +=> "<b>&lt;script&gt;</b>"</pre> + + <p> + You can also use <tt>print</tt> from within JavaScript code. This is + sometimes more convenient than using <tt><%= ... %></tt>. + </p> + + <pre> +var compiled = _.template("<% print('Hello ' + epithet); %>"); +compiled({epithet: "stooge"}); +=> "Hello stooge"</pre> + + <p> + If ERB-style delimiters aren't your cup of tea, you can change Underscore's + template settings to use different symbols to set off interpolated code. + Define an <b>interpolate</b> regex to match expressions that should be + interpolated verbatim, an <b>escape</b> regex to match expressions that should + be inserted after being HTML escaped, and an <b>evaluate</b> regex to match + expressions that should be evaluated without insertion into the resulting + string. You may define or omit any combination of the three. + For example, to perform + <a href="https://github.com/janl/mustache.js#readme">Mustache.js</a> + style templating: + </p> + + <pre> +_.templateSettings = { + interpolate: /\{\{(.+?)\}\}/g +}; + +var template = _.template("Hello {{ name }}!"); +template({name: "Mustache"}); +=> "Hello Mustache!"</pre> + + <p> + By default, <b>template</b> places the values from your data in the local scope + via the <tt>with</tt> statement. However, you can specify a single variable name + with the <b>variable</b> setting. This can significantly improve the speed + at which a template is able to render. + </p> + + <pre> +_.template("Using 'with': <%= data.answer %>", {answer: 'no'}, {variable: 'data'}); +=> "Using 'with': no"</pre> + + <p> + Precompiling your templates can be a big help when debugging errors you can't + reproduce. This is because precompiled templates can provide line numbers and + a stack trace, something that is not possible when compiling templates on the client. + The <b>source</b> property is available on the compiled template + function for easy precompilation. + </p> + + <pre><script> + JST.project = <%= _.template(jstText).source %>; +</script></pre> + + + <h2 id="chaining">Chaining</h2> + + <p> + You can use Underscore in either an object-oriented or a functional style, + depending on your preference. The following two lines of code are + identical ways to double a list of numbers. + </p> + + <pre> +_.map([1, 2, 3], function(n){ return n * 2; }); +_([1, 2, 3]).map(function(n){ return n * 2; });</pre> + + <p> + Calling <tt>chain</tt> will cause all future method calls to return + wrapped objects. When you've finished the computation, call + <tt>value</tt> to retrieve the final value. Here's an example of chaining + together a <b>map/flatten/reduce</b>, in order to get the word count of + every word in a song. + </p> + +<pre> +var lyrics = [ + {line: 1, words: "I'm a lumberjack and I'm okay"}, + {line: 2, words: "I sleep all night and I work all day"}, + {line: 3, words: "He's a lumberjack and he's okay"}, + {line: 4, words: "He sleeps all night and he works all day"} +]; + +_.chain(lyrics) + .map(function(line) { return line.words.split(' '); }) + .flatten() + .reduce(function(counts, word) { + counts[word] = (counts[word] || 0) + 1; + return counts; + }, {}) + .value(); + +=> {lumberjack: 2, all: 4, night: 2 ... }</pre> + + <p> + In addition, the + <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/prototype">Array prototype's methods</a> + are proxied through the chained Underscore object, so you can slip a + <tt>reverse</tt> or a <tt>push</tt> into your chain, and continue to + modify the array. + </p> + + <p id="chain"> + <b class="header">chain</b><code>_.chain(obj)</code> + <br /> + Returns a wrapped object. Calling methods on this object will continue + to return wrapped objects until <tt>value</tt> is called. + </p> + <pre> +var stooges = [{name: 'curly', age: 25}, {name: 'moe', age: 21}, {name: 'larry', age: 23}]; +var youngest = _.chain(stooges) + .sortBy(function(stooge){ return stooge.age; }) + .map(function(stooge){ return stooge.name + ' is ' + stooge.age; }) + .first() + .value(); +=> "moe is 21" +</pre> + + <p id="value"> + <b class="header">value</b><code>_(obj).value()</code> + <br /> + Extracts the value of a wrapped object. + </p> + <pre> +_([1, 2, 3]).value(); +=> [1, 2, 3] +</pre> + + <h2 id="links">Links & Suggested Reading</h2> + + <p> + The Underscore documentation is also available in + <a href="http://learning.github.io/underscore/">Simplified Chinese</a>. + </p> + + <p> + <a href="http://mirven.github.io/underscore.lua/">Underscore.lua</a>, + a Lua port of the functions that are applicable in both languages. + Includes OOP-wrapping and chaining. + (<a href="https://github.com/mirven/underscore.lua">source</a>) + </p> + + <p> + <a href="http://underscorem.org/">Underscore.m</a>, an Objective-C port + of many of the Underscore.js functions, using a syntax that encourages + chaining. + (<a href="https://github.com/robb/Underscore.m">source</a>) + </p> + + <p> + <a href="http://kmalakoff.github.io/_.m/">_.m</a>, an alternative + Objective-C port that tries to stick a little closer to the original + Underscore.js API. + (<a href="https://github.com/kmalakoff/_.m">source</a>) + </p> + + <p> + <a href="http://brianhaveri.github.io/Underscore.php/">Underscore.php</a>, + a PHP port of the functions that are applicable in both languages. + Includes OOP-wrapping and chaining. + (<a href="https://github.com/brianhaveri/Underscore.php">source</a>) + </p> + + <p> + <a href="http://vti.github.io/underscore-perl/">Underscore-perl</a>, + a Perl port of many of the Underscore.js functions, + aimed at on Perl hashes and arrays. + (<a href="https://github.com/vti/underscore-perl">source</a>) + </p> + + <p> + <a href="http://russplaysguitar.github.io/UnderscoreCF/">Underscore.cfc</a>, + a Coldfusion port of many of the Underscore.js functions. + (<a href="https://github.com/russplaysguitar/underscorecf">source</a>) + </p> + + <p> + <a href="http://epeli.github.io/underscore.string/">Underscore.string</a>, + an Underscore extension that adds functions for string-manipulation: + <tt>trim</tt>, <tt>startsWith</tt>, <tt>contains</tt>, <tt>capitalize</tt>, + <tt>reverse</tt>, <tt>sprintf</tt>, and more. + </p> + + <p> + Ruby's <a href="http://ruby-doc.org/core/classes/Enumerable.html">Enumerable</a> module. + </p> + + <p> + <a href="http://prototypejs.org/">Prototype.js</a>, which provides + JavaScript with collection functions in the manner closest to Ruby's Enumerable. + </p> + + <p> + Oliver Steele's + <a href="http://osteele.com/sources/javascript/functional/">Functional JavaScript</a>, + which includes comprehensive higher-order function support as well as string lambdas. + </p> + + <p> + Michael Aufreiter's <a href="https://github.com/substance/data">Data.js</a>, + a data manipulation + persistence library for JavaScript. + </p> + + <p> + Python's <a href="http://docs.python.org/library/itertools.html">itertools</a>. + </p> + + <p> + <a href="http://toolz.readthedocs.org/">PyToolz</a>, a Python port + that extends itertools and functools to include much of the + Underscore API. + </p> + + <p> + <a href="https://github.com/Suor/funcy">Funcy</a>, a practical + collection of functional helpers for Python, partially inspired by Underscore. + </p> + + <h2 id="changelog">Change Log</h2> + + + <p id="1.6.0"> + <b class="header">1.6.0</b> — <small><i>February 10, 2014</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.5.2...1.6.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.6.0/index.html">Docs</a><br /> + <ul> + <li> + Underscore now registers itself for AMD (Require.js), Bower and Component, + as well as being a CommonJS module and a regular (Java)Script. + An ugliness, but perhaps a necessary one. + </li> + <li> + Added <tt>_.partition</tt>, a way to split a collection into two lists + of results — those that pass and those that fail a particular predicate. + </li> + <li> + Added <tt>_.property</tt>, for easy creation of iterators that pull + specific properties from objects. Useful in conjunction with other + Underscore collection functions. + </li> + <li> + Added <tt>_.matches</tt>, a function that will give you a predicate + that can be used to tell if a given object matches a list of specified + key/value properties. + </li> + <li> + Added <tt>_.constant</tt>, as a higher-order <tt>_.identity</tt>. + </li> + <li> + Added <tt>_.now</tt>, an optimized way to get a timestamp — used + internally to speed up <tt>debounce</tt> and <tt>throttle</tt>. + </li> + <li> + The <tt>_.partial</tt> function may now be used to partially apply + any of its arguments, by passing <tt>_</tt> wherever you'd like a + placeholder variable, to be filled-in later. + </li> + <li> + The <tt>_.each</tt> function now returns a reference to the list for chaining. + </li> + <li> + The <tt>_.keys</tt> function now returns an empty array for + non-objects instead of throwing. + </li> + <li> + … and more miscellaneous refactoring. + </li> + </ul> + </p> + + <p id="1.5.2"> + <b class="header">1.5.2</b> — <small><i>September 7, 2013</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.5.1...1.5.2">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.5.2/index.html">Docs</a><br /> + <ul> + <li> + Added an <tt>indexBy</tt> function, which fits in alongside its + cousins, <tt>countBy</tt> and <tt>groupBy</tt>. + </li> + <li> + Added a <tt>sample</tt> function, for sampling random elements from + arrays. + </li> + <li> + Some optimizations relating to functions that can be implemented + in terms of <tt>_.keys</tt> (which includes, significantly, + <tt>each</tt> on objects). Also for <tt>debounce</tt> in a tight loop. + </li> + </ul> + </p> + + <p id="1.5.1"> + <b class="header">1.5.1</b> — <small><i>July 8, 2013</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.5.0...1.5.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.5.1/index.html">Docs</a><br /> + <ul> + <li> + Removed <tt>unzip</tt>, as it's simply the application of <tt>zip</tt> + to an array of arguments. Use <tt>_.zip.apply(_, list)</tt> to + transpose instead. + </li> + </ul> + </p> + + <p id="1.5.0"> + <b class="header">1.5.0</b> — <small><i>July 6, 2013</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.4.4...1.5.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.5.0/index.html">Docs</a><br /> + <ul> + <li> + Added a new <tt>unzip</tt> function, as the inverse of <tt>_.zip</tt>. + </li> + <li> + The <tt>throttle</tt> function now takes an <tt>options</tt> argument, + allowing you to disable execution of the throttled function on either + the <b>leading</b> or <b>trailing</b> edge. + </li> + <li> + A source map is now supplied for easier debugging of the minified + production build of Underscore. + </li> + <li> + The <tt>defaults</tt> function now only overrides <tt>undefined</tt> + values, not <tt>null</tt> ones. + </li> + <li> + Removed the ability to call <tt>_.bindAll</tt> with no method name + arguments. It's pretty much always wiser to white-list the names of + the methods you'd like to bind. + </li> + <li> + Removed the ability to call <tt>_.after</tt> with an invocation count + of zero. The minimum number of calls is (naturally) now <tt>1</tt>. + </li> + </ul> + </p> + + <p id="1.4.4"> + <b class="header">1.4.4</b> — <small><i>January 30, 2013</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.4.3...1.4.4">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.4.4/index.html">Docs</a><br /> + <ul> + <li> + Added <tt>_.findWhere</tt>, for finding the first element in a list + that matches a particular set of keys and values. + </li> + <li> + Added <tt>_.partial</tt>, for partially applying a function <i>without</i> + changing its dynamic reference to <tt>this</tt>. + </li> + <li> + Simplified <tt>bind</tt> by removing some edge cases involving + constructor functions. In short: don't <tt>_.bind</tt> your + constructors. + </li> + <li> + A minor optimization to <tt>invoke</tt>. + </li> + <li> + Fix bug in the minified version due to the minifier incorrectly + optimizing-away <tt>isFunction</tt>. + </li> + </ul> + </p> + + <p id="1.4.3"> + <b class="header">1.4.3</b> — <small><i>December 4, 2012</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.4.2...1.4.3">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.4.3/index.html">Docs</a><br /> + <ul> + <li> + Improved Underscore compatibility with Adobe's JS engine that can be + used to script Illustrator, Photoshop, and friends. + </li> + <li> + Added a default <tt>_.identity</tt> iterator to <tt>countBy</tt> and + <tt>groupBy</tt>. + </li> + <li> + The <tt>uniq</tt> function can now take <tt>array, iterator, context</tt> + as the argument list. + </li> + <li> + The <tt>times</tt> function now returns the mapped array of iterator + results. + </li> + <li> + Simplified and fixed bugs in <tt>throttle</tt>. + </li> + </ul> + </p> + + <p id="1.4.2"> + <b class="header">1.4.2</b> — <small><i>October 6, 2012</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.4.1...1.4.2">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.4.2/index.html">Docs</a><br /> + <ul> + <li> + For backwards compatibility, returned to pre-1.4.0 behavior when + passing <tt>null</tt> to iteration functions. They now become no-ops + again. + </li> + </ul> + </p> + + <p id="1.4.1"> + <b class="header">1.4.1</b> — <small><i>October 1, 2012</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.4.0...1.4.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.4.1/index.html">Docs</a><br /> + <ul> + <li> + Fixed a 1.4.0 regression in the <tt>lastIndexOf</tt> function. + </li> + </ul> + </p> + + <p id="1.4.0"> + <b class="header">1.4.0</b> — <small><i>September 27, 2012</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.3.3...1.4.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.4.0/index.html">Docs</a><br /> + <ul> + <li> + Added a <tt>pairs</tt> function, for turning a JavaScript object + into <tt>[key, value]</tt> pairs ... as well as an <tt>object</tt> + function, for converting an array of <tt>[key, value]</tt> pairs + into an object. + </li> + <li> + Added a <tt>countBy</tt> function, for counting the number of objects + in a list that match a certain criteria. + </li> + <li> + Added an <tt>invert</tt> function, for performing a simple inversion + of the keys and values in an object. + </li> + <li> + Added a <tt>where</tt> function, for easy cases of filtering a list + for objects with specific values. + </li> + <li> + Added an <tt>omit</tt> function, for filtering an object to remove + certain keys. + </li> + <li> + Added a <tt>random</tt> function, to return a random number in a + given range. + </li> + <li> + <tt>_.debounce</tt>'d functions now return their last updated value, + just like <tt>_.throttle</tt>'d functions do. + </li> + <li> + The <tt>sortBy</tt> function now runs a stable sort algorithm. + </li> + <li> + Added the optional <tt>fromIndex</tt> option to <tt>indexOf</tt> and + <tt>lastIndexOf</tt>. + </li> + <li> + "Sparse" arrays are no longer supported in Underscore iteration + functions. Use a <tt>for</tt> loop instead (or better yet, an object). + </li> + <li> + The <tt>min</tt> and <tt>max</tt> functions may now be called on + <i>very</i> large arrays. + </li> + <li> + Interpolation in templates now represents <tt>null</tt> and + <tt>undefined</tt> as the empty string. + </li> + <li> + <del>Underscore iteration functions no longer accept <tt>null</tt> values + as a no-op argument. You'll get an early error instead.</del> + </li> + <li> + A number of edge-cases fixes and tweaks, which you can spot in the + <a href="https://github.com/jashkenas/underscore/compare/1.3.3...1.4.0">diff</a>. + Depending on how you're using Underscore, <b>1.4.0</b> may be more + backwards-incompatible than usual — please test when you upgrade. + </li> + </ul> + </p> + + <p id="1.3.3"> + <b class="header">1.3.3</b> — <small><i>April 10, 2012</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.3.1...1.3.3">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.3.3/index.html">Docs</a><br /> + <ul> + <li> + Many improvements to <tt>_.template</tt>, which now provides the + <tt>source</tt> of the template function as a property, for potentially + even more efficient pre-compilation on the server-side. You may now + also set the <tt>variable</tt> option when creating a template, + which will cause your passed-in data to be made available under the + variable you named, instead of using a <tt>with</tt> statement — + significantly improving the speed of rendering the template. + </li> + <li> + Added the <tt>pick</tt> function, which allows you to filter an + object literal with a whitelist of allowed property names. + </li> + <li> + Added the <tt>result</tt> function, for convenience when working + with APIs that allow either functions or raw properties. + </li> + <li> + Added the <tt>isFinite</tt> function, because sometimes knowing that + a value is a number just ain't quite enough. + </li> + <li> + The <tt>sortBy</tt> function may now also be passed the string name + of a property to use as the sort order on each object. + </li> + <li> + Fixed <tt>uniq</tt> to work with sparse arrays. + </li> + <li> + The <tt>difference</tt> function now performs a shallow flatten + instead of a deep one when computing array differences. + </li> + <li> + The <tt>debounce</tt> function now takes an <tt>immediate</tt> + parameter, which will cause the callback to fire on the leading + instead of the trailing edge. + </li> + </ul> + </p> + + <p id="1.3.1"> + <b class="header">1.3.1</b> — <small><i>January 23, 2012</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.3.0...1.3.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.3.1/index.html">Docs</a><br /> + <ul> + <li> + Added an <tt>_.has</tt> function, as a safer way to use <tt>hasOwnProperty</tt>. + </li> + <li> + Added <tt>_.collect</tt> as an alias for <tt>_.map</tt>. Smalltalkers, rejoice. + </li> + <li> + Reverted an old change so that <tt>_.extend</tt> will correctly copy + over keys with undefined values again. + </li> + <li> + Bugfix to stop escaping slashes within interpolations in <tt>_.template</tt>. + </li> + </ul> + </p> + + <p id="1.3.0"> + <b class="header">1.3.0</b> — <small><i>January 11, 2012</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.2.4...1.3.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.3.0/index.html">Docs</a><br /> + <ul> + <li> + Removed AMD (RequireJS) support from Underscore. If you'd like to use + Underscore with RequireJS, you can load it as a normal script, wrap + or patch your copy, or download a forked version. + </li> + </ul> + </p> + + <p id="1.2.4"> + <b class="header">1.2.4</b> — <small><i>January 4, 2012</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.2.3...1.2.4">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.2.4/index.html">Docs</a><br /> + <ul> + <li> + You now can (and probably should, as it's simpler) + write <tt>_.chain(list)</tt> + instead of <tt>_(list).chain()</tt>. + </li> + <li> + Fix for escaped characters in Underscore templates, and for supporting + customizations of <tt>_.templateSettings</tt> that only define one or + two of the required regexes. + </li> + <li> + Fix for passing an array as the first argument to an <tt>_.wrap</tt>'d function. + </li> + <li> + Improved compatibility with ClojureScript, which adds a <tt>call</tt> + function to <tt>String.prototype</tt>. + </li> + </ul> + </p> + + <p id="1.2.3"> + <b class="header">1.2.3</b> — <small><i>December 7, 2011</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.2.2...1.2.3">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.2.3/index.html">Docs</a><br /> + <ul> + <li> + Dynamic scope is now preserved for compiled <tt>_.template</tt> functions, + so you can use the value of <tt>this</tt> if you like. + </li> + <li> + Sparse array support of <tt>_.indexOf</tt>, <tt>_.lastIndexOf</tt>. + </li> + <li> + Both <tt>_.reduce</tt> and <tt>_.reduceRight</tt> can now be passed an + explicitly <tt>undefined</tt> value. (There's no reason why you'd + want to do this.) + </li> + </ul> + </p> + + <p id="1.2.2"> + <b class="header">1.2.2</b> — <small><i>November 14, 2011</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.2.1...1.2.2">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.2.1/index.html">Docs</a><br /> + <ul> + <li> + Continued tweaks to <tt>_.isEqual</tt> semantics. Now JS primitives are + considered equivalent to their wrapped versions, and arrays are compared + by their numeric properties only <small>(#351)</small>. + </li> + <li> + <tt>_.escape</tt> no longer tries to be smart about not double-escaping + already-escaped HTML entities. Now it just escapes regardless <small>(#350)</small>. + </li> + <li> + In <tt>_.template</tt>, you may now leave semicolons out of evaluated + statements if you wish: <tt><% }) %></tt> <small>(#369)</small>. + </li> + <li> + <tt>_.after(callback, 0)</tt> will now trigger the callback immediately, + making "after" easier to use with asynchronous APIs <small>(#366)</small>. + </li> + </ul> + </p> + + <p id="1.2.1"> + <b class="header">1.2.1</b> — <small><i>October 24, 2011</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.2.0...1.2.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.2.1/index.html">Docs</a><br /> + <ul> + <li> + Several important bug fixes for <tt>_.isEqual</tt>, which should now + do better on mutated Arrays, and on non-Array objects with + <tt>length</tt> properties. <small>(#329)</small> + </li> + <li> + <a href="https://github.com/jrburke">James Burke</a> + contributed Underscore exporting for AMD module loaders, and + <a href="https://github.com/tonylukasavage">Tony Lukasavage</a> + for Appcelerator Titanium. + <small>(#335, #338)</small> + </li> + <li> + You can now <tt>_.groupBy(list, 'property')</tt> as a shortcut for + grouping values by a particular common property. + </li> + <li> + <tt>_.throttle</tt>'d functions now fire immediately upon invocation, + and are rate-limited thereafter <small>(#170, #266)</small>. + </li> + <li> + Most of the <tt>_.is[Type]</tt> checks no longer ducktype. + </li> + <li> + The <tt>_.bind</tt> function now also works on constructors, a-la + ES5 ... but you would never want to use <tt>_.bind</tt> on a + constructor function. + </li> + <li> + <tt>_.clone</tt> no longer wraps non-object types in Objects. + </li> + <li> + <tt>_.find</tt> and <tt>_.filter</tt> are now the preferred names for + <tt>_.detect</tt> and <tt>_.select</tt>. + </li> + </ul> + </p> + + <p id="1.2.0"> + <b class="header">1.2.0</b> — <small><i>October 5, 2011</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.1.7...1.2.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.2.0/index.html">Docs</a><br /> + <ul> + <li> + The <tt>_.isEqual</tt> function now + supports true deep equality comparisons, with checks for cyclic structures, + thanks to Kit Cambridge. + </li> + <li> + Underscore templates now support HTML escaping interpolations, using + <tt><%- ... %></tt> syntax. + </li> + <li> + Ryan Tenney contributed <tt>_.shuffle</tt>, which uses a modified + Fisher-Yates to give you a shuffled copy of an array. + </li> + <li> + <tt>_.uniq</tt> can now be passed an optional iterator, to determine by + what criteria an object should be considered unique. + </li> + <li> + <tt>_.last</tt> now takes an optional argument which will return the last + N elements of the list. + </li> + <li> + A new <tt>_.initial</tt> function was added, as a mirror of <tt>_.rest</tt>, + which returns all the initial values of a list (except the last N). + </li> + </ul> + </p> + + <p id="1.1.7"> + <b class="header">1.1.7</b> — <small><i>July 13, 2011</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.1.6...1.1.7">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.1.7/index.html">Docs</a><br /> + Added <tt>_.groupBy</tt>, which aggregates a collection into groups of like items. + Added <tt>_.union</tt> and <tt>_.difference</tt>, to complement the + (re-named) <tt>_.intersection</tt>. + Various improvements for support of sparse arrays. + <tt>_.toArray</tt> now returns a clone, if directly passed an array. + <tt>_.functions</tt> now also returns the names of functions that are present + in the prototype chain. + </p> + + <p id="1.1.6"> + <b class="header">1.1.6</b> — <small><i>April 18, 2011</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.1.5...1.1.6">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.1.6/index.html">Docs</a><br /> + Added <tt>_.after</tt>, which will return a function that only runs after + first being called a specified number of times. + <tt>_.invoke</tt> can now take a direct function reference. + <tt>_.every</tt> now requires an iterator function to be passed, which + mirrors the ECMA5 API. + <tt>_.extend</tt> no longer copies keys when the value is undefined. + <tt>_.bind</tt> now errors when trying to bind an undefined value. + </p> + + <p id="1.1.5"> + <b class="header">1.1.5</b> — <small><i>March 20, 2011</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.1.4...1.1.5">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.1.5/index.html">Docs</a><br /> + Added an <tt>_.defaults</tt> function, for use merging together JS objects + representing default options. + Added an <tt>_.once</tt> function, for manufacturing functions that should + only ever execute a single time. + <tt>_.bind</tt> now delegates to the native ECMAScript 5 version, + where available. + <tt>_.keys</tt> now throws an error when used on non-Object values, as in + ECMAScript 5. + Fixed a bug with <tt>_.keys</tt> when used over sparse arrays. + </p> + + <p id="1.1.4"> + <b class="header">1.1.4</b> — <small><i>January 9, 2011</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.1.3...1.1.4">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.1.4/index.html">Docs</a><br /> + Improved compliance with ES5's Array methods when passing <tt>null</tt> + as a value. <tt>_.wrap</tt> now correctly sets <tt>this</tt> for the + wrapped function. <tt>_.indexOf</tt> now takes an optional flag for + finding the insertion index in an array that is guaranteed to already + be sorted. Avoiding the use of <tt>.callee</tt>, to allow <tt>_.isArray</tt> + to work properly in ES5's strict mode. + </p> + + <p id="1.1.3"> + <b class="header">1.1.3</b> — <small><i>December 1, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.1.2...1.1.3">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.1.3/index.html">Docs</a><br /> + In CommonJS, Underscore may now be required with just: <br /> + <tt>var _ = require("underscore")</tt>. + Added <tt>_.throttle</tt> and <tt>_.debounce</tt> functions. + Removed <tt>_.breakLoop</tt>, in favor of an ECMA5-style un-<i>break</i>-able + each implementation — this removes the try/catch, and you'll now have + better stack traces for exceptions that are thrown within an Underscore iterator. + Improved the <b>isType</b> family of functions for better interoperability + with Internet Explorer host objects. + <tt>_.template</tt> now correctly escapes backslashes in templates. + Improved <tt>_.reduce</tt> compatibility with the ECMA5 version: + if you don't pass an initial value, the first item in the collection is used. + <tt>_.each</tt> no longer returns the iterated collection, for improved + consistency with ES5's <tt>forEach</tt>. + </p> + + <p id="1.1.2"> + <b class="header">1.1.2</b> — <small><i>October 15, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.1.1...1.1.2">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.1.2/index.html">Docs</a><br /> + Fixed <tt>_.contains</tt>, which was mistakenly pointing at + <tt>_.intersect</tt> instead of <tt>_.include</tt>, like it should + have been. Added <tt>_.unique</tt> as an alias for <tt>_.uniq</tt>. + </p> + + <p id="1.1.1"> + <b class="header">1.1.1</b> — <small><i>October 5, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.1.0...1.1.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.1.1/index.html">Docs</a><br /> + Improved the speed of <tt>_.template</tt>, and its handling of multiline + interpolations. Ryan Tenney contributed optimizations to many Underscore + functions. An annotated version of the source code is now available. + </p> + + <p id="1.1.0"> + <b class="header">1.1.0</b> — <small><i>August 18, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.0.4...1.1.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.1.0/index.html">Docs</a><br /> + The method signature of <tt>_.reduce</tt> has been changed to match + the ECMAScript 5 signature, instead of the Ruby/Prototype.js version. + This is a backwards-incompatible change. <tt>_.template</tt> may now be + called with no arguments, and preserves whitespace. <tt>_.contains</tt> + is a new alias for <tt>_.include</tt>. + </p> + + <p id="1.0.4"> + <b class="header">1.0.4</b> — <small><i>June 22, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.0.3...1.0.4">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.0.4/index.html">Docs</a><br /> + <a href="http://themoell.com/">Andri Möll</a> contributed the <tt>_.memoize</tt> + function, which can be used to speed up expensive repeated computations + by caching the results. + </p> + + <p id="1.0.3"> + <b class="header">1.0.3</b> — <small><i>June 14, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.0.2...1.0.3">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.0.3/index.html">Docs</a><br /> + Patch that makes <tt>_.isEqual</tt> return <tt>false</tt> if any property + of the compared object has a <tt>NaN</tt> value. Technically the correct + thing to do, but of questionable semantics. Watch out for NaN comparisons. + </p> + + <p id="1.0.2"> + <b class="header">1.0.2</b> — <small><i>March 23, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.0.1...1.0.2">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.0.2/index.html">Docs</a><br /> + Fixes <tt>_.isArguments</tt> in recent versions of Opera, which have + arguments objects as real Arrays. + </p> + + <p id="1.0.1"> + <b class="header">1.0.1</b> — <small><i>March 19, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/1.0.0...1.0.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.0.1/index.html">Docs</a><br /> + Bugfix for <tt>_.isEqual</tt>, when comparing two objects with the same + number of undefined keys, but with different names. + </p> + + <p id="1.0.0"> + <b class="header">1.0.0</b> — <small><i>March 18, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.6.0...1.0.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/1.0.0/index.html">Docs</a><br /> + Things have been stable for many months now, so Underscore is now + considered to be out of beta, at <b>1.0</b>. Improvements since <b>0.6</b> + include <tt>_.isBoolean</tt>, and the ability to have <tt>_.extend</tt> + take multiple source objects. + </p> + + <p id="0.6.0"> + <b class="header">0.6.0</b> — <small><i>February 24, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.5.8...0.6.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.6.0/index.html">Docs</a><br /> + Major release. Incorporates a number of + <a href="https://github.com/ratbeard">Mile Frawley's</a> refactors for + safer duck-typing on collection functions, and cleaner internals. A new + <tt>_.mixin</tt> method that allows you to extend Underscore with utility + functions of your own. Added <tt>_.times</tt>, which works the same as in + Ruby or Prototype.js. Native support for ECMAScript 5's <tt>Array.isArray</tt>, + and <tt>Object.keys</tt>. + </p> + + <p id="0.5.8"> + <b class="header">0.5.8</b> — <small><i>January 28, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.5.7...0.5.8">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.5.8/index.html">Docs</a><br /> + Fixed Underscore's collection functions to work on + <a href="https://developer.mozilla.org/En/DOM/NodeList">NodeLists</a> and + <a href="https://developer.mozilla.org/En/DOM/HTMLCollection">HTMLCollections</a> + once more, thanks to + <a href="https://github.com/JustinTulloss">Justin Tulloss</a>. + </p> + + <p id="0.5.7"> + <b class="header">0.5.7</b> — <small><i>January 20, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.5.6...0.5.7">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.5.7/index.html">Docs</a><br /> + A safer implementation of <tt>_.isArguments</tt>, and a + faster <tt>_.isNumber</tt>,<br />thanks to + <a href="http://jedschmidt.com/">Jed Schmidt</a>. + </p> + + <p id="0.5.6"> + <b class="header">0.5.6</b> — <small><i>January 18, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.5.5...0.5.6">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.5.6/index.html">Docs</a><br /> + Customizable delimiters for <tt>_.template</tt>, contributed by + <a href="https://github.com/iamnoah">Noah Sloan</a>. + </p> + + <p id="0.5.5"> + <b class="header">0.5.5</b> — <small><i>January 9, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.5.4...0.5.5">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.5.5/index.html">Docs</a><br /> + Fix for a bug in MobileSafari's OOP-wrapper, with the arguments object. + </p> + + <p id="0.5.4"> + <b class="header">0.5.4</b> — <small><i>January 5, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.5.2...0.5.4">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.5.4/index.html">Docs</a><br /> + Fix for multiple single quotes within a template string for + <tt>_.template</tt>. See: + <a href="http://www.west-wind.com/Weblog/posts/509108.aspx">Rick Strahl's blog post</a>. + </p> + + <p id="0.5.2"> + <b class="header">0.5.2</b> — <small><i>January 1, 2010</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.5.1...0.5.2">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.5.2/index.html">Docs</a><br /> + New implementations of <tt>isArray</tt>, <tt>isDate</tt>, <tt>isFunction</tt>, + <tt>isNumber</tt>, <tt>isRegExp</tt>, and <tt>isString</tt>, thanks to + a suggestion from + <a href="http://www.broofa.com/">Robert Kieffer</a>. + Instead of doing <tt>Object#toString</tt> + comparisons, they now check for expected properties, which is less safe, + but more than an order of magnitude faster. Most other Underscore + functions saw minor speed improvements as a result. + <a href="http://dolzhenko.org/">Evgeniy Dolzhenko</a> + contributed <tt>_.tap</tt>, + <a href="http://ruby-doc.org/core-1.9/classes/Object.html#M000191">similar to Ruby 1.9's</a>, + which is handy for injecting side effects (like logging) into chained calls. + </p> + + <p id="0.5.1"> + <b class="header">0.5.1</b> — <small><i>December 9, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.5.0...0.5.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.5.1/index.html">Docs</a><br /> + Added an <tt>_.isArguments</tt> function. Lots of little safety checks + and optimizations contributed by + <a href="https://github.com/iamnoah">Noah Sloan</a> and + <a href="http://themoell.com/">Andri Möll</a>. + </p> + + <p id="0.5.0"> + <b class="header">0.5.0</b> — <small><i>December 7, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.4.7...0.5.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.5.0/index.html">Docs</a><br /> + <b>[API Changes]</b> <tt>_.bindAll</tt> now takes the context object as + its first parameter. If no method names are passed, all of the context + object's methods are bound to it, enabling chaining and easier binding. + <tt>_.functions</tt> now takes a single argument and returns the names + of its Function properties. Calling <tt>_.functions(_)</tt> will get you + the previous behavior. + Added <tt>_.isRegExp</tt> so that <tt>isEqual</tt> can now test for RegExp equality. + All of the "is" functions have been shrunk down into a single definition. + <a href="https://github.com/grayrest">Karl Guertin</a> contributed patches. + </p> + + <p id="0.4.7"> + <b class="header">0.4.7</b> — <small><i>December 6, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.4.6...0.4.7">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.4.7/index.html">Docs</a><br /> + Added <tt>isDate</tt>, <tt>isNaN</tt>, and <tt>isNull</tt>, for completeness. + Optimizations for <tt>isEqual</tt> when checking equality between Arrays + or Dates. <tt>_.keys</tt> is now <small><i><b>25%–2X</b></i></small> faster (depending on your + browser) which speeds up the functions that rely on it, such as <tt>_.each</tt>. + </p> + + <p id="0.4.6"> + <b class="header">0.4.6</b> — <small><i>November 30, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.4.5...0.4.6">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.4.6/index.html">Docs</a><br /> + Added the <tt>range</tt> function, a port of the + <a href="http://docs.python.org/library/functions.html#range">Python + function of the same name</a>, for generating flexibly-numbered lists + of integers. Original patch contributed by + <a href="https://github.com/kylichuku">Kirill Ishanov</a>. + </p> + + <p id="0.4.5"> + <b class="header">0.4.5</b> — <small><i>November 19, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.4.4...0.4.5">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.4.5/index.html">Docs</a><br /> + Added <tt>rest</tt> for Arrays and arguments objects, and aliased + <tt>first</tt> as <tt>head</tt>, and <tt>rest</tt> as <tt>tail</tt>, + thanks to <a href="https://github.com/lukesutton">Luke Sutton</a>'s patches. + Added tests ensuring that all Underscore Array functions also work on + <i>arguments</i> objects. + </p> + + <p id="0.4.4"> + <b class="header">0.4.4</b> — <small><i>November 18, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.4.3...0.4.4">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.4.4/index.html">Docs</a><br /> + Added <tt>isString</tt>, and <tt>isNumber</tt>, for consistency. Fixed + <tt>_.isEqual(NaN, NaN)</tt> to return <i>true</i> (which is debatable). + </p> + + <p id="0.4.3"> + <b class="header">0.4.3</b> — <small><i>November 9, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.4.2...0.4.3">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.4.3/index.html">Docs</a><br /> + Started using the native <tt>StopIteration</tt> object in browsers that support it. + Fixed Underscore setup for CommonJS environments. + </p> + + <p id="0.4.2"> + <b class="header">0.4.2</b> — <small><i>November 9, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.4.1...0.4.2">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.4.2/index.html">Docs</a><br /> + Renamed the unwrapping function to <tt>value</tt>, for clarity. + </p> + + <p id="0.4.1"> + <b class="header">0.4.1</b> — <small><i>November 8, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.4.0...0.4.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.4.1/index.html">Docs</a><br /> + Chained Underscore objects now support the Array prototype methods, so + that you can perform the full range of operations on a wrapped array + without having to break your chain. Added a <tt>breakLoop</tt> method + to <b>break</b> in the middle of any Underscore iteration. Added an + <tt>isEmpty</tt> function that works on arrays and objects. + </p> + + <p id="0.4.0"> + <b class="header">0.4.0</b> — <small><i>November 7, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.3.3...0.4.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.4.0/index.html">Docs</a><br /> + All Underscore functions can now be called in an object-oriented style, + like so: <tt>_([1, 2, 3]).map(...);</tt>. Original patch provided by + <a href="http://macournoyer.com/">Marc-André Cournoyer</a>. + Wrapped objects can be chained through multiple + method invocations. A <a href="#object-functions"><tt>functions</tt></a> method + was added, providing a sorted list of all the functions in Underscore. + </p> + + <p id="0.3.3"> + <b class="header">0.3.3</b> — <small><i>October 31, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.3.2...0.3.3">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.3.3/index.html">Docs</a><br /> + Added the JavaScript 1.8 function <tt>reduceRight</tt>. Aliased it + as <tt>foldr</tt>, and aliased <tt>reduce</tt> as <tt>foldl</tt>. + </p> + + <p id="0.3.2"> + <b class="header">0.3.2</b> — <small><i>October 29, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.3.1...0.3.2">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.3.2/index.html">Docs</a><br /> + Now runs on stock <a href="http://www.mozilla.org/rhino/">Rhino</a> + interpreters with: <tt>load("underscore.js")</tt>. + Added <a href="#identity"><tt>identity</tt></a> as a utility function. + </p> + + <p id="0.3.1"> + <b class="header">0.3.1</b> — <small><i>October 29, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.3.0...0.3.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.3.1/index.html">Docs</a><br /> + All iterators are now passed in the original collection as their third + argument, the same as JavaScript 1.6's <b>forEach</b>. Iterating over + objects is now called with <tt>(value, key, collection)</tt>, for details + see <a href="#each"><tt>_.each</tt></a>. + </p> + + <p id="0.3.0"> + <b class="header">0.3.0</b> — <small><i>October 29, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.2.0...0.3.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.3.0/index.html">Docs</a><br /> + Added <a href="https://github.com/DmitryBaranovskiy">Dmitry Baranovskiy</a>'s + comprehensive optimizations, merged in + <a href="https://github.com/kriskowal">Kris Kowal</a>'s patches to make Underscore + <a href="http://wiki.commonjs.org/wiki/CommonJS">CommonJS</a> and + <a href="http://narwhaljs.org/">Narwhal</a> compliant. + </p> + + <p id="0.2.0"> + <b class="header">0.2.0</b> — <small><i>October 28, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.1.1...0.2.0">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.2.0/index.html">Docs</a><br /> + Added <tt>compose</tt> and <tt>lastIndexOf</tt>, renamed <tt>inject</tt> to + <tt>reduce</tt>, added aliases for <tt>inject</tt>, <tt>filter</tt>, + <tt>every</tt>, <tt>some</tt>, and <tt>forEach</tt>. + </p> + + <p id="0.1.1"> + <b class="header">0.1.1</b> — <small><i>October 28, 2009</i></small> — <a href="https://github.com/jashkenas/underscore/compare/0.1.0...0.1.1">Diff</a> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.1.1/index.html">Docs</a><br /> + Added <tt>noConflict</tt>, so that the "Underscore" object can be assigned to + other variables. + </p> + + <p id="0.1.0"> + <b class="header">0.1.0</b> — <small><i>October 28, 2009</i></small> — <a href="http://htmlpreview.github.io/?https://raw.github.com/jashkenas/underscore/0.1.1/index.html">Docs</a><br /> + Initial release of Underscore.js. + </p> + + <p> + <a href="http://documentcloud.org/" title="A DocumentCloud Project" style="background:none;"> + <img src="http://jashkenas.s3.amazonaws.com/images/a_documentcloud_project.png" alt="A DocumentCloud Project" /> + </a> + </p> + + </div> + + </div> + + <!-- Include Underscore, so you can play with it in the console. --> + <script type="text/javascript" src="underscore.js"></script> + +</body> +</html> diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/package.json b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/package.json index 49e9145c9..70c9ac2c5 100644 --- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/package.json +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/package.json @@ -21,11 +21,12 @@ "version": "1.6.0", "devDependencies": { "docco": "0.6.x", - "phantomjs": "1.9.0-1", - "uglify-js": "2.4.x" + "phantomjs": "1.9.7-1", + "uglify-js": "2.4.x", + "eslint": "0.6.x" }, "scripts": { - "test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true", + "test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true && eslint underscore.js", "build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js", "doc": "docco underscore.js" }, @@ -40,28 +41,13 @@ "underscore-min.js", "LICENSE" ], + "readme": " __\n /\\ \\ __\n __ __ ___ \\_\\ \\ __ _ __ ____ ___ ___ _ __ __ /\\_\\ ____\n /\\ \\/\\ \\ /' _ `\\ /'_ \\ /'__`\\/\\ __\\/ ,__\\ / ___\\ / __`\\/\\ __\\/'__`\\ \\/\\ \\ /',__\\\n \\ \\ \\_\\ \\/\\ \\/\\ \\/\\ \\ \\ \\/\\ __/\\ \\ \\//\\__, `\\/\\ \\__//\\ \\ \\ \\ \\ \\//\\ __/ __ \\ \\ \\/\\__, `\\\n \\ \\____/\\ \\_\\ \\_\\ \\___,_\\ \\____\\\\ \\_\\\\/\\____/\\ \\____\\ \\____/\\ \\_\\\\ \\____\\/\\_\\ _\\ \\ \\/\\____/\n \\/___/ \\/_/\\/_/\\/__,_ /\\/____/ \\/_/ \\/___/ \\/____/\\/___/ \\/_/ \\/____/\\/_//\\ \\_\\ \\/___/\n \\ \\____/\n \\/___/\n\nUnderscore.js is a utility-belt library for JavaScript that provides\nsupport for the usual functional suspects (each, map, reduce, filter...)\nwithout extending any core JavaScript objects.\n\nFor Docs, License, Tests, and pre-packed downloads, see:\nhttp://underscorejs.org\n\nUnderscore is an open-sourced component of DocumentCloud:\nhttps://github.com/documentcloud\n\nMany thanks to our contributors:\nhttps://github.com/jashkenas/underscore/contributors\n", + "readmeFilename": "README.md", "bugs": { "url": "https://github.com/jashkenas/underscore/issues" }, "_id": "underscore@1.6.0", - "dist": { - "shasum": "8b38b10cacdef63337b8b24e4ff86d45aea529a8", - "tarball": "http://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz" - }, - "_from": "underscore@>= 1.3.0", - "_npmVersion": "1.3.21", - "_npmUser": { - "name": "jashkenas", - "email": "jashkenas@gmail.com" - }, - "maintainers": [ - { - "name": "jashkenas", - "email": "jashkenas@gmail.com" - } - ], - "directories": {}, - "_shasum": "8b38b10cacdef63337b8b24e4ff86d45aea529a8", - "_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", - "readme": "ERROR: No README data found!" + "_shasum": "444b9113da7a490c14f9c9b4230d06363e45a2c0", + "_resolved": "git+https://github.com/jashkenas/underscore#b5591f1e9313a09cf8140abe0cec5d7f75429452", + "_from": "underscore@>=1.3.0" } diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/arrays.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/arrays.js new file mode 100644 index 000000000..1621ad03d --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/arrays.js @@ -0,0 +1,323 @@ +(function() { + + module('Arrays'); + + test('first', function() { + equal(_.first([1, 2, 3]), 1, 'can pull out the first element of an array'); + equal(_([1, 2, 3]).first(), 1, 'can perform OO-style "first()"'); + deepEqual(_.first([1, 2, 3], 0), [], 'can pass an index to first'); + deepEqual(_.first([1, 2, 3], 2), [1, 2], 'can pass an index to first'); + deepEqual(_.first([1, 2, 3], 5), [1, 2, 3], 'can pass an index to first'); + var result = (function(){ return _.first(arguments); })(4, 3, 2, 1); + equal(result, 4, 'works on an arguments object.'); + result = _.map([[1, 2, 3], [1, 2, 3]], _.first); + deepEqual(result, [1, 1], 'works well with _.map'); + result = (function() { return _.first([1, 2, 3], 2); })(); + deepEqual(result, [1, 2]); + + equal(_.first(null), undefined, 'handles nulls'); + strictEqual(_.first([1, 2, 3], -1).length, 0); + }); + + test('head', function() { + strictEqual(_.first, _.head, 'alias for first'); + }); + + test('take', function() { + strictEqual(_.first, _.take, 'alias for first'); + }); + + test('rest', function() { + var numbers = [1, 2, 3, 4]; + deepEqual(_.rest(numbers), [2, 3, 4], 'working rest()'); + deepEqual(_.rest(numbers, 0), [1, 2, 3, 4], 'working rest(0)'); + deepEqual(_.rest(numbers, 2), [3, 4], 'rest can take an index'); + var result = (function(){ return _(arguments).rest(); })(1, 2, 3, 4); + deepEqual(result, [2, 3, 4], 'works on arguments object'); + result = _.map([[1, 2, 3], [1, 2, 3]], _.rest); + deepEqual(_.flatten(result), [2, 3, 2, 3], 'works well with _.map'); + result = (function(){ return _(arguments).rest(); })(1, 2, 3, 4); + deepEqual(result, [2, 3, 4], 'works on arguments object'); + }); + + test('tail', function() { + strictEqual(_.rest, _.tail, 'alias for rest'); + }); + + test('drop', function() { + strictEqual(_.rest, _.drop, 'alias for rest'); + }); + + test('initial', function() { + deepEqual(_.initial([1, 2, 3, 4, 5]), [1, 2, 3, 4], 'working initial()'); + deepEqual(_.initial([1, 2, 3, 4], 2), [1, 2], 'initial can take an index'); + deepEqual(_.initial([1, 2, 3, 4], 6), [], 'initial can take a large index'); + var result = (function(){ return _(arguments).initial(); })(1, 2, 3, 4); + deepEqual(result, [1, 2, 3], 'initial works on arguments object'); + result = _.map([[1, 2, 3], [1, 2, 3]], _.initial); + deepEqual(_.flatten(result), [1, 2, 1, 2], 'initial works with _.map'); + }); + + test('last', function() { + equal(_.last([1, 2, 3]), 3, 'can pull out the last element of an array'); + deepEqual(_.last([1, 2, 3], 0), [], 'can pass an index to last'); + deepEqual(_.last([1, 2, 3], 2), [2, 3], 'can pass an index to last'); + deepEqual(_.last([1, 2, 3], 5), [1, 2, 3], 'can pass an index to last'); + var result = (function(){ return _(arguments).last(); })(1, 2, 3, 4); + equal(result, 4, 'works on an arguments object'); + result = _.map([[1, 2, 3], [1, 2, 3]], _.last); + deepEqual(result, [3, 3], 'works well with _.map'); + + equal(_.last(null), undefined, 'handles nulls'); + strictEqual(_.last([1, 2, 3], -1).length, 0); + }); + + test('compact', function() { + equal(_.compact([0, 1, false, 2, false, 3]).length, 3, 'can trim out all falsy values'); + var result = (function(){ return _.compact(arguments).length; })(0, 1, false, 2, false, 3); + equal(result, 3, 'works on an arguments object'); + }); + + test('flatten', function() { + var list = [1, [2], [3, [[[4]]]]]; + deepEqual(_.flatten(list), [1, 2, 3, 4], 'can flatten nested arrays'); + deepEqual(_.flatten(list, true), [1, 2, 3, [[[4]]]], 'can shallowly flatten nested arrays'); + var result = (function(){ return _.flatten(arguments); })(1, [2], [3, [[[4]]]]); + deepEqual(result, [1, 2, 3, 4], 'works on an arguments object'); + list = [[1], [2], [3], [[4]]]; + deepEqual(_.flatten(list, true), [1, 2, 3, [4]], 'can shallowly flatten arrays containing only other arrays'); + }); + + test('without', function() { + var list = [1, 2, 1, 0, 3, 1, 4]; + deepEqual(_.without(list, 0, 1), [2, 3, 4], 'can remove all instances of an object'); + var result = (function(){ return _.without(arguments, 0, 1); })(1, 2, 1, 0, 3, 1, 4); + deepEqual(result, [2, 3, 4], 'works on an arguments object'); + + list = [{one : 1}, {two : 2}]; + ok(_.without(list, {one : 1}).length == 2, 'uses real object identity for comparisons.'); + ok(_.without(list, list[0]).length == 1, 'ditto.'); + }); + + test('uniq', function() { + var list = [1, 2, 1, 3, 1, 4]; + deepEqual(_.uniq(list), [1, 2, 3, 4], 'can find the unique values of an unsorted array'); + + list = [1, 1, 1, 2, 2, 3]; + deepEqual(_.uniq(list, true), [1, 2, 3], 'can find the unique values of a sorted array faster'); + + list = [{name: 'moe'}, {name: 'curly'}, {name: 'larry'}, {name: 'curly'}]; + var iterator = function(value) { return value.name; }; + deepEqual(_.map(_.uniq(list, false, iterator), iterator), ['moe', 'curly', 'larry'], 'can find the unique values of an array using a custom iterator'); + + deepEqual(_.map(_.uniq(list, iterator), iterator), ['moe', 'curly', 'larry'], 'can find the unique values of an array using a custom iterator without specifying whether array is sorted'); + + iterator = function(value) { return value +1; }; + list = [1, 2, 2, 3, 4, 4]; + deepEqual(_.uniq(list, true, iterator), [1, 2, 3, 4], 'iterator works with sorted array'); + + var result = (function(){ return _.uniq(arguments); })(1, 2, 1, 3, 1, 4); + deepEqual(result, [1, 2, 3, 4], 'works on an arguments object'); + + deepEqual(_.uniq(null), []); + + var context = {}; + list = [3]; + _.uniq(list, function(value, index, array) { + strictEqual(this, context); + strictEqual(value, 3); + strictEqual(index, 0); + }, context); + }); + + test('unique', function() { + strictEqual(_.uniq, _.unique, 'alias for uniq'); + }); + + test('intersection', function() { + var stooges = ['moe', 'curly', 'larry'], leaders = ['moe', 'groucho']; + deepEqual(_.intersection(stooges, leaders), ['moe'], 'can take the set intersection of two arrays'); + deepEqual(_(stooges).intersection(leaders), ['moe'], 'can perform an OO-style intersection'); + var result = (function(){ return _.intersection(arguments, leaders); })('moe', 'curly', 'larry'); + deepEqual(result, ['moe'], 'works on an arguments object'); + var theSixStooges = ['moe', 'moe', 'curly', 'curly', 'larry', 'larry']; + deepEqual(_.intersection(theSixStooges, leaders), ['moe'], 'returns a duplicate-free array'); + result = _.intersection([2, 4, 3, 1], [1, 2, 3]); + deepEqual(result, [2, 3, 1], 'preserves order of first array'); + result = _.intersection(null, [1, 2, 3]); + equal(Object.prototype.toString.call(result), '[object Array]', 'returns an empty array when passed null as first argument'); + equal(result.length, 0, 'returns an empty array when passed null as first argument'); + result = _.intersection([1, 2, 3], null); + equal(Object.prototype.toString.call(result), '[object Array]', 'returns an empty array when passed null as argument beyond the first'); + equal(result.length, 0, 'returns an empty array when passed null as argument beyond the first'); + }); + + test('union', function() { + var result = _.union([1, 2, 3], [2, 30, 1], [1, 40]); + deepEqual(result, [1, 2, 3, 30, 40], 'takes the union of a list of arrays'); + + result = _.union([1, 2, 3], [2, 30, 1], [1, 40, [1]]); + deepEqual(result, [1, 2, 3, 30, 40, [1]], 'takes the union of a list of nested arrays'); + + var args = null; + (function(){ args = arguments; })(1, 2, 3); + result = _.union(args, [2, 30, 1], [1, 40]); + deepEqual(result, [1, 2, 3, 30, 40], 'takes the union of a list of arrays'); + + result = _.union([1, 2, 3], 4); + deepEqual(result, [1, 2, 3], 'restrict the union to arrays only'); + }); + + test('difference', function() { + var result = _.difference([1, 2, 3], [2, 30, 40]); + deepEqual(result, [1, 3], 'takes the difference of two arrays'); + + result = _.difference([1, 2, 3, 4], [2, 30, 40], [1, 11, 111]); + deepEqual(result, [3, 4], 'takes the difference of three arrays'); + + result = _.difference([1, 2, 3], 1); + deepEqual(result, [1, 2, 3], 'restrict the difference to arrays only'); + }); + + test('zip', function() { + var names = ['moe', 'larry', 'curly'], ages = [30, 40, 50], leaders = [true]; + deepEqual(_.zip(names, ages, leaders), [ + ['moe', 30, true], + ['larry', 40, undefined], + ['curly', 50, undefined] + ], 'zipped together arrays of different lengths'); + + var stooges = _.zip(['moe', 30, 'stooge 1'], ['larry', 40, 'stooge 2'], ['curly', 50, 'stooge 3']); + deepEqual(stooges, [['moe', 'larry', 'curly'], [30, 40, 50], ['stooge 1', 'stooge 2', 'stooge 3']], 'zipped pairs'); + + // In the case of difference lengths of the tuples undefineds + // should be used as placeholder + stooges = _.zip(['moe', 30], ['larry', 40], ['curly', 50, 'extra data']); + deepEqual(stooges, [['moe', 'larry', 'curly'], [30, 40, 50], [undefined, undefined, 'extra data']], 'zipped pairs with empties'); + + var empty = _.zip([]); + deepEqual(empty, [], 'unzipped empty'); + + deepEqual(_.zip(null), [], 'handles null'); + deepEqual(_.zip(), [], '_.zip() returns []'); + }); + + test('object', function() { + var result = _.object(['moe', 'larry', 'curly'], [30, 40, 50]); + var shouldBe = {moe: 30, larry: 40, curly: 50}; + deepEqual(result, shouldBe, 'two arrays zipped together into an object'); + + result = _.object([['one', 1], ['two', 2], ['three', 3]]); + shouldBe = {one: 1, two: 2, three: 3}; + deepEqual(result, shouldBe, 'an array of pairs zipped together into an object'); + + var stooges = {moe: 30, larry: 40, curly: 50}; + deepEqual(_.object(_.pairs(stooges)), stooges, 'an object converted to pairs and back to an object'); + + deepEqual(_.object(null), {}, 'handles nulls'); + }); + + test('indexOf', function() { + var numbers = [1, 2, 3]; + equal(_.indexOf(numbers, 2), 1, 'can compute indexOf'); + var result = (function(){ return _.indexOf(arguments, 2); })(1, 2, 3); + equal(result, 1, 'works on an arguments object'); + equal(_.indexOf(null, 2), -1, 'handles nulls properly'); + + var num = 35; + numbers = [10, 20, 30, 40, 50]; + var index = _.indexOf(numbers, num, true); + equal(index, -1, '35 is not in the list'); + + numbers = [10, 20, 30, 40, 50]; num = 40; + index = _.indexOf(numbers, num, true); + equal(index, 3, '40 is in the list'); + + numbers = [1, 40, 40, 40, 40, 40, 40, 40, 50, 60, 70]; num = 40; + equal(_.indexOf(numbers, num, true), 1, '40 is in the list'); + equal(_.indexOf(numbers, 6, true), -1, '6 isnt in the list'); + equal(_.indexOf([1, 2, 5, 4, 6, 7], 5, true), -1, 'sorted indexOf doesn\'t uses binary search'); + ok(_.every(["1", [], {}, null], function() { + return _.indexOf(numbers, num, {}) === 1; + }), 'non-nums as fromIndex make indexOf assume sorted'); + + numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3]; + index = _.indexOf(numbers, 2, 5); + equal(index, 7, 'supports the fromIndex argument'); + + index = _.indexOf([,,,], undefined); + equal(index, 0, 'treats sparse arrays as if they were dense'); + + var array = [1, 2, 3, 1, 2, 3]; + strictEqual(_.indexOf(array, 1, -3), 3, 'neg `fromIndex` starts at the right index'); + strictEqual(_.indexOf(array, 1, -2), -1, 'neg `fromIndex` starts at the right index'); + strictEqual(_.indexOf(array, 2, -3), 4); + _.each([-6, -8, -Infinity], function(fromIndex) { + strictEqual(_.indexOf(array, 1, fromIndex), 0); + }); + strictEqual(_.indexOf([1, 2, 3], 1, true), 0); + }); + + test('lastIndexOf', function() { + var numbers = [1, 0, 1]; + var falsey = [, '', 0, false, NaN, null, undefined]; + equal(_.lastIndexOf(numbers, 1), 2); + + numbers = [1, 0, 1, 0, 0, 1, 0, 0, 0]; + numbers.lastIndexOf = null; + equal(_.lastIndexOf(numbers, 1), 5, 'can compute lastIndexOf, even without the native function'); + equal(_.lastIndexOf(numbers, 0), 8, 'lastIndexOf the other element'); + var result = (function(){ return _.lastIndexOf(arguments, 1); })(1, 0, 1, 0, 0, 1, 0, 0, 0); + equal(result, 5, 'works on an arguments object'); + equal(_.lastIndexOf(null, 2), -1, 'handles nulls properly'); + + numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3]; + var index = _.lastIndexOf(numbers, 2, 2); + equal(index, 1, 'supports the fromIndex argument'); + + var array = [1, 2, 3, 1, 2, 3]; + + strictEqual(_.lastIndexOf(array, 1, 0), 0, 'starts at the correct from idx'); + strictEqual(_.lastIndexOf(array, 3), 5, 'should return the index of the last matched value'); + strictEqual(_.lastIndexOf(array, 4), -1, 'should return `-1` for an unmatched value'); + + strictEqual(_.lastIndexOf(array, 1, 2), 0, 'should work with a positive `fromIndex`'); + + _.each([6, 8, Math.pow(2, 32), Infinity], function(fromIndex) { + strictEqual(_.lastIndexOf(array, undefined, fromIndex), -1); + strictEqual(_.lastIndexOf(array, 1, fromIndex), 3); + strictEqual(_.lastIndexOf(array, '', fromIndex), -1); + }); + + var expected = _.map(falsey, function(value) { + return typeof value == 'number' ? -1 : 5; + }); + + var actual = _.map(falsey, function(fromIndex) { + return _.lastIndexOf(array, 3, fromIndex); + }); + + deepEqual(actual, expected, 'should treat falsey `fromIndex` values, except `0` and `NaN`, as `array.length`'); + strictEqual(_.lastIndexOf(array, 3, '1'), 5, 'should treat non-number `fromIndex` values as `array.length`'); + strictEqual(_.lastIndexOf(array, 3, true), 5, 'should treat non-number `fromIndex` values as `array.length`'); + + strictEqual(_.lastIndexOf(array, 2, -3), 1, 'should work with a negative `fromIndex`'); + strictEqual(_.lastIndexOf(array, 1, -3), 3, 'neg `fromIndex` starts at the right index'); + + deepEqual(_.map([-6, -8, -Infinity], function(fromIndex) { + return _.lastIndexOf(array, 1, fromIndex); + }), [0, -1, -1]); + }); + + test('range', function() { + deepEqual(_.range(0), [], 'range with 0 as a first argument generates an empty array'); + deepEqual(_.range(4), [0, 1, 2, 3], 'range with a single positive argument generates an array of elements 0,1,2,...,n-1'); + deepEqual(_.range(5, 8), [5, 6, 7], 'range with two arguments a & b, a<b generates an array of elements a,a+1,a+2,...,b-2,b-1'); + deepEqual(_.range(8, 5), [], 'range with two arguments a & b, b<a generates an empty array'); + deepEqual(_.range(3, 10, 3), [3, 6, 9], 'range with three arguments a & b & c, c < b-a, a < b generates an array of elements a,a+c,a+2c,...,b - (multiplier of a) < c'); + deepEqual(_.range(3, 10, 15), [3], 'range with three arguments a & b & c, c > b-a, a < b generates an array with a single element, equal to a'); + deepEqual(_.range(12, 7, -2), [12, 10, 8], 'range with three arguments a & b & c, a > b, c < 0 generates an array of elements a,a-c,a-2c and ends with the number not less than b'); + deepEqual(_.range(0, -10, -1), [0, -1, -2, -3, -4, -5, -6, -7, -8, -9], 'final example in the Python docs'); + }); + +})(); diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/chaining.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/chaining.js new file mode 100644 index 000000000..0f377e2bc --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/chaining.js @@ -0,0 +1,65 @@ +(function() { + + module('Chaining'); + + test('map/flatten/reduce', function() { + var lyrics = [ + "I'm a lumberjack and I'm okay", + "I sleep all night and I work all day", + "He's a lumberjack and he's okay", + "He sleeps all night and he works all day" + ]; + var counts = _(lyrics).chain() + .map(function(line) { return line.split(''); }) + .flatten() + .reduce(function(hash, l) { + hash[l] = hash[l] || 0; + hash[l]++; + return hash; + }, {}).value(); + ok(counts.a == 16 && counts.e == 10, 'counted all the letters in the song'); + }); + + test('select/reject/sortBy', function() { + var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + numbers = _(numbers).chain().select(function(n) { + return n % 2 === 0; + }).reject(function(n) { + return n % 4 === 0; + }).sortBy(function(n) { + return -n; + }).value(); + deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers'); + }); + + test('select/reject/sortBy in functional style', function() { + var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + numbers = _.chain(numbers).select(function(n) { + return n % 2 === 0; + }).reject(function(n) { + return n % 4 === 0; + }).sortBy(function(n) { + return -n; + }).value(); + deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers'); + }); + + test('reverse/concat/unshift/pop/map', function() { + var numbers = [1, 2, 3, 4, 5]; + numbers = _(numbers).chain() + .reverse() + .concat([5, 5, 5]) + .unshift(17) + .pop() + .map(function(n){ return n * 2; }) + .value(); + deepEqual(numbers, [34, 10, 8, 6, 4, 2, 10, 10], 'can chain together array functions.'); + }); + + test('chaining works in small stages', function() { + var o = _([1, 2, 3, 4]).chain(); + deepEqual(o.filter(function(i) { return i < 3; }).value(), [1, 2]); + deepEqual(o.filter(function(i) { return i > 2; }).value(), [3, 4]); + }); + +})(); diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/collections.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/collections.js new file mode 100644 index 000000000..0a36bfe85 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/collections.js @@ -0,0 +1,676 @@ +(function() { + + module('Collections'); + + test('each', function() { + _.each([1, 2, 3], function(num, i) { + equal(num, i + 1, 'each iterators provide value and iteration count'); + }); + + var answers = []; + _.each([1, 2, 3], function(num){ answers.push(num * this.multiplier);}, {multiplier : 5}); + deepEqual(answers, [5, 10, 15], 'context object property accessed'); + + answers = []; + _.each([1, 2, 3], function(num){ answers.push(num); }); + deepEqual(answers, [1, 2, 3], 'aliased as "forEach"'); + + answers = []; + var obj = {one : 1, two : 2, three : 3}; + obj.constructor.prototype.four = 4; + _.each(obj, function(value, key){ answers.push(key); }); + deepEqual(answers, ['one', 'two', 'three'], 'iterating over objects works, and ignores the object prototype.'); + delete obj.constructor.prototype.four; + + var answer = null; + _.each([1, 2, 3], function(num, index, arr){ if (_.include(arr, num)) answer = true; }); + ok(answer, 'can reference the original collection from inside the iterator'); + + answers = 0; + _.each(null, function(){ ++answers; }); + equal(answers, 0, 'handles a null properly'); + + _.each(false, function(){}); + + var a = [1, 2, 3]; + strictEqual(_.each(a, function(){}), a); + strictEqual(_.each(null, function(){}), null); + + var b = [1, 2, 3]; + b.length = 100; + answers = 0; + _.each(b, function(){ ++answers; }); + equal(answers, 100, 'enumerates [0, length)'); + }); + + test('forEach', function() { + strictEqual(_.each, _.forEach, 'alias for each'); + }); + + test('lookupIterator with contexts', function() { + _.each([true, false, 'yes', '', 0, 1, {}], function(context) { + _.each([1], function() { + equal(this, context); + }, context); + }); + }); + + test('map', function() { + var doubled = _.map([1, 2, 3], function(num){ return num * 2; }); + deepEqual(doubled, [2, 4, 6], 'doubled numbers'); + + var tripled = _.map([1, 2, 3], function(num){ return num * this.multiplier; }, {multiplier : 3}); + deepEqual(tripled, [3, 6, 9], 'tripled numbers with context'); + + var doubled = _([1, 2, 3]).map(function(num){ return num * 2; }); + deepEqual(doubled, [2, 4, 6], 'OO-style doubled numbers'); + + if (document.querySelectorAll) { + var ids = _.map(document.querySelectorAll('#map-test *'), function(n){ return n.id; }); + deepEqual(ids, ['id1', 'id2'], 'Can use collection methods on NodeLists.'); + } + + var ids = _.map({length: 2, 0: {id: '1'}, 1: {id: '2'}}, function(n){ + return n.id; + }); + deepEqual(ids, ['1', '2'], 'Can use collection methods on Array-likes.'); + + deepEqual(_.map(null, _.noop), [], 'handles a null properly'); + + deepEqual(_.map([1], function() { + return this.length; + }, [5]), [1], 'called with context'); + + // Passing a property name like _.pluck. + var people = [{name : 'moe', age : 30}, {name : 'curly', age : 50}]; + deepEqual(_.map(people, 'name'), ['moe', 'curly'], 'predicate string map to object properties'); + }); + + test('collect', function() { + strictEqual(_.map, _.collect, 'alias for map'); + }); + + test('reduce', function() { + var sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num; }, 0); + equal(sum, 6, 'can sum up an array'); + + var context = {multiplier : 3}; + sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num * this.multiplier; }, 0, context); + equal(sum, 18, 'can reduce with a context object'); + + sum = _.inject([1, 2, 3], function(sum, num){ return sum + num; }, 0); + equal(sum, 6, 'aliased as "inject"'); + + sum = _([1, 2, 3]).reduce(function(sum, num){ return sum + num; }, 0); + equal(sum, 6, 'OO-style reduce'); + + var sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num; }); + equal(sum, 6, 'default initial value'); + + var prod = _.reduce([1, 2, 3, 4], function(prod, num){ return prod * num; }); + equal(prod, 24, 'can reduce via multiplication'); + + ok(_.reduce(null, _.noop, 138) === 138, 'handles a null (with initial value) properly'); + equal(_.reduce([], _.noop, undefined), undefined, 'undefined can be passed as a special case'); + + raises(function() { _.reduce([], _.noop); }, TypeError, 'throws an error for empty arrays with no initial value'); + raises(function() {_.reduce(null, _.noop);}, TypeError, 'handles a null (without initial value) properly'); + }); + + test('foldl', function() { + strictEqual(_.reduce, _.foldl, 'alias for reduce'); + }); + + test('reduceRight', function() { + var list = _.reduceRight(['foo', 'bar', 'baz'], function(memo, str){ return memo + str; }, ''); + equal(list, 'bazbarfoo', 'can perform right folds'); + + var list = _.reduceRight(['foo', 'bar', 'baz'], function(memo, str){ return memo + str; }); + equal(list, 'bazbarfoo', 'default initial value'); + + var sum = _.reduceRight({a: 1, b: 2, c: 3}, function(sum, num){ return sum + num; }); + equal(sum, 6, 'default initial value on object'); + + ok(_.reduceRight(null, _.noop, 138) === 138, 'handles a null (with initial value) properly'); + + equal(_.reduceRight([], _.noop, undefined), undefined, 'undefined can be passed as a special case'); + + raises(function() { _.reduceRight([], _.noop); }, TypeError, 'throws an error for empty arrays with no initial value'); + raises(function() {_.reduceRight(null, _.noop);}, TypeError, 'handles a null (without initial value) properly'); + + // Assert that the correct arguments are being passed. + + var args, + memo = {}, + object = {a: 1, b: 2}, + lastKey = _.keys(object).pop(); + + var expected = lastKey == 'a' + ? [memo, 1, 'a', object] + : [memo, 2, 'b', object]; + + _.reduceRight(object, function() { + args || (args = _.toArray(arguments)); + }, memo); + + deepEqual(args, expected); + + // And again, with numeric keys. + + object = {'2': 'a', '1': 'b'}; + lastKey = _.keys(object).pop(); + args = null; + + expected = lastKey == '2' + ? [memo, 'a', '2', object] + : [memo, 'b', '1', object]; + + _.reduceRight(object, function() { + args || (args = _.toArray(arguments)); + }, memo); + + deepEqual(args, expected); + }); + + test('foldr', function() { + strictEqual(_.reduceRight, _.foldr, 'alias for reduceRight'); + }); + + test('find', function() { + var array = [1, 2, 3, 4]; + strictEqual(_.find(array, function(n) { return n > 2; }), 3, 'should return first found `value`'); + strictEqual(_.find(array, function() { return false; }), void 0, 'should return `undefined` if `value` is not found'); + + // Matching an object like _.findWhere. + var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}, {a: 2, b: 4}]; + deepEqual(_.find(list, {a: 1}), {a: 1, b: 2}, 'can be used as findWhere'); + deepEqual(_.find(list, {b: 4}), {a: 1, b: 4}); + ok(!_.find(list, {c: 1}), 'undefined when not found'); + ok(!_.find([], {c: 1}), 'undefined when searching empty list'); + + var result = _.find([1, 2, 3], function(num){ return num * 2 == 4; }); + equal(result, 2, 'found the first "2" and broke the loop'); + }); + + test('detect', function() { + strictEqual(_.detect, _.find, 'alias for detect'); + }); + + test('filter', function() { + var evenArray = [1, 2, 3, 4, 5, 6]; + var evenObject = {one: 1, two: 2, three: 3}; + var isEven = function(num){ return num % 2 === 0; }; + + deepEqual(_.filter(evenArray, isEven), [2, 4, 6]); + deepEqual(_.filter(evenObject, isEven), [2], 'can filter objects'); + deepEqual(_.filter([{}, evenObject, []], 'two'), [evenObject], 'predicate string map to object properties'); + + _.filter([1], function() { + equal(this, evenObject, 'given context'); + }, evenObject); + + // Can be used like _.where. + var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}]; + deepEqual(_.filter(list, {a: 1}), [{a: 1, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}]); + deepEqual(_.filter(list, {b: 2}), [{a: 1, b: 2}, {a: 2, b: 2}]); + deepEqual(_.filter(list, {}), list, 'Empty object accepts all items'); + deepEqual(_(list).filter({}), list, 'OO-filter'); + }); + + test('select', function() { + strictEqual(_.filter, _.select, 'alias for filter'); + }); + + test('reject', function() { + var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; }); + deepEqual(odds, [1, 3, 5], 'rejected each even number'); + + var context = 'obj'; + + var evens = _.reject([1, 2, 3, 4, 5, 6], function(num){ + equal(context, 'obj'); + return num % 2 != 0; + }, context); + deepEqual(evens, [2, 4, 6], 'rejected each odd number'); + + deepEqual(_.reject([odds, {one: 1, two: 2, three: 3}], 'two'), [odds], 'predicate string map to object properties'); + + // Can be used like _.where. + var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}]; + deepEqual(_.reject(list, {a: 1}), [{a: 2, b: 2}]); + deepEqual(_.reject(list, {b: 2}), [{a: 1, b: 3}, {a: 1, b: 4}]); + deepEqual(_.reject(list, {}), [], 'Returns empty list given empty object'); + deepEqual(_.reject(list, []), [], 'Returns empty list given empty array'); + }); + + test('every', function() { + ok(_.every([], _.identity), 'the empty set'); + ok(_.every([true, true, true], _.identity), 'every true values'); + ok(!_.every([true, false, true], _.identity), 'one false value'); + ok(_.every([0, 10, 28], function(num){ return num % 2 == 0; }), 'even numbers'); + ok(!_.every([0, 11, 28], function(num){ return num % 2 == 0; }), 'an odd number'); + ok(_.every([1], _.identity) === true, 'cast to boolean - true'); + ok(_.every([0], _.identity) === false, 'cast to boolean - false'); + ok(!_.every([undefined, undefined, undefined], _.identity), 'works with arrays of undefined'); + + var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}]; + ok(!_.every(list, {a: 1, b: 2}), 'Can be called with object'); + ok(_.every(list, 'a'), 'String mapped to object property'); + + list = [{a: 1, b: 2}, {a: 2, b: 2, c: true}]; + ok(_.every(list, {b: 2}), 'Can be called with object'); + ok(!_.every(list, 'c'), 'String mapped to object property'); + + ok(_.every({a: 1, b: 2, c: 3, d: 4}, _.isNumber), 'takes objects'); + ok(!_.every({a: 1, b: 2, c: 3, d: 4}, _.isObject), 'takes objects'); + ok(_.every(['a', 'b', 'c', 'd'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works'); + ok(!_.every(['a', 'b', 'c', 'd', 'f'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works'); + }); + + test('all', function() { + strictEqual(_.all, _.every, 'alias for all'); + }); + + test('some', function() { + ok(!_.some([]), 'the empty set'); + ok(!_.some([false, false, false]), 'all false values'); + ok(_.some([false, false, true]), 'one true value'); + ok(_.some([null, 0, 'yes', false]), 'a string'); + ok(!_.some([null, 0, '', false]), 'falsy values'); + ok(!_.some([1, 11, 29], function(num){ return num % 2 == 0; }), 'all odd numbers'); + ok(_.some([1, 10, 29], function(num){ return num % 2 == 0; }), 'an even number'); + ok(_.some([1], _.identity) === true, 'cast to boolean - true'); + ok(_.some([0], _.identity) === false, 'cast to boolean - false'); + ok(_.some([false, false, true])); + + var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}]; + ok(!_.some(list, {a: 5, b: 2}), 'Can be called with object'); + ok(_.some(list, 'a'), 'String mapped to object property'); + + list = [{a: 1, b: 2}, {a: 2, b: 2, c: true}]; + ok(_.some(list, {b: 2}), 'Can be called with object'); + ok(!_.some(list, 'd'), 'String mapped to object property'); + + ok(_.some({a: '1', b: '2', c: '3', d: '4', e: 6}, _.isNumber), 'takes objects'); + ok(!_.some({a: 1, b: 2, c: 3, d: 4}, _.isObject), 'takes objects'); + ok(_.some(['a', 'b', 'c', 'd'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works'); + ok(!_.some(['x', 'y', 'z'], _.hasOwnProperty, {a: 1, b: 2, c: 3, d: 4}), 'context works'); + }); + + test('any', function() { + strictEqual(_.any, _.some, 'alias for any'); + }); + + test('contains', function() { + ok(_.contains([1, 2, 3], 2), 'two is in the array'); + ok(!_.contains([1, 3, 9], 2), 'two is not in the array'); + ok(_.contains({moe: 1, larry: 3, curly: 9}, 3) === true, '_.contains on objects checks their values'); + ok(_([1, 2, 3]).contains(2), 'OO-style contains'); + }); + + test('include', function() { + strictEqual(_.contains, _.include, 'alias for contains'); + }); + + test('invoke', function() { + var list = [[5, 1, 7], [3, 2, 1]]; + var result = _.invoke(list, 'sort'); + deepEqual(result[0], [1, 5, 7], 'first array sorted'); + deepEqual(result[1], [1, 2, 3], 'second array sorted'); + }); + + test('invoke w/ function reference', function() { + var list = [[5, 1, 7], [3, 2, 1]]; + var result = _.invoke(list, Array.prototype.sort); + deepEqual(result[0], [1, 5, 7], 'first array sorted'); + deepEqual(result[1], [1, 2, 3], 'second array sorted'); + }); + + // Relevant when using ClojureScript + test('invoke when strings have a call method', function() { + String.prototype.call = function() { + return 42; + }; + var list = [[5, 1, 7], [3, 2, 1]]; + var s = 'foo'; + equal(s.call(), 42, 'call function exists'); + var result = _.invoke(list, 'sort'); + deepEqual(result[0], [1, 5, 7], 'first array sorted'); + deepEqual(result[1], [1, 2, 3], 'second array sorted'); + delete String.prototype.call; + equal(s.call, undefined, 'call function removed'); + }); + + test('pluck', function() { + var people = [{name: 'moe', age: 30}, {name: 'curly', age: 50}]; + deepEqual(_.pluck(people, 'name'), ['moe', 'curly'], 'pulls names out of objects'); + //compat: most flexible handling of edge cases + deepEqual(_.pluck([{'[object Object]': 1}], {}), [1]); + }); + + test('where', function() { + var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}]; + var result = _.where(list, {a: 1}); + equal(result.length, 3); + equal(result[result.length - 1].b, 4); + result = _.where(list, {b: 2}); + equal(result.length, 2); + equal(result[0].a, 1); + result = _.where(list, {}); + equal(result.length, list.length); + + function test() {} + test.map = _.map; + deepEqual(_.where([_, {a: 1, b: 2}, _], test), [_, _], 'checks properties given function'); + }); + + test('findWhere', function() { + var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}, {a: 2, b: 4}]; + var result = _.findWhere(list, {a: 1}); + deepEqual(result, {a: 1, b: 2}); + result = _.findWhere(list, {b: 4}); + deepEqual(result, {a: 1, b: 4}); + + result = _.findWhere(list, {c: 1}); + ok(_.isUndefined(result), 'undefined when not found'); + + result = _.findWhere([], {c: 1}); + ok(_.isUndefined(result), 'undefined when searching empty list'); + + function test() {} + test.map = _.map; + equal(_.findWhere([_, {a: 1, b: 2}, _], test), _, 'checks properties given function'); + + function TestClass() { + this.y = 5; + this.x = 'foo'; + } + var expect = {c: 1, x: 'foo', y: 5}; + deepEqual(_.findWhere([{y: 5, b: 6}, expect], new TestClass()), expect, 'uses class instance properties'); + }); + + test('max', function() { + equal(3, _.max([1, 2, 3]), 'can perform a regular Math.max'); + + var neg = _.max([1, 2, 3], function(num){ return -num; }); + equal(neg, 1, 'can perform a computation-based max'); + + equal(-Infinity, _.max({}), 'Maximum value of an empty object'); + equal(-Infinity, _.max([]), 'Maximum value of an empty array'); + equal(_.max({'a': 'a'}), -Infinity, 'Maximum value of a non-numeric collection'); + + equal(299999, _.max(_.range(1, 300000)), 'Maximum value of a too-big array'); + + equal(3, _.max([1, 2, 3, 'test']), 'Finds correct max in array starting with num and containing a NaN'); + equal(3, _.max(['test', 1, 2, 3]), 'Finds correct max in array starting with NaN'); + + var a = {x: -Infinity}; + var b = {x: -Infinity}; + var iterator = function(o){ return o.x; }; + equal(_.max([a, b], iterator), a, 'Respects iterator return value of -Infinity'); + + deepEqual(_.max([{'a': 1}, {'a': 0, 'b': 3}, {'a': 4}, {'a': 2}], 'a'), {'a': 4}, 'String keys use property iterator'); + + deepEqual(_.max([0, 2], function(a, b){ return a * this.x; }, {x: 1}), 2, 'Iterator context'); + }); + + test('min', function() { + equal(1, _.min([1, 2, 3]), 'can perform a regular Math.min'); + + var neg = _.min([1, 2, 3], function(num){ return -num; }); + equal(neg, 3, 'can perform a computation-based min'); + + equal(Infinity, _.min({}), 'Minimum value of an empty object'); + equal(Infinity, _.min([]), 'Minimum value of an empty array'); + equal(_.min({'a': 'a'}), Infinity, 'Minimum value of a non-numeric collection'); + + var now = new Date(9999999999); + var then = new Date(0); + equal(_.min([now, then]), then); + + equal(1, _.min(_.range(1, 300000)), 'Minimum value of a too-big array'); + + equal(1, _.min([1, 2, 3, 'test']), 'Finds correct min in array starting with num and containing a NaN'); + equal(1, _.min(['test', 1, 2, 3]), 'Finds correct min in array starting with NaN'); + + var a = {x: Infinity}; + var b = {x: Infinity}; + var iterator = function(o){ return o.x; }; + equal(_.min([a, b], iterator), a, 'Respects iterator return value of Infinity'); + + deepEqual(_.min([{'a': 1}, {'a': 0, 'b': 3}, {'a': 4}, {'a': 2}], 'a'), {'a': 0, 'b': 3}, 'String keys use property iterator'); + + deepEqual(_.min([0, 2], function(a, b){ return a * this.x; }, {x: -1}), 2, 'Iterator context'); + }); + + test('sortBy', function() { + var people = [{name : 'curly', age : 50}, {name : 'moe', age : 30}]; + people = _.sortBy(people, function(person){ return person.age; }); + deepEqual(_.pluck(people, 'name'), ['moe', 'curly'], 'stooges sorted by age'); + + var list = [undefined, 4, 1, undefined, 3, 2]; + deepEqual(_.sortBy(list, _.identity), [1, 2, 3, 4, undefined, undefined], 'sortBy with undefined values'); + + var list = ['one', 'two', 'three', 'four', 'five']; + var sorted = _.sortBy(list, 'length'); + deepEqual(sorted, ['one', 'two', 'four', 'five', 'three'], 'sorted by length'); + + function Pair(x, y) { + this.x = x; + this.y = y; + } + + var collection = [ + new Pair(1, 1), new Pair(1, 2), + new Pair(1, 3), new Pair(1, 4), + new Pair(1, 5), new Pair(1, 6), + new Pair(2, 1), new Pair(2, 2), + new Pair(2, 3), new Pair(2, 4), + new Pair(2, 5), new Pair(2, 6), + new Pair(undefined, 1), new Pair(undefined, 2), + new Pair(undefined, 3), new Pair(undefined, 4), + new Pair(undefined, 5), new Pair(undefined, 6) + ]; + + var actual = _.sortBy(collection, function(pair) { + return pair.x; + }); + + deepEqual(actual, collection, 'sortBy should be stable'); + + deepEqual(_.sortBy(collection, 'x'), collection, 'sortBy accepts property string'); + + var list = ['q', 'w', 'e', 'r', 't', 'y']; + deepEqual(_.sortBy(list), ['e', 'q', 'r', 't', 'w', 'y'], 'uses _.identity if iterator is not specified'); + }); + + test('groupBy', function() { + var parity = _.groupBy([1, 2, 3, 4, 5, 6], function(num){ return num % 2; }); + ok('0' in parity && '1' in parity, 'created a group for each value'); + deepEqual(parity[0], [2, 4, 6], 'put each even number in the right group'); + + var list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']; + var grouped = _.groupBy(list, 'length'); + deepEqual(grouped['3'], ['one', 'two', 'six', 'ten']); + deepEqual(grouped['4'], ['four', 'five', 'nine']); + deepEqual(grouped['5'], ['three', 'seven', 'eight']); + + var context = {}; + _.groupBy([{}], function(){ ok(this === context); }, context); + + grouped = _.groupBy([4.2, 6.1, 6.4], function(num) { + return Math.floor(num) > 4 ? 'hasOwnProperty' : 'constructor'; + }); + equal(grouped.constructor.length, 1); + equal(grouped.hasOwnProperty.length, 2); + + var array = [{}]; + _.groupBy(array, function(value, index, obj){ ok(obj === array); }); + + var array = [1, 2, 1, 2, 3]; + var grouped = _.groupBy(array); + equal(grouped['1'].length, 2); + equal(grouped['3'].length, 1); + + var matrix = [ + [1, 2], + [1, 3], + [2, 3] + ]; + deepEqual(_.groupBy(matrix, 0), {1: [[1, 2], [1, 3]], 2: [[2, 3]]}); + deepEqual(_.groupBy(matrix, 1), {2: [[1, 2]], 3: [[1, 3], [2, 3]]}); + }); + + test('indexBy', function() { + var parity = _.indexBy([1, 2, 3, 4, 5], function(num){ return num % 2 == 0; }); + equal(parity['true'], 4); + equal(parity['false'], 5); + + var list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']; + var grouped = _.indexBy(list, 'length'); + equal(grouped['3'], 'ten'); + equal(grouped['4'], 'nine'); + equal(grouped['5'], 'eight'); + + var array = [1, 2, 1, 2, 3]; + var grouped = _.indexBy(array); + equal(grouped['1'], 1); + equal(grouped['2'], 2); + equal(grouped['3'], 3); + }); + + test('countBy', function() { + var parity = _.countBy([1, 2, 3, 4, 5], function(num){ return num % 2 == 0; }); + equal(parity['true'], 2); + equal(parity['false'], 3); + + var list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']; + var grouped = _.countBy(list, 'length'); + equal(grouped['3'], 4); + equal(grouped['4'], 3); + equal(grouped['5'], 3); + + var context = {}; + _.countBy([{}], function(){ ok(this === context); }, context); + + grouped = _.countBy([4.2, 6.1, 6.4], function(num) { + return Math.floor(num) > 4 ? 'hasOwnProperty' : 'constructor'; + }); + equal(grouped.constructor, 1); + equal(grouped.hasOwnProperty, 2); + + var array = [{}]; + _.countBy(array, function(value, index, obj){ ok(obj === array); }); + + var array = [1, 2, 1, 2, 3]; + var grouped = _.countBy(array); + equal(grouped['1'], 2); + equal(grouped['3'], 1); + }); + + test('sortedIndex', function() { + var numbers = [10, 20, 30, 40, 50], num = 35; + var indexForNum = _.sortedIndex(numbers, num); + equal(indexForNum, 3, '35 should be inserted at index 3'); + + var indexFor30 = _.sortedIndex(numbers, 30); + equal(indexFor30, 2, '30 should be inserted at index 2'); + + var objects = [{x: 10}, {x: 20}, {x: 30}, {x: 40}]; + var iterator = function(obj){ return obj.x; }; + strictEqual(_.sortedIndex(objects, {x: 25}, iterator), 2); + strictEqual(_.sortedIndex(objects, {x: 35}, 'x'), 3); + + var context = {1: 2, 2: 3, 3: 4}; + iterator = function(obj){ return this[obj]; }; + strictEqual(_.sortedIndex([1, 3], 2, iterator, context), 1); + }); + + test('shuffle', function() { + var numbers = _.range(10); + var shuffled = _.shuffle(numbers).sort(); + notStrictEqual(numbers, shuffled, 'original object is unmodified'); + deepEqual(shuffled, numbers, 'contains the same members before and after shuffle'); + }); + + test('sample', function() { + var numbers = _.range(10); + var all_sampled = _.sample(numbers, 10).sort(); + deepEqual(all_sampled, numbers, 'contains the same members before and after sample'); + all_sampled = _.sample(numbers, 20).sort(); + deepEqual(all_sampled, numbers, 'also works when sampling more objects than are present'); + ok(_.contains(numbers, _.sample(numbers)), 'sampling a single element returns something from the array'); + strictEqual(_.sample([]), undefined, 'sampling empty array with no number returns undefined'); + notStrictEqual(_.sample([], 5), [], 'sampling empty array with a number returns an empty array'); + notStrictEqual(_.sample([1, 2, 3], 0), [], 'sampling an array with 0 picks returns an empty array'); + deepEqual(_.sample([1, 2], -1), [], 'sampling a negative number of picks returns an empty array'); + ok(_.contains([1, 2, 3], _.sample({a: 1, b: 2, c: 3})), 'sample one value from an object'); + }); + + test('toArray', function() { + ok(!_.isArray(arguments), 'arguments object is not an array'); + ok(_.isArray(_.toArray(arguments)), 'arguments object converted into array'); + var a = [1, 2, 3]; + ok(_.toArray(a) !== a, 'array is cloned'); + deepEqual(_.toArray(a), [1, 2, 3], 'cloned array contains same elements'); + + var numbers = _.toArray({one : 1, two : 2, three : 3}); + deepEqual(numbers, [1, 2, 3], 'object flattened into array'); + + // test in IE < 9 + try { + var actual = _.toArray(document.childNodes); + } catch(ex) { } + + ok(_.isArray(actual), 'should not throw converting a node list'); + }); + + test('size', function() { + equal(_.size({one : 1, two : 2, three : 3}), 3, 'can compute the size of an object'); + equal(_.size([1, 2, 3]), 3, 'can compute the size of an array'); + equal(_.size({length: 3, 0: 0, 1: 0, 2: 0}), 3, 'can compute the size of Array-likes'); + + var func = function() { + return _.size(arguments); + }; + + equal(func(1, 2, 3, 4), 4, 'can test the size of the arguments object'); + + equal(_.size('hello'), 5, 'can compute the size of a string literal'); + equal(_.size(new String('hello')), 5, 'can compute the size of string object'); + + equal(_.size(null), 0, 'handles nulls'); + }); + + test('partition', function() { + var list = [0, 1, 2, 3, 4, 5]; + deepEqual(_.partition(list, function(x) { return x < 4; }), [[0, 1, 2, 3], [4, 5]], 'handles bool return values'); + deepEqual(_.partition(list, function(x) { return x & 1; }), [[1, 3, 5], [0, 2, 4]], 'handles 0 and 1 return values'); + deepEqual(_.partition(list, function(x) { return x - 3; }), [[0, 1, 2, 4, 5], [3]], 'handles other numeric return values'); + deepEqual(_.partition(list, function(x) { return x > 1 ? null : true; }), [[0, 1], [2, 3, 4, 5]], 'handles null return values'); + deepEqual(_.partition(list, function(x) { if(x < 2) return true; }), [[0, 1], [2, 3, 4, 5]], 'handles undefined return values'); + deepEqual(_.partition({a: 1, b: 2, c: 3}, function(x) { return x > 1; }), [[2, 3], [1]], 'handles objects'); + + deepEqual(_.partition(list, function(x, index) { return index % 2; }), [[1, 3, 5], [0, 2, 4]], 'can reference the array index'); + deepEqual(_.partition(list, function(x, index, arr) { return x === arr.length - 1; }), [[5], [0, 1, 2, 3, 4]], 'can reference the collection'); + + // Default iterator + deepEqual(_.partition([1, false, true, '']), [[1, true], [false, '']], 'Default iterator'); + deepEqual(_.partition([{x: 1}, {x: 0}, {x: 1}], 'x'), [[{x: 1}, {x: 1}], [{x: 0}]], 'Takes a string'); + + // Context + var predicate = function(x){ return x === this.x }; + deepEqual(_.partition([1, 2, 3], predicate, {x: 2}), [[2], [1, 3]], 'partition takes a context argument'); + + deepEqual(_.partition([{a: 1}, {b: 2}, {a: 1, b: 2}], {a: 1}), [[{a: 1}, {a: 1, b: 2}], [{b: 2}]], 'predicate can be object'); + + var object = {a: 1}; + _.partition(object, function(val, key, obj) { + equal(val, 1); + equal(key, 'a'); + equal(object, object); + equal(this, predicate); + }, predicate); + }); + +})(); diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/functions.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/functions.js new file mode 100644 index 000000000..47e1e456d --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/functions.js @@ -0,0 +1,535 @@ +(function() { + + module('Functions'); + + test('bind', function() { + var context = {name : 'moe'}; + var func = function(arg) { return 'name: ' + (this.name || arg); }; + var bound = _.bind(func, context); + equal(bound(), 'name: moe', 'can bind a function to a context'); + + bound = _(func).bind(context); + equal(bound(), 'name: moe', 'can do OO-style binding'); + + bound = _.bind(func, null, 'curly'); + equal(bound(), 'name: curly', 'can bind without specifying a context'); + + func = function(salutation, name) { return salutation + ': ' + name; }; + func = _.bind(func, this, 'hello'); + equal(func('moe'), 'hello: moe', 'the function was partially applied in advance'); + + func = _.bind(func, this, 'curly'); + equal(func(), 'hello: curly', 'the function was completely applied in advance'); + + func = function(salutation, firstname, lastname) { return salutation + ': ' + firstname + ' ' + lastname; }; + func = _.bind(func, this, 'hello', 'moe', 'curly'); + equal(func(), 'hello: moe curly', 'the function was partially applied in advance and can accept multiple arguments'); + + func = function(context, message) { equal(this, context, message); }; + _.bind(func, 0, 0, 'can bind a function to `0`')(); + _.bind(func, '', '', 'can bind a function to an empty string')(); + _.bind(func, false, false, 'can bind a function to `false`')(); + + // These tests are only meaningful when using a browser without a native bind function + // To test this with a modern browser, set underscore's nativeBind to undefined + var F = function () { return this; }; + var Boundf = _.bind(F, {hello: 'moe curly'}); + var newBoundf = new Boundf(); + equal(newBoundf.hello, undefined, 'function should not be bound to the context, to comply with ECMAScript 5'); + equal(Boundf().hello, 'moe curly', "When called without the new operator, it's OK to be bound to the context"); + ok(newBoundf instanceof F, 'a bound instance is an instance of the original function'); + + raises(function() { _.bind('notafunction'); }, TypeError, 'throws an error when binding to a non-function'); + }); + + test('partial', function() { + var obj = {name: 'moe'}; + var func = function() { return this.name + ' ' + _.toArray(arguments).join(' '); }; + + obj.func = _.partial(func, 'a', 'b'); + equal(obj.func('c', 'd'), 'moe a b c d', 'can partially apply'); + + obj.func = _.partial(func, _, 'b', _, 'd'); + equal(obj.func('a', 'c'), 'moe a b c d', 'can partially apply with placeholders'); + + func = _.partial(function() { return arguments.length; }, _, 'b', _, 'd'); + equal(func('a', 'c', 'e'), 5, 'accepts more arguments than the number of placeholders'); + equal(func('a'), 4, 'accepts fewer arguments than the number of placeholders'); + + func = _.partial(function() { return typeof arguments[2]; }, _, 'b', _, 'd'); + equal(func('a'), 'undefined', 'unfilled placeholders are undefined'); + }); + + test('bindAll', function() { + var curly = {name : 'curly'}, moe = { + name : 'moe', + getName : function() { return 'name: ' + this.name; }, + sayHi : function() { return 'hi: ' + this.name; } + }; + curly.getName = moe.getName; + _.bindAll(moe, 'getName', 'sayHi'); + curly.sayHi = moe.sayHi; + equal(curly.getName(), 'name: curly', 'unbound function is bound to current object'); + equal(curly.sayHi(), 'hi: moe', 'bound function is still bound to original object'); + + curly = {name : 'curly'}; + moe = { + name : 'moe', + getName : function() { return 'name: ' + this.name; }, + sayHi : function() { return 'hi: ' + this.name; }, + sayLast : function() { return this.sayHi(_.last(arguments)); } + }; + + raises(function() { _.bindAll(moe); }, Error, 'throws an error for bindAll with no functions named'); + raises(function() { _.bindAll(moe, "sayBye"); }, TypeError, 'throws an error for bindAll if the given key is undefined'); + raises(function() { _.bindAll(moe, "name"); }, TypeError, 'throws an error for bindAll if the given key is not a function'); + + _.bindAll(moe, 'sayHi', 'sayLast'); + curly.sayHi = moe.sayHi; + equal(curly.sayHi(), 'hi: moe'); + + var sayLast = moe.sayLast; + equal(sayLast(1, 2, 3, 4, 5, 6, 7, 'Tom'), 'hi: moe', 'createCallback works with any number of arguments'); + }); + + test('memoize', function() { + var fib = function(n) { + return n < 2 ? n : fib(n - 1) + fib(n - 2); + }; + equal(fib(10), 55, 'a memoized version of fibonacci produces identical results'); + fib = _.memoize(fib); // Redefine `fib` for memoization + equal(fib(10), 55, 'a memoized version of fibonacci produces identical results'); + + var o = function(str) { + return str; + }; + var fastO = _.memoize(o); + equal(o('toString'), 'toString', 'checks hasOwnProperty'); + equal(fastO('toString'), 'toString', 'checks hasOwnProperty'); + + // Expose the cache. + var upper = _.memoize(function(s) { + return s.toUpperCase(); + }); + equal(upper('foo'), 'FOO'); + equal(upper('bar'), 'BAR'); + deepEqual(upper.cache, {foo: 'FOO', bar: 'BAR'}); + upper.cache = {foo: 'BAR', bar: 'FOO'}; + equal(upper('foo'), 'BAR'); + equal(upper('bar'), 'FOO'); + + var hashed = _.memoize(function(key) { + //https://github.com/jashkenas/underscore/pull/1679#discussion_r13736209 + ok(/[a-z]+/.test(key), 'hasher doesn\'t change keys'); + return key; + }, function(key) { + return key.toUpperCase(); + }); + hashed('yep'); + deepEqual(hashed.cache, {'YEP': 'yep'}, 'takes a hasher'); + }); + + asyncTest('delay', 2, function() { + var delayed = false; + _.delay(function(){ delayed = true; }, 100); + setTimeout(function(){ ok(!delayed, "didn't delay the function quite yet"); }, 50); + setTimeout(function(){ ok(delayed, 'delayed the function'); start(); }, 150); + }); + + asyncTest('defer', 1, function() { + var deferred = false; + _.defer(function(bool){ deferred = bool; }, true); + _.delay(function(){ ok(deferred, 'deferred the function'); start(); }, 50); + }); + + asyncTest('throttle', 2, function() { + var counter = 0; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 32); + throttledIncr(); throttledIncr(); + + equal(counter, 1, 'incr was called immediately'); + _.delay(function(){ equal(counter, 2, 'incr was throttled'); start(); }, 64); + }); + + asyncTest('throttle arguments', 2, function() { + var value = 0; + var update = function(val){ value = val; }; + var throttledUpdate = _.throttle(update, 32); + throttledUpdate(1); throttledUpdate(2); + _.delay(function(){ throttledUpdate(3); }, 64); + equal(value, 1, 'updated to latest value'); + _.delay(function(){ equal(value, 3, 'updated to latest value'); start(); }, 96); + }); + + asyncTest('throttle once', 2, function() { + var counter = 0; + var incr = function(){ return ++counter; }; + var throttledIncr = _.throttle(incr, 32); + var result = throttledIncr(); + _.delay(function(){ + equal(result, 1, 'throttled functions return their value'); + equal(counter, 1, 'incr was called once'); start(); + }, 64); + }); + + asyncTest('throttle twice', 1, function() { + var counter = 0; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 32); + throttledIncr(); throttledIncr(); + _.delay(function(){ equal(counter, 2, 'incr was called twice'); start(); }, 64); + }); + + asyncTest('more throttling', 3, function() { + var counter = 0; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 30); + throttledIncr(); throttledIncr(); + ok(counter == 1); + _.delay(function(){ + ok(counter == 2); + throttledIncr(); + ok(counter == 3); + start(); + }, 85); + }); + + asyncTest('throttle repeatedly with results', 6, function() { + var counter = 0; + var incr = function(){ return ++counter; }; + var throttledIncr = _.throttle(incr, 100); + var results = []; + var saveResult = function() { results.push(throttledIncr()); }; + saveResult(); saveResult(); + _.delay(saveResult, 50); + _.delay(saveResult, 150); + _.delay(saveResult, 160); + _.delay(saveResult, 230); + _.delay(function() { + equal(results[0], 1, 'incr was called once'); + equal(results[1], 1, 'incr was throttled'); + equal(results[2], 1, 'incr was throttled'); + equal(results[3], 2, 'incr was called twice'); + equal(results[4], 2, 'incr was throttled'); + equal(results[5], 3, 'incr was called trailing'); + start(); + }, 300); + }); + + asyncTest('throttle triggers trailing call when invoked repeatedly', 2, function() { + var counter = 0; + var limit = 48; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 32); + + var stamp = new Date; + while ((new Date - stamp) < limit) { + throttledIncr(); + } + var lastCount = counter; + ok(counter > 1); + + _.delay(function() { + ok(counter > lastCount); + start(); + }, 96); + }); + + asyncTest('throttle does not trigger leading call when leading is set to false', 2, function() { + var counter = 0; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 60, {leading: false}); + + throttledIncr(); throttledIncr(); + ok(counter === 0); + + _.delay(function() { + ok(counter == 1); + start(); + }, 96); + }); + + asyncTest('more throttle does not trigger leading call when leading is set to false', 3, function() { + var counter = 0; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 100, {leading: false}); + + throttledIncr(); + _.delay(throttledIncr, 50); + _.delay(throttledIncr, 60); + _.delay(throttledIncr, 200); + ok(counter === 0); + + _.delay(function() { + ok(counter == 1); + }, 250); + + _.delay(function() { + ok(counter == 2); + start(); + }, 350); + }); + + asyncTest('one more throttle with leading: false test', 2, function() { + var counter = 0; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 100, {leading: false}); + + var time = new Date; + while (new Date - time < 350) throttledIncr(); + ok(counter <= 3); + + _.delay(function() { + ok(counter <= 4); + start(); + }, 200); + }); + + asyncTest('throttle does not trigger trailing call when trailing is set to false', 4, function() { + var counter = 0; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 60, {trailing: false}); + + throttledIncr(); throttledIncr(); throttledIncr(); + ok(counter === 1); + + _.delay(function() { + ok(counter == 1); + + throttledIncr(); throttledIncr(); + ok(counter == 2); + + _.delay(function() { + ok(counter == 2); + start(); + }, 96); + }, 96); + }); + + asyncTest('throttle continues to function after system time is set backwards', 2, function() { + var counter = 0; + var incr = function(){ counter++; }; + var throttledIncr = _.throttle(incr, 100); + var origNowFunc = _.now; + + throttledIncr(); + ok(counter == 1); + _.now = function () { + return new Date(2013, 0, 1, 1, 1, 1); + }; + + _.delay(function() { + throttledIncr(); + ok(counter == 2); + start(); + _.now = origNowFunc; + }, 200); + }); + + asyncTest('throttle re-entrant', 2, function() { + var sequence = [ + ['b1', 'b2'], + ['c1', 'c2'] + ]; + var value = ''; + var throttledAppend; + var append = function(arg){ + value += this + arg; + var args = sequence.pop() + if (args) { + throttledAppend.call(args[0], args[1]); + } + }; + throttledAppend = _.throttle(append, 32); + throttledAppend.call('a1', 'a2'); + equal(value, 'a1a2'); + _.delay(function(){ + equal(value, 'a1a2c1c2b1b2', 'append was throttled successfully'); + start(); + }, 100); + }); + + asyncTest('debounce', 1, function() { + var counter = 0; + var incr = function(){ counter++; }; + var debouncedIncr = _.debounce(incr, 32); + debouncedIncr(); debouncedIncr(); + _.delay(debouncedIncr, 16); + _.delay(function(){ equal(counter, 1, 'incr was debounced'); start(); }, 96); + }); + + asyncTest('debounce asap', 4, function() { + var a, b; + var counter = 0; + var incr = function(){ return ++counter; }; + var debouncedIncr = _.debounce(incr, 64, true); + a = debouncedIncr(); + b = debouncedIncr(); + equal(a, 1); + equal(b, 1); + equal(counter, 1, 'incr was called immediately'); + _.delay(debouncedIncr, 16); + _.delay(debouncedIncr, 32); + _.delay(debouncedIncr, 48); + _.delay(function(){ equal(counter, 1, 'incr was debounced'); start(); }, 128); + }); + + asyncTest('debounce asap recursively', 2, function() { + var counter = 0; + var debouncedIncr = _.debounce(function(){ + counter++; + if (counter < 10) debouncedIncr(); + }, 32, true); + debouncedIncr(); + equal(counter, 1, 'incr was called immediately'); + _.delay(function(){ equal(counter, 1, 'incr was debounced'); start(); }, 96); + }); + + asyncTest('debounce after system time is set backwards', 2, function() { + var counter = 0; + var origNowFunc = _.now; + var debouncedIncr = _.debounce(function(){ + counter++; + }, 100, true); + + debouncedIncr(); + equal(counter, 1, 'incr was called immediately'); + + _.now = function () { + return new Date(2013, 0, 1, 1, 1, 1); + }; + + _.delay(function() { + debouncedIncr(); + equal(counter, 2, 'incr was debounced successfully'); + start(); + _.now = origNowFunc; + }, 200); + }); + + asyncTest('debounce re-entrant', 2, function() { + var sequence = [ + ['b1', 'b2'] + ]; + var value = ''; + var debouncedAppend; + var append = function(arg){ + value += this + arg; + var args = sequence.pop() + if (args) { + debouncedAppend.call(args[0], args[1]); + } + }; + debouncedAppend = _.debounce(append, 32); + debouncedAppend.call('a1', 'a2'); + equal(value, ''); + _.delay(function(){ + equal(value, 'a1a2b1b2', 'append was debounced successfully'); + start(); + }, 100); + }); + + test('once', function() { + var num = 0; + var increment = _.once(function(){ return ++num; }); + increment(); + increment(); + equal(num, 1); + + equal(increment(), 1, 'stores a memo to the last value'); + }); + + test('Recursive onced function.', 1, function() { + var f = _.once(function(){ + ok(true); + f(); + }); + f(); + }); + + test('wrap', function() { + var greet = function(name){ return 'hi: ' + name; }; + var backwards = _.wrap(greet, function(func, name){ return func(name) + ' ' + name.split('').reverse().join(''); }); + equal(backwards('moe'), 'hi: moe eom', 'wrapped the salutation function'); + + var inner = function(){ return 'Hello '; }; + var obj = {name : 'Moe'}; + obj.hi = _.wrap(inner, function(fn){ return fn() + this.name; }); + equal(obj.hi(), 'Hello Moe'); + + var noop = function(){}; + var wrapped = _.wrap(noop, function(fn){ return Array.prototype.slice.call(arguments, 0); }); + var ret = wrapped(['whats', 'your'], 'vector', 'victor'); + deepEqual(ret, [noop, ['whats', 'your'], 'vector', 'victor']); + }); + + test('negate', function() { + var isOdd = function(n){ return (n & 1) == 1; }; + equal(_.negate(isOdd)(2), true, 'should return the complement of the given function'); + equal(_.negate(isOdd)(3), false, 'should return the complement of the given function'); + }); + + test('compose', function() { + var greet = function(name){ return 'hi: ' + name; }; + var exclaim = function(sentence){ return sentence + '!'; }; + var composed = _.compose(exclaim, greet); + equal(composed('moe'), 'hi: moe!', 'can compose a function that takes another'); + + composed = _.compose(greet, exclaim); + equal(composed('moe'), 'hi: moe!', 'in this case, the functions are also commutative'); + + // f(g(h(x, y, z))) + function h(x, y, z) { + equal(arguments.length, 3, 'First function called with multiple args'); + return z * y; + }; + function g(x) { + equal(arguments.length, 1, 'Composed function is called with 1 argument'); + return x; + }; + function f(x) { + equal(arguments.length, 1, 'Composed function is called with 1 argument'); + return x * 2; + }; + composed = _.compose(f, g, h); + equal(composed(1, 2, 3), 12); + }); + + test('after', function() { + var testAfter = function(afterAmount, timesCalled) { + var afterCalled = 0; + var after = _.after(afterAmount, function() { + afterCalled++; + }); + while (timesCalled--) after(); + return afterCalled; + }; + + equal(testAfter(5, 5), 1, 'after(N) should fire after being called N times'); + equal(testAfter(5, 4), 0, 'after(N) should not fire unless called N times'); + equal(testAfter(0, 0), 0, 'after(0) should not fire immediately'); + equal(testAfter(0, 1), 1, 'after(0) should fire when first invoked'); + }); + + test('before', function() { + var testBefore = function(beforeAmount, timesCalled) { + var beforeCalled = 0; + var before = _.before(beforeAmount, function() { beforeCalled++; }); + while (timesCalled--) before(); + return beforeCalled; + }; + + equal(testBefore(5, 5), 4, 'before(N) should not fire after being called N times'); + equal(testBefore(5, 4), 4, 'before(N) should fire before being called N times'); + equal(testBefore(0, 0), 0, 'before(0) should not fire immediately'); + equal(testBefore(0, 1), 0, 'before(0) should not fire when first invoked'); + + var context = {num: 0}; + var increment = _.before(3, function(){ return ++this.num; }); + _.times(10, increment, context); + equal(increment(), 2, 'stores a memo to the last value'); + equal(context.num, 2, 'provides context'); + }); + +})(); diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/index.html b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/index.html new file mode 100644 index 000000000..f6e9352ef --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/index.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<html> +<head> + <title>Underscore Test Suite</title> + <link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen"> + <link rel="icon" href="../favicon.ico"> +</head> +<body> + <div id="qunit"></div> + <div id="qunit-fixture"> + <div id="map-test"> + <div id="id1"></div> + <div id="id2"></div> + </div> + </div> + <script src="vendor/qunit.js"></script> + <script src="../underscore.js"></script> + + <script src="collections.js"></script> + <script src="arrays.js"></script> + <script src="functions.js"></script> + <script src="objects.js"></script> + <script src="utility.js"></script> + <script src="chaining.js"></script> +</body> +</html> diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/objects.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/objects.js new file mode 100644 index 000000000..dc53db5e3 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/objects.js @@ -0,0 +1,665 @@ +(function() { + + module('Objects'); + + test('keys', function() { + deepEqual(_.keys({one : 1, two : 2}), ['one', 'two'], 'can extract the keys from an object'); + // the test above is not safe because it relies on for-in enumeration order + var a = []; a[1] = 0; + deepEqual(_.keys(a), ['1'], 'is not fooled by sparse arrays; see issue #95'); + deepEqual(_.keys(null), []); + deepEqual(_.keys(void 0), []); + deepEqual(_.keys(1), []); + deepEqual(_.keys('a'), []); + deepEqual(_.keys(true), []); + }); + + test('values', function() { + deepEqual(_.values({one: 1, two: 2}), [1, 2], 'can extract the values from an object'); + deepEqual(_.values({one: 1, two: 2, length: 3}), [1, 2, 3], '... even when one of them is "length"'); + }); + + test('pairs', function() { + deepEqual(_.pairs({one: 1, two: 2}), [['one', 1], ['two', 2]], 'can convert an object into pairs'); + deepEqual(_.pairs({one: 1, two: 2, length: 3}), [['one', 1], ['two', 2], ['length', 3]], '... even when one of them is "length"'); + }); + + test('invert', function() { + var obj = {first: 'Moe', second: 'Larry', third: 'Curly'}; + deepEqual(_.keys(_.invert(obj)), ['Moe', 'Larry', 'Curly'], 'can invert an object'); + deepEqual(_.invert(_.invert(obj)), obj, 'two inverts gets you back where you started'); + + var obj = {length: 3}; + ok(_.invert(obj)['3'] == 'length', 'can invert an object with "length"') + }); + + test('functions', function() { + var obj = {a : 'dash', b : _.map, c : (/yo/), d : _.reduce}; + deepEqual(['b', 'd'], _.functions(obj), 'can grab the function names of any passed-in object'); + + var Animal = function(){}; + Animal.prototype.run = function(){}; + deepEqual(_.functions(new Animal), ['run'], 'also looks up functions on the prototype'); + }); + + test('methods', function() { + strictEqual(_.functions, _.methods, 'alias for functions'); + }); + + test('extend', function() { + var result; + equal(_.extend({}, {a: 'b'}).a, 'b', 'can extend an object with the attributes of another'); + equal(_.extend({a: 'x'}, {a: 'b'}).a, 'b', 'properties in source override destination'); + equal(_.extend({x: 'x'}, {a: 'b'}).x, 'x', "properties not in source don't get overriden"); + result = _.extend({x: 'x'}, {a: 'a'}, {b: 'b'}); + deepEqual(result, {x: 'x', a: 'a', b: 'b'}, 'can extend from multiple source objects'); + result = _.extend({x: 'x'}, {a: 'a', x: 2}, {a: 'b'}); + deepEqual(result, {x: 2, a: 'b'}, 'extending from multiple source objects last property trumps'); + result = _.extend({}, {a: void 0, b: null}); + deepEqual(_.keys(result), ['a', 'b'], 'extend copies undefined values'); + + try { + result = {}; + _.extend(result, null, undefined, {a: 1}); + } catch(ex) {} + + equal(result.a, 1, 'should not error on `null` or `undefined` sources'); + + strictEqual(_.extend(null, {a: 1}), null, 'extending null results in null'); + strictEqual(_.extend(undefined, {a: 1}), undefined, 'extending undefined results in undefined'); + }); + + test('pick', function() { + var result; + result = _.pick({a: 1, b: 2, c: 3}, 'a', 'c'); + deepEqual(result, {a: 1, c: 3}, 'can restrict properties to those named'); + result = _.pick({a: 1, b: 2, c: 3}, ['b', 'c']); + deepEqual(result, {b: 2, c: 3}, 'can restrict properties to those named in an array'); + result = _.pick({a: 1, b: 2, c: 3}, ['a'], 'b'); + deepEqual(result, {a: 1, b: 2}, 'can restrict properties to those named in mixed args'); + result = _.pick(['a', 'b'], 1); + deepEqual(result, {1: 'b'}, 'can pick numeric properties'); + + deepEqual(_.pick(null, 'a', 'b'), {}, 'non objects return empty object'); + deepEqual(_.pick(undefined, 'toString'), {}, 'null/undefined return empty object'); + deepEqual(_.pick(5, 'toString', 'b'), {toString: Number.prototype.toString}, 'can iterate primitives'); + + var data = {a: 1, b: 2, c: 3}; + var callback = function(value, key, object) { + strictEqual(key, {1: 'a', 2: 'b', 3: 'c'}[value]); + strictEqual(object, data); + return value !== this.value; + }; + result = _.pick(data, callback, {value: 2}); + deepEqual(result, {a: 1, c: 3}, 'can accept a predicate and context'); + + var Obj = function(){}; + Obj.prototype = {a: 1, b: 2, c: 3}; + var instance = new Obj(); + deepEqual(_.pick(instance, 'a', 'c'), {a: 1, c: 3}, 'include prototype props'); + + deepEqual(_.pick(data, function(val, key) { + return this[key] === 3 && this === instance; + }, instance), {c: 3}, 'function is given context'); + }); + + test('omit', function() { + var result; + result = _.omit({a: 1, b: 2, c: 3}, 'b'); + deepEqual(result, {a: 1, c: 3}, 'can omit a single named property'); + result = _.omit({a: 1, b: 2, c: 3}, 'a', 'c'); + deepEqual(result, {b: 2}, 'can omit several named properties'); + result = _.omit({a: 1, b: 2, c: 3}, ['b', 'c']); + deepEqual(result, {a: 1}, 'can omit properties named in an array'); + result = _.omit(['a', 'b'], 0); + deepEqual(result, {1: 'b'}, 'can omit numeric properties'); + + deepEqual(_.omit(null, 'a', 'b'), {}, 'non objects return empty object'); + deepEqual(_.omit(undefined, 'toString'), {}, 'null/undefined return empty object'); + deepEqual(_.omit(5, 'toString', 'b'), {}, 'returns empty object for primitives'); + + var data = {a: 1, b: 2, c: 3}; + var callback = function(value, key, object) { + strictEqual(key, {1: 'a', 2: 'b', 3: 'c'}[value]); + strictEqual(object, data); + return value !== this.value; + }; + result = _.omit(data, callback, {value: 2}); + deepEqual(result, {b: 2}, 'can accept a predicate'); + + var Obj = function(){}; + Obj.prototype = {a: 1, b: 2, c: 3}; + var instance = new Obj(); + deepEqual(_.omit(instance, 'b'), {a: 1, c: 3}, 'include prototype props'); + + deepEqual(_.omit(data, function(val, key) { + return this[key] === 3 && this === instance; + }, instance), {a: 1, b: 2}, 'function is given context'); + }); + + test('defaults', function() { + var result; + var options = {zero: 0, one: 1, empty: '', nan: NaN, nothing: null}; + + _.defaults(options, {zero: 1, one: 10, twenty: 20, nothing: 'str'}); + equal(options.zero, 0, 'value exists'); + equal(options.one, 1, 'value exists'); + equal(options.twenty, 20, 'default applied'); + equal(options.nothing, null, "null isn't overridden"); + + _.defaults(options, {empty: 'full'}, {nan: 'nan'}, {word: 'word'}, {word: 'dog'}); + equal(options.empty, '', 'value exists'); + ok(_.isNaN(options.nan), "NaN isn't overridden"); + equal(options.word, 'word', 'new value is added, first one wins'); + + try { + options = {}; + _.defaults(options, null, undefined, {a: 1}); + } catch(ex) {} + + equal(options.a, 1, 'should not error on `null` or `undefined` sources'); + + strictEqual(_.defaults(null, {a: 1}), null, 'result is null if destination is null'); + strictEqual(_.defaults(undefined, {a: 1}), undefined, 'result is undefined if destination is undefined'); + }); + + test('clone', function() { + var moe = {name : 'moe', lucky : [13, 27, 34]}; + var clone = _.clone(moe); + equal(clone.name, 'moe', 'the clone as the attributes of the original'); + + clone.name = 'curly'; + ok(clone.name == 'curly' && moe.name == 'moe', 'clones can change shallow attributes without affecting the original'); + + clone.lucky.push(101); + equal(_.last(moe.lucky), 101, 'changes to deep attributes are shared with the original'); + + equal(_.clone(undefined), void 0, 'non objects should not be changed by clone'); + equal(_.clone(1), 1, 'non objects should not be changed by clone'); + equal(_.clone(null), null, 'non objects should not be changed by clone'); + }); + + test('isEqual', function() { + function First() { + this.value = 1; + } + First.prototype.value = 1; + function Second() { + this.value = 1; + } + Second.prototype.value = 2; + + // Basic equality and identity comparisons. + ok(_.isEqual(null, null), '`null` is equal to `null`'); + ok(_.isEqual(), '`undefined` is equal to `undefined`'); + + ok(!_.isEqual(0, -0), '`0` is not equal to `-0`'); + ok(!_.isEqual(-0, 0), 'Commutative equality is implemented for `0` and `-0`'); + ok(!_.isEqual(null, undefined), '`null` is not equal to `undefined`'); + ok(!_.isEqual(undefined, null), 'Commutative equality is implemented for `null` and `undefined`'); + + // String object and primitive comparisons. + ok(_.isEqual('Curly', 'Curly'), 'Identical string primitives are equal'); + ok(_.isEqual(new String('Curly'), new String('Curly')), 'String objects with identical primitive values are equal'); + ok(_.isEqual(new String('Curly'), 'Curly'), 'String primitives and their corresponding object wrappers are equal'); + ok(_.isEqual('Curly', new String('Curly')), 'Commutative equality is implemented for string objects and primitives'); + + ok(!_.isEqual('Curly', 'Larry'), 'String primitives with different values are not equal'); + ok(!_.isEqual(new String('Curly'), new String('Larry')), 'String objects with different primitive values are not equal'); + ok(!_.isEqual(new String('Curly'), {toString: function(){ return 'Curly'; }}), 'String objects and objects with a custom `toString` method are not equal'); + + // Number object and primitive comparisons. + ok(_.isEqual(75, 75), 'Identical number primitives are equal'); + ok(_.isEqual(new Number(75), new Number(75)), 'Number objects with identical primitive values are equal'); + ok(_.isEqual(75, new Number(75)), 'Number primitives and their corresponding object wrappers are equal'); + ok(_.isEqual(new Number(75), 75), 'Commutative equality is implemented for number objects and primitives'); + ok(!_.isEqual(new Number(0), -0), '`new Number(0)` and `-0` are not equal'); + ok(!_.isEqual(0, new Number(-0)), 'Commutative equality is implemented for `new Number(0)` and `-0`'); + + ok(!_.isEqual(new Number(75), new Number(63)), 'Number objects with different primitive values are not equal'); + ok(!_.isEqual(new Number(63), {valueOf: function(){ return 63; }}), 'Number objects and objects with a `valueOf` method are not equal'); + + // Comparisons involving `NaN`. + ok(_.isEqual(NaN, NaN), '`NaN` is equal to `NaN`'); + ok(_.isEqual(Object(NaN), NaN), 'Object(`NaN`) is equal to `NaN`'); + ok(!_.isEqual(61, NaN), 'A number primitive is not equal to `NaN`'); + ok(!_.isEqual(new Number(79), NaN), 'A number object is not equal to `NaN`'); + ok(!_.isEqual(Infinity, NaN), '`Infinity` is not equal to `NaN`'); + + // Boolean object and primitive comparisons. + ok(_.isEqual(true, true), 'Identical boolean primitives are equal'); + ok(_.isEqual(new Boolean, new Boolean), 'Boolean objects with identical primitive values are equal'); + ok(_.isEqual(true, new Boolean(true)), 'Boolean primitives and their corresponding object wrappers are equal'); + ok(_.isEqual(new Boolean(true), true), 'Commutative equality is implemented for booleans'); + ok(!_.isEqual(new Boolean(true), new Boolean), 'Boolean objects with different primitive values are not equal'); + + // Common type coercions. + ok(!_.isEqual(new Boolean(false), true), '`new Boolean(false)` is not equal to `true`'); + ok(!_.isEqual('75', 75), 'String and number primitives with like values are not equal'); + ok(!_.isEqual(new Number(63), new String(63)), 'String and number objects with like values are not equal'); + ok(!_.isEqual(75, '75'), 'Commutative equality is implemented for like string and number values'); + ok(!_.isEqual(0, ''), 'Number and string primitives with like values are not equal'); + ok(!_.isEqual(1, true), 'Number and boolean primitives with like values are not equal'); + ok(!_.isEqual(new Boolean(false), new Number(0)), 'Boolean and number objects with like values are not equal'); + ok(!_.isEqual(false, new String('')), 'Boolean primitives and string objects with like values are not equal'); + ok(!_.isEqual(12564504e5, new Date(2009, 9, 25)), 'Dates and their corresponding numeric primitive values are not equal'); + + // Dates. + ok(_.isEqual(new Date(2009, 9, 25), new Date(2009, 9, 25)), 'Date objects referencing identical times are equal'); + ok(!_.isEqual(new Date(2009, 9, 25), new Date(2009, 11, 13)), 'Date objects referencing different times are not equal'); + ok(!_.isEqual(new Date(2009, 11, 13), { + getTime: function(){ + return 12606876e5; + } + }), 'Date objects and objects with a `getTime` method are not equal'); + ok(!_.isEqual(new Date('Curly'), new Date('Curly')), 'Invalid dates are not equal'); + + // Functions. + ok(!_.isEqual(First, Second), 'Different functions with identical bodies and source code representations are not equal'); + + // RegExps. + ok(_.isEqual(/(?:)/gim, /(?:)/gim), 'RegExps with equivalent patterns and flags are equal'); + ok(_.isEqual(/(?:)/gi, /(?:)/ig), 'Flag order is not significant'); + ok(!_.isEqual(/(?:)/g, /(?:)/gi), 'RegExps with equivalent patterns and different flags are not equal'); + ok(!_.isEqual(/Moe/gim, /Curly/gim), 'RegExps with different patterns and equivalent flags are not equal'); + ok(!_.isEqual(/(?:)/gi, /(?:)/g), 'Commutative equality is implemented for RegExps'); + ok(!_.isEqual(/Curly/g, {source: 'Larry', global: true, ignoreCase: false, multiline: false}), 'RegExps and RegExp-like objects are not equal'); + + // Empty arrays, array-like objects, and object literals. + ok(_.isEqual({}, {}), 'Empty object literals are equal'); + ok(_.isEqual([], []), 'Empty array literals are equal'); + ok(_.isEqual([{}], [{}]), 'Empty nested arrays and objects are equal'); + ok(!_.isEqual({length: 0}, []), 'Array-like objects and arrays are not equal.'); + ok(!_.isEqual([], {length: 0}), 'Commutative equality is implemented for array-like objects'); + + ok(!_.isEqual({}, []), 'Object literals and array literals are not equal'); + ok(!_.isEqual([], {}), 'Commutative equality is implemented for objects and arrays'); + + // Arrays with primitive and object values. + ok(_.isEqual([1, 'Larry', true], [1, 'Larry', true]), 'Arrays containing identical primitives are equal'); + ok(_.isEqual([(/Moe/g), new Date(2009, 9, 25)], [(/Moe/g), new Date(2009, 9, 25)]), 'Arrays containing equivalent elements are equal'); + + // Multi-dimensional arrays. + var a = [new Number(47), false, 'Larry', /Moe/, new Date(2009, 11, 13), ['running', 'biking', new String('programming')], {a: 47}]; + var b = [new Number(47), false, 'Larry', /Moe/, new Date(2009, 11, 13), ['running', 'biking', new String('programming')], {a: 47}]; + ok(_.isEqual(a, b), 'Arrays containing nested arrays and objects are recursively compared'); + + // Overwrite the methods defined in ES 5.1 section 15.4.4. + a.forEach = a.map = a.filter = a.every = a.indexOf = a.lastIndexOf = a.some = a.reduce = a.reduceRight = null; + b.join = b.pop = b.reverse = b.shift = b.slice = b.splice = b.concat = b.sort = b.unshift = null; + + // Array elements and properties. + ok(_.isEqual(a, b), 'Arrays containing equivalent elements and different non-numeric properties are equal'); + a.push('White Rocks'); + ok(!_.isEqual(a, b), 'Arrays of different lengths are not equal'); + a.push('East Boulder'); + b.push('Gunbarrel Ranch', 'Teller Farm'); + ok(!_.isEqual(a, b), 'Arrays of identical lengths containing different elements are not equal'); + + // Sparse arrays. + ok(_.isEqual(Array(3), Array(3)), 'Sparse arrays of identical lengths are equal'); + ok(!_.isEqual(Array(3), Array(6)), 'Sparse arrays of different lengths are not equal when both are empty'); + + var sparse = []; + sparse[1] = 5; + ok(_.isEqual(sparse, [undefined, 5]), 'Handles sparse arrays as dense') + + // Simple objects. + ok(_.isEqual({a: 'Curly', b: 1, c: true}, {a: 'Curly', b: 1, c: true}), 'Objects containing identical primitives are equal'); + ok(_.isEqual({a: /Curly/g, b: new Date(2009, 11, 13)}, {a: /Curly/g, b: new Date(2009, 11, 13)}), 'Objects containing equivalent members are equal'); + ok(!_.isEqual({a: 63, b: 75}, {a: 61, b: 55}), 'Objects of identical sizes with different values are not equal'); + ok(!_.isEqual({a: 63, b: 75}, {a: 61, c: 55}), 'Objects of identical sizes with different property names are not equal'); + ok(!_.isEqual({a: 1, b: 2}, {a: 1}), 'Objects of different sizes are not equal'); + ok(!_.isEqual({a: 1}, {a: 1, b: 2}), 'Commutative equality is implemented for objects'); + ok(!_.isEqual({x: 1, y: undefined}, {x: 1, z: 2}), 'Objects with identical keys and different values are not equivalent'); + + // `A` contains nested objects and arrays. + a = { + name: new String('Moe Howard'), + age: new Number(77), + stooge: true, + hobbies: ['acting'], + film: { + name: 'Sing a Song of Six Pants', + release: new Date(1947, 9, 30), + stars: [new String('Larry Fine'), 'Shemp Howard'], + minutes: new Number(16), + seconds: 54 + } + }; + + // `B` contains equivalent nested objects and arrays. + b = { + name: new String('Moe Howard'), + age: new Number(77), + stooge: true, + hobbies: ['acting'], + film: { + name: 'Sing a Song of Six Pants', + release: new Date(1947, 9, 30), + stars: [new String('Larry Fine'), 'Shemp Howard'], + minutes: new Number(16), + seconds: 54 + } + }; + ok(_.isEqual(a, b), 'Objects with nested equivalent members are recursively compared'); + + // Instances. + ok(_.isEqual(new First, new First), 'Object instances are equal'); + ok(!_.isEqual(new First, new Second), 'Objects with different constructors and identical own properties are not equal'); + ok(!_.isEqual({value: 1}, new First), 'Object instances and objects sharing equivalent properties are not equal'); + ok(!_.isEqual({value: 2}, new Second), 'The prototype chain of objects should not be examined'); + + // Circular Arrays. + (a = []).push(a); + (b = []).push(b); + ok(_.isEqual(a, b), 'Arrays containing circular references are equal'); + a.push(new String('Larry')); + b.push(new String('Larry')); + ok(_.isEqual(a, b), 'Arrays containing circular references and equivalent properties are equal'); + a.push('Shemp'); + b.push('Curly'); + ok(!_.isEqual(a, b), 'Arrays containing circular references and different properties are not equal'); + + // More circular arrays #767. + a = ['everything is checked but', 'this', 'is not']; + a[1] = a; + b = ['everything is checked but', ['this', 'array'], 'is not']; + ok(!_.isEqual(a, b), 'Comparison of circular references with non-circular references are not equal'); + + // Circular Objects. + a = {abc: null}; + b = {abc: null}; + a.abc = a; + b.abc = b; + ok(_.isEqual(a, b), 'Objects containing circular references are equal'); + a.def = 75; + b.def = 75; + ok(_.isEqual(a, b), 'Objects containing circular references and equivalent properties are equal'); + a.def = new Number(75); + b.def = new Number(63); + ok(!_.isEqual(a, b), 'Objects containing circular references and different properties are not equal'); + + // More circular objects #767. + a = {everything: 'is checked', but: 'this', is: 'not'}; + a.but = a; + b = {everything: 'is checked', but: {that: 'object'}, is: 'not'}; + ok(!_.isEqual(a, b), 'Comparison of circular references with non-circular object references are not equal'); + + // Cyclic Structures. + a = [{abc: null}]; + b = [{abc: null}]; + (a[0].abc = a).push(a); + (b[0].abc = b).push(b); + ok(_.isEqual(a, b), 'Cyclic structures are equal'); + a[0].def = 'Larry'; + b[0].def = 'Larry'; + ok(_.isEqual(a, b), 'Cyclic structures containing equivalent properties are equal'); + a[0].def = new String('Larry'); + b[0].def = new String('Curly'); + ok(!_.isEqual(a, b), 'Cyclic structures containing different properties are not equal'); + + // Complex Circular References. + a = {foo: {b: {foo: {c: {foo: null}}}}}; + b = {foo: {b: {foo: {c: {foo: null}}}}}; + a.foo.b.foo.c.foo = a; + b.foo.b.foo.c.foo = b; + ok(_.isEqual(a, b), 'Cyclic structures with nested and identically-named properties are equal'); + + // Chaining. + ok(!_.isEqual(_({x: 1, y: undefined}).chain(), _({x: 1, z: 2}).chain()), 'Chained objects containing different values are not equal'); + + a = _({x: 1, y: 2}).chain(); + b = _({x: 1, y: 2}).chain(); + equal(_.isEqual(a.isEqual(b), _(true)), true, '`isEqual` can be chained'); + + // Objects from another frame. + ok(_.isEqual({}, iObject)); + + // Objects without a `constructor` property + if (Object.create) { + a = Object.create(null, {x: {value: 1, enumerable: true}}); + b = {x: 1}; + ok(_.isEqual(a, b), 'Handles objects without a constructor (e.g. from Object.create'); + } + + function Foo() { this.a = 1; } + Foo.prototype.constructor = null; + + var other = { 'a': 1 }; + strictEqual(_.isEqual(new Foo, other), false, 'Objects from different constructors are not equal'); + }); + + test('isEmpty', function() { + ok(!_([1]).isEmpty(), '[1] is not empty'); + ok(_.isEmpty([]), '[] is empty'); + ok(!_.isEmpty({one : 1}), '{one : 1} is not empty'); + ok(_.isEmpty({}), '{} is empty'); + ok(_.isEmpty(new RegExp('')), 'objects with prototype properties are empty'); + ok(_.isEmpty(null), 'null is empty'); + ok(_.isEmpty(), 'undefined is empty'); + ok(_.isEmpty(''), 'the empty string is empty'); + ok(!_.isEmpty('moe'), 'but other strings are not'); + + var obj = {one : 1}; + delete obj.one; + ok(_.isEmpty(obj), 'deleting all the keys from an object empties it'); + + var args = function(){ return arguments; }; + ok(_.isEmpty(args()), 'empty arguments object is empty'); + ok(!_.isEmpty(args('')), 'non-empty arguments object is not empty'); + }); + + // Setup remote variables for iFrame tests. + var iframe = document.createElement('iframe'); + iframe.frameBorder = iframe.height = iframe.width = 0 + document.body.appendChild(iframe); + var iDoc = (iDoc = iframe.contentDocument || iframe.contentWindow).document || iDoc; + iDoc.write( + '<script>\ + parent.iElement = document.createElement("div");\ + parent.iArguments = (function(){ return arguments; })(1, 2, 3);\ + parent.iArray = [1, 2, 3];\ + parent.iString = new String("hello");\ + parent.iNumber = new Number(100);\ + parent.iFunction = (function(){});\ + parent.iDate = new Date();\ + parent.iRegExp = /hi/;\ + parent.iNaN = NaN;\ + parent.iNull = null;\ + parent.iBoolean = new Boolean(false);\ + parent.iUndefined = undefined;\ + parent.iObject = {};\ + </script>' + ); + iDoc.close(); + + test('isElement', function() { + ok(!_.isElement('div'), 'strings are not dom elements'); + ok(_.isElement(document.body), 'the body tag is a DOM element'); + ok(_.isElement(iElement), 'even from another frame'); + }); + + test('isArguments', function() { + var args = (function(){ return arguments; })(1, 2, 3); + ok(!_.isArguments('string'), 'a string is not an arguments object'); + ok(!_.isArguments(_.isArguments), 'a function is not an arguments object'); + ok(_.isArguments(args), 'but the arguments object is an arguments object'); + ok(!_.isArguments(_.toArray(args)), 'but not when it\'s converted into an array'); + ok(!_.isArguments([1, 2, 3]), 'and not vanilla arrays.'); + ok(_.isArguments(iArguments), 'even from another frame'); + }); + + test('isObject', function() { + ok(_.isObject(arguments), 'the arguments object is object'); + ok(_.isObject([1, 2, 3]), 'and arrays'); + ok(_.isObject(document.body), 'and DOM element'); + ok(_.isObject(iElement), 'even from another frame'); + ok(_.isObject(function () {}), 'and functions'); + ok(_.isObject(iFunction), 'even from another frame'); + ok(!_.isObject(null), 'but not null'); + ok(!_.isObject(undefined), 'and not undefined'); + ok(!_.isObject('string'), 'and not string'); + ok(!_.isObject(12), 'and not number'); + ok(!_.isObject(true), 'and not boolean'); + ok(_.isObject(new String('string')), 'but new String()'); + }); + + test('isArray', function() { + ok(!_.isArray(undefined), 'undefined vars are not arrays'); + ok(!_.isArray(arguments), 'the arguments object is not an array'); + ok(_.isArray([1, 2, 3]), 'but arrays are'); + ok(_.isArray(iArray), 'even from another frame'); + }); + + test('isString', function() { + var obj = new String('I am a string object'); + ok(!_.isString(document.body), 'the document body is not a string'); + ok(_.isString([1, 2, 3].join(', ')), 'but strings are'); + ok(_.isString(iString), 'even from another frame'); + ok(_.isString('I am a string literal'), 'string literals are'); + ok(_.isString(obj), 'so are String objects'); + }); + + test('isNumber', function() { + ok(!_.isNumber('string'), 'a string is not a number'); + ok(!_.isNumber(arguments), 'the arguments object is not a number'); + ok(!_.isNumber(undefined), 'undefined is not a number'); + ok(_.isNumber(3 * 4 - 7 / 10), 'but numbers are'); + ok(_.isNumber(NaN), 'NaN *is* a number'); + ok(_.isNumber(Infinity), 'Infinity is a number'); + ok(_.isNumber(iNumber), 'even from another frame'); + ok(!_.isNumber('1'), 'numeric strings are not numbers'); + }); + + test('isBoolean', function() { + ok(!_.isBoolean(2), 'a number is not a boolean'); + ok(!_.isBoolean('string'), 'a string is not a boolean'); + ok(!_.isBoolean('false'), 'the string "false" is not a boolean'); + ok(!_.isBoolean('true'), 'the string "true" is not a boolean'); + ok(!_.isBoolean(arguments), 'the arguments object is not a boolean'); + ok(!_.isBoolean(undefined), 'undefined is not a boolean'); + ok(!_.isBoolean(NaN), 'NaN is not a boolean'); + ok(!_.isBoolean(null), 'null is not a boolean'); + ok(_.isBoolean(true), 'but true is'); + ok(_.isBoolean(false), 'and so is false'); + ok(_.isBoolean(iBoolean), 'even from another frame'); + }); + + test('isFunction', function() { + ok(!_.isFunction(undefined), 'undefined vars are not functions'); + ok(!_.isFunction([1, 2, 3]), 'arrays are not functions'); + ok(!_.isFunction('moe'), 'strings are not functions'); + ok(_.isFunction(_.isFunction), 'but functions are'); + ok(_.isFunction(iFunction), 'even from another frame'); + ok(_.isFunction(function(){}), 'even anonymous ones'); + }); + + test('isDate', function() { + ok(!_.isDate(100), 'numbers are not dates'); + ok(!_.isDate({}), 'objects are not dates'); + ok(_.isDate(new Date()), 'but dates are'); + ok(_.isDate(iDate), 'even from another frame'); + }); + + test('isRegExp', function() { + ok(!_.isRegExp(_.identity), 'functions are not RegExps'); + ok(_.isRegExp(/identity/), 'but RegExps are'); + ok(_.isRegExp(iRegExp), 'even from another frame'); + }); + + test('isFinite', function() { + ok(!_.isFinite(undefined), 'undefined is not finite'); + ok(!_.isFinite(null), 'null is not finite'); + ok(!_.isFinite(NaN), 'NaN is not finite'); + ok(!_.isFinite(Infinity), 'Infinity is not finite'); + ok(!_.isFinite(-Infinity), '-Infinity is not finite'); + ok(_.isFinite('12'), 'Numeric strings are numbers'); + ok(!_.isFinite('1a'), 'Non numeric strings are not numbers'); + ok(!_.isFinite(''), 'Empty strings are not numbers'); + var obj = new Number(5); + ok(_.isFinite(obj), 'Number instances can be finite'); + ok(_.isFinite(0), '0 is finite'); + ok(_.isFinite(123), 'Ints are finite'); + ok(_.isFinite(-12.44), 'Floats are finite'); + }); + + test('isNaN', function() { + ok(!_.isNaN(undefined), 'undefined is not NaN'); + ok(!_.isNaN(null), 'null is not NaN'); + ok(!_.isNaN(0), '0 is not NaN'); + ok(_.isNaN(NaN), 'but NaN is'); + ok(_.isNaN(iNaN), 'even from another frame'); + ok(_.isNaN(new Number(NaN)), 'wrapped NaN is still NaN'); + }); + + test('isNull', function() { + ok(!_.isNull(undefined), 'undefined is not null'); + ok(!_.isNull(NaN), 'NaN is not null'); + ok(_.isNull(null), 'but null is'); + ok(_.isNull(iNull), 'even from another frame'); + }); + + test('isUndefined', function() { + ok(!_.isUndefined(1), 'numbers are defined'); + ok(!_.isUndefined(null), 'null is defined'); + ok(!_.isUndefined(false), 'false is defined'); + ok(!_.isUndefined(NaN), 'NaN is defined'); + ok(_.isUndefined(), 'nothing is undefined'); + ok(_.isUndefined(undefined), 'undefined is undefined'); + ok(_.isUndefined(iUndefined), 'even from another frame'); + }); + + if (window.ActiveXObject) { + test('IE host objects', function() { + var xml = new ActiveXObject('Msxml2.DOMDocument.3.0'); + ok(!_.isNumber(xml)); + ok(!_.isBoolean(xml)); + ok(!_.isNaN(xml)); + ok(!_.isFunction(xml)); + ok(!_.isNull(xml)); + ok(!_.isUndefined(xml)); + }); + } + + test('tap', function() { + var intercepted = null; + var interceptor = function(obj) { intercepted = obj; }; + var returned = _.tap(1, interceptor); + equal(intercepted, 1, 'passes tapped object to interceptor'); + equal(returned, 1, 'returns tapped object'); + + returned = _([1, 2, 3]).chain(). + map(function(n){ return n * 2; }). + max(). + tap(interceptor). + value(); + ok(returned == 6 && intercepted == 6, 'can use tapped objects in a chain'); + }); + + test("has", function () { + var obj = {foo: "bar", func: function () {} }; + ok(_.has(obj, "foo"), "has() checks that the object has a property."); + ok(_.has(obj, "baz") == false, "has() returns false if the object doesn't have the property."); + ok(_.has(obj, "func"), "has() works for functions too."); + obj.hasOwnProperty = null; + ok(_.has(obj, "foo"), "has() works even when the hasOwnProperty method is deleted."); + var child = {}; + child.prototype = obj; + ok(_.has(child, "foo") == false, "has() does not check the prototype chain for a property."); + strictEqual(_.has(null, 'foo'), false, 'has() returns false for null'); + strictEqual(_.has(undefined, 'foo'), false, 'has() returns false for undefined'); + }); + + test("matches", function() { + var moe = {name: 'Moe Howard', hair: true}; + var curly = {name: 'Curly Howard', hair: false}; + var stooges = [moe, curly]; + ok(_.find(stooges, _.matches({hair: false})) === curly, "returns a predicate that can be used by finding functions."); + ok(_.find(stooges, _.matches(moe)) === moe, "can be used to locate an object exists in a collection."); + deepEqual(_.where([null, undefined], {a: 1}), [], 'Do not throw on null values.'); + deepEqual(_.where([null, undefined], null), [null, undefined], 'null matches null'); + deepEqual(_.where([null, undefined], {}), [null, undefined], 'null matches {}'); + }); + +})(); diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/utility.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/utility.js new file mode 100644 index 000000000..37c90076d --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/utility.js @@ -0,0 +1,294 @@ +(function() { + + var templateSettings; + + module('Utility', { + + setup: function() { + templateSettings = _.clone(_.templateSettings); + }, + + teardown: function() { + _.templateSettings = templateSettings; + } + + }); + + test('#750 - Return _ instance.', 2, function() { + var instance = _([]); + ok(_(instance) === instance); + ok(new _(instance) === instance); + }); + + test('identity', function() { + var moe = {name : 'moe'}; + equal(_.identity(moe), moe, 'moe is the same as his identity'); + }); + + test('constant', function() { + var moe = {name : 'moe'}; + equal(_.constant(moe)(), moe, 'should create a function that returns moe'); + }); + + test('noop', function() { + strictEqual(_.noop('curly', 'larry', 'moe'), undefined, 'should always return undefined'); + }); + + test('property', function() { + var moe = {name : 'moe'}; + equal(_.property('name')(moe), 'moe', 'should return the property with the given name'); + }); + + test('random', function() { + var array = _.range(1000); + var min = Math.pow(2, 31); + var max = Math.pow(2, 62); + + ok(_.every(array, function() { + return _.random(min, max) >= min; + }), 'should produce a random number greater than or equal to the minimum number'); + + ok(_.some(array, function() { + return _.random(Number.MAX_VALUE) > 0; + }), 'should produce a random number when passed `Number.MAX_VALUE`'); + }); + + test('now', function() { + var diff = _.now() - new Date().getTime(); + ok(diff <= 0 && diff > -5, 'Produces the correct time in milliseconds');//within 5ms + }); + + test('uniqueId', function() { + var ids = [], i = 0; + while(i++ < 100) ids.push(_.uniqueId()); + equal(_.uniq(ids).length, ids.length, 'can generate a globally-unique stream of ids'); + }); + + test('times', function() { + var vals = []; + _.times(3, function (i) { vals.push(i); }); + deepEqual(vals, [0, 1, 2], 'is 0 indexed'); + // + vals = []; + _(3).times(function(i) { vals.push(i); }); + deepEqual(vals, [0, 1, 2], 'works as a wrapper'); + // collects return values + deepEqual([0, 1, 2], _.times(3, function(i) { return i; }), 'collects return values'); + + deepEqual(_.times(0, _.identity), []); + deepEqual(_.times(-1, _.identity), []); + deepEqual(_.times(parseFloat('-Infinity'), _.identity), []); + }); + + test('mixin', function() { + _.mixin({ + myReverse: function(string) { + return string.split('').reverse().join(''); + } + }); + equal(_.myReverse('panacea'), 'aecanap', 'mixed in a function to _'); + equal(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OOP wrapper'); + }); + + test('_.escape', function() { + equal(_.escape('Curly & Moe'), 'Curly & Moe'); + equal(_.escape('<a href="http://moe.com">Curly & Moe\'s</a>'), '<a href="http://moe.com">Curly & Moe's</a>'); + equal(_.escape('Curly & Moe'), 'Curly &amp; Moe'); + equal(_.escape(null), ''); + }); + + test('_.unescape', function() { + var string = 'Curly & Moe'; + equal(_.unescape('Curly & Moe'), string); + equal(_.unescape('<a href="http://moe.com">Curly & Moe's</a>'), '<a href="http://moe.com">Curly & Moe\'s</a>'); + equal(_.unescape('Curly &amp; Moe'), 'Curly & Moe'); + equal(_.unescape(null), ''); + equal(_.unescape(_.escape(string)), string); + }); + + test('template', function() { + var basicTemplate = _.template("<%= thing %> is gettin' on my noives!"); + var result = basicTemplate({thing : 'This'}); + equal(result, "This is gettin' on my noives!", 'can do basic attribute interpolation'); + + var sansSemicolonTemplate = _.template('A <% this %> B'); + equal(sansSemicolonTemplate(), 'A B'); + + var backslashTemplate = _.template('<%= thing %> is \\ridanculous'); + equal(backslashTemplate({thing: 'This'}), 'This is \\ridanculous'); + + var escapeTemplate = _.template('<%= a ? "checked=\\"checked\\"" : "" %>'); + equal(escapeTemplate({a: true}), 'checked="checked"', 'can handle slash escapes in interpolations.'); + + var fancyTemplate = _.template('<ul><% \ + for (var key in people) { \ + %><li><%= people[key] %></li><% } %></ul>'); + result = fancyTemplate({people : {moe : 'Moe', larry : 'Larry', curly : 'Curly'}}); + equal(result, '<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', 'can run arbitrary javascript in templates'); + + var escapedCharsInJavascriptTemplate = _.template('<ul><% _.each(numbers.split("\\n"), function(item) { %><li><%= item %></li><% }) %></ul>'); + result = escapedCharsInJavascriptTemplate({numbers: 'one\ntwo\nthree\nfour'}); + equal(result, '<ul><li>one</li><li>two</li><li>three</li><li>four</li></ul>', 'Can use escaped characters (e.g. \\n) in JavaScript'); + + var namespaceCollisionTemplate = _.template('<%= pageCount %> <%= thumbnails[pageCount] %> <% _.each(thumbnails, function(p) { %><div class="thumbnail" rel="<%= p %>"></div><% }); %>'); + result = namespaceCollisionTemplate({ + pageCount: 3, + thumbnails: { + 1: 'p1-thumbnail.gif', + 2: 'p2-thumbnail.gif', + 3: 'p3-thumbnail.gif' + } + }); + equal(result, '3 p3-thumbnail.gif <div class="thumbnail" rel="p1-thumbnail.gif"></div><div class="thumbnail" rel="p2-thumbnail.gif"></div><div class="thumbnail" rel="p3-thumbnail.gif"></div>'); + + var noInterpolateTemplate = _.template('<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>'); + result = noInterpolateTemplate(); + equal(result, '<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>'); + + var quoteTemplate = _.template("It's its, not it's"); + equal(quoteTemplate({}), "It's its, not it's"); + + var quoteInStatementAndBody = _.template("<%\ + if(foo == 'bar'){ \ + %>Statement quotes and 'quotes'.<% } %>"); + equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'."); + + var withNewlinesAndTabs = _.template('This\n\t\tis: <%= x %>.\n\tok.\nend.'); + equal(withNewlinesAndTabs({x: 'that'}), 'This\n\t\tis: that.\n\tok.\nend.'); + + var template = _.template('<i><%- value %></i>'); + var result = template({value: '<script>'}); + equal(result, '<i><script></i>'); + + var stooge = { + name: 'Moe', + template: _.template("I'm <%= this.name %>") + }; + equal(stooge.template(), "I'm Moe"); + + template = _.template('\n \ + <%\n \ + // a comment\n \ + if (data) { data += 12345; }; %>\n \ + <li><%= data %></li>\n \ + '); + equal(template({data : 12345}).replace(/\s/g, ''), '<li>24690</li>'); + + _.templateSettings = { + evaluate : /\{\{([\s\S]+?)\}\}/g, + interpolate : /\{\{=([\s\S]+?)\}\}/g + }; + + var custom = _.template('<ul>{{ for (var key in people) { }}<li>{{= people[key] }}</li>{{ } }}</ul>'); + result = custom({people : {moe : 'Moe', larry : 'Larry', curly : 'Curly'}}); + equal(result, '<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', 'can run arbitrary javascript in templates'); + + var customQuote = _.template("It's its, not it's"); + equal(customQuote({}), "It's its, not it's"); + + var quoteInStatementAndBody = _.template("{{ if(foo == 'bar'){ }}Statement quotes and 'quotes'.{{ } }}"); + equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'."); + + _.templateSettings = { + evaluate : /<\?([\s\S]+?)\?>/g, + interpolate : /<\?=([\s\S]+?)\?>/g + }; + + var customWithSpecialChars = _.template('<ul><? for (var key in people) { ?><li><?= people[key] ?></li><? } ?></ul>'); + result = customWithSpecialChars({people : {moe : 'Moe', larry : 'Larry', curly : 'Curly'}}); + equal(result, '<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', 'can run arbitrary javascript in templates'); + + var customWithSpecialCharsQuote = _.template("It's its, not it's"); + equal(customWithSpecialCharsQuote({}), "It's its, not it's"); + + var quoteInStatementAndBody = _.template("<? if(foo == 'bar'){ ?>Statement quotes and 'quotes'.<? } ?>"); + equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'."); + + _.templateSettings = { + interpolate : /\{\{(.+?)\}\}/g + }; + + var mustache = _.template('Hello {{planet}}!'); + equal(mustache({planet : 'World'}), 'Hello World!', 'can mimic mustache.js'); + + var templateWithNull = _.template('a null undefined {{planet}}'); + equal(templateWithNull({planet : 'world'}), 'a null undefined world', 'can handle missing escape and evaluate settings'); + }); + + test('_.template provides the generated function source, when a SyntaxError occurs', function() { + try { + _.template('<b><%= if x %></b>'); + } catch (ex) { + var source = ex.source; + } + ok(/__p/.test(source)); + }); + + test('_.template handles \\u2028 & \\u2029', function() { + var tmpl = _.template('<p>\u2028<%= "\\u2028\\u2029" %>\u2029</p>'); + strictEqual(tmpl(), '<p>\u2028\u2028\u2029\u2029</p>'); + }); + + test('result calls functions and returns primitives', function() { + var obj = {w: '', x: 'x', y: function(){ return this.x; }}; + strictEqual(_.result(obj, 'w'), ''); + strictEqual(_.result(obj, 'x'), 'x'); + strictEqual(_.result(obj, 'y'), 'x'); + strictEqual(_.result(obj, 'z'), undefined); + strictEqual(_.result(null, 'x'), undefined); + }); + + test('_.templateSettings.variable', function() { + var s = '<%=data.x%>'; + var data = {x: 'x'}; + strictEqual(_.template(s, data, {variable: 'data'}), 'x'); + _.templateSettings.variable = 'data'; + strictEqual(_.template(s)(data), 'x'); + }); + + test('#547 - _.templateSettings is unchanged by custom settings.', function() { + ok(!_.templateSettings.variable); + _.template('', {}, {variable: 'x'}); + ok(!_.templateSettings.variable); + }); + + test('#556 - undefined template variables.', function() { + var template = _.template('<%=x%>'); + strictEqual(template({x: null}), ''); + strictEqual(template({x: undefined}), ''); + + var templateEscaped = _.template('<%-x%>'); + strictEqual(templateEscaped({x: null}), ''); + strictEqual(templateEscaped({x: undefined}), ''); + + var templateWithProperty = _.template('<%=x.foo%>'); + strictEqual(templateWithProperty({x: {} }), ''); + strictEqual(templateWithProperty({x: {} }), ''); + + var templateWithPropertyEscaped = _.template('<%-x.foo%>'); + strictEqual(templateWithPropertyEscaped({x: {} }), ''); + strictEqual(templateWithPropertyEscaped({x: {} }), ''); + }); + + test('interpolate evaluates code only once.', 2, function() { + var count = 0; + var template = _.template('<%= f() %>'); + template({f: function(){ ok(!(count++)); }}); + + var countEscaped = 0; + var templateEscaped = _.template('<%- f() %>'); + templateEscaped({f: function(){ ok(!(countEscaped++)); }}); + }); + + test('#746 - _.template settings are not modified.', 1, function() { + var settings = {}; + _.template('', null, settings); + deepEqual(settings, {}); + }); + + test('#779 - delimeters are applied to unescaped text.', 1, function() { + var template = _.template('<<\nx\n>>', null, {evaluate: /<<(.*?)>>/g}); + strictEqual(template(), '<<\nx\n>>'); + }); + +})(); diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.css b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.css new file mode 100644 index 000000000..7ba3f9a30 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.css @@ -0,0 +1,244 @@ +/** + * QUnit v1.12.0 - A JavaScript Unit Testing Framework + * + * http://qunitjs.com + * + * Copyright 2012 jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +/** Font Family and Sizes */ + +#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { + font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif; +} + +#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } +#qunit-tests { font-size: smaller; } + + +/** Resets */ + +#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter { + margin: 0; + padding: 0; +} + + +/** Header */ + +#qunit-header { + padding: 0.5em 0 0.5em 1em; + + color: #8699a4; + background-color: #0d3349; + + font-size: 1.5em; + line-height: 1em; + font-weight: normal; + + border-radius: 5px 5px 0 0; + -moz-border-radius: 5px 5px 0 0; + -webkit-border-top-right-radius: 5px; + -webkit-border-top-left-radius: 5px; +} + +#qunit-header a { + text-decoration: none; + color: #c2ccd1; +} + +#qunit-header a:hover, +#qunit-header a:focus { + color: #fff; +} + +#qunit-testrunner-toolbar label { + display: inline-block; + padding: 0 .5em 0 .1em; +} + +#qunit-banner { + height: 5px; +} + +#qunit-testrunner-toolbar { + padding: 0.5em 0 0.5em 2em; + color: #5E740B; + background-color: #eee; + overflow: hidden; +} + +#qunit-userAgent { + padding: 0.5em 0 0.5em 2.5em; + background-color: #2b81af; + color: #fff; + text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; +} + +#qunit-modulefilter-container { + float: right; +} + +/** Tests: Pass/Fail */ + +#qunit-tests { + list-style-position: inside; +} + +#qunit-tests li { + padding: 0.4em 0.5em 0.4em 2.5em; + border-bottom: 1px solid #fff; + list-style-position: inside; +} + +#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running { + display: none; +} + +#qunit-tests li strong { + cursor: pointer; +} + +#qunit-tests li a { + padding: 0.5em; + color: #c2ccd1; + text-decoration: none; +} +#qunit-tests li a:hover, +#qunit-tests li a:focus { + color: #000; +} + +#qunit-tests li .runtime { + float: right; + font-size: smaller; +} + +.qunit-assert-list { + margin-top: 0.5em; + padding: 0.5em; + + background-color: #fff; + + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; +} + +.qunit-collapsed { + display: none; +} + +#qunit-tests table { + border-collapse: collapse; + margin-top: .2em; +} + +#qunit-tests th { + text-align: right; + vertical-align: top; + padding: 0 .5em 0 0; +} + +#qunit-tests td { + vertical-align: top; +} + +#qunit-tests pre { + margin: 0; + white-space: pre-wrap; + word-wrap: break-word; +} + +#qunit-tests del { + background-color: #e0f2be; + color: #374e0c; + text-decoration: none; +} + +#qunit-tests ins { + background-color: #ffcaca; + color: #500; + text-decoration: none; +} + +/*** Test Counts */ + +#qunit-tests b.counts { color: black; } +#qunit-tests b.passed { color: #5E740B; } +#qunit-tests b.failed { color: #710909; } + +#qunit-tests li li { + padding: 5px; + background-color: #fff; + border-bottom: none; + list-style-position: inside; +} + +/*** Passing Styles */ + +#qunit-tests li li.pass { + color: #3c510c; + background-color: #fff; + border-left: 10px solid #C6E746; +} + +#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } +#qunit-tests .pass .test-name { color: #366097; } + +#qunit-tests .pass .test-actual, +#qunit-tests .pass .test-expected { color: #999999; } + +#qunit-banner.qunit-pass { background-color: #C6E746; } + +/*** Failing Styles */ + +#qunit-tests li li.fail { + color: #710909; + background-color: #fff; + border-left: 10px solid #EE5757; + white-space: pre; +} + +#qunit-tests > li:last-child { + border-radius: 0 0 5px 5px; + -moz-border-radius: 0 0 5px 5px; + -webkit-border-bottom-right-radius: 5px; + -webkit-border-bottom-left-radius: 5px; +} + +#qunit-tests .fail { color: #000000; background-color: #EE5757; } +#qunit-tests .fail .test-name, +#qunit-tests .fail .module-name { color: #000000; } + +#qunit-tests .fail .test-actual { color: #EE5757; } +#qunit-tests .fail .test-expected { color: green; } + +#qunit-banner.qunit-fail { background-color: #EE5757; } + + +/** Result */ + +#qunit-testresult { + padding: 0.5em 0.5em 0.5em 2.5em; + + color: #2b81af; + background-color: #D2E0E6; + + border-bottom: 1px solid white; +} +#qunit-testresult .module-name { + font-weight: bold; +} + +/** Fixture */ + +#qunit-fixture { + position: absolute; + top: -10000px; + left: -10000px; + width: 1000px; + height: 1000px; +} diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.js new file mode 100644 index 000000000..84c73907d --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.js @@ -0,0 +1,2212 @@ +/** + * QUnit v1.12.0 - A JavaScript Unit Testing Framework + * + * http://qunitjs.com + * + * Copyright 2013 jQuery Foundation and other contributors + * Released under the MIT license. + * https://jquery.org/license/ + */ + +(function( window ) { + +var QUnit, + assert, + config, + onErrorFnPrev, + testId = 0, + fileName = (sourceFromStacktrace( 0 ) || "" ).replace(/(:\d+)+\)?/, "").replace(/.+\//, ""), + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + // Keep a local reference to Date (GH-283) + Date = window.Date, + setTimeout = window.setTimeout, + defined = { + setTimeout: typeof window.setTimeout !== "undefined", + sessionStorage: (function() { + var x = "qunit-test-string"; + try { + sessionStorage.setItem( x, x ); + sessionStorage.removeItem( x ); + return true; + } catch( e ) { + return false; + } + }()) + }, + /** + * Provides a normalized error string, correcting an issue + * with IE 7 (and prior) where Error.prototype.toString is + * not properly implemented + * + * Based on http://es5.github.com/#x15.11.4.4 + * + * @param {String|Error} error + * @return {String} error message + */ + errorString = function( error ) { + var name, message, + errorString = error.toString(); + if ( errorString.substring( 0, 7 ) === "[object" ) { + name = error.name ? error.name.toString() : "Error"; + message = error.message ? error.message.toString() : ""; + if ( name && message ) { + return name + ": " + message; + } else if ( name ) { + return name; + } else if ( message ) { + return message; + } else { + return "Error"; + } + } else { + return errorString; + } + }, + /** + * Makes a clone of an object using only Array or Object as base, + * and copies over the own enumerable properties. + * + * @param {Object} obj + * @return {Object} New object with only the own properties (recursively). + */ + objectValues = function( obj ) { + // Grunt 0.3.x uses an older version of jshint that still has jshint/jshint#392. + /*jshint newcap: false */ + var key, val, + vals = QUnit.is( "array", obj ) ? [] : {}; + for ( key in obj ) { + if ( hasOwn.call( obj, key ) ) { + val = obj[key]; + vals[key] = val === Object(val) ? objectValues(val) : val; + } + } + return vals; + }; + +function Test( settings ) { + extend( this, settings ); + this.assertions = []; + this.testNumber = ++Test.count; +} + +Test.count = 0; + +Test.prototype = { + init: function() { + var a, b, li, + tests = id( "qunit-tests" ); + + if ( tests ) { + b = document.createElement( "strong" ); + b.innerHTML = this.nameHtml; + + // `a` initialized at top of scope + a = document.createElement( "a" ); + a.innerHTML = "Rerun"; + a.href = QUnit.url({ testNumber: this.testNumber }); + + li = document.createElement( "li" ); + li.appendChild( b ); + li.appendChild( a ); + li.className = "running"; + li.id = this.id = "qunit-test-output" + testId++; + + tests.appendChild( li ); + } + }, + setup: function() { + if ( + // Emit moduleStart when we're switching from one module to another + this.module !== config.previousModule || + // They could be equal (both undefined) but if the previousModule property doesn't + // yet exist it means this is the first test in a suite that isn't wrapped in a + // module, in which case we'll just emit a moduleStart event for 'undefined'. + // Without this, reporters can get testStart before moduleStart which is a problem. + !hasOwn.call( config, "previousModule" ) + ) { + if ( hasOwn.call( config, "previousModule" ) ) { + runLoggingCallbacks( "moduleDone", QUnit, { + name: config.previousModule, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all + }); + } + config.previousModule = this.module; + config.moduleStats = { all: 0, bad: 0 }; + runLoggingCallbacks( "moduleStart", QUnit, { + name: this.module + }); + } + + config.current = this; + + this.testEnvironment = extend({ + setup: function() {}, + teardown: function() {} + }, this.moduleTestEnvironment ); + + this.started = +new Date(); + runLoggingCallbacks( "testStart", QUnit, { + name: this.testName, + module: this.module + }); + + /*jshint camelcase:false */ + + + /** + * Expose the current test environment. + * + * @deprecated since 1.12.0: Use QUnit.config.current.testEnvironment instead. + */ + QUnit.current_testEnvironment = this.testEnvironment; + + /*jshint camelcase:true */ + + if ( !config.pollution ) { + saveGlobal(); + } + if ( config.notrycatch ) { + this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); + return; + } + try { + this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert ); + } catch( e ) { + QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); + } + }, + run: function() { + config.current = this; + + var running = id( "qunit-testresult" ); + + if ( running ) { + running.innerHTML = "Running: <br/>" + this.nameHtml; + } + + if ( this.async ) { + QUnit.stop(); + } + + this.callbackStarted = +new Date(); + + if ( config.notrycatch ) { + this.callback.call( this.testEnvironment, QUnit.assert ); + this.callbackRuntime = +new Date() - this.callbackStarted; + return; + } + + try { + this.callback.call( this.testEnvironment, QUnit.assert ); + this.callbackRuntime = +new Date() - this.callbackStarted; + } catch( e ) { + this.callbackRuntime = +new Date() - this.callbackStarted; + + QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) ); + // else next test will carry the responsibility + saveGlobal(); + + // Restart the tests if they're blocking + if ( config.blocking ) { + QUnit.start(); + } + } + }, + teardown: function() { + config.current = this; + if ( config.notrycatch ) { + if ( typeof this.callbackRuntime === "undefined" ) { + this.callbackRuntime = +new Date() - this.callbackStarted; + } + this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); + return; + } else { + try { + this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert ); + } catch( e ) { + QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) ); + } + } + checkPollution(); + }, + finish: function() { + config.current = this; + if ( config.requireExpects && this.expected === null ) { + QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack ); + } else if ( this.expected !== null && this.expected !== this.assertions.length ) { + QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack ); + } else if ( this.expected === null && !this.assertions.length ) { + QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack ); + } + + var i, assertion, a, b, time, li, ol, + test = this, + good = 0, + bad = 0, + tests = id( "qunit-tests" ); + + this.runtime = +new Date() - this.started; + config.stats.all += this.assertions.length; + config.moduleStats.all += this.assertions.length; + + if ( tests ) { + ol = document.createElement( "ol" ); + ol.className = "qunit-assert-list"; + + for ( i = 0; i < this.assertions.length; i++ ) { + assertion = this.assertions[i]; + + li = document.createElement( "li" ); + li.className = assertion.result ? "pass" : "fail"; + li.innerHTML = assertion.message || ( assertion.result ? "okay" : "failed" ); + ol.appendChild( li ); + + if ( assertion.result ) { + good++; + } else { + bad++; + config.stats.bad++; + config.moduleStats.bad++; + } + } + + // store result when possible + if ( QUnit.config.reorder && defined.sessionStorage ) { + if ( bad ) { + sessionStorage.setItem( "qunit-test-" + this.module + "-" + this.testName, bad ); + } else { + sessionStorage.removeItem( "qunit-test-" + this.module + "-" + this.testName ); + } + } + + if ( bad === 0 ) { + addClass( ol, "qunit-collapsed" ); + } + + // `b` initialized at top of scope + b = document.createElement( "strong" ); + b.innerHTML = this.nameHtml + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>"; + + addEvent(b, "click", function() { + var next = b.parentNode.lastChild, + collapsed = hasClass( next, "qunit-collapsed" ); + ( collapsed ? removeClass : addClass )( next, "qunit-collapsed" ); + }); + + addEvent(b, "dblclick", function( e ) { + var target = e && e.target ? e.target : window.event.srcElement; + if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) { + target = target.parentNode; + } + if ( window.location && target.nodeName.toLowerCase() === "strong" ) { + window.location = QUnit.url({ testNumber: test.testNumber }); + } + }); + + // `time` initialized at top of scope + time = document.createElement( "span" ); + time.className = "runtime"; + time.innerHTML = this.runtime + " ms"; + + // `li` initialized at top of scope + li = id( this.id ); + li.className = bad ? "fail" : "pass"; + li.removeChild( li.firstChild ); + a = li.firstChild; + li.appendChild( b ); + li.appendChild( a ); + li.appendChild( time ); + li.appendChild( ol ); + + } else { + for ( i = 0; i < this.assertions.length; i++ ) { + if ( !this.assertions[i].result ) { + bad++; + config.stats.bad++; + config.moduleStats.bad++; + } + } + } + + runLoggingCallbacks( "testDone", QUnit, { + name: this.testName, + module: this.module, + failed: bad, + passed: this.assertions.length - bad, + total: this.assertions.length, + duration: this.runtime + }); + + QUnit.reset(); + + config.current = undefined; + }, + + queue: function() { + var bad, + test = this; + + synchronize(function() { + test.init(); + }); + function run() { + // each of these can by async + synchronize(function() { + test.setup(); + }); + synchronize(function() { + test.run(); + }); + synchronize(function() { + test.teardown(); + }); + synchronize(function() { + test.finish(); + }); + } + + // `bad` initialized at top of scope + // defer when previous test run passed, if storage is available + bad = QUnit.config.reorder && defined.sessionStorage && + +sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName ); + + if ( bad ) { + run(); + } else { + synchronize( run, true ); + } + } +}; + +// Root QUnit object. +// `QUnit` initialized at top of scope +QUnit = { + + // call on start of module test to prepend name to all tests + module: function( name, testEnvironment ) { + config.currentModule = name; + config.currentModuleTestEnvironment = testEnvironment; + config.modules[name] = true; + }, + + asyncTest: function( testName, expected, callback ) { + if ( arguments.length === 2 ) { + callback = expected; + expected = null; + } + + QUnit.test( testName, expected, callback, true ); + }, + + test: function( testName, expected, callback, async ) { + var test, + nameHtml = "<span class='test-name'>" + escapeText( testName ) + "</span>"; + + if ( arguments.length === 2 ) { + callback = expected; + expected = null; + } + + if ( config.currentModule ) { + nameHtml = "<span class='module-name'>" + escapeText( config.currentModule ) + "</span>: " + nameHtml; + } + + test = new Test({ + nameHtml: nameHtml, + testName: testName, + expected: expected, + async: async, + callback: callback, + module: config.currentModule, + moduleTestEnvironment: config.currentModuleTestEnvironment, + stack: sourceFromStacktrace( 2 ) + }); + + if ( !validTest( test ) ) { + return; + } + + test.queue(); + }, + + // Specify the number of expected assertions to guarantee that failed test (no assertions are run at all) don't slip through. + expect: function( asserts ) { + if (arguments.length === 1) { + config.current.expected = asserts; + } else { + return config.current.expected; + } + }, + + start: function( count ) { + // QUnit hasn't been initialized yet. + // Note: RequireJS (et al) may delay onLoad + if ( config.semaphore === undefined ) { + QUnit.begin(function() { + // This is triggered at the top of QUnit.load, push start() to the event loop, to allow QUnit.load to finish first + setTimeout(function() { + QUnit.start( count ); + }); + }); + return; + } + + config.semaphore -= count || 1; + // don't start until equal number of stop-calls + if ( config.semaphore > 0 ) { + return; + } + // ignore if start is called more often then stop + if ( config.semaphore < 0 ) { + config.semaphore = 0; + QUnit.pushFailure( "Called start() while already started (QUnit.config.semaphore was 0 already)", null, sourceFromStacktrace(2) ); + return; + } + // A slight delay, to avoid any current callbacks + if ( defined.setTimeout ) { + setTimeout(function() { + if ( config.semaphore > 0 ) { + return; + } + if ( config.timeout ) { + clearTimeout( config.timeout ); + } + + config.blocking = false; + process( true ); + }, 13); + } else { + config.blocking = false; + process( true ); + } + }, + + stop: function( count ) { + config.semaphore += count || 1; + config.blocking = true; + + if ( config.testTimeout && defined.setTimeout ) { + clearTimeout( config.timeout ); + config.timeout = setTimeout(function() { + QUnit.ok( false, "Test timed out" ); + config.semaphore = 1; + QUnit.start(); + }, config.testTimeout ); + } + } +}; + +// `assert` initialized at top of scope +// Assert helpers +// All of these must either call QUnit.push() or manually do: +// - runLoggingCallbacks( "log", .. ); +// - config.current.assertions.push({ .. }); +// We attach it to the QUnit object *after* we expose the public API, +// otherwise `assert` will become a global variable in browsers (#341). +assert = { + /** + * Asserts rough true-ish result. + * @name ok + * @function + * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); + */ + ok: function( result, msg ) { + if ( !config.current ) { + throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) ); + } + result = !!result; + msg = msg || (result ? "okay" : "failed" ); + + var source, + details = { + module: config.current.module, + name: config.current.testName, + result: result, + message: msg + }; + + msg = "<span class='test-message'>" + escapeText( msg ) + "</span>"; + + if ( !result ) { + source = sourceFromStacktrace( 2 ); + if ( source ) { + details.source = source; + msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr></table>"; + } + } + runLoggingCallbacks( "log", QUnit, details ); + config.current.assertions.push({ + result: result, + message: msg + }); + }, + + /** + * Assert that the first two arguments are equal, with an optional message. + * Prints out both actual and expected values. + * @name equal + * @function + * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" ); + */ + equal: function( actual, expected, message ) { + /*jshint eqeqeq:false */ + QUnit.push( expected == actual, actual, expected, message ); + }, + + /** + * @name notEqual + * @function + */ + notEqual: function( actual, expected, message ) { + /*jshint eqeqeq:false */ + QUnit.push( expected != actual, actual, expected, message ); + }, + + /** + * @name propEqual + * @function + */ + propEqual: function( actual, expected, message ) { + actual = objectValues(actual); + expected = objectValues(expected); + QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); + }, + + /** + * @name notPropEqual + * @function + */ + notPropEqual: function( actual, expected, message ) { + actual = objectValues(actual); + expected = objectValues(expected); + QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message ); + }, + + /** + * @name deepEqual + * @function + */ + deepEqual: function( actual, expected, message ) { + QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); + }, + + /** + * @name notDeepEqual + * @function + */ + notDeepEqual: function( actual, expected, message ) { + QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message ); + }, + + /** + * @name strictEqual + * @function + */ + strictEqual: function( actual, expected, message ) { + QUnit.push( expected === actual, actual, expected, message ); + }, + + /** + * @name notStrictEqual + * @function + */ + notStrictEqual: function( actual, expected, message ) { + QUnit.push( expected !== actual, actual, expected, message ); + }, + + "throws": function( block, expected, message ) { + var actual, + expectedOutput = expected, + ok = false; + + // 'expected' is optional + if ( typeof expected === "string" ) { + message = expected; + expected = null; + } + + config.current.ignoreGlobalErrors = true; + try { + block.call( config.current.testEnvironment ); + } catch (e) { + actual = e; + } + config.current.ignoreGlobalErrors = false; + + if ( actual ) { + // we don't want to validate thrown error + if ( !expected ) { + ok = true; + expectedOutput = null; + // expected is a regexp + } else if ( QUnit.objectType( expected ) === "regexp" ) { + ok = expected.test( errorString( actual ) ); + // expected is a constructor + } else if ( actual instanceof expected ) { + ok = true; + // expected is a validation function which returns true is validation passed + } else if ( expected.call( {}, actual ) === true ) { + expectedOutput = null; + ok = true; + } + + QUnit.push( ok, actual, expectedOutput, message ); + } else { + QUnit.pushFailure( message, null, "No exception was thrown." ); + } + } +}; + +/** + * @deprecated since 1.8.0 + * Kept assertion helpers in root for backwards compatibility. + */ +extend( QUnit, assert ); + +/** + * @deprecated since 1.9.0 + * Kept root "raises()" for backwards compatibility. + * (Note that we don't introduce assert.raises). + */ +QUnit.raises = assert[ "throws" ]; + +/** + * @deprecated since 1.0.0, replaced with error pushes since 1.3.0 + * Kept to avoid TypeErrors for undefined methods. + */ +QUnit.equals = function() { + QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" ); +}; +QUnit.same = function() { + QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" ); +}; + +// We want access to the constructor's prototype +(function() { + function F() {} + F.prototype = QUnit; + QUnit = new F(); + // Make F QUnit's constructor so that we can add to the prototype later + QUnit.constructor = F; +}()); + +/** + * Config object: Maintain internal state + * Later exposed as QUnit.config + * `config` initialized at top of scope + */ +config = { + // The queue of tests to run + queue: [], + + // block until document ready + blocking: true, + + // when enabled, show only failing tests + // gets persisted through sessionStorage and can be changed in UI via checkbox + hidepassed: false, + + // by default, run previously failed tests first + // very useful in combination with "Hide passed tests" checked + reorder: true, + + // by default, modify document.title when suite is done + altertitle: true, + + // when enabled, all tests must call expect() + requireExpects: false, + + // add checkboxes that are persisted in the query-string + // when enabled, the id is set to `true` as a `QUnit.config` property + urlConfig: [ + { + id: "noglobals", + label: "Check for Globals", + tooltip: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings." + }, + { + id: "notrycatch", + label: "No try-catch", + tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings." + } + ], + + // Set of all modules. + modules: {}, + + // logging callback queues + begin: [], + done: [], + log: [], + testStart: [], + testDone: [], + moduleStart: [], + moduleDone: [] +}; + +// Export global variables, unless an 'exports' object exists, +// in that case we assume we're in CommonJS (dealt with on the bottom of the script) +if ( typeof exports === "undefined" ) { + extend( window, QUnit.constructor.prototype ); + + // Expose QUnit object + window.QUnit = QUnit; +} + +// Initialize more QUnit.config and QUnit.urlParams +(function() { + var i, + location = window.location || { search: "", protocol: "file:" }, + params = location.search.slice( 1 ).split( "&" ), + length = params.length, + urlParams = {}, + current; + + if ( params[ 0 ] ) { + for ( i = 0; i < length; i++ ) { + current = params[ i ].split( "=" ); + current[ 0 ] = decodeURIComponent( current[ 0 ] ); + // allow just a key to turn on a flag, e.g., test.html?noglobals + current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true; + urlParams[ current[ 0 ] ] = current[ 1 ]; + } + } + + QUnit.urlParams = urlParams; + + // String search anywhere in moduleName+testName + config.filter = urlParams.filter; + + // Exact match of the module name + config.module = urlParams.module; + + config.testNumber = parseInt( urlParams.testNumber, 10 ) || null; + + // Figure out if we're running the tests from a server or not + QUnit.isLocal = location.protocol === "file:"; +}()); + +// Extend QUnit object, +// these after set here because they should not be exposed as global functions +extend( QUnit, { + assert: assert, + + config: config, + + // Initialize the configuration options + init: function() { + extend( config, { + stats: { all: 0, bad: 0 }, + moduleStats: { all: 0, bad: 0 }, + started: +new Date(), + updateRate: 1000, + blocking: false, + autostart: true, + autorun: false, + filter: "", + queue: [], + semaphore: 1 + }); + + var tests, banner, result, + qunit = id( "qunit" ); + + if ( qunit ) { + qunit.innerHTML = + "<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" + + "<h2 id='qunit-banner'></h2>" + + "<div id='qunit-testrunner-toolbar'></div>" + + "<h2 id='qunit-userAgent'></h2>" + + "<ol id='qunit-tests'></ol>"; + } + + tests = id( "qunit-tests" ); + banner = id( "qunit-banner" ); + result = id( "qunit-testresult" ); + + if ( tests ) { + tests.innerHTML = ""; + } + + if ( banner ) { + banner.className = ""; + } + + if ( result ) { + result.parentNode.removeChild( result ); + } + + if ( tests ) { + result = document.createElement( "p" ); + result.id = "qunit-testresult"; + result.className = "result"; + tests.parentNode.insertBefore( result, tests ); + result.innerHTML = "Running...<br/> "; + } + }, + + // Resets the test setup. Useful for tests that modify the DOM. + /* + DEPRECATED: Use multiple tests instead of resetting inside a test. + Use testStart or testDone for custom cleanup. + This method will throw an error in 2.0, and will be removed in 2.1 + */ + reset: function() { + var fixture = id( "qunit-fixture" ); + if ( fixture ) { + fixture.innerHTML = config.fixture; + } + }, + + // Trigger an event on an element. + // @example triggerEvent( document.body, "click" ); + triggerEvent: function( elem, type, event ) { + if ( document.createEvent ) { + event = document.createEvent( "MouseEvents" ); + event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, + 0, 0, 0, 0, 0, false, false, false, false, 0, null); + + elem.dispatchEvent( event ); + } else if ( elem.fireEvent ) { + elem.fireEvent( "on" + type ); + } + }, + + // Safe object type checking + is: function( type, obj ) { + return QUnit.objectType( obj ) === type; + }, + + objectType: function( obj ) { + if ( typeof obj === "undefined" ) { + return "undefined"; + // consider: typeof null === object + } + if ( obj === null ) { + return "null"; + } + + var match = toString.call( obj ).match(/^\[object\s(.*)\]$/), + type = match && match[1] || ""; + + switch ( type ) { + case "Number": + if ( isNaN(obj) ) { + return "nan"; + } + return "number"; + case "String": + case "Boolean": + case "Array": + case "Date": + case "RegExp": + case "Function": + return type.toLowerCase(); + } + if ( typeof obj === "object" ) { + return "object"; + } + return undefined; + }, + + push: function( result, actual, expected, message ) { + if ( !config.current ) { + throw new Error( "assertion outside test context, was " + sourceFromStacktrace() ); + } + + var output, source, + details = { + module: config.current.module, + name: config.current.testName, + result: result, + message: message, + actual: actual, + expected: expected + }; + + message = escapeText( message ) || ( result ? "okay" : "failed" ); + message = "<span class='test-message'>" + message + "</span>"; + output = message; + + if ( !result ) { + expected = escapeText( QUnit.jsDump.parse(expected) ); + actual = escapeText( QUnit.jsDump.parse(actual) ); + output += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + expected + "</pre></td></tr>"; + + if ( actual !== expected ) { + output += "<tr class='test-actual'><th>Result: </th><td><pre>" + actual + "</pre></td></tr>"; + output += "<tr class='test-diff'><th>Diff: </th><td><pre>" + QUnit.diff( expected, actual ) + "</pre></td></tr>"; + } + + source = sourceFromStacktrace(); + + if ( source ) { + details.source = source; + output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr>"; + } + + output += "</table>"; + } + + runLoggingCallbacks( "log", QUnit, details ); + + config.current.assertions.push({ + result: !!result, + message: output + }); + }, + + pushFailure: function( message, source, actual ) { + if ( !config.current ) { + throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace(2) ); + } + + var output, + details = { + module: config.current.module, + name: config.current.testName, + result: false, + message: message + }; + + message = escapeText( message ) || "error"; + message = "<span class='test-message'>" + message + "</span>"; + output = message; + + output += "<table>"; + + if ( actual ) { + output += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeText( actual ) + "</pre></td></tr>"; + } + + if ( source ) { + details.source = source; + output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr>"; + } + + output += "</table>"; + + runLoggingCallbacks( "log", QUnit, details ); + + config.current.assertions.push({ + result: false, + message: output + }); + }, + + url: function( params ) { + params = extend( extend( {}, QUnit.urlParams ), params ); + var key, + querystring = "?"; + + for ( key in params ) { + if ( hasOwn.call( params, key ) ) { + querystring += encodeURIComponent( key ) + "=" + + encodeURIComponent( params[ key ] ) + "&"; + } + } + return window.location.protocol + "//" + window.location.host + + window.location.pathname + querystring.slice( 0, -1 ); + }, + + extend: extend, + id: id, + addEvent: addEvent, + addClass: addClass, + hasClass: hasClass, + removeClass: removeClass + // load, equiv, jsDump, diff: Attached later +}); + +/** + * @deprecated: Created for backwards compatibility with test runner that set the hook function + * into QUnit.{hook}, instead of invoking it and passing the hook function. + * QUnit.constructor is set to the empty F() above so that we can add to it's prototype here. + * Doing this allows us to tell if the following methods have been overwritten on the actual + * QUnit object. + */ +extend( QUnit.constructor.prototype, { + + // Logging callbacks; all receive a single argument with the listed properties + // run test/logs.html for any related changes + begin: registerLoggingCallback( "begin" ), + + // done: { failed, passed, total, runtime } + done: registerLoggingCallback( "done" ), + + // log: { result, actual, expected, message } + log: registerLoggingCallback( "log" ), + + // testStart: { name } + testStart: registerLoggingCallback( "testStart" ), + + // testDone: { name, failed, passed, total, duration } + testDone: registerLoggingCallback( "testDone" ), + + // moduleStart: { name } + moduleStart: registerLoggingCallback( "moduleStart" ), + + // moduleDone: { name, failed, passed, total } + moduleDone: registerLoggingCallback( "moduleDone" ) +}); + +if ( typeof document === "undefined" || document.readyState === "complete" ) { + config.autorun = true; +} + +QUnit.load = function() { + runLoggingCallbacks( "begin", QUnit, {} ); + + // Initialize the config, saving the execution queue + var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, + urlConfigCheckboxesContainer, urlConfigCheckboxes, moduleFilter, + numModules = 0, + moduleNames = [], + moduleFilterHtml = "", + urlConfigHtml = "", + oldconfig = extend( {}, config ); + + QUnit.init(); + extend(config, oldconfig); + + config.blocking = false; + + len = config.urlConfig.length; + + for ( i = 0; i < len; i++ ) { + val = config.urlConfig[i]; + if ( typeof val === "string" ) { + val = { + id: val, + label: val, + tooltip: "[no tooltip available]" + }; + } + config[ val.id ] = QUnit.urlParams[ val.id ]; + urlConfigHtml += "<input id='qunit-urlconfig-" + escapeText( val.id ) + + "' name='" + escapeText( val.id ) + + "' type='checkbox'" + ( config[ val.id ] ? " checked='checked'" : "" ) + + " title='" + escapeText( val.tooltip ) + + "'><label for='qunit-urlconfig-" + escapeText( val.id ) + + "' title='" + escapeText( val.tooltip ) + "'>" + val.label + "</label>"; + } + for ( i in config.modules ) { + if ( config.modules.hasOwnProperty( i ) ) { + moduleNames.push(i); + } + } + numModules = moduleNames.length; + moduleNames.sort( function( a, b ) { + return a.localeCompare( b ); + }); + moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " + + ( config.module === undefined ? "selected='selected'" : "" ) + + ">< All Modules ></option>"; + + + for ( i = 0; i < numModules; i++) { + moduleFilterHtml += "<option value='" + escapeText( encodeURIComponent(moduleNames[i]) ) + "' " + + ( config.module === moduleNames[i] ? "selected='selected'" : "" ) + + ">" + escapeText(moduleNames[i]) + "</option>"; + } + moduleFilterHtml += "</select>"; + + // `userAgent` initialized at top of scope + userAgent = id( "qunit-userAgent" ); + if ( userAgent ) { + userAgent.innerHTML = navigator.userAgent; + } + + // `banner` initialized at top of scope + banner = id( "qunit-header" ); + if ( banner ) { + banner.innerHTML = "<a href='" + QUnit.url({ filter: undefined, module: undefined, testNumber: undefined }) + "'>" + banner.innerHTML + "</a> "; + } + + // `toolbar` initialized at top of scope + toolbar = id( "qunit-testrunner-toolbar" ); + if ( toolbar ) { + // `filter` initialized at top of scope + filter = document.createElement( "input" ); + filter.type = "checkbox"; + filter.id = "qunit-filter-pass"; + + addEvent( filter, "click", function() { + var tmp, + ol = document.getElementById( "qunit-tests" ); + + if ( filter.checked ) { + ol.className = ol.className + " hidepass"; + } else { + tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " "; + ol.className = tmp.replace( / hidepass /, " " ); + } + if ( defined.sessionStorage ) { + if (filter.checked) { + sessionStorage.setItem( "qunit-filter-passed-tests", "true" ); + } else { + sessionStorage.removeItem( "qunit-filter-passed-tests" ); + } + } + }); + + if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem( "qunit-filter-passed-tests" ) ) { + filter.checked = true; + // `ol` initialized at top of scope + ol = document.getElementById( "qunit-tests" ); + ol.className = ol.className + " hidepass"; + } + toolbar.appendChild( filter ); + + // `label` initialized at top of scope + label = document.createElement( "label" ); + label.setAttribute( "for", "qunit-filter-pass" ); + label.setAttribute( "title", "Only show tests and assertions that fail. Stored in sessionStorage." ); + label.innerHTML = "Hide passed tests"; + toolbar.appendChild( label ); + + urlConfigCheckboxesContainer = document.createElement("span"); + urlConfigCheckboxesContainer.innerHTML = urlConfigHtml; + urlConfigCheckboxes = urlConfigCheckboxesContainer.getElementsByTagName("input"); + // For oldIE support: + // * Add handlers to the individual elements instead of the container + // * Use "click" instead of "change" + // * Fallback from event.target to event.srcElement + addEvents( urlConfigCheckboxes, "click", function( event ) { + var params = {}, + target = event.target || event.srcElement; + params[ target.name ] = target.checked ? true : undefined; + window.location = QUnit.url( params ); + }); + toolbar.appendChild( urlConfigCheckboxesContainer ); + + if (numModules > 1) { + moduleFilter = document.createElement( "span" ); + moduleFilter.setAttribute( "id", "qunit-modulefilter-container" ); + moduleFilter.innerHTML = moduleFilterHtml; + addEvent( moduleFilter.lastChild, "change", function() { + var selectBox = moduleFilter.getElementsByTagName("select")[0], + selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value); + + window.location = QUnit.url({ + module: ( selectedModule === "" ) ? undefined : selectedModule, + // Remove any existing filters + filter: undefined, + testNumber: undefined + }); + }); + toolbar.appendChild(moduleFilter); + } + } + + // `main` initialized at top of scope + main = id( "qunit-fixture" ); + if ( main ) { + config.fixture = main.innerHTML; + } + + if ( config.autostart ) { + QUnit.start(); + } +}; + +addEvent( window, "load", QUnit.load ); + +// `onErrorFnPrev` initialized at top of scope +// Preserve other handlers +onErrorFnPrev = window.onerror; + +// Cover uncaught exceptions +// Returning true will suppress the default browser handler, +// returning false will let it run. +window.onerror = function ( error, filePath, linerNr ) { + var ret = false; + if ( onErrorFnPrev ) { + ret = onErrorFnPrev( error, filePath, linerNr ); + } + + // Treat return value as window.onerror itself does, + // Only do our handling if not suppressed. + if ( ret !== true ) { + if ( QUnit.config.current ) { + if ( QUnit.config.current.ignoreGlobalErrors ) { + return true; + } + QUnit.pushFailure( error, filePath + ":" + linerNr ); + } else { + QUnit.test( "global failure", extend( function() { + QUnit.pushFailure( error, filePath + ":" + linerNr ); + }, { validTest: validTest } ) ); + } + return false; + } + + return ret; +}; + +function done() { + config.autorun = true; + + // Log the last module results + if ( config.currentModule ) { + runLoggingCallbacks( "moduleDone", QUnit, { + name: config.currentModule, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all + }); + } + delete config.previousModule; + + var i, key, + banner = id( "qunit-banner" ), + tests = id( "qunit-tests" ), + runtime = +new Date() - config.started, + passed = config.stats.all - config.stats.bad, + html = [ + "Tests completed in ", + runtime, + " milliseconds.<br/>", + "<span class='passed'>", + passed, + "</span> assertions of <span class='total'>", + config.stats.all, + "</span> passed, <span class='failed'>", + config.stats.bad, + "</span> failed." + ].join( "" ); + + if ( banner ) { + banner.className = ( config.stats.bad ? "qunit-fail" : "qunit-pass" ); + } + + if ( tests ) { + id( "qunit-testresult" ).innerHTML = html; + } + + if ( config.altertitle && typeof document !== "undefined" && document.title ) { + // show ✖ for good, ✔ for bad suite result in title + // use escape sequences in case file gets loaded with non-utf-8-charset + document.title = [ + ( config.stats.bad ? "\u2716" : "\u2714" ), + document.title.replace( /^[\u2714\u2716] /i, "" ) + ].join( " " ); + } + + // clear own sessionStorage items if all tests passed + if ( config.reorder && defined.sessionStorage && config.stats.bad === 0 ) { + // `key` & `i` initialized at top of scope + for ( i = 0; i < sessionStorage.length; i++ ) { + key = sessionStorage.key( i++ ); + if ( key.indexOf( "qunit-test-" ) === 0 ) { + sessionStorage.removeItem( key ); + } + } + } + + // scroll back to top to show results + if ( window.scrollTo ) { + window.scrollTo(0, 0); + } + + runLoggingCallbacks( "done", QUnit, { + failed: config.stats.bad, + passed: passed, + total: config.stats.all, + runtime: runtime + }); +} + +/** @return Boolean: true if this test should be ran */ +function validTest( test ) { + var include, + filter = config.filter && config.filter.toLowerCase(), + module = config.module && config.module.toLowerCase(), + fullName = (test.module + ": " + test.testName).toLowerCase(); + + // Internally-generated tests are always valid + if ( test.callback && test.callback.validTest === validTest ) { + delete test.callback.validTest; + return true; + } + + if ( config.testNumber ) { + return test.testNumber === config.testNumber; + } + + if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) { + return false; + } + + if ( !filter ) { + return true; + } + + include = filter.charAt( 0 ) !== "!"; + if ( !include ) { + filter = filter.slice( 1 ); + } + + // If the filter matches, we need to honour include + if ( fullName.indexOf( filter ) !== -1 ) { + return include; + } + + // Otherwise, do the opposite + return !include; +} + +// so far supports only Firefox, Chrome and Opera (buggy), Safari (for real exceptions) +// Later Safari and IE10 are supposed to support error.stack as well +// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack +function extractStacktrace( e, offset ) { + offset = offset === undefined ? 3 : offset; + + var stack, include, i; + + if ( e.stacktrace ) { + // Opera + return e.stacktrace.split( "\n" )[ offset + 3 ]; + } else if ( e.stack ) { + // Firefox, Chrome + stack = e.stack.split( "\n" ); + if (/^error$/i.test( stack[0] ) ) { + stack.shift(); + } + if ( fileName ) { + include = []; + for ( i = offset; i < stack.length; i++ ) { + if ( stack[ i ].indexOf( fileName ) !== -1 ) { + break; + } + include.push( stack[ i ] ); + } + if ( include.length ) { + return include.join( "\n" ); + } + } + return stack[ offset ]; + } else if ( e.sourceURL ) { + // Safari, PhantomJS + // hopefully one day Safari provides actual stacktraces + // exclude useless self-reference for generated Error objects + if ( /qunit.js$/.test( e.sourceURL ) ) { + return; + } + // for actual exceptions, this is useful + return e.sourceURL + ":" + e.line; + } +} +function sourceFromStacktrace( offset ) { + try { + throw new Error(); + } catch ( e ) { + return extractStacktrace( e, offset ); + } +} + +/** + * Escape text for attribute or text content. + */ +function escapeText( s ) { + if ( !s ) { + return ""; + } + s = s + ""; + // Both single quotes and double quotes (for attributes) + return s.replace( /['"<>&]/g, function( s ) { + switch( s ) { + case "'": + return "'"; + case "\"": + return """; + case "<": + return "<"; + case ">": + return ">"; + case "&": + return "&"; + } + }); +} + +function synchronize( callback, last ) { + config.queue.push( callback ); + + if ( config.autorun && !config.blocking ) { + process( last ); + } +} + +function process( last ) { + function next() { + process( last ); + } + var start = new Date().getTime(); + config.depth = config.depth ? config.depth + 1 : 1; + + while ( config.queue.length && !config.blocking ) { + if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) { + config.queue.shift()(); + } else { + setTimeout( next, 13 ); + break; + } + } + config.depth--; + if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) { + done(); + } +} + +function saveGlobal() { + config.pollution = []; + + if ( config.noglobals ) { + for ( var key in window ) { + if ( hasOwn.call( window, key ) ) { + // in Opera sometimes DOM element ids show up here, ignore them + if ( /^qunit-test-output/.test( key ) ) { + continue; + } + config.pollution.push( key ); + } + } + } +} + +function checkPollution() { + var newGlobals, + deletedGlobals, + old = config.pollution; + + saveGlobal(); + + newGlobals = diff( config.pollution, old ); + if ( newGlobals.length > 0 ) { + QUnit.pushFailure( "Introduced global variable(s): " + newGlobals.join(", ") ); + } + + deletedGlobals = diff( old, config.pollution ); + if ( deletedGlobals.length > 0 ) { + QUnit.pushFailure( "Deleted global variable(s): " + deletedGlobals.join(", ") ); + } +} + +// returns a new Array with the elements that are in a but not in b +function diff( a, b ) { + var i, j, + result = a.slice(); + + for ( i = 0; i < result.length; i++ ) { + for ( j = 0; j < b.length; j++ ) { + if ( result[i] === b[j] ) { + result.splice( i, 1 ); + i--; + break; + } + } + } + return result; +} + +function extend( a, b ) { + for ( var prop in b ) { + if ( hasOwn.call( b, prop ) ) { + // Avoid "Member not found" error in IE8 caused by messing with window.constructor + if ( !( prop === "constructor" && a === window ) ) { + if ( b[ prop ] === undefined ) { + delete a[ prop ]; + } else { + a[ prop ] = b[ prop ]; + } + } + } + } + + return a; +} + +/** + * @param {HTMLElement} elem + * @param {string} type + * @param {Function} fn + */ +function addEvent( elem, type, fn ) { + // Standards-based browsers + if ( elem.addEventListener ) { + elem.addEventListener( type, fn, false ); + // IE + } else { + elem.attachEvent( "on" + type, fn ); + } +} + +/** + * @param {Array|NodeList} elems + * @param {string} type + * @param {Function} fn + */ +function addEvents( elems, type, fn ) { + var i = elems.length; + while ( i-- ) { + addEvent( elems[i], type, fn ); + } +} + +function hasClass( elem, name ) { + return (" " + elem.className + " ").indexOf(" " + name + " ") > -1; +} + +function addClass( elem, name ) { + if ( !hasClass( elem, name ) ) { + elem.className += (elem.className ? " " : "") + name; + } +} + +function removeClass( elem, name ) { + var set = " " + elem.className + " "; + // Class name may appear multiple times + while ( set.indexOf(" " + name + " ") > -1 ) { + set = set.replace(" " + name + " " , " "); + } + // If possible, trim it for prettiness, but not necessarily + elem.className = typeof set.trim === "function" ? set.trim() : set.replace(/^\s+|\s+$/g, ""); +} + +function id( name ) { + return !!( typeof document !== "undefined" && document && document.getElementById ) && + document.getElementById( name ); +} + +function registerLoggingCallback( key ) { + return function( callback ) { + config[key].push( callback ); + }; +} + +// Supports deprecated method of completely overwriting logging callbacks +function runLoggingCallbacks( key, scope, args ) { + var i, callbacks; + if ( QUnit.hasOwnProperty( key ) ) { + QUnit[ key ].call(scope, args ); + } else { + callbacks = config[ key ]; + for ( i = 0; i < callbacks.length; i++ ) { + callbacks[ i ].call( scope, args ); + } + } +} + +// Test for equality any JavaScript type. +// Author: Philippe Rathé <prathe@gmail.com> +QUnit.equiv = (function() { + + // Call the o related callback with the given arguments. + function bindCallbacks( o, callbacks, args ) { + var prop = QUnit.objectType( o ); + if ( prop ) { + if ( QUnit.objectType( callbacks[ prop ] ) === "function" ) { + return callbacks[ prop ].apply( callbacks, args ); + } else { + return callbacks[ prop ]; // or undefined + } + } + } + + // the real equiv function + var innerEquiv, + // stack to decide between skip/abort functions + callers = [], + // stack to avoiding loops from circular referencing + parents = [], + parentsB = [], + + getProto = Object.getPrototypeOf || function ( obj ) { + /*jshint camelcase:false */ + return obj.__proto__; + }, + callbacks = (function () { + + // for string, boolean, number and null + function useStrictEquality( b, a ) { + /*jshint eqeqeq:false */ + if ( b instanceof a.constructor || a instanceof b.constructor ) { + // to catch short annotation VS 'new' annotation of a + // declaration + // e.g. var i = 1; + // var j = new Number(1); + return a == b; + } else { + return a === b; + } + } + + return { + "string": useStrictEquality, + "boolean": useStrictEquality, + "number": useStrictEquality, + "null": useStrictEquality, + "undefined": useStrictEquality, + + "nan": function( b ) { + return isNaN( b ); + }, + + "date": function( b, a ) { + return QUnit.objectType( b ) === "date" && a.valueOf() === b.valueOf(); + }, + + "regexp": function( b, a ) { + return QUnit.objectType( b ) === "regexp" && + // the regex itself + a.source === b.source && + // and its modifiers + a.global === b.global && + // (gmi) ... + a.ignoreCase === b.ignoreCase && + a.multiline === b.multiline && + a.sticky === b.sticky; + }, + + // - skip when the property is a method of an instance (OOP) + // - abort otherwise, + // initial === would have catch identical references anyway + "function": function() { + var caller = callers[callers.length - 1]; + return caller !== Object && typeof caller !== "undefined"; + }, + + "array": function( b, a ) { + var i, j, len, loop, aCircular, bCircular; + + // b could be an object literal here + if ( QUnit.objectType( b ) !== "array" ) { + return false; + } + + len = a.length; + if ( len !== b.length ) { + // safe and faster + return false; + } + + // track reference to avoid circular references + parents.push( a ); + parentsB.push( b ); + for ( i = 0; i < len; i++ ) { + loop = false; + for ( j = 0; j < parents.length; j++ ) { + aCircular = parents[j] === a[i]; + bCircular = parentsB[j] === b[i]; + if ( aCircular || bCircular ) { + if ( a[i] === b[i] || aCircular && bCircular ) { + loop = true; + } else { + parents.pop(); + parentsB.pop(); + return false; + } + } + } + if ( !loop && !innerEquiv(a[i], b[i]) ) { + parents.pop(); + parentsB.pop(); + return false; + } + } + parents.pop(); + parentsB.pop(); + return true; + }, + + "object": function( b, a ) { + /*jshint forin:false */ + var i, j, loop, aCircular, bCircular, + // Default to true + eq = true, + aProperties = [], + bProperties = []; + + // comparing constructors is more strict than using + // instanceof + if ( a.constructor !== b.constructor ) { + // Allow objects with no prototype to be equivalent to + // objects with Object as their constructor. + if ( !(( getProto(a) === null && getProto(b) === Object.prototype ) || + ( getProto(b) === null && getProto(a) === Object.prototype ) ) ) { + return false; + } + } + + // stack constructor before traversing properties + callers.push( a.constructor ); + + // track reference to avoid circular references + parents.push( a ); + parentsB.push( b ); + + // be strict: don't ensure hasOwnProperty and go deep + for ( i in a ) { + loop = false; + for ( j = 0; j < parents.length; j++ ) { + aCircular = parents[j] === a[i]; + bCircular = parentsB[j] === b[i]; + if ( aCircular || bCircular ) { + if ( a[i] === b[i] || aCircular && bCircular ) { + loop = true; + } else { + eq = false; + break; + } + } + } + aProperties.push(i); + if ( !loop && !innerEquiv(a[i], b[i]) ) { + eq = false; + break; + } + } + + parents.pop(); + parentsB.pop(); + callers.pop(); // unstack, we are done + + for ( i in b ) { + bProperties.push( i ); // collect b's properties + } + + // Ensures identical properties name + return eq && innerEquiv( aProperties.sort(), bProperties.sort() ); + } + }; + }()); + + innerEquiv = function() { // can take multiple arguments + var args = [].slice.apply( arguments ); + if ( args.length < 2 ) { + return true; // end transition + } + + return (function( a, b ) { + if ( a === b ) { + return true; // catch the most you can + } else if ( a === null || b === null || typeof a === "undefined" || + typeof b === "undefined" || + QUnit.objectType(a) !== QUnit.objectType(b) ) { + return false; // don't lose time with error prone cases + } else { + return bindCallbacks(a, callbacks, [ b, a ]); + } + + // apply transition with (1..n) arguments + }( args[0], args[1] ) && innerEquiv.apply( this, args.splice(1, args.length - 1 )) ); + }; + + return innerEquiv; +}()); + +/** + * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | + * http://flesler.blogspot.com Licensed under BSD + * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008 + * + * @projectDescription Advanced and extensible data dumping for Javascript. + * @version 1.0.0 + * @author Ariel Flesler + * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html} + */ +QUnit.jsDump = (function() { + function quote( str ) { + return "\"" + str.toString().replace( /"/g, "\\\"" ) + "\""; + } + function literal( o ) { + return o + ""; + } + function join( pre, arr, post ) { + var s = jsDump.separator(), + base = jsDump.indent(), + inner = jsDump.indent(1); + if ( arr.join ) { + arr = arr.join( "," + s + inner ); + } + if ( !arr ) { + return pre + post; + } + return [ pre, inner + arr, base + post ].join(s); + } + function array( arr, stack ) { + var i = arr.length, ret = new Array(i); + this.up(); + while ( i-- ) { + ret[i] = this.parse( arr[i] , undefined , stack); + } + this.down(); + return join( "[", ret, "]" ); + } + + var reName = /^function (\w+)/, + jsDump = { + // type is used mostly internally, you can fix a (custom)type in advance + parse: function( obj, type, stack ) { + stack = stack || [ ]; + var inStack, res, + parser = this.parsers[ type || this.typeOf(obj) ]; + + type = typeof parser; + inStack = inArray( obj, stack ); + + if ( inStack !== -1 ) { + return "recursion(" + (inStack - stack.length) + ")"; + } + if ( type === "function" ) { + stack.push( obj ); + res = parser.call( this, obj, stack ); + stack.pop(); + return res; + } + return ( type === "string" ) ? parser : this.parsers.error; + }, + typeOf: function( obj ) { + var type; + if ( obj === null ) { + type = "null"; + } else if ( typeof obj === "undefined" ) { + type = "undefined"; + } else if ( QUnit.is( "regexp", obj) ) { + type = "regexp"; + } else if ( QUnit.is( "date", obj) ) { + type = "date"; + } else if ( QUnit.is( "function", obj) ) { + type = "function"; + } else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) { + type = "window"; + } else if ( obj.nodeType === 9 ) { + type = "document"; + } else if ( obj.nodeType ) { + type = "node"; + } else if ( + // native arrays + toString.call( obj ) === "[object Array]" || + // NodeList objects + ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) ) + ) { + type = "array"; + } else if ( obj.constructor === Error.prototype.constructor ) { + type = "error"; + } else { + type = typeof obj; + } + return type; + }, + separator: function() { + return this.multiline ? this.HTML ? "<br />" : "\n" : this.HTML ? " " : " "; + }, + // extra can be a number, shortcut for increasing-calling-decreasing + indent: function( extra ) { + if ( !this.multiline ) { + return ""; + } + var chr = this.indentChar; + if ( this.HTML ) { + chr = chr.replace( /\t/g, " " ).replace( / /g, " " ); + } + return new Array( this.depth + ( extra || 0 ) ).join(chr); + }, + up: function( a ) { + this.depth += a || 1; + }, + down: function( a ) { + this.depth -= a || 1; + }, + setParser: function( name, parser ) { + this.parsers[name] = parser; + }, + // The next 3 are exposed so you can use them + quote: quote, + literal: literal, + join: join, + // + depth: 1, + // This is the list of parsers, to modify them, use jsDump.setParser + parsers: { + window: "[Window]", + document: "[Document]", + error: function(error) { + return "Error(\"" + error.message + "\")"; + }, + unknown: "[Unknown]", + "null": "null", + "undefined": "undefined", + "function": function( fn ) { + var ret = "function", + // functions never have name in IE + name = "name" in fn ? fn.name : (reName.exec(fn) || [])[1]; + + if ( name ) { + ret += " " + name; + } + ret += "( "; + + ret = [ ret, QUnit.jsDump.parse( fn, "functionArgs" ), "){" ].join( "" ); + return join( ret, QUnit.jsDump.parse(fn,"functionCode" ), "}" ); + }, + array: array, + nodelist: array, + "arguments": array, + object: function( map, stack ) { + /*jshint forin:false */ + var ret = [ ], keys, key, val, i; + QUnit.jsDump.up(); + keys = []; + for ( key in map ) { + keys.push( key ); + } + keys.sort(); + for ( i = 0; i < keys.length; i++ ) { + key = keys[ i ]; + val = map[ key ]; + ret.push( QUnit.jsDump.parse( key, "key" ) + ": " + QUnit.jsDump.parse( val, undefined, stack ) ); + } + QUnit.jsDump.down(); + return join( "{", ret, "}" ); + }, + node: function( node ) { + var len, i, val, + open = QUnit.jsDump.HTML ? "<" : "<", + close = QUnit.jsDump.HTML ? ">" : ">", + tag = node.nodeName.toLowerCase(), + ret = open + tag, + attrs = node.attributes; + + if ( attrs ) { + for ( i = 0, len = attrs.length; i < len; i++ ) { + val = attrs[i].nodeValue; + // IE6 includes all attributes in .attributes, even ones not explicitly set. + // Those have values like undefined, null, 0, false, "" or "inherit". + if ( val && val !== "inherit" ) { + ret += " " + attrs[i].nodeName + "=" + QUnit.jsDump.parse( val, "attribute" ); + } + } + } + ret += close; + + // Show content of TextNode or CDATASection + if ( node.nodeType === 3 || node.nodeType === 4 ) { + ret += node.nodeValue; + } + + return ret + open + "/" + tag + close; + }, + // function calls it internally, it's the arguments part of the function + functionArgs: function( fn ) { + var args, + l = fn.length; + + if ( !l ) { + return ""; + } + + args = new Array(l); + while ( l-- ) { + // 97 is 'a' + args[l] = String.fromCharCode(97+l); + } + return " " + args.join( ", " ) + " "; + }, + // object calls it internally, the key part of an item in a map + key: quote, + // function calls it internally, it's the content of the function + functionCode: "[code]", + // node calls it internally, it's an html attribute value + attribute: quote, + string: quote, + date: quote, + regexp: literal, + number: literal, + "boolean": literal + }, + // if true, entities are escaped ( <, >, \t, space and \n ) + HTML: false, + // indentation unit + indentChar: " ", + // if true, items in a collection, are separated by a \n, else just a space. + multiline: true + }; + + return jsDump; +}()); + +// from jquery.js +function inArray( elem, array ) { + if ( array.indexOf ) { + return array.indexOf( elem ); + } + + for ( var i = 0, length = array.length; i < length; i++ ) { + if ( array[ i ] === elem ) { + return i; + } + } + + return -1; +} + +/* + * Javascript Diff Algorithm + * By John Resig (http://ejohn.org/) + * Modified by Chu Alan "sprite" + * + * Released under the MIT license. + * + * More Info: + * http://ejohn.org/projects/javascript-diff-algorithm/ + * + * Usage: QUnit.diff(expected, actual) + * + * QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over" + */ +QUnit.diff = (function() { + /*jshint eqeqeq:false, eqnull:true */ + function diff( o, n ) { + var i, + ns = {}, + os = {}; + + for ( i = 0; i < n.length; i++ ) { + if ( !hasOwn.call( ns, n[i] ) ) { + ns[ n[i] ] = { + rows: [], + o: null + }; + } + ns[ n[i] ].rows.push( i ); + } + + for ( i = 0; i < o.length; i++ ) { + if ( !hasOwn.call( os, o[i] ) ) { + os[ o[i] ] = { + rows: [], + n: null + }; + } + os[ o[i] ].rows.push( i ); + } + + for ( i in ns ) { + if ( hasOwn.call( ns, i ) ) { + if ( ns[i].rows.length === 1 && hasOwn.call( os, i ) && os[i].rows.length === 1 ) { + n[ ns[i].rows[0] ] = { + text: n[ ns[i].rows[0] ], + row: os[i].rows[0] + }; + o[ os[i].rows[0] ] = { + text: o[ os[i].rows[0] ], + row: ns[i].rows[0] + }; + } + } + } + + for ( i = 0; i < n.length - 1; i++ ) { + if ( n[i].text != null && n[ i + 1 ].text == null && n[i].row + 1 < o.length && o[ n[i].row + 1 ].text == null && + n[ i + 1 ] == o[ n[i].row + 1 ] ) { + + n[ i + 1 ] = { + text: n[ i + 1 ], + row: n[i].row + 1 + }; + o[ n[i].row + 1 ] = { + text: o[ n[i].row + 1 ], + row: i + 1 + }; + } + } + + for ( i = n.length - 1; i > 0; i-- ) { + if ( n[i].text != null && n[ i - 1 ].text == null && n[i].row > 0 && o[ n[i].row - 1 ].text == null && + n[ i - 1 ] == o[ n[i].row - 1 ]) { + + n[ i - 1 ] = { + text: n[ i - 1 ], + row: n[i].row - 1 + }; + o[ n[i].row - 1 ] = { + text: o[ n[i].row - 1 ], + row: i - 1 + }; + } + } + + return { + o: o, + n: n + }; + } + + return function( o, n ) { + o = o.replace( /\s+$/, "" ); + n = n.replace( /\s+$/, "" ); + + var i, pre, + str = "", + out = diff( o === "" ? [] : o.split(/\s+/), n === "" ? [] : n.split(/\s+/) ), + oSpace = o.match(/\s+/g), + nSpace = n.match(/\s+/g); + + if ( oSpace == null ) { + oSpace = [ " " ]; + } + else { + oSpace.push( " " ); + } + + if ( nSpace == null ) { + nSpace = [ " " ]; + } + else { + nSpace.push( " " ); + } + + if ( out.n.length === 0 ) { + for ( i = 0; i < out.o.length; i++ ) { + str += "<del>" + out.o[i] + oSpace[i] + "</del>"; + } + } + else { + if ( out.n[0].text == null ) { + for ( n = 0; n < out.o.length && out.o[n].text == null; n++ ) { + str += "<del>" + out.o[n] + oSpace[n] + "</del>"; + } + } + + for ( i = 0; i < out.n.length; i++ ) { + if (out.n[i].text == null) { + str += "<ins>" + out.n[i] + nSpace[i] + "</ins>"; + } + else { + // `pre` initialized at top of scope + pre = ""; + + for ( n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++ ) { + pre += "<del>" + out.o[n] + oSpace[n] + "</del>"; + } + str += " " + out.n[i].text + nSpace[i] + pre; + } + } + } + + return str; + }; +}()); + +// for CommonJS environments, export everything +if ( typeof exports !== "undefined" ) { + extend( exports, QUnit.constructor.prototype ); +} + +// get at whatever the global object is, like window in browsers +}( (function() {return this;}.call()) )); diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/runner.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/runner.js new file mode 100644 index 000000000..4b1d38b1b --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/runner.js @@ -0,0 +1,127 @@ +/* + * QtWebKit-powered headless test runner using PhantomJS + * + * PhantomJS binaries: http://phantomjs.org/download.html + * Requires PhantomJS 1.6+ (1.7+ recommended) + * + * Run with: + * phantomjs runner.js [url-of-your-qunit-testsuite] + * + * e.g. + * phantomjs runner.js http://localhost/qunit/test/index.html + */ + +/*jshint latedef:false */ +/*global phantom:false, require:false, console:false, window:false, QUnit:false */ + +(function() { + 'use strict'; + + var args = require('system').args; + + // arg[0]: scriptName, args[1...]: arguments + if (args.length !== 2) { + console.error('Usage:\n phantomjs runner.js [url-of-your-qunit-testsuite]'); + phantom.exit(1); + } + + var url = args[1], + page = require('webpage').create(); + + // Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`) + page.onConsoleMessage = function(msg) { + console.log(msg); + }; + + page.onInitialized = function() { + page.evaluate(addLogging); + }; + + page.onCallback = function(message) { + var result, + failed; + + if (message) { + if (message.name === 'QUnit.done') { + result = message.data; + failed = !result || result.failed; + + phantom.exit(failed ? 1 : 0); + } + } + }; + + page.open(url, function(status) { + if (status !== 'success') { + console.error('Unable to access network: ' + status); + phantom.exit(1); + } else { + // Cannot do this verification with the 'DOMContentLoaded' handler because it + // will be too late to attach it if a page does not have any script tags. + var qunitMissing = page.evaluate(function() { return (typeof QUnit === 'undefined' || !QUnit); }); + if (qunitMissing) { + console.error('The `QUnit` object is not present on this page.'); + phantom.exit(1); + } + + // Do nothing... the callback mechanism will handle everything! + } + }); + + function addLogging() { + window.document.addEventListener('DOMContentLoaded', function() { + var current_test_assertions = []; + + QUnit.log(function(details) { + var response; + + // Ignore passing assertions + if (details.result) { + return; + } + + response = details.message || ''; + + if (typeof details.expected !== 'undefined') { + if (response) { + response += ', '; + } + + response += 'expected: ' + details.expected + ', but was: ' + details.actual; + if (details.source) { + response += "\n" + details.source; + } + } + + current_test_assertions.push('Failed assertion: ' + response); + }); + + QUnit.testDone(function(result) { + var i, + len, + name = result.module + ': ' + result.name; + + if (result.failed) { + console.log('Test failed: ' + name); + + for (i = 0, len = current_test_assertions.length; i < len; i++) { + console.log(' ' + current_test_assertions[i]); + } + } + + current_test_assertions.length = 0; + }); + + QUnit.done(function(result) { + console.log('Took ' + result.runtime + 'ms to run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed + ' failed.'); + + if (typeof window.callPhantom === 'function') { + window.callPhantom({ + 'name': 'QUnit.done', + 'data': result + }); + } + }); + }, false); + } +})(); diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore-min.map b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore-min.map new file mode 100644 index 000000000..47c69bad3 --- /dev/null +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore-min.map @@ -0,0 +1 @@ +{"version":3,"file":"underscore-min.js","sources":["underscore.js"],"names":["root","this","previousUnderscore","_","breaker","ArrayProto","Array","prototype","ObjProto","Object","FuncProto","Function","push","slice","concat","toString","hasOwnProperty","nativeForEach","forEach","nativeMap","map","nativeReduce","reduce","nativeReduceRight","reduceRight","nativeFilter","filter","nativeEvery","every","nativeSome","some","nativeIndexOf","indexOf","nativeLastIndexOf","lastIndexOf","nativeIsArray","isArray","nativeKeys","keys","nativeBind","bind","obj","_wrapped","exports","module","VERSION","each","iterator","context","length","i","call","collect","results","value","index","list","reduceError","foldl","inject","memo","initial","arguments","TypeError","foldr","find","detect","predicate","result","any","select","reject","all","identity","contains","include","target","invoke","method","args","isFunc","isFunction","apply","pluck","key","property","where","attrs","matches","findWhere","max","Math","Infinity","lastComputed","computed","min","shuffle","rand","shuffled","random","sample","n","guard","values","lookupIterator","sortBy","criteria","sort","left","right","a","b","group","behavior","groupBy","has","indexBy","countBy","sortedIndex","array","low","high","mid","toArray","size","first","head","take","last","rest","tail","drop","compact","flatten","input","shallow","output","isArguments","without","difference","partition","pass","fail","elem","uniq","unique","isSorted","seen","union","intersection","item","other","zip","object","from","hasIndex","range","start","stop","step","ceil","idx","ctor","func","bound","self","partial","boundArgs","position","bindAll","funcs","Error","f","memoize","hasher","delay","wait","setTimeout","defer","throttle","options","timeout","previous","later","leading","now","remaining","clearTimeout","trailing","debounce","immediate","timestamp","callNow","once","ran","wrap","wrapper","compose","after","times","isObject","pairs","invert","functions","methods","names","extend","source","prop","pick","copy","omit","defaults","clone","tap","interceptor","eq","aStack","bStack","className","String","global","multiline","ignoreCase","aCtor","constructor","bCtor","pop","isEqual","isEmpty","isString","isElement","nodeType","name","isFinite","isNaN","parseFloat","isNumber","isBoolean","isNull","isUndefined","noConflict","constant","accum","floor","Date","getTime","entityMap","escape","&","<",">","\"","'","unescape","entityRegexes","RegExp","join","string","replace","match","mixin","idCounter","uniqueId","prefix","id","templateSettings","evaluate","interpolate","noMatch","escapes","\\","\r","\n","\t","
","
","escaper","template","text","data","settings","render","matcher","offset","variable","e","chain","_chain","define","amd"],"mappings":";;;;CAKA,WAME,GAAIA,GAAOC,KAGPC,EAAqBF,EAAKG,EAG1BC,KAGAC,EAAaC,MAAMC,UAAWC,EAAWC,OAAOF,UAAWG,EAAYC,SAASJ,UAIlFK,EAAmBP,EAAWO,KAC9BC,EAAmBR,EAAWQ,MAC9BC,EAAmBT,EAAWS,OAC9BC,EAAmBP,EAASO,SAC5BC,EAAmBR,EAASQ,eAK5BC,EAAqBZ,EAAWa,QAChCC,EAAqBd,EAAWe,IAChCC,EAAqBhB,EAAWiB,OAChCC,EAAqBlB,EAAWmB,YAChCC,EAAqBpB,EAAWqB,OAChCC,EAAqBtB,EAAWuB,MAChCC,EAAqBxB,EAAWyB,KAChCC,EAAqB1B,EAAW2B,QAChCC,EAAqB5B,EAAW6B,YAChCC,EAAqB7B,MAAM8B,QAC3BC,EAAqB5B,OAAO6B,KAC5BC,EAAqB7B,EAAU8B,KAG7BrC,EAAI,SAASsC,GACf,MAAIA,aAAetC,GAAUsC,EACvBxC,eAAgBE,QACtBF,KAAKyC,SAAWD,GADiB,GAAItC,GAAEsC,GAQlB,oBAAZE,UACa,mBAAXC,SAA0BA,OAAOD,UAC1CA,QAAUC,OAAOD,QAAUxC,GAE7BwC,QAAQxC,EAAIA,GAEZH,EAAKG,EAAIA,EAIXA,EAAE0C,QAAU,OAQZ,IAAIC,GAAO3C,EAAE2C,KAAO3C,EAAEe,QAAU,SAASuB,EAAKM,EAAUC,GACtD,GAAW,MAAPP,EAAa,MAAOA,EACxB,IAAIxB,GAAiBwB,EAAIvB,UAAYD,EACnCwB,EAAIvB,QAAQ6B,EAAUC,OACjB,IAAIP,EAAIQ,UAAYR,EAAIQ,QAC7B,IAAK,GAAIC,GAAI,EAAGD,EAASR,EAAIQ,OAAYA,EAAJC,EAAYA,IAC/C,GAAIH,EAASI,KAAKH,EAASP,EAAIS,GAAIA,EAAGT,KAASrC,EAAS,WAI1D,KAAK,GADDkC,GAAOnC,EAAEmC,KAAKG,GACTS,EAAI,EAAGD,EAASX,EAAKW,OAAYA,EAAJC,EAAYA,IAChD,GAAIH,EAASI,KAAKH,EAASP,EAAIH,EAAKY,IAAKZ,EAAKY,GAAIT,KAASrC,EAAS,MAGxE,OAAOqC,GAKTtC,GAAEiB,IAAMjB,EAAEiD,QAAU,SAASX,EAAKM,EAAUC,GAC1C,GAAIK,KACJ,OAAW,OAAPZ,EAAoBY,EACpBlC,GAAasB,EAAIrB,MAAQD,EAAkBsB,EAAIrB,IAAI2B,EAAUC,IACjEF,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/BH,EAAQzC,KAAKmC,EAASI,KAAKH,EAASM,EAAOC,EAAOC,MAE7CH,GAGT,IAAII,GAAc,6CAIlBtD,GAAEmB,OAASnB,EAAEuD,MAAQvD,EAAEwD,OAAS,SAASlB,EAAKM,EAAUa,EAAMZ,GAC5D,GAAIa,GAAUC,UAAUb,OAAS,CAEjC,IADW,MAAPR,IAAaA,MACbpB,GAAgBoB,EAAInB,SAAWD,EAEjC,MADI2B,KAASD,EAAW5C,EAAEqC,KAAKO,EAAUC,IAClCa,EAAUpB,EAAInB,OAAOyB,EAAUa,GAAQnB,EAAInB,OAAOyB,EAU3D,IARAD,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC1BK,EAIHD,EAAOb,EAASI,KAAKH,EAASY,EAAMN,EAAOC,EAAOC,IAHlDI,EAAON,EACPO,GAAU,MAKTA,EAAS,KAAM,IAAIE,WAAUN,EAClC,OAAOG,IAKTzD,EAAEqB,YAAcrB,EAAE6D,MAAQ,SAASvB,EAAKM,EAAUa,EAAMZ,GACtD,GAAIa,GAAUC,UAAUb,OAAS,CAEjC,IADW,MAAPR,IAAaA,MACblB,GAAqBkB,EAAIjB,cAAgBD,EAE3C,MADIyB,KAASD,EAAW5C,EAAEqC,KAAKO,EAAUC,IAClCa,EAAUpB,EAAIjB,YAAYuB,EAAUa,GAAQnB,EAAIjB,YAAYuB,EAErE,IAAIE,GAASR,EAAIQ,MACjB,IAAIA,KAAYA,EAAQ,CACtB,GAAIX,GAAOnC,EAAEmC,KAAKG,EAClBQ,GAASX,EAAKW,OAWhB,GATAH,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/BD,EAAQjB,EAAOA,IAAOW,KAAYA,EAC7BY,EAIHD,EAAOb,EAASI,KAAKH,EAASY,EAAMnB,EAAIc,GAAQA,EAAOC,IAHvDI,EAAOnB,EAAIc,GACXM,GAAU,MAKTA,EAAS,KAAM,IAAIE,WAAUN,EAClC,OAAOG,IAITzD,EAAE8D,KAAO9D,EAAE+D,OAAS,SAASzB,EAAK0B,EAAWnB,GAC3C,GAAIoB,EAOJ,OANAC,GAAI5B,EAAK,SAASa,EAAOC,EAAOC,GAC9B,MAAIW,GAAUhB,KAAKH,EAASM,EAAOC,EAAOC,IACxCY,EAASd,GACF,GAFT,SAKKc,GAMTjE,EAAEuB,OAASvB,EAAEmE,OAAS,SAAS7B,EAAK0B,EAAWnB,GAC7C,GAAIK,KACJ,OAAW,OAAPZ,EAAoBY,EACpB5B,GAAgBgB,EAAIf,SAAWD,EAAqBgB,EAAIf,OAAOyC,EAAWnB,IAC9EF,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC3BW,EAAUhB,KAAKH,EAASM,EAAOC,EAAOC,IAAOH,EAAQzC,KAAK0C,KAEzDD,IAITlD,EAAEoE,OAAS,SAAS9B,EAAK0B,EAAWnB,GAClC,MAAO7C,GAAEuB,OAAOe,EAAK,SAASa,EAAOC,EAAOC,GAC1C,OAAQW,EAAUhB,KAAKH,EAASM,EAAOC,EAAOC,IAC7CR,IAML7C,EAAEyB,MAAQzB,EAAEqE,IAAM,SAAS/B,EAAK0B,EAAWnB,GACzCmB,IAAcA,EAAYhE,EAAEsE,SAC5B,IAAIL,IAAS,CACb,OAAW,OAAP3B,EAAoB2B,EACpBzC,GAAec,EAAIb,QAAUD,EAAoBc,EAAIb,MAAMuC,EAAWnB,IAC1EF,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/B,OAAMY,EAASA,GAAUD,EAAUhB,KAAKH,EAASM,EAAOC,EAAOC,IAA/D,OAA8EpD,MAEvEgE,GAMX,IAAIC,GAAMlE,EAAE2B,KAAO3B,EAAEkE,IAAM,SAAS5B,EAAK0B,EAAWnB,GAClDmB,IAAcA,EAAYhE,EAAEsE,SAC5B,IAAIL,IAAS,CACb,OAAW,OAAP3B,EAAoB2B,EACpBvC,GAAcY,EAAIX,OAASD,EAAmBY,EAAIX,KAAKqC,EAAWnB,IACtEF,EAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/B,MAAIY,KAAWA,EAASD,EAAUhB,KAAKH,EAASM,EAAOC,EAAOC,IAAepD,EAA7E,WAEOgE,GAKXjE,GAAEuE,SAAWvE,EAAEwE,QAAU,SAASlC,EAAKmC,GACrC,MAAW,OAAPnC,GAAoB,EACpBV,GAAiBU,EAAIT,UAAYD,EAAsBU,EAAIT,QAAQ4C,KAAY,EAC5EP,EAAI5B,EAAK,SAASa,GACvB,MAAOA,KAAUsB,KAKrBzE,EAAE0E,OAAS,SAASpC,EAAKqC,GACvB,GAAIC,GAAOlE,EAAMsC,KAAKW,UAAW,GAC7BkB,EAAS7E,EAAE8E,WAAWH,EAC1B,OAAO3E,GAAEiB,IAAIqB,EAAK,SAASa,GACzB,OAAQ0B,EAASF,EAASxB,EAAMwB,IAASI,MAAM5B,EAAOyB,MAK1D5E,EAAEgF,MAAQ,SAAS1C,EAAK2C,GACtB,MAAOjF,GAAEiB,IAAIqB,EAAKtC,EAAEkF,SAASD,KAK/BjF,EAAEmF,MAAQ,SAAS7C,EAAK8C,GACtB,MAAOpF,GAAEuB,OAAOe,EAAKtC,EAAEqF,QAAQD,KAKjCpF,EAAEsF,UAAY,SAAShD,EAAK8C,GAC1B,MAAOpF,GAAE8D,KAAKxB,EAAKtC,EAAEqF,QAAQD,KAM/BpF,EAAEuF,IAAM,SAASjD,EAAKM,EAAUC,GAC9B,IAAKD,GAAY5C,EAAEiC,QAAQK,IAAQA,EAAI,MAAQA,EAAI,IAAMA,EAAIQ,OAAS,MACpE,MAAO0C,MAAKD,IAAIR,MAAMS,KAAMlD,EAE9B,IAAI2B,IAAUwB,IAAUC,GAAgBD,GAQxC,OAPA9C,GAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/B,GAAIsC,GAAW/C,EAAWA,EAASI,KAAKH,EAASM,EAAOC,EAAOC,GAAQF,CACnEwC,GAAWD,IACbzB,EAASd,EACTuC,EAAeC,KAGZ1B,GAITjE,EAAE4F,IAAM,SAAStD,EAAKM,EAAUC,GAC9B,IAAKD,GAAY5C,EAAEiC,QAAQK,IAAQA,EAAI,MAAQA,EAAI,IAAMA,EAAIQ,OAAS,MACpE,MAAO0C,MAAKI,IAAIb,MAAMS,KAAMlD,EAE9B,IAAI2B,GAASwB,IAAUC,EAAeD,GAQtC,OAPA9C,GAAKL,EAAK,SAASa,EAAOC,EAAOC,GAC/B,GAAIsC,GAAW/C,EAAWA,EAASI,KAAKH,EAASM,EAAOC,EAAOC,GAAQF,CACxDuC,GAAXC,IACF1B,EAASd,EACTuC,EAAeC,KAGZ1B,GAKTjE,EAAE6F,QAAU,SAASvD,GACnB,GAAIwD,GACA1C,EAAQ,EACR2C,IAMJ,OALApD,GAAKL,EAAK,SAASa,GACjB2C,EAAO9F,EAAEgG,OAAO5C,KAChB2C,EAAS3C,EAAQ,GAAK2C,EAASD,GAC/BC,EAASD,GAAQ3C,IAEZ4C,GAMT/F,EAAEiG,OAAS,SAAS3D,EAAK4D,EAAGC,GAC1B,MAAS,OAALD,GAAaC,GACX7D,EAAIQ,UAAYR,EAAIQ,SAAQR,EAAMtC,EAAEoG,OAAO9D,IACxCA,EAAItC,EAAEgG,OAAO1D,EAAIQ,OAAS,KAE5B9C,EAAE6F,QAAQvD,GAAK5B,MAAM,EAAG8E,KAAKD,IAAI,EAAGW,IAI7C,IAAIG,GAAiB,SAASlD,GAC5B,MAAa,OAATA,EAAsBnD,EAAEsE,SACxBtE,EAAE8E,WAAW3B,GAAeA,EACzBnD,EAAEkF,SAAS/B,GAIpBnD,GAAEsG,OAAS,SAAShE,EAAKM,EAAUC,GAEjC,MADAD,GAAWyD,EAAezD,GACnB5C,EAAEgF,MAAMhF,EAAEiB,IAAIqB,EAAK,SAASa,EAAOC,EAAOC,GAC/C,OACEF,MAAOA,EACPC,MAAOA,EACPmD,SAAU3D,EAASI,KAAKH,EAASM,EAAOC,EAAOC,MAEhDmD,KAAK,SAASC,EAAMC,GACrB,GAAIC,GAAIF,EAAKF,SACTK,EAAIF,EAAMH,QACd,IAAII,IAAMC,EAAG,CACX,GAAID,EAAIC,GAAKD,QAAW,GAAG,MAAO,EAClC,IAAQC,EAAJD,GAASC,QAAW,GAAG,OAAQ,EAErC,MAAOH,GAAKrD,MAAQsD,EAAMtD,QACxB,SAIN,IAAIyD,GAAQ,SAASC,GACnB,MAAO,UAASxE,EAAKM,EAAUC,GAC7B,GAAIoB,KAMJ,OALArB,GAAWyD,EAAezD,GAC1BD,EAAKL,EAAK,SAASa,EAAOC,GACxB,GAAI6B,GAAMrC,EAASI,KAAKH,EAASM,EAAOC,EAAOd,EAC/CwE,GAAS7C,EAAQgB,EAAK9B,KAEjBc,GAMXjE,GAAE+G,QAAUF,EAAM,SAAS5C,EAAQgB,EAAK9B,GACtCnD,EAAEgH,IAAI/C,EAAQgB,GAAOhB,EAAOgB,GAAKxE,KAAK0C,GAASc,EAAOgB,IAAQ9B,KAKhEnD,EAAEiH,QAAUJ,EAAM,SAAS5C,EAAQgB,EAAK9B,GACtCc,EAAOgB,GAAO9B,IAMhBnD,EAAEkH,QAAUL,EAAM,SAAS5C,EAAQgB,GACjCjF,EAAEgH,IAAI/C,EAAQgB,GAAOhB,EAAOgB,KAAShB,EAAOgB,GAAO,IAKrDjF,EAAEmH,YAAc,SAASC,EAAO9E,EAAKM,EAAUC,GAC7CD,EAAWyD,EAAezD,EAG1B,KAFA,GAAIO,GAAQP,EAASI,KAAKH,EAASP,GAC/B+E,EAAM,EAAGC,EAAOF,EAAMtE,OACbwE,EAAND,GAAY,CACjB,GAAIE,GAAOF,EAAMC,IAAU,CAC3B1E,GAASI,KAAKH,EAASuE,EAAMG,IAAQpE,EAAQkE,EAAME,EAAM,EAAID,EAAOC,EAEtE,MAAOF,IAITrH,EAAEwH,QAAU,SAASlF,GACnB,MAAKA,GACDtC,EAAEiC,QAAQK,GAAa5B,EAAMsC,KAAKV,GAClCA,EAAIQ,UAAYR,EAAIQ,OAAe9C,EAAEiB,IAAIqB,EAAKtC,EAAEsE,UAC7CtE,EAAEoG,OAAO9D,OAIlBtC,EAAEyH,KAAO,SAASnF,GAChB,MAAW,OAAPA,EAAoB,EAChBA,EAAIQ,UAAYR,EAAIQ,OAAUR,EAAIQ,OAAS9C,EAAEmC,KAAKG,GAAKQ,QASjE9C,EAAE0H,MAAQ1H,EAAE2H,KAAO3H,EAAE4H,KAAO,SAASR,EAAOlB,EAAGC,GAC7C,MAAa,OAATiB,MAA2B,GACrB,MAALlB,GAAcC,EAAciB,EAAM,GAC/B,EAAJlB,KACGxF,EAAMsC,KAAKoE,EAAO,EAAGlB,IAO9BlG,EAAE0D,QAAU,SAAS0D,EAAOlB,EAAGC,GAC7B,MAAOzF,GAAMsC,KAAKoE,EAAO,EAAGA,EAAMtE,QAAgB,MAALoD,GAAcC,EAAQ,EAAID,KAKzElG,EAAE6H,KAAO,SAAST,EAAOlB,EAAGC,GAC1B,MAAa,OAATiB,MAA2B,GACrB,MAALlB,GAAcC,EAAciB,EAAMA,EAAMtE,OAAS,GAC/CpC,EAAMsC,KAAKoE,EAAO5B,KAAKD,IAAI6B,EAAMtE,OAASoD,EAAG,KAOtDlG,EAAE8H,KAAO9H,EAAE+H,KAAO/H,EAAEgI,KAAO,SAASZ,EAAOlB,EAAGC,GAC5C,MAAOzF,GAAMsC,KAAKoE,EAAa,MAALlB,GAAcC,EAAQ,EAAID,IAItDlG,EAAEiI,QAAU,SAASb,GACnB,MAAOpH,GAAEuB,OAAO6F,EAAOpH,EAAEsE,UAI3B,IAAI4D,GAAU,SAASC,EAAOC,EAASC,GACrC,MAAID,IAAWpI,EAAEyB,MAAM0G,EAAOnI,EAAEiC,SACvBtB,EAAOoE,MAAMsD,EAAQF,IAE9BxF,EAAKwF,EAAO,SAAShF,GACfnD,EAAEiC,QAAQkB,IAAUnD,EAAEsI,YAAYnF,GACpCiF,EAAU3H,EAAKsE,MAAMsD,EAAQlF,GAAS+E,EAAQ/E,EAAOiF,EAASC,GAE9DA,EAAO5H,KAAK0C,KAGTkF,GAITrI,GAAEkI,QAAU,SAASd,EAAOgB,GAC1B,MAAOF,GAAQd,EAAOgB,OAIxBpI,EAAEuI,QAAU,SAASnB,GACnB,MAAOpH,GAAEwI,WAAWpB,EAAO1G,EAAMsC,KAAKW,UAAW,KAKnD3D,EAAEyI,UAAY,SAASrB,EAAOpD,GAC5B,GAAI0E,MAAWC,IAIf,OAHAhG,GAAKyE,EAAO,SAASwB,IAClB5E,EAAU4E,GAAQF,EAAOC,GAAMlI,KAAKmI,MAE/BF,EAAMC,IAMhB3I,EAAE6I,KAAO7I,EAAE8I,OAAS,SAAS1B,EAAO2B,EAAUnG,EAAUC,GAClD7C,EAAE8E,WAAWiE,KACflG,EAAUD,EACVA,EAAWmG,EACXA,GAAW,EAEb,IAAIrF,GAAUd,EAAW5C,EAAEiB,IAAImG,EAAOxE,EAAUC,GAAWuE,EACvDlE,KACA8F,IAOJ,OANArG,GAAKe,EAAS,SAASP,EAAOC,IACxB2F,EAAa3F,GAAS4F,EAAKA,EAAKlG,OAAS,KAAOK,EAAUnD,EAAEuE,SAASyE,EAAM7F,MAC7E6F,EAAKvI,KAAK0C,GACVD,EAAQzC,KAAK2G,EAAMhE,OAGhBF,GAKTlD,EAAEiJ,MAAQ,WACR,MAAOjJ,GAAE6I,KAAK7I,EAAEkI,QAAQvE,WAAW,KAKrC3D,EAAEkJ,aAAe,SAAS9B,GACxB,GAAIU,GAAOpH,EAAMsC,KAAKW,UAAW,EACjC,OAAO3D,GAAEuB,OAAOvB,EAAE6I,KAAKzB,GAAQ,SAAS+B,GACtC,MAAOnJ,GAAEyB,MAAMqG,EAAM,SAASsB,GAC5B,MAAOpJ,GAAEuE,SAAS6E,EAAOD,QAO/BnJ,EAAEwI,WAAa,SAASpB,GACtB,GAAIU,GAAOnH,EAAOoE,MAAM7E,EAAYQ,EAAMsC,KAAKW,UAAW,GAC1D,OAAO3D,GAAEuB,OAAO6F,EAAO,SAASjE,GAAQ,OAAQnD,EAAEuE,SAASuD,EAAM3E,MAKnEnD,EAAEqJ,IAAM,WAGN,IAAK,GAFDvG,GAAS9C,EAAEuF,IAAIvF,EAAEgF,MAAMrB,UAAW,UAAUhD,OAAO,IACnDuC,EAAU,GAAI/C,OAAM2C,GACfC,EAAI,EAAOD,EAAJC,EAAYA,IAC1BG,EAAQH,GAAK/C,EAAEgF,MAAMrB,UAAW,GAAKZ,EAEvC,OAAOG,IAMTlD,EAAEsJ,OAAS,SAASjG,EAAM+C,GACxB,GAAY,MAAR/C,EAAc,QAElB,KAAK,GADDY,MACKlB,EAAI,EAAGD,EAASO,EAAKP,OAAYA,EAAJC,EAAYA,IAC5CqD,EACFnC,EAAOZ,EAAKN,IAAMqD,EAAOrD,GAEzBkB,EAAOZ,EAAKN,GAAG,IAAMM,EAAKN,GAAG,EAGjC,OAAOkB,IASTjE,EAAE6B,QAAU,SAASuF,EAAO+B,EAAMJ,GAChC,GAAa,MAAT3B,EAAe,OAAQ,CAC3B,IAAIrE,GAAI,EAAGD,EAASsE,EAAMtE,MAC1B,IAAIiG,EAAU,CACZ,GAAuB,gBAAZA,GAIT,MADAhG,GAAI/C,EAAEmH,YAAYC,EAAO+B,GAClB/B,EAAMrE,KAAOoG,EAAOpG,GAAK,CAHhCA,GAAgB,EAAXgG,EAAevD,KAAKD,IAAI,EAAGzC,EAASiG,GAAYA,EAMzD,GAAInH,GAAiBwF,EAAMvF,UAAYD,EAAe,MAAOwF,GAAMvF,QAAQsH,EAAMJ,EACjF,MAAWjG,EAAJC,EAAYA,IAAK,GAAIqE,EAAMrE,KAAOoG,EAAM,MAAOpG,EACtD,QAAQ,GAIV/C,EAAE+B,YAAc,SAASqF,EAAO+B,EAAMI,GACpC,GAAa,MAATnC,EAAe,OAAQ,CAC3B,IAAIoC,GAAmB,MAARD,CACf,IAAIzH,GAAqBsF,EAAMrF,cAAgBD,EAC7C,MAAO0H,GAAWpC,EAAMrF,YAAYoH,EAAMI,GAAQnC,EAAMrF,YAAYoH,EAGtE,KADA,GAAIpG,GAAKyG,EAAWD,EAAOnC,EAAMtE,OAC1BC,KAAK,GAAIqE,EAAMrE,KAAOoG,EAAM,MAAOpG,EAC1C,QAAQ,GAMV/C,EAAEyJ,MAAQ,SAASC,EAAOC,EAAMC,GAC1BjG,UAAUb,QAAU,IACtB6G,EAAOD,GAAS,EAChBA,EAAQ,GAEVE,EAAOjG,UAAU,IAAM,CAMvB,KAJA,GAAIb,GAAS0C,KAAKD,IAAIC,KAAKqE,MAAMF,EAAOD,GAASE,GAAO,GACpDE,EAAM,EACNL,EAAQ,GAAItJ,OAAM2C,GAEVA,EAANgH,GACJL,EAAMK,KAASJ,EACfA,GAASE,CAGX,OAAOH,GAOT,IAAIM,GAAO,YAKX/J,GAAEqC,KAAO,SAAS2H,EAAMnH,GACtB,GAAI+B,GAAMqF,CACV,IAAI7H,GAAc4H,EAAK3H,OAASD,EAAY,MAAOA,GAAW2C,MAAMiF,EAAMtJ,EAAMsC,KAAKW,UAAW,GAChG,KAAK3D,EAAE8E,WAAWkF,GAAO,KAAM,IAAIpG,UAEnC,OADAgB,GAAOlE,EAAMsC,KAAKW,UAAW,GACtBsG,EAAQ,WACb,KAAMnK,eAAgBmK,IAAQ,MAAOD,GAAKjF,MAAMlC,EAAS+B,EAAKjE,OAAOD,EAAMsC,KAAKW,YAChFoG,GAAK3J,UAAY4J,EAAK5J,SACtB,IAAI8J,GAAO,GAAIH,EACfA,GAAK3J,UAAY,IACjB,IAAI6D,GAAS+F,EAAKjF,MAAMmF,EAAMtF,EAAKjE,OAAOD,EAAMsC,KAAKW,YACrD,OAAIrD,QAAO2D,KAAYA,EAAeA,EAC/BiG,IAOXlK,EAAEmK,QAAU,SAASH,GACnB,GAAII,GAAY1J,EAAMsC,KAAKW,UAAW,EACtC,OAAO,YAGL,IAAK,GAFD0G,GAAW,EACXzF,EAAOwF,EAAU1J,QACZqC,EAAI,EAAGD,EAAS8B,EAAK9B,OAAYA,EAAJC,EAAYA,IAC5C6B,EAAK7B,KAAO/C,IAAG4E,EAAK7B,GAAKY,UAAU0G,KAEzC,MAAOA,EAAW1G,UAAUb,QAAQ8B,EAAKnE,KAAKkD,UAAU0G,KACxD,OAAOL,GAAKjF,MAAMjF,KAAM8E,KAO5B5E,EAAEsK,QAAU,SAAShI,GACnB,GAAIiI,GAAQ7J,EAAMsC,KAAKW,UAAW,EAClC,IAAqB,IAAjB4G,EAAMzH,OAAc,KAAM,IAAI0H,OAAM,wCAExC,OADA7H,GAAK4H,EAAO,SAASE,GAAKnI,EAAImI,GAAKzK,EAAEqC,KAAKC,EAAImI,GAAInI,KAC3CA,GAITtC,EAAE0K,QAAU,SAASV,EAAMW,GACzB,GAAIlH,KAEJ,OADAkH,KAAWA,EAAS3K,EAAEsE,UACf,WACL,GAAIW,GAAM0F,EAAO5F,MAAMjF,KAAM6D,UAC7B,OAAO3D,GAAEgH,IAAIvD,EAAMwB,GAAOxB,EAAKwB,GAAQxB,EAAKwB,GAAO+E,EAAKjF,MAAMjF,KAAM6D,aAMxE3D,EAAE4K,MAAQ,SAASZ,EAAMa,GACvB,GAAIjG,GAAOlE,EAAMsC,KAAKW,UAAW,EACjC,OAAOmH,YAAW,WAAY,MAAOd,GAAKjF,MAAM,KAAMH,IAAUiG,IAKlE7K,EAAE+K,MAAQ,SAASf,GACjB,MAAOhK,GAAE4K,MAAM7F,MAAM/E,GAAIgK,EAAM,GAAGrJ,OAAOD,EAAMsC,KAAKW,UAAW,MAQjE3D,EAAEgL,SAAW,SAAShB,EAAMa,EAAMI,GAChC,GAAIpI,GAAS+B,EAAMX,EACfiH,EAAU,KACVC,EAAW,CACfF,KAAYA,KACZ,IAAIG,GAAQ,WACVD,EAAWF,EAAQI,WAAY,EAAQ,EAAIrL,EAAEsL,MAC7CJ,EAAU,KACVjH,EAAS+F,EAAKjF,MAAMlC,EAAS+B,GAC7B/B,EAAU+B,EAAO,KAEnB,OAAO,YACL,GAAI0G,GAAMtL,EAAEsL,KACPH,IAAYF,EAAQI,WAAY,IAAOF,EAAWG,EACvD,IAAIC,GAAYV,GAAQS,EAAMH,EAY9B,OAXAtI,GAAU/C,KACV8E,EAAOjB,UACU,GAAb4H,GACFC,aAAaN,GACbA,EAAU,KACVC,EAAWG,EACXrH,EAAS+F,EAAKjF,MAAMlC,EAAS+B,GAC7B/B,EAAU+B,EAAO,MACPsG,GAAWD,EAAQQ,YAAa,IAC1CP,EAAUJ,WAAWM,EAAOG,IAEvBtH,IAQXjE,EAAE0L,SAAW,SAAS1B,EAAMa,EAAMc,GAChC,GAAIT,GAAStG,EAAM/B,EAAS+I,EAAW3H,EAEnCmH,EAAQ,WACV,GAAIvD,GAAO7H,EAAEsL,MAAQM,CACVf,GAAPhD,EACFqD,EAAUJ,WAAWM,EAAOP,EAAOhD,IAEnCqD,EAAU,KACLS,IACH1H,EAAS+F,EAAKjF,MAAMlC,EAAS+B,GAC7B/B,EAAU+B,EAAO,OAKvB,OAAO,YACL/B,EAAU/C,KACV8E,EAAOjB,UACPiI,EAAY5L,EAAEsL,KACd,IAAIO,GAAUF,IAAcT,CAS5B,OARKA,KACHA,EAAUJ,WAAWM,EAAOP,IAE1BgB,IACF5H,EAAS+F,EAAKjF,MAAMlC,EAAS+B,GAC7B/B,EAAU+B,EAAO,MAGZX,IAMXjE,EAAE8L,KAAO,SAAS9B,GAChB,GAAiBvG,GAAbsI,GAAM,CACV,OAAO,YACL,MAAIA,GAAYtI,GAChBsI,GAAM,EACNtI,EAAOuG,EAAKjF,MAAMjF,KAAM6D,WACxBqG,EAAO,KACAvG,KAOXzD,EAAEgM,KAAO,SAAShC,EAAMiC,GACtB,MAAOjM,GAAEmK,QAAQ8B,EAASjC,IAK5BhK,EAAEkM,QAAU,WACV,GAAI3B,GAAQ5G,SACZ,OAAO,YAEL,IAAK,GADDiB,GAAOjB,UACFZ,EAAIwH,EAAMzH,OAAS,EAAGC,GAAK,EAAGA,IACrC6B,GAAQ2F,EAAMxH,GAAGgC,MAAMjF,KAAM8E,GAE/B,OAAOA,GAAK,KAKhB5E,EAAEmM,MAAQ,SAASC,EAAOpC,GACxB,MAAO,YACL,QAAMoC,EAAQ,EACLpC,EAAKjF,MAAMjF,KAAM6D,WAD1B,SAWJ3D,EAAEmC,KAAO,SAASG,GAChB,IAAKtC,EAAEqM,SAAS/J,GAAM,QACtB,IAAIJ,EAAY,MAAOA,GAAWI,EAClC,IAAIH,KACJ,KAAK,GAAI8C,KAAO3C,GAAStC,EAAEgH,IAAI1E,EAAK2C,IAAM9C,EAAK1B,KAAKwE,EACpD,OAAO9C,IAITnC,EAAEoG,OAAS,SAAS9D,GAIlB,IAAK,GAHDH,GAAOnC,EAAEmC,KAAKG,GACdQ,EAASX,EAAKW,OACdsD,EAAS,GAAIjG,OAAM2C,GACdC,EAAI,EAAOD,EAAJC,EAAYA,IAC1BqD,EAAOrD,GAAKT,EAAIH,EAAKY,GAEvB,OAAOqD,IAITpG,EAAEsM,MAAQ,SAAShK,GAIjB,IAAK,GAHDH,GAAOnC,EAAEmC,KAAKG,GACdQ,EAASX,EAAKW,OACdwJ,EAAQ,GAAInM,OAAM2C,GACbC,EAAI,EAAOD,EAAJC,EAAYA,IAC1BuJ,EAAMvJ,IAAMZ,EAAKY,GAAIT,EAAIH,EAAKY,IAEhC,OAAOuJ,IAITtM,EAAEuM,OAAS,SAASjK,GAGlB,IAAK,GAFD2B,MACA9B,EAAOnC,EAAEmC,KAAKG,GACTS,EAAI,EAAGD,EAASX,EAAKW,OAAYA,EAAJC,EAAYA,IAChDkB,EAAO3B,EAAIH,EAAKY,KAAOZ,EAAKY,EAE9B,OAAOkB,IAKTjE,EAAEwM,UAAYxM,EAAEyM,QAAU,SAASnK,GACjC,GAAIoK,KACJ,KAAK,GAAIzH,KAAO3C,GACVtC,EAAE8E,WAAWxC,EAAI2C,KAAOyH,EAAMjM,KAAKwE,EAEzC,OAAOyH,GAAMlG,QAIfxG,EAAE2M,OAAS,SAASrK,GAQlB,MAPAK,GAAKjC,EAAMsC,KAAKW,UAAW,GAAI,SAASiJ,GACtC,GAAIA,EACF,IAAK,GAAIC,KAAQD,GACftK,EAAIuK,GAAQD,EAAOC,KAIlBvK,GAITtC,EAAE8M,KAAO,SAASxK,GAChB,GAAIyK,MACA5K,EAAOxB,EAAOoE,MAAM7E,EAAYQ,EAAMsC,KAAKW,UAAW,GAI1D,OAHAhB,GAAKR,EAAM,SAAS8C,GACdA,IAAO3C,KAAKyK,EAAK9H,GAAO3C,EAAI2C,MAE3B8H,GAIT/M,EAAEgN,KAAO,SAAS1K,GAChB,GAAIyK,MACA5K,EAAOxB,EAAOoE,MAAM7E,EAAYQ,EAAMsC,KAAKW,UAAW,GAC1D,KAAK,GAAIsB,KAAO3C,GACTtC,EAAEuE,SAASpC,EAAM8C,KAAM8H,EAAK9H,GAAO3C,EAAI2C,GAE9C,OAAO8H,IAIT/M,EAAEiN,SAAW,SAAS3K,GAQpB,MAPAK,GAAKjC,EAAMsC,KAAKW,UAAW,GAAI,SAASiJ,GACtC,GAAIA,EACF,IAAK,GAAIC,KAAQD,GACXtK,EAAIuK,SAAe,KAAGvK,EAAIuK,GAAQD,EAAOC,MAI5CvK,GAITtC,EAAEkN,MAAQ,SAAS5K,GACjB,MAAKtC,GAAEqM,SAAS/J,GACTtC,EAAEiC,QAAQK,GAAOA,EAAI5B,QAAUV,EAAE2M,UAAWrK,GADtBA,GAO/BtC,EAAEmN,IAAM,SAAS7K,EAAK8K,GAEpB,MADAA,GAAY9K,GACLA,EAIT,IAAI+K,GAAK,SAAS1G,EAAGC,EAAG0G,EAAQC,GAG9B,GAAI5G,IAAMC,EAAG,MAAa,KAAND,GAAW,EAAIA,GAAK,EAAIC,CAE5C,IAAS,MAALD,GAAkB,MAALC,EAAW,MAAOD,KAAMC,CAErCD,aAAa3G,KAAG2G,EAAIA,EAAEpE,UACtBqE,YAAa5G,KAAG4G,EAAIA,EAAErE,SAE1B,IAAIiL,GAAY5M,EAASoC,KAAK2D,EAC9B,IAAI6G,GAAa5M,EAASoC,KAAK4D,GAAI,OAAO,CAC1C,QAAQ4G,GAEN,IAAK,kBAGH,MAAO7G,IAAK8G,OAAO7G,EACrB,KAAK,kBAGH,MAAOD,KAAMA,EAAIC,IAAMA,EAAU,GAALD,EAAS,EAAIA,GAAK,EAAIC,EAAID,IAAMC,CAC9D,KAAK,gBACL,IAAK,mBAIH,OAAQD,IAAMC,CAEhB,KAAK,kBACH,MAAOD,GAAEiG,QAAUhG,EAAEgG,QACdjG,EAAE+G,QAAU9G,EAAE8G,QACd/G,EAAEgH,WAAa/G,EAAE+G,WACjBhH,EAAEiH,YAAchH,EAAEgH,WAE7B,GAAgB,gBAALjH,IAA6B,gBAALC,GAAe,OAAO,CAIzD,KADA,GAAI9D,GAASwK,EAAOxK,OACbA,KAGL,GAAIwK,EAAOxK,IAAW6D,EAAG,MAAO4G,GAAOzK,IAAW8D,CAIpD,IAAIiH,GAAQlH,EAAEmH,YAAaC,EAAQnH,EAAEkH,WACrC,IAAID,IAAUE,KAAW/N,EAAE8E,WAAW+I,IAAWA,YAAiBA,IACzC7N,EAAE8E,WAAWiJ,IAAWA,YAAiBA,KAC1C,eAAiBpH,IAAK,eAAiBC,GAC7D,OAAO,CAGT0G,GAAO7M,KAAKkG,GACZ4G,EAAO9M,KAAKmG,EACZ,IAAIa,GAAO,EAAGxD,GAAS,CAEvB,IAAiB,kBAAbuJ,GAIF,GAFA/F,EAAOd,EAAE7D,OACTmB,EAASwD,GAAQb,EAAE9D,OAGjB,KAAO2E,MACCxD,EAASoJ,EAAG1G,EAAEc,GAAOb,EAAEa,GAAO6F,EAAQC,WAG3C,CAEL,IAAK,GAAItI,KAAO0B,GACd,GAAI3G,EAAEgH,IAAIL,EAAG1B,KAEXwC,MAEMxD,EAASjE,EAAEgH,IAAIJ,EAAG3B,IAAQoI,EAAG1G,EAAE1B,GAAM2B,EAAE3B,GAAMqI,EAAQC,KAAU,KAIzE,IAAItJ,EAAQ,CACV,IAAKgB,IAAO2B,GACV,GAAI5G,EAAEgH,IAAIJ,EAAG3B,KAAUwC,IAAS,KAElCxD,IAAUwD,GAMd,MAFA6F,GAAOU,MACPT,EAAOS,MACA/J,EAITjE,GAAEiO,QAAU,SAAStH,EAAGC,GACtB,MAAOyG,GAAG1G,EAAGC,UAKf5G,EAAEkO,QAAU,SAAS5L,GACnB,GAAW,MAAPA,EAAa,OAAO,CACxB,IAAItC,EAAEiC,QAAQK,IAAQtC,EAAEmO,SAAS7L,GAAM,MAAsB,KAAfA,EAAIQ,MAClD,KAAK,GAAImC,KAAO3C,GAAK,GAAItC,EAAEgH,IAAI1E,EAAK2C,GAAM,OAAO,CACjD,QAAO,GAITjF,EAAEoO,UAAY,SAAS9L,GACrB,SAAUA,GAAwB,IAAjBA,EAAI+L,WAKvBrO,EAAEiC,QAAUD,GAAiB,SAASM,GACpC,MAA6B,kBAAtB1B,EAASoC,KAAKV,IAIvBtC,EAAEqM,SAAW,SAAS/J,GACpB,MAAOA,KAAQhC,OAAOgC,IAIxBK,GAAM,YAAa,WAAY,SAAU,SAAU,OAAQ,UAAW,SAAS2L,GAC7EtO,EAAE,KAAOsO,GAAQ,SAAShM,GACxB,MAAO1B,GAASoC,KAAKV,IAAQ,WAAagM,EAAO,OAMhDtO,EAAEsI,YAAY3E,aACjB3D,EAAEsI,YAAc,SAAShG,GACvB,SAAUA,IAAOtC,EAAEgH,IAAI1E,EAAK,aAKX,kBAAV,MACTtC,EAAE8E,WAAa,SAASxC,GACtB,MAAsB,kBAARA,KAKlBtC,EAAEuO,SAAW,SAASjM,GACpB,MAAOiM,UAASjM,KAASkM,MAAMC,WAAWnM,KAI5CtC,EAAEwO,MAAQ,SAASlM,GACjB,MAAOtC,GAAE0O,SAASpM,IAAQA,IAAQA,GAIpCtC,EAAE2O,UAAY,SAASrM,GACrB,MAAOA,MAAQ,GAAQA,KAAQ,GAA+B,oBAAtB1B,EAASoC,KAAKV,IAIxDtC,EAAE4O,OAAS,SAAStM,GAClB,MAAe,QAARA,GAITtC,EAAE6O,YAAc,SAASvM,GACvB,MAAOA,SAAa,IAKtBtC,EAAEgH,IAAM,SAAS1E,EAAK2C,GACpB,MAAOpE,GAAemC,KAAKV,EAAK2C,IAQlCjF,EAAE8O,WAAa,WAEb,MADAjP,GAAKG,EAAID,EACFD,MAITE,EAAEsE,SAAW,SAASnB,GACpB,MAAOA,IAGTnD,EAAE+O,SAAW,SAAS5L,GACpB,MAAO,YACL,MAAOA,KAIXnD,EAAEkF,SAAW,SAASD,GACpB,MAAO,UAAS3C,GACd,MAAOA,GAAI2C,KAKfjF,EAAEqF,QAAU,SAASD,GACnB,MAAO,UAAS9C,GACd,GAAIA,IAAQ8C,EAAO,OAAO,CAC1B,KAAK,GAAIH,KAAOG,GACd,GAAIA,EAAMH,KAAS3C,EAAI2C,GACrB,OAAO,CAEX,QAAO,IAKXjF,EAAEoM,MAAQ,SAASlG,EAAGtD,EAAUC,GAE9B,IAAK,GADDmM,GAAQ7O,MAAMqF,KAAKD,IAAI,EAAGW,IACrBnD,EAAI,EAAOmD,EAAJnD,EAAOA,IAAKiM,EAAMjM,GAAKH,EAASI,KAAKH,EAASE,EAC9D,OAAOiM,IAIThP,EAAEgG,OAAS,SAASJ,EAAKL,GAKvB,MAJW,OAAPA,IACFA,EAAMK,EACNA,EAAM,GAEDA,EAAMJ,KAAKyJ,MAAMzJ,KAAKQ,UAAYT,EAAMK,EAAM,KAIvD5F,EAAEsL,IAAM4D,KAAK5D,KAAO,WAAa,OAAO,GAAI4D,OAAOC,UAGnD,IAAIC,IACFC,QACEC,IAAK,QACLC,IAAK,OACLC,IAAK,OACLC,IAAK,SACLC,IAAK,UAGTN,GAAUO,SAAW3P,EAAEuM,OAAO6C,EAAUC,OAGxC,IAAIO,IACFP,OAAU,GAAIQ,QAAO,IAAM7P,EAAEmC,KAAKiN,EAAUC,QAAQS,KAAK,IAAM,IAAK,KACpEH,SAAU,GAAIE,QAAO,IAAM7P,EAAEmC,KAAKiN,EAAUO,UAAUG,KAAK,KAAO,IAAK,KAIzE9P,GAAE2C,MAAM,SAAU,YAAa,SAASgC,GACtC3E,EAAE2E,GAAU,SAASoL,GACnB,MAAc,OAAVA,EAAuB,IACnB,GAAKA,GAAQC,QAAQJ,EAAcjL,GAAS,SAASsL,GAC3D,MAAOb,GAAUzK,GAAQsL,QAO/BjQ,EAAEiE,OAAS,SAASqF,EAAQpE,GAC1B,GAAc,MAAVoE,EAAgB,WAAY,EAChC,IAAInG,GAAQmG,EAAOpE,EACnB,OAAOlF,GAAE8E,WAAW3B,GAASA,EAAMH,KAAKsG,GAAUnG,GAIpDnD,EAAEkQ,MAAQ,SAAS5N,GACjBK,EAAK3C,EAAEwM,UAAUlK,GAAM,SAASgM,GAC9B,GAAItE,GAAOhK,EAAEsO,GAAQhM,EAAIgM,EACzBtO,GAAEI,UAAUkO,GAAQ,WAClB,GAAI1J,IAAQ9E,KAAKyC,SAEjB,OADA9B,GAAKsE,MAAMH,EAAMjB,WACVM,EAAOjB,KAAKlD,KAAMkK,EAAKjF,MAAM/E,EAAG4E,OAO7C,IAAIuL,GAAY,CAChBnQ,GAAEoQ,SAAW,SAASC,GACpB,GAAIC,KAAOH,EAAY,EACvB,OAAOE,GAASA,EAASC,EAAKA,GAKhCtQ,EAAEuQ,kBACAC,SAAc,kBACdC,YAAc,mBACdpB,OAAc,mBAMhB,IAAIqB,GAAU,OAIVC,GACFjB,IAAU,IACVkB,KAAU,KACVC,KAAU,IACVC,KAAU,IACVC,IAAU,IACVC,SAAU,QACVC,SAAU,SAGRC,EAAU,8BAKdlR,GAAEmR,SAAW,SAASC,EAAMC,EAAMC,GAChC,GAAIC,EACJD,GAAWtR,EAAEiN,YAAaqE,EAAUtR,EAAEuQ,iBAGtC,IAAIiB,GAAU,GAAI3B,UACfyB,EAASjC,QAAUqB,GAAS9D,QAC5B0E,EAASb,aAAeC,GAAS9D,QACjC0E,EAASd,UAAYE,GAAS9D,QAC/BkD,KAAK,KAAO,KAAM,KAGhB1M,EAAQ,EACRwJ,EAAS,QACbwE,GAAKpB,QAAQwB,EAAS,SAASvB,EAAOZ,EAAQoB,EAAaD,EAAUiB,GAcnE,MAbA7E,IAAUwE,EAAK1Q,MAAM0C,EAAOqO,GACzBzB,QAAQkB,EAAS,SAASjB,GAAS,MAAO,KAAOU,EAAQV,KAExDZ,IACFzC,GAAU,cAAgByC,EAAS,kCAEjCoB,IACF7D,GAAU,cAAgB6D,EAAc,wBAEtCD,IACF5D,GAAU,OAAS4D,EAAW,YAEhCpN,EAAQqO,EAASxB,EAAMnN,OAChBmN,IAETrD,GAAU,OAGL0E,EAASI,WAAU9E,EAAS,mBAAqBA,EAAS,OAE/DA,EAAS,2CACP,oDACAA,EAAS,eAEX,KACE2E,EAAS,GAAI/Q,UAAS8Q,EAASI,UAAY,MAAO,IAAK9E,GACvD,MAAO+E,GAEP,KADAA,GAAE/E,OAASA,EACL+E,EAGR,GAAIN,EAAM,MAAOE,GAAOF,EAAMrR,EAC9B,IAAImR,GAAW,SAASE,GACtB,MAAOE,GAAOvO,KAAKlD,KAAMuR,EAAMrR,GAMjC,OAFAmR,GAASvE,OAAS,aAAe0E,EAASI,UAAY,OAAS,OAAS9E,EAAS,IAE1EuE,GAITnR,EAAE4R,MAAQ,SAAStP,GACjB,MAAOtC,GAAEsC,GAAKsP,QAUhB,IAAI3N,GAAS,SAAS3B,GACpB,MAAOxC,MAAK+R,OAAS7R,EAAEsC,GAAKsP,QAAUtP,EAIxCtC,GAAEkQ,MAAMlQ,GAGR2C,GAAM,MAAO,OAAQ,UAAW,QAAS,OAAQ,SAAU,WAAY,SAAS2L,GAC9E,GAAI3J,GAASzE,EAAWoO,EACxBtO,GAAEI,UAAUkO,GAAQ,WAClB,GAAIhM,GAAMxC,KAAKyC,QAGf,OAFAoC,GAAOI,MAAMzC,EAAKqB,WACL,SAAR2K,GAA2B,UAARA,GAAoC,IAAfhM,EAAIQ,cAAqBR,GAAI,GACnE2B,EAAOjB,KAAKlD,KAAMwC,MAK7BK,GAAM,SAAU,OAAQ,SAAU,SAAS2L,GACzC,GAAI3J,GAASzE,EAAWoO,EACxBtO,GAAEI,UAAUkO,GAAQ,WAClB,MAAOrK,GAAOjB,KAAKlD,KAAM6E,EAAOI,MAAMjF,KAAKyC,SAAUoB,eAIzD3D,EAAE2M,OAAO3M,EAAEI,WAGTwR,MAAO,WAEL,MADA9R,MAAK+R,QAAS,EACP/R,MAITqD,MAAO,WACL,MAAOrD,MAAKyC,YAYM,kBAAXuP,SAAyBA,OAAOC,KACzCD,OAAO,gBAAkB,WACvB,MAAO9R,OAGVgD,KAAKlD"}
\ No newline at end of file diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore.js index 9a4cabecf..bc4505051 100644 --- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore.js +++ b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore.js @@ -14,9 +14,6 @@ // Save the previous value of the `_` variable. var previousUnderscore = root._; - // Establish the object that gets returned to break out of a loop iteration. - var breaker = {}; - // Save bytes in the minified (but not gzipped) version: var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; @@ -31,15 +28,6 @@ // All **ECMAScript 5** native function implementations that we hope to use // are declared here. var - nativeForEach = ArrayProto.forEach, - nativeMap = ArrayProto.map, - nativeReduce = ArrayProto.reduce, - nativeReduceRight = ArrayProto.reduceRight, - nativeFilter = ArrayProto.filter, - nativeEvery = ArrayProto.every, - nativeSome = ArrayProto.some, - nativeIndexOf = ArrayProto.indexOf, - nativeLastIndexOf = ArrayProto.lastIndexOf, nativeIsArray = Array.isArray, nativeKeys = Object.keys, nativeBind = FuncProto.bind; @@ -67,96 +55,126 @@ // Current version. _.VERSION = '1.6.0'; + // Internal function: creates a callback bound to its context if supplied + var createCallback = function(func, context, argCount) { + if (context === void 0) return func; + switch (argCount == null ? 3 : argCount) { + case 1: return function(value) { + return func.call(context, value); + }; + case 2: return function(value, other) { + return func.call(context, value, other); + }; + case 3: return function(value, index, collection) { + return func.call(context, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(context, accumulator, value, index, collection); + }; + } + return function() { + return func.apply(context, arguments); + }; + }; + + // An internal function to generate lookup iterators. + var lookupIterator = function(value, context, argCount) { + if (value == null) return _.identity; + if (_.isFunction(value)) return createCallback(value, context, argCount); + if (_.isObject(value)) return _.matches(value); + return _.property(value); + }; + // Collection Functions // -------------------- // The cornerstone, an `each` implementation, aka `forEach`. - // Handles objects with the built-in `forEach`, arrays, and raw objects. - // Delegates to **ECMAScript 5**'s native `forEach` if available. - var each = _.each = _.forEach = function(obj, iterator, context) { + // Handles raw objects in addition to array-likes. Treats all + // sparse array-likes as if they were dense. + _.each = _.forEach = function(obj, iterator, context) { if (obj == null) return obj; - if (nativeForEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, length = obj.length; i < length; i++) { - if (iterator.call(context, obj[i], i, obj) === breaker) return; + iterator = createCallback(iterator, context); + var i, length = obj.length; + if (length === +length) { + for (i = 0; i < length; i++) { + iterator(obj[i], i, obj); } } else { var keys = _.keys(obj); - for (var i = 0, length = keys.length; i < length; i++) { - if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; + for (i = 0, length = keys.length; i < length; i++) { + iterator(obj[keys[i]], keys[i], obj); } } return obj; }; // Return the results of applying the iterator to each element. - // Delegates to **ECMAScript 5**'s native `map` if available. _.map = _.collect = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); - each(obj, function(value, index, list) { - results.push(iterator.call(context, value, index, list)); - }); + if (obj == null) return []; + iterator = lookupIterator(iterator, context); + var length = obj.length, + currentKey, keys; + if (length !== +length) { + keys = _.keys(obj); + length = keys.length; + } + var results = Array(length); + for (var index = 0; index < length; index++) { + currentKey = keys ? keys[index] : index; + results[index] = iterator(obj[currentKey], currentKey, obj); + } return results; }; var reduceError = 'Reduce of empty array with no initial value'; // **Reduce** builds up a single result from a list of values, aka `inject`, - // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. + // or `foldl`. _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { var initial = arguments.length > 2; if (obj == null) obj = []; - if (nativeReduce && obj.reduce === nativeReduce) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); - } - each(obj, function(value, index, list) { + iterator = createCallback(iterator, context, 4); + _.each(obj, function(value, index, list) { if (!initial) { memo = value; initial = true; } else { - memo = iterator.call(context, memo, value, index, list); + memo = iterator(memo, value, index, list); } }); - if (!initial) throw new TypeError(reduceError); + if (!initial) throw TypeError(reduceError); return memo; }; // The right-associative version of reduce, also known as `foldr`. - // Delegates to **ECMAScript 5**'s native `reduceRight` if available. _.reduceRight = _.foldr = function(obj, iterator, memo, context) { var initial = arguments.length > 2; if (obj == null) obj = []; - if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); - } var length = obj.length; + iterator = createCallback(iterator, context, 4); if (length !== +length) { var keys = _.keys(obj); length = keys.length; } - each(obj, function(value, index, list) { + _.each(obj, function(value, index, list) { index = keys ? keys[--length] : --length; if (!initial) { memo = obj[index]; initial = true; } else { - memo = iterator.call(context, memo, obj[index], index, list); + memo = iterator(memo, obj[index], index, list); } }); - if (!initial) throw new TypeError(reduceError); + if (!initial) throw TypeError(reduceError); return memo; }; // Return the first value which passes a truth test. Aliased as `detect`. _.find = _.detect = function(obj, predicate, context) { var result; - any(obj, function(value, index, list) { - if (predicate.call(context, value, index, list)) { + predicate = lookupIterator(predicate, context); + _.some(obj, function(value, index, list) { + if (predicate(value, index, list)) { result = value; return true; } @@ -165,61 +183,66 @@ }; // Return all the elements that pass a truth test. - // Delegates to **ECMAScript 5**'s native `filter` if available. // Aliased as `select`. _.filter = _.select = function(obj, predicate, context) { var results = []; if (obj == null) return results; - if (nativeFilter && obj.filter === nativeFilter) return obj.filter(predicate, context); - each(obj, function(value, index, list) { - if (predicate.call(context, value, index, list)) results.push(value); + predicate = lookupIterator(predicate, context); + _.each(obj, function(value, index, list) { + if (predicate(value, index, list)) results.push(value); }); return results; }; // Return all the elements for which a truth test fails. _.reject = function(obj, predicate, context) { - return _.filter(obj, function(value, index, list) { - return !predicate.call(context, value, index, list); - }, context); + return _.filter(obj, _.negate(lookupIterator(predicate)), context); }; // Determine whether all of the elements match a truth test. - // Delegates to **ECMAScript 5**'s native `every` if available. // Aliased as `all`. _.every = _.all = function(obj, predicate, context) { - predicate || (predicate = _.identity); - var result = true; - if (obj == null) return result; - if (nativeEvery && obj.every === nativeEvery) return obj.every(predicate, context); - each(obj, function(value, index, list) { - if (!(result = result && predicate.call(context, value, index, list))) return breaker; - }); - return !!result; + if (obj == null) return true; + predicate = lookupIterator(predicate, context); + var length = obj.length; + var index, currentKey, keys; + if (length !== +length) { + keys = _.keys(obj); + length = keys.length; + } + for (index = 0; index < length; index++) { + currentKey = keys ? keys[index] : index; + if (!predicate(obj[currentKey], currentKey, obj)) return false; + } + return true; }; // Determine if at least one element in the object matches a truth test. - // Delegates to **ECMAScript 5**'s native `some` if available. // Aliased as `any`. - var any = _.some = _.any = function(obj, predicate, context) { - predicate || (predicate = _.identity); - var result = false; - if (obj == null) return result; - if (nativeSome && obj.some === nativeSome) return obj.some(predicate, context); - each(obj, function(value, index, list) { - if (result || (result = predicate.call(context, value, index, list))) return breaker; - }); - return !!result; + // Determine if at least one element in the object matches a truth test. + // Aliased as `any`. + _.some = _.any = function(obj, predicate, context) { + if (obj == null) return false; + predicate = lookupIterator(predicate, context); + var length = obj.length; + var index, currentKey, keys; + if (length !== +length) { + keys = _.keys(obj); + length = keys.length; + } + for (index = 0; index < length; index++) { + currentKey = keys ? keys[index] : index; + if (predicate(obj[currentKey], currentKey, obj)) return true; + } + return false; }; // Determine if the array or object contains a given value (using `===`). // Aliased as `include`. _.contains = _.include = function(obj, target) { if (obj == null) return false; - if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - return any(obj, function(value) { - return value === target; - }); + if (obj.length !== +obj.length) obj = _.values(obj); + return _.indexOf(obj, target) >= 0; }; // Invoke a method (with arguments) on every item in a collection. @@ -248,37 +271,51 @@ return _.find(obj, _.matches(attrs)); }; - // Return the maximum element or (element-based computation). - // Can't optimize arrays of integers longer than 65,535 elements. - // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797) + // Return the maximum element (or element-based computation). _.max = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.max.apply(Math, obj); - } - var result = -Infinity, lastComputed = -Infinity; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - if (computed > lastComputed) { - result = value; - lastComputed = computed; + var result = -Infinity, lastComputed = -Infinity, + value, computed; + if (!iterator && _.isArray(obj)) { + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value > result) { + result = value; + } } - }); + } else { + iterator = lookupIterator(iterator, context); + _.each(obj, function(value, index, list) { + computed = iterator(value, index, list); + if (computed > lastComputed || computed === -Infinity && result === -Infinity) { + result = value; + lastComputed = computed; + } + }); + } return result; }; // Return the minimum element (or element-based computation). _.min = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.min.apply(Math, obj); - } - var result = Infinity, lastComputed = Infinity; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - if (computed < lastComputed) { - result = value; - lastComputed = computed; + var result = Infinity, lastComputed = Infinity, + value, computed; + if (!iterator && _.isArray(obj)) { + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value < result) { + result = value; + } } - }); + } else { + iterator = lookupIterator(iterator, context); + _.each(obj, function(value, index, list) { + computed = iterator(value, index, list); + if (computed < lastComputed || computed === Infinity && result === Infinity) { + result = value; + lastComputed = computed; + } + }); + } return result; }; @@ -288,7 +325,7 @@ var rand; var index = 0; var shuffled = []; - each(obj, function(value) { + _.each(obj, function(value) { rand = _.random(index++); shuffled[index - 1] = shuffled[rand]; shuffled[rand] = value; @@ -307,21 +344,14 @@ return _.shuffle(obj).slice(0, Math.max(0, n)); }; - // An internal function to generate lookup iterators. - var lookupIterator = function(value) { - if (value == null) return _.identity; - if (_.isFunction(value)) return value; - return _.property(value); - }; - // Sort the object's values by a criterion produced by an iterator. _.sortBy = function(obj, iterator, context) { - iterator = lookupIterator(iterator); + iterator = lookupIterator(iterator, context); return _.pluck(_.map(obj, function(value, index, list) { return { value: value, index: index, - criteria: iterator.call(context, value, index, list) + criteria: iterator(value, index, list) }; }).sort(function(left, right) { var a = left.criteria; @@ -338,10 +368,10 @@ var group = function(behavior) { return function(obj, iterator, context) { var result = {}; - iterator = lookupIterator(iterator); - each(obj, function(value, index) { - var key = iterator.call(context, value, index, obj); - behavior(result, key, value); + iterator = lookupIterator(iterator, context); + _.each(obj, function(value, index) { + var key = iterator(value, index, obj); + behavior(result, value, key); }); return result; }; @@ -349,32 +379,32 @@ // Groups the object's values by a criterion. Pass either a string attribute // to group by, or a function that returns the criterion. - _.groupBy = group(function(result, key, value) { - _.has(result, key) ? result[key].push(value) : result[key] = [value]; + _.groupBy = group(function(result, value, key) { + if (_.has(result, key)) result[key].push(value); else result[key] = [value]; }); // Indexes the object's values by a criterion, similar to `groupBy`, but for // when you know that your index values will be unique. - _.indexBy = group(function(result, key, value) { + _.indexBy = group(function(result, value, key) { result[key] = value; }); // Counts instances of an object that group by a certain criterion. Pass // either a string attribute to count by, or a function that returns the // criterion. - _.countBy = group(function(result, key) { - _.has(result, key) ? result[key]++ : result[key] = 1; + _.countBy = group(function(result, value, key) { + if (_.has(result, key)) result[key]++; else result[key] = 1; }); // Use a comparator function to figure out the smallest index at which // an object should be inserted so as to maintain order. Uses binary search. _.sortedIndex = function(array, obj, iterator, context) { - iterator = lookupIterator(iterator); - var value = iterator.call(context, obj); + iterator = lookupIterator(iterator, context, 1); + var value = iterator(obj); var low = 0, high = array.length; while (low < high) { var mid = (low + high) >>> 1; - iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; + if (iterator(array[mid]) < value) low = mid + 1; else high = mid; } return low; }; @@ -390,7 +420,18 @@ // Return the number of elements in an object. _.size = function(obj) { if (obj == null) return 0; - return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; + return obj.length === +obj.length ? obj.length : _.keys(obj).length; + }; + + // Split a collection into two arrays: one whose elements all satisfy the given + // predicate, and one whose elements all do not satisfy the predicate. + _.partition = function(obj, predicate, context) { + predicate = lookupIterator(predicate, context); + var pass = [], fail = []; + _.each(obj, function(value, key, obj) { + (predicate(value, key, obj) ? pass : fail).push(value); + }); + return [pass, fail]; }; // Array Functions @@ -401,7 +442,7 @@ // allows it to work with `_.map`. _.first = _.head = _.take = function(array, n, guard) { if (array == null) return void 0; - if ((n == null) || guard) return array[0]; + if (n == null || guard) return array[0]; if (n < 0) return []; return slice.call(array, 0, n); }; @@ -411,14 +452,14 @@ // the array, excluding the last N. The **guard** check allows it to work with // `_.map`. _.initial = function(array, n, guard) { - return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); + return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); }; // Get the last element of an array. Passing **n** will return the last N // values in the array. The **guard** check allows it to work with `_.map`. _.last = function(array, n, guard) { if (array == null) return void 0; - if ((n == null) || guard) return array[array.length - 1]; + if (n == null || guard) return array[array.length - 1]; return slice.call(array, Math.max(array.length - n, 0)); }; @@ -427,7 +468,7 @@ // the rest N values in the array. The **guard** // check allows it to work with `_.map`. _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, (n == null) || guard ? 1 : n); + return slice.call(array, n == null || guard ? 1 : n); }; // Trim out all falsy values from an array. @@ -436,23 +477,26 @@ }; // Internal implementation of a recursive `flatten` function. - var flatten = function(input, shallow, output) { + var flatten = function(input, shallow, strict, output) { if (shallow && _.every(input, _.isArray)) { return concat.apply(output, input); } - each(input, function(value) { - if (_.isArray(value) || _.isArguments(value)) { - shallow ? push.apply(output, value) : flatten(value, shallow, output); + for (var i = 0, length = input.length; i < length; i++) { + var value = input[i]; + if (!_.isArray(value) && !_.isArguments(value)) { + if (!strict) output.push(value); + } else if (shallow) { + push.apply(output, value); } else { - output.push(value); + flatten(value, shallow, strict, output); } - }); + } return output; }; // Flatten out an array, either recursively (by default), or just one level. _.flatten = function(array, shallow) { - return flatten(array, shallow, []); + return flatten(array, shallow, false, []); }; // Return a version of the array that does not contain the specified value(s). @@ -460,68 +504,71 @@ return _.difference(array, slice.call(arguments, 1)); }; - // Split an array into two arrays: one whose elements all satisfy the given - // predicate, and one whose elements all do not satisfy the predicate. - _.partition = function(array, predicate) { - var pass = [], fail = []; - each(array, function(elem) { - (predicate(elem) ? pass : fail).push(elem); - }); - return [pass, fail]; - }; - // Produce a duplicate-free version of the array. If the array has already // been sorted, you have the option of using a faster algorithm. // Aliased as `unique`. _.uniq = _.unique = function(array, isSorted, iterator, context) { + if (array == null) return []; if (_.isFunction(isSorted)) { context = iterator; iterator = isSorted; isSorted = false; } - var initial = iterator ? _.map(array, iterator, context) : array; - var results = []; + if (iterator) iterator = lookupIterator(iterator, context); + var result = []; var seen = []; - each(initial, function(value, index) { - if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { - seen.push(value); - results.push(array[index]); + for (var i = 0, length = array.length; i < length; i++) { + var value = array[i]; + if (iterator) value = iterator(value, i, array); + if (isSorted ? !i || seen !== value : !_.contains(seen, value)) { + if (isSorted) seen = value; + else seen.push(value); + result.push(array[i]); } - }); - return results; + } + return result; }; // Produce an array that contains the union: each distinct element from all of // the passed-in arrays. _.union = function() { - return _.uniq(_.flatten(arguments, true)); + return _.uniq(flatten(arguments, true, true, [])); }; // Produce an array that contains every item shared between all the // passed-in arrays. _.intersection = function(array) { - var rest = slice.call(arguments, 1); - return _.filter(_.uniq(array), function(item) { - return _.every(rest, function(other) { - return _.contains(other, item); - }); - }); + if (array == null) return []; + var result = []; + var argsLength = arguments.length; + for (var i = 0, length = array.length; i < length; i++) { + var item = array[i]; + if (_.contains(result, item)) continue; + for (var j = 1; j < argsLength; j++) { + if (!_.contains(arguments[j], item)) break; + } + if (j === argsLength) result.push(item); + } + return result; }; // Take the difference between one array and a number of other arrays. // Only the elements present in just the first array will remain. _.difference = function(array) { - var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); - return _.filter(array, function(value){ return !_.contains(rest, value); }); + var rest = flatten(slice.call(arguments, 1), true, true, []); + return _.filter(array, function(value){ + return !_.contains(rest, value); + }); }; // Zip together multiple lists into a single array -- elements that share // an index go together. - _.zip = function() { - var length = _.max(_.pluck(arguments, 'length').concat(0)); - var results = new Array(length); + _.zip = function(array) { + if (array == null) return []; + var length = _.max(arguments, 'length').length; + var results = Array(length); for (var i = 0; i < length; i++) { - results[i] = _.pluck(arguments, '' + i); + results[i] = _.pluck(arguments, i); } return results; }; @@ -542,10 +589,8 @@ return result; }; - // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), - // we need this function. Return the position of the first occurrence of an - // item in an array, or -1 if the item is not included in the array. - // Delegates to **ECMAScript 5**'s native `indexOf` if available. + // Return the position of the first occurrence of an item in an array, + // or -1 if the item is not included in the array. // If the array is large and already in sort order, pass `true` // for **isSorted** to use binary search. _.indexOf = function(array, item, isSorted) { @@ -553,26 +598,23 @@ var i = 0, length = array.length; if (isSorted) { if (typeof isSorted == 'number') { - i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted); + i = isSorted < 0 ? Math.max(0, length + isSorted) : isSorted; } else { i = _.sortedIndex(array, item); return array[i] === item ? i : -1; } } - if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); for (; i < length; i++) if (array[i] === item) return i; return -1; }; - // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. _.lastIndexOf = function(array, item, from) { if (array == null) return -1; - var hasIndex = from != null; - if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { - return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); + var idx = array.length; + if (typeof from == 'number') { + idx = from < 0 ? idx + from + 1 : Math.min(idx, from + 1); } - var i = (hasIndex ? from : array.length); - while (i--) if (array[i] === item) return i; + while (--idx >= 0) if (array[idx] === item) return idx; return -1; }; @@ -588,9 +630,9 @@ var length = Math.max(Math.ceil((stop - start) / step), 0); var idx = 0; - var range = new Array(length); + var range = Array(length); - while(idx < length) { + while (idx < length) { range[idx++] = start; start += step; } @@ -602,7 +644,7 @@ // ------------------ // Reusable constructor function for prototype setting. - var ctor = function(){}; + var Ctor = function(){}; // Create a function bound to a given object (assigning `this`, and arguments, // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if @@ -610,17 +652,18 @@ _.bind = function(func, context) { var args, bound; if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - if (!_.isFunction(func)) throw new TypeError; + if (!_.isFunction(func)) throw TypeError('Bind must be called on a function'); args = slice.call(arguments, 2); - return bound = function() { + bound = function() { if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); - ctor.prototype = func.prototype; - var self = new ctor; - ctor.prototype = null; + Ctor.prototype = func.prototype; + var self = new Ctor; + Ctor.prototype = null; var result = func.apply(self, args.concat(slice.call(arguments))); if (Object(result) === result) return result; return self; }; + return bound; }; // Partially apply a function by creating a version that has had some of its @@ -643,27 +686,34 @@ // are the method names to be bound. Useful for ensuring that all callbacks // defined on an object belong to it. _.bindAll = function(obj) { - var funcs = slice.call(arguments, 1); - if (funcs.length === 0) throw new Error('bindAll must be passed function names'); - each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); + var i, length = arguments.length, key; + if (length <= 1) throw Error('bindAll must be passed function names'); + for (i = 1; i < length; i++) { + key = arguments[i]; + obj[key] = _.bind(obj[key], obj); + } return obj; }; // Memoize an expensive function by storing its results. _.memoize = function(func, hasher) { - var memo = {}; - hasher || (hasher = _.identity); - return function() { - var key = hasher.apply(this, arguments); - return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); + var memoize = function(key) { + var cache = memoize.cache; + var address = hasher ? hasher.apply(this, arguments) : key; + if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); + return cache[key]; }; + memoize.cache = {}; + return memoize; }; // Delays a function for the given number of milliseconds, and then calls // it with the arguments supplied. _.delay = function(func, wait) { var args = slice.call(arguments, 2); - return setTimeout(function(){ return func.apply(null, args); }, wait); + return setTimeout(function(){ + return func.apply(null, args); + }, wait); }; // Defers a function, scheduling it to run after the current call stack has @@ -681,12 +731,12 @@ var context, args, result; var timeout = null; var previous = 0; - options || (options = {}); + if (!options) options = {}; var later = function() { previous = options.leading === false ? 0 : _.now(); timeout = null; result = func.apply(context, args); - context = args = null; + if (!timeout) context = args = null; }; return function() { var now = _.now(); @@ -694,12 +744,12 @@ var remaining = wait - (now - previous); context = this; args = arguments; - if (remaining <= 0) { + if (remaining <= 0 || remaining > wait) { clearTimeout(timeout); timeout = null; previous = now; result = func.apply(context, args); - context = args = null; + if (!timeout) context = args = null; } else if (!timeout && options.trailing !== false) { timeout = setTimeout(later, remaining); } @@ -716,13 +766,14 @@ var later = function() { var last = _.now() - timestamp; - if (last < wait) { + + if (last < wait && last > 0) { timeout = setTimeout(later, wait - last); } else { timeout = null; if (!immediate) { result = func.apply(context, args); - context = args = null; + if (!timeout) context = args = null; } } }; @@ -732,9 +783,7 @@ args = arguments; timestamp = _.now(); var callNow = immediate && !timeout; - if (!timeout) { - timeout = setTimeout(later, wait); - } + if (!timeout) timeout = setTimeout(later, wait); if (callNow) { result = func.apply(context, args); context = args = null; @@ -744,19 +793,6 @@ }; }; - // Returns a function that will be executed at most one time, no matter how - // often you call it. Useful for lazy initialization. - _.once = function(func) { - var ran = false, memo; - return function() { - if (ran) return memo; - ran = true; - memo = func.apply(this, arguments); - func = null; - return memo; - }; - }; - // Returns the first function passed as an argument to the second, // allowing you to adjust arguments, run code before and after, and // conditionally execute the original function. @@ -764,16 +800,23 @@ return _.partial(wrapper, func); }; + // Returns a negated version of the passed-in predicate. + _.negate = function(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; + }; + // Returns a function that is the composition of a list of functions, each // consuming the return value of the function that follows. _.compose = function() { - var funcs = arguments; + var args = arguments; + var start = args.length - 1; return function() { - var args = arguments; - for (var i = funcs.length - 1; i >= 0; i--) { - args = [funcs[i].apply(this, args)]; - } - return args[0]; + var i = start; + var result = args[start].apply(this, arguments); + while (i--) result = args[i].call(this, result); + return result; }; }; @@ -786,6 +829,22 @@ }; }; + // Returns a function that will only be executed before being called N times. + _.before = function(times, func) { + var memo; + return function() { + if (--times > 0) { + memo = func.apply(this, arguments); + } + else func = null; + return memo; + }; + }; + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + _.once = _.partial(_.before, 2); + // Object Functions // ---------------- @@ -803,7 +862,7 @@ _.values = function(obj) { var keys = _.keys(obj); var length = keys.length; - var values = new Array(length); + var values = Array(length); for (var i = 0; i < length; i++) { values[i] = obj[keys[i]]; } @@ -814,7 +873,7 @@ _.pairs = function(obj) { var keys = _.keys(obj); var length = keys.length; - var pairs = new Array(length); + var pairs = Array(length); for (var i = 0; i < length; i++) { pairs[i] = [keys[i], obj[keys[i]]]; } @@ -843,45 +902,60 @@ // Extend a given object with all the properties in passed-in object(s). _.extend = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - obj[prop] = source[prop]; - } + if (!_.isObject(obj)) return obj; + var source, prop; + for (var i = 1, length = arguments.length; i < length; i++) { + source = arguments[i]; + for (prop in source) { + obj[prop] = source[prop]; } - }); + } return obj; }; // Return a copy of the object only containing the whitelisted properties. - _.pick = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - each(keys, function(key) { - if (key in obj) copy[key] = obj[key]; - }); - return copy; + _.pick = function(obj, iterator, context) { + var result = {}, key; + if (obj == null) return result; + if (_.isFunction(iterator)) { + iterator = createCallback(iterator, context); + for (key in obj) { + var value = obj[key]; + if (iterator(value, key, obj)) result[key] = value; + } + } else { + var keys = concat.apply([], slice.call(arguments, 1)); + obj = Object(obj); + for (var i = 0, length = keys.length; i < length; i++) { + key = keys[i]; + if (key in obj) result[key] = obj[key]; + } + } + return result; }; // Return a copy of the object without the blacklisted properties. - _.omit = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - for (var key in obj) { - if (!_.contains(keys, key)) copy[key] = obj[key]; + _.omit = function(obj, iterator, context) { + if (_.isFunction(iterator)) { + iterator = _.negate(iterator); + } else { + var keys = _.map(concat.apply([], slice.call(arguments, 1)), String); + iterator = function(value, key) { + return !_.contains(keys, key); + }; } - return copy; + return _.pick(obj, iterator, context); }; // Fill in a given object with default properties. _.defaults = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - if (obj[prop] === void 0) obj[prop] = source[prop]; - } + if (!_.isObject(obj)) return obj; + for (var i = 1, length = arguments.length; i < length; i++) { + var source = arguments[i]; + for (var prop in source) { + if (obj[prop] === void 0) obj[prop] = source[prop]; } - }); + } return obj; }; @@ -903,7 +977,7 @@ var eq = function(a, b, aStack, bStack) { // Identical objects are equal. `0 === -0`, but they aren't identical. // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). - if (a === b) return a !== 0 || 1 / a == 1 / b; + if (a === b) return a !== 0 || 1 / a === 1 / b; // A strict comparison is necessary because `null == undefined`. if (a == null || b == null) return a === b; // Unwrap any wrapped objects. @@ -911,29 +985,27 @@ if (b instanceof _) b = b._wrapped; // Compare `[[Class]]` names. var className = toString.call(a); - if (className != toString.call(b)) return false; + if (className !== toString.call(b)) return false; switch (className) { - // Strings, numbers, dates, and booleans are compared by value. + // Strings, numbers, regular expressions, dates, and booleans are compared by value. + case '[object RegExp]': + // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') case '[object String]': // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is // equivalent to `new String("5")`. - return a == String(b); + return '' + a === '' + b; case '[object Number]': - // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for - // other numeric values. - return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); + // `NaN`s are equivalent, but non-reflexive. + // Object(NaN) is equivalent to NaN + if (a != +a) return b != +b; + // An `egal` comparison is performed for other numeric values. + return a == 0 ? 1 / a == 1 / b : a == +b; case '[object Date]': case '[object Boolean]': // Coerce dates and booleans to numeric primitive values. Dates are compared by their // millisecond representations. Note that invalid dates with millisecond representations // of `NaN` are not equivalent. - return +a == +b; - // RegExps are compared by their source patterns and flags. - case '[object RegExp]': - return a.source == b.source && - a.global == b.global && - a.multiline == b.multiline && - a.ignoreCase == b.ignoreCase; + return +a === +b; } if (typeof a != 'object' || typeof b != 'object') return false; // Assume equality for cyclic structures. The algorithm for detecting cyclic @@ -942,25 +1014,29 @@ while (length--) { // Linear search. Performance is inversely proportional to the number of // unique nested structures. - if (aStack[length] == a) return bStack[length] == b; + if (aStack[length] === a) return bStack[length] === b; } // Objects with different constructors are not equivalent, but `Object`s // from different frames are. var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && - _.isFunction(bCtor) && (bCtor instanceof bCtor)) - && ('constructor' in a && 'constructor' in b)) { + if ( + aCtor !== bCtor && + // Handle Object.create(x) cases + 'constructor' in a && 'constructor' in b && + !(_.isFunction(aCtor) && aCtor instanceof aCtor && + _.isFunction(bCtor) && bCtor instanceof bCtor) + ) { return false; } // Add the first object to the stack of traversed objects. aStack.push(a); bStack.push(b); - var size = 0, result = true; + var size, result; // Recursively compare objects and arrays. - if (className == '[object Array]') { + if (className === '[object Array]') { // Compare array lengths to determine if a deep comparison is necessary. size = a.length; - result = size == b.length; + result = size === b.length; if (result) { // Deep compare the contents, ignoring non-numeric properties. while (size--) { @@ -969,20 +1045,16 @@ } } else { // Deep compare objects. - for (var key in a) { - if (_.has(a, key)) { - // Count the expected number of properties. - size++; - // Deep compare each member. - if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; - } - } - // Ensure that both objects contain the same number of properties. + var keys = _.keys(a), key; + size = keys.length; + // Ensure that both objects contain the same number of properties before comparing deep equality. + result = _.keys(b).length == size; if (result) { - for (key in b) { - if (_.has(b, key) && !(size--)) break; + while (size--) { + // Deep compare each member + key = keys[size]; + if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; } - result = !size; } } // Remove the first object from the stack of traversed objects. @@ -1000,7 +1072,7 @@ // An "empty" object has no enumerable own-properties. _.isEmpty = function(obj) { if (obj == null) return true; - if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; + if (_.isArray(obj) || _.isString(obj) || _.isArguments(obj)) return obj.length === 0; for (var key in obj) if (_.has(obj, key)) return false; return true; }; @@ -1013,7 +1085,7 @@ // Is a given value an array? // Delegates to ECMA5's native Array.isArray _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) == '[object Array]'; + return toString.call(obj) === '[object Array]'; }; // Is a given variable an object? @@ -1022,9 +1094,9 @@ }; // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. - each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { + _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { _['is' + name] = function(obj) { - return toString.call(obj) == '[object ' + name + ']'; + return toString.call(obj) === '[object ' + name + ']'; }; }); @@ -1032,12 +1104,12 @@ // there isn't any inspectable "Arguments" type. if (!_.isArguments(arguments)) { _.isArguments = function(obj) { - return !!(obj && _.has(obj, 'callee')); + return _.has(obj, 'callee'); }; } // Optimize `isFunction` if appropriate. - if (typeof (/./) !== 'function') { + if (typeof /./ !== 'function') { _.isFunction = function(obj) { return typeof obj === 'function'; }; @@ -1050,12 +1122,12 @@ // Is the given value `NaN`? (NaN is the only number which does not equal itself). _.isNaN = function(obj) { - return _.isNumber(obj) && obj != +obj; + return _.isNumber(obj) && obj !== +obj; }; // Is a given value a boolean? _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; + return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; }; // Is a given value equal to null? @@ -1071,7 +1143,7 @@ // Shortcut function for checking if an object has a given property directly // on itself (in other words, not on a prototype). _.has = function(obj, key) { - return hasOwnProperty.call(obj, key); + return obj != null && hasOwnProperty.call(obj, key); }; // Utility Functions @@ -1090,11 +1162,13 @@ }; _.constant = function(value) { - return function () { + return function() { return value; }; }; + _.noop = function(){}; + _.property = function(key) { return function(obj) { return obj[key]; @@ -1104,19 +1178,18 @@ // Returns a predicate for checking whether an object has a given set of `key:value` pairs. _.matches = function(attrs) { return function(obj) { - if (obj === attrs) return true; //avoid comparing an object to itself. - for (var key in attrs) { - if (attrs[key] !== obj[key]) - return false; - } + if (obj == null) return _.isEmpty(attrs); + if (obj === attrs) return true; + for (var key in attrs) if (attrs[key] !== obj[key]) return false; return true; - } + }; }; // Run a function **n** times. _.times = function(n, iterator, context) { var accum = Array(Math.max(0, n)); - for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); + iterator = createCallback(iterator, context, 1); + for (var i = 0; i < n; i++) accum[i] = iterator(i); return accum; }; @@ -1130,7 +1203,9 @@ }; // A (possibly faster) way to get the current timestamp as an integer. - _.now = Date.now || function() { return new Date().getTime(); }; + _.now = Date.now || function() { + return new Date().getTime(); + }; // List of HTML entities for escaping. var entityMap = { @@ -1146,8 +1221,8 @@ // Regexes containing the keys and values listed immediately above. var entityRegexes = { - escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), - unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') + escape: RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), + unescape: RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') }; // Functions for escaping and unescaping strings to/from HTML interpolation. @@ -1165,19 +1240,7 @@ _.result = function(object, property) { if (object == null) return void 0; var value = object[property]; - return _.isFunction(value) ? value.call(object) : value; - }; - - // Add your own custom functions to the Underscore object. - _.mixin = function(obj) { - each(_.functions(obj), function(name) { - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [this._wrapped]; - push.apply(args, arguments); - return result.call(this, func.apply(_, args)); - }; - }); + return _.isFunction(value) ? object[property]() : value; }; // Generate a unique integer id (unique within the entire client session). @@ -1208,22 +1271,24 @@ '\\': '\\', '\r': 'r', '\n': 'n', - '\t': 't', '\u2028': 'u2028', '\u2029': 'u2029' }; - var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; + var escaper = /\\|'|\r|\n|\u2028|\u2029/g; + + var escapeChar = function(match) { + return '\\' + escapes[match]; + }; // JavaScript micro-templating, similar to John Resig's implementation. // Underscore templating handles arbitrary delimiters, preserves whitespace, // and correctly escapes quotes within interpolated code. _.template = function(text, data, settings) { - var render; settings = _.defaults({}, settings, _.templateSettings); // Combine delimiters into one regular expression via alternation. - var matcher = new RegExp([ + var matcher = RegExp([ (settings.escape || noMatch).source, (settings.interpolate || noMatch).source, (settings.evaluate || noMatch).source @@ -1233,19 +1298,18 @@ var index = 0; var source = "__p+='"; text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset) - .replace(escaper, function(match) { return '\\' + escapes[match]; }); + source += text.slice(index, offset).replace(escaper, escapeChar); + index = offset + match.length; if (escape) { source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } - if (interpolate) { + } else if (interpolate) { source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } - if (evaluate) { + } else if (evaluate) { source += "';\n" + evaluate + "\n__p+='"; } - index = offset + match.length; + + // Adobe VMs need the match returned to produce the correct offest. return match; }); source += "';\n"; @@ -1255,10 +1319,10 @@ source = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + - source + "return __p;\n"; + source + 'return __p;\n'; try { - render = new Function(settings.variable || 'obj', '_', source); + var render = Function(settings.variable || 'obj', '_', source); } catch (e) { e.source = source; throw e; @@ -1269,15 +1333,18 @@ return render.call(this, data, _); }; - // Provide the compiled function source as a convenience for precompilation. - template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; + // Provide the compiled source as a convenience for precompilation. + var argument = settings.variable || 'obj'; + template.source = 'function(' + argument + '){\n' + source + '}'; return template; }; - // Add a "chain" function, which will delegate to the wrapper. + // Add a "chain" function. Start chaining a wrapped Underscore object. _.chain = function(obj) { - return _(obj).chain(); + var instance = _(obj); + instance._chain = true; + return instance; }; // OOP @@ -1291,42 +1358,44 @@ return this._chain ? _(obj).chain() : obj; }; + // Add your own custom functions to the Underscore object. + _.mixin = function(obj) { + _.each(_.functions(obj), function(name) { + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [this._wrapped]; + push.apply(args, arguments); + return result.call(this, func.apply(_, args)); + }; + }); + }; + // Add all of the Underscore functions to the wrapper object. _.mixin(_); // Add all mutator Array functions to the wrapper. - each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { + _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { var method = ArrayProto[name]; _.prototype[name] = function() { var obj = this._wrapped; method.apply(obj, arguments); - if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; + if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0]; return result.call(this, obj); }; }); // Add all accessor Array functions to the wrapper. - each(['concat', 'join', 'slice'], function(name) { + _.each(['concat', 'join', 'slice'], function(name) { var method = ArrayProto[name]; _.prototype[name] = function() { return result.call(this, method.apply(this._wrapped, arguments)); }; }); - _.extend(_.prototype, { - - // Start chaining a wrapped Underscore object. - chain: function() { - this._chain = true; - return this; - }, - - // Extracts the result from a wrapped and chained object. - value: function() { - return this._wrapped; - } - - }); + // Extracts the result from a wrapped and chained object. + _.prototype.value = function() { + return this._wrapped; + }; // AMD registration happens at the end for compatibility with AMD loaders // that may not enforce next-turn semantics on modules. Even though general @@ -1340,4 +1409,4 @@ return _; }); } -}).call(this); +}.call(this)); diff --git a/node_modules/columnify/node_modules/wcwidth.js/package.json b/node_modules/columnify/node_modules/wcwidth.js/package.json index 104b70763..9542cc97d 100644 --- a/node_modules/columnify/node_modules/wcwidth.js/package.json +++ b/node_modules/columnify/node_modules/wcwidth.js/package.json @@ -41,7 +41,7 @@ "shasum": "44298a7c899c17501990fdaddd76ef6bd081be75", "tarball": "http://registry.npmjs.org/wcwidth.js/-/wcwidth.js-0.0.4.tgz" }, - "_from": "wcwidth.js@~0.0.4", + "_from": "wcwidth.js@>=0.0.4-0 <0.1.0-0", "_npmVersion": "1.3.11", "_npmUser": { "name": "mycoboco", diff --git a/node_modules/init-package-json/package.json b/node_modules/init-package-json/package.json index 9b787e08b..38ca8ff9b 100644 --- a/node_modules/init-package-json/package.json +++ b/node_modules/init-package-json/package.json @@ -1,6 +1,6 @@ { "name": "init-package-json", - "version": "0.1.1", + "version": "0.1.2", "main": "init-package-json.js", "scripts": { "test": "tap test/*.js" @@ -21,7 +21,7 @@ "promzard": "~0.2.0", "read": "~1.0.1", "read-package-json": "1", - "semver": "2.x" + "semver": "2.x || 3.x" }, "devDependencies": { "tap": "~0.2.5", @@ -39,12 +39,12 @@ ], "readme": "# init-package-json\n\nA node module to get your node module started.\n\n## Usage\n\n```javascript\nvar init = require('init-package-json')\nvar path = require('path')\n\n// a path to a promzard module. In the event that this file is\n// not found, one will be provided for you.\nvar initFile = path.resolve(process.env.HOME, '.npm-init')\n\n// the dir where we're doin stuff.\nvar dir = process.cwd()\n\n// extra stuff that gets put into the PromZard module's context.\n// In npm, this is the resolved config object. Exposed as 'config'\n// Optional.\nvar configData = { some: 'extra stuff' }\n\n// Any existing stuff from the package.json file is also exposed in the\n// PromZard module as the `package` object. There will also be free\n// vars for:\n// * `filename` path to the package.json file\n// * `basename` the tip of the package dir\n// * `dirname` the parent of the package dir\n\ninit(dir, initFile, configData, function (er, data) {\n // the data's already been written to {dir}/package.json\n // now you can do stuff with it\n})\n```\n\nOr from the command line:\n\n```\n$ npm-init\n```\n\nSee [PromZard](https://github.com/isaacs/promzard) for details about\nwhat can go in the config file.\n", "readmeFilename": "README.md", - "gitHead": "7b37987583b1bfda997818be09f9c0cc9132f4fd", + "gitHead": "fb789da2e92adc77c7161e442c716577f662fc08", "bugs": { "url": "https://github.com/isaacs/init-package-json/issues" }, "homepage": "https://github.com/isaacs/init-package-json", - "_id": "init-package-json@0.1.1", - "_shasum": "2b37bd82ca9ebdbf9df50238b850385e898a35c1", - "_from": "init-package-json@latest" + "_id": "init-package-json@0.1.2", + "_shasum": "9e232ccae0d5cf712cd7773b0f1fcd59b7edc2da", + "_from": "init-package-json@>=0.1.1-0 <0.2.0-0" } diff --git a/node_modules/node-gyp/node_modules/.bin/nopt b/node_modules/node-gyp/node_modules/.bin/nopt new file mode 120000 index 000000000..6b6566ea7 --- /dev/null +++ b/node_modules/node-gyp/node_modules/.bin/nopt @@ -0,0 +1 @@ +../nopt/bin/nopt.js
\ No newline at end of file diff --git a/node_modules/node-gyp/node_modules/.bin/semver b/node_modules/node-gyp/node_modules/.bin/semver new file mode 120000 index 000000000..317eb293d --- /dev/null +++ b/node_modules/node-gyp/node_modules/.bin/semver @@ -0,0 +1 @@ +../semver/bin/semver
\ No newline at end of file diff --git a/node_modules/node-gyp/node_modules/glob/.npmignore b/node_modules/node-gyp/node_modules/glob/.npmignore new file mode 100644 index 000000000..2af4b71c9 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/.npmignore @@ -0,0 +1,2 @@ +.*.swp +test/a/ diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/.travis.yml b/node_modules/node-gyp/node_modules/glob/.travis.yml index 84fd7ca24..baa0031d5 100644 --- a/node_modules/npm-registry-client/node_modules/mkdirp/.travis.yml +++ b/node_modules/node-gyp/node_modules/glob/.travis.yml @@ -1,5 +1,3 @@ language: node_js node_js: - - 0.6 - 0.8 - - 0.9 diff --git a/node_modules/node-gyp/node_modules/glob/LICENSE b/node_modules/node-gyp/node_modules/glob/LICENSE new file mode 100644 index 000000000..0c44ae716 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Isaac Z. Schlueter ("Author") +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. 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 AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS +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. diff --git a/node_modules/node-gyp/node_modules/glob/README.md b/node_modules/node-gyp/node_modules/glob/README.md new file mode 100644 index 000000000..cc6916451 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/README.md @@ -0,0 +1,250 @@ +# Glob + +Match files using the patterns the shell uses, like stars and stuff. + +This is a glob implementation in JavaScript. It uses the `minimatch` +library to do its matching. + +## Attention: node-glob users! + +The API has changed dramatically between 2.x and 3.x. This library is +now 100% JavaScript, and the integer flags have been replaced with an +options object. + +Also, there's an event emitter class, proper tests, and all the other +things you've come to expect from node modules. + +And best of all, no compilation! + +## Usage + +```javascript +var glob = require("glob") + +// options is optional +glob("**/*.js", options, function (er, files) { + // files is an array of filenames. + // If the `nonull` option is set, and nothing + // was found, then files is ["**/*.js"] + // er is an error object or null. +}) +``` + +## Features + +Please see the [minimatch +documentation](https://github.com/isaacs/minimatch) for more details. + +Supports these glob features: + +* Brace Expansion +* Extended glob matching +* "Globstar" `**` matching + +See: + +* `man sh` +* `man bash` +* `man 3 fnmatch` +* `man 5 gitignore` +* [minimatch documentation](https://github.com/isaacs/minimatch) + +## glob(pattern, [options], cb) + +* `pattern` {String} Pattern to be matched +* `options` {Object} +* `cb` {Function} + * `err` {Error | null} + * `matches` {Array<String>} filenames found matching the pattern + +Perform an asynchronous glob search. + +## glob.sync(pattern, [options]) + +* `pattern` {String} Pattern to be matched +* `options` {Object} +* return: {Array<String>} filenames found matching the pattern + +Perform a synchronous glob search. + +## Class: glob.Glob + +Create a Glob object by instanting the `glob.Glob` class. + +```javascript +var Glob = require("glob").Glob +var mg = new Glob(pattern, options, cb) +``` + +It's an EventEmitter, and starts walking the filesystem to find matches +immediately. + +### new glob.Glob(pattern, [options], [cb]) + +* `pattern` {String} pattern to search for +* `options` {Object} +* `cb` {Function} Called when an error occurs, or matches are found + * `err` {Error | null} + * `matches` {Array<String>} filenames found matching the pattern + +Note that if the `sync` flag is set in the options, then matches will +be immediately available on the `g.found` member. + +### Properties + +* `minimatch` The minimatch object that the glob uses. +* `options` The options object passed in. +* `error` The error encountered. When an error is encountered, the + glob object is in an undefined state, and should be discarded. +* `aborted` Boolean which is set to true when calling `abort()`. There + is no way at this time to continue a glob search after aborting, but + you can re-use the statCache to avoid having to duplicate syscalls. +* `statCache` Collection of all the stat results the glob search + performed. +* `cache` Convenience object. Each field has the following possible + values: + * `false` - Path does not exist + * `true` - Path exists + * `1` - Path exists, and is not a directory + * `2` - Path exists, and is a directory + * `[file, entries, ...]` - Path exists, is a directory, and the + array value is the results of `fs.readdir` + +### Events + +* `end` When the matching is finished, this is emitted with all the + matches found. If the `nonull` option is set, and no match was found, + then the `matches` list contains the original pattern. The matches + are sorted, unless the `nosort` flag is set. +* `match` Every time a match is found, this is emitted with the matched. +* `error` Emitted when an unexpected error is encountered, or whenever + any fs error occurs if `options.strict` is set. +* `abort` When `abort()` is called, this event is raised. + +### Methods + +* `abort` Stop the search. + +### Options + +All the options that can be passed to Minimatch can also be passed to +Glob to change pattern matching behavior. Also, some have been added, +or have glob-specific ramifications. + +All options are false by default, unless otherwise noted. + +All options are added to the glob object, as well. + +* `cwd` The current working directory in which to search. Defaults + to `process.cwd()`. +* `root` The place where patterns starting with `/` will be mounted + onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix + systems, and `C:\` or some such on Windows.) +* `dot` Include `.dot` files in normal matches and `globstar` matches. + Note that an explicit dot in a portion of the pattern will always + match dot files. +* `nomount` By default, a pattern starting with a forward-slash will be + "mounted" onto the root setting, so that a valid filesystem path is + returned. Set this flag to disable that behavior. +* `mark` Add a `/` character to directory matches. Note that this + requires additional stat calls. +* `nosort` Don't sort the results. +* `stat` Set to true to stat *all* results. This reduces performance + somewhat, and is completely unnecessary, unless `readdir` is presumed + to be an untrustworthy indicator of file existence. It will cause + ELOOP to be triggered one level sooner in the case of cyclical + symbolic links. +* `silent` When an unusual error is encountered + when attempting to read a directory, a warning will be printed to + stderr. Set the `silent` option to true to suppress these warnings. +* `strict` When an unusual error is encountered + when attempting to read a directory, the process will just continue on + in search of other matches. Set the `strict` option to raise an error + in these cases. +* `cache` See `cache` property above. Pass in a previously generated + cache object to save some fs calls. +* `statCache` A cache of results of filesystem information, to prevent + unnecessary stat calls. While it should not normally be necessary to + set this, you may pass the statCache from one glob() call to the + options object of another, if you know that the filesystem will not + change between calls. (See "Race Conditions" below.) +* `sync` Perform a synchronous glob search. +* `nounique` In some cases, brace-expanded patterns can result in the + same file showing up multiple times in the result set. By default, + this implementation prevents duplicates in the result set. + Set this flag to disable that behavior. +* `nonull` Set to never return an empty set, instead returning a set + containing the pattern itself. This is the default in glob(3). +* `nocase` Perform a case-insensitive match. Note that case-insensitive + filesystems will sometimes result in glob returning results that are + case-insensitively matched anyway, since readdir and stat will not + raise an error. +* `debug` Set to enable debug logging in minimatch and glob. +* `globDebug` Set to enable debug logging in glob, but not minimatch. + +## Comparisons to other fnmatch/glob implementations + +While strict compliance with the existing standards is a worthwhile +goal, some discrepancies exist between node-glob and other +implementations, and are intentional. + +If the pattern starts with a `!` character, then it is negated. Set the +`nonegate` flag to suppress this behavior, and treat leading `!` +characters normally. This is perhaps relevant if you wish to start the +pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` +characters at the start of a pattern will negate the pattern multiple +times. + +If a pattern starts with `#`, then it is treated as a comment, and +will not match anything. Use `\#` to match a literal `#` at the +start of a line, or set the `nocomment` flag to suppress this behavior. + +The double-star character `**` is supported by default, unless the +`noglobstar` flag is set. This is supported in the manner of bsdglob +and bash 4.1, where `**` only has special significance if it is the only +thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but +`a/**b` will not. + +If an escaped pattern has no matches, and the `nonull` flag is set, +then glob returns the pattern as-provided, rather than +interpreting the character escapes. For example, +`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than +`"*a?"`. This is akin to setting the `nullglob` option in bash, except +that it does not resolve escaped pattern characters. + +If brace expansion is not disabled, then it is performed before any +other interpretation of the glob pattern. Thus, a pattern like +`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded +**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are +checked for validity. Since those two are valid, matching proceeds. + +## Windows + +**Please only use forward-slashes in glob expressions.** + +Though windows uses either `/` or `\` as its path separator, only `/` +characters are used by this glob implementation. You must use +forward-slashes **only** in glob expressions. Back-slashes will always +be interpreted as escape characters, not path separators. + +Results from absolute patterns such as `/foo/*` are mounted onto the +root setting using `path.join`. On windows, this will by default result +in `/foo/*` matching `C:\foo\bar.txt`. + +## Race Conditions + +Glob searching, by its very nature, is susceptible to race conditions, +since it relies on directory walking and such. + +As a result, it is possible that a file that exists when glob looks for +it may have been deleted or modified by the time it returns the result. + +As part of its internal implementation, this program caches all stat +and readdir calls that it makes, in order to cut down on system +overhead. However, this also makes it even more susceptible to races, +especially if the cache or statCache objects are reused between glob +calls. + +Users are thus advised not to use a glob result as a guarantee of +filesystem state in the face of rapid changes. For the vast majority +of operations, this is never a problem. diff --git a/node_modules/node-gyp/node_modules/glob/examples/g.js b/node_modules/node-gyp/node_modules/glob/examples/g.js new file mode 100644 index 000000000..be122df00 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/examples/g.js @@ -0,0 +1,9 @@ +var Glob = require("../").Glob + +var pattern = "test/a/**/[cg]/../[cg]" +console.log(pattern) + +var mg = new Glob(pattern, {mark: true, sync:true}, function (er, matches) { + console.log("matches", matches) +}) +console.log("after") diff --git a/node_modules/node-gyp/node_modules/glob/examples/usr-local.js b/node_modules/node-gyp/node_modules/glob/examples/usr-local.js new file mode 100644 index 000000000..327a425e4 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/examples/usr-local.js @@ -0,0 +1,9 @@ +var Glob = require("../").Glob + +var pattern = "{./*/*,/*,/usr/local/*}" +console.log(pattern) + +var mg = new Glob(pattern, {mark: true}, function (er, matches) { + console.log("matches", matches) +}) +console.log("after") diff --git a/node_modules/node-gyp/node_modules/glob/glob.js b/node_modules/node-gyp/node_modules/glob/glob.js new file mode 100644 index 000000000..f646c4483 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/glob.js @@ -0,0 +1,728 @@ +// Approach: +// +// 1. Get the minimatch set +// 2. For each pattern in the set, PROCESS(pattern) +// 3. Store matches per-set, then uniq them +// +// PROCESS(pattern) +// Get the first [n] items from pattern that are all strings +// Join these together. This is PREFIX. +// If there is no more remaining, then stat(PREFIX) and +// add to matches if it succeeds. END. +// readdir(PREFIX) as ENTRIES +// If fails, END +// If pattern[n] is GLOBSTAR +// // handle the case where the globstar match is empty +// // by pruning it out, and testing the resulting pattern +// PROCESS(pattern[0..n] + pattern[n+1 .. $]) +// // handle other cases. +// for ENTRY in ENTRIES (not dotfiles) +// // attach globstar + tail onto the entry +// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $]) +// +// else // not globstar +// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) +// Test ENTRY against pattern[n] +// If fails, continue +// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) +// +// Caveat: +// Cache all stats and readdirs results to minimize syscall. Since all +// we ever care about is existence and directory-ness, we can just keep +// `true` for files, and [children,...] for directories, or `false` for +// things that don't exist. + + + +module.exports = glob + +var fs = require("fs") +, minimatch = require("minimatch") +, Minimatch = minimatch.Minimatch +, inherits = require("inherits") +, EE = require("events").EventEmitter +, path = require("path") +, isDir = {} +, assert = require("assert").ok + +function glob (pattern, options, cb) { + if (typeof options === "function") cb = options, options = {} + if (!options) options = {} + + if (typeof options === "number") { + deprecated() + return + } + + var g = new Glob(pattern, options, cb) + return g.sync ? g.found : g +} + +glob.fnmatch = deprecated + +function deprecated () { + throw new Error("glob's interface has changed. Please see the docs.") +} + +glob.sync = globSync +function globSync (pattern, options) { + if (typeof options === "number") { + deprecated() + return + } + + options = options || {} + options.sync = true + return glob(pattern, options) +} + +this._processingEmitQueue = false + +glob.Glob = Glob +inherits(Glob, EE) +function Glob (pattern, options, cb) { + if (!(this instanceof Glob)) { + return new Glob(pattern, options, cb) + } + + if (typeof options === "function") { + cb = options + options = null + } + + if (typeof cb === "function") { + this.on("error", cb) + this.on("end", function (matches) { + cb(null, matches) + }) + } + + options = options || {} + + this._endEmitted = false + this.EOF = {} + this._emitQueue = [] + + this.paused = false + this._processingEmitQueue = false + + this.maxDepth = options.maxDepth || 1000 + this.maxLength = options.maxLength || Infinity + this.cache = options.cache || {} + this.statCache = options.statCache || {} + + this.changedCwd = false + var cwd = process.cwd() + if (!options.hasOwnProperty("cwd")) this.cwd = cwd + else { + this.cwd = options.cwd + this.changedCwd = path.resolve(options.cwd) !== cwd + } + + this.root = options.root || path.resolve(this.cwd, "/") + this.root = path.resolve(this.root) + if (process.platform === "win32") + this.root = this.root.replace(/\\/g, "/") + + this.nomount = !!options.nomount + + if (!pattern) { + throw new Error("must provide pattern") + } + + // base-matching: just use globstar for that. + if (options.matchBase && -1 === pattern.indexOf("/")) { + if (options.noglobstar) { + throw new Error("base matching requires globstar") + } + pattern = "**/" + pattern + } + + this.strict = options.strict !== false + this.dot = !!options.dot + this.mark = !!options.mark + this.sync = !!options.sync + this.nounique = !!options.nounique + this.nonull = !!options.nonull + this.nosort = !!options.nosort + this.nocase = !!options.nocase + this.stat = !!options.stat + + this.debug = !!options.debug || !!options.globDebug + if (this.debug) + this.log = console.error + + this.silent = !!options.silent + + var mm = this.minimatch = new Minimatch(pattern, options) + this.options = mm.options + pattern = this.pattern = mm.pattern + + this.error = null + this.aborted = false + + // list of all the patterns that ** has resolved do, so + // we can avoid visiting multiple times. + this._globstars = {} + + EE.call(this) + + // process each pattern in the minimatch set + var n = this.minimatch.set.length + + // The matches are stored as {<filename>: true,...} so that + // duplicates are automagically pruned. + // Later, we do an Object.keys() on these. + // Keep them as a list so we can fill in when nonull is set. + this.matches = new Array(n) + + this.minimatch.set.forEach(iterator.bind(this)) + function iterator (pattern, i, set) { + this._process(pattern, 0, i, function (er) { + if (er) this.emit("error", er) + if (-- n <= 0) this._finish() + }) + } +} + +Glob.prototype.log = function () {} + +Glob.prototype._finish = function () { + assert(this instanceof Glob) + + var nou = this.nounique + , all = nou ? [] : {} + + for (var i = 0, l = this.matches.length; i < l; i ++) { + var matches = this.matches[i] + this.log("matches[%d] =", i, matches) + // do like the shell, and spit out the literal glob + if (!matches) { + if (this.nonull) { + var literal = this.minimatch.globSet[i] + if (nou) all.push(literal) + else all[literal] = true + } + } else { + // had matches + var m = Object.keys(matches) + if (nou) all.push.apply(all, m) + else m.forEach(function (m) { + all[m] = true + }) + } + } + + if (!nou) all = Object.keys(all) + + if (!this.nosort) { + all = all.sort(this.nocase ? alphasorti : alphasort) + } + + if (this.mark) { + // at *some* point we statted all of these + all = all.map(this._mark, this) + } + + this.log("emitting end", all) + + this.EOF = this.found = all + this.emitMatch(this.EOF) +} + +function alphasorti (a, b) { + a = a.toLowerCase() + b = b.toLowerCase() + return alphasort(a, b) +} + +function alphasort (a, b) { + return a > b ? 1 : a < b ? -1 : 0 +} + +Glob.prototype._mark = function (p) { + var c = this.cache[p] + var m = p + if (c) { + var isDir = c === 2 || Array.isArray(c) + var slash = p.slice(-1) === '/' + + if (isDir && !slash) + m += '/' + else if (!isDir && slash) + m = m.slice(0, -1) + + if (m !== p) { + this.statCache[m] = this.statCache[p] + this.cache[m] = this.cache[p] + } + } + + return m +} + +Glob.prototype.abort = function () { + this.aborted = true + this.emit("abort") +} + +Glob.prototype.pause = function () { + if (this.paused) return + if (this.sync) + this.emit("error", new Error("Can't pause/resume sync glob")) + this.paused = true + this.emit("pause") +} + +Glob.prototype.resume = function () { + if (!this.paused) return + if (this.sync) + this.emit("error", new Error("Can't pause/resume sync glob")) + this.paused = false + this.emit("resume") + this._processEmitQueue() + //process.nextTick(this.emit.bind(this, "resume")) +} + +Glob.prototype.emitMatch = function (m) { + this.log('emitMatch', m) + this._emitQueue.push(m) + this._processEmitQueue() +} + +Glob.prototype._processEmitQueue = function (m) { + this.log("pEQ paused=%j processing=%j m=%j", this.paused, + this._processingEmitQueue, m) + var done = false + while (!this._processingEmitQueue && + !this.paused) { + this._processingEmitQueue = true + var m = this._emitQueue.shift() + this.log(">processEmitQueue", m === this.EOF ? ":EOF:" : m) + if (!m) { + this.log(">processEmitQueue, falsey m") + this._processingEmitQueue = false + break + } + + if (m === this.EOF || !(this.mark && !this.stat)) { + this.log("peq: unmarked, or eof") + next.call(this, 0, false) + } else if (this.statCache[m]) { + var sc = this.statCache[m] + var exists + if (sc) + exists = sc.isDirectory() ? 2 : 1 + this.log("peq: stat cached") + next.call(this, exists, exists === 2) + } else { + this.log("peq: _stat, then next") + this._stat(m, next) + } + + function next(exists, isDir) { + this.log("next", m, exists, isDir) + var ev = m === this.EOF ? "end" : "match" + + // "end" can only happen once. + assert(!this._endEmitted) + if (ev === "end") + this._endEmitted = true + + if (exists) { + // Doesn't mean it necessarily doesn't exist, it's possible + // we just didn't check because we don't care that much, or + // this is EOF anyway. + if (isDir && !m.match(/\/$/)) { + m = m + "/" + } else if (!isDir && m.match(/\/$/)) { + m = m.replace(/\/+$/, "") + } + } + this.log("emit", ev, m) + this.emit(ev, m) + this._processingEmitQueue = false + if (done && m !== this.EOF && !this.paused) + this._processEmitQueue() + } + } + done = true +} + +Glob.prototype._process = function (pattern, depth, index, cb_) { + assert(this instanceof Glob) + + var cb = function cb (er, res) { + assert(this instanceof Glob) + if (this.paused) { + if (!this._processQueue) { + this._processQueue = [] + this.once("resume", function () { + var q = this._processQueue + this._processQueue = null + q.forEach(function (cb) { cb() }) + }) + } + this._processQueue.push(cb_.bind(this, er, res)) + } else { + cb_.call(this, er, res) + } + }.bind(this) + + if (this.aborted) return cb() + + if (depth > this.maxDepth) return cb() + + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === "string") { + n ++ + } + // now n is the index of the first one that is *not* a string. + + // see if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + prefix = pattern.join("/") + this._stat(prefix, function (exists, isDir) { + // either it's there, or it isn't. + // nothing more to do, either way. + if (exists) { + if (prefix && isAbsolute(prefix) && !this.nomount) { + if (prefix.charAt(0) === "/") { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + } + } + + if (process.platform === "win32") + prefix = prefix.replace(/\\/g, "/") + + this.matches[index] = this.matches[index] || {} + this.matches[index][prefix] = true + this.emitMatch(prefix) + } + return cb() + }) + return + + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break + + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's "absolute" like /foo/bar, + // or "relative" like "../baz" + prefix = pattern.slice(0, n) + prefix = prefix.join("/") + break + } + + // get the list of entries. + var read + if (prefix === null) read = "." + else if (isAbsolute(prefix) || isAbsolute(pattern.join("/"))) { + if (!prefix || !isAbsolute(prefix)) { + prefix = path.join("/", prefix) + } + read = prefix = path.resolve(prefix) + + // if (process.platform === "win32") + // read = prefix = prefix.replace(/^[a-zA-Z]:|\\/g, "/") + + this.log('absolute: ', prefix, this.root, pattern, read) + } else { + read = prefix + } + + this.log('readdir(%j)', read, this.cwd, this.root) + + return this._readdir(read, function (er, entries) { + if (er) { + // not a directory! + // this means that, whatever else comes after this, it can never match + return cb() + } + + // globstar is special + if (pattern[n] === minimatch.GLOBSTAR) { + // test without the globstar, and with every child both below + // and replacing the globstar. + var s = [ pattern.slice(0, n).concat(pattern.slice(n + 1)) ] + entries.forEach(function (e) { + if (e.charAt(0) === "." && !this.dot) return + // instead of the globstar + s.push(pattern.slice(0, n).concat(e).concat(pattern.slice(n + 1))) + // below the globstar + s.push(pattern.slice(0, n).concat(e).concat(pattern.slice(n))) + }, this) + + s = s.filter(function (pattern) { + var key = gsKey(pattern) + var seen = !this._globstars[key] + this._globstars[key] = true + return seen + }, this) + + if (!s.length) + return cb() + + // now asyncForEach over this + var l = s.length + , errState = null + s.forEach(function (gsPattern) { + this._process(gsPattern, depth + 1, index, function (er) { + if (errState) return + if (er) return cb(errState = er) + if (--l <= 0) return cb() + }) + }, this) + + return + } + + // not a globstar + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = pattern[n] + var rawGlob = pattern[n]._glob + , dotOk = this.dot || rawGlob.charAt(0) === "." + + entries = entries.filter(function (e) { + return (e.charAt(0) !== "." || dotOk) && + e.match(pattern[n]) + }) + + // If n === pattern.length - 1, then there's no need for the extra stat + // *unless* the user has specified "mark" or "stat" explicitly. + // We know that they exist, since the readdir returned them. + if (n === pattern.length - 1 && + !this.mark && + !this.stat) { + entries.forEach(function (e) { + if (prefix) { + if (prefix !== "/") e = prefix + "/" + e + else e = prefix + e + } + if (e.charAt(0) === "/" && !this.nomount) { + e = path.join(this.root, e) + } + + if (process.platform === "win32") + e = e.replace(/\\/g, "/") + + this.matches[index] = this.matches[index] || {} + this.matches[index][e] = true + this.emitMatch(e) + }, this) + return cb.call(this) + } + + + // now test all the remaining entries as stand-ins for that part + // of the pattern. + var l = entries.length + , errState = null + if (l === 0) return cb() // no matches possible + entries.forEach(function (e) { + var p = pattern.slice(0, n).concat(e).concat(pattern.slice(n + 1)) + this._process(p, depth + 1, index, function (er) { + if (errState) return + if (er) return cb(errState = er) + if (--l === 0) return cb.call(this) + }) + }, this) + }) + +} + +function gsKey (pattern) { + return '**' + pattern.map(function (p) { + return (p === minimatch.GLOBSTAR) ? '**' : (''+p) + }).join('/') +} + +Glob.prototype._stat = function (f, cb) { + assert(this instanceof Glob) + var abs = f + if (f.charAt(0) === "/") { + abs = path.join(this.root, f) + } else if (this.changedCwd) { + abs = path.resolve(this.cwd, f) + } + + if (f.length > this.maxLength) { + var er = new Error("Path name too long") + er.code = "ENAMETOOLONG" + er.path = f + return this._afterStat(f, abs, cb, er) + } + + this.log('stat', [this.cwd, f, '=', abs]) + + if (!this.stat && this.cache.hasOwnProperty(f)) { + var exists = this.cache[f] + , isDir = exists && (Array.isArray(exists) || exists === 2) + if (this.sync) return cb.call(this, !!exists, isDir) + return process.nextTick(cb.bind(this, !!exists, isDir)) + } + + var stat = this.statCache[abs] + if (this.sync || stat) { + var er + try { + stat = fs.statSync(abs) + } catch (e) { + er = e + } + this._afterStat(f, abs, cb, er, stat) + } else { + fs.stat(abs, this._afterStat.bind(this, f, abs, cb)) + } +} + +Glob.prototype._afterStat = function (f, abs, cb, er, stat) { + var exists + assert(this instanceof Glob) + + if (abs.slice(-1) === "/" && stat && !stat.isDirectory()) { + this.log("should be ENOTDIR, fake it") + + er = new Error("ENOTDIR, not a directory '" + abs + "'") + er.path = abs + er.code = "ENOTDIR" + stat = null + } + + var emit = !this.statCache[abs] + this.statCache[abs] = stat + + if (er || !stat) { + exists = false + } else { + exists = stat.isDirectory() ? 2 : 1 + if (emit) + this.emit('stat', f, stat) + } + this.cache[f] = this.cache[f] || exists + cb.call(this, !!exists, exists === 2) +} + +Glob.prototype._readdir = function (f, cb) { + assert(this instanceof Glob) + var abs = f + if (f.charAt(0) === "/") { + abs = path.join(this.root, f) + } else if (isAbsolute(f)) { + abs = f + } else if (this.changedCwd) { + abs = path.resolve(this.cwd, f) + } + + if (f.length > this.maxLength) { + var er = new Error("Path name too long") + er.code = "ENAMETOOLONG" + er.path = f + return this._afterReaddir(f, abs, cb, er) + } + + this.log('readdir', [this.cwd, f, abs]) + if (this.cache.hasOwnProperty(f)) { + var c = this.cache[f] + if (Array.isArray(c)) { + if (this.sync) return cb.call(this, null, c) + return process.nextTick(cb.bind(this, null, c)) + } + + if (!c || c === 1) { + // either ENOENT or ENOTDIR + var code = c ? "ENOTDIR" : "ENOENT" + , er = new Error((c ? "Not a directory" : "Not found") + ": " + f) + er.path = f + er.code = code + this.log(f, er) + if (this.sync) return cb.call(this, er) + return process.nextTick(cb.bind(this, er)) + } + + // at this point, c === 2, meaning it's a dir, but we haven't + // had to read it yet, or c === true, meaning it's *something* + // but we don't have any idea what. Need to read it, either way. + } + + if (this.sync) { + var er, entries + try { + entries = fs.readdirSync(abs) + } catch (e) { + er = e + } + return this._afterReaddir(f, abs, cb, er, entries) + } + + fs.readdir(abs, this._afterReaddir.bind(this, f, abs, cb)) +} + +Glob.prototype._afterReaddir = function (f, abs, cb, er, entries) { + assert(this instanceof Glob) + if (entries && !er) { + this.cache[f] = entries + // if we haven't asked to stat everything for suresies, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. This also gets us one step + // further into ELOOP territory. + if (!this.mark && !this.stat) { + entries.forEach(function (e) { + if (f === "/") e = f + e + else e = f + "/" + e + this.cache[e] = true + }, this) + } + + return cb.call(this, er, entries) + } + + // now handle errors, and cache the information + if (er) switch (er.code) { + case "ENOTDIR": // totally normal. means it *does* exist. + this.cache[f] = 1 + return cb.call(this, er) + case "ENOENT": // not terribly unusual + case "ELOOP": + case "ENAMETOOLONG": + case "UNKNOWN": + this.cache[f] = false + return cb.call(this, er) + default: // some unusual error. Treat as failure. + this.cache[f] = false + if (this.strict) this.emit("error", er) + if (!this.silent) console.error("glob error", er) + return cb.call(this, er) + } +} + +var isAbsolute = process.platform === "win32" ? absWin : absUnix + +function absWin (p) { + if (absUnix(p)) return true + // pull off the device/UNC bit from a windows path. + // from node's lib/path.js + var splitDeviceRe = + /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/ + , result = splitDeviceRe.exec(p) + , device = result[1] || '' + , isUnc = device && device.charAt(1) !== ':' + , isAbsolute = !!result[2] || isUnc // UNC paths are always absolute + + return isAbsolute +} + +function absUnix (p) { + return p.charAt(0) === "/" || p === "" +} diff --git a/node_modules/node-gyp/node_modules/glob/package.json b/node_modules/node-gyp/node_modules/glob/package.json new file mode 100644 index 000000000..b6607582d --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/package.json @@ -0,0 +1,58 @@ +{ + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "name": "glob", + "description": "a little globber", + "version": "3.2.11", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-glob.git" + }, + "main": "glob.js", + "engines": { + "node": "*" + }, + "dependencies": { + "inherits": "2", + "minimatch": "0.3" + }, + "devDependencies": { + "tap": "~0.4.0", + "mkdirp": "0", + "rimraf": "1" + }, + "scripts": { + "test": "tap test/*.js", + "test-regen": "TEST_REGEN=1 node test/00-setup.js" + }, + "license": "BSD", + "gitHead": "73f57e99510582b2024b762305970ebcf9b70aa2", + "bugs": { + "url": "https://github.com/isaacs/node-glob/issues" + }, + "homepage": "https://github.com/isaacs/node-glob", + "_id": "glob@3.2.11", + "_shasum": "4a973f635b9190f715d10987d5c00fd2815ebe3d", + "_from": "glob@>=3.0.0-0 <4.0.0-0", + "_npmVersion": "1.4.10", + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "dist": { + "shasum": "4a973f635b9190f715d10987d5c00fd2815ebe3d", + "tarball": "http://registry.npmjs.org/glob/-/glob-3.2.11.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/node_modules/node-gyp/node_modules/glob/test/00-setup.js b/node_modules/node-gyp/node_modules/glob/test/00-setup.js new file mode 100644 index 000000000..245afafda --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/00-setup.js @@ -0,0 +1,176 @@ +// just a little pre-run script to set up the fixtures. +// zz-finish cleans it up + +var mkdirp = require("mkdirp") +var path = require("path") +var i = 0 +var tap = require("tap") +var fs = require("fs") +var rimraf = require("rimraf") + +var files = +[ "a/.abcdef/x/y/z/a" +, "a/abcdef/g/h" +, "a/abcfed/g/h" +, "a/b/c/d" +, "a/bc/e/f" +, "a/c/d/c/b" +, "a/cb/e/f" +] + +var symlinkTo = path.resolve(__dirname, "a/symlink/a/b/c") +var symlinkFrom = "../.." + +files = files.map(function (f) { + return path.resolve(__dirname, f) +}) + +tap.test("remove fixtures", function (t) { + rimraf(path.resolve(__dirname, "a"), function (er) { + t.ifError(er, "remove fixtures") + t.end() + }) +}) + +files.forEach(function (f) { + tap.test(f, function (t) { + var d = path.dirname(f) + mkdirp(d, 0755, function (er) { + if (er) { + t.fail(er) + return t.bailout() + } + fs.writeFile(f, "i like tests", function (er) { + t.ifError(er, "make file") + t.end() + }) + }) + }) +}) + +if (process.platform !== "win32") { + tap.test("symlinky", function (t) { + var d = path.dirname(symlinkTo) + console.error("mkdirp", d) + mkdirp(d, 0755, function (er) { + t.ifError(er) + fs.symlink(symlinkFrom, symlinkTo, "dir", function (er) { + t.ifError(er, "make symlink") + t.end() + }) + }) + }) +} + +;["foo","bar","baz","asdf","quux","qwer","rewq"].forEach(function (w) { + w = "/tmp/glob-test/" + w + tap.test("create " + w, function (t) { + mkdirp(w, function (er) { + if (er) + throw er + t.pass(w) + t.end() + }) + }) +}) + + +// generate the bash pattern test-fixtures if possible +if (process.platform === "win32" || !process.env.TEST_REGEN) { + console.error("Windows, or TEST_REGEN unset. Using cached fixtures.") + return +} + +var spawn = require("child_process").spawn; +var globs = + // put more patterns here. + // anything that would be directly in / should be in /tmp/glob-test + ["test/a/*/+(c|g)/./d" + ,"test/a/**/[cg]/../[cg]" + ,"test/a/{b,c,d,e,f}/**/g" + ,"test/a/b/**" + ,"test/**/g" + ,"test/a/abc{fed,def}/g/h" + ,"test/a/abc{fed/g,def}/**/" + ,"test/a/abc{fed/g,def}/**///**/" + ,"test/**/a/**/" + ,"test/+(a|b|c)/a{/,bc*}/**" + ,"test/*/*/*/f" + ,"test/**/f" + ,"test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**" + ,"{./*/*,/tmp/glob-test/*}" + ,"{/tmp/glob-test/*,*}" // evil owl face! how you taunt me! + ,"test/a/!(symlink)/**" + ] +var bashOutput = {} +var fs = require("fs") + +globs.forEach(function (pattern) { + tap.test("generate fixture " + pattern, function (t) { + var cmd = "shopt -s globstar && " + + "shopt -s extglob && " + + "shopt -s nullglob && " + + // "shopt >&2; " + + "eval \'for i in " + pattern + "; do echo $i; done\'" + var cp = spawn("bash", ["-c", cmd], { cwd: path.dirname(__dirname) }) + var out = [] + cp.stdout.on("data", function (c) { + out.push(c) + }) + cp.stderr.pipe(process.stderr) + cp.on("close", function (code) { + out = flatten(out) + if (!out) + out = [] + else + out = cleanResults(out.split(/\r*\n/)) + + bashOutput[pattern] = out + t.notOk(code, "bash test should finish nicely") + t.end() + }) + }) +}) + +tap.test("save fixtures", function (t) { + var fname = path.resolve(__dirname, "bash-results.json") + var data = JSON.stringify(bashOutput, null, 2) + "\n" + fs.writeFile(fname, data, function (er) { + t.ifError(er) + t.end() + }) +}) + +function cleanResults (m) { + // normalize discrepancies in ordering, duplication, + // and ending slashes. + return m.map(function (m) { + return m.replace(/\/+/g, "/").replace(/\/$/, "") + }).sort(alphasort).reduce(function (set, f) { + if (f !== set[set.length - 1]) set.push(f) + return set + }, []).sort(alphasort).map(function (f) { + // de-windows + return (process.platform !== 'win32') ? f + : f.replace(/^[a-zA-Z]:\\\\/, '/').replace(/\\/g, '/') + }) +} + +function flatten (chunks) { + var s = 0 + chunks.forEach(function (c) { s += c.length }) + var out = new Buffer(s) + s = 0 + chunks.forEach(function (c) { + c.copy(out, s) + s += c.length + }) + + return out.toString().trim() +} + +function alphasort (a, b) { + a = a.toLowerCase() + b = b.toLowerCase() + return a > b ? 1 : a < b ? -1 : 0 +} diff --git a/node_modules/node-gyp/node_modules/glob/test/bash-comparison.js b/node_modules/node-gyp/node_modules/glob/test/bash-comparison.js new file mode 100644 index 000000000..239ed1a9c --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/bash-comparison.js @@ -0,0 +1,63 @@ +// basic test +// show that it does the same thing by default as the shell. +var tap = require("tap") +, child_process = require("child_process") +, bashResults = require("./bash-results.json") +, globs = Object.keys(bashResults) +, glob = require("../") +, path = require("path") + +// run from the root of the project +// this is usually where you're at anyway, but be sure. +process.chdir(path.resolve(__dirname, "..")) + +function alphasort (a, b) { + a = a.toLowerCase() + b = b.toLowerCase() + return a > b ? 1 : a < b ? -1 : 0 +} + +globs.forEach(function (pattern) { + var expect = bashResults[pattern] + // anything regarding the symlink thing will fail on windows, so just skip it + if (process.platform === "win32" && + expect.some(function (m) { + return /\/symlink\//.test(m) + })) + return + + tap.test(pattern, function (t) { + glob(pattern, function (er, matches) { + if (er) + throw er + + // sort and unmark, just to match the shell results + matches = cleanResults(matches) + + t.deepEqual(matches, expect, pattern) + t.end() + }) + }) + + tap.test(pattern + " sync", function (t) { + var matches = cleanResults(glob.sync(pattern)) + + t.deepEqual(matches, expect, "should match shell") + t.end() + }) +}) + +function cleanResults (m) { + // normalize discrepancies in ordering, duplication, + // and ending slashes. + return m.map(function (m) { + return m.replace(/\/+/g, "/").replace(/\/$/, "") + }).sort(alphasort).reduce(function (set, f) { + if (f !== set[set.length - 1]) set.push(f) + return set + }, []).sort(alphasort).map(function (f) { + // de-windows + return (process.platform !== 'win32') ? f + : f.replace(/^[a-zA-Z]:[\/\\]+/, '/').replace(/[\\\/]+/g, '/') + }) +} diff --git a/node_modules/node-gyp/node_modules/glob/test/bash-results.json b/node_modules/node-gyp/node_modules/glob/test/bash-results.json new file mode 100644 index 000000000..8051c7238 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/bash-results.json @@ -0,0 +1,351 @@ +{ + "test/a/*/+(c|g)/./d": [ + "test/a/b/c/./d" + ], + "test/a/**/[cg]/../[cg]": [ + "test/a/abcdef/g/../g", + "test/a/abcfed/g/../g", + "test/a/b/c/../c", + "test/a/c/../c", + "test/a/c/d/c/../c", + "test/a/symlink/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/../c" + ], + "test/a/{b,c,d,e,f}/**/g": [], + "test/a/b/**": [ + "test/a/b", + "test/a/b/c", + "test/a/b/c/d" + ], + "test/**/g": [ + "test/a/abcdef/g", + "test/a/abcfed/g" + ], + "test/a/abc{fed,def}/g/h": [ + "test/a/abcdef/g/h", + "test/a/abcfed/g/h" + ], + "test/a/abc{fed/g,def}/**/": [ + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcfed/g" + ], + "test/a/abc{fed/g,def}/**///**/": [ + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcfed/g" + ], + "test/**/a/**/": [ + "test/a", + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcfed", + "test/a/abcfed/g", + "test/a/b", + "test/a/b/c", + "test/a/bc", + "test/a/bc/e", + "test/a/c", + "test/a/c/d", + "test/a/c/d/c", + "test/a/cb", + "test/a/cb/e", + "test/a/symlink", + "test/a/symlink/a", + "test/a/symlink/a/b", + "test/a/symlink/a/b/c", + "test/a/symlink/a/b/c/a", + "test/a/symlink/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b" + ], + "test/+(a|b|c)/a{/,bc*}/**": [ + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcdef/g/h", + "test/a/abcfed", + "test/a/abcfed/g", + "test/a/abcfed/g/h" + ], + "test/*/*/*/f": [ + "test/a/bc/e/f", + "test/a/cb/e/f" + ], + "test/**/f": [ + "test/a/bc/e/f", + "test/a/cb/e/f" + ], + "test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**": [ + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b", + "test/a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c" + ], + "{./*/*,/tmp/glob-test/*}": [ + "./examples/g.js", + "./examples/usr-local.js", + "./node_modules/inherits", + "./node_modules/minimatch", + "./node_modules/mkdirp", + "./node_modules/rimraf", + "./node_modules/tap", + "./test/00-setup.js", + "./test/a", + "./test/bash-comparison.js", + "./test/bash-results.json", + "./test/cwd-test.js", + "./test/globstar-match.js", + "./test/mark.js", + "./test/new-glob-optional-options.js", + "./test/nocase-nomagic.js", + "./test/pause-resume.js", + "./test/readme-issue.js", + "./test/root-nomount.js", + "./test/root.js", + "./test/stat.js", + "./test/zz-cleanup.js", + "/tmp/glob-test/asdf", + "/tmp/glob-test/bar", + "/tmp/glob-test/baz", + "/tmp/glob-test/foo", + "/tmp/glob-test/quux", + "/tmp/glob-test/qwer", + "/tmp/glob-test/rewq" + ], + "{/tmp/glob-test/*,*}": [ + "/tmp/glob-test/asdf", + "/tmp/glob-test/bar", + "/tmp/glob-test/baz", + "/tmp/glob-test/foo", + "/tmp/glob-test/quux", + "/tmp/glob-test/qwer", + "/tmp/glob-test/rewq", + "examples", + "glob.js", + "LICENSE", + "node_modules", + "package.json", + "README.md", + "test" + ], + "test/a/!(symlink)/**": [ + "test/a/abcdef", + "test/a/abcdef/g", + "test/a/abcdef/g/h", + "test/a/abcfed", + "test/a/abcfed/g", + "test/a/abcfed/g/h", + "test/a/b", + "test/a/b/c", + "test/a/b/c/d", + "test/a/bc", + "test/a/bc/e", + "test/a/bc/e/f", + "test/a/c", + "test/a/c/d", + "test/a/c/d/c", + "test/a/c/d/c/b", + "test/a/cb", + "test/a/cb/e", + "test/a/cb/e/f" + ] +} diff --git a/node_modules/node-gyp/node_modules/glob/test/cwd-test.js b/node_modules/node-gyp/node_modules/glob/test/cwd-test.js new file mode 100644 index 000000000..352c27efa --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/cwd-test.js @@ -0,0 +1,55 @@ +var tap = require("tap") + +var origCwd = process.cwd() +process.chdir(__dirname) + +tap.test("changing cwd and searching for **/d", function (t) { + var glob = require('../') + var path = require('path') + t.test('.', function (t) { + glob('**/d', function (er, matches) { + t.ifError(er) + t.like(matches, [ 'a/b/c/d', 'a/c/d' ]) + t.end() + }) + }) + + t.test('a', function (t) { + glob('**/d', {cwd:path.resolve('a')}, function (er, matches) { + t.ifError(er) + t.like(matches, [ 'b/c/d', 'c/d' ]) + t.end() + }) + }) + + t.test('a/b', function (t) { + glob('**/d', {cwd:path.resolve('a/b')}, function (er, matches) { + t.ifError(er) + t.like(matches, [ 'c/d' ]) + t.end() + }) + }) + + t.test('a/b/', function (t) { + glob('**/d', {cwd:path.resolve('a/b/')}, function (er, matches) { + t.ifError(er) + t.like(matches, [ 'c/d' ]) + t.end() + }) + }) + + t.test('.', function (t) { + glob('**/d', {cwd: process.cwd()}, function (er, matches) { + t.ifError(er) + t.like(matches, [ 'a/b/c/d', 'a/c/d' ]) + t.end() + }) + }) + + t.test('cd -', function (t) { + process.chdir(origCwd) + t.end() + }) + + t.end() +}) diff --git a/node_modules/node-gyp/node_modules/glob/test/globstar-match.js b/node_modules/node-gyp/node_modules/glob/test/globstar-match.js new file mode 100644 index 000000000..9b234fa2a --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/globstar-match.js @@ -0,0 +1,19 @@ +var Glob = require("../glob.js").Glob +var test = require('tap').test + +test('globstar should not have dupe matches', function(t) { + var pattern = 'a/**/[gh]' + var g = new Glob(pattern, { cwd: __dirname }) + var matches = [] + g.on('match', function(m) { + console.error('match %j', m) + matches.push(m) + }) + g.on('end', function(set) { + console.error('set', set) + matches = matches.sort() + set = set.sort() + t.same(matches, set, 'should have same set of matches') + t.end() + }) +}) diff --git a/node_modules/node-gyp/node_modules/glob/test/mark.js b/node_modules/node-gyp/node_modules/glob/test/mark.js new file mode 100644 index 000000000..bf411c0e5 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/mark.js @@ -0,0 +1,118 @@ +var test = require("tap").test +var glob = require('../') +process.chdir(__dirname) + +// expose timing issues +var lag = 5 +glob.Glob.prototype._stat = function(o) { return function(f, cb) { + var args = arguments + setTimeout(function() { + o.call(this, f, cb) + }.bind(this), lag += 5) +}}(glob.Glob.prototype._stat) + + +test("mark, with **", function (t) { + glob("a/*b*/**", {mark: true}, function (er, results) { + if (er) + throw er + var expect = + [ 'a/abcdef/', + 'a/abcdef/g/', + 'a/abcdef/g/h', + 'a/abcfed/', + 'a/abcfed/g/', + 'a/abcfed/g/h', + 'a/b/', + 'a/b/c/', + 'a/b/c/d', + 'a/bc/', + 'a/bc/e/', + 'a/bc/e/f', + 'a/cb/', + 'a/cb/e/', + 'a/cb/e/f' ] + + t.same(results, expect) + t.end() + }) +}) + +test("mark, no / on pattern", function (t) { + glob("a/*", {mark: true}, function (er, results) { + if (er) + throw er + var expect = [ 'a/abcdef/', + 'a/abcfed/', + 'a/b/', + 'a/bc/', + 'a/c/', + 'a/cb/' ] + + if (process.platform !== "win32") + expect.push('a/symlink/') + + t.same(results, expect) + t.end() + }).on('match', function(m) { + t.similar(m, /\/$/) + }) +}) + +test("mark=false, no / on pattern", function (t) { + glob("a/*", function (er, results) { + if (er) + throw er + var expect = [ 'a/abcdef', + 'a/abcfed', + 'a/b', + 'a/bc', + 'a/c', + 'a/cb' ] + + if (process.platform !== "win32") + expect.push('a/symlink') + t.same(results, expect) + t.end() + }).on('match', function(m) { + t.similar(m, /[^\/]$/) + }) +}) + +test("mark=true, / on pattern", function (t) { + glob("a/*/", {mark: true}, function (er, results) { + if (er) + throw er + var expect = [ 'a/abcdef/', + 'a/abcfed/', + 'a/b/', + 'a/bc/', + 'a/c/', + 'a/cb/' ] + if (process.platform !== "win32") + expect.push('a/symlink/') + t.same(results, expect) + t.end() + }).on('match', function(m) { + t.similar(m, /\/$/) + }) +}) + +test("mark=false, / on pattern", function (t) { + glob("a/*/", function (er, results) { + if (er) + throw er + var expect = [ 'a/abcdef/', + 'a/abcfed/', + 'a/b/', + 'a/bc/', + 'a/c/', + 'a/cb/' ] + if (process.platform !== "win32") + expect.push('a/symlink/') + t.same(results, expect) + t.end() + }).on('match', function(m) { + t.similar(m, /\/$/) + }) +}) diff --git a/node_modules/node-gyp/node_modules/glob/test/new-glob-optional-options.js b/node_modules/node-gyp/node_modules/glob/test/new-glob-optional-options.js new file mode 100644 index 000000000..3e7dc5acb --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/new-glob-optional-options.js @@ -0,0 +1,10 @@ +var Glob = require('../glob.js').Glob; +var test = require('tap').test; + +test('new glob, with cb, and no options', function (t) { + new Glob(__filename, function(er, results) { + if (er) throw er; + t.same(results, [__filename]); + t.end(); + }); +}); diff --git a/node_modules/node-gyp/node_modules/glob/test/nocase-nomagic.js b/node_modules/node-gyp/node_modules/glob/test/nocase-nomagic.js new file mode 100644 index 000000000..2503f2310 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/nocase-nomagic.js @@ -0,0 +1,113 @@ +var fs = require('fs'); +var test = require('tap').test; +var glob = require('../'); + +test('mock fs', function(t) { + var stat = fs.stat + var statSync = fs.statSync + var readdir = fs.readdir + var readdirSync = fs.readdirSync + + function fakeStat(path) { + var ret + switch (path.toLowerCase()) { + case '/tmp': case '/tmp/': + ret = { isDirectory: function() { return true } } + break + case '/tmp/a': + ret = { isDirectory: function() { return false } } + break + } + return ret + } + + fs.stat = function(path, cb) { + var f = fakeStat(path); + if (f) { + process.nextTick(function() { + cb(null, f) + }) + } else { + stat.call(fs, path, cb) + } + } + + fs.statSync = function(path) { + return fakeStat(path) || statSync.call(fs, path) + } + + function fakeReaddir(path) { + var ret + switch (path.toLowerCase()) { + case '/tmp': case '/tmp/': + ret = [ 'a', 'A' ] + break + case '/': + ret = ['tmp', 'tMp', 'tMP', 'TMP'] + } + return ret + } + + fs.readdir = function(path, cb) { + var f = fakeReaddir(path) + if (f) + process.nextTick(function() { + cb(null, f) + }) + else + readdir.call(fs, path, cb) + } + + fs.readdirSync = function(path) { + return fakeReaddir(path) || readdirSync.call(fs, path) + } + + t.pass('mocked') + t.end() +}) + +test('nocase, nomagic', function(t) { + var n = 2 + var want = [ '/TMP/A', + '/TMP/a', + '/tMP/A', + '/tMP/a', + '/tMp/A', + '/tMp/a', + '/tmp/A', + '/tmp/a' ] + glob('/tmp/a', { nocase: true }, function(er, res) { + if (er) + throw er + t.same(res.sort(), want) + if (--n === 0) t.end() + }) + glob('/tmp/A', { nocase: true }, function(er, res) { + if (er) + throw er + t.same(res.sort(), want) + if (--n === 0) t.end() + }) +}) + +test('nocase, with some magic', function(t) { + t.plan(2) + var want = [ '/TMP/A', + '/TMP/a', + '/tMP/A', + '/tMP/a', + '/tMp/A', + '/tMp/a', + '/tmp/A', + '/tmp/a' ] + glob('/tmp/*', { nocase: true }, function(er, res) { + if (er) + throw er + t.same(res.sort(), want) + }) + glob('/tmp/*', { nocase: true }, function(er, res) { + if (er) + throw er + t.same(res.sort(), want) + }) +}) diff --git a/node_modules/node-gyp/node_modules/glob/test/pause-resume.js b/node_modules/node-gyp/node_modules/glob/test/pause-resume.js new file mode 100644 index 000000000..e1ffbab1c --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/pause-resume.js @@ -0,0 +1,73 @@ +// show that no match events happen while paused. +var tap = require("tap") +, child_process = require("child_process") +// just some gnarly pattern with lots of matches +, pattern = "test/a/!(symlink)/**" +, bashResults = require("./bash-results.json") +, patterns = Object.keys(bashResults) +, glob = require("../") +, Glob = glob.Glob +, path = require("path") + +// run from the root of the project +// this is usually where you're at anyway, but be sure. +process.chdir(path.resolve(__dirname, "..")) + +function alphasort (a, b) { + a = a.toLowerCase() + b = b.toLowerCase() + return a > b ? 1 : a < b ? -1 : 0 +} + +function cleanResults (m) { + // normalize discrepancies in ordering, duplication, + // and ending slashes. + return m.map(function (m) { + return m.replace(/\/+/g, "/").replace(/\/$/, "") + }).sort(alphasort).reduce(function (set, f) { + if (f !== set[set.length - 1]) set.push(f) + return set + }, []).sort(alphasort).map(function (f) { + // de-windows + return (process.platform !== 'win32') ? f + : f.replace(/^[a-zA-Z]:\\\\/, '/').replace(/\\/g, '/') + }) +} + +var globResults = [] +tap.test("use a Glob object, and pause/resume it", function (t) { + var g = new Glob(pattern) + , paused = false + , res = [] + , expect = bashResults[pattern] + + g.on("pause", function () { + console.error("pause") + }) + + g.on("resume", function () { + console.error("resume") + }) + + g.on("match", function (m) { + t.notOk(g.paused, "must not be paused") + globResults.push(m) + g.pause() + t.ok(g.paused, "must be paused") + setTimeout(g.resume.bind(g), 10) + }) + + g.on("end", function (matches) { + t.pass("reached glob end") + globResults = cleanResults(globResults) + matches = cleanResults(matches) + t.deepEqual(matches, globResults, + "end event matches should be the same as match events") + + t.deepEqual(matches, expect, + "glob matches should be the same as bash results") + + t.end() + }) +}) + diff --git a/node_modules/node-gyp/node_modules/glob/test/readme-issue.js b/node_modules/node-gyp/node_modules/glob/test/readme-issue.js new file mode 100644 index 000000000..0b4e0be29 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/readme-issue.js @@ -0,0 +1,36 @@ +var test = require("tap").test +var glob = require("../") + +var mkdirp = require("mkdirp") +var fs = require("fs") +var rimraf = require("rimraf") +var dir = __dirname + "/package" + +test("setup", function (t) { + mkdirp.sync(dir) + fs.writeFileSync(dir + "/package.json", "{}", "ascii") + fs.writeFileSync(dir + "/README", "x", "ascii") + t.pass("setup done") + t.end() +}) + +test("glob", function (t) { + var opt = { + cwd: dir, + nocase: true, + mark: true + } + + glob("README?(.*)", opt, function (er, files) { + if (er) + throw er + t.same(files, ["README"]) + t.end() + }) +}) + +test("cleanup", function (t) { + rimraf.sync(dir) + t.pass("clean") + t.end() +}) diff --git a/node_modules/node-gyp/node_modules/glob/test/root-nomount.js b/node_modules/node-gyp/node_modules/glob/test/root-nomount.js new file mode 100644 index 000000000..3ac5979b0 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/root-nomount.js @@ -0,0 +1,39 @@ +var tap = require("tap") + +var origCwd = process.cwd() +process.chdir(__dirname) + +tap.test("changing root and searching for /b*/**", function (t) { + var glob = require('../') + var path = require('path') + t.test('.', function (t) { + glob('/b*/**', { globDebug: true, root: '.', nomount: true }, function (er, matches) { + t.ifError(er) + t.like(matches, []) + t.end() + }) + }) + + t.test('a', function (t) { + glob('/b*/**', { globDebug: true, root: path.resolve('a'), nomount: true }, function (er, matches) { + t.ifError(er) + t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ]) + t.end() + }) + }) + + t.test('root=a, cwd=a/b', function (t) { + glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b'), nomount: true }, function (er, matches) { + t.ifError(er) + t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ]) + t.end() + }) + }) + + t.test('cd -', function (t) { + process.chdir(origCwd) + t.end() + }) + + t.end() +}) diff --git a/node_modules/node-gyp/node_modules/glob/test/root.js b/node_modules/node-gyp/node_modules/glob/test/root.js new file mode 100644 index 000000000..95c23f99c --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/root.js @@ -0,0 +1,46 @@ +var t = require("tap") + +var origCwd = process.cwd() +process.chdir(__dirname) + +var glob = require('../') +var path = require('path') + +t.test('.', function (t) { + glob('/b*/**', { globDebug: true, root: '.' }, function (er, matches) { + t.ifError(er) + t.like(matches, []) + t.end() + }) +}) + + +t.test('a', function (t) { + console.error("root=" + path.resolve('a')) + glob('/b*/**', { globDebug: true, root: path.resolve('a') }, function (er, matches) { + t.ifError(er) + var wanted = [ + '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' + ].map(function (m) { + return path.join(path.resolve('a'), m).replace(/\\/g, '/') + }) + + t.like(matches, wanted) + t.end() + }) +}) + +t.test('root=a, cwd=a/b', function (t) { + glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b') }, function (er, matches) { + t.ifError(er) + t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) { + return path.join(path.resolve('a'), m).replace(/\\/g, '/') + })) + t.end() + }) +}) + +t.test('cd -', function (t) { + process.chdir(origCwd) + t.end() +}) diff --git a/node_modules/node-gyp/node_modules/glob/test/stat.js b/node_modules/node-gyp/node_modules/glob/test/stat.js new file mode 100644 index 000000000..62917114b --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/stat.js @@ -0,0 +1,32 @@ +var glob = require('../') +var test = require('tap').test +var path = require('path') + +test('stat all the things', function(t) { + var g = new glob.Glob('a/*abc*/**', { stat: true, cwd: __dirname }) + var matches = [] + g.on('match', function(m) { + matches.push(m) + }) + var stats = [] + g.on('stat', function(m) { + stats.push(m) + }) + g.on('end', function(eof) { + stats = stats.sort() + matches = matches.sort() + eof = eof.sort() + t.same(stats, matches) + t.same(eof, matches) + var cache = Object.keys(this.statCache) + t.same(cache.map(function (f) { + return path.relative(__dirname, f) + }).sort(), matches) + + cache.forEach(function(c) { + t.equal(typeof this.statCache[c], 'object') + }, this) + + t.end() + }) +}) diff --git a/node_modules/node-gyp/node_modules/glob/test/zz-cleanup.js b/node_modules/node-gyp/node_modules/glob/test/zz-cleanup.js new file mode 100644 index 000000000..e085f0fa7 --- /dev/null +++ b/node_modules/node-gyp/node_modules/glob/test/zz-cleanup.js @@ -0,0 +1,11 @@ +// remove the fixtures +var tap = require("tap") +, rimraf = require("rimraf") +, path = require("path") + +tap.test("cleanup fixtures", function (t) { + rimraf(path.resolve(__dirname, "a"), function (er) { + t.ifError(er, "removed") + t.end() + }) +}) diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/.npmignore b/node_modules/node-gyp/node_modules/graceful-fs/.npmignore index 9303c347e..c2658d7d1 100644 --- a/node_modules/npm-registry-client/node_modules/mkdirp/.npmignore +++ b/node_modules/node-gyp/node_modules/graceful-fs/.npmignore @@ -1,2 +1 @@ node_modules/ -npm-debug.log
\ No newline at end of file diff --git a/node_modules/node-gyp/node_modules/graceful-fs/LICENSE b/node_modules/node-gyp/node_modules/graceful-fs/LICENSE new file mode 100644 index 000000000..0c44ae716 --- /dev/null +++ b/node_modules/node-gyp/node_modules/graceful-fs/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Isaac Z. Schlueter ("Author") +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. 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 AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS +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. diff --git a/node_modules/node-gyp/node_modules/graceful-fs/README.md b/node_modules/node-gyp/node_modules/graceful-fs/README.md new file mode 100644 index 000000000..eb1a10935 --- /dev/null +++ b/node_modules/node-gyp/node_modules/graceful-fs/README.md @@ -0,0 +1,26 @@ +# graceful-fs + +graceful-fs functions as a drop-in replacement for the fs module, +making various improvements. + +The improvements are meant to normalize behavior across different +platforms and environments, and to make filesystem access more +resilient to errors. + +## Improvements over fs module + +graceful-fs: + +* Queues up `open` and `readdir` calls, and retries them once + something closes if there is an EMFILE error from too many file + descriptors. +* fixes `lchmod` for Node versions prior to 0.6.2. +* implements `fs.lutimes` if possible. Otherwise it becomes a noop. +* ignores `EINVAL` and `EPERM` errors in `chown`, `fchown` or + `lchown` if the user isn't root. +* makes `lchmod` and `lchown` become noops, if not available. +* retries reading a file if `read` results in EAGAIN error. + +On Windows, it retries renaming a file for up to one second if `EACCESS` +or `EPERM` error occurs, likely because antivirus software has locked +the directory. diff --git a/node_modules/node-gyp/node_modules/graceful-fs/graceful-fs.js b/node_modules/node-gyp/node_modules/graceful-fs/graceful-fs.js new file mode 100644 index 000000000..c84db9101 --- /dev/null +++ b/node_modules/node-gyp/node_modules/graceful-fs/graceful-fs.js @@ -0,0 +1,160 @@ +// Monkey-patching the fs module. +// It's ugly, but there is simply no other way to do this. +var fs = module.exports = require('fs') + +var assert = require('assert') + +// fix up some busted stuff, mostly on windows and old nodes +require('./polyfills.js') + +// The EMFILE enqueuing stuff + +var util = require('util') + +function noop () {} + +var debug = noop +if (util.debuglog) + debug = util.debuglog('gfs') +else if (/\bgfs\b/i.test(process.env.NODE_DEBUG || '')) + debug = function() { + var m = util.format.apply(util, arguments) + m = 'GFS: ' + m.split(/\n/).join('\nGFS: ') + console.error(m) + } + +if (/\bgfs\b/i.test(process.env.NODE_DEBUG || '')) { + process.on('exit', function() { + debug('fds', fds) + debug(queue) + assert.equal(queue.length, 0) + }) +} + + +var originalOpen = fs.open +fs.open = open + +function open(path, flags, mode, cb) { + if (typeof mode === "function") cb = mode, mode = null + if (typeof cb !== "function") cb = noop + new OpenReq(path, flags, mode, cb) +} + +function OpenReq(path, flags, mode, cb) { + this.path = path + this.flags = flags + this.mode = mode + this.cb = cb + Req.call(this) +} + +util.inherits(OpenReq, Req) + +OpenReq.prototype.process = function() { + originalOpen.call(fs, this.path, this.flags, this.mode, this.done) +} + +var fds = {} +OpenReq.prototype.done = function(er, fd) { + debug('open done', er, fd) + if (fd) + fds['fd' + fd] = this.path + Req.prototype.done.call(this, er, fd) +} + + +var originalReaddir = fs.readdir +fs.readdir = readdir + +function readdir(path, cb) { + if (typeof cb !== "function") cb = noop + new ReaddirReq(path, cb) +} + +function ReaddirReq(path, cb) { + this.path = path + this.cb = cb + Req.call(this) +} + +util.inherits(ReaddirReq, Req) + +ReaddirReq.prototype.process = function() { + originalReaddir.call(fs, this.path, this.done) +} + +ReaddirReq.prototype.done = function(er, files) { + if (files && files.sort) + files = files.sort() + Req.prototype.done.call(this, er, files) + onclose() +} + + +var originalClose = fs.close +fs.close = close + +function close (fd, cb) { + debug('close', fd) + if (typeof cb !== "function") cb = noop + delete fds['fd' + fd] + originalClose.call(fs, fd, function(er) { + onclose() + cb(er) + }) +} + + +var originalCloseSync = fs.closeSync +fs.closeSync = closeSync + +function closeSync (fd) { + try { + return originalCloseSync(fd) + } finally { + onclose() + } +} + + +// Req class +function Req () { + // start processing + this.done = this.done.bind(this) + this.failures = 0 + this.process() +} + +Req.prototype.done = function (er, result) { + var tryAgain = false + if (er) { + var code = er.code + var tryAgain = code === "EMFILE" + if (process.platform === "win32") + tryAgain = tryAgain || code === "OK" + } + + if (tryAgain) { + this.failures ++ + enqueue(this) + } else { + var cb = this.cb + cb(er, result) + } +} + +var queue = [] + +function enqueue(req) { + queue.push(req) + debug('enqueue %d %s', queue.length, req.constructor.name, req) +} + +function onclose() { + var req = queue.shift() + if (req) { + debug('process', req.constructor.name, req) + req.process() + } +} diff --git a/node_modules/node-gyp/node_modules/graceful-fs/package.json b/node_modules/node-gyp/node_modules/graceful-fs/package.json new file mode 100644 index 000000000..a0b8be65a --- /dev/null +++ b/node_modules/node-gyp/node_modules/graceful-fs/package.json @@ -0,0 +1,65 @@ +{ + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me" + }, + "name": "graceful-fs", + "description": "A drop-in replacement for fs, making various improvements.", + "version": "2.0.3", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-graceful-fs.git" + }, + "main": "graceful-fs.js", + "engines": { + "node": ">=0.4.0" + }, + "directories": { + "test": "test" + }, + "scripts": { + "test": "tap test/*.js" + }, + "keywords": [ + "fs", + "module", + "reading", + "retry", + "retries", + "queue", + "error", + "errors", + "handling", + "EMFILE", + "EAGAIN", + "EINVAL", + "EPERM", + "EACCESS" + ], + "license": "BSD", + "bugs": { + "url": "https://github.com/isaacs/node-graceful-fs/issues" + }, + "homepage": "https://github.com/isaacs/node-graceful-fs", + "_id": "graceful-fs@2.0.3", + "dist": { + "shasum": "7cd2cdb228a4a3f36e95efa6cc142de7d1a136d0", + "tarball": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz" + }, + "_from": "graceful-fs@>=2.0.0-0 <3.0.0-0", + "_npmVersion": "1.4.6", + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "_shasum": "7cd2cdb228a4a3f36e95efa6cc142de7d1a136d0", + "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/node_modules/node-gyp/node_modules/graceful-fs/polyfills.js b/node_modules/node-gyp/node_modules/graceful-fs/polyfills.js new file mode 100644 index 000000000..afc83b3f2 --- /dev/null +++ b/node_modules/node-gyp/node_modules/graceful-fs/polyfills.js @@ -0,0 +1,228 @@ +var fs = require('fs') +var constants = require('constants') + +var origCwd = process.cwd +var cwd = null +process.cwd = function() { + if (!cwd) + cwd = origCwd.call(process) + return cwd +} +var chdir = process.chdir +process.chdir = function(d) { + cwd = null + chdir.call(process, d) +} + +// (re-)implement some things that are known busted or missing. + +// lchmod, broken prior to 0.6.2 +// back-port the fix here. +if (constants.hasOwnProperty('O_SYMLINK') && + process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) { + fs.lchmod = function (path, mode, callback) { + callback = callback || noop + fs.open( path + , constants.O_WRONLY | constants.O_SYMLINK + , mode + , function (err, fd) { + if (err) { + callback(err) + return + } + // prefer to return the chmod error, if one occurs, + // but still try to close, and report closing errors if they occur. + fs.fchmod(fd, mode, function (err) { + fs.close(fd, function(err2) { + callback(err || err2) + }) + }) + }) + } + + fs.lchmodSync = function (path, mode) { + var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode) + + // prefer to return the chmod error, if one occurs, + // but still try to close, and report closing errors if they occur. + var err, err2 + try { + var ret = fs.fchmodSync(fd, mode) + } catch (er) { + err = er + } + try { + fs.closeSync(fd) + } catch (er) { + err2 = er + } + if (err || err2) throw (err || err2) + return ret + } +} + + +// lutimes implementation, or no-op +if (!fs.lutimes) { + if (constants.hasOwnProperty("O_SYMLINK")) { + fs.lutimes = function (path, at, mt, cb) { + fs.open(path, constants.O_SYMLINK, function (er, fd) { + cb = cb || noop + if (er) return cb(er) + fs.futimes(fd, at, mt, function (er) { + fs.close(fd, function (er2) { + return cb(er || er2) + }) + }) + }) + } + + fs.lutimesSync = function (path, at, mt) { + var fd = fs.openSync(path, constants.O_SYMLINK) + , err + , err2 + , ret + + try { + var ret = fs.futimesSync(fd, at, mt) + } catch (er) { + err = er + } + try { + fs.closeSync(fd) + } catch (er) { + err2 = er + } + if (err || err2) throw (err || err2) + return ret + } + + } else if (fs.utimensat && constants.hasOwnProperty("AT_SYMLINK_NOFOLLOW")) { + // maybe utimensat will be bound soonish? + fs.lutimes = function (path, at, mt, cb) { + fs.utimensat(path, at, mt, constants.AT_SYMLINK_NOFOLLOW, cb) + } + + fs.lutimesSync = function (path, at, mt) { + return fs.utimensatSync(path, at, mt, constants.AT_SYMLINK_NOFOLLOW) + } + + } else { + fs.lutimes = function (_a, _b, _c, cb) { process.nextTick(cb) } + fs.lutimesSync = function () {} + } +} + + +// https://github.com/isaacs/node-graceful-fs/issues/4 +// Chown should not fail on einval or eperm if non-root. + +fs.chown = chownFix(fs.chown) +fs.fchown = chownFix(fs.fchown) +fs.lchown = chownFix(fs.lchown) + +fs.chownSync = chownFixSync(fs.chownSync) +fs.fchownSync = chownFixSync(fs.fchownSync) +fs.lchownSync = chownFixSync(fs.lchownSync) + +function chownFix (orig) { + if (!orig) return orig + return function (target, uid, gid, cb) { + return orig.call(fs, target, uid, gid, function (er, res) { + if (chownErOk(er)) er = null + cb(er, res) + }) + } +} + +function chownFixSync (orig) { + if (!orig) return orig + return function (target, uid, gid) { + try { + return orig.call(fs, target, uid, gid) + } catch (er) { + if (!chownErOk(er)) throw er + } + } +} + +function chownErOk (er) { + // if there's no getuid, or if getuid() is something other than 0, + // and the error is EINVAL or EPERM, then just ignore it. + // This specific case is a silent failure in cp, install, tar, + // and most other unix tools that manage permissions. + // When running as root, or if other types of errors are encountered, + // then it's strict. + if (!er || (!process.getuid || process.getuid() !== 0) + && (er.code === "EINVAL" || er.code === "EPERM")) return true +} + + +// if lchmod/lchown do not exist, then make them no-ops +if (!fs.lchmod) { + fs.lchmod = function (path, mode, cb) { + process.nextTick(cb) + } + fs.lchmodSync = function () {} +} +if (!fs.lchown) { + fs.lchown = function (path, uid, gid, cb) { + process.nextTick(cb) + } + fs.lchownSync = function () {} +} + + + +// on Windows, A/V software can lock the directory, causing this +// to fail with an EACCES or EPERM if the directory contains newly +// created files. Try again on failure, for up to 1 second. +if (process.platform === "win32") { + var rename_ = fs.rename + fs.rename = function rename (from, to, cb) { + var start = Date.now() + rename_(from, to, function CB (er) { + if (er + && (er.code === "EACCES" || er.code === "EPERM") + && Date.now() - start < 1000) { + return rename_(from, to, CB) + } + cb(er) + }) + } +} + + +// if read() returns EAGAIN, then just try it again. +var read = fs.read +fs.read = function (fd, buffer, offset, length, position, callback_) { + var callback + if (callback_ && typeof callback_ === 'function') { + var eagCounter = 0 + callback = function (er, _, __) { + if (er && er.code === 'EAGAIN' && eagCounter < 10) { + eagCounter ++ + return read.call(fs, fd, buffer, offset, length, position, callback) + } + callback_.apply(this, arguments) + } + } + return read.call(fs, fd, buffer, offset, length, position, callback) +} + +var readSync = fs.readSync +fs.readSync = function (fd, buffer, offset, length, position) { + var eagCounter = 0 + while (true) { + try { + return readSync.call(fs, fd, buffer, offset, length, position) + } catch (er) { + if (er.code === 'EAGAIN' && eagCounter < 10) { + eagCounter ++ + continue + } + throw er + } + } +} + diff --git a/node_modules/node-gyp/node_modules/graceful-fs/test/open.js b/node_modules/node-gyp/node_modules/graceful-fs/test/open.js new file mode 100644 index 000000000..104f36b0b --- /dev/null +++ b/node_modules/node-gyp/node_modules/graceful-fs/test/open.js @@ -0,0 +1,39 @@ +var test = require('tap').test +var fs = require('../graceful-fs.js') + +test('graceful fs is monkeypatched fs', function (t) { + t.equal(fs, require('fs')) + t.end() +}) + +test('open an existing file works', function (t) { + var fd = fs.openSync(__filename, 'r') + fs.closeSync(fd) + fs.open(__filename, 'r', function (er, fd) { + if (er) throw er + fs.close(fd, function (er) { + if (er) throw er + t.pass('works') + t.end() + }) + }) +}) + +test('open a non-existing file throws', function (t) { + var er + try { + var fd = fs.openSync('this file does not exist', 'r') + } catch (x) { + er = x + } + t.ok(er, 'should throw') + t.notOk(fd, 'should not get an fd') + t.equal(er.code, 'ENOENT') + + fs.open('neither does this file', 'r', function (er, fd) { + t.ok(er, 'should throw') + t.notOk(fd, 'should not get an fd') + t.equal(er.code, 'ENOENT') + t.end() + }) +}) diff --git a/node_modules/node-gyp/node_modules/graceful-fs/test/readdir-sort.js b/node_modules/node-gyp/node_modules/graceful-fs/test/readdir-sort.js new file mode 100644 index 000000000..aeaedf1c1 --- /dev/null +++ b/node_modules/node-gyp/node_modules/graceful-fs/test/readdir-sort.js @@ -0,0 +1,21 @@ +var test = require("tap").test +var fs = require("fs") + +var readdir = fs.readdir +fs.readdir = function(path, cb) { + process.nextTick(function() { + cb(null, ["b", "z", "a"]) + }) +} + +var g = require("../") + +test("readdir reorder", function (t) { + g.readdir("whatevers", function (er, files) { + if (er) + throw er + console.error(files) + t.same(files, [ "a", "b", "z" ]) + t.end() + }) +}) diff --git a/node_modules/node-gyp/node_modules/nopt/.npmignore b/node_modules/node-gyp/node_modules/nopt/.npmignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/node-gyp/node_modules/nopt/LICENSE b/node_modules/node-gyp/node_modules/nopt/LICENSE new file mode 100644 index 000000000..05a401094 --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/LICENSE @@ -0,0 +1,23 @@ +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/node-gyp/node_modules/nopt/README.md b/node_modules/node-gyp/node_modules/nopt/README.md new file mode 100644 index 000000000..96798a1da --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/README.md @@ -0,0 +1,210 @@ +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 -fp # unknown opts are ok. +{ blatzk: true, flag: true, pick: true } + +$ node my-program.js --blatzk=1000 -fp # but you need to use = if they have a value +{ blatzk: 1000, 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. When types are ordered, this implies a +preference, and the first type that can be used to properly interpret +the value will be used. + +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/node-gyp/node_modules/nopt/bin/nopt.js b/node_modules/node-gyp/node_modules/nopt/bin/nopt.js new file mode 100755 index 000000000..30e9fdbab --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/bin/nopt.js @@ -0,0 +1,51 @@ +#!/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 + , clear: Boolean + , config: Boolean + , length: Number + } + , 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" ] + , c: ["--config"] + , l: ["--length"] + } + , 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/node-gyp/node_modules/nopt/examples/my-program.js b/node_modules/node-gyp/node_modules/nopt/examples/my-program.js new file mode 100755 index 000000000..142447e18 --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/examples/my-program.js @@ -0,0 +1,30 @@ +#!/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/node-gyp/node_modules/nopt/lib/nopt.js b/node_modules/node-gyp/node_modules/nopt/lib/nopt.js new file mode 100644 index 000000000..9efab7af4 --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/lib/nopt.js @@ -0,0 +1,412 @@ +// 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} + Object.defineProperty(data.argv, 'toString', { value: function () { + return this.original.map(JSON.stringify).join(" ") + }, enumerable: false }) + return data +} + +function clean (data, types, typeDefs) { + typeDefs = typeDefs || exports.typeDefs + var remove = {} + , typeDefault = [false, true, null, String, Number, Array] + + 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) { + if (val === true) return false + val = String(val) + var homePattern = process.platform === 'win32' ? /^~(\/|\\)/ : /^~\// + if (val.match(homePattern) && process.env.HOME) { + val = path.resolve(process.env.HOME, val.substr(2)) + } + 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 + } + var hadEq = false + if (arg.charAt(0) === "-" && arg.length > 1) { + if (arg.indexOf("=") !== -1) { + hadEq = true + 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 = null + 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 + + // allow unknown things to be arrays if specified multiple times. + if (!types.hasOwnProperty(arg) && data.hasOwnProperty(arg)) { + if (!Array.isArray(data[arg])) + data[arg] = [data[arg]] + isArray = true + } + + var val + , la = args[i + 1] + + var isBool = typeof no === 'boolean' || + types[arg] === Boolean || + Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 || + (typeof types[arg] === 'undefined' && !hadEq) || + (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 (types[arg] === String && la === undefined) + la = "" + + 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 it's an exact known option, then don't go any further + if (abbrevs[arg] === arg) + return null + + // if it's an exact known shortopt, same deal + if (shorthands[arg]) { + // make it an array, if it's a list of words + if (shorthands[arg] && !Array.isArray(shorthands[arg])) + shorthands[arg] = shorthands[arg].split(/\s+/) + + return shorthands[arg] + } + + // first check to see if this arg is a set of single-char shorthands + 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 + debug('shorthand 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 it's an arg abbrev, and not a literal shorthand, then prefer the arg + if (abbrevs[arg] && !shorthands[arg]) + return null + + // if it's an abbr for a shorthand, then use that + if (shortAbbr[arg]) + arg = shortAbbr[arg] + + // make it an array, if it's a list of words + if (shorthands[arg] && !Array.isArray(shorthands[arg])) + shorthands[arg] = shorthands[arg].split(/\s+/) + + return shorthands[arg] +} diff --git a/node_modules/node-gyp/node_modules/nopt/package.json b/node_modules/node-gyp/node_modules/nopt/package.json new file mode 100644 index 000000000..b955c381f --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/package.json @@ -0,0 +1,56 @@ +{ + "name": "nopt", + "version": "2.2.1", + "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "main": "lib/nopt.js", + "scripts": { + "test": "tap test/*.js" + }, + "repository": { + "type": "git", + "url": "http://github.com/isaacs/nopt" + }, + "bin": { + "nopt": "./bin/nopt.js" + }, + "license": { + "type": "MIT", + "url": "https://github.com/isaacs/nopt/raw/master/LICENSE" + }, + "dependencies": { + "abbrev": "1" + }, + "devDependencies": { + "tap": "~0.4.8" + }, + "bugs": { + "url": "https://github.com/isaacs/nopt/issues" + }, + "homepage": "https://github.com/isaacs/nopt", + "_id": "nopt@2.2.1", + "_shasum": "2aa09b7d1768487b3b89a9c5aa52335bff0baea7", + "_from": "nopt@>=2.0.0-0 <3.0.0-0", + "_npmVersion": "1.4.7", + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "dist": { + "shasum": "2aa09b7d1768487b3b89a9c5aa52335bff0baea7", + "tarball": "http://registry.npmjs.org/nopt/-/nopt-2.2.1.tgz" + }, + "directories": {}, + "_resolved": "https://registry.npmjs.org/nopt/-/nopt-2.2.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/node_modules/node-gyp/node_modules/nopt/test/basic.js b/node_modules/node-gyp/node_modules/nopt/test/basic.js new file mode 100644 index 000000000..b31dccf54 --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/test/basic.js @@ -0,0 +1,243 @@ +var nopt = require("../") + , test = require('tap').test + + +test("passing a string results in a string", function (t) { + var parsed = nopt({ key: String }, {}, ["--key", "myvalue"], 0) + t.same(parsed.key, "myvalue") + t.end() +}) + +// https://github.com/npm/nopt/issues/31 +test("Empty String results in empty string, not true", function (t) { + var parsed = nopt({ empty: String }, {}, ["--empty"], 0) + t.same(parsed.empty, "") + t.end() +}) + +test("~ path is resolved to $HOME", function (t) { + var path = require("path") + if (!process.env.HOME) process.env.HOME = "/tmp" + var parsed = nopt({key: path}, {}, ["--key=~/val"], 0) + t.same(parsed.key, path.resolve(process.env.HOME, "val")) + t.end() +}) + +test("other tests", function (t) { + + var util = require("util") + , Stream = require("stream") + , path = require("path") + , url = require("url") + + , 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 + , path: path + } + + ; [["-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")} + ,[]] + ,["-cl 1" + ,{config: true, length: 1} + ,[] + ,{config: Boolean, length: Number, clear: Boolean} + ,{c: "--config", l: "--length"}] + ,["--acount bla" + ,{"acount":true} + ,["bla"] + ,{account: Boolean, credentials: Boolean, options: String} + ,{a:"--account", c:"--credentials",o:"--options"}] + ,["--clear" + ,{clear:true} + ,[] + ,{clear:Boolean,con:Boolean,len:Boolean,exp:Boolean,add:Boolean,rep:Boolean} + ,{c:"--con",l:"--len",e:"--exp",a:"--add",r:"--rep"}] + ,["--file -" + ,{"file":"-"} + ,[] + ,{file:String} + ,{}] + ,["--file -" + ,{"file":true} + ,["-"] + ,{file:Boolean} + ,{}] + ,["--path" + ,{"path":null} + ,[]] + ,["--path ." + ,{"path":process.cwd()} + ,[]] + ].forEach(function (test) { + var argv = test[0].split(/\s+/) + , opts = test[1] + , rem = test[2] + , actual = nopt(test[3] || types, test[4] || shorthands, argv, 0) + , parsed = actual.argv + delete actual.argv + 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") { + t.deepEqual(e, a) + } else { + t.equal(e, a) + } + } + t.deepEqual(rem, parsed.remain) + }) + t.end() +}) diff --git a/node_modules/node-gyp/node_modules/semver/.npmignore b/node_modules/node-gyp/node_modules/semver/.npmignore new file mode 100644 index 000000000..7300fbc79 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/.npmignore @@ -0,0 +1 @@ +# nada diff --git a/node_modules/node-gyp/node_modules/semver/LICENSE b/node_modules/node-gyp/node_modules/semver/LICENSE new file mode 100644 index 000000000..0c44ae716 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Isaac Z. Schlueter ("Author") +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. 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 AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS +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. diff --git a/node_modules/node-gyp/node_modules/semver/Makefile b/node_modules/node-gyp/node_modules/semver/Makefile new file mode 100644 index 000000000..5717ccf42 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/Makefile @@ -0,0 +1,24 @@ +files = semver.browser.js \ + semver.min.js \ + semver.browser.js.gz \ + semver.min.js.gz + +all: $(files) + +clean: + rm -f $(files) + +semver.browser.js: head.js semver.js foot.js + ( cat head.js; \ + cat semver.js | \ + egrep -v '^ *\/\* nomin \*\/' | \ + perl -pi -e 's/debug\([^\)]+\)//g'; \ + cat foot.js ) > semver.browser.js + +semver.min.js: semver.browser.js + uglifyjs -m <semver.browser.js >semver.min.js + +%.gz: % + gzip --stdout -9 <$< >$@ + +.PHONY: all clean diff --git a/node_modules/node-gyp/node_modules/semver/README.md b/node_modules/node-gyp/node_modules/semver/README.md new file mode 100644 index 000000000..ef0465981 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/README.md @@ -0,0 +1,142 @@ +semver(1) -- The semantic versioner for npm +=========================================== + +## Usage + + $ npm install semver + + semver.valid('1.2.3') // '1.2.3' + semver.valid('a.b.c') // null + semver.clean(' =v1.2.3 ') // '1.2.3' + semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true + semver.gt('1.2.3', '9.8.7') // false + semver.lt('1.2.3', '9.8.7') // true + +As a command-line utility: + + $ semver -h + + Usage: semver <version> [<version> [...]] [-r <range> | -i <inc> | -d <dec>] + Test if version(s) satisfy the supplied range(s), and sort them. + + Multiple versions or ranges may be supplied, unless increment + or decrement options are specified. In that case, only a single + version may be used, and it is incremented by the specified level + + Program exits successfully if any valid version satisfies + all supplied ranges, and prints all satisfying versions. + + If no versions are valid, or ranges are not satisfied, + then exits failure. + + Versions are printed in ascending order, so supplying + multiple versions to the utility will just sort them. + +## Versions + +A "version" is described by the v2.0.0 specification found at +<http://semver.org/>. + +A leading `"="` or `"v"` character is stripped off and ignored. + +## Ranges + +The following range styles are supported: + +* `1.2.3` A specific version. When nothing else will do. Note that + build metadata is still ignored, so `1.2.3+build2012` will satisfy + this range. +* `>1.2.3` Greater than a specific version. +* `<1.2.3` Less than a specific version. If there is no prerelease + tag on the version range, then no prerelease version will be allowed + either, even though these are technically "less than". +* `>=1.2.3` Greater than or equal to. Note that prerelease versions + are NOT equal to their "normal" equivalents, so `1.2.3-beta` will + not satisfy this range, but `2.3.0-beta` will. +* `<=1.2.3` Less than or equal to. In this case, prerelease versions + ARE allowed, so `1.2.3-beta` would satisfy. +* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4` +* `~1.2.3` := `>=1.2.3-0 <1.3.0-0` "Reasonably close to 1.2.3". When + using tilde operators, prerelease versions are supported as well, + but a prerelease of the next significant digit will NOT be + satisfactory, so `1.3.0-beta` will not satisfy `~1.2.3`. +* `^1.2.3` := `>=1.2.3-0 <2.0.0-0` "Compatible with 1.2.3". When + using caret operators, anything from the specified version (including + prerelease) will be supported up to, but not including, the next + major version (or its prereleases). `1.5.1` will satisfy `^1.2.3`, + while `1.2.2` and `2.0.0-beta` will not. +* `^0.1.3` := `>=0.1.3-0 <0.2.0-0` "Compatible with 0.1.3". 0.x.x versions are + special: the first non-zero component indicates potentially breaking changes, + meaning the caret operator matches any version with the same first non-zero + component starting at the specified version. +* `^0.0.2` := `=0.0.2` "Only the version 0.0.2 is considered compatible" +* `~1.2` := `>=1.2.0-0 <1.3.0-0` "Any version starting with 1.2" +* `^1.2` := `>=1.2.0-0 <2.0.0-0` "Any version compatible with 1.2" +* `1.2.x` := `>=1.2.0-0 <1.3.0-0` "Any version starting with 1.2" +* `~1` := `>=1.0.0-0 <2.0.0-0` "Any version starting with 1" +* `^1` := `>=1.0.0-0 <2.0.0-0` "Any version compatible with 1" +* `1.x` := `>=1.0.0-0 <2.0.0-0` "Any version starting with 1" + + +Ranges can be joined with either a space (which implies "and") or a +`||` (which implies "or"). + +## Functions + +All methods and classes take a final `loose` boolean argument that, if +true, will be more forgiving about not-quite-valid semver strings. +The resulting output will always be 100% strict, of course. + +Strict-mode Comparators and Ranges will be strict about the SemVer +strings that they parse. + +* valid(v): Return the parsed version, or null if it's not valid. +* inc(v, release): Return the version incremented by the release type + (major, minor, patch, or prerelease), or null if it's not valid. + +### Comparison + +* gt(v1, v2): `v1 > v2` +* gte(v1, v2): `v1 >= v2` +* lt(v1, v2): `v1 < v2` +* lte(v1, v2): `v1 <= v2` +* eq(v1, v2): `v1 == v2` This is true if they're logically equivalent, + even if they're not the exact same string. You already know how to + compare strings. +* neq(v1, v2): `v1 != v2` The opposite of eq. +* cmp(v1, comparator, v2): Pass in a comparison string, and it'll call + the corresponding function above. `"==="` and `"!=="` do simple + string comparison, but are included for completeness. Throws if an + invalid comparison string is provided. +* compare(v1, v2): Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if + v2 is greater. Sorts in ascending order if passed to Array.sort(). +* rcompare(v1, v2): The reverse of compare. Sorts an array of versions + in descending order when passed to Array.sort(). + + +### Ranges + +* validRange(range): Return the valid range or null if it's not valid +* satisfies(version, range): Return true if the version satisfies the + range. +* maxSatisfying(versions, range): Return the highest version in the list + that satisfies the range, or null if none of them do. +* gtr(version, range): Return true if version is greater than all the + versions possible in the range. +* ltr(version, range): Return true if version is less than all the + versions possible in the range. +* outside(version, range, hilo): Return true if the version is outside + the bounds of the range in either the high or low direction. The + `hilo` argument must be either the string `'>'` or `'<'`. (This is + the function called by `gtr` and `ltr`.) + +Note that, since ranges may be non-contiguous, a version might not be +greater than a range, less than a range, *or* satisfy a range! For +example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9` +until `2.0.0`, so the version `1.2.10` would not be greater than the +range (because 2.0.1 satisfies, which is higher), nor less than the +range (since 1.2.8 satisfies, which is lower), and it also does not +satisfy the range. + +If you want to know if a version satisfies or does not satisfy a +range, use the `satisfies(version, range)` function. diff --git a/node_modules/node-gyp/node_modules/semver/bin/semver b/node_modules/node-gyp/node_modules/semver/bin/semver new file mode 100755 index 000000000..88b4c7d31 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/bin/semver @@ -0,0 +1,124 @@ +#!/usr/bin/env node +// Standalone semver comparison program. +// Exits successfully and prints matching version(s) if +// any supplied version is valid and passes all tests. + +var argv = process.argv.slice(2) + , versions = [] + , range = [] + , gt = [] + , lt = [] + , eq = [] + , inc = null + , version = require("../package.json").version + , loose = false + , semver = require("../semver") + , reverse = false + +main() + +function main () { + if (!argv.length) return help() + while (argv.length) { + var a = argv.shift() + var i = a.indexOf('=') + if (i !== -1) { + a = a.slice(0, i) + argv.unshift(a.slice(i + 1)) + } + switch (a) { + case "-rv": case "-rev": case "--rev": case "--reverse": + reverse = true + break + case "-l": case "--loose": + loose = true + break + case "-v": case "--version": + versions.push(argv.shift()) + break + case "-i": case "--inc": case "--increment": + switch (argv[0]) { + case "major": case "minor": case "patch": case "prerelease": + inc = argv.shift() + break + default: + inc = "patch" + break + } + break + case "-r": case "--range": + range.push(argv.shift()) + break + case "-h": case "--help": case "-?": + return help() + default: + versions.push(a) + break + } + } + + versions = versions.filter(function (v) { + return semver.valid(v, loose) + }) + if (!versions.length) return fail() + if (inc && (versions.length !== 1 || range.length)) + return failInc() + + for (var i = 0, l = range.length; i < l ; i ++) { + versions = versions.filter(function (v) { + return semver.satisfies(v, range[i], loose) + }) + if (!versions.length) return fail() + } + return success(versions) +} + +function failInc () { + console.error("--inc can only be used on a single version with no range") + fail() +} + +function fail () { process.exit(1) } + +function success () { + var compare = reverse ? "rcompare" : "compare" + versions.sort(function (a, b) { + return semver[compare](a, b, loose) + }).map(function (v) { + return semver.clean(v, loose) + }).map(function (v) { + return inc ? semver.inc(v, inc, loose) : v + }).forEach(function (v,i,_) { console.log(v) }) +} + +function help () { + console.log(["SemVer " + version + ,"" + ,"A JavaScript implementation of the http://semver.org/ specification" + ,"Copyright Isaac Z. Schlueter" + ,"" + ,"Usage: semver [options] <version> [<version> [...]]" + ,"Prints valid versions sorted by SemVer precedence" + ,"" + ,"Options:" + ,"-r --range <range>" + ," Print versions that match the specified range." + ,"" + ,"-i --increment [<level>]" + ," Increment a version by the specified level. Level can" + ," be one of: major, minor, patch, or prerelease" + ," Default level is 'patch'." + ," Only one version may be specified." + ,"" + ,"-l --loose" + ," Interpret versions and ranges loosely" + ,"" + ,"Program exits successfully if any valid version satisfies" + ,"all supplied ranges, and prints all satisfying versions." + ,"" + ,"If no satisfying versions are found, then exits failure." + ,"" + ,"Versions are printed in ascending order, so supplying" + ,"multiple versions to the utility will just sort them." + ].join("\n")) +} diff --git a/node_modules/node-gyp/node_modules/semver/foot.js b/node_modules/node-gyp/node_modules/semver/foot.js new file mode 100644 index 000000000..8f83c20f8 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/foot.js @@ -0,0 +1,6 @@ + +})( + typeof exports === 'object' ? exports : + typeof define === 'function' && define.amd ? {} : + semver = {} +); diff --git a/node_modules/node-gyp/node_modules/semver/head.js b/node_modules/node-gyp/node_modules/semver/head.js new file mode 100644 index 000000000..653686517 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/head.js @@ -0,0 +1,2 @@ +;(function(exports) { + diff --git a/node_modules/node-gyp/node_modules/semver/package.json b/node_modules/node-gyp/node_modules/semver/package.json new file mode 100644 index 000000000..e73694c9d --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/package.json @@ -0,0 +1,49 @@ +{ + "name": "semver", + "version": "2.2.1", + "description": "The semantic version parser used by npm.", + "main": "semver.js", + "browser": "semver.browser.js", + "min": "semver.min.js", + "scripts": { + "test": "tap test/*.js", + "prepublish": "make" + }, + "devDependencies": { + "tap": "0.x >=0.0.4", + "uglify-js": "~2.3.6" + }, + "license": "BSD", + "repository": { + "type": "git", + "url": "git://github.com/isaacs/node-semver.git" + }, + "bin": { + "semver": "./bin/semver" + }, + "bugs": { + "url": "https://github.com/isaacs/node-semver/issues" + }, + "homepage": "https://github.com/isaacs/node-semver", + "_id": "semver@2.2.1", + "dist": { + "shasum": "7941182b3ffcc580bff1c17942acdf7951c0d213", + "tarball": "http://registry.npmjs.org/semver/-/semver-2.2.1.tgz" + }, + "_from": "semver@>=2.2.1-0 <2.3.0-0", + "_npmVersion": "1.3.12", + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + } + ], + "directories": {}, + "_shasum": "7941182b3ffcc580bff1c17942acdf7951c0d213", + "_resolved": "https://registry.npmjs.org/semver/-/semver-2.2.1.tgz", + "readme": "ERROR: No README data found!" +} diff --git a/node_modules/node-gyp/node_modules/semver/semver.browser.js b/node_modules/node-gyp/node_modules/semver/semver.browser.js new file mode 100644 index 000000000..e05ecc19c --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/semver.browser.js @@ -0,0 +1,1007 @@ +;(function(exports) { + +// export the class if we are in a Node-like system. +if (typeof module === 'object' && module.exports === exports) + exports = module.exports = SemVer; + +// The debug function is excluded entirely from the minified version. + +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +exports.SEMVER_SPEC_VERSION = '2.0.0'; + +// The actual regexps go on exports.re +var re = exports.re = []; +var src = exports.src = []; +var R = 0; + +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. + +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. + +var NUMERICIDENTIFIER = R++; +src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'; +var NUMERICIDENTIFIERLOOSE = R++; +src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; + + +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. + +var NONNUMERICIDENTIFIER = R++; +src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; + + +// ## Main Version +// Three dot-separated numeric identifiers. + +var MAINVERSION = R++; +src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + + '(' + src[NUMERICIDENTIFIER] + ')\\.' + + '(' + src[NUMERICIDENTIFIER] + ')'; + +var MAINVERSIONLOOSE = R++; +src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +var PRERELEASEIDENTIFIER = R++; +src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + + '|' + src[NONNUMERICIDENTIFIER] + ')'; + +var PRERELEASEIDENTIFIERLOOSE = R++; +src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + + '|' + src[NONNUMERICIDENTIFIER] + ')'; + + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +var PRERELEASE = R++; +src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'; + +var PRERELEASELOOSE = R++; +src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +var BUILDIDENTIFIER = R++; +src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +var BUILD = R++; +src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; + + +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. + +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. + +var FULL = R++; +var FULLPLAIN = 'v?' + src[MAINVERSION] + + src[PRERELEASE] + '?' + + src[BUILD] + '?'; + +src[FULL] = '^' + FULLPLAIN + '$'; + +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + + src[PRERELEASELOOSE] + '?' + + src[BUILD] + '?'; + +var LOOSE = R++; +src[LOOSE] = '^' + LOOSEPLAIN + '$'; + +var GTLT = R++; +src[GTLT] = '((?:<|>)?=?)'; + +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +var XRANGEIDENTIFIERLOOSE = R++; +src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'; +var XRANGEIDENTIFIER = R++; +src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'; + +var XRANGEPLAIN = R++; +src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + + '(?:(' + src[PRERELEASE] + ')' + + ')?)?)?'; + +var XRANGEPLAINLOOSE = R++; +src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:(' + src[PRERELEASELOOSE] + ')' + + ')?)?)?'; + +// >=2.x, for example, means >=2.0.0-0 +// <1.x would be the same as "<1.0.0-0", though. +var XRANGE = R++; +src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'; +var XRANGELOOSE = R++; +src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +var LONETILDE = R++; +src[LONETILDE] = '(?:~>?)'; + +var TILDETRIM = R++; +src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'; +re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g'); +var tildeTrimReplace = '$1~'; + +var TILDE = R++; +src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'; +var TILDELOOSE = R++; +src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +var LONECARET = R++; +src[LONECARET] = '(?:\\^)'; + +var CARETTRIM = R++; +src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'; +re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g'); +var caretTrimReplace = '$1^'; + +var CARET = R++; +src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'; +var CARETLOOSE = R++; +src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; + +// A simple gt/lt/eq thing, or just "" to indicate "any version" +var COMPARATORLOOSE = R++; +src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'; +var COMPARATOR = R++; +src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; + + +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +var COMPARATORTRIM = R++; +src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; + +// this one has to use the /g flag +re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g'); +var comparatorTrimReplace = '$1$2$3'; + + +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +var HYPHENRANGE = R++; +src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + + '\\s+-\\s+' + + '(' + src[XRANGEPLAIN] + ')' + + '\\s*$'; + +var HYPHENRANGELOOSE = R++; +src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[XRANGEPLAINLOOSE] + ')' + + '\\s*$'; + +// Star ranges basically just allow anything at all. +var STAR = R++; +src[STAR] = '(<|>)?=?\\s*\\*'; + +// Compile to actual regexp objects. +// All are flag-free, unless they were created above with a flag. +for (var i = 0; i < R; i++) { + ; + if (!re[i]) + re[i] = new RegExp(src[i]); +} + +exports.parse = parse; +function parse(version, loose) { + var r = loose ? re[LOOSE] : re[FULL]; + return (r.test(version)) ? new SemVer(version, loose) : null; +} + +exports.valid = valid; +function valid(version, loose) { + var v = parse(version, loose); + return v ? v.version : null; +} + + +exports.clean = clean; +function clean(version, loose) { + var s = parse(version, loose); + return s ? s.version : null; +} + +exports.SemVer = SemVer; + +function SemVer(version, loose) { + if (version instanceof SemVer) { + if (version.loose === loose) + return version; + else + version = version.version; + } + + if (!(this instanceof SemVer)) + return new SemVer(version, loose); + + ; + this.loose = loose; + var m = version.trim().match(loose ? re[LOOSE] : re[FULL]); + + if (!m) + throw new TypeError('Invalid Version: ' + version); + + this.raw = version; + + // these are actually numbers + this.major = +m[1]; + this.minor = +m[2]; + this.patch = +m[3]; + + // numberify any prerelease numeric ids + if (!m[4]) + this.prerelease = []; + else + this.prerelease = m[4].split('.').map(function(id) { + return (/^[0-9]+$/.test(id)) ? +id : id; + }); + + this.build = m[5] ? m[5].split('.') : []; + this.format(); +} + +SemVer.prototype.format = function() { + this.version = this.major + '.' + this.minor + '.' + this.patch; + if (this.prerelease.length) + this.version += '-' + this.prerelease.join('.'); + return this.version; +}; + +SemVer.prototype.inspect = function() { + return '<SemVer "' + this + '">'; +}; + +SemVer.prototype.toString = function() { + return this.version; +}; + +SemVer.prototype.compare = function(other) { + ; + if (!(other instanceof SemVer)) + other = new SemVer(other, this.loose); + + return this.compareMain(other) || this.comparePre(other); +}; + +SemVer.prototype.compareMain = function(other) { + if (!(other instanceof SemVer)) + other = new SemVer(other, this.loose); + + return compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch); +}; + +SemVer.prototype.comparePre = function(other) { + if (!(other instanceof SemVer)) + other = new SemVer(other, this.loose); + + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) + return -1; + else if (!this.prerelease.length && other.prerelease.length) + return 1; + else if (!this.prerelease.lenth && !other.prerelease.length) + return 0; + + var i = 0; + do { + var a = this.prerelease[i]; + var b = other.prerelease[i]; + ; + if (a === undefined && b === undefined) + return 0; + else if (b === undefined) + return 1; + else if (a === undefined) + return -1; + else if (a === b) + continue; + else + return compareIdentifiers(a, b); + } while (++i); +}; + +SemVer.prototype.inc = function(release) { + switch (release) { + case 'major': + this.major++; + this.minor = -1; + case 'minor': + this.minor++; + this.patch = -1; + case 'patch': + this.patch++; + this.prerelease = []; + break; + case 'prerelease': + if (this.prerelease.length === 0) + this.prerelease = [0]; + else { + var i = this.prerelease.length; + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++; + i = -2; + } + } + if (i === -1) // didn't increment anything + this.prerelease.push(0); + } + break; + + default: + throw new Error('invalid increment argument: ' + release); + } + this.format(); + return this; +}; + +exports.inc = inc; +function inc(version, release, loose) { + try { + return new SemVer(version, loose).inc(release).version; + } catch (er) { + return null; + } +} + +exports.compareIdentifiers = compareIdentifiers; + +var numeric = /^[0-9]+$/; +function compareIdentifiers(a, b) { + var anum = numeric.test(a); + var bnum = numeric.test(b); + + if (anum && bnum) { + a = +a; + b = +b; + } + + return (anum && !bnum) ? -1 : + (bnum && !anum) ? 1 : + a < b ? -1 : + a > b ? 1 : + 0; +} + +exports.rcompareIdentifiers = rcompareIdentifiers; +function rcompareIdentifiers(a, b) { + return compareIdentifiers(b, a); +} + +exports.compare = compare; +function compare(a, b, loose) { + return new SemVer(a, loose).compare(b); +} + +exports.compareLoose = compareLoose; +function compareLoose(a, b) { + return compare(a, b, true); +} + +exports.rcompare = rcompare; +function rcompare(a, b, loose) { + return compare(b, a, loose); +} + +exports.sort = sort; +function sort(list, loose) { + return list.sort(function(a, b) { + return exports.compare(a, b, loose); + }); +} + +exports.rsort = rsort; +function rsort(list, loose) { + return list.sort(function(a, b) { + return exports.rcompare(a, b, loose); + }); +} + +exports.gt = gt; +function gt(a, b, loose) { + return compare(a, b, loose) > 0; +} + +exports.lt = lt; +function lt(a, b, loose) { + return compare(a, b, loose) < 0; +} + +exports.eq = eq; +function eq(a, b, loose) { + return compare(a, b, loose) === 0; +} + +exports.neq = neq; +function neq(a, b, loose) { + return compare(a, b, loose) !== 0; +} + +exports.gte = gte; +function gte(a, b, loose) { + return compare(a, b, loose) >= 0; +} + +exports.lte = lte; +function lte(a, b, loose) { + return compare(a, b, loose) <= 0; +} + +exports.cmp = cmp; +function cmp(a, op, b, loose) { + var ret; + switch (op) { + case '===': ret = a === b; break; + case '!==': ret = a !== b; break; + case '': case '=': case '==': ret = eq(a, b, loose); break; + case '!=': ret = neq(a, b, loose); break; + case '>': ret = gt(a, b, loose); break; + case '>=': ret = gte(a, b, loose); break; + case '<': ret = lt(a, b, loose); break; + case '<=': ret = lte(a, b, loose); break; + default: throw new TypeError('Invalid operator: ' + op); + } + return ret; +} + +exports.Comparator = Comparator; +function Comparator(comp, loose) { + if (comp instanceof Comparator) { + if (comp.loose === loose) + return comp; + else + comp = comp.value; + } + + if (!(this instanceof Comparator)) + return new Comparator(comp, loose); + + ; + this.loose = loose; + this.parse(comp); + + if (this.semver === ANY) + this.value = ''; + else + this.value = this.operator + this.semver.version; +} + +var ANY = {}; +Comparator.prototype.parse = function(comp) { + var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; + var m = comp.match(r); + + if (!m) + throw new TypeError('Invalid comparator: ' + comp); + + this.operator = m[1]; + // if it literally is just '>' or '' then allow anything. + if (!m[2]) + this.semver = ANY; + else { + this.semver = new SemVer(m[2], this.loose); + + // <1.2.3-rc DOES allow 1.2.3-beta (has prerelease) + // >=1.2.3 DOES NOT allow 1.2.3-beta + // <=1.2.3 DOES allow 1.2.3-beta + // However, <1.2.3 does NOT allow 1.2.3-beta, + // even though `1.2.3-beta < 1.2.3` + // The assumption is that the 1.2.3 version has something you + // *don't* want, so we push the prerelease down to the minimum. + if (this.operator === '<' && !this.semver.prerelease.length) { + this.semver.prerelease = ['0']; + this.semver.format(); + } + } +}; + +Comparator.prototype.inspect = function() { + return '<SemVer Comparator "' + this + '">'; +}; + +Comparator.prototype.toString = function() { + return this.value; +}; + +Comparator.prototype.test = function(version) { + ; + return (this.semver === ANY) ? true : + cmp(version, this.operator, this.semver, this.loose); +}; + + +exports.Range = Range; +function Range(range, loose) { + if ((range instanceof Range) && range.loose === loose) + return range; + + if (!(this instanceof Range)) + return new Range(range, loose); + + this.loose = loose; + + // First, split based on boolean or || + this.raw = range; + this.set = range.split(/\s*\|\|\s*/).map(function(range) { + return this.parseRange(range.trim()); + }, this).filter(function(c) { + // throw out any that are not relevant for whatever reason + return c.length; + }); + + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range); + } + + this.format(); +} + +Range.prototype.inspect = function() { + return '<SemVer Range "' + this.range + '">'; +}; + +Range.prototype.format = function() { + this.range = this.set.map(function(comps) { + return comps.join(' ').trim(); + }).join('||').trim(); + return this.range; +}; + +Range.prototype.toString = function() { + return this.range; +}; + +Range.prototype.parseRange = function(range) { + var loose = this.loose; + range = range.trim(); + ; + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]; + range = range.replace(hr, hyphenReplace); + ; + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace); + ; + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[TILDETRIM], tildeTrimReplace); + + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[CARETTRIM], caretTrimReplace); + + // normalize spaces + range = range.split(/\s+/).join(' '); + + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; + var set = range.split(' ').map(function(comp) { + return parseComparator(comp, loose); + }).join(' ').split(/\s+/); + if (this.loose) { + // in loose mode, throw out any that are not valid comparators + set = set.filter(function(comp) { + return !!comp.match(compRe); + }); + } + set = set.map(function(comp) { + return new Comparator(comp, loose); + }); + + return set; +}; + +// Mostly just for testing and legacy API reasons +exports.toComparators = toComparators; +function toComparators(range, loose) { + return new Range(range, loose).set.map(function(comp) { + return comp.map(function(c) { + return c.value; + }).join(' ').trim().split(' '); + }); +} + +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +function parseComparator(comp, loose) { + ; + comp = replaceCarets(comp, loose); + ; + comp = replaceTildes(comp, loose); + ; + comp = replaceXRanges(comp, loose); + ; + comp = replaceStars(comp, loose); + ; + return comp; +} + +function isX(id) { + return !id || id.toLowerCase() === 'x' || id === '*'; +} + +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 +function replaceTildes(comp, loose) { + return comp.trim().split(/\s+/).map(function(comp) { + return replaceTilde(comp, loose); + }).join(' '); +} + +function replaceTilde(comp, loose) { + var r = loose ? re[TILDELOOSE] : re[TILDE]; + return comp.replace(r, function(_, M, m, p, pr) { + ; + var ret; + + if (isX(M)) + ret = ''; + else if (isX(m)) + ret = '>=' + M + '.0.0-0 <' + (+M + 1) + '.0.0-0'; + else if (isX(p)) + // ~1.2 == >=1.2.0- <1.3.0- + ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0'; + else if (pr) { + ; + if (pr.charAt(0) !== '-') + pr = '-' + pr; + ret = '>=' + M + '.' + m + '.' + p + pr + + ' <' + M + '.' + (+m + 1) + '.0-0'; + } else + // ~1.2.3 == >=1.2.3-0 <1.3.0-0 + ret = '>=' + M + '.' + m + '.' + p + '-0' + + ' <' + M + '.' + (+m + 1) + '.0-0'; + + ; + return ret; + }); +} + +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 +// ^1.2.3 --> >=1.2.3 <2.0.0 +// ^1.2.0 --> >=1.2.0 <2.0.0 +function replaceCarets(comp, loose) { + return comp.trim().split(/\s+/).map(function(comp) { + return replaceCaret(comp, loose); + }).join(' '); +} + +function replaceCaret(comp, loose) { + var r = loose ? re[CARETLOOSE] : re[CARET]; + return comp.replace(r, function(_, M, m, p, pr) { + ; + var ret; + + if (isX(M)) + ret = ''; + else if (isX(m)) + ret = '>=' + M + '.0.0-0 <' + (+M + 1) + '.0.0-0'; + else if (isX(p)) { + if (M === '0') + ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0'; + else + ret = '>=' + M + '.' + m + '.0-0 <' + (+M + 1) + '.0.0-0'; + } else if (pr) { + ; + if (pr.charAt(0) !== '-') + pr = '-' + pr; + if (M === '0') { + if (m === '0') + ret = '=' + M + '.' + m + '.' + p + pr; + else + ret = '>=' + M + '.' + m + '.' + p + pr + + ' <' + M + '.' + (+m + 1) + '.0-0'; + } else + ret = '>=' + M + '.' + m + '.' + p + pr + + ' <' + (+M + 1) + '.0.0-0'; + } else { + if (M === '0') { + if (m === '0') + ret = '=' + M + '.' + m + '.' + p; + else + ret = '>=' + M + '.' + m + '.' + p + '-0' + + ' <' + M + '.' + (+m + 1) + '.0-0'; + } else + ret = '>=' + M + '.' + m + '.' + p + '-0' + + ' <' + (+M + 1) + '.0.0-0'; + } + + ; + return ret; + }); +} + +function replaceXRanges(comp, loose) { + ; + return comp.split(/\s+/).map(function(comp) { + return replaceXRange(comp, loose); + }).join(' '); +} + +function replaceXRange(comp, loose) { + comp = comp.trim(); + var r = loose ? re[XRANGELOOSE] : re[XRANGE]; + return comp.replace(r, function(ret, gtlt, M, m, p, pr) { + ; + var xM = isX(M); + var xm = xM || isX(m); + var xp = xm || isX(p); + var anyX = xp; + + if (gtlt === '=' && anyX) + gtlt = ''; + + if (gtlt && anyX) { + // replace X with 0, and then append the -0 min-prerelease + if (xM) + M = 0; + if (xm) + m = 0; + if (xp) + p = 0; + + if (gtlt === '>') { + // >1 => >=2.0.0-0 + // >1.2 => >=1.3.0-0 + // >1.2.3 => >= 1.2.4-0 + gtlt = '>='; + if (xM) { + // no change + } else if (xm) { + M = +M + 1; + m = 0; + p = 0; + } else if (xp) { + m = +m + 1; + p = 0; + } + } + + + ret = gtlt + M + '.' + m + '.' + p + '-0'; + } else if (xM) { + // allow any + ret = '*'; + } else if (xm) { + // append '-0' onto the version, otherwise + // '1.x.x' matches '2.0.0-beta', since the tag + // *lowers* the version value + ret = '>=' + M + '.0.0-0 <' + (+M + 1) + '.0.0-0'; + } else if (xp) { + ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0'; + } + + ; + + return ret; + }); +} + +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +function replaceStars(comp, loose) { + ; + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[STAR], ''); +} + +// This function is passed to string.replace(re[HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0-0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0-0 <3.5.0-0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0-0 <3.5.0-0 +function hyphenReplace($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) { + + if (isX(fM)) + from = ''; + else if (isX(fm)) + from = '>=' + fM + '.0.0-0'; + else if (isX(fp)) + from = '>=' + fM + '.' + fm + '.0-0'; + else + from = '>=' + from; + + if (isX(tM)) + to = ''; + else if (isX(tm)) + to = '<' + (+tM + 1) + '.0.0-0'; + else if (isX(tp)) + to = '<' + tM + '.' + (+tm + 1) + '.0-0'; + else if (tpr) + to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr; + else + to = '<=' + to; + + return (from + ' ' + to).trim(); +} + + +// if ANY of the sets match ALL of its comparators, then pass +Range.prototype.test = function(version) { + if (!version) + return false; + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version)) + return true; + } + return false; +}; + +function testSet(set, version) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) + return false; + } + return true; +} + +exports.satisfies = satisfies; +function satisfies(version, range, loose) { + try { + range = new Range(range, loose); + } catch (er) { + return false; + } + return range.test(version); +} + +exports.maxSatisfying = maxSatisfying; +function maxSatisfying(versions, range, loose) { + return versions.filter(function(version) { + return satisfies(version, range, loose); + }).sort(function(a, b) { + return rcompare(a, b, loose); + })[0] || null; +} + +exports.validRange = validRange; +function validRange(range, loose) { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, loose).range || '*'; + } catch (er) { + return null; + } +} + +// Determine if version is less than all the versions possible in the range +exports.ltr = ltr; +function ltr(version, range, loose) { + return outside(version, range, '<', loose); +} + +// Determine if version is greater than all the versions possible in the range. +exports.gtr = gtr; +function gtr(version, range, loose) { + return outside(version, range, '>', loose); +} + +exports.outside = outside; +function outside(version, range, hilo, loose) { + version = new SemVer(version, loose); + range = new Range(range, loose); + + var gtfn, ltefn, ltfn, comp, ecomp; + switch (hilo) { + case '>': + gtfn = gt; + ltefn = lte; + ltfn = lt; + comp = '>'; + ecomp = '>='; + break; + case '<': + gtfn = lt; + ltefn = gte; + ltfn = gt; + comp = '<'; + ecomp = '<='; + break; + default: + throw new TypeError('Must provide a hilo val of "<" or ">"'); + } + + // If it satisifes the range it is not outside + if (satisfies(version, range, loose)) { + return false; + } + + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. + + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i]; + + var high = null; + var low = null; + + comparators.forEach(function(comparator) { + high = high || comparator; + low = low || comparator; + if (gtfn(comparator.semver, high.semver, loose)) { + high = comparator; + } else if (ltfn(comparator.semver, low.semver, loose)) { + low = comparator; + } + }); + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false; + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false; + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false; + } + } + return true; +} + +// Use the define() function if we're in AMD land +if (typeof define === 'function' && define.amd) + define(exports); + +})( + typeof exports === 'object' ? exports : + typeof define === 'function' && define.amd ? {} : + semver = {} +); diff --git a/node_modules/node-gyp/node_modules/semver/semver.browser.js.gz b/node_modules/node-gyp/node_modules/semver/semver.browser.js.gz Binary files differnew file mode 100644 index 000000000..b9549f809 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/semver.browser.js.gz diff --git a/node_modules/node-gyp/node_modules/semver/semver.js b/node_modules/node-gyp/node_modules/semver/semver.js new file mode 100644 index 000000000..9e9470d86 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/semver.js @@ -0,0 +1,1011 @@ +// export the class if we are in a Node-like system. +if (typeof module === 'object' && module.exports === exports) + exports = module.exports = SemVer; + +// The debug function is excluded entirely from the minified version. +/* nomin */ var debug; +/* nomin */ if (typeof process === 'object' && + /* nomin */ process.env && + /* nomin */ process.env.NODE_DEBUG && + /* nomin */ /\bsemver\b/i.test(process.env.NODE_DEBUG)) + /* nomin */ debug = function() { + /* nomin */ var args = Array.prototype.slice.call(arguments, 0); + /* nomin */ args.unshift('SEMVER'); + /* nomin */ console.log.apply(console, args); + /* nomin */ }; +/* nomin */ else + /* nomin */ debug = function() {}; + +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +exports.SEMVER_SPEC_VERSION = '2.0.0'; + +// The actual regexps go on exports.re +var re = exports.re = []; +var src = exports.src = []; +var R = 0; + +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. + +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. + +var NUMERICIDENTIFIER = R++; +src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'; +var NUMERICIDENTIFIERLOOSE = R++; +src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'; + + +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. + +var NONNUMERICIDENTIFIER = R++; +src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'; + + +// ## Main Version +// Three dot-separated numeric identifiers. + +var MAINVERSION = R++; +src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + + '(' + src[NUMERICIDENTIFIER] + ')\\.' + + '(' + src[NUMERICIDENTIFIER] + ')'; + +var MAINVERSIONLOOSE = R++; +src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[NUMERICIDENTIFIERLOOSE] + ')'; + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +var PRERELEASEIDENTIFIER = R++; +src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + + '|' + src[NONNUMERICIDENTIFIER] + ')'; + +var PRERELEASEIDENTIFIERLOOSE = R++; +src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + + '|' + src[NONNUMERICIDENTIFIER] + ')'; + + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +var PRERELEASE = R++; +src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'; + +var PRERELEASELOOSE = R++; +src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'; + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +var BUILDIDENTIFIER = R++; +src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'; + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +var BUILD = R++; +src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))'; + + +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. + +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. + +var FULL = R++; +var FULLPLAIN = 'v?' + src[MAINVERSION] + + src[PRERELEASE] + '?' + + src[BUILD] + '?'; + +src[FULL] = '^' + FULLPLAIN + '$'; + +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + + src[PRERELEASELOOSE] + '?' + + src[BUILD] + '?'; + +var LOOSE = R++; +src[LOOSE] = '^' + LOOSEPLAIN + '$'; + +var GTLT = R++; +src[GTLT] = '((?:<|>)?=?)'; + +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +var XRANGEIDENTIFIERLOOSE = R++; +src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'; +var XRANGEIDENTIFIER = R++; +src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'; + +var XRANGEPLAIN = R++; +src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + + '(?:(' + src[PRERELEASE] + ')' + + ')?)?)?'; + +var XRANGEPLAINLOOSE = R++; +src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + + '(?:(' + src[PRERELEASELOOSE] + ')' + + ')?)?)?'; + +// >=2.x, for example, means >=2.0.0-0 +// <1.x would be the same as "<1.0.0-0", though. +var XRANGE = R++; +src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'; +var XRANGELOOSE = R++; +src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'; + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +var LONETILDE = R++; +src[LONETILDE] = '(?:~>?)'; + +var TILDETRIM = R++; +src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'; +re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g'); +var tildeTrimReplace = '$1~'; + +var TILDE = R++; +src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'; +var TILDELOOSE = R++; +src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'; + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +var LONECARET = R++; +src[LONECARET] = '(?:\\^)'; + +var CARETTRIM = R++; +src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'; +re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g'); +var caretTrimReplace = '$1^'; + +var CARET = R++; +src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'; +var CARETLOOSE = R++; +src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'; + +// A simple gt/lt/eq thing, or just "" to indicate "any version" +var COMPARATORLOOSE = R++; +src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'; +var COMPARATOR = R++; +src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'; + + +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +var COMPARATORTRIM = R++; +src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'; + +// this one has to use the /g flag +re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g'); +var comparatorTrimReplace = '$1$2$3'; + + +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +var HYPHENRANGE = R++; +src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + + '\\s+-\\s+' + + '(' + src[XRANGEPLAIN] + ')' + + '\\s*$'; + +var HYPHENRANGELOOSE = R++; +src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[XRANGEPLAINLOOSE] + ')' + + '\\s*$'; + +// Star ranges basically just allow anything at all. +var STAR = R++; +src[STAR] = '(<|>)?=?\\s*\\*'; + +// Compile to actual regexp objects. +// All are flag-free, unless they were created above with a flag. +for (var i = 0; i < R; i++) { + debug(i, src[i]); + if (!re[i]) + re[i] = new RegExp(src[i]); +} + +exports.parse = parse; +function parse(version, loose) { + var r = loose ? re[LOOSE] : re[FULL]; + return (r.test(version)) ? new SemVer(version, loose) : null; +} + +exports.valid = valid; +function valid(version, loose) { + var v = parse(version, loose); + return v ? v.version : null; +} + + +exports.clean = clean; +function clean(version, loose) { + var s = parse(version, loose); + return s ? s.version : null; +} + +exports.SemVer = SemVer; + +function SemVer(version, loose) { + if (version instanceof SemVer) { + if (version.loose === loose) + return version; + else + version = version.version; + } + + if (!(this instanceof SemVer)) + return new SemVer(version, loose); + + debug('SemVer', version, loose); + this.loose = loose; + var m = version.trim().match(loose ? re[LOOSE] : re[FULL]); + + if (!m) + throw new TypeError('Invalid Version: ' + version); + + this.raw = version; + + // these are actually numbers + this.major = +m[1]; + this.minor = +m[2]; + this.patch = +m[3]; + + // numberify any prerelease numeric ids + if (!m[4]) + this.prerelease = []; + else + this.prerelease = m[4].split('.').map(function(id) { + return (/^[0-9]+$/.test(id)) ? +id : id; + }); + + this.build = m[5] ? m[5].split('.') : []; + this.format(); +} + +SemVer.prototype.format = function() { + this.version = this.major + '.' + this.minor + '.' + this.patch; + if (this.prerelease.length) + this.version += '-' + this.prerelease.join('.'); + return this.version; +}; + +SemVer.prototype.inspect = function() { + return '<SemVer "' + this + '">'; +}; + +SemVer.prototype.toString = function() { + return this.version; +}; + +SemVer.prototype.compare = function(other) { + debug('SemVer.compare', this.version, this.loose, other); + if (!(other instanceof SemVer)) + other = new SemVer(other, this.loose); + + return this.compareMain(other) || this.comparePre(other); +}; + +SemVer.prototype.compareMain = function(other) { + if (!(other instanceof SemVer)) + other = new SemVer(other, this.loose); + + return compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch); +}; + +SemVer.prototype.comparePre = function(other) { + if (!(other instanceof SemVer)) + other = new SemVer(other, this.loose); + + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) + return -1; + else if (!this.prerelease.length && other.prerelease.length) + return 1; + else if (!this.prerelease.lenth && !other.prerelease.length) + return 0; + + var i = 0; + do { + var a = this.prerelease[i]; + var b = other.prerelease[i]; + debug('prerelease compare', i, a, b); + if (a === undefined && b === undefined) + return 0; + else if (b === undefined) + return 1; + else if (a === undefined) + return -1; + else if (a === b) + continue; + else + return compareIdentifiers(a, b); + } while (++i); +}; + +SemVer.prototype.inc = function(release) { + switch (release) { + case 'major': + this.major++; + this.minor = -1; + case 'minor': + this.minor++; + this.patch = -1; + case 'patch': + this.patch++; + this.prerelease = []; + break; + case 'prerelease': + if (this.prerelease.length === 0) + this.prerelease = [0]; + else { + var i = this.prerelease.length; + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++; + i = -2; + } + } + if (i === -1) // didn't increment anything + this.prerelease.push(0); + } + break; + + default: + throw new Error('invalid increment argument: ' + release); + } + this.format(); + return this; +}; + +exports.inc = inc; +function inc(version, release, loose) { + try { + return new SemVer(version, loose).inc(release).version; + } catch (er) { + return null; + } +} + +exports.compareIdentifiers = compareIdentifiers; + +var numeric = /^[0-9]+$/; +function compareIdentifiers(a, b) { + var anum = numeric.test(a); + var bnum = numeric.test(b); + + if (anum && bnum) { + a = +a; + b = +b; + } + + return (anum && !bnum) ? -1 : + (bnum && !anum) ? 1 : + a < b ? -1 : + a > b ? 1 : + 0; +} + +exports.rcompareIdentifiers = rcompareIdentifiers; +function rcompareIdentifiers(a, b) { + return compareIdentifiers(b, a); +} + +exports.compare = compare; +function compare(a, b, loose) { + return new SemVer(a, loose).compare(b); +} + +exports.compareLoose = compareLoose; +function compareLoose(a, b) { + return compare(a, b, true); +} + +exports.rcompare = rcompare; +function rcompare(a, b, loose) { + return compare(b, a, loose); +} + +exports.sort = sort; +function sort(list, loose) { + return list.sort(function(a, b) { + return exports.compare(a, b, loose); + }); +} + +exports.rsort = rsort; +function rsort(list, loose) { + return list.sort(function(a, b) { + return exports.rcompare(a, b, loose); + }); +} + +exports.gt = gt; +function gt(a, b, loose) { + return compare(a, b, loose) > 0; +} + +exports.lt = lt; +function lt(a, b, loose) { + return compare(a, b, loose) < 0; +} + +exports.eq = eq; +function eq(a, b, loose) { + return compare(a, b, loose) === 0; +} + +exports.neq = neq; +function neq(a, b, loose) { + return compare(a, b, loose) !== 0; +} + +exports.gte = gte; +function gte(a, b, loose) { + return compare(a, b, loose) >= 0; +} + +exports.lte = lte; +function lte(a, b, loose) { + return compare(a, b, loose) <= 0; +} + +exports.cmp = cmp; +function cmp(a, op, b, loose) { + var ret; + switch (op) { + case '===': ret = a === b; break; + case '!==': ret = a !== b; break; + case '': case '=': case '==': ret = eq(a, b, loose); break; + case '!=': ret = neq(a, b, loose); break; + case '>': ret = gt(a, b, loose); break; + case '>=': ret = gte(a, b, loose); break; + case '<': ret = lt(a, b, loose); break; + case '<=': ret = lte(a, b, loose); break; + default: throw new TypeError('Invalid operator: ' + op); + } + return ret; +} + +exports.Comparator = Comparator; +function Comparator(comp, loose) { + if (comp instanceof Comparator) { + if (comp.loose === loose) + return comp; + else + comp = comp.value; + } + + if (!(this instanceof Comparator)) + return new Comparator(comp, loose); + + debug('comparator', comp, loose); + this.loose = loose; + this.parse(comp); + + if (this.semver === ANY) + this.value = ''; + else + this.value = this.operator + this.semver.version; +} + +var ANY = {}; +Comparator.prototype.parse = function(comp) { + var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; + var m = comp.match(r); + + if (!m) + throw new TypeError('Invalid comparator: ' + comp); + + this.operator = m[1]; + // if it literally is just '>' or '' then allow anything. + if (!m[2]) + this.semver = ANY; + else { + this.semver = new SemVer(m[2], this.loose); + + // <1.2.3-rc DOES allow 1.2.3-beta (has prerelease) + // >=1.2.3 DOES NOT allow 1.2.3-beta + // <=1.2.3 DOES allow 1.2.3-beta + // However, <1.2.3 does NOT allow 1.2.3-beta, + // even though `1.2.3-beta < 1.2.3` + // The assumption is that the 1.2.3 version has something you + // *don't* want, so we push the prerelease down to the minimum. + if (this.operator === '<' && !this.semver.prerelease.length) { + this.semver.prerelease = ['0']; + this.semver.format(); + } + } +}; + +Comparator.prototype.inspect = function() { + return '<SemVer Comparator "' + this + '">'; +}; + +Comparator.prototype.toString = function() { + return this.value; +}; + +Comparator.prototype.test = function(version) { + debug('Comparator.test', version, this.loose); + return (this.semver === ANY) ? true : + cmp(version, this.operator, this.semver, this.loose); +}; + + +exports.Range = Range; +function Range(range, loose) { + if ((range instanceof Range) && range.loose === loose) + return range; + + if (!(this instanceof Range)) + return new Range(range, loose); + + this.loose = loose; + + // First, split based on boolean or || + this.raw = range; + this.set = range.split(/\s*\|\|\s*/).map(function(range) { + return this.parseRange(range.trim()); + }, this).filter(function(c) { + // throw out any that are not relevant for whatever reason + return c.length; + }); + + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range); + } + + this.format(); +} + +Range.prototype.inspect = function() { + return '<SemVer Range "' + this.range + '">'; +}; + +Range.prototype.format = function() { + this.range = this.set.map(function(comps) { + return comps.join(' ').trim(); + }).join('||').trim(); + return this.range; +}; + +Range.prototype.toString = function() { + return this.range; +}; + +Range.prototype.parseRange = function(range) { + var loose = this.loose; + range = range.trim(); + debug('range', range, loose); + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]; + range = range.replace(hr, hyphenReplace); + debug('hyphen replace', range); + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace); + debug('comparator trim', range, re[COMPARATORTRIM]); + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[TILDETRIM], tildeTrimReplace); + + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[CARETTRIM], caretTrimReplace); + + // normalize spaces + range = range.split(/\s+/).join(' '); + + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]; + var set = range.split(' ').map(function(comp) { + return parseComparator(comp, loose); + }).join(' ').split(/\s+/); + if (this.loose) { + // in loose mode, throw out any that are not valid comparators + set = set.filter(function(comp) { + return !!comp.match(compRe); + }); + } + set = set.map(function(comp) { + return new Comparator(comp, loose); + }); + + return set; +}; + +// Mostly just for testing and legacy API reasons +exports.toComparators = toComparators; +function toComparators(range, loose) { + return new Range(range, loose).set.map(function(comp) { + return comp.map(function(c) { + return c.value; + }).join(' ').trim().split(' '); + }); +} + +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +function parseComparator(comp, loose) { + debug('comp', comp); + comp = replaceCarets(comp, loose); + debug('caret', comp); + comp = replaceTildes(comp, loose); + debug('tildes', comp); + comp = replaceXRanges(comp, loose); + debug('xrange', comp); + comp = replaceStars(comp, loose); + debug('stars', comp); + return comp; +} + +function isX(id) { + return !id || id.toLowerCase() === 'x' || id === '*'; +} + +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 +function replaceTildes(comp, loose) { + return comp.trim().split(/\s+/).map(function(comp) { + return replaceTilde(comp, loose); + }).join(' '); +} + +function replaceTilde(comp, loose) { + var r = loose ? re[TILDELOOSE] : re[TILDE]; + return comp.replace(r, function(_, M, m, p, pr) { + debug('tilde', comp, _, M, m, p, pr); + var ret; + + if (isX(M)) + ret = ''; + else if (isX(m)) + ret = '>=' + M + '.0.0-0 <' + (+M + 1) + '.0.0-0'; + else if (isX(p)) + // ~1.2 == >=1.2.0- <1.3.0- + ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0'; + else if (pr) { + debug('replaceTilde pr', pr); + if (pr.charAt(0) !== '-') + pr = '-' + pr; + ret = '>=' + M + '.' + m + '.' + p + pr + + ' <' + M + '.' + (+m + 1) + '.0-0'; + } else + // ~1.2.3 == >=1.2.3-0 <1.3.0-0 + ret = '>=' + M + '.' + m + '.' + p + '-0' + + ' <' + M + '.' + (+m + 1) + '.0-0'; + + debug('tilde return', ret); + return ret; + }); +} + +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 +// ^1.2.3 --> >=1.2.3 <2.0.0 +// ^1.2.0 --> >=1.2.0 <2.0.0 +function replaceCarets(comp, loose) { + return comp.trim().split(/\s+/).map(function(comp) { + return replaceCaret(comp, loose); + }).join(' '); +} + +function replaceCaret(comp, loose) { + var r = loose ? re[CARETLOOSE] : re[CARET]; + return comp.replace(r, function(_, M, m, p, pr) { + debug('caret', comp, _, M, m, p, pr); + var ret; + + if (isX(M)) + ret = ''; + else if (isX(m)) + ret = '>=' + M + '.0.0-0 <' + (+M + 1) + '.0.0-0'; + else if (isX(p)) { + if (M === '0') + ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0'; + else + ret = '>=' + M + '.' + m + '.0-0 <' + (+M + 1) + '.0.0-0'; + } else if (pr) { + debug('replaceCaret pr', pr); + if (pr.charAt(0) !== '-') + pr = '-' + pr; + if (M === '0') { + if (m === '0') + ret = '=' + M + '.' + m + '.' + p + pr; + else + ret = '>=' + M + '.' + m + '.' + p + pr + + ' <' + M + '.' + (+m + 1) + '.0-0'; + } else + ret = '>=' + M + '.' + m + '.' + p + pr + + ' <' + (+M + 1) + '.0.0-0'; + } else { + if (M === '0') { + if (m === '0') + ret = '=' + M + '.' + m + '.' + p; + else + ret = '>=' + M + '.' + m + '.' + p + '-0' + + ' <' + M + '.' + (+m + 1) + '.0-0'; + } else + ret = '>=' + M + '.' + m + '.' + p + '-0' + + ' <' + (+M + 1) + '.0.0-0'; + } + + debug('caret return', ret); + return ret; + }); +} + +function replaceXRanges(comp, loose) { + debug('replaceXRanges', comp, loose); + return comp.split(/\s+/).map(function(comp) { + return replaceXRange(comp, loose); + }).join(' '); +} + +function replaceXRange(comp, loose) { + comp = comp.trim(); + var r = loose ? re[XRANGELOOSE] : re[XRANGE]; + return comp.replace(r, function(ret, gtlt, M, m, p, pr) { + debug('xRange', comp, ret, gtlt, M, m, p, pr); + var xM = isX(M); + var xm = xM || isX(m); + var xp = xm || isX(p); + var anyX = xp; + + if (gtlt === '=' && anyX) + gtlt = ''; + + if (gtlt && anyX) { + // replace X with 0, and then append the -0 min-prerelease + if (xM) + M = 0; + if (xm) + m = 0; + if (xp) + p = 0; + + if (gtlt === '>') { + // >1 => >=2.0.0-0 + // >1.2 => >=1.3.0-0 + // >1.2.3 => >= 1.2.4-0 + gtlt = '>='; + if (xM) { + // no change + } else if (xm) { + M = +M + 1; + m = 0; + p = 0; + } else if (xp) { + m = +m + 1; + p = 0; + } + } + + + ret = gtlt + M + '.' + m + '.' + p + '-0'; + } else if (xM) { + // allow any + ret = '*'; + } else if (xm) { + // append '-0' onto the version, otherwise + // '1.x.x' matches '2.0.0-beta', since the tag + // *lowers* the version value + ret = '>=' + M + '.0.0-0 <' + (+M + 1) + '.0.0-0'; + } else if (xp) { + ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0'; + } + + debug('xRange return', ret); + + return ret; + }); +} + +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +function replaceStars(comp, loose) { + debug('replaceStars', comp, loose); + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[STAR], ''); +} + +// This function is passed to string.replace(re[HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0-0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0-0 <3.5.0-0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0-0 <3.5.0-0 +function hyphenReplace($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) { + + if (isX(fM)) + from = ''; + else if (isX(fm)) + from = '>=' + fM + '.0.0-0'; + else if (isX(fp)) + from = '>=' + fM + '.' + fm + '.0-0'; + else + from = '>=' + from; + + if (isX(tM)) + to = ''; + else if (isX(tm)) + to = '<' + (+tM + 1) + '.0.0-0'; + else if (isX(tp)) + to = '<' + tM + '.' + (+tm + 1) + '.0-0'; + else if (tpr) + to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr; + else + to = '<=' + to; + + return (from + ' ' + to).trim(); +} + + +// if ANY of the sets match ALL of its comparators, then pass +Range.prototype.test = function(version) { + if (!version) + return false; + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version)) + return true; + } + return false; +}; + +function testSet(set, version) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) + return false; + } + return true; +} + +exports.satisfies = satisfies; +function satisfies(version, range, loose) { + try { + range = new Range(range, loose); + } catch (er) { + return false; + } + return range.test(version); +} + +exports.maxSatisfying = maxSatisfying; +function maxSatisfying(versions, range, loose) { + return versions.filter(function(version) { + return satisfies(version, range, loose); + }).sort(function(a, b) { + return rcompare(a, b, loose); + })[0] || null; +} + +exports.validRange = validRange; +function validRange(range, loose) { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, loose).range || '*'; + } catch (er) { + return null; + } +} + +// Determine if version is less than all the versions possible in the range +exports.ltr = ltr; +function ltr(version, range, loose) { + return outside(version, range, '<', loose); +} + +// Determine if version is greater than all the versions possible in the range. +exports.gtr = gtr; +function gtr(version, range, loose) { + return outside(version, range, '>', loose); +} + +exports.outside = outside; +function outside(version, range, hilo, loose) { + version = new SemVer(version, loose); + range = new Range(range, loose); + + var gtfn, ltefn, ltfn, comp, ecomp; + switch (hilo) { + case '>': + gtfn = gt; + ltefn = lte; + ltfn = lt; + comp = '>'; + ecomp = '>='; + break; + case '<': + gtfn = lt; + ltefn = gte; + ltfn = gt; + comp = '<'; + ecomp = '<='; + break; + default: + throw new TypeError('Must provide a hilo val of "<" or ">"'); + } + + // If it satisifes the range it is not outside + if (satisfies(version, range, loose)) { + return false; + } + + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. + + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i]; + + var high = null; + var low = null; + + comparators.forEach(function(comparator) { + high = high || comparator; + low = low || comparator; + if (gtfn(comparator.semver, high.semver, loose)) { + high = comparator; + } else if (ltfn(comparator.semver, low.semver, loose)) { + low = comparator; + } + }); + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false; + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false; + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false; + } + } + return true; +} + +// Use the define() function if we're in AMD land +if (typeof define === 'function' && define.amd) + define(exports); diff --git a/node_modules/node-gyp/node_modules/semver/semver.min.js b/node_modules/node-gyp/node_modules/semver/semver.min.js new file mode 100644 index 000000000..c2164c33e --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/semver.min.js @@ -0,0 +1 @@ +(function(e){if(typeof module==="object"&&module.exports===e)e=module.exports=H;e.SEMVER_SPEC_VERSION="2.0.0";var r=e.re=[];var t=e.src=[];var n=0;var i=n++;t[i]="0|[1-9]\\d*";var s=n++;t[s]="[0-9]+";var o=n++;t[o]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var a=n++;t[a]="("+t[i]+")\\."+"("+t[i]+")\\."+"("+t[i]+")";var f=n++;t[f]="("+t[s]+")\\."+"("+t[s]+")\\."+"("+t[s]+")";var u=n++;t[u]="(?:"+t[i]+"|"+t[o]+")";var l=n++;t[l]="(?:"+t[s]+"|"+t[o]+")";var c=n++;t[c]="(?:-("+t[u]+"(?:\\."+t[u]+")*))";var p=n++;t[p]="(?:-?("+t[l]+"(?:\\."+t[l]+")*))";var h=n++;t[h]="[0-9A-Za-z-]+";var v=n++;t[v]="(?:\\+("+t[h]+"(?:\\."+t[h]+")*))";var m=n++;var g="v?"+t[a]+t[c]+"?"+t[v]+"?";t[m]="^"+g+"$";var w="[v=\\s]*"+t[f]+t[p]+"?"+t[v]+"?";var d=n++;t[d]="^"+w+"$";var y=n++;t[y]="((?:<|>)?=?)";var $=n++;t[$]=t[s]+"|x|X|\\*";var j=n++;t[j]=t[i]+"|x|X|\\*";var b=n++;t[b]="[v=\\s]*("+t[j]+")"+"(?:\\.("+t[j]+")"+"(?:\\.("+t[j]+")"+"(?:("+t[c]+")"+")?)?)?";var E=n++;t[E]="[v=\\s]*("+t[$]+")"+"(?:\\.("+t[$]+")"+"(?:\\.("+t[$]+")"+"(?:("+t[p]+")"+")?)?)?";var k=n++;t[k]="^"+t[y]+"\\s*"+t[b]+"$";var x=n++;t[x]="^"+t[y]+"\\s*"+t[E]+"$";var R=n++;t[R]="(?:~>?)";var S=n++;t[S]="(\\s*)"+t[R]+"\\s+";r[S]=new RegExp(t[S],"g");var V="$1~";var I=n++;t[I]="^"+t[R]+t[b]+"$";var A=n++;t[A]="^"+t[R]+t[E]+"$";var C=n++;t[C]="(?:\\^)";var T=n++;t[T]="(\\s*)"+t[C]+"\\s+";r[T]=new RegExp(t[T],"g");var M="$1^";var z=n++;t[z]="^"+t[C]+t[b]+"$";var P=n++;t[P]="^"+t[C]+t[E]+"$";var Z=n++;t[Z]="^"+t[y]+"\\s*("+w+")$|^$";var q=n++;t[q]="^"+t[y]+"\\s*("+g+")$|^$";var L=n++;t[L]="(\\s*)"+t[y]+"\\s*("+w+"|"+t[b]+")";r[L]=new RegExp(t[L],"g");var X="$1$2$3";var _=n++;t[_]="^\\s*("+t[b]+")"+"\\s+-\\s+"+"("+t[b]+")"+"\\s*$";var N=n++;t[N]="^\\s*("+t[E]+")"+"\\s+-\\s+"+"("+t[E]+")"+"\\s*$";var O=n++;t[O]="(<|>)?=?\\s*\\*";for(var B=0;B<n;B++){if(!r[B])r[B]=new RegExp(t[B])}e.parse=D;function D(e,t){var n=t?r[d]:r[m];return n.test(e)?new H(e,t):null}e.valid=F;function F(e,r){var t=D(e,r);return t?t.version:null}e.clean=G;function G(e,r){var t=D(e,r);return t?t.version:null}e.SemVer=H;function H(e,t){if(e instanceof H){if(e.loose===t)return e;else e=e.version}if(!(this instanceof H))return new H(e,t);this.loose=t;var n=e.trim().match(t?r[d]:r[m]);if(!n)throw new TypeError("Invalid Version: "+e);this.raw=e;this.major=+n[1];this.minor=+n[2];this.patch=+n[3];if(!n[4])this.prerelease=[];else this.prerelease=n[4].split(".").map(function(e){return/^[0-9]+$/.test(e)?+e:e});this.build=n[5]?n[5].split("."):[];this.format()}H.prototype.format=function(){this.version=this.major+"."+this.minor+"."+this.patch;if(this.prerelease.length)this.version+="-"+this.prerelease.join(".");return this.version};H.prototype.inspect=function(){return'<SemVer "'+this+'">'};H.prototype.toString=function(){return this.version};H.prototype.compare=function(e){if(!(e instanceof H))e=new H(e,this.loose);return this.compareMain(e)||this.comparePre(e)};H.prototype.compareMain=function(e){if(!(e instanceof H))e=new H(e,this.loose);return Q(this.major,e.major)||Q(this.minor,e.minor)||Q(this.patch,e.patch)};H.prototype.comparePre=function(e){if(!(e instanceof H))e=new H(e,this.loose);if(this.prerelease.length&&!e.prerelease.length)return-1;else if(!this.prerelease.length&&e.prerelease.length)return 1;else if(!this.prerelease.lenth&&!e.prerelease.length)return 0;var r=0;do{var t=this.prerelease[r];var n=e.prerelease[r];if(t===undefined&&n===undefined)return 0;else if(n===undefined)return 1;else if(t===undefined)return-1;else if(t===n)continue;else return Q(t,n)}while(++r)};H.prototype.inc=function(e){switch(e){case"major":this.major++;this.minor=-1;case"minor":this.minor++;this.patch=-1;case"patch":this.patch++;this.prerelease=[];break;case"prerelease":if(this.prerelease.length===0)this.prerelease=[0];else{var r=this.prerelease.length;while(--r>=0){if(typeof this.prerelease[r]==="number"){this.prerelease[r]++;r=-2}}if(r===-1)this.prerelease.push(0)}break;default:throw new Error("invalid increment argument: "+e)}this.format();return this};e.inc=J;function J(e,r,t){try{return new H(e,t).inc(r).version}catch(n){return null}}e.compareIdentifiers=Q;var K=/^[0-9]+$/;function Q(e,r){var t=K.test(e);var n=K.test(r);if(t&&n){e=+e;r=+r}return t&&!n?-1:n&&!t?1:e<r?-1:e>r?1:0}e.rcompareIdentifiers=U;function U(e,r){return Q(r,e)}e.compare=W;function W(e,r,t){return new H(e,t).compare(r)}e.compareLoose=Y;function Y(e,r){return W(e,r,true)}e.rcompare=er;function er(e,r,t){return W(r,e,t)}e.sort=rr;function rr(r,t){return r.sort(function(r,n){return e.compare(r,n,t)})}e.rsort=tr;function tr(r,t){return r.sort(function(r,n){return e.rcompare(r,n,t)})}e.gt=nr;function nr(e,r,t){return W(e,r,t)>0}e.lt=ir;function ir(e,r,t){return W(e,r,t)<0}e.eq=sr;function sr(e,r,t){return W(e,r,t)===0}e.neq=or;function or(e,r,t){return W(e,r,t)!==0}e.gte=ar;function ar(e,r,t){return W(e,r,t)>=0}e.lte=fr;function fr(e,r,t){return W(e,r,t)<=0}e.cmp=ur;function ur(e,r,t,n){var i;switch(r){case"===":i=e===t;break;case"!==":i=e!==t;break;case"":case"=":case"==":i=sr(e,t,n);break;case"!=":i=or(e,t,n);break;case">":i=nr(e,t,n);break;case">=":i=ar(e,t,n);break;case"<":i=ir(e,t,n);break;case"<=":i=fr(e,t,n);break;default:throw new TypeError("Invalid operator: "+r)}return i}e.Comparator=lr;function lr(e,r){if(e instanceof lr){if(e.loose===r)return e;else e=e.value}if(!(this instanceof lr))return new lr(e,r);this.loose=r;this.parse(e);if(this.semver===cr)this.value="";else this.value=this.operator+this.semver.version}var cr={};lr.prototype.parse=function(e){var t=this.loose?r[Z]:r[q];var n=e.match(t);if(!n)throw new TypeError("Invalid comparator: "+e);this.operator=n[1];if(!n[2])this.semver=cr;else{this.semver=new H(n[2],this.loose);if(this.operator==="<"&&!this.semver.prerelease.length){this.semver.prerelease=["0"];this.semver.format()}}};lr.prototype.inspect=function(){return'<SemVer Comparator "'+this+'">'};lr.prototype.toString=function(){return this.value};lr.prototype.test=function(e){return this.semver===cr?true:ur(e,this.operator,this.semver,this.loose)};e.Range=pr;function pr(e,r){if(e instanceof pr&&e.loose===r)return e;if(!(this instanceof pr))return new pr(e,r);this.loose=r;this.raw=e;this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length});if(!this.set.length){throw new TypeError("Invalid SemVer Range: "+e)}this.format()}pr.prototype.inspect=function(){return'<SemVer Range "'+this.range+'">'};pr.prototype.format=function(){this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim();return this.range};pr.prototype.toString=function(){return this.range};pr.prototype.parseRange=function(e){var t=this.loose;e=e.trim();var n=t?r[N]:r[_];e=e.replace(n,Er);e=e.replace(r[L],X);e=e.replace(r[S],V);e=e.replace(r[T],M);e=e.split(/\s+/).join(" ");var i=t?r[Z]:r[q];var s=e.split(" ").map(function(e){return vr(e,t)}).join(" ").split(/\s+/);if(this.loose){s=s.filter(function(e){return!!e.match(i)})}s=s.map(function(e){return new lr(e,t)});return s};e.toComparators=hr;function hr(e,r){return new pr(e,r).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})}function vr(e,r){e=dr(e,r);e=gr(e,r);e=$r(e,r);e=br(e,r);return e}function mr(e){return!e||e.toLowerCase()==="x"||e==="*"}function gr(e,r){return e.trim().split(/\s+/).map(function(e){return wr(e,r)}).join(" ")}function wr(e,t){var n=t?r[A]:r[I];return e.replace(n,function(e,r,t,n,i){var s;if(mr(r))s="";else if(mr(t))s=">="+r+".0.0-0 <"+(+r+1)+".0.0-0";else if(mr(n))s=">="+r+"."+t+".0-0 <"+r+"."+(+t+1)+".0-0";else if(i){if(i.charAt(0)!=="-")i="-"+i;s=">="+r+"."+t+"."+n+i+" <"+r+"."+(+t+1)+".0-0"}else s=">="+r+"."+t+"."+n+"-0"+" <"+r+"."+(+t+1)+".0-0";return s})}function dr(e,r){return e.trim().split(/\s+/).map(function(e){return yr(e,r)}).join(" ")}function yr(e,t){var n=t?r[P]:r[z];return e.replace(n,function(e,r,t,n,i){var s;if(mr(r))s="";else if(mr(t))s=">="+r+".0.0-0 <"+(+r+1)+".0.0-0";else if(mr(n)){if(r==="0")s=">="+r+"."+t+".0-0 <"+r+"."+(+t+1)+".0-0";else s=">="+r+"."+t+".0-0 <"+(+r+1)+".0.0-0"}else if(i){if(i.charAt(0)!=="-")i="-"+i;if(r==="0"){if(t==="0")s="="+r+"."+t+"."+n+i;else s=">="+r+"."+t+"."+n+i+" <"+r+"."+(+t+1)+".0-0"}else s=">="+r+"."+t+"."+n+i+" <"+(+r+1)+".0.0-0"}else{if(r==="0"){if(t==="0")s="="+r+"."+t+"."+n;else s=">="+r+"."+t+"."+n+"-0"+" <"+r+"."+(+t+1)+".0-0"}else s=">="+r+"."+t+"."+n+"-0"+" <"+(+r+1)+".0.0-0"}return s})}function $r(e,r){return e.split(/\s+/).map(function(e){return jr(e,r)}).join(" ")}function jr(e,t){e=e.trim();var n=t?r[x]:r[k];return e.replace(n,function(e,r,t,n,i,s){var o=mr(t);var a=o||mr(n);var f=a||mr(i);var u=f;if(r==="="&&u)r="";if(r&&u){if(o)t=0;if(a)n=0;if(f)i=0;if(r===">"){r=">=";if(o){}else if(a){t=+t+1;n=0;i=0}else if(f){n=+n+1;i=0}}e=r+t+"."+n+"."+i+"-0"}else if(o){e="*"}else if(a){e=">="+t+".0.0-0 <"+(+t+1)+".0.0-0"}else if(f){e=">="+t+"."+n+".0-0 <"+t+"."+(+n+1)+".0-0"}return e})}function br(e,t){return e.trim().replace(r[O],"")}function Er(e,r,t,n,i,s,o,a,f,u,l,c,p){if(mr(t))r="";else if(mr(n))r=">="+t+".0.0-0";else if(mr(i))r=">="+t+"."+n+".0-0";else r=">="+r;if(mr(f))a="";else if(mr(u))a="<"+(+f+1)+".0.0-0";else if(mr(l))a="<"+f+"."+(+u+1)+".0-0";else if(c)a="<="+f+"."+u+"."+l+"-"+c;else a="<="+a;return(r+" "+a).trim()}pr.prototype.test=function(e){if(!e)return false;for(var r=0;r<this.set.length;r++){if(kr(this.set[r],e))return true}return false};function kr(e,r){for(var t=0;t<e.length;t++){if(!e[t].test(r))return false}return true}e.satisfies=xr;function xr(e,r,t){try{r=new pr(r,t)}catch(n){return false}return r.test(e)}e.maxSatisfying=Rr;function Rr(e,r,t){return e.filter(function(e){return xr(e,r,t)}).sort(function(e,r){return er(e,r,t)})[0]||null}e.validRange=Sr;function Sr(e,r){try{return new pr(e,r).range||"*"}catch(t){return null}}e.ltr=Vr;function Vr(e,r,t){return Ar(e,r,"<",t)}e.gtr=Ir;function Ir(e,r,t){return Ar(e,r,">",t)}e.outside=Ar;function Ar(e,r,t,n){e=new H(e,n);r=new pr(r,n);var i,s,o,a,f;switch(t){case">":i=nr;s=fr;o=ir;a=">";f=">=";break;case"<":i=ir;s=ar;o=nr;a="<";f="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(xr(e,r,n)){return false}for(var u=0;u<r.set.length;++u){var l=r.set[u];var c=null;var p=null;l.forEach(function(e){c=c||e;p=p||e;if(i(e.semver,c.semver,n)){c=e}else if(o(e.semver,p.semver,n)){p=e}});if(c.operator===a||c.operator===f){return false}if((!p.operator||p.operator===a)&&s(e,p.semver)){return false}else if(p.operator===f&&o(e,p.semver)){return false}}return true}if(typeof define==="function"&&define.amd)define(e)})(typeof exports==="object"?exports:typeof define==="function"&&define.amd?{}:semver={});
\ No newline at end of file diff --git a/node_modules/node-gyp/node_modules/semver/semver.min.js.gz b/node_modules/node-gyp/node_modules/semver/semver.min.js.gz Binary files differnew file mode 100644 index 000000000..e82da41e3 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/semver.min.js.gz diff --git a/node_modules/node-gyp/node_modules/semver/test/amd.js b/node_modules/node-gyp/node_modules/semver/test/amd.js new file mode 100644 index 000000000..a6041341b --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/test/amd.js @@ -0,0 +1,15 @@ +var tap = require('tap'); +var test = tap.test; + +test('amd', function(t) { + global.define = define; + define.amd = true; + var defined = null; + function define(stuff) { + defined = stuff; + } + var fromRequire = require('../'); + t.ok(defined, 'amd function called'); + t.equal(fromRequire, defined, 'amd stuff same as require stuff'); + t.end(); +}); diff --git a/node_modules/node-gyp/node_modules/semver/test/gtr.js b/node_modules/node-gyp/node_modules/semver/test/gtr.js new file mode 100644 index 000000000..cb6199efc --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/test/gtr.js @@ -0,0 +1,173 @@ +var tap = require('tap'); +var test = tap.test; +var semver = require('../semver.js'); +var gtr = semver.gtr; + +test('\ngtr tests', function(t) { + // [range, version, loose] + // Version should be greater than range + [ + ['~1.2.2', '1.3.0'], + ['~0.6.1-1', '0.7.1-1'], + ['1.0.0 - 2.0.0', '2.0.1'], + ['1.0.0', '1.0.1-beta1'], + ['1.0.0', '2.0.0'], + ['<=2.0.0', '2.1.1'], + ['<=2.0.0', '3.2.9'], + ['<2.0.0', '2.0.0'], + ['0.1.20 || 1.2.4', '1.2.5'], + ['2.x.x', '3.0.0'], + ['1.2.x', '1.3.0'], + ['1.2.x || 2.x', '3.0.0'], + ['2.*.*', '5.0.1'], + ['1.2.*', '1.3.3'], + ['1.2.* || 2.*', '4.0.0'], + ['2', '3.0.0'], + ['2.3', '2.4.2'], + ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.5.5'], + ['~>3.2.1', '3.3.0'], // >=3.2.1 <3.3.0 + ['~1', '2.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '2.2.4'], + ['~> 1', '3.2.3'], + ['~1.0', '1.1.2'], // >=1.0.0 <1.1.0 + ['~ 1.0', '1.1.0'], + ['<1.2', '1.2.0'], + ['< 1.2', '1.2.1'], + ['1', '2.0.0beta', true], + ['~v0.5.4-pre', '0.6.0'], + ['~v0.5.4-pre', '0.6.1-pre'], + ['=0.7.x', '0.8.0'], + ['=0.7.x', '0.8.0-asdf'], + ['<=0.7.x', '0.7.0'], + ['~1.2.2', '1.3.0'], + ['1.0.0 - 2.0.0', '2.2.3'], + ['1.0.0', '1.0.1'], + ['<=2.0.0', '3.0.0'], + ['<=2.0.0', '2.9999.9999'], + ['<=2.0.0', '2.2.9'], + ['<2.0.0', '2.9999.9999'], + ['<2.0.0', '2.2.9'], + ['2.x.x', '3.1.3'], + ['1.2.x', '1.3.3'], + ['1.2.x || 2.x', '3.1.3'], + ['2.*.*', '3.1.3'], + ['1.2.*', '1.3.3'], + ['1.2.* || 2.*', '3.1.3'], + ['2', '3.1.2'], + ['2.3', '2.4.1'], + ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 + ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 + ['~1', '2.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '2.2.3'], + ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 + ['<1', '1.0.0'], + ['1', '2.0.0beta', true], + ['<1', '1.0.0beta', true], + ['< 1', '1.0.0beta', true], + ['=0.7.x', '0.8.2'], + ['<=0.7.x', '0.7.2'] + ].forEach(function(tuple) { + var range = tuple[0]; + var version = tuple[1]; + var loose = tuple[2] || false; + var msg = 'gtr(' + version + ', ' + range + ', ' + loose + ')'; + t.ok(gtr(version, range, loose), msg); + }); + t.end(); +}); + +test('\nnegative gtr tests', function(t) { + // [range, version, loose] + // Version should NOT be greater than range + [ + ['~0.6.1-1', '0.6.1-1'], + ['1.0.0 - 2.0.0', '1.2.3'], + ['1.0.0 - 2.0.0', '0.9.9'], + ['1.0.0', '1.0.0'], + ['>=*', '0.2.4'], + ['', '1.0.0', true], + ['*', '1.2.3'], + ['*', 'v1.2.3-foo'], + ['>=1.0.0', '1.0.0'], + ['>=1.0.0', '1.0.1'], + ['>=1.0.0', '1.1.0'], + ['>1.0.0', '1.0.1'], + ['>1.0.0', '1.1.0'], + ['<=2.0.0', '2.0.0'], + ['<=2.0.0', '1.9999.9999'], + ['<=2.0.0', '0.2.9'], + ['<2.0.0', '1.9999.9999'], + ['<2.0.0', '0.2.9'], + ['>= 1.0.0', '1.0.0'], + ['>= 1.0.0', '1.0.1'], + ['>= 1.0.0', '1.1.0'], + ['> 1.0.0', '1.0.1'], + ['> 1.0.0', '1.1.0'], + ['<= 2.0.0', '2.0.0'], + ['<= 2.0.0', '1.9999.9999'], + ['<= 2.0.0', '0.2.9'], + ['< 2.0.0', '1.9999.9999'], + ['<\t2.0.0', '0.2.9'], + ['>=0.1.97', 'v0.1.97'], + ['>=0.1.97', '0.1.97'], + ['0.1.20 || 1.2.4', '1.2.4'], + ['0.1.20 || >1.2.4', '1.2.4'], + ['0.1.20 || 1.2.4', '1.2.3'], + ['0.1.20 || 1.2.4', '0.1.20'], + ['>=0.2.3 || <0.0.1', '0.0.0'], + ['>=0.2.3 || <0.0.1', '0.2.3'], + ['>=0.2.3 || <0.0.1', '0.2.4'], + ['||', '1.3.4'], + ['2.x.x', '2.1.3'], + ['1.2.x', '1.2.3'], + ['1.2.x || 2.x', '2.1.3'], + ['1.2.x || 2.x', '1.2.3'], + ['x', '1.2.3'], + ['2.*.*', '2.1.3'], + ['1.2.*', '1.2.3'], + ['1.2.* || 2.*', '2.1.3'], + ['1.2.* || 2.*', '1.2.3'], + ['1.2.* || 2.*', '1.2.3'], + ['*', '1.2.3'], + ['2', '2.1.2'], + ['2.3', '2.3.1'], + ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.5'], + ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0 + ['~1', '1.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '1.2.3'], + ['~> 1', '1.2.3'], + ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0 + ['~ 1.0', '1.0.2'], + ['>=1', '1.0.0'], + ['>= 1', '1.0.0'], + ['<1.2', '1.1.1'], + ['< 1.2', '1.1.1'], + ['1', '1.0.0beta', true], + ['~v0.5.4-pre', '0.5.5'], + ['~v0.5.4-pre', '0.5.4'], + ['=0.7.x', '0.7.2'], + ['>=0.7.x', '0.7.2'], + ['=0.7.x', '0.7.0-asdf'], + ['>=0.7.x', '0.7.0-asdf'], + ['<=0.7.x', '0.6.2'], + ['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'], + ['>=0.2.3 <=0.2.4', '0.2.4'], + ['1.0.0 - 2.0.0', '2.0.0'], + ['^1', '0.0.0-0'], + ['^3.0.0', '2.0.0'], + ['^1.0.0 || ~2.0.1', '2.0.0'], + ['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'], + ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true], + ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true], + ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'] + ].forEach(function(tuple) { + var range = tuple[0]; + var version = tuple[1]; + var loose = tuple[2] || false; + var msg = '!gtr(' + version + ', ' + range + ', ' + loose + ')'; + t.notOk(gtr(version, range, loose), msg); + }); + t.end(); +}); diff --git a/node_modules/node-gyp/node_modules/semver/test/index.js b/node_modules/node-gyp/node_modules/semver/test/index.js new file mode 100644 index 000000000..e6c9cefb0 --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/test/index.js @@ -0,0 +1,556 @@ +var tap = require('tap'); +var test = tap.test; +var semver = require('../semver.js'); +var eq = semver.eq; +var gt = semver.gt; +var lt = semver.lt; +var neq = semver.neq; +var cmp = semver.cmp; +var gte = semver.gte; +var lte = semver.lte; +var satisfies = semver.satisfies; +var validRange = semver.validRange; +var inc = semver.inc; +var replaceStars = semver.replaceStars; +var toComparators = semver.toComparators; +var SemVer = semver.SemVer; +var Range = semver.Range; + +test('\ncomparison tests', function(t) { + // [version1, version2] + // version1 should be greater than version2 + [['0.0.0', '0.0.0-foo'], + ['0.0.1', '0.0.0'], + ['1.0.0', '0.9.9'], + ['0.10.0', '0.9.0'], + ['0.99.0', '0.10.0'], + ['2.0.0', '1.2.3'], + ['v0.0.0', '0.0.0-foo', true], + ['v0.0.1', '0.0.0', true], + ['v1.0.0', '0.9.9', true], + ['v0.10.0', '0.9.0', true], + ['v0.99.0', '0.10.0', true], + ['v2.0.0', '1.2.3', true], + ['0.0.0', 'v0.0.0-foo', true], + ['0.0.1', 'v0.0.0', true], + ['1.0.0', 'v0.9.9', true], + ['0.10.0', 'v0.9.0', true], + ['0.99.0', 'v0.10.0', true], + ['2.0.0', 'v1.2.3', true], + ['1.2.3', '1.2.3-asdf'], + ['1.2.3', '1.2.3-4'], + ['1.2.3', '1.2.3-4-foo'], + ['1.2.3-5-foo', '1.2.3-5'], + ['1.2.3-5', '1.2.3-4'], + ['1.2.3-5-foo', '1.2.3-5-Foo'], + ['3.0.0', '2.7.2+asdf'], + ['1.2.3-a.10', '1.2.3-a.5'], + ['1.2.3-a.b', '1.2.3-a.5'], + ['1.2.3-a.b', '1.2.3-a'], + ['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100'] + ].forEach(function(v) { + var v0 = v[0]; + var v1 = v[1]; + var loose = v[2]; + t.ok(gt(v0, v1, loose), "gt('" + v0 + "', '" + v1 + "')"); + t.ok(lt(v1, v0, loose), "lt('" + v1 + "', '" + v0 + "')"); + t.ok(!gt(v1, v0, loose), "!gt('" + v1 + "', '" + v0 + "')"); + t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')"); + t.ok(eq(v0, v0, loose), "eq('" + v0 + "', '" + v0 + "')"); + t.ok(eq(v1, v1, loose), "eq('" + v1 + "', '" + v1 + "')"); + t.ok(neq(v0, v1, loose), "neq('" + v0 + "', '" + v1 + "')"); + t.ok(cmp(v1, '==', v1, loose), "cmp('" + v1 + "' == '" + v1 + "')"); + t.ok(cmp(v0, '>=', v1, loose), "cmp('" + v0 + "' >= '" + v1 + "')"); + t.ok(cmp(v1, '<=', v0, loose), "cmp('" + v1 + "' <= '" + v0 + "')"); + t.ok(cmp(v0, '!=', v1, loose), "cmp('" + v0 + "' != '" + v1 + "')"); + }); + t.end(); +}); + +test('\nequality tests', function(t) { + // [version1, version2] + // version1 should be equivalent to version2 + [['1.2.3', 'v1.2.3', true], + ['1.2.3', '=1.2.3', true], + ['1.2.3', 'v 1.2.3', true], + ['1.2.3', '= 1.2.3', true], + ['1.2.3', ' v1.2.3', true], + ['1.2.3', ' =1.2.3', true], + ['1.2.3', ' v 1.2.3', true], + ['1.2.3', ' = 1.2.3', true], + ['1.2.3-0', 'v1.2.3-0', true], + ['1.2.3-0', '=1.2.3-0', true], + ['1.2.3-0', 'v 1.2.3-0', true], + ['1.2.3-0', '= 1.2.3-0', true], + ['1.2.3-0', ' v1.2.3-0', true], + ['1.2.3-0', ' =1.2.3-0', true], + ['1.2.3-0', ' v 1.2.3-0', true], + ['1.2.3-0', ' = 1.2.3-0', true], + ['1.2.3-1', 'v1.2.3-1', true], + ['1.2.3-1', '=1.2.3-1', true], + ['1.2.3-1', 'v 1.2.3-1', true], + ['1.2.3-1', '= 1.2.3-1', true], + ['1.2.3-1', ' v1.2.3-1', true], + ['1.2.3-1', ' =1.2.3-1', true], + ['1.2.3-1', ' v 1.2.3-1', true], + ['1.2.3-1', ' = 1.2.3-1', true], + ['1.2.3-beta', 'v1.2.3-beta', true], + ['1.2.3-beta', '=1.2.3-beta', true], + ['1.2.3-beta', 'v 1.2.3-beta', true], + ['1.2.3-beta', '= 1.2.3-beta', true], + ['1.2.3-beta', ' v1.2.3-beta', true], + ['1.2.3-beta', ' =1.2.3-beta', true], + ['1.2.3-beta', ' v 1.2.3-beta', true], + ['1.2.3-beta', ' = 1.2.3-beta', true], + ['1.2.3-beta+build', ' = 1.2.3-beta+otherbuild', true], + ['1.2.3+build', ' = 1.2.3+otherbuild', true], + ['1.2.3-beta+build', '1.2.3-beta+otherbuild'], + ['1.2.3+build', '1.2.3+otherbuild'], + [' v1.2.3+build', '1.2.3+otherbuild'] + ].forEach(function(v) { + var v0 = v[0]; + var v1 = v[1]; + var loose = v[2]; + t.ok(eq(v0, v1, loose), "eq('" + v0 + "', '" + v1 + "')"); + t.ok(!neq(v0, v1, loose), "!neq('" + v0 + "', '" + v1 + "')"); + t.ok(cmp(v0, '==', v1, loose), 'cmp(' + v0 + '==' + v1 + ')'); + t.ok(!cmp(v0, '!=', v1, loose), '!cmp(' + v0 + '!=' + v1 + ')'); + t.ok(!cmp(v0, '===', v1, loose), '!cmp(' + v0 + '===' + v1 + ')'); + t.ok(cmp(v0, '!==', v1, loose), 'cmp(' + v0 + '!==' + v1 + ')'); + t.ok(!gt(v0, v1, loose), "!gt('" + v0 + "', '" + v1 + "')"); + t.ok(gte(v0, v1, loose), "gte('" + v0 + "', '" + v1 + "')"); + t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')"); + t.ok(lte(v0, v1, loose), "lte('" + v0 + "', '" + v1 + "')"); + }); + t.end(); +}); + + +test('\nrange tests', function(t) { + // [range, version] + // version should be included by range + [['1.0.0 - 2.0.0', '1.2.3'], + ['1.0.0', '1.0.0'], + ['>=*', '0.2.4'], + ['', '1.0.0'], + ['*', '1.2.3'], + ['*', 'v1.2.3-foo', true], + ['>=1.0.0', '1.0.0'], + ['>=1.0.0', '1.0.1'], + ['>=1.0.0', '1.1.0'], + ['>1.0.0', '1.0.1'], + ['>1.0.0', '1.1.0'], + ['<=2.0.0', '2.0.0'], + ['<=2.0.0', '1.9999.9999'], + ['<=2.0.0', '0.2.9'], + ['<2.0.0', '1.9999.9999'], + ['<2.0.0', '0.2.9'], + ['>= 1.0.0', '1.0.0'], + ['>= 1.0.0', '1.0.1'], + ['>= 1.0.0', '1.1.0'], + ['> 1.0.0', '1.0.1'], + ['> 1.0.0', '1.1.0'], + ['<= 2.0.0', '2.0.0'], + ['<= 2.0.0', '1.9999.9999'], + ['<= 2.0.0', '0.2.9'], + ['< 2.0.0', '1.9999.9999'], + ['<\t2.0.0', '0.2.9'], + ['>=0.1.97', 'v0.1.97', true], + ['>=0.1.97', '0.1.97'], + ['0.1.20 || 1.2.4', '1.2.4'], + ['>=0.2.3 || <0.0.1', '0.0.0'], + ['>=0.2.3 || <0.0.1', '0.2.3'], + ['>=0.2.3 || <0.0.1', '0.2.4'], + ['||', '1.3.4'], + ['2.x.x', '2.1.3'], + ['1.2.x', '1.2.3'], + ['1.2.x || 2.x', '2.1.3'], + ['1.2.x || 2.x', '1.2.3'], + ['x', '1.2.3'], + ['2.*.*', '2.1.3'], + ['1.2.*', '1.2.3'], + ['1.2.* || 2.*', '2.1.3'], + ['1.2.* || 2.*', '1.2.3'], + ['*', '1.2.3'], + ['2', '2.1.2'], + ['2.3', '2.3.1'], + ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.5'], + ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0, + ['~1', '1.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '1.2.3'], + ['~> 1', '1.2.3'], + ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0, + ['~ 1.0', '1.0.2'], + ['~ 1.0.3', '1.0.12'], + ['>=1', '1.0.0'], + ['>= 1', '1.0.0'], + ['<1.2', '1.1.1'], + ['< 1.2', '1.1.1'], + ['1', '1.0.0beta', true], + ['~v0.5.4-pre', '0.5.5'], + ['~v0.5.4-pre', '0.5.4'], + ['=0.7.x', '0.7.2'], + ['>=0.7.x', '0.7.2'], + ['=0.7.x', '0.7.0-asdf'], + ['>=0.7.x', '0.7.0-asdf'], + ['<=0.7.x', '0.6.2'], + ['~1.2.1 >=1.2.3', '1.2.3'], + ['~1.2.1 =1.2.3', '1.2.3'], + ['~1.2.1 1.2.3', '1.2.3'], + ['~1.2.1 >=1.2.3 1.2.3', '1.2.3'], + ['~1.2.1 1.2.3 >=1.2.3', '1.2.3'], + ['~1.2.1 1.2.3', '1.2.3'], + ['>=1.2.1 1.2.3', '1.2.3'], + ['1.2.3 >=1.2.1', '1.2.3'], + ['>=1.2.3 >=1.2.1', '1.2.3'], + ['>=1.2.1 >=1.2.3', '1.2.3'], + ['<=1.2.3', '1.2.3-beta'], + ['>1.2', '1.3.0-beta'], + ['>=1.2', '1.2.8'], + ['^1.2.3', '1.8.1'], + ['^1.2.3', '1.2.3-beta'], + ['^0.1.2', '0.1.2'], + ['^0.1', '0.1.2'], + ['^1.2', '1.4.2'], + ['^1.2 ^1', '1.4.2'], + ['^1.2', '1.2.0-pre'], + ['^1.2.3', '1.2.3-pre'] + ].forEach(function(v) { + var range = v[0]; + var ver = v[1]; + var loose = v[2]; + t.ok(satisfies(ver, range, loose), range + ' satisfied by ' + ver); + }); + t.end(); +}); + +test('\nnegative range tests', function(t) { + // [range, version] + // version should not be included by range + [['1.0.0 - 2.0.0', '2.2.3'], + ['1.0.0', '1.0.1'], + ['>=1.0.0', '0.0.0'], + ['>=1.0.0', '0.0.1'], + ['>=1.0.0', '0.1.0'], + ['>1.0.0', '0.0.1'], + ['>1.0.0', '0.1.0'], + ['<=2.0.0', '3.0.0'], + ['<=2.0.0', '2.9999.9999'], + ['<=2.0.0', '2.2.9'], + ['<2.0.0', '2.9999.9999'], + ['<2.0.0', '2.2.9'], + ['>=0.1.97', 'v0.1.93', true], + ['>=0.1.97', '0.1.93'], + ['0.1.20 || 1.2.4', '1.2.3'], + ['>=0.2.3 || <0.0.1', '0.0.3'], + ['>=0.2.3 || <0.0.1', '0.2.2'], + ['2.x.x', '1.1.3'], + ['2.x.x', '3.1.3'], + ['1.2.x', '1.3.3'], + ['1.2.x || 2.x', '3.1.3'], + ['1.2.x || 2.x', '1.1.3'], + ['2.*.*', '1.1.3'], + ['2.*.*', '3.1.3'], + ['1.2.*', '1.3.3'], + ['1.2.* || 2.*', '3.1.3'], + ['1.2.* || 2.*', '1.1.3'], + ['2', '1.1.2'], + ['2.3', '2.4.1'], + ['~2.4', '2.5.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.3.9'], + ['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0 + ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 + ['~1', '0.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '2.2.3'], + ['~1.0', '1.1.0'], // >=1.0.0 <1.1.0 + ['<1', '1.0.0'], + ['>=1.2', '1.1.1'], + ['1', '2.0.0beta', true], + ['~v0.5.4-beta', '0.5.4-alpha'], + ['<1', '1.0.0beta', true], + ['< 1', '1.0.0beta', true], + ['=0.7.x', '0.8.2'], + ['>=0.7.x', '0.6.2'], + ['<=0.7.x', '0.7.2'], + ['<1.2.3', '1.2.3-beta'], + ['=1.2.3', '1.2.3-beta'], + ['>1.2', '1.2.8'], + ['^1.2.3', '2.0.0-alpha'], + ['^1.2.3', '1.2.2'], + ['^1.2', '1.1.9'], + // invalid ranges never satisfied! + ['blerg', '1.2.3'], + ['git+https://user:password0123@github.com/foo', '123.0.0', true], + ['^1.2.3', '2.0.0-pre'] + ].forEach(function(v) { + var range = v[0]; + var ver = v[1]; + var loose = v[2]; + var found = satisfies(ver, range, loose); + t.ok(!found, ver + ' not satisfied by ' + range); + }); + t.end(); +}); + +test('\nincrement versions test', function(t) { + // [version, inc, result] + // inc(version, inc) -> result + [['1.2.3', 'major', '2.0.0'], + ['1.2.3', 'minor', '1.3.0'], + ['1.2.3', 'patch', '1.2.4'], + ['1.2.3tag', 'major', '2.0.0', true], + ['1.2.3-tag', 'major', '2.0.0'], + ['1.2.3', 'fake', null], + ['fake', 'major', null], + ['1.2.3', 'prerelease', '1.2.3-0'], + ['1.2.3-0', 'prerelease', '1.2.3-1'], + ['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1'], + ['1.2.3-alpha.1', 'prerelease', '1.2.3-alpha.2'], + ['1.2.3-alpha.2', 'prerelease', '1.2.3-alpha.3'], + ['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta'], + ['1.2.3-alpha.1.beta', 'prerelease', '1.2.3-alpha.2.beta'], + ['1.2.3-alpha.2.beta', 'prerelease', '1.2.3-alpha.3.beta'], + ['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta'], + ['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta'], + ['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta'], + ['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1'], + ['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2'], + ['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3'], + ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'], + ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'], + ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta'] + ].forEach(function(v) { + var pre = v[0]; + var what = v[1]; + var wanted = v[2]; + var loose = v[3]; + var found = inc(pre, what, loose); + t.equal(found, wanted, 'inc(' + pre + ', ' + what + ') === ' + wanted); + }); + + t.end(); +}); + +test('\nvalid range test', function(t) { + // [range, result] + // validRange(range) -> result + // translate ranges into their canonical form + [['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'], + ['1.0.0', '1.0.0'], + ['>=*', '>=0.0.0-0'], + ['', '*'], + ['*', '*'], + ['*', '*'], + ['>=1.0.0', '>=1.0.0'], + ['>1.0.0', '>1.0.0'], + ['<=2.0.0', '<=2.0.0'], + ['1', '>=1.0.0-0 <2.0.0-0'], + ['<=2.0.0', '<=2.0.0'], + ['<=2.0.0', '<=2.0.0'], + ['<2.0.0', '<2.0.0-0'], + ['<2.0.0', '<2.0.0-0'], + ['>= 1.0.0', '>=1.0.0'], + ['>= 1.0.0', '>=1.0.0'], + ['>= 1.0.0', '>=1.0.0'], + ['> 1.0.0', '>1.0.0'], + ['> 1.0.0', '>1.0.0'], + ['<= 2.0.0', '<=2.0.0'], + ['<= 2.0.0', '<=2.0.0'], + ['<= 2.0.0', '<=2.0.0'], + ['< 2.0.0', '<2.0.0-0'], + ['< 2.0.0', '<2.0.0-0'], + ['>=0.1.97', '>=0.1.97'], + ['>=0.1.97', '>=0.1.97'], + ['0.1.20 || 1.2.4', '0.1.20||1.2.4'], + ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1-0'], + ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1-0'], + ['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1-0'], + ['||', '||'], + ['2.x.x', '>=2.0.0-0 <3.0.0-0'], + ['1.2.x', '>=1.2.0-0 <1.3.0-0'], + ['1.2.x || 2.x', '>=1.2.0-0 <1.3.0-0||>=2.0.0-0 <3.0.0-0'], + ['1.2.x || 2.x', '>=1.2.0-0 <1.3.0-0||>=2.0.0-0 <3.0.0-0'], + ['x', '*'], + ['2.*.*', '>=2.0.0-0 <3.0.0-0'], + ['1.2.*', '>=1.2.0-0 <1.3.0-0'], + ['1.2.* || 2.*', '>=1.2.0-0 <1.3.0-0||>=2.0.0-0 <3.0.0-0'], + ['*', '*'], + ['2', '>=2.0.0-0 <3.0.0-0'], + ['2.3', '>=2.3.0-0 <2.4.0-0'], + ['~2.4', '>=2.4.0-0 <2.5.0-0'], + ['~2.4', '>=2.4.0-0 <2.5.0-0'], + ['~>3.2.1', '>=3.2.1-0 <3.3.0-0'], + ['~1', '>=1.0.0-0 <2.0.0-0'], + ['~>1', '>=1.0.0-0 <2.0.0-0'], + ['~> 1', '>=1.0.0-0 <2.0.0-0'], + ['~1.0', '>=1.0.0-0 <1.1.0-0'], + ['~ 1.0', '>=1.0.0-0 <1.1.0-0'], + ['^0', '>=0.0.0-0 <1.0.0-0'], + ['^ 1', '>=1.0.0-0 <2.0.0-0'], + ['^0.1', '>=0.1.0-0 <0.2.0-0'], + ['^1.0', '>=1.0.0-0 <2.0.0-0'], + ['^1.2', '>=1.2.0-0 <2.0.0-0'], + ['^0.0.1', '=0.0.1'], + ['^0.0.1-beta', '=0.0.1-beta'], + ['^0.1.2', '>=0.1.2-0 <0.2.0-0'], + ['^1.2.3', '>=1.2.3-0 <2.0.0-0'], + ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0-0'], + ['<1', '<1.0.0-0'], + ['< 1', '<1.0.0-0'], + ['>=1', '>=1.0.0-0'], + ['>= 1', '>=1.0.0-0'], + ['<1.2', '<1.2.0-0'], + ['< 1.2', '<1.2.0-0'], + ['1', '>=1.0.0-0 <2.0.0-0'], + ['>01.02.03', '>1.2.3', true], + ['>01.02.03', null], + ['~1.2.3beta', '>=1.2.3-beta <1.3.0-0', true], + ['~1.2.3beta', null], + ['^ 1.2 ^ 1', '>=1.2.0-0 <2.0.0-0 >=1.0.0-0 <2.0.0-0'] + ].forEach(function(v) { + var pre = v[0]; + var wanted = v[1]; + var loose = v[2]; + var found = validRange(pre, loose); + + t.equal(found, wanted, 'validRange(' + pre + ') === ' + wanted); + }); + + t.end(); +}); + +test('\ncomparators test', function(t) { + // [range, comparators] + // turn range into a set of individual comparators + [['1.0.0 - 2.0.0', [['>=1.0.0', '<=2.0.0']]], + ['1.0.0', [['1.0.0']]], + ['>=*', [['>=0.0.0-0']]], + ['', [['']]], + ['*', [['']]], + ['*', [['']]], + ['>=1.0.0', [['>=1.0.0']]], + ['>=1.0.0', [['>=1.0.0']]], + ['>=1.0.0', [['>=1.0.0']]], + ['>1.0.0', [['>1.0.0']]], + ['>1.0.0', [['>1.0.0']]], + ['<=2.0.0', [['<=2.0.0']]], + ['1', [['>=1.0.0-0', '<2.0.0-0']]], + ['<=2.0.0', [['<=2.0.0']]], + ['<=2.0.0', [['<=2.0.0']]], + ['<2.0.0', [['<2.0.0-0']]], + ['<2.0.0', [['<2.0.0-0']]], + ['>= 1.0.0', [['>=1.0.0']]], + ['>= 1.0.0', [['>=1.0.0']]], + ['>= 1.0.0', [['>=1.0.0']]], + ['> 1.0.0', [['>1.0.0']]], + ['> 1.0.0', [['>1.0.0']]], + ['<= 2.0.0', [['<=2.0.0']]], + ['<= 2.0.0', [['<=2.0.0']]], + ['<= 2.0.0', [['<=2.0.0']]], + ['< 2.0.0', [['<2.0.0-0']]], + ['<\t2.0.0', [['<2.0.0-0']]], + ['>=0.1.97', [['>=0.1.97']]], + ['>=0.1.97', [['>=0.1.97']]], + ['0.1.20 || 1.2.4', [['0.1.20'], ['1.2.4']]], + ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1-0']]], + ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1-0']]], + ['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1-0']]], + ['||', [[''], ['']]], + ['2.x.x', [['>=2.0.0-0', '<3.0.0-0']]], + ['1.2.x', [['>=1.2.0-0', '<1.3.0-0']]], + ['1.2.x || 2.x', [['>=1.2.0-0', '<1.3.0-0'], ['>=2.0.0-0', '<3.0.0-0']]], + ['1.2.x || 2.x', [['>=1.2.0-0', '<1.3.0-0'], ['>=2.0.0-0', '<3.0.0-0']]], + ['x', [['']]], + ['2.*.*', [['>=2.0.0-0', '<3.0.0-0']]], + ['1.2.*', [['>=1.2.0-0', '<1.3.0-0']]], + ['1.2.* || 2.*', [['>=1.2.0-0', '<1.3.0-0'], ['>=2.0.0-0', '<3.0.0-0']]], + ['1.2.* || 2.*', [['>=1.2.0-0', '<1.3.0-0'], ['>=2.0.0-0', '<3.0.0-0']]], + ['*', [['']]], + ['2', [['>=2.0.0-0', '<3.0.0-0']]], + ['2.3', [['>=2.3.0-0', '<2.4.0-0']]], + ['~2.4', [['>=2.4.0-0', '<2.5.0-0']]], + ['~2.4', [['>=2.4.0-0', '<2.5.0-0']]], + ['~>3.2.1', [['>=3.2.1-0', '<3.3.0-0']]], + ['~1', [['>=1.0.0-0', '<2.0.0-0']]], + ['~>1', [['>=1.0.0-0', '<2.0.0-0']]], + ['~> 1', [['>=1.0.0-0', '<2.0.0-0']]], + ['~1.0', [['>=1.0.0-0', '<1.1.0-0']]], + ['~ 1.0', [['>=1.0.0-0', '<1.1.0-0']]], + ['~ 1.0.3', [['>=1.0.3-0', '<1.1.0-0']]], + ['~> 1.0.3', [['>=1.0.3-0', '<1.1.0-0']]], + ['<1', [['<1.0.0-0']]], + ['< 1', [['<1.0.0-0']]], + ['>=1', [['>=1.0.0-0']]], + ['>= 1', [['>=1.0.0-0']]], + ['<1.2', [['<1.2.0-0']]], + ['< 1.2', [['<1.2.0-0']]], + ['1', [['>=1.0.0-0', '<2.0.0-0']]], + ['1 2', [['>=1.0.0-0', '<2.0.0-0', '>=2.0.0-0', '<3.0.0-0']]], + ['1.2 - 3.4.5', [['>=1.2.0-0', '<=3.4.5']]], + ['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0-0']]] + ].forEach(function(v) { + var pre = v[0]; + var wanted = v[1]; + var found = toComparators(v[0]); + var jw = JSON.stringify(wanted); + t.equivalent(found, wanted, 'toComparators(' + pre + ') === ' + jw); + }); + + t.end(); +}); + +test('\nstrict vs loose version numbers', function(t) { + [['=1.2.3', '1.2.3'], + ['01.02.03', '1.2.3'], + ['1.2.3-beta.01', '1.2.3-beta.1'], + [' =1.2.3', '1.2.3'], + ['1.2.3foo', '1.2.3-foo'] + ].forEach(function(v) { + var loose = v[0]; + var strict = v[1]; + t.throws(function() { + new SemVer(loose); + }); + var lv = new SemVer(loose, true); + t.equal(lv.version, strict); + t.ok(eq(loose, strict, true)); + t.throws(function() { + eq(loose, strict); + }); + t.throws(function() { + new SemVer(strict).compare(loose); + }); + }); + t.end(); +}); + +test('\nstrict vs loose ranges', function(t) { + [['>=01.02.03', '>=1.2.3'], + ['~1.02.03beta', '>=1.2.3-beta <1.3.0-0'] + ].forEach(function(v) { + var loose = v[0]; + var comps = v[1]; + t.throws(function() { + new Range(loose); + }); + t.equal(new Range(loose, true).range, comps); + }); + t.end(); +}); + +test('\nmax satisfying', function(t) { + [[['1.2.3', '1.2.4'], '1.2', '1.2.4'], + [['1.2.4', '1.2.3'], '1.2', '1.2.4'], + [['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.6'], + [['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true] + ].forEach(function(v) { + var versions = v[0]; + var range = v[1]; + var expect = v[2]; + var loose = v[3]; + var actual = semver.maxSatisfying(versions, range, loose); + t.equal(actual, expect); + }); + t.end(); +}); diff --git a/node_modules/node-gyp/node_modules/semver/test/ltr.js b/node_modules/node-gyp/node_modules/semver/test/ltr.js new file mode 100644 index 000000000..a4f503a3c --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/test/ltr.js @@ -0,0 +1,174 @@ +var tap = require('tap'); +var test = tap.test; +var semver = require('../semver.js'); +var ltr = semver.ltr; + +test('\nltr tests', function(t) { + // [range, version, loose] + // Version should be less than range + [ + ['~1.2.2', '1.2.1'], + ['~0.6.1-1', '0.6.1-0'], + ['1.0.0 - 2.0.0', '0.0.1'], + ['1.0.0-beta.2', '1.0.0-beta.1'], + ['1.0.0', '0.0.0'], + ['>=2.0.0', '1.1.1'], + ['>=2.0.0', '1.2.9'], + ['>2.0.0', '2.0.0'], + ['0.1.20 || 1.2.4', '0.1.5'], + ['2.x.x', '1.0.0'], + ['1.2.x', '1.1.0'], + ['1.2.x || 2.x', '1.0.0'], + ['2.*.*', '1.0.1'], + ['1.2.*', '1.1.3'], + ['1.2.* || 2.*', '1.1.9999'], + ['2', '1.0.0'], + ['2.3', '2.2.2'], + ['~2.4', '2.3.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.3.5'], + ['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0 + ['~1', '0.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '0.2.4'], + ['~> 1', '0.2.3'], + ['~1.0', '0.1.2'], // >=1.0.0 <1.1.0 + ['~ 1.0', '0.1.0'], + ['>1.2', '1.2.0'], + ['> 1.2', '1.2.1'], + ['1', '0.0.0beta', true], + ['~v0.5.4-pre', '0.5.4-alpha'], + ['~v0.5.4-pre', '0.5.4-alpha'], + ['=0.7.x', '0.6.0'], + ['=0.7.x', '0.6.0-asdf'], + ['>=0.7.x', '0.6.0'], + ['~1.2.2', '1.2.1'], + ['1.0.0 - 2.0.0', '0.2.3'], + ['1.0.0', '0.0.1'], + ['>=2.0.0', '1.0.0'], + ['>=2.0.0', '1.9999.9999'], + ['>=2.0.0', '1.2.9'], + ['>2.0.0', '2.0.0'], + ['>2.0.0', '1.2.9'], + ['2.x.x', '1.1.3'], + ['1.2.x', '1.1.3'], + ['1.2.x || 2.x', '1.1.3'], + ['2.*.*', '1.1.3'], + ['1.2.*', '1.1.3'], + ['1.2.* || 2.*', '1.1.3'], + ['2', '1.9999.9999'], + ['2.3', '2.2.1'], + ['~2.4', '2.3.0'], // >=2.4.0 <2.5.0 + ['~>3.2.1', '2.3.2'], // >=3.2.1 <3.3.0 + ['~1', '0.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '0.2.3'], + ['~1.0', '0.0.0'], // >=1.0.0 <1.1.0 + ['>1', '1.0.0'], + ['2', '1.0.0beta', true], + ['>1', '1.0.0beta', true], + ['> 1', '1.0.0beta', true], + ['=0.7.x', '0.6.2'], + ['>=0.7.x', '0.6.2'] + ].forEach(function(tuple) { + var range = tuple[0]; + var version = tuple[1]; + var loose = tuple[2] || false; + var msg = 'ltr(' + version + ', ' + range + ', ' + loose + ')'; + t.ok(ltr(version, range, loose), msg); + }); + t.end(); +}); + +test('\nnegative ltr tests', function(t) { + // [range, version, loose] + // Version should NOT be greater than range + [ + ['~ 1.0', '1.1.0'], + ['~0.6.1-1', '0.6.1-1'], + ['1.0.0 - 2.0.0', '1.2.3'], + ['1.0.0 - 2.0.0', '2.9.9'], + ['1.0.0', '1.0.0'], + ['>=*', '0.2.4'], + ['', '1.0.0', true], + ['*', '1.2.3'], + ['*', 'v1.2.3-foo'], + ['>=1.0.0', '1.0.0'], + ['>=1.0.0', '1.0.1'], + ['>=1.0.0', '1.1.0'], + ['>1.0.0', '1.0.1'], + ['>1.0.0', '1.1.0'], + ['<=2.0.0', '2.0.0'], + ['<=2.0.0', '1.9999.9999'], + ['<=2.0.0', '0.2.9'], + ['<2.0.0', '1.9999.9999'], + ['<2.0.0', '0.2.9'], + ['>= 1.0.0', '1.0.0'], + ['>= 1.0.0', '1.0.1'], + ['>= 1.0.0', '1.1.0'], + ['> 1.0.0', '1.0.1'], + ['> 1.0.0', '1.1.0'], + ['<= 2.0.0', '2.0.0'], + ['<= 2.0.0', '1.9999.9999'], + ['<= 2.0.0', '0.2.9'], + ['< 2.0.0', '1.9999.9999'], + ['<\t2.0.0', '0.2.9'], + ['>=0.1.97', 'v0.1.97'], + ['>=0.1.97', '0.1.97'], + ['0.1.20 || 1.2.4', '1.2.4'], + ['0.1.20 || >1.2.4', '1.2.4'], + ['0.1.20 || 1.2.4', '1.2.3'], + ['0.1.20 || 1.2.4', '0.1.20'], + ['>=0.2.3 || <0.0.1', '0.0.0'], + ['>=0.2.3 || <0.0.1', '0.2.3'], + ['>=0.2.3 || <0.0.1', '0.2.4'], + ['||', '1.3.4'], + ['2.x.x', '2.1.3'], + ['1.2.x', '1.2.3'], + ['1.2.x || 2.x', '2.1.3'], + ['1.2.x || 2.x', '1.2.3'], + ['x', '1.2.3'], + ['2.*.*', '2.1.3'], + ['1.2.*', '1.2.3'], + ['1.2.* || 2.*', '2.1.3'], + ['1.2.* || 2.*', '1.2.3'], + ['1.2.* || 2.*', '1.2.3'], + ['*', '1.2.3'], + ['2', '2.1.2'], + ['2.3', '2.3.1'], + ['~2.4', '2.4.0'], // >=2.4.0 <2.5.0 + ['~2.4', '2.4.5'], + ['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0 + ['~1', '1.2.3'], // >=1.0.0 <2.0.0 + ['~>1', '1.2.3'], + ['~> 1', '1.2.3'], + ['~1.0', '1.0.2'], // >=1.0.0 <1.1.0 + ['~ 1.0', '1.0.2'], + ['>=1', '1.0.0'], + ['>= 1', '1.0.0'], + ['<1.2', '1.1.1'], + ['< 1.2', '1.1.1'], + ['1', '1.0.0beta', true], + ['~v0.5.4-pre', '0.5.5'], + ['~v0.5.4-pre', '0.5.4'], + ['=0.7.x', '0.7.2'], + ['>=0.7.x', '0.7.2'], + ['=0.7.x', '0.7.0-asdf'], + ['>=0.7.x', '0.7.0-asdf'], + ['<=0.7.x', '0.6.2'], + ['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'], + ['>=0.2.3 <=0.2.4', '0.2.4'], + ['1.0.0 - 2.0.0', '2.0.0'], + ['^1', '1.0.0-0'], + ['^3.0.0', '4.0.0'], + ['^1.0.0 || ~2.0.1', '2.0.0'], + ['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'], + ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true], + ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true], + ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'] + ].forEach(function(tuple) { + var range = tuple[0]; + var version = tuple[1]; + var loose = tuple[2] || false; + var msg = '!ltr(' + version + ', ' + range + ', ' + loose + ')'; + t.notOk(ltr(version, range, loose), msg); + }); + t.end(); +}); diff --git a/node_modules/node-gyp/node_modules/semver/test/no-module.js b/node_modules/node-gyp/node_modules/semver/test/no-module.js new file mode 100644 index 000000000..96d1cd1fc --- /dev/null +++ b/node_modules/node-gyp/node_modules/semver/test/no-module.js @@ -0,0 +1,19 @@ +var tap = require('tap'); +var test = tap.test; + +test('no module system', function(t) { + var fs = require('fs'); + var vm = require('vm'); + var head = fs.readFileSync(require.resolve('../head.js'), 'utf8'); + var src = fs.readFileSync(require.resolve('../'), 'utf8'); + var foot = fs.readFileSync(require.resolve('../foot.js'), 'utf8'); + vm.runInThisContext(head + src + foot, 'semver.js'); + + // just some basic poking to see if it did some stuff + t.type(global.semver, 'object'); + t.type(global.semver.SemVer, 'function'); + t.type(global.semver.Range, 'function'); + t.ok(global.semver.satisfies('1.2.3', '1.2')); + t.end(); +}); + diff --git a/node_modules/node-gyp/package.json b/node_modules/node-gyp/package.json index 88ba331fa..ea112a756 100644 --- a/node_modules/node-gyp/package.json +++ b/node_modules/node-gyp/package.json @@ -27,17 +27,17 @@ }, "main": "./lib/node-gyp.js", "dependencies": { - "glob": "3 || 4", - "graceful-fs": "2||3", + "glob": "3", + "graceful-fs": "2", "fstream": "0", "minimatch": "0", "mkdirp": "0", - "nopt": "2 || 3", + "nopt": "2", "npmlog": "0", "osenv": "0", "request": "2", "rimraf": "2", - "semver": "2", + "semver": "~2.2.1", "tar": "0", "which": "1" }, @@ -50,7 +50,7 @@ "homepage": "https://github.com/TooTallNate/node-gyp", "_id": "node-gyp@0.13.1", "_shasum": "5a484dd2dc13d5b894a8fe781a250c07eae7bffa", - "_from": "node-gyp@~0.13.0", + "_from": "node-gyp@latest", "_npmVersion": "1.4.9", "_npmUser": { "name": "tootallnate", @@ -71,6 +71,5 @@ "tarball": "http://registry.npmjs.org/node-gyp/-/node-gyp-0.13.1.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-0.13.1.tgz", - "readme": "ERROR: No README data found!" + "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-0.13.1.tgz" } diff --git a/node_modules/normalize-package-data/package.json b/node_modules/normalize-package-data/package.json index c1e1ce07f..672f0b57f 100644 --- a/node_modules/normalize-package-data/package.json +++ b/node_modules/normalize-package-data/package.json @@ -1,6 +1,6 @@ { "name": "normalize-package-data", - "version": "0.4.1", + "version": "0.4.2", "author": { "name": "Meryn Stol", "email": "merynstol@gmail.com" @@ -17,7 +17,7 @@ "dependencies": { "github-url-from-git": "~1.1.1", "github-url-from-username-repo": "^0.2.0", - "semver": "2" + "semver": "2 || 3" }, "devDependencies": { "tap": "~0.2.5", @@ -40,12 +40,12 @@ ], "readme": "# normalize-package-data [![Build Status](https://travis-ci.org/meryn/normalize-package-data.png?branch=master)](https://travis-ci.org/meryn/normalize-package-data)\n\nnormalize-package data exports a function that normalizes package metadata. This data is typically found in a package.json file, but in principle could come from any source - for example the npm registry.\n\nnormalize-package-data is used by [read-package-json](https://npmjs.org/package/read-package-json) to normalize the data it reads from a package.json file. In turn, read-package-json is used by [npm](https://npmjs.org/package/npm) and various npm-related tools.\n\n## Installation\n\n```\nnpm install normalize-package-data\n```\n\n## Usage\n\nBasic usage is really simple. You call the function that normalize-package-data exports. Let's call it `normalizeData`.\n\n```javascript\nnormalizeData = require('normalize-package-data')\npackageData = fs.readfileSync(\"package.json\")\nnormalizeData(packageData)\n// packageData is now normalized\n```\n\n#### Strict mode\n\nYou may activate strict validation by passing true as the second argument.\n\n```javascript\nnormalizeData = require('normalize-package-data')\npackageData = fs.readfileSync(\"package.json\")\nwarnFn = function(msg) { console.error(msg) }\nnormalizeData(packageData, true)\n// packageData is now normalized\n```\n\nIf strict mode is activated, only Semver 2.0 version strings are accepted. Otherwise, Semver 1.0 strings are accepted as well. Packages must have a name, and the name field must not have contain leading or trailing whitespace.\n\n#### Warnings\n\nOptionally, you may pass a \"warning\" function. It gets called whenever the `normalizeData` function encounters something that doesn't look right. It indicates less than perfect input data.\n\n```javascript\nnormalizeData = require('normalize-package-data')\npackageData = fs.readfileSync(\"package.json\")\nwarnFn = function(msg) { console.error(msg) }\nnormalizeData(packageData, warnFn)\n// packageData is now normalized. Any number of warnings may have been logged.\n```\n\nYou may combine strict validation with warnings by passing `true` as the second argument, and `warnFn` as third.\n\nWhen `private` field is set to `true`, warnings will be suppressed.\n\n### Potential exceptions\n\nIf the supplied data has an invalid name or version vield, `normalizeData` will throw an error. Depending on where you call `normalizeData`, you may want to catch these errors so can pass them to a callback.\n\n## What normalization (currently) entails\n\n* The value of `name` field gets trimmed (unless in strict mode).\n* The value of the `version` field gets cleaned by `semver.clean`. See [documentation for the semver module](https://github.com/isaacs/node-semver).\n* If `name` and/or `version` fields are missing, they are set to empty strings.\n* If `files` field is not an array, it will be removed.\n* If `bin` field is a string, then `bin` field will become an object with `name` set to the value of the `name` field, and `bin` set to the original string value.\n* If `man` field is a string, it will become an array with the original string as its sole member.\n* If `keywords` field is string, it is considered to be a list of keywords separated by one or more white-space characters. It gets converted to an array by splitting on `\\s+`.\n* All people fields (`author`, `maintainers`, `contributors`) get converted into objects with name, email and url properties.\n* If `bundledDependencies` field (a typo) exists and `bundleDependencies` field does not, `bundledDependencies` will get renamed to `bundleDependencies`.\n* If the value of any of the dependencies fields (`dependencies`, `devDependencies`, `optionalDependencies`) is a string, it gets converted into an object with familiar `name=>value` pairs.\n* The values in `optionalDependencies` get added to `dependencies`. The `optionalDependencies` array is left untouched.\n* If `description` field does not exists, but `readme` field does, then (more or less) the first paragraph of text that's found in the readme is taken as value for `description`.\n* If `repository` field is a string, it will become an object with `url` set to the original string value, and `type` set to `\"git\"`.\n* If `repository.url` is not a valid url, but in the style of \"[owner-name]/[repo-name]\", `repository.url` will be set to git://github.com/[owner-name]/[repo-name]\n* If `bugs` field is a string, the value of `bugs` field is changed into an object with `url` set to the original string value.\n* If `bugs` field does not exist, but `repository` field points to a repository hosted on GitHub, the value of the `bugs` field gets set to an url in the form of https://github.com/[owner-name]/[repo-name]/issues . If the repository field points to a GitHub Gist repo url, the associated http url is chosen.\n* If `bugs` field is an object, the resulting value only has email and url properties. If email and url properties are not strings, they are ignored. If no valid values for either email or url is found, bugs field will be removed.\n* If `homepage` field is not a string, it will be removed.\n* If the url in the `homepage` field does not specify a protocol, then http is assumed. For example, `myproject.org` will be changed to `http://myproject.org`.\n* If `homepage` field does not exist, but `repository` field points to a repository hosted on GitHub, the value of the `homepage` field gets set to an url in the form of https://github.com/[owner-name]/[repo-name]/ . If the repository field points to a GitHub Gist repo url, the associated http url is chosen.\n\n### Rules for name field\n\nIf `name` field is given, the value of the name field must be a string. The string may not:\n\n* start with a period.\n* contain the following characters: `/@\\s+%`\n* contain and characters that would need to be encoded for use in urls.\n* resemble the word `node_modules` or `favicon.ico` (case doesn't matter).\n\n### Rules for version field\n\nIf `version` field is given, the value of the version field must be a valid *semver* string, as determined by the `semver.valid` method. See [documentation for the semver module](https://github.com/isaacs/node-semver).\n\n## Credits\n\nThis package contains code based on read-package-json written by Isaac Z. Schlueter. Used with permisson.\n\n## License\n\nnormalize-package-data is released under the [BSD 2-Clause License](http://opensource.org/licenses/MIT). \nCopyright (c) 2013 Meryn Stol ", "readmeFilename": "README.md", - "gitHead": "4d16aac9bf196d0816c9c86d4108f39ea705202a", + "gitHead": "09ff709e33e611bb4e6ad5aa2b33e52e77b3fa36", "bugs": { "url": "https://github.com/meryn/normalize-package-data/issues" }, "homepage": "https://github.com/meryn/normalize-package-data", - "_id": "normalize-package-data@0.4.1", - "_shasum": "c7c83d0927cda14332aa08cf48e944919ed9102f", - "_from": "normalize-package-data@0.4.1" + "_id": "normalize-package-data@0.4.2", + "_shasum": "166dc052a74e2f5ac1d3d23903ab3f2e2b7dd8e6", + "_from": "normalize-package-data@latest" } diff --git a/node_modules/npm-install-checks/package.json b/node_modules/npm-install-checks/package.json index 9457df0b5..e0e98a1c9 100644 --- a/node_modules/npm-install-checks/package.json +++ b/node_modules/npm-install-checks/package.json @@ -1,11 +1,11 @@ { "name": "npm-install-checks", - "version": "1.0.2", + "version": "1.0.3", "description": "checks that npm runs during the installation of a module", "main": "index.js", "dependencies": { "npmlog": "0.1", - "semver": "^2.3.0" + "semver": "^2.3.0 || 3.x" }, "devDependencies": { "tap": "~0.4.8", @@ -34,8 +34,8 @@ }, "readme": "# npm-install-checks\n\nA package that contains checks that npm runs during the installation.\n\n## API\n\n### .checkEngine(target, npmVer, nodeVer, force, strict, cb)\nCheck if node/npm version is supported by the package.\n\nError type: `ENOTSUP`\n\n### .checkPlatform(target, force, cb)\nCheck if OS/Arch is supported by the package.\n\nError type: `EBADPLATFORM`\n\n### .checkCycle(target, ancestors, cb)\nCheck for cyclic dependencies.\n\nError type: `ECYCLE`\n\n### .checkGit(folder, cb)\nCheck if a folder is a .git folder.\n\nError type: `EISGIT`\n", "readmeFilename": "README.md", - "gitHead": "056ade7c5e3a6b3c720ca6a743c1b99a0705d29e", - "_id": "npm-install-checks@1.0.2", - "_shasum": "ebba769753fc8551308333ef411920743a6809f6", - "_from": "npm-install-checks@latest" + "gitHead": "ca29c68e45e691062471eeb4875f4ec5905277c5", + "_id": "npm-install-checks@1.0.3", + "_shasum": "9301006141a8f1454ae6bfe9a2f89da91316de02", + "_from": "npm-install-checks@>=1.0.2-0 <1.1.0-0" } diff --git a/node_modules/npm-package-arg/package.json b/node_modules/npm-package-arg/package.json index fd9e74c42..f4a1bcdc7 100644 --- a/node_modules/npm-package-arg/package.json +++ b/node_modules/npm-package-arg/package.json @@ -1,13 +1,13 @@ { "name": "npm-package-arg", - "version": "2.0.1", + "version": "2.0.2", "description": "Parse the things that can be arguments to `npm install`", "main": "npa.js", "directories": { "test": "test" }, "dependencies": { - "semver": "^2.3.0" + "semver": "^2.3.0 || 3.x" }, "devDependencies": { "tap": "^0.4.9" @@ -31,8 +31,8 @@ "homepage": "https://github.com/npm/npm-package-arg", "readme": "# npm-package-arg\n\nParse the things that can be arguments to `npm install`\n\nTakes an argument like `foo@1.2`, or `foo@user/foo`, or\n`http://x.com/foo.tgz`, or `git+https://github.com/user/foo`, and\nfigures out what type of thing it is.\n\n## USAGE\n\n```javascript\nvar assert = require(\"assert\")\nvar npa = require(\"npm-package-arg\")\n\n// Pass in the descriptor, and it'll return an object\nvar parsed = npa(\"foo@1.2\")\n\n// Returns an object like:\n// {\n// name: \"foo\", // The bit in front of the @\n// type: \"range\", // the type of descriptor this is\n// spec: \"1.2\" // the specifier for this descriptor\n// }\n\n// Completely unreasonable invalid garbage throws an error\n// Make sure you wrap this in a try/catch if you have not\n// already sanitized the inputs!\nassert.throws(function() {\n npa(\"this is not \\0 a valid package name or url\")\n})\n```\n\nFor more examples, see the test file.\n\n## Result Objects\n\nThe objects that are returned by npm-package-arg contain the following\nfields:\n\n* `name` - If known, the `name` field expected in the resulting pkg.\n* `type` - One of the following strings:\n * `git` - A git repo\n * `github` - A github shorthand, like `user/project`\n * `tag` - A tagged version, like `\"foo@latest\"`\n * `version` - A specific version number, like `\"foo@1.2.3\"`\n * `range` - A version range, like `\"foo@2.x\"`\n * `local` - A local file or folder path\n * `remote` - An http url (presumably to a tgz)\n* `spec` - The \"thing\". URL, the range, git repo, etc.\n* `raw` - The original un-modified string that was provided.\n* `rawSpec` - The part after the `name@...`, as it was originally\n provided.\n* `scope` - If a name is something like `@org/module` then the `scope`\n field will be set to `org`. If it doesn't have a scoped name, then\n scope is `null`.\n", "readmeFilename": "README.md", - "gitHead": "543239e7db293cea99ac366050dd96c6cc55879c", - "_id": "npm-package-arg@2.0.1", - "_shasum": "73340bbb51cdf7656ac0bfa4fd18c16db245ba58", + "gitHead": "2e21602126b7bda86a7db95f9939e43a6710b8be", + "_id": "npm-package-arg@2.0.2", + "_shasum": "e4f660c683068eccba9b27b4075cc00c0ccc6037", "_from": "npm-package-arg@latest" } diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/LICENSE b/node_modules/npm-registry-client/node_modules/mkdirp/LICENSE deleted file mode 100644 index 432d1aeb0..000000000 --- a/node_modules/npm-registry-client/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/npm-registry-client/node_modules/mkdirp/examples/pow.js b/node_modules/npm-registry-client/node_modules/mkdirp/examples/pow.js deleted file mode 100644 index e6924212e..000000000 --- a/node_modules/npm-registry-client/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/npm-registry-client/node_modules/mkdirp/index.js b/node_modules/npm-registry-client/node_modules/mkdirp/index.js deleted file mode 100644 index fda6de8a2..000000000 --- a/node_modules/npm-registry-client/node_modules/mkdirp/index.js +++ /dev/null @@ -1,82 +0,0 @@ -var path = require('path'); -var fs = require('fs'); - -module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP; - -function mkdirP (p, mode, f, made) { - if (typeof mode === 'function' || mode === undefined) { - f = mode; - mode = 0777 & (~process.umask()); - } - if (!made) made = null; - - var cb = f || function () {}; - if (typeof mode === 'string') mode = parseInt(mode, 8); - p = path.resolve(p); - - fs.mkdir(p, mode, function (er) { - if (!er) { - made = made || p; - return cb(null, made); - } - switch (er.code) { - case 'ENOENT': - mkdirP(path.dirname(p), mode, function (er, made) { - if (er) cb(er, made); - else mkdirP(p, mode, cb, made); - }); - break; - - // In the case of any other error, just see if there's a dir - // there already. If so, then hooray! If not, then something - // is borked. - default: - fs.stat(p, function (er2, stat) { - // if the stat fails, then that's super weird. - // let the original error be the failure reason. - if (er2 || !stat.isDirectory()) cb(er, made) - else cb(null, made); - }); - break; - } - }); -} - -mkdirP.sync = function sync (p, mode, made) { - if (mode === undefined) { - mode = 0777 & (~process.umask()); - } - if (!made) made = null; - - if (typeof mode === 'string') mode = parseInt(mode, 8); - p = path.resolve(p); - - try { - fs.mkdirSync(p, mode); - made = made || p; - } - catch (err0) { - switch (err0.code) { - case 'ENOENT' : - made = sync(path.dirname(p), mode, made); - sync(p, mode, made); - break; - - // In the case of any other error, just see if there's a dir - // there already. If so, then hooray! If not, then something - // is borked. - default: - var stat; - try { - stat = fs.statSync(p); - } - catch (err1) { - throw err0; - } - if (!stat.isDirectory()) throw err0; - break; - } - } - - return made; -}; diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/package.json b/node_modules/npm-registry-client/node_modules/mkdirp/package.json deleted file mode 100644 index 88110b968..000000000 --- a/node_modules/npm-registry-client/node_modules/mkdirp/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "mkdirp", - "description": "Recursively mkdir, like `mkdir -p`", - "version": "0.3.5", - "author": { - "name": "James Halliday", - "email": "mail@substack.net", - "url": "http://substack.net" - }, - "main": "./index", - "keywords": [ - "mkdir", - "directory" - ], - "repository": { - "type": "git", - "url": "http://github.com/substack/node-mkdirp.git" - }, - "scripts": { - "test": "tap test/*.js" - }, - "devDependencies": { - "tap": "~0.4.0" - }, - "license": "MIT", - "readme": "# mkdirp\n\nLike `mkdir -p`, but in node.js!\n\n[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp)\n\n# example\n\n## pow.js\n\n```js\nvar mkdirp = require('mkdirp');\n \nmkdirp('/tmp/foo/bar/baz', function (err) {\n if (err) console.error(err)\n else console.log('pow!')\n});\n```\n\nOutput\n\n```\npow!\n```\n\nAnd now /tmp/foo/bar/baz exists, huzzah!\n\n# methods\n\n```js\nvar mkdirp = require('mkdirp');\n```\n\n## mkdirp(dir, mode, cb)\n\nCreate a new directory and any necessary subdirectories at `dir` with octal\npermission string `mode`.\n\nIf `mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\n`cb(err, made)` fires with the error or the first directory `made`\nthat had to be created, if any.\n\n## mkdirp.sync(dir, mode)\n\nSynchronously create a new directory and any necessary subdirectories at `dir`\nwith octal permission string `mode`.\n\nIf `mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\nReturns the first directory that had to be created, if any.\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install mkdirp\n```\n\n# license\n\nMIT\n", - "readmeFilename": "readme.markdown", - "_id": "mkdirp@0.3.5", - "dist": { - "shasum": "de3e5f8961c88c787ee1368df849ac4413eca8d7", - "tarball": "http://localhost:1337/mkdirp/-/mkdirp-0.3.5.tgz" - }, - "_from": "mkdirp@>=0.3.3-0 <0.4.0-0", - "_npmVersion": "1.2.2", - "_npmUser": { - "name": "substack", - "email": "mail@substack.net" - }, - "maintainers": [ - { - "name": "substack", - "email": "mail@substack.net" - } - ], - "directories": {}, - "_shasum": "de3e5f8961c88c787ee1368df849ac4413eca8d7", - "_resolved": "http://localhost:1337/mkdirp/-/mkdirp-0.3.5.tgz", - "bugs": { - "url": "https://github.com/substack/node-mkdirp/issues" - }, - "homepage": "https://github.com/substack/node-mkdirp" -} diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/readme.markdown b/node_modules/npm-registry-client/node_modules/mkdirp/readme.markdown deleted file mode 100644 index 83b0216ab..000000000 --- a/node_modules/npm-registry-client/node_modules/mkdirp/readme.markdown +++ /dev/null @@ -1,63 +0,0 @@ -# mkdirp - -Like `mkdir -p`, but in node.js! - -[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp) - -# example - -## pow.js - -```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 - -```js -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())`. - -`cb(err, made)` fires with the error or the first directory `made` -that had to be created, if any. - -## 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())`. - -Returns the first directory that had to be created, if any. - -# install - -With [npm](http://npmjs.org) do: - -``` -npm install mkdirp -``` - -# license - -MIT diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/test/chmod.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/chmod.js deleted file mode 100644 index 520dcb8e9..000000000 --- a/node_modules/npm-registry-client/node_modules/mkdirp/test/chmod.js +++ /dev/null @@ -1,38 +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.end(); - }); - }); -}); diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/test/clobber.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/clobber.js deleted file mode 100644 index 0eb709987..000000000 --- a/node_modules/npm-registry-client/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/npm-registry-client/node_modules/mkdirp/test/mkdirp.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/mkdirp.js deleted file mode 100644 index b07cd70c1..000000000 --- a/node_modules/npm-registry-client/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/npm-registry-client/node_modules/mkdirp/test/perm.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/perm.js deleted file mode 100644 index 23a7abbd2..000000000 --- a/node_modules/npm-registry-client/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/npm-registry-client/node_modules/mkdirp/test/perm_sync.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/perm_sync.js deleted file mode 100644 index f685f6090..000000000 --- a/node_modules/npm-registry-client/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/npm-registry-client/node_modules/mkdirp/test/race.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/race.js deleted file mode 100644 index 96a044763..000000000 --- a/node_modules/npm-registry-client/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/npm-registry-client/node_modules/mkdirp/test/rel.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/rel.js deleted file mode 100644 index 79858243a..000000000 --- a/node_modules/npm-registry-client/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/npm-registry-client/node_modules/mkdirp/test/return.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/return.js deleted file mode 100644 index bce68e561..000000000 --- a/node_modules/npm-registry-client/node_modules/mkdirp/test/return.js +++ /dev/null @@ -1,25 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('return value', function (t) { - t.plan(4); - 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('/'); - - // should return the first dir created. - // By this point, it would be profoundly surprising if /tmp didn't - // already exist, since every other test makes things in there. - mkdirp(file, function (err, made) { - t.ifError(err); - t.equal(made, '/tmp/' + x); - mkdirp(file, function (err, made) { - t.ifError(err); - t.equal(made, null); - }); - }); -}); diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/test/return_sync.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/return_sync.js deleted file mode 100644 index 7c222d355..000000000 --- a/node_modules/npm-registry-client/node_modules/mkdirp/test/return_sync.js +++ /dev/null @@ -1,24 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('return value', 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('/'); - - // should return the first dir created. - // By this point, it would be profoundly surprising if /tmp didn't - // already exist, since every other test makes things in there. - // Note that this will throw on failure, which will fail the test. - var made = mkdirp.sync(file); - t.equal(made, '/tmp/' + x); - - // making the same file again should have no effect. - made = mkdirp.sync(file); - t.equal(made, null); -}); diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/test/root.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/root.js deleted file mode 100644 index 97ad7a2f3..000000000 --- a/node_modules/npm-registry-client/node_modules/mkdirp/test/root.js +++ /dev/null @@ -1,18 +0,0 @@ -var mkdirp = require('../'); -var path = require('path'); -var fs = require('fs'); -var test = require('tap').test; - -test('root', function (t) { - // '/' on unix, 'c:/' on windows. - var file = path.resolve('/'); - - mkdirp(file, 0755, function (err) { - if (err) throw err - fs.stat(file, function (er, stat) { - if (er) throw er - t.ok(stat.isDirectory(), 'target is a directory'); - t.end(); - }) - }); -}); diff --git a/node_modules/npm-registry-client/node_modules/mkdirp/test/sync.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/sync.js deleted file mode 100644 index 7530cada8..000000000 --- a/node_modules/npm-registry-client/node_modules/mkdirp/test/sync.js +++ /dev/null @@ -1,32 +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('/'); - - try { - mkdirp.sync(file, 0755); - } catch (err) { - t.fail(err); - return t.end(); - } - - 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/npm-registry-client/node_modules/mkdirp/test/umask.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/umask.js deleted file mode 100644 index 64ccafe22..000000000 --- a/node_modules/npm-registry-client/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/npm-registry-client/node_modules/mkdirp/test/umask_sync.js b/node_modules/npm-registry-client/node_modules/mkdirp/test/umask_sync.js deleted file mode 100644 index 35bd5cbbf..000000000 --- a/node_modules/npm-registry-client/node_modules/mkdirp/test/umask_sync.js +++ /dev/null @@ -1,32 +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('/'); - - try { - mkdirp.sync(file); - } catch (err) { - t.fail(err); - return t.end(); - } - - 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/npm-registry-client/package.json b/node_modules/npm-registry-client/package.json index 15623f6e6..6acb40410 100644 --- a/node_modules/npm-registry-client/package.json +++ b/node_modules/npm-registry-client/package.json @@ -1,12 +1,8 @@ { - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, + "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)", "name": "npm-registry-client", "description": "Client for the npm registry", - "version": "3.0.2", + "version": "3.0.5", "repository": { "url": "git://github.com/isaacs/npm-registry-client" }, @@ -17,15 +13,14 @@ "dependencies": { "chownr": "0", "graceful-fs": "^3.0.0", - "mkdirp": "~0.3.3", - "normalize-package-data": "^0.4.0", + "mkdirp": "0.5", + "normalize-package-data": "0.4", "npm-cache-filename": "^1.0.0", "request": "2 >=2.25.0", "retry": "0.6.0", - "rimraf": "~2", - "semver": "2 >=2.2.1", - "slide": "~1.1.3", - "npmlog": "" + "rimraf": "2", + "semver": "2 >=2.2.1 || 3.x", + "slide": "^1.1.3" }, "devDependencies": { "tap": "" @@ -33,34 +28,5 @@ "optionalDependencies": { "npmlog": "" }, - "license": "BSD", - "gitHead": "15343019160ace0b9874cf0ec186b3425dbc7301", - "bugs": { - "url": "https://github.com/isaacs/npm-registry-client/issues" - }, - "homepage": "https://github.com/isaacs/npm-registry-client", - "_id": "npm-registry-client@3.0.2", - "_shasum": "5dd0910157ce55f4286a1871d39f9a2128cd3c99", - "_from": "npm-registry-client@3.0.2", - "_npmVersion": "1.5.0-alpha-2", - "_npmUser": { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - } - ], - "dist": { - "shasum": "5dd0910157ce55f4286a1871d39f9a2128cd3c99", - "tarball": "http://registry.npmjs.org/npm-registry-client/-/npm-registry-client-3.0.2.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-3.0.2.tgz" + "license": "BSD" } diff --git a/node_modules/npmconf/node_modules/mkdirp/package.json b/node_modules/npmconf/node_modules/mkdirp/package.json index 88110b968..cc3a8c895 100644 --- a/node_modules/npmconf/node_modules/mkdirp/package.json +++ b/node_modules/npmconf/node_modules/mkdirp/package.json @@ -23,12 +23,10 @@ "tap": "~0.4.0" }, "license": "MIT", - "readme": "# mkdirp\n\nLike `mkdir -p`, but in node.js!\n\n[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp)\n\n# example\n\n## pow.js\n\n```js\nvar mkdirp = require('mkdirp');\n \nmkdirp('/tmp/foo/bar/baz', function (err) {\n if (err) console.error(err)\n else console.log('pow!')\n});\n```\n\nOutput\n\n```\npow!\n```\n\nAnd now /tmp/foo/bar/baz exists, huzzah!\n\n# methods\n\n```js\nvar mkdirp = require('mkdirp');\n```\n\n## mkdirp(dir, mode, cb)\n\nCreate a new directory and any necessary subdirectories at `dir` with octal\npermission string `mode`.\n\nIf `mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\n`cb(err, made)` fires with the error or the first directory `made`\nthat had to be created, if any.\n\n## mkdirp.sync(dir, mode)\n\nSynchronously create a new directory and any necessary subdirectories at `dir`\nwith octal permission string `mode`.\n\nIf `mode` isn't specified, it defaults to `0777 & (~process.umask())`.\n\nReturns the first directory that had to be created, if any.\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install mkdirp\n```\n\n# license\n\nMIT\n", - "readmeFilename": "readme.markdown", "_id": "mkdirp@0.3.5", "dist": { "shasum": "de3e5f8961c88c787ee1368df849ac4413eca8d7", - "tarball": "http://localhost:1337/mkdirp/-/mkdirp-0.3.5.tgz" + "tarball": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz" }, "_from": "mkdirp@>=0.3.3-0 <0.4.0-0", "_npmVersion": "1.2.2", @@ -44,9 +42,10 @@ ], "directories": {}, "_shasum": "de3e5f8961c88c787ee1368df849ac4413eca8d7", - "_resolved": "http://localhost:1337/mkdirp/-/mkdirp-0.3.5.tgz", + "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz", "bugs": { "url": "https://github.com/substack/node-mkdirp/issues" }, + "readme": "ERROR: No README data found!", "homepage": "https://github.com/substack/node-mkdirp" } diff --git a/node_modules/npmconf/package.json b/node_modules/npmconf/package.json index 30aaeca18..6892f0d89 100644 --- a/node_modules/npmconf/package.json +++ b/node_modules/npmconf/package.json @@ -1,6 +1,6 @@ { "name": "npmconf", - "version": "2.0.3", + "version": "2.0.4", "description": "The config thing npm uses", "main": "npmconf.js", "directories": { @@ -14,7 +14,7 @@ "nopt": "~3.0.1", "once": "~1.3.0", "osenv": "^0.1.0", - "semver": "2", + "semver": "2 || 3", "uid-number": "0.0.5" }, "devDependencies": { @@ -40,33 +40,14 @@ "url": "http://blog.izs.me" }, "license": "BSD", - "gitHead": "df12c6dffb0d5894afded0bc662f98c1320793d7", + "readme": "# npmconf\n\nThe config thing npm uses\n\nIf you are interested in interacting with the config settings that npm\nuses, then use this module.\n\nHowever, if you are writing a new Node.js program, and want\nconfiguration functionality similar to what npm has, but for your\nown thing, then I'd recommend using [rc](https://github.com/dominictarr/rc),\nwhich is probably what you want.\n\nIf I were to do it all over again, that's what I'd do for npm. But,\nalas, there are many systems depending on many of the particulars of\nnpm's configuration setup, so it's not worth the cost of changing.\n\n## USAGE\n\n```javascript\nvar npmconf = require('npmconf')\n\n// pass in the cli options that you read from the cli\n// or whatever top-level configs you want npm to use for now.\nnpmconf.load({some:'configs'}, function (er, conf) {\n // do stuff with conf\n conf.get('some', 'cli') // 'configs'\n conf.get('username') // 'joebobwhatevers'\n conf.set('foo', 'bar', 'user')\n conf.save('user', function (er) {\n // foo = bar is now saved to ~/.npmrc or wherever\n })\n})\n```\n", + "readmeFilename": "README.md", + "gitHead": "05c45131b9d59211a27c7c384bd9f6127ddf70d3", "bugs": { "url": "https://github.com/isaacs/npmconf/issues" }, "homepage": "https://github.com/isaacs/npmconf", - "_id": "npmconf@2.0.3", - "_shasum": "b1bf8e47972e859e93d84873efea89cab6251344", - "_from": "npmconf@2.0.3", - "_npmVersion": "1.5.0-alpha-3", - "_npmUser": { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - } - ], - "dist": { - "shasum": "b1bf8e47972e859e93d84873efea89cab6251344", - "tarball": "http://registry.npmjs.org/npmconf/-/npmconf-2.0.3.tgz" - }, - "_resolved": "https://registry.npmjs.org/npmconf/-/npmconf-2.0.3.tgz", - "readme": "ERROR: No README data found!" + "_id": "npmconf@2.0.4", + "_shasum": "598d79a5f780c213e9e9bfcf0ec9ca303840b628", + "_from": "npmconf@latest" } diff --git a/node_modules/read-installed/node_modules/util-extend/package.json b/node_modules/read-installed/node_modules/util-extend/package.json index 96f5a3f51..cbcbed27f 100644 --- a/node_modules/read-installed/node_modules/util-extend/package.json +++ b/node_modules/read-installed/node_modules/util-extend/package.json @@ -22,7 +22,7 @@ "shasum": "bb703b79480293ddcdcfb3c6a9fea20f483415bc", "tarball": "http://registry.npmjs.org/util-extend/-/util-extend-1.0.1.tgz" }, - "_from": "util-extend@^1.0.1", + "_from": "util-extend@>=1.0.1-0 <2.0.0-0", "_npmVersion": "1.3.4", "_npmUser": { "name": "isaacs", @@ -36,5 +36,6 @@ ], "directories": {}, "_shasum": "bb703b79480293ddcdcfb3c6a9fea20f483415bc", - "_resolved": "https://registry.npmjs.org/util-extend/-/util-extend-1.0.1.tgz" + "_resolved": "https://registry.npmjs.org/util-extend/-/util-extend-1.0.1.tgz", + "homepage": "https://github.com/isaacs/util-extend" } diff --git a/node_modules/read-installed/package.json b/node_modules/read-installed/package.json index de958a544..dc869c6f6 100644 --- a/node_modules/read-installed/package.json +++ b/node_modules/read-installed/package.json @@ -1,7 +1,7 @@ { "name": "read-installed", "description": "Read all the installed packages in a folder, and return a tree structure with all the data.", - "version": "2.0.5", + "version": "2.0.7", "repository": { "type": "git", "url": "git://github.com/isaacs/read-installed" @@ -12,7 +12,7 @@ }, "dependencies": { "read-package-json": "1", - "semver": "2", + "semver": "2 || 3", "slide": "~1.1.3", "util-extend": "^1.0.1", "graceful-fs": "2 || 3" @@ -31,12 +31,12 @@ }, "readme": "# read-installed\n\nRead all the installed packages in a folder, and return a tree\nstructure with all the data.\n\nnpm uses this.\n\n## 2.0.0\n\nBreaking changes in `2.0.0`:\n\nThe second argument is now an `Object` that contains the following keys:\n\n * `depth` optional, defaults to Infinity\n * `log` optional log Function\n * `dev` optional, default false, set to true to include devDependencies\n\n## Usage\n\n```javascript\nvar readInstalled = require(\"read-installed\")\n// optional options\nvar options = { dev: false, log: fn, depth: 2 }\nreadInstalled(folder, options, function (er, data) {\n ...\n})\n```\n", "readmeFilename": "README.md", - "gitHead": "2595631e4d3cbd64b26cee63dc3b5ce9f53e3533", + "gitHead": "4b38f9ed81e9c533764241c2ee45fe96ef31e2f8", "bugs": { "url": "https://github.com/isaacs/read-installed/issues" }, "homepage": "https://github.com/isaacs/read-installed", - "_id": "read-installed@2.0.5", - "_shasum": "761eda1fd2dc322f8e77844a8bf1ddedbcfc754b", + "_id": "read-installed@2.0.7", + "_shasum": "a82157a5e273576c57f230ecec3702ab215a6d6c", "_from": "read-installed@latest" } diff --git a/node_modules/read-installed/read-installed.js b/node_modules/read-installed/read-installed.js index 9b5a47962..3574e6c2f 100644 --- a/node_modules/read-installed/read-installed.js +++ b/node_modules/read-installed/read-installed.js @@ -330,7 +330,7 @@ function findUnmet (obj, opts) { } else if (!semver.satisfies(dependency.version, peerDeps[d], true)) { dependency.peerInvalid = true } else { - dependency.extraneous = false + dependency.extraneous = dependency.extraneous || false } }) diff --git a/node_modules/read-installed/test/fixtures/grandparent-peer-dev/package.json b/node_modules/read-installed/test/fixtures/grandparent-peer-dev/package.json new file mode 100644 index 000000000..1a229c1cf --- /dev/null +++ b/node_modules/read-installed/test/fixtures/grandparent-peer-dev/package.json @@ -0,0 +1,8 @@ +{ + "name": "example", + "version": "0.0.0", + "devDependencies": { + "plugin-wrapper": "0.0.0", + "framework": "0.0.0" + } +} diff --git a/node_modules/read-installed/test/grandparent-peer-dev.js b/node_modules/read-installed/test/grandparent-peer-dev.js new file mode 100644 index 000000000..fd7c2d2bc --- /dev/null +++ b/node_modules/read-installed/test/grandparent-peer-dev.js @@ -0,0 +1,20 @@ +var readInstalled = require('../read-installed.js') +var test = require('tap').test +var path = require('path'); + +function allValid(t, map) { + var deps = Object.keys(map.dependencies || {}) + deps.forEach(function (dep) { + t.ok(map.dependencies[dep].extraneous, 'dependency ' + dep + ' of ' + map.name + ' is extraneous') + }) +} + +test('grandparent dev peer dependencies should be extraneous', function(t) { + readInstalled( + path.join(__dirname, 'fixtures/grandparent-peer-dev'), + { log: console.error }, + function(err, map) { + allValid(t, map) + t.end() + }) +}) diff --git a/node_modules/read-package-json/package.json b/node_modules/read-package-json/package.json index 084732cbe..06c46ebbe 100644 --- a/node_modules/read-package-json/package.json +++ b/node_modules/read-package-json/package.json @@ -1,6 +1,6 @@ { "name": "read-package-json", - "version": "1.2.3", + "version": "1.2.4", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -18,7 +18,7 @@ "dependencies": { "glob": "^4.0.2", "lru-cache": "2", - "normalize-package-data": "^0.4.0", + "normalize-package-data": "0.4", "graceful-fs": "2 || 3" }, "devDependencies": { @@ -28,34 +28,14 @@ "graceful-fs": "2 || 3" }, "license": "ISC", - "gitHead": "ffb0c1a1221cb01e3071ab1a4a1d7d913352d9e7", + "readme": "# read-package-json\n\nThis is the thing that npm uses to read package.json files. It\nvalidates some stuff, and loads some default things.\n\nIt keeps a cache of the files you've read, so that you don't end\nup reading the same package.json file multiple times.\n\nNote that if you just want to see what's literally in the package.json\nfile, you can usually do `var data = require('some-module/package.json')`.\n\nThis module is basically only needed by npm, but it's handy to see what\nnpm will see when it looks at your package.\n\n## Usage\n\n```javascript\nvar readJson = require('read-package-json')\n\n// readJson(filename, [logFunction=noop], [strict=false], cb)\nreadJson('/path/to/package.json', console.error, false, function (er, data) {\n if (er) {\n console.error(\"There was an error reading the file\")\n return\n }\n\n console.error('the package data is', data)\n});\n```\n\n## readJson(file, [logFn = noop], [strict = false], cb)\n\n* `file` {String} The path to the package.json file\n* `logFn` {Function} Function to handle logging. Defaults to a noop.\n* `strict` {Boolean} True to enforce SemVer 2.0 version strings, and\n other strict requirements.\n* `cb` {Function} Gets called with `(er, data)`, as is The Node Way.\n\nReads the JSON file and does the things.\n\n## `package.json` Fields\n\nSee `man 5 package.json` or `npm help json`.\n\n## readJson.log\n\nBy default this is a reference to the `npmlog` module. But if that\nmodule can't be found, then it'll be set to just a dummy thing that does\nnothing.\n\nReplace with your own `{log,warn,error}` object for fun loggy time.\n\n## readJson.extras(file, data, cb)\n\nRun all the extra stuff relative to the file, with the parsed data.\n\nModifies the data as it does stuff. Calls the cb when it's done.\n\n## readJson.extraSet = [fn, fn, ...]\n\nArray of functions that are called by `extras`. Each one receives the\narguments `fn(file, data, cb)` and is expected to call `cb(er, data)`\nwhen done or when an error occurs.\n\nOrder is indeterminate, so each function should be completely\nindependent.\n\nMix and match!\n\n## readJson.cache\n\nThe `lru-cache` object that readJson uses to not read the same file over\nand over again. See\n[lru-cache](https://github.com/isaacs/node-lru-cache) for details.\n\n## Other Relevant Files Besides `package.json`\n\nSome other files have an effect on the resulting data object, in the\nfollowing ways:\n\n### `README?(.*)`\n\nIf there is a `README` or `README.*` file present, then npm will attach\na `readme` field to the data with the contents of this file.\n\nOwing to the fact that roughly 100% of existing node modules have\nMarkdown README files, it will generally be assumed to be Markdown,\nregardless of the extension. Please plan accordingly.\n\n### `server.js`\n\nIf there is a `server.js` file, and there is not already a\n`scripts.start` field, then `scripts.start` will be set to `node\nserver.js`.\n\n### `AUTHORS`\n\nIf there is not already a `contributors` field, then the `contributors`\nfield will be set to the contents of the `AUTHORS` file, split by lines,\nand parsed.\n\n### `bindings.gyp`\n\nIf a bindings.gyp file exists, and there is not already a\n`scripts.install` field, then the `scripts.install` field will be set to\n`node-gyp rebuild`.\n\n### `wscript`\n\nIf a wscript file exists, and there is not already a `scripts.install`\nfield, then the `scripts.install` field will be set to `node-waf clean ;\nnode-waf configure build`.\n\nNote that the `bindings.gyp` file supercedes this, since node-waf has\nbeen deprecated in favor of node-gyp.\n\n### `index.js`\n\nIf the json file does not exist, but there is a `index.js` file\npresent instead, and that file has a package comment, then it will try\nto parse the package comment, and use that as the data instead.\n\nA package comment looks like this:\n\n```javascript\n/**package\n * { \"name\": \"my-bare-module\"\n * , \"version\": \"1.2.3\"\n * , \"description\": \"etc....\" }\n **/\n\n// or...\n\n/**package\n{ \"name\": \"my-bare-module\"\n, \"version\": \"1.2.3\"\n, \"description\": \"etc....\" }\n**/\n```\n\nThe important thing is that it starts with `/**package`, and ends with\n`**/`. If the package.json file exists, then the index.js is not\nparsed.\n\n### `{directories.man}/*.[0-9]`\n\nIf there is not already a `man` field defined as an array of files or a\nsingle file, and\nthere is a `directories.man` field defined, then that directory will\nbe searched for manpages.\n\nAny valid manpages found in that directory will be assigned to the `man`\narray, and installed in the appropriate man directory at package install\ntime, when installed globally on a Unix system.\n\n### `{directories.bin}/*`\n\nIf there is not already a `bin` field defined as a string filename or a\nhash of `<name> : <filename>` pairs, then the `directories.bin`\ndirectory will be searched and all the files within it will be linked as\nexecutables at install time.\n\nWhen installing locally, npm links bins into `node_modules/.bin`, which\nis in the `PATH` environ when npm runs scripts. When\ninstalling globally, they are linked into `{prefix}/bin`, which is\npresumably in the `PATH` environment variable.\n", + "readmeFilename": "README.md", + "gitHead": "7127ed4d9fe93bb0c2b2809b3c10a4f23f0c8236", "bugs": { "url": "https://github.com/isaacs/read-package-json/issues" }, "homepage": "https://github.com/isaacs/read-package-json", - "_id": "read-package-json@1.2.3", - "_shasum": "12efad3cce1ff64bed9da951e9f4ed3d1b1d185e", - "_from": "read-package-json@1.2.3", - "_npmVersion": "1.4.16", - "_npmUser": { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - "maintainers": [ - { - "name": "isaacs", - "email": "i@izs.me" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - } - ], - "dist": { - "shasum": "12efad3cce1ff64bed9da951e9f4ed3d1b1d185e", - "tarball": "http://registry.npmjs.org/read-package-json/-/read-package-json-1.2.3.tgz" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-1.2.3.tgz", - "readme": "ERROR: No README data found!" + "_id": "read-package-json@1.2.4", + "_shasum": "7482e541baa70f2dc21cd1a51a68be82b904aa97", + "_from": "read-package-json@latest" } diff --git a/node_modules/semver/README.md b/node_modules/semver/README.md index 4e95b8465..2ca8d80c3 100644 --- a/node_modules/semver/README.md +++ b/node_modules/semver/README.md @@ -66,11 +66,11 @@ The following range styles are supported: prerelease) will be supported up to, but not including, the next major version (or its prereleases). `1.5.1` will satisfy `^1.2.3`, while `1.2.2` and `2.0.0-beta` will not. -* `^0.1.3` := `>=0.1.3-0 <0.2.0-0` "Compatible with `0.1.3`". `0.x.x` versions are - special: the first non-zero component indicates potentially breaking changes, - meaning the caret operator matches any version with the same first non-zero - component starting at the specified version. -* `^0.0.2` := `=0.0.2` "Only the version `0.0.2` is considered compatible" +* `^0.1.3` := `0.1.3` "Compatible with `0.1.3`". `0.x.x` versions are + special: since the semver spec specifies that `0.x.x` versions make + no stability guarantees, only the version specified is considered + valid. +* `^0.0.2` := `0.0.2` "Only the version `0.0.2` is considered compatible" * `~1.2` := `>=1.2.0-0 <1.3.0-0` "Any version starting with `1.2`" * `^1.2` := `>=1.2.0-0 <2.0.0-0` "Any version compatible with `1.2`" * `1.2.x` := `>=1.2.0-0 <1.3.0-0` "Any version starting with `1.2`" diff --git a/node_modules/semver/bin/semver b/node_modules/semver/bin/semver index 848420630..41c148fb8 100755 --- a/node_modules/semver/bin/semver +++ b/node_modules/semver/bin/semver @@ -107,8 +107,8 @@ function help () { ,"" ,"-i --increment [<level>]" ," Increment a version by the specified level. Level can" - ," be one of: major, minor, patch, or prerelease" - ," Default level is 'patch'." + ," be one of: major, minor, patch, premajor, preminor," + ," prepatch, or prerelease. Default level is 'patch'." ," Only one version may be specified." ,"" ,"-l --loose" diff --git a/node_modules/semver/package.json b/node_modules/semver/package.json index b65d866c3..4e4ae5827 100644 --- a/node_modules/semver/package.json +++ b/node_modules/semver/package.json @@ -1,6 +1,6 @@ { "name": "semver", - "version": "2.3.0", + "version": "3.0.0", "description": "The semantic version parser used by npm.", "main": "semver.js", "browser": "semver.browser.js", @@ -21,13 +21,14 @@ "bin": { "semver": "./bin/semver" }, - "readme": "semver(1) -- The semantic versioner for npm\n===========================================\n\n## Usage\n\n $ npm install semver\n\n semver.valid('1.2.3') // '1.2.3'\n semver.valid('a.b.c') // null\n semver.clean(' =v1.2.3 ') // '1.2.3'\n semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true\n semver.gt('1.2.3', '9.8.7') // false\n semver.lt('1.2.3', '9.8.7') // true\n\nAs a command-line utility:\n\n $ semver -h\n\n Usage: semver <version> [<version> [...]] [-r <range> | -i <inc> | -d <dec>]\n Test if version(s) satisfy the supplied range(s), and sort them.\n\n Multiple versions or ranges may be supplied, unless increment\n or decrement options are specified. In that case, only a single\n version may be used, and it is incremented by the specified level\n\n Program exits successfully if any valid version satisfies\n all supplied ranges, and prints all satisfying versions.\n\n If no versions are valid, or ranges are not satisfied,\n then exits failure.\n\n Versions are printed in ascending order, so supplying\n multiple versions to the utility will just sort them.\n\n## Versions\n\nA \"version\" is described by the `v2.0.0` specification found at\n<http://semver.org/>.\n\nA leading `\"=\"` or `\"v\"` character is stripped off and ignored.\n\n## Ranges\n\nThe following range styles are supported:\n\n* `1.2.3` A specific version. When nothing else will do. Must be a full\n version number, with major, minor, and patch versions specified.\n Note that build metadata is still ignored, so `1.2.3+build2012` will\n satisfy this range.\n* `>1.2.3` Greater than a specific version.\n* `<1.2.3` Less than a specific version. If there is no prerelease\n tag on the version range, then no prerelease version will be allowed\n either, even though these are technically \"less than\".\n* `>=1.2.3` Greater than or equal to. Note that prerelease versions\n are NOT equal to their \"normal\" equivalents, so `1.2.3-beta` will\n not satisfy this range, but `2.3.0-beta` will.\n* `<=1.2.3` Less than or equal to. In this case, prerelease versions\n ARE allowed, so `1.2.3-beta` would satisfy.\n* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`\n* `~1.2.3` := `>=1.2.3-0 <1.3.0-0` \"Reasonably close to `1.2.3`\". When\n using tilde operators, prerelease versions are supported as well,\n but a prerelease of the next significant digit will NOT be\n satisfactory, so `1.3.0-beta` will not satisfy `~1.2.3`.\n* `^1.2.3` := `>=1.2.3-0 <2.0.0-0` \"Compatible with `1.2.3`\". When\n using caret operators, anything from the specified version (including\n prerelease) will be supported up to, but not including, the next\n major version (or its prereleases). `1.5.1` will satisfy `^1.2.3`,\n while `1.2.2` and `2.0.0-beta` will not.\n* `^0.1.3` := `>=0.1.3-0 <0.2.0-0` \"Compatible with `0.1.3`\". `0.x.x` versions are\n special: the first non-zero component indicates potentially breaking changes,\n meaning the caret operator matches any version with the same first non-zero\n component starting at the specified version.\n* `^0.0.2` := `=0.0.2` \"Only the version `0.0.2` is considered compatible\"\n* `~1.2` := `>=1.2.0-0 <1.3.0-0` \"Any version starting with `1.2`\"\n* `^1.2` := `>=1.2.0-0 <2.0.0-0` \"Any version compatible with `1.2`\"\n* `1.2.x` := `>=1.2.0-0 <1.3.0-0` \"Any version starting with `1.2`\"\n* `1.2.*` Same as `1.2.x`.\n* `1.2` Same as `1.2.x`.\n* `~1` := `>=1.0.0-0 <2.0.0-0` \"Any version starting with `1`\"\n* `^1` := `>=1.0.0-0 <2.0.0-0` \"Any version compatible with `1`\"\n* `1.x` := `>=1.0.0-0 <2.0.0-0` \"Any version starting with `1`\"\n* `1.*` Same as `1.x`.\n* `1` Same as `1.x`.\n* `*` Any version whatsoever.\n* `x` Same as `*`.\n* `\"\"` (just an empty string) Same as `*`.\n\n\nRanges can be joined with either a space (which implies \"and\") or a\n`||` (which implies \"or\").\n\n## Functions\n\nAll methods and classes take a final `loose` boolean argument that, if\ntrue, will be more forgiving about not-quite-valid semver strings.\nThe resulting output will always be 100% strict, of course.\n\nStrict-mode Comparators and Ranges will be strict about the SemVer\nstrings that they parse.\n\n* `valid(v)`: Return the parsed version, or null if it's not valid.\n* `inc(v, release)`: Return the version incremented by the release\n type (`major`, `premajor`, `minor`, `preminor`, `patch`,\n `prepatch`, or `prerelease`), or null if it's not valid\n * `premajor` in one call will bump the version up to the next major\n version and down to a prerelease of that major version.\n `preminor`, and `prepatch` work the same way.\n * If called from a non-prerelease version, the `prerelease` will work the\n same as `prepatch`. It increments the patch version, then makes a\n prerelease. If the input version is already a prerelease it simply\n increments it.\n\n### Comparison\n\n* `gt(v1, v2)`: `v1 > v2`\n* `gte(v1, v2)`: `v1 >= v2`\n* `lt(v1, v2)`: `v1 < v2`\n* `lte(v1, v2)`: `v1 <= v2`\n* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,\n even if they're not the exact same string. You already know how to\n compare strings.\n* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.\n* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call\n the corresponding function above. `\"===\"` and `\"!==\"` do simple\n string comparison, but are included for completeness. Throws if an\n invalid comparison string is provided.\n* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if\n `v2` is greater. Sorts in ascending order if passed to `Array.sort()`.\n* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions\n in descending order when passed to `Array.sort()`.\n\n\n### Ranges\n\n* `validRange(range)`: Return the valid range or null if it's not valid\n* `satisfies(version, range)`: Return true if the version satisfies the\n range.\n* `maxSatisfying(versions, range)`: Return the highest version in the list\n that satisfies the range, or `null` if none of them do.\n* `gtr(version, range)`: Return `true` if version is greater than all the\n versions possible in the range.\n* `ltr(version, range)`: Return `true` if version is less than all the\n versions possible in the range.\n* `outside(version, range, hilo)`: Return true if the version is outside\n the bounds of the range in either the high or low direction. The\n `hilo` argument must be either the string `'>'` or `'<'`. (This is\n the function called by `gtr` and `ltr`.)\n\nNote that, since ranges may be non-contiguous, a version might not be\ngreater than a range, less than a range, *or* satisfy a range! For\nexample, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`\nuntil `2.0.0`, so the version `1.2.10` would not be greater than the\nrange (because `2.0.1` satisfies, which is higher), nor less than the\nrange (since `1.2.8` satisfies, which is lower), and it also does not\nsatisfy the range.\n\nIf you want to know if a version satisfies or does not satisfy a\nrange, use the `satisfies(version, range)` function.\n", + "readme": "semver(1) -- The semantic versioner for npm\n===========================================\n\n## Usage\n\n $ npm install semver\n\n semver.valid('1.2.3') // '1.2.3'\n semver.valid('a.b.c') // null\n semver.clean(' =v1.2.3 ') // '1.2.3'\n semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true\n semver.gt('1.2.3', '9.8.7') // false\n semver.lt('1.2.3', '9.8.7') // true\n\nAs a command-line utility:\n\n $ semver -h\n\n Usage: semver <version> [<version> [...]] [-r <range> | -i <inc> | -d <dec>]\n Test if version(s) satisfy the supplied range(s), and sort them.\n\n Multiple versions or ranges may be supplied, unless increment\n or decrement options are specified. In that case, only a single\n version may be used, and it is incremented by the specified level\n\n Program exits successfully if any valid version satisfies\n all supplied ranges, and prints all satisfying versions.\n\n If no versions are valid, or ranges are not satisfied,\n then exits failure.\n\n Versions are printed in ascending order, so supplying\n multiple versions to the utility will just sort them.\n\n## Versions\n\nA \"version\" is described by the `v2.0.0` specification found at\n<http://semver.org/>.\n\nA leading `\"=\"` or `\"v\"` character is stripped off and ignored.\n\n## Ranges\n\nThe following range styles are supported:\n\n* `1.2.3` A specific version. When nothing else will do. Must be a full\n version number, with major, minor, and patch versions specified.\n Note that build metadata is still ignored, so `1.2.3+build2012` will\n satisfy this range.\n* `>1.2.3` Greater than a specific version.\n* `<1.2.3` Less than a specific version. If there is no prerelease\n tag on the version range, then no prerelease version will be allowed\n either, even though these are technically \"less than\".\n* `>=1.2.3` Greater than or equal to. Note that prerelease versions\n are NOT equal to their \"normal\" equivalents, so `1.2.3-beta` will\n not satisfy this range, but `2.3.0-beta` will.\n* `<=1.2.3` Less than or equal to. In this case, prerelease versions\n ARE allowed, so `1.2.3-beta` would satisfy.\n* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`\n* `~1.2.3` := `>=1.2.3-0 <1.3.0-0` \"Reasonably close to `1.2.3`\". When\n using tilde operators, prerelease versions are supported as well,\n but a prerelease of the next significant digit will NOT be\n satisfactory, so `1.3.0-beta` will not satisfy `~1.2.3`.\n* `^1.2.3` := `>=1.2.3-0 <2.0.0-0` \"Compatible with `1.2.3`\". When\n using caret operators, anything from the specified version (including\n prerelease) will be supported up to, but not including, the next\n major version (or its prereleases). `1.5.1` will satisfy `^1.2.3`,\n while `1.2.2` and `2.0.0-beta` will not.\n* `^0.1.3` := `0.1.3` \"Compatible with `0.1.3`\". `0.x.x` versions are\n special: since the semver spec specifies that `0.x.x` versions make\n no stability guarantees, only the version specified is considered\n valid.\n* `^0.0.2` := `0.0.2` \"Only the version `0.0.2` is considered compatible\"\n* `~1.2` := `>=1.2.0-0 <1.3.0-0` \"Any version starting with `1.2`\"\n* `^1.2` := `>=1.2.0-0 <2.0.0-0` \"Any version compatible with `1.2`\"\n* `1.2.x` := `>=1.2.0-0 <1.3.0-0` \"Any version starting with `1.2`\"\n* `1.2.*` Same as `1.2.x`.\n* `1.2` Same as `1.2.x`.\n* `~1` := `>=1.0.0-0 <2.0.0-0` \"Any version starting with `1`\"\n* `^1` := `>=1.0.0-0 <2.0.0-0` \"Any version compatible with `1`\"\n* `1.x` := `>=1.0.0-0 <2.0.0-0` \"Any version starting with `1`\"\n* `1.*` Same as `1.x`.\n* `1` Same as `1.x`.\n* `*` Any version whatsoever.\n* `x` Same as `*`.\n* `\"\"` (just an empty string) Same as `*`.\n\n\nRanges can be joined with either a space (which implies \"and\") or a\n`||` (which implies \"or\").\n\n## Functions\n\nAll methods and classes take a final `loose` boolean argument that, if\ntrue, will be more forgiving about not-quite-valid semver strings.\nThe resulting output will always be 100% strict, of course.\n\nStrict-mode Comparators and Ranges will be strict about the SemVer\nstrings that they parse.\n\n* `valid(v)`: Return the parsed version, or null if it's not valid.\n* `inc(v, release)`: Return the version incremented by the release\n type (`major`, `premajor`, `minor`, `preminor`, `patch`,\n `prepatch`, or `prerelease`), or null if it's not valid\n * `premajor` in one call will bump the version up to the next major\n version and down to a prerelease of that major version.\n `preminor`, and `prepatch` work the same way.\n * If called from a non-prerelease version, the `prerelease` will work the\n same as `prepatch`. It increments the patch version, then makes a\n prerelease. If the input version is already a prerelease it simply\n increments it.\n\n### Comparison\n\n* `gt(v1, v2)`: `v1 > v2`\n* `gte(v1, v2)`: `v1 >= v2`\n* `lt(v1, v2)`: `v1 < v2`\n* `lte(v1, v2)`: `v1 <= v2`\n* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,\n even if they're not the exact same string. You already know how to\n compare strings.\n* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.\n* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call\n the corresponding function above. `\"===\"` and `\"!==\"` do simple\n string comparison, but are included for completeness. Throws if an\n invalid comparison string is provided.\n* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if\n `v2` is greater. Sorts in ascending order if passed to `Array.sort()`.\n* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions\n in descending order when passed to `Array.sort()`.\n\n\n### Ranges\n\n* `validRange(range)`: Return the valid range or null if it's not valid\n* `satisfies(version, range)`: Return true if the version satisfies the\n range.\n* `maxSatisfying(versions, range)`: Return the highest version in the list\n that satisfies the range, or `null` if none of them do.\n* `gtr(version, range)`: Return `true` if version is greater than all the\n versions possible in the range.\n* `ltr(version, range)`: Return `true` if version is less than all the\n versions possible in the range.\n* `outside(version, range, hilo)`: Return true if the version is outside\n the bounds of the range in either the high or low direction. The\n `hilo` argument must be either the string `'>'` or `'<'`. (This is\n the function called by `gtr` and `ltr`.)\n\nNote that, since ranges may be non-contiguous, a version might not be\ngreater than a range, less than a range, *or* satisfy a range! For\nexample, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`\nuntil `2.0.0`, so the version `1.2.10` would not be greater than the\nrange (because `2.0.1` satisfies, which is higher), nor less than the\nrange (since `1.2.8` satisfies, which is lower), and it also does not\nsatisfy the range.\n\nIf you want to know if a version satisfies or does not satisfy a\nrange, use the `satisfies(version, range)` function.\n", "readmeFilename": "README.md", + "gitHead": "e077f4e33e21b280a5cf6688d850dabf5f6e48e2", "bugs": { "url": "https://github.com/isaacs/node-semver/issues" }, "homepage": "https://github.com/isaacs/node-semver", - "_id": "semver@2.3.0", - "_shasum": "d31b2903ebe2a1806c05b8e763916a7183108a15", + "_id": "semver@3.0.0", + "_shasum": "994f634b9535a36b07fde690faa811a9ed35b4f3", "_from": "semver@latest" } diff --git a/node_modules/semver/semver.browser.js b/node_modules/semver/semver.browser.js index 0f414c3d8..98a23298f 100644 --- a/node_modules/semver/semver.browser.js +++ b/node_modules/semver/semver.browser.js @@ -356,6 +356,10 @@ SemVer.prototype.inc = function(release) { this.inc('pre'); break; case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0; this.inc('patch'); this.inc('pre'); break; @@ -548,6 +552,9 @@ Comparator.prototype.parse = function(comp) { throw new TypeError('Invalid comparator: ' + comp); this.operator = m[1]; + if (this.operator === '=') + this.operator = ''; + // if it literally is just '>' or '' then allow anything. if (!m[2]) this.semver = ANY; @@ -753,6 +760,11 @@ function replaceCaret(comp, loose) { return comp.replace(r, function(_, M, m, p, pr) { ; var ret; + if (pr) { + if (pr.charAt(0) !== '-') + pr = '-' + pr; + } else + pr = ''; if (isX(M)) ret = ''; @@ -763,30 +775,14 @@ function replaceCaret(comp, loose) { ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0'; else ret = '>=' + M + '.' + m + '.0-0 <' + (+M + 1) + '.0.0-0'; - } else if (pr) { - ; - if (pr.charAt(0) !== '-') - pr = '-' + pr; - if (M === '0') { - if (m === '0') - ret = '=' + M + '.' + m + '.' + p + pr; - else - ret = '>=' + M + '.' + m + '.' + p + pr + - ' <' + M + '.' + (+m + 1) + '.0-0'; - } else - ret = '>=' + M + '.' + m + '.' + p + pr + - ' <' + (+M + 1) + '.0.0-0'; - } else { - if (M === '0') { - if (m === '0') - ret = '=' + M + '.' + m + '.' + p; - else - ret = '>=' + M + '.' + m + '.' + p + '-0' + - ' <' + M + '.' + (+m + 1) + '.0-0'; - } else - ret = '>=' + M + '.' + m + '.' + p + '-0' + - ' <' + (+M + 1) + '.0.0-0'; - } + } else if (M === '0') + ret = '=' + M + '.' + m + '.' + p + pr; + else if (pr) + ret = '>=' + M + '.' + m + '.' + p + pr + + ' <' + (+M + 1) + '.0.0-0'; + else + ret = '>=' + M + '.' + m + '.' + p + '-0' + + ' <' + (+M + 1) + '.0.0-0'; ; return ret; diff --git a/node_modules/semver/semver.browser.js.gz b/node_modules/semver/semver.browser.js.gz Binary files differindex 2b07bae51..767029e5e 100644 --- a/node_modules/semver/semver.browser.js.gz +++ b/node_modules/semver/semver.browser.js.gz diff --git a/node_modules/semver/semver.js b/node_modules/semver/semver.js index a7385b41c..2939331c8 100644 --- a/node_modules/semver/semver.js +++ b/node_modules/semver/semver.js @@ -366,6 +366,10 @@ SemVer.prototype.inc = function(release) { this.inc('pre'); break; case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0; this.inc('patch'); this.inc('pre'); break; @@ -558,6 +562,9 @@ Comparator.prototype.parse = function(comp) { throw new TypeError('Invalid comparator: ' + comp); this.operator = m[1]; + if (this.operator === '=') + this.operator = ''; + // if it literally is just '>' or '' then allow anything. if (!m[2]) this.semver = ANY; @@ -763,6 +770,11 @@ function replaceCaret(comp, loose) { return comp.replace(r, function(_, M, m, p, pr) { debug('caret', comp, _, M, m, p, pr); var ret; + if (pr) { + if (pr.charAt(0) !== '-') + pr = '-' + pr; + } else + pr = ''; if (isX(M)) ret = ''; @@ -773,30 +785,14 @@ function replaceCaret(comp, loose) { ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0'; else ret = '>=' + M + '.' + m + '.0-0 <' + (+M + 1) + '.0.0-0'; - } else if (pr) { - debug('replaceCaret pr', pr); - if (pr.charAt(0) !== '-') - pr = '-' + pr; - if (M === '0') { - if (m === '0') - ret = '=' + M + '.' + m + '.' + p + pr; - else - ret = '>=' + M + '.' + m + '.' + p + pr + - ' <' + M + '.' + (+m + 1) + '.0-0'; - } else - ret = '>=' + M + '.' + m + '.' + p + pr + - ' <' + (+M + 1) + '.0.0-0'; - } else { - if (M === '0') { - if (m === '0') - ret = '=' + M + '.' + m + '.' + p; - else - ret = '>=' + M + '.' + m + '.' + p + '-0' + - ' <' + M + '.' + (+m + 1) + '.0-0'; - } else - ret = '>=' + M + '.' + m + '.' + p + '-0' + - ' <' + (+M + 1) + '.0.0-0'; - } + } else if (M === '0') + ret = '=' + M + '.' + m + '.' + p + pr; + else if (pr) + ret = '>=' + M + '.' + m + '.' + p + pr + + ' <' + (+M + 1) + '.0.0-0'; + else + ret = '>=' + M + '.' + m + '.' + p + '-0' + + ' <' + (+M + 1) + '.0.0-0'; debug('caret return', ret); return ret; diff --git a/node_modules/semver/semver.min.js b/node_modules/semver/semver.min.js index 66e13b863..db48461b4 100644 --- a/node_modules/semver/semver.min.js +++ b/node_modules/semver/semver.min.js @@ -1 +1 @@ -(function(e){if(typeof module==="object"&&module.exports===e)e=module.exports=H;e.SEMVER_SPEC_VERSION="2.0.0";var r=e.re=[];var t=e.src=[];var n=0;var i=n++;t[i]="0|[1-9]\\d*";var s=n++;t[s]="[0-9]+";var a=n++;t[a]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var o=n++;t[o]="("+t[i]+")\\."+"("+t[i]+")\\."+"("+t[i]+")";var f=n++;t[f]="("+t[s]+")\\."+"("+t[s]+")\\."+"("+t[s]+")";var u=n++;t[u]="(?:"+t[i]+"|"+t[a]+")";var c=n++;t[c]="(?:"+t[s]+"|"+t[a]+")";var l=n++;t[l]="(?:-("+t[u]+"(?:\\."+t[u]+")*))";var p=n++;t[p]="(?:-?("+t[c]+"(?:\\."+t[c]+")*))";var h=n++;t[h]="[0-9A-Za-z-]+";var v=n++;t[v]="(?:\\+("+t[h]+"(?:\\."+t[h]+")*))";var m=n++;var g="v?"+t[o]+t[l]+"?"+t[v]+"?";t[m]="^"+g+"$";var w="[v=\\s]*"+t[f]+t[p]+"?"+t[v]+"?";var d=n++;t[d]="^"+w+"$";var y=n++;t[y]="((?:<|>)?=?)";var b=n++;t[b]=t[s]+"|x|X|\\*";var $=n++;t[$]=t[i]+"|x|X|\\*";var j=n++;t[j]="[v=\\s]*("+t[$]+")"+"(?:\\.("+t[$]+")"+"(?:\\.("+t[$]+")"+"(?:("+t[l]+")"+")?)?)?";var k=n++;t[k]="[v=\\s]*("+t[b]+")"+"(?:\\.("+t[b]+")"+"(?:\\.("+t[b]+")"+"(?:("+t[p]+")"+")?)?)?";var E=n++;t[E]="^"+t[y]+"\\s*"+t[j]+"$";var x=n++;t[x]="^"+t[y]+"\\s*"+t[k]+"$";var R=n++;t[R]="(?:~>?)";var S=n++;t[S]="(\\s*)"+t[R]+"\\s+";r[S]=new RegExp(t[S],"g");var V="$1~";var I=n++;t[I]="^"+t[R]+t[j]+"$";var T=n++;t[T]="^"+t[R]+t[k]+"$";var A=n++;t[A]="(?:\\^)";var C=n++;t[C]="(\\s*)"+t[A]+"\\s+";r[C]=new RegExp(t[C],"g");var M="$1^";var z=n++;t[z]="^"+t[A]+t[j]+"$";var P=n++;t[P]="^"+t[A]+t[k]+"$";var Z=n++;t[Z]="^"+t[y]+"\\s*("+w+")$|^$";var q=n++;t[q]="^"+t[y]+"\\s*("+g+")$|^$";var L=n++;t[L]="(\\s*)"+t[y]+"\\s*("+w+"|"+t[j]+")";r[L]=new RegExp(t[L],"g");var X="$1$2$3";var _=n++;t[_]="^\\s*("+t[j]+")"+"\\s+-\\s+"+"("+t[j]+")"+"\\s*$";var N=n++;t[N]="^\\s*("+t[k]+")"+"\\s+-\\s+"+"("+t[k]+")"+"\\s*$";var O=n++;t[O]="(<|>)?=?\\s*\\*";for(var B=0;B<n;B++){if(!r[B])r[B]=new RegExp(t[B])}e.parse=D;function D(e,t){var n=t?r[d]:r[m];return n.test(e)?new H(e,t):null}e.valid=F;function F(e,r){var t=D(e,r);return t?t.version:null}e.clean=G;function G(e,r){var t=D(e,r);return t?t.version:null}e.SemVer=H;function H(e,t){if(e instanceof H){if(e.loose===t)return e;else e=e.version}else if(typeof e!=="string"){throw new TypeError("Invalid Version: "+e)}if(!(this instanceof H))return new H(e,t);this.loose=t;var n=e.trim().match(t?r[d]:r[m]);if(!n)throw new TypeError("Invalid Version: "+e);this.raw=e;this.major=+n[1];this.minor=+n[2];this.patch=+n[3];if(!n[4])this.prerelease=[];else this.prerelease=n[4].split(".").map(function(e){return/^[0-9]+$/.test(e)?+e:e});this.build=n[5]?n[5].split("."):[];this.format()}H.prototype.format=function(){this.version=this.major+"."+this.minor+"."+this.patch;if(this.prerelease.length)this.version+="-"+this.prerelease.join(".");return this.version};H.prototype.inspect=function(){return'<SemVer "'+this+'">'};H.prototype.toString=function(){return this.version};H.prototype.compare=function(e){if(!(e instanceof H))e=new H(e,this.loose);return this.compareMain(e)||this.comparePre(e)};H.prototype.compareMain=function(e){if(!(e instanceof H))e=new H(e,this.loose);return Q(this.major,e.major)||Q(this.minor,e.minor)||Q(this.patch,e.patch)};H.prototype.comparePre=function(e){if(!(e instanceof H))e=new H(e,this.loose);if(this.prerelease.length&&!e.prerelease.length)return-1;else if(!this.prerelease.length&&e.prerelease.length)return 1;else if(!this.prerelease.length&&!e.prerelease.length)return 0;var r=0;do{var t=this.prerelease[r];var n=e.prerelease[r];if(t===undefined&&n===undefined)return 0;else if(n===undefined)return 1;else if(t===undefined)return-1;else if(t===n)continue;else return Q(t,n)}while(++r)};H.prototype.inc=function(e){switch(e){case"premajor":this.inc("major");this.inc("pre");break;case"preminor":this.inc("minor");this.inc("pre");break;case"prepatch":this.inc("patch");this.inc("pre");break;case"prerelease":if(this.prerelease.length===0)this.inc("patch");this.inc("pre");break;case"major":this.major++;this.minor=-1;case"minor":this.minor++;this.patch=0;this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{var r=this.prerelease.length;while(--r>=0){if(typeof this.prerelease[r]==="number"){this.prerelease[r]++;r=-2}}if(r===-1)this.prerelease.push(0)}break;default:throw new Error("invalid increment argument: "+e)}this.format();return this};e.inc=J;function J(e,r,t){try{return new H(e,t).inc(r).version}catch(n){return null}}e.compareIdentifiers=Q;var K=/^[0-9]+$/;function Q(e,r){var t=K.test(e);var n=K.test(r);if(t&&n){e=+e;r=+r}return t&&!n?-1:n&&!t?1:e<r?-1:e>r?1:0}e.rcompareIdentifiers=U;function U(e,r){return Q(r,e)}e.compare=W;function W(e,r,t){return new H(e,t).compare(r)}e.compareLoose=Y;function Y(e,r){return W(e,r,true)}e.rcompare=er;function er(e,r,t){return W(r,e,t)}e.sort=rr;function rr(r,t){return r.sort(function(r,n){return e.compare(r,n,t)})}e.rsort=tr;function tr(r,t){return r.sort(function(r,n){return e.rcompare(r,n,t)})}e.gt=nr;function nr(e,r,t){return W(e,r,t)>0}e.lt=ir;function ir(e,r,t){return W(e,r,t)<0}e.eq=sr;function sr(e,r,t){return W(e,r,t)===0}e.neq=ar;function ar(e,r,t){return W(e,r,t)!==0}e.gte=or;function or(e,r,t){return W(e,r,t)>=0}e.lte=fr;function fr(e,r,t){return W(e,r,t)<=0}e.cmp=ur;function ur(e,r,t,n){var i;switch(r){case"===":i=e===t;break;case"!==":i=e!==t;break;case"":case"=":case"==":i=sr(e,t,n);break;case"!=":i=ar(e,t,n);break;case">":i=nr(e,t,n);break;case">=":i=or(e,t,n);break;case"<":i=ir(e,t,n);break;case"<=":i=fr(e,t,n);break;default:throw new TypeError("Invalid operator: "+r)}return i}e.Comparator=cr;function cr(e,r){if(e instanceof cr){if(e.loose===r)return e;else e=e.value}if(!(this instanceof cr))return new cr(e,r);this.loose=r;this.parse(e);if(this.semver===lr)this.value="";else this.value=this.operator+this.semver.version}var lr={};cr.prototype.parse=function(e){var t=this.loose?r[Z]:r[q];var n=e.match(t);if(!n)throw new TypeError("Invalid comparator: "+e);this.operator=n[1];if(!n[2])this.semver=lr;else{this.semver=new H(n[2],this.loose);if(this.operator==="<"&&!this.semver.prerelease.length){this.semver.prerelease=["0"];this.semver.format()}}};cr.prototype.inspect=function(){return'<SemVer Comparator "'+this+'">'};cr.prototype.toString=function(){return this.value};cr.prototype.test=function(e){return this.semver===lr?true:ur(e,this.operator,this.semver,this.loose)};e.Range=pr;function pr(e,r){if(e instanceof pr&&e.loose===r)return e;if(!(this instanceof pr))return new pr(e,r);this.loose=r;this.raw=e;this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length});if(!this.set.length){throw new TypeError("Invalid SemVer Range: "+e)}this.format()}pr.prototype.inspect=function(){return'<SemVer Range "'+this.range+'">'};pr.prototype.format=function(){this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim();return this.range};pr.prototype.toString=function(){return this.range};pr.prototype.parseRange=function(e){var t=this.loose;e=e.trim();var n=t?r[N]:r[_];e=e.replace(n,kr);e=e.replace(r[L],X);e=e.replace(r[S],V);e=e.replace(r[C],M);e=e.split(/\s+/).join(" ");var i=t?r[Z]:r[q];var s=e.split(" ").map(function(e){return vr(e,t)}).join(" ").split(/\s+/);if(this.loose){s=s.filter(function(e){return!!e.match(i)})}s=s.map(function(e){return new cr(e,t)});return s};e.toComparators=hr;function hr(e,r){return new pr(e,r).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})}function vr(e,r){e=dr(e,r);e=gr(e,r);e=br(e,r);e=jr(e,r);return e}function mr(e){return!e||e.toLowerCase()==="x"||e==="*"}function gr(e,r){return e.trim().split(/\s+/).map(function(e){return wr(e,r)}).join(" ")}function wr(e,t){var n=t?r[T]:r[I];return e.replace(n,function(e,r,t,n,i){var s;if(mr(r))s="";else if(mr(t))s=">="+r+".0.0-0 <"+(+r+1)+".0.0-0";else if(mr(n))s=">="+r+"."+t+".0-0 <"+r+"."+(+t+1)+".0-0";else if(i){if(i.charAt(0)!=="-")i="-"+i;s=">="+r+"."+t+"."+n+i+" <"+r+"."+(+t+1)+".0-0"}else s=">="+r+"."+t+"."+n+"-0"+" <"+r+"."+(+t+1)+".0-0";return s})}function dr(e,r){return e.trim().split(/\s+/).map(function(e){return yr(e,r)}).join(" ")}function yr(e,t){var n=t?r[P]:r[z];return e.replace(n,function(e,r,t,n,i){var s;if(mr(r))s="";else if(mr(t))s=">="+r+".0.0-0 <"+(+r+1)+".0.0-0";else if(mr(n)){if(r==="0")s=">="+r+"."+t+".0-0 <"+r+"."+(+t+1)+".0-0";else s=">="+r+"."+t+".0-0 <"+(+r+1)+".0.0-0"}else if(i){if(i.charAt(0)!=="-")i="-"+i;if(r==="0"){if(t==="0")s="="+r+"."+t+"."+n+i;else s=">="+r+"."+t+"."+n+i+" <"+r+"."+(+t+1)+".0-0"}else s=">="+r+"."+t+"."+n+i+" <"+(+r+1)+".0.0-0"}else{if(r==="0"){if(t==="0")s="="+r+"."+t+"."+n;else s=">="+r+"."+t+"."+n+"-0"+" <"+r+"."+(+t+1)+".0-0"}else s=">="+r+"."+t+"."+n+"-0"+" <"+(+r+1)+".0.0-0"}return s})}function br(e,r){return e.split(/\s+/).map(function(e){return $r(e,r)}).join(" ")}function $r(e,t){e=e.trim();var n=t?r[x]:r[E];return e.replace(n,function(e,r,t,n,i,s){var a=mr(t);var o=a||mr(n);var f=o||mr(i);var u=f;if(r==="="&&u)r="";if(r&&u){if(a)t=0;if(o)n=0;if(f)i=0;if(r===">"){r=">=";if(a){}else if(o){t=+t+1;n=0;i=0}else if(f){n=+n+1;i=0}}e=r+t+"."+n+"."+i+"-0"}else if(a){e="*"}else if(o){e=">="+t+".0.0-0 <"+(+t+1)+".0.0-0"}else if(f){e=">="+t+"."+n+".0-0 <"+t+"."+(+n+1)+".0-0"}return e})}function jr(e,t){return e.trim().replace(r[O],"")}function kr(e,r,t,n,i,s,a,o,f,u,c,l,p){if(mr(t))r="";else if(mr(n))r=">="+t+".0.0-0";else if(mr(i))r=">="+t+"."+n+".0-0";else r=">="+r;if(mr(f))o="";else if(mr(u))o="<"+(+f+1)+".0.0-0";else if(mr(c))o="<"+f+"."+(+u+1)+".0-0";else if(l)o="<="+f+"."+u+"."+c+"-"+l;else o="<="+o;return(r+" "+o).trim()}pr.prototype.test=function(e){if(!e)return false;for(var r=0;r<this.set.length;r++){if(Er(this.set[r],e))return true}return false};function Er(e,r){for(var t=0;t<e.length;t++){if(!e[t].test(r))return false}return true}e.satisfies=xr;function xr(e,r,t){try{r=new pr(r,t)}catch(n){return false}return r.test(e)}e.maxSatisfying=Rr;function Rr(e,r,t){return e.filter(function(e){return xr(e,r,t)}).sort(function(e,r){return er(e,r,t)})[0]||null}e.validRange=Sr;function Sr(e,r){try{return new pr(e,r).range||"*"}catch(t){return null}}e.ltr=Vr;function Vr(e,r,t){return Tr(e,r,"<",t)}e.gtr=Ir;function Ir(e,r,t){return Tr(e,r,">",t)}e.outside=Tr;function Tr(e,r,t,n){e=new H(e,n);r=new pr(r,n);var i,s,a,o,f;switch(t){case">":i=nr;s=fr;a=ir;o=">";f=">=";break;case"<":i=ir;s=or;a=nr;o="<";f="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(xr(e,r,n)){return false}for(var u=0;u<r.set.length;++u){var c=r.set[u];var l=null;var p=null;c.forEach(function(e){l=l||e;p=p||e;if(i(e.semver,l.semver,n)){l=e}else if(a(e.semver,p.semver,n)){p=e}});if(l.operator===o||l.operator===f){return false}if((!p.operator||p.operator===o)&&s(e,p.semver)){return false}else if(p.operator===f&&a(e,p.semver)){return false}}return true}if(typeof define==="function"&&define.amd)define(e)})(typeof exports==="object"?exports:typeof define==="function"&&define.amd?{}:semver={});
\ No newline at end of file +(function(e){if(typeof module==="object"&&module.exports===e)e=module.exports=H;e.SEMVER_SPEC_VERSION="2.0.0";var r=e.re=[];var t=e.src=[];var n=0;var i=n++;t[i]="0|[1-9]\\d*";var s=n++;t[s]="[0-9]+";var a=n++;t[a]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var o=n++;t[o]="("+t[i]+")\\."+"("+t[i]+")\\."+"("+t[i]+")";var f=n++;t[f]="("+t[s]+")\\."+"("+t[s]+")\\."+"("+t[s]+")";var u=n++;t[u]="(?:"+t[i]+"|"+t[a]+")";var c=n++;t[c]="(?:"+t[s]+"|"+t[a]+")";var l=n++;t[l]="(?:-("+t[u]+"(?:\\."+t[u]+")*))";var p=n++;t[p]="(?:-?("+t[c]+"(?:\\."+t[c]+")*))";var h=n++;t[h]="[0-9A-Za-z-]+";var v=n++;t[v]="(?:\\+("+t[h]+"(?:\\."+t[h]+")*))";var m=n++;var g="v?"+t[o]+t[l]+"?"+t[v]+"?";t[m]="^"+g+"$";var w="[v=\\s]*"+t[f]+t[p]+"?"+t[v]+"?";var d=n++;t[d]="^"+w+"$";var y=n++;t[y]="((?:<|>)?=?)";var b=n++;t[b]=t[s]+"|x|X|\\*";var $=n++;t[$]=t[i]+"|x|X|\\*";var j=n++;t[j]="[v=\\s]*("+t[$]+")"+"(?:\\.("+t[$]+")"+"(?:\\.("+t[$]+")"+"(?:("+t[l]+")"+")?)?)?";var k=n++;t[k]="[v=\\s]*("+t[b]+")"+"(?:\\.("+t[b]+")"+"(?:\\.("+t[b]+")"+"(?:("+t[p]+")"+")?)?)?";var E=n++;t[E]="^"+t[y]+"\\s*"+t[j]+"$";var x=n++;t[x]="^"+t[y]+"\\s*"+t[k]+"$";var R=n++;t[R]="(?:~>?)";var S=n++;t[S]="(\\s*)"+t[R]+"\\s+";r[S]=new RegExp(t[S],"g");var V="$1~";var I=n++;t[I]="^"+t[R]+t[j]+"$";var T=n++;t[T]="^"+t[R]+t[k]+"$";var A=n++;t[A]="(?:\\^)";var C=n++;t[C]="(\\s*)"+t[A]+"\\s+";r[C]=new RegExp(t[C],"g");var M="$1^";var z=n++;t[z]="^"+t[A]+t[j]+"$";var P=n++;t[P]="^"+t[A]+t[k]+"$";var Z=n++;t[Z]="^"+t[y]+"\\s*("+w+")$|^$";var q=n++;t[q]="^"+t[y]+"\\s*("+g+")$|^$";var L=n++;t[L]="(\\s*)"+t[y]+"\\s*("+w+"|"+t[j]+")";r[L]=new RegExp(t[L],"g");var X="$1$2$3";var _=n++;t[_]="^\\s*("+t[j]+")"+"\\s+-\\s+"+"("+t[j]+")"+"\\s*$";var N=n++;t[N]="^\\s*("+t[k]+")"+"\\s+-\\s+"+"("+t[k]+")"+"\\s*$";var O=n++;t[O]="(<|>)?=?\\s*\\*";for(var B=0;B<n;B++){if(!r[B])r[B]=new RegExp(t[B])}e.parse=D;function D(e,t){var n=t?r[d]:r[m];return n.test(e)?new H(e,t):null}e.valid=F;function F(e,r){var t=D(e,r);return t?t.version:null}e.clean=G;function G(e,r){var t=D(e,r);return t?t.version:null}e.SemVer=H;function H(e,t){if(e instanceof H){if(e.loose===t)return e;else e=e.version}else if(typeof e!=="string"){throw new TypeError("Invalid Version: "+e)}if(!(this instanceof H))return new H(e,t);this.loose=t;var n=e.trim().match(t?r[d]:r[m]);if(!n)throw new TypeError("Invalid Version: "+e);this.raw=e;this.major=+n[1];this.minor=+n[2];this.patch=+n[3];if(!n[4])this.prerelease=[];else this.prerelease=n[4].split(".").map(function(e){return/^[0-9]+$/.test(e)?+e:e});this.build=n[5]?n[5].split("."):[];this.format()}H.prototype.format=function(){this.version=this.major+"."+this.minor+"."+this.patch;if(this.prerelease.length)this.version+="-"+this.prerelease.join(".");return this.version};H.prototype.inspect=function(){return'<SemVer "'+this+'">'};H.prototype.toString=function(){return this.version};H.prototype.compare=function(e){if(!(e instanceof H))e=new H(e,this.loose);return this.compareMain(e)||this.comparePre(e)};H.prototype.compareMain=function(e){if(!(e instanceof H))e=new H(e,this.loose);return Q(this.major,e.major)||Q(this.minor,e.minor)||Q(this.patch,e.patch)};H.prototype.comparePre=function(e){if(!(e instanceof H))e=new H(e,this.loose);if(this.prerelease.length&&!e.prerelease.length)return-1;else if(!this.prerelease.length&&e.prerelease.length)return 1;else if(!this.prerelease.length&&!e.prerelease.length)return 0;var r=0;do{var t=this.prerelease[r];var n=e.prerelease[r];if(t===undefined&&n===undefined)return 0;else if(n===undefined)return 1;else if(t===undefined)return-1;else if(t===n)continue;else return Q(t,n)}while(++r)};H.prototype.inc=function(e){switch(e){case"premajor":this.inc("major");this.inc("pre");break;case"preminor":this.inc("minor");this.inc("pre");break;case"prepatch":this.prerelease.length=0;this.inc("patch");this.inc("pre");break;case"prerelease":if(this.prerelease.length===0)this.inc("patch");this.inc("pre");break;case"major":this.major++;this.minor=-1;case"minor":this.minor++;this.patch=0;this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{var r=this.prerelease.length;while(--r>=0){if(typeof this.prerelease[r]==="number"){this.prerelease[r]++;r=-2}}if(r===-1)this.prerelease.push(0)}break;default:throw new Error("invalid increment argument: "+e)}this.format();return this};e.inc=J;function J(e,r,t){try{return new H(e,t).inc(r).version}catch(n){return null}}e.compareIdentifiers=Q;var K=/^[0-9]+$/;function Q(e,r){var t=K.test(e);var n=K.test(r);if(t&&n){e=+e;r=+r}return t&&!n?-1:n&&!t?1:e<r?-1:e>r?1:0}e.rcompareIdentifiers=U;function U(e,r){return Q(r,e)}e.compare=W;function W(e,r,t){return new H(e,t).compare(r)}e.compareLoose=Y;function Y(e,r){return W(e,r,true)}e.rcompare=er;function er(e,r,t){return W(r,e,t)}e.sort=rr;function rr(r,t){return r.sort(function(r,n){return e.compare(r,n,t)})}e.rsort=tr;function tr(r,t){return r.sort(function(r,n){return e.rcompare(r,n,t)})}e.gt=nr;function nr(e,r,t){return W(e,r,t)>0}e.lt=ir;function ir(e,r,t){return W(e,r,t)<0}e.eq=sr;function sr(e,r,t){return W(e,r,t)===0}e.neq=ar;function ar(e,r,t){return W(e,r,t)!==0}e.gte=or;function or(e,r,t){return W(e,r,t)>=0}e.lte=fr;function fr(e,r,t){return W(e,r,t)<=0}e.cmp=ur;function ur(e,r,t,n){var i;switch(r){case"===":i=e===t;break;case"!==":i=e!==t;break;case"":case"=":case"==":i=sr(e,t,n);break;case"!=":i=ar(e,t,n);break;case">":i=nr(e,t,n);break;case">=":i=or(e,t,n);break;case"<":i=ir(e,t,n);break;case"<=":i=fr(e,t,n);break;default:throw new TypeError("Invalid operator: "+r)}return i}e.Comparator=cr;function cr(e,r){if(e instanceof cr){if(e.loose===r)return e;else e=e.value}if(!(this instanceof cr))return new cr(e,r);this.loose=r;this.parse(e);if(this.semver===lr)this.value="";else this.value=this.operator+this.semver.version}var lr={};cr.prototype.parse=function(e){var t=this.loose?r[Z]:r[q];var n=e.match(t);if(!n)throw new TypeError("Invalid comparator: "+e);this.operator=n[1];if(this.operator==="=")this.operator="";if(!n[2])this.semver=lr;else{this.semver=new H(n[2],this.loose);if(this.operator==="<"&&!this.semver.prerelease.length){this.semver.prerelease=["0"];this.semver.format()}}};cr.prototype.inspect=function(){return'<SemVer Comparator "'+this+'">'};cr.prototype.toString=function(){return this.value};cr.prototype.test=function(e){return this.semver===lr?true:ur(e,this.operator,this.semver,this.loose)};e.Range=pr;function pr(e,r){if(e instanceof pr&&e.loose===r)return e;if(!(this instanceof pr))return new pr(e,r);this.loose=r;this.raw=e;this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length});if(!this.set.length){throw new TypeError("Invalid SemVer Range: "+e)}this.format()}pr.prototype.inspect=function(){return'<SemVer Range "'+this.range+'">'};pr.prototype.format=function(){this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim();return this.range};pr.prototype.toString=function(){return this.range};pr.prototype.parseRange=function(e){var t=this.loose;e=e.trim();var n=t?r[N]:r[_];e=e.replace(n,kr);e=e.replace(r[L],X);e=e.replace(r[S],V);e=e.replace(r[C],M);e=e.split(/\s+/).join(" ");var i=t?r[Z]:r[q];var s=e.split(" ").map(function(e){return vr(e,t)}).join(" ").split(/\s+/);if(this.loose){s=s.filter(function(e){return!!e.match(i)})}s=s.map(function(e){return new cr(e,t)});return s};e.toComparators=hr;function hr(e,r){return new pr(e,r).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})}function vr(e,r){e=dr(e,r);e=gr(e,r);e=br(e,r);e=jr(e,r);return e}function mr(e){return!e||e.toLowerCase()==="x"||e==="*"}function gr(e,r){return e.trim().split(/\s+/).map(function(e){return wr(e,r)}).join(" ")}function wr(e,t){var n=t?r[T]:r[I];return e.replace(n,function(e,r,t,n,i){var s;if(mr(r))s="";else if(mr(t))s=">="+r+".0.0-0 <"+(+r+1)+".0.0-0";else if(mr(n))s=">="+r+"."+t+".0-0 <"+r+"."+(+t+1)+".0-0";else if(i){if(i.charAt(0)!=="-")i="-"+i;s=">="+r+"."+t+"."+n+i+" <"+r+"."+(+t+1)+".0-0"}else s=">="+r+"."+t+"."+n+"-0"+" <"+r+"."+(+t+1)+".0-0";return s})}function dr(e,r){return e.trim().split(/\s+/).map(function(e){return yr(e,r)}).join(" ")}function yr(e,t){var n=t?r[P]:r[z];return e.replace(n,function(e,r,t,n,i){var s;if(i){if(i.charAt(0)!=="-")i="-"+i}else i="";if(mr(r))s="";else if(mr(t))s=">="+r+".0.0-0 <"+(+r+1)+".0.0-0";else if(mr(n)){if(r==="0")s=">="+r+"."+t+".0-0 <"+r+"."+(+t+1)+".0-0";else s=">="+r+"."+t+".0-0 <"+(+r+1)+".0.0-0"}else if(r==="0")s="="+r+"."+t+"."+n+i;else if(i)s=">="+r+"."+t+"."+n+i+" <"+(+r+1)+".0.0-0";else s=">="+r+"."+t+"."+n+"-0"+" <"+(+r+1)+".0.0-0";return s})}function br(e,r){return e.split(/\s+/).map(function(e){return $r(e,r)}).join(" ")}function $r(e,t){e=e.trim();var n=t?r[x]:r[E];return e.replace(n,function(e,r,t,n,i,s){var a=mr(t);var o=a||mr(n);var f=o||mr(i);var u=f;if(r==="="&&u)r="";if(r&&u){if(a)t=0;if(o)n=0;if(f)i=0;if(r===">"){r=">=";if(a){}else if(o){t=+t+1;n=0;i=0}else if(f){n=+n+1;i=0}}e=r+t+"."+n+"."+i+"-0"}else if(a){e="*"}else if(o){e=">="+t+".0.0-0 <"+(+t+1)+".0.0-0"}else if(f){e=">="+t+"."+n+".0-0 <"+t+"."+(+n+1)+".0-0"}return e})}function jr(e,t){return e.trim().replace(r[O],"")}function kr(e,r,t,n,i,s,a,o,f,u,c,l,p){if(mr(t))r="";else if(mr(n))r=">="+t+".0.0-0";else if(mr(i))r=">="+t+"."+n+".0-0";else r=">="+r;if(mr(f))o="";else if(mr(u))o="<"+(+f+1)+".0.0-0";else if(mr(c))o="<"+f+"."+(+u+1)+".0-0";else if(l)o="<="+f+"."+u+"."+c+"-"+l;else o="<="+o;return(r+" "+o).trim()}pr.prototype.test=function(e){if(!e)return false;for(var r=0;r<this.set.length;r++){if(Er(this.set[r],e))return true}return false};function Er(e,r){for(var t=0;t<e.length;t++){if(!e[t].test(r))return false}return true}e.satisfies=xr;function xr(e,r,t){try{r=new pr(r,t)}catch(n){return false}return r.test(e)}e.maxSatisfying=Rr;function Rr(e,r,t){return e.filter(function(e){return xr(e,r,t)}).sort(function(e,r){return er(e,r,t)})[0]||null}e.validRange=Sr;function Sr(e,r){try{return new pr(e,r).range||"*"}catch(t){return null}}e.ltr=Vr;function Vr(e,r,t){return Tr(e,r,"<",t)}e.gtr=Ir;function Ir(e,r,t){return Tr(e,r,">",t)}e.outside=Tr;function Tr(e,r,t,n){e=new H(e,n);r=new pr(r,n);var i,s,a,o,f;switch(t){case">":i=nr;s=fr;a=ir;o=">";f=">=";break;case"<":i=ir;s=or;a=nr;o="<";f="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(xr(e,r,n)){return false}for(var u=0;u<r.set.length;++u){var c=r.set[u];var l=null;var p=null;c.forEach(function(e){l=l||e;p=p||e;if(i(e.semver,l.semver,n)){l=e}else if(a(e.semver,p.semver,n)){p=e}});if(l.operator===o||l.operator===f){return false}if((!p.operator||p.operator===o)&&s(e,p.semver)){return false}else if(p.operator===f&&a(e,p.semver)){return false}}return true}if(typeof define==="function"&&define.amd)define(e)})(typeof exports==="object"?exports:typeof define==="function"&&define.amd?{}:semver={});
\ No newline at end of file diff --git a/node_modules/semver/semver.min.js.gz b/node_modules/semver/semver.min.js.gz Binary files differindex cc05248ff..531c38183 100644 --- a/node_modules/semver/semver.min.js.gz +++ b/node_modules/semver/semver.min.js.gz diff --git a/node_modules/semver/test/index.js b/node_modules/semver/test/index.js index 6285b693f..abd9713d0 100644 --- a/node_modules/semver/test/index.js +++ b/node_modules/semver/test/index.js @@ -1,3 +1,5 @@ +'use strict'; + var tap = require('tap'); var test = tap.test; var semver = require('../semver.js'); @@ -327,10 +329,12 @@ test('\nincrement versions test', function(t) { ['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'], ['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'], ['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta'], + ['1.2.0', 'prepatch', '1.2.1-0'], + ['1.2.0-1', 'prepatch', '1.2.1-0'], ['1.2.0', 'preminor', '1.3.0-0'], + ['1.2.0-1', 'preminor', '1.3.0-0'], ['1.2.0', 'premajor', '2.0.0-0'], - ['1.2.0', 'preminor', '1.3.0-0'], - ['1.2.0', 'premajor', '2.0.0-0'] + ['1.2.0-1', 'premajor', '2.0.0-0'] ].forEach(function(v) { @@ -404,9 +408,9 @@ test('\nvalid range test', function(t) { ['^0.1', '>=0.1.0-0 <0.2.0-0'], ['^1.0', '>=1.0.0-0 <2.0.0-0'], ['^1.2', '>=1.2.0-0 <2.0.0-0'], - ['^0.0.1', '=0.0.1'], - ['^0.0.1-beta', '=0.0.1-beta'], - ['^0.1.2', '>=0.1.2-0 <0.2.0-0'], + ['^0.0.1', '0.0.1'], + ['^0.0.1-beta', '0.0.1-beta'], + ['^0.1.2', '0.1.2'], ['^1.2.3', '>=1.2.3-0 <2.0.0-0'], ['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0-0'], ['<1', '<1.0.0-0'], diff --git a/node_modules/semver/test/ltr.js b/node_modules/semver/test/ltr.js index a4f503a3c..d1461371b 100644 --- a/node_modules/semver/test/ltr.js +++ b/node_modules/semver/test/ltr.js @@ -162,7 +162,8 @@ test('\nnegative ltr tests', function(t) { ['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'], ['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true], ['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true], - ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'] + ['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'], + ['=0.1.0', '1.0.0'] ].forEach(function(tuple) { var range = tuple[0]; var version = tuple[1]; diff --git a/package.json b/package.json index a1c98d171..a7911243f 100644 --- a/package.json +++ b/package.json @@ -62,26 +62,27 @@ "lru-cache": "~2.5.0", "minimatch": "~0.3.0", "mkdirp": "~0.5.0", - "node-gyp": "~0.13.0", + "node-gyp": "~0.13.1", "nopt": "~3.0.1", + "normalize-package-data": "~0.4.2", "npm-cache-filename": "~1.0.1", "npm-install-checks": "~1.0.2", - "npm-package-arg": "~2.0.1", + "npm-package-arg": "~2.0.2", "npm-registry-client": "~3.0.2", "npm-user-validate": "~0.1.0", - "npmconf": "~2.0.3", + "npmconf": "~2.0.4", "npmlog": "~0.1.1", "once": "~1.3.0", "opener": "~1.3.0", "osenv": "~0.1.0", "path-is-inside": "~1.0.0", "read": "~1.0.4", - "read-installed": "~2.0.5", - "read-package-json": "~1.2.3", + "read-installed": "~2.0.7", + "read-package-json": "~1.2.4", "request": "~2.30.0", "retry": "~0.6.0", "rimraf": "~2.2.8", - "semver": "~2.3.0", + "semver": "~3.0.0", "sha": "~1.2.1", "slide": "~1.1.5", "sorted-object": "~1.0.0", @@ -155,7 +156,7 @@ "npm-registry-couchapp": "~2.4.3", "npm-registry-mock": "~0.6.3", "ronn": "~0.3.6", - "tap": "~0.4.9" + "tap": "~0.4.12" }, "engines": { "node": ">=0.8", |