Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2014-08-29 09:16:05 +0400
committerForrest L Norvell <forrest@npmjs.com>2014-08-29 09:16:05 +0400
commitbf247edf5429c6b3ec4d4cb798fa0eb0a9c19fc1 (patch)
treedad6102c4ea3a8bec8d629222f7bec92b54f9a4d /node_modules/columnify
parent4bbe682a6d4eabcd23f892932308c9f228bf4de3 (diff)
columnify@1.2.1
Diffstat (limited to 'node_modules/columnify')
-rw-r--r--node_modules/columnify/Readme.md25
-rw-r--r--node_modules/columnify/index.js26
-rwxr-xr-xnode_modules/columnify/node_modules/strip-ansi/cli.js26
-rw-r--r--node_modules/columnify/node_modules/strip-ansi/index.js4
-rw-r--r--node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/index.js4
-rw-r--r--node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/package.json78
-rw-r--r--node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/readme.md33
-rw-r--r--node_modules/columnify/node_modules/strip-ansi/package.json30
-rw-r--r--node_modules/columnify/node_modules/strip-ansi/readme.md25
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/INSTALL.md12
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/NEWS9
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/README.md65
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.editorconfig14
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.travis.yml8
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CNAME1
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CONTRIBUTING.md11
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/LICENSE23
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/README.md22
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/bower.json7
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/component.json10
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/docco.css506
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/favicon.icobin1406 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/background.pngbin2108 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/underscore.pngbin8634 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.eotbin29804 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.ttfbin66836 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.woffbin33244 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.eotbin29509 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.ttfbin68620 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.woffbin33124 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.eotbin18190 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.ttfbin48136 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.woffbin20576 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/stylesheets/normalize.css375
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/underscore.html3261
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/favicon.icobin1406 -> 0 bytes
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/index.html2777
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/package.json53
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/arrays.js323
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/chaining.js65
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/collections.js676
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/functions.js535
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/index.html26
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/objects.js665
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/utility.js294
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.css244
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.js2212
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/runner.js127
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore-min.js6
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore-min.map1
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore.js1412
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/package.json60
-rw-r--r--node_modules/columnify/node_modules/wcwidth.js/wcwidth.js262
-rw-r--r--node_modules/columnify/node_modules/wcwidth/.npmignore (renamed from node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.gitignore)1
-rw-r--r--node_modules/columnify/node_modules/wcwidth/LICENSE (renamed from node_modules/columnify/node_modules/wcwidth.js/LICENSE.md)1
-rw-r--r--node_modules/columnify/node_modules/wcwidth/Readme.md33
-rw-r--r--node_modules/columnify/node_modules/wcwidth/combining.js50
-rw-r--r--node_modules/columnify/node_modules/wcwidth/docs/index.md65
-rw-r--r--node_modules/columnify/node_modules/wcwidth/index.js99
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/.npmignore1
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/README.md43
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/index.js13
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/.npmignore1
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/.travis.yml5
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/LICENSE18
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/README.md126
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/clone.js129
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/package.json121
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/test.js271
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/package.json50
-rw-r--r--node_modules/columnify/node_modules/wcwidth/node_modules/defaults/test.js34
-rw-r--r--node_modules/columnify/node_modules/wcwidth/package.json60
-rw-r--r--node_modules/columnify/node_modules/wcwidth/test/index.js64
-rw-r--r--node_modules/columnify/package.json23
-rw-r--r--node_modules/columnify/utils.js42
-rw-r--r--node_modules/columnify/width.js2
76 files changed, 1438 insertions, 14127 deletions
diff --git a/node_modules/columnify/Readme.md b/node_modules/columnify/Readme.md
index a20739b65..43ae36c2c 100644
--- a/node_modules/columnify/Readme.md
+++ b/node_modules/columnify/Readme.md
@@ -191,7 +191,7 @@ module2 0.2.0
## Other Configuration Options
-### Align Right
+### Align Right/Center
```js
var data = {
@@ -211,6 +211,27 @@ commander@2.0.0 1
debug@0.8.1 1
```
+Align Center works in a similar way.
+
+
+### Padding
+
+```js
+var data = {
+ "shortKey": "veryVeryVeryVeryVeryLongVal",
+ "veryVeryVeryVeryVeryLongKey": "shortVal"
+}
+
+columnify(data, { paddingChr: '.'})
+```
+
+#### Output:
+```
+KEY........................ VALUE......................
+shortKey................... veryVeryVeryVeryVeryLongVal
+veryVeryVeryVeryVeryLongKey shortVal...................
+```
+
### Preserve existing newlines
By default, `columnify` sanitises text by replacing any occurance of 1 or more whitespace characters with a single space.
@@ -344,5 +365,3 @@ module-one some description 0.0.1
## License
MIT
-
-
diff --git a/node_modules/columnify/index.js b/node_modules/columnify/index.js
index 63257dcec..c44b8ca8f 100644
--- a/node_modules/columnify/index.js
+++ b/node_modules/columnify/index.js
@@ -3,6 +3,7 @@
var wcwidth = require('./width')
var utils = require('./utils')
var padRight = utils.padRight
+var padCenter = utils.padCenter
var padLeft = utils.padLeft
var splitIntoLines = utils.splitIntoLines
var splitLongWords = utils.splitLongWords
@@ -15,6 +16,8 @@ var DEFAULTS = {
truncate: false,
truncateMarker: '…',
preserveNewLines: false,
+ paddingChr: ' ',
+ showHeaders: true,
headingTransform: function(key) {
return key.toUpperCase()
},
@@ -40,6 +43,7 @@ module.exports = function(items, options) {
options.spacing = options.spacing || '\n' // probably useless
options.preserveNewLines = !!options.preserveNewLines
+ options.showHeaders = !!options.showHeaders;
options.columns = options.columns || options.include // alias include/columns, prefer columns if supplied
var columnNames = options.columns || [] // optional user-supplied columns to include
@@ -99,12 +103,13 @@ module.exports = function(items, options) {
// add headers
var headers = {}
- columnNames.forEach(function(columnName) {
- var column = columns[columnName]
- headers[columnName] = column.headingTransform(columnName)
- })
- items.unshift(headers)
-
+ if(options.showHeaders) {
+ columnNames.forEach(function(columnName) {
+ var column = columns[columnName]
+ headers[columnName] = column.headingTransform(columnName)
+ })
+ items.unshift(headers)
+ }
// get actual max-width between min & max
// based on length of data in columns
columnNames.forEach(function(columnName) {
@@ -156,7 +161,7 @@ module.exports = function(items, options) {
})
- var rows = createRows(items, columns, columnNames) // merge lines into rows
+ var rows = createRows(items, columns, columnNames, options.paddingChr) // merge lines into rows
// conceive output
return rows.reduce(function(output, row) {
return output.concat(row.reduce(function(rowOut, line) {
@@ -176,7 +181,7 @@ module.exports = function(items, options) {
* @return Array items wrapped in arrays, corresponding to lines
*/
-function createRows(items, columns, columnNames) {
+function createRows(items, columns, columnNames, paddingChr) {
return items.map(function(item) {
var row = []
var numLines = 0
@@ -189,8 +194,9 @@ function createRows(items, columns, columnNames) {
columnNames.forEach(function(columnName) {
var column = columns[columnName]
var val = item[columnName][i] || '' // || '' ensures empty columns get padded
- if (column.align == 'right') row[i].push(padLeft(val, column.width))
- else row[i].push(padRight(val, column.width))
+ if (column.align == 'right') row[i].push(padLeft(val, column.width, paddingChr))
+ else if (column.align == 'center') row[i].push(padCenter(val, column.width, paddingChr))
+ else row[i].push(padRight(val, column.width, paddingChr))
})
}
return row
diff --git a/node_modules/columnify/node_modules/strip-ansi/cli.js b/node_modules/columnify/node_modules/strip-ansi/cli.js
index f8019cdae..602ae00e8 100755
--- a/node_modules/columnify/node_modules/strip-ansi/cli.js
+++ b/node_modules/columnify/node_modules/strip-ansi/cli.js
@@ -1,18 +1,30 @@
#!/usr/bin/env node
'use strict';
var fs = require('fs');
-var strip = require('./index');
+var pkg = require('./package.json');
+var strip = require('./');
var input = process.argv[2];
-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>');
+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();
return;
}
-if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
- console.log(require('./package').version);
+if (process.argv.indexOf('--version') !== -1) {
+ console.log(pkg.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 9ce2f3d48..099480fbf 100644
--- a/node_modules/columnify/node_modules/strip-ansi/index.js
+++ b/node_modules/columnify/node_modules/strip-ansi/index.js
@@ -1,4 +1,6 @@
'use strict';
+var ansiRegex = require('ansi-regex')();
+
module.exports = function (str) {
- return typeof str === 'string' ? str.replace(/\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[m|K]/g, '') : str;
+ return typeof str === 'string' ? str.replace(ansiRegex, '') : 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
new file mode 100644
index 000000000..783c5c7bb
--- /dev/null
+++ b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/index.js
@@ -0,0 +1,4 @@
+'use strict';
+module.exports = function () {
+ return /\u001b\[(?:[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
new file mode 100644
index 000000000..ca610250c
--- /dev/null
+++ b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/package.json
@@ -0,0 +1,78 @@
+{
+ "name": "ansi-regex",
+ "version": "0.2.1",
+ "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",
+ "match",
+ "test",
+ "find",
+ "pattern"
+ ],
+ "devDependencies": {
+ "mocha": "*"
+ },
+ "bugs": {
+ "url": "https://github.com/sindresorhus/ansi-regex/issues"
+ },
+ "homepage": "https://github.com/sindresorhus/ansi-regex",
+ "_id": "ansi-regex@0.2.1",
+ "_shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
+ "_from": "ansi-regex@0.2.1",
+ "_npmVersion": "1.4.9",
+ "_npmUser": {
+ "name": "sindresorhus",
+ "email": "sindresorhus@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "sindresorhus",
+ "email": "sindresorhus@gmail.com"
+ }
+ ],
+ "dist": {
+ "shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
+ "tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz"
+}
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
new file mode 100644
index 000000000..ae876e729
--- /dev/null
+++ b/node_modules/columnify/node_modules/strip-ansi/node_modules/ansi-regex/readme.md
@@ -0,0 +1,33 @@
+# 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('\u001b[4mcake\u001b[0m');
+//=> true
+
+ansiRegex().test('cake');
+//=> false
+
+'\u001b[4mcake\u001b[0m'.match(ansiRegex());
+//=> ['\u001b[4m', '\u001b[0m']
+```
+
+*It's a function so you can create multiple instances. Regexes with the global flag will have the `.lastIndex` property changed for each call to methods on the instance. Therefore reusing the instance with multiple calls will not work as expected for `.test()`.*
+
+
+## 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 e0c5bc43f..64c4dee52 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.1",
- "description": "Strip ANSI escape codes (used for colorizing strings in the terminal)",
+ "version": "1.0.0",
+ "description": "Strip ANSI escape codes",
"license": "MIT",
"bin": {
"strip-ansi": "cli.js"
@@ -50,20 +50,21 @@
"command-line",
"text"
],
+ "dependencies": {
+ "ansi-regex": "^0.2.1"
+ },
"devDependencies": {
"mocha": "*"
},
+ "gitHead": "6fea2ef935f1ba10d43e4c4d9814af328803935c",
"bugs": {
"url": "https://github.com/sindresorhus/strip-ansi/issues"
},
"homepage": "https://github.com/sindresorhus/strip-ansi",
- "_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",
+ "_id": "strip-ansi@1.0.0",
+ "_shasum": "6c021321d6ece161a3c608fbab268c7328901c73",
+ "_from": "strip-ansi@>=1.0.0-0 <2.0.0-0",
+ "_npmVersion": "1.4.14",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
@@ -72,9 +73,16 @@
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
+ },
+ {
+ "name": "jbnicolai",
+ "email": "jappelman@xebia.com"
}
],
+ "dist": {
+ "shasum": "6c021321d6ece161a3c608fbab268c7328901c73",
+ "tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-1.0.0.tgz"
+ },
"directories": {},
- "_shasum": "09218505ccf1083a41460150571355efabaa126e",
- "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.2.1.tgz"
+ "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-1.0.0.tgz"
}
diff --git a/node_modules/columnify/node_modules/strip-ansi/readme.md b/node_modules/columnify/node_modules/strip-ansi/readme.md
index c6a0634fa..5477079d0 100644
--- a/node_modules/columnify/node_modules/strip-ansi/readme.md
+++ b/node_modules/columnify/node_modules/strip-ansi/readme.md
@@ -1,13 +1,11 @@
# 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#Colors_and_Styles) (used for colorizing strings in the terminal)
-
-Used in the terminal color module [chalk](https://github.com/sindresorhus/chalk).
+> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
-```bash
+```sh
$ npm install --save strip-ansi
```
@@ -24,23 +22,22 @@ stripAnsi('\x1b[4mcake\x1b[0m');
## CLI
-You can also use it as a CLI app by installing it globally:
-
-```bash
+```sh
$ npm install --global strip-ansi
```
-#### Usage
-
-```bash
+```sh
$ strip-ansi --help
-strip-ansi <input-file>
-or
-cat <input-file> | strip-ansi
+Usage
+ $ strip-ansi <input-file> > <output-file>
+ $ cat <input-file> | strip-ansi > <output-file>
+
+Example
+ $ strip-ansi unicorn.txt > unicorn-stripped.txt
```
## License
-[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com)
+MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/node_modules/columnify/node_modules/wcwidth.js/INSTALL.md b/node_modules/columnify/node_modules/wcwidth.js/INSTALL.md
deleted file mode 100644
index e4eafaff7..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/INSTALL.md
+++ /dev/null
@@ -1,12 +0,0 @@
-How To Build and Install wcwidth.js
-===================================
-
-This package does not provide an automated way to build or install the library
-except using [`npm`](http://npmjs.org/package/wcwidth.js) because wcwidth.js is
-intended to runs on top of [`node.js`](http://nodejs.org) that is a javascript
-interpreter. If you have `node.js` installed,
-
- npm install wcwidth.js
-
-brings the latest version of `wcwidth.js` and installs it with its all
-depending packages.
diff --git a/node_modules/columnify/node_modules/wcwidth.js/NEWS b/node_modules/columnify/node_modules/wcwidth.js/NEWS
deleted file mode 100644
index cf80fbc1c..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/NEWS
+++ /dev/null
@@ -1,9 +0,0 @@
-What's New in wcwidth.js?
-=========================
-
-2014-04-26 0.0.4 released.
-2012-12-13 0.0.3 released.
-2012-12-12 Moved the repository to git/github.
-2012-10-16 0.0.2 released.
-2012-10-16 Using `wcwidth' without invoking it checked.
-2012-10-12 First release.
diff --git a/node_modules/columnify/node_modules/wcwidth.js/README.md b/node_modules/columnify/node_modules/wcwidth.js/README.md
deleted file mode 100644
index 6c562cff5..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/README.md
+++ /dev/null
@@ -1,65 +0,0 @@
-wcwidth.js: A JavaScript Porting of Markus Kuhn's wcwidth() Implementation
-==========================================================================
-
-`wcwidth.js` is a simple JavaScript porting of `wcwidth()` implemented in C
-[by Markus Kuhn](http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c).
-
-`wcwidth()` and its string version, `wcswidth()` are defined by IEEE Std
-1002.1-2001, a.k.a. POSIX.1-2001, and return the number of columns used to
-represent the given wide character and string. Markus's implementation assumes
-the wide character given to those functions to be encoded in ISO 10646, which
-is almost true for JavaScript's characters.
-
-For convenience, `wcwidth.js` sets the getter of the property named `wcwidth`
-for the string type. You don't need to invoke a function to get the width of
-strings, but inspecting the `wcwidth` property is enough. The following code
-snippet shows how to use `wcwidth.js`:
-
- var wcwidth = require('wcwidth')({
- nul: 0,
- control: -1,
- monkeypatch: true
- }); // equivalent to var wcwidth = require('wcwidth')();
-
- console.log("한글".wcwidth); // prints 4
- console.log("\0".wcwidth); // prints 0
- console.log("\t".wcwidth); // prints -1
-
-The argument `{ nul: 0, control: -1, monkeypatch: true }` (which are the
-default values, in fact) tells `wcwidth.js` to return 0 for the NUL character
-and -1 for non-printable control characters. Setting a negative value to `nul`
-or `control` makes the `wcwidth` property set to -1 for any string that
-contains NUL or control characters respectively. If you plan to replace each
-control character with, say, `???` when printing, you can 'require'
-`wcwidth.js` as follows:
-
- var wcwidth = require('wcwidth')({
- control: 3
- }); // leaving nul as 0
-
- console.log("\t".wcwidth); // prints 3
- console.log("\0".wcwidth); // prints 0
-
-The last option `monkeypatch` allows `wcwidth.js` to monkey-patch
-`String.prototype` to provide the getter `wcwidth`. Even if it is convenient to
-have a getter that looks like the native one, it is sometimes unwanted as
-adding a getter into `String.prototype` may break node.js's module system; you
-are not guaranteed to have the version your code `require`s through the getter
-if other modules you're using also depend on other versions of `wcwidth.js`
-(thanks to [timoxley](https://github.com/timoxley) for the information). By
-setting `monkeypatch` to `false`, `wcwidth.js` touches no global object and
-provides no getter but a callable method explained below.
-
-`wcwidth.js` also provides a method. Since JavaScript has no character type,
-it is meaningless to have two versions while POSIX does for C. The method also
-accepts a code value that can be obtained by the `charCodeAt()` method.
-
- console.log(wcwidth('한')); // prints 2
- console.log(wcwidth('글'.charCodeAt(0)); // prints 2
- console.log(wcwidth('한글')); // prints 4
-
-`INSTALL.md` explains how to build and install the library. For the copyright
-issues, see the accompanying `LICENSE.md` file.
-
-If you have a question or suggestion, do not hesitate to contact me via email
-(woong.jun at gmail.com) or web (http://code.woong.org/).
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
deleted file mode 100644
index 8e920719d..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.editorconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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/.travis.yml b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.travis.yml
deleted file mode 100644
index dbf89b3a4..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.travis.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-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
deleted file mode 100644
index a007e65c4..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CNAME
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644
index 8b22557d1..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/CONTRIBUTING.md
+++ /dev/null
@@ -1,11 +0,0 @@
-## 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/LICENSE b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/LICENSE
deleted file mode 100644
index 0d6b8739d..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/LICENSE
+++ /dev/null
@@ -1,23 +0,0 @@
-Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative
-Reporters & Editors
-
-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/columnify/node_modules/wcwidth.js/node_modules/underscore/README.md b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/README.md
deleted file mode 100644
index c2ba2590c..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
- __
- /\ \ __
- __ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
- /\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
- \ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
- \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
- \/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
- \ \____/
- \/___/
-
-Underscore.js is a utility-belt library for JavaScript that provides
-support for the usual functional suspects (each, map, reduce, filter...)
-without extending any core JavaScript objects.
-
-For Docs, License, Tests, and pre-packed downloads, see:
-http://underscorejs.org
-
-Underscore is an open-sourced component of DocumentCloud:
-https://github.com/documentcloud
-
-Many thanks to our contributors:
-https://github.com/jashkenas/underscore/contributors
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
deleted file mode 100644
index 2d3e0291c..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/bower.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "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
deleted file mode 100644
index bb1775e70..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/component.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "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
deleted file mode 100644
index a2899ac87..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/docco.css
+++ /dev/null
@@ -1,506 +0,0 @@
-/*--------------------- 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
deleted file mode 100644
index 030496838..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/favicon.ico
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 90ee6934d..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/background.png
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 3449cbe2a..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/images/underscore.png
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 1b32532a8..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.eot
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index dc4cc9c27..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.ttf
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index fa16fd0ab..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-bold.woff
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 40bd654b5..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.eot
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index c2c72902a..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.ttf
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 81a09d18e..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/aller-light.woff
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 98a9a7fba..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.eot
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 2af39b08b..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.ttf
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index de558b5a2..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/fonts/novecento-bold.woff
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 73abb76fa..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/public/stylesheets/normalize.css
+++ /dev/null
@@ -1,375 +0,0 @@
-/*! 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
deleted file mode 100644
index 014d5dece..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/docs/underscore.html
+++ /dev/null
@@ -1,3261 +0,0 @@
-<!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">&#182;</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 &amp; 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">&#182;</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">&#182;</a>
- </div>
-
- </div>
-
- </li>
-
-
- <li id="section-4">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-4">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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> &amp;&amp; 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">&#182;</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">&#182;</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">&#182;</a>
- </div>
-
- </div>
-
- </li>
-
-
- <li id="section-15">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-15">&#182;</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 &amp;&amp; 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 &lt; 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 &lt; 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">&#182;</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 &amp;&amp; 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">&#182;</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 &gt; <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 &amp;&amp; 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">&#182;</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 &gt; <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 &amp;&amp; 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">&#182;</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">&#182;</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 &amp;&amp; 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">&#182;</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">&#182;</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 &amp;&amp; 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 &amp;&amp; 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">&#182;</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 &amp;&amp; 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">&#182;</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 &amp;&amp; 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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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 &amp;&amp; _.isArray(obj) &amp;&amp; obj[<span class="hljs-number">0</span>] === +obj[<span class="hljs-number">0</span>] &amp;&amp; obj.length &lt; <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 &gt; 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">&#182;</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 &amp;&amp; _.isArray(obj) &amp;&amp; obj[<span class="hljs-number">0</span>] === +obj[<span class="hljs-number">0</span>] &amp;&amp; obj.length &lt; <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 &lt; 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">&#182;</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">&#182;</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">&#182;</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">&#182;</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 &gt; 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 &lt; 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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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 &lt; high) {
- <span class="hljs-keyword">var</span> mid = (low + high) &gt;&gt;&gt; <span class="hljs-number">1</span>;
- iterator.call(context, array[mid]) &lt; 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">&#182;</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">&#182;</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">&#182;</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">&#182;</a>
- </div>
-
- </div>
-
- </li>
-
-
- <li id="section-44">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-44">&#182;</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 &lt; <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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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 &amp;&amp; _.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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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 &lt; 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">&#182;</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 &lt; 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">&#182;</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 &lt; <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 &amp;&amp; array.indexOf === nativeIndexOf) <span class="hljs-keyword">return</span> array.indexOf(item, isSorted);
- <span class="hljs-keyword">for</span> (; i &lt; 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">&#182;</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 &amp;&amp; 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">&#182;</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 &lt;= <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 &lt; 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">&#182;</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">&#182;</a>
- </div>
-
- </div>
-
- </li>
-
-
- <li id="section-64">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-64">&#182;</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">&#182;</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 &amp;&amp; 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">&#182;</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 &lt; 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 &lt; <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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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 &amp;&amp; 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 &lt;= <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 &amp;&amp; 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">&#182;</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 &lt; 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 &amp;&amp; !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">&#182;</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">&#182;</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">&#182;</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 &gt;= <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">&#182;</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 &lt; <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">&#182;</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">&#182;</a>
- </div>
-
- </div>
-
- </li>
-
-
- <li id="section-79">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-79">&#182;</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">&#182;</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 &lt; 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">&#182;</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 &lt; 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">&#182;</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 &lt; 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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</a>
- </div>
- <p>Primitives and their corresponding object wrappers are equivalent; thus, <code>&quot;5&quot;</code> is
-equivalent to <code>new String(&quot;5&quot;)</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">&#182;</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">&#182;</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">&#182;</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 &amp;&amp;
- a.global == b.global &amp;&amp;
- a.multiline == b.multiline &amp;&amp;
- 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">&#182;</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">&#182;</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">&#182;</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 &amp;&amp; !(_.isFunction(aCtor) &amp;&amp; (aCtor <span class="hljs-keyword">instanceof</span> aCtor) &amp;&amp;
- _.isFunction(bCtor) &amp;&amp; (bCtor <span class="hljs-keyword">instanceof</span> bCtor))
- &amp;&amp; (<span class="hljs-string">'constructor'</span> <span class="hljs-keyword">in</span> a &amp;&amp; <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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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) &amp;&amp; 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">&#182;</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) &amp;&amp; !(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">&#182;</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">&#182;</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">&#182;</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">&#182;</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 &amp;&amp; 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">&#182;</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">&#182;</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">&#182;</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">&#182;</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 &amp;&amp; _.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">&#182;</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">&#182;</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) &amp;&amp; !<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">&#182;</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) &amp;&amp; obj != +obj;
- };</pre></div></div>
-
- </li>
-
-
- <li id="section-122">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-122">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</a>
- </div>
-
- </div>
-
- </li>
-
-
- <li id="section-128">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-128">&#182;</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">&#182;</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">&#182;</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">&#182;</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 &lt; 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">&#182;</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">&#182;</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">&#182;</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">'&amp;'</span>: <span class="hljs-string">'&amp;amp;'</span>,
- <span class="hljs-string">'&lt;'</span>: <span class="hljs-string">'&amp;lt;'</span>,
- <span class="hljs-string">'&gt;'</span>: <span class="hljs-string">'&amp;gt;'</span>,
- <span class="hljs-string">'"'</span>: <span class="hljs-string">'&amp;quot;'</span>,
- <span class="hljs-string">"'"</span>: <span class="hljs-string">'&amp;#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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">/&lt;%([\s\S]+?)%&gt;/g</span>,
- interpolate : <span class="hljs-regexp">/&lt;%=([\s\S]+?)%&gt;/g</span>,
- <span class="hljs-built_in">escape</span> : <span class="hljs-regexp">/&lt;%-([\s\S]+?)%&gt;/g</span>
- };</pre></div></div>
-
- </li>
-
-
- <li id="section-141">
- <div class="annotation">
-
- <div class="pilwrap ">
- <a class="pilcrow" href="#section-141">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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">&#182;</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>) &amp;&amp; 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">&#182;</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">&#182;</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">&#182;</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">&#182;</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> &amp;&amp; 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
deleted file mode 100644
index 030496838..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/favicon.ico
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 785750f3e..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/index.html
+++ /dev/null
@@ -1,2777 +0,0 @@
-<!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>&raquo; <a href="https://github.com/jashkenas/underscore">GitHub Repository</a></li>
- <li>&raquo; <a href="docs/underscore.html">Annotated Source</a></li>
- <li>&raquo; <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&rsquo;s the answer to the question: &ldquo;If I sit down in front of a
- blank HTML page, and want to start being productive immediately, what do I need?&rdquo;
- &hellip; 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> &mdash;
- as well as more specialized helpers: function binding, javascript
- templating, deep equality testing, and so on.
- </p>
-
- <p>
- A complete <a href="test/">Test &amp; 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>
- &nbsp;<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);
-=&gt; alerts each number in turn...
-_.each({one: 1, two: 2, three: 3}, alert);
-=&gt; 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; });
-=&gt; [3, 6, 9]
-_.map({one: 1, two: 2, three: 3}, function(num, key){ return num * 3; });
-=&gt; [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);
-=&gt; 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); }, []);
-=&gt; [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; });
-=&gt; 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; });
-=&gt; [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});
-=&gt; [{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"});
-=&gt; {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; });
-=&gt; [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);
-=&gt; 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]);
-=&gt; 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);
-=&gt; 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');
-=&gt; [[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');
-=&gt; ["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; });
-=&gt; {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);
-=&gt; 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); });
-=&gt; [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); });
-=&gt; {1: [1.3], 2: [2.1, 2.4]}
-
-_.groupBy(['one', 'two', 'three'], 'length');
-=&gt; {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');
-=&gt; {
- "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';
-});
-=&gt; {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]);
-=&gt; [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]);
-=&gt; 4
-
-_.sample([1, 2, 3, 4, 5, 6], 3);
-=&gt; [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);
-=&gt; [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});
-=&gt; 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);
-=&gt; [[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]);
-=&gt; 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]);
-=&gt; [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]);
-=&gt; 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]);
-=&gt; [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]);
-=&gt; [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]]]]);
-=&gt; [1, 2, 3, 4];
-
-_.flatten([1, [2], [3, [[4]]]], true);
-=&gt; [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);
-=&gt; [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]);
-=&gt; [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]);
-=&gt; [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]);
-=&gt; [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]);
-=&gt; [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]);
-=&gt; [["moe", 30, true], ["larry", 40, false], ["curly", 50, false]]
-
-_.zip.apply(_, arrayOfRowsOfData);
-=&gt; 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]);
-=&gt; {moe: 30, larry: 40, curly: 50}
-
-_.object([['moe', 30], ['larry', 40], ['curly', 50]]);
-=&gt; {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);
-=&gt; 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);
-=&gt; 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);
-=&gt; 3
-
-var stooges = [{name: 'moe', age: 40}, {name: 'curly', age: 60}];
-_.sortedIndex(stooges, {name: 'larry', age: 50}, 'age');
-=&gt; 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);
-=&gt; [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
-_.range(1, 11);
-=&gt; [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
-_.range(0, 30, 5);
-=&gt; [0, 5, 10, 15, 20, 25]
-_.range(0, -10, -1);
-=&gt; [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
-_.range(0);
-=&gt; []
-</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();
-=&gt; '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);
-=&gt; 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 &lt; 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');
-=&gt; '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();
-=&gt; '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);
-=&gt; 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');
-=&gt; '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});
-=&gt; ["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});
-=&gt; [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});
-=&gt; [["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"});
-=&gt; {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 &mdash;
- that is to say, the name of every function property of the object.
- </p>
- <pre>
-_.functions(_);
-=&gt; ["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});
-=&gt; {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');
-=&gt; {name: 'moe', age: 50}
-_.pick({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) {
- return _.isNumber(value);
-});
-=&gt; {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');
-=&gt; {name: 'moe', age: 50}
-_.omit({name: 'moe', age: 50, userid: 'moe1'}, function(value, key, object) {
- return _.isNumber(value);
-});
-=&gt; {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"});
-=&gt; {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'});
-=&gt; {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();
-=&gt; // [2, 200] (alerted)
-=&gt; [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");
-=&gt; 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);
-=&gt; 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;
-=&gt; false
-_.isEqual(moe, clone);
-=&gt; 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]);
-=&gt; false
-_.isEmpty({});
-=&gt; 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]);
-=&gt; 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); })();
-=&gt; false
-_.isArray([1,2,3]);
-=&gt; 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({});
-=&gt; true
-_.isObject(1);
-=&gt; 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);
-=&gt; true
-_.isArguments([1,2,3]);
-=&gt; 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);
-=&gt; 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");
-=&gt; 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);
-=&gt; 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);
-=&gt; true
-
-_.isFinite(-Infinity);
-=&gt; 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);
-=&gt; 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());
-=&gt; 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/);
-=&gt; 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);
-=&gt; true
-isNaN(undefined);
-=&gt; true
-_.isNaN(undefined);
-=&gt; 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);
-=&gt; true
-_.isNull(undefined);
-=&gt; 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);
-=&gt; 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);
-=&gt; 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)();
-=&gt; 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);
-=&gt; 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();
-=&gt; "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_');
-=&gt; '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>&amp;</tt>, <tt>&lt;</tt>, <tt>&gt;</tt>, <tt>&quot;</tt>, and <tt>&#x27;</tt> characters.
- </p>
- <pre>
-_.escape('Curly, Larry &amp; Moe');
-=&gt; "Curly, Larry &amp;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;amp;</tt>, <tt>&amp;lt;</tt>, <tt>&amp;gt;</tt>,
- <tt>&amp;quot;</tt>, and <tt>&amp;#x27;</tt>
- with their unescaped counterparts.
- </p>
- <pre>
-_.unescape('Curly, Larry &amp;amp; Moe');
-=&gt; "Curly, Larry &amp; 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');
-=&gt; "crumpets"
-_.result(object, 'stuff');
-=&gt; "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();
-=&gt; 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>&lt;%= &hellip; %&gt;</tt>, as well as execute arbitrary JavaScript code, with
- <tt>&lt;% &hellip; %&gt;</tt>. If you wish to interpolate a value, and have
- it be HTML-escaped, use <tt>&lt;%- &hellip; %&gt;</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: &lt;%= name %&gt;");
-compiled({name: 'moe'});
-=&gt; "hello: moe"
-
-var list = "&lt;% _.each(people, function(name) { %&gt; &lt;li&gt;&lt;%= name %&gt;&lt;/li&gt; &lt;% }); %&gt;";
-_.template(list, {people: ['moe', 'curly', 'larry']});
-=&gt; "&lt;li&gt;moe&lt;/li&gt;&lt;li&gt;curly&lt;/li&gt;&lt;li&gt;larry&lt;/li&gt;"
-
-var template = _.template("&lt;b&gt;&lt;%- value %&gt;&lt;/b&gt;");
-template({value: '&lt;script&gt;'});
-=&gt; "&lt;b&gt;&amp;lt;script&amp;gt;&lt;/b&gt;"</pre>
-
- <p>
- You can also use <tt>print</tt> from within JavaScript code. This is
- sometimes more convenient than using <tt>&lt;%= ... %&gt;</tt>.
- </p>
-
- <pre>
-var compiled = _.template("&lt;% print('Hello ' + epithet); %&gt;");
-compiled({epithet: "stooge"});
-=&gt; "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"});
-=&gt; "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'});
-=&gt; "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>&lt;script&gt;
- JST.project = <%= _.template(jstText).source %>;
-&lt;/script&gt;</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();
-
-=&gt; {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();
-=&gt; "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();
-=&gt; [1, 2, 3]
-</pre>
-
- <h2 id="links">Links &amp; 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> &mdash; <small><i>February 10, 2014</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.5.2...1.6.0">Diff</a> &mdash; <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 &mdash; 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>
- &hellip; and more miscellaneous refactoring.
- </li>
- </ul>
- </p>
-
- <p id="1.5.2">
- <b class="header">1.5.2</b> &mdash; <small><i>September 7, 2013</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.5.1...1.5.2">Diff</a> &mdash; <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> &mdash; <small><i>July 8, 2013</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.5.0...1.5.1">Diff</a> &mdash; <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> &mdash; <small><i>July 6, 2013</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.4...1.5.0">Diff</a> &mdash; <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> &mdash; <small><i>January 30, 2013</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.3...1.4.4">Diff</a> &mdash; <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> &mdash; <small><i>December 4, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.2...1.4.3">Diff</a> &mdash; <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> &mdash; <small><i>October 6, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.1...1.4.2">Diff</a> &mdash; <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> &mdash; <small><i>October 1, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.4.0...1.4.1">Diff</a> &mdash; <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> &mdash; <small><i>September 27, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.3.3...1.4.0">Diff</a> &mdash; <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 &mdash; please test when you upgrade.
- </li>
- </ul>
- </p>
-
- <p id="1.3.3">
- <b class="header">1.3.3</b> &mdash; <small><i>April 10, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.3.1...1.3.3">Diff</a> &mdash; <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 &mdash;
- 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> &mdash; <small><i>January 23, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.3.0...1.3.1">Diff</a> &mdash; <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> &mdash; <small><i>January 11, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.4...1.3.0">Diff</a> &mdash; <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> &mdash; <small><i>January 4, 2012</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.3...1.2.4">Diff</a> &mdash; <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> &mdash; <small><i>December 7, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.2...1.2.3">Diff</a> &mdash; <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> &mdash; <small><i>November 14, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.1...1.2.2">Diff</a> &mdash; <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>&lt;% }) %&gt;</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> &mdash; <small><i>October 24, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.2.0...1.2.1">Diff</a> &mdash; <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> &mdash; <small><i>October 5, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.7...1.2.0">Diff</a> &mdash; <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>&lt;%- ... %&gt;</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> &mdash; <small><i>July 13, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.6...1.1.7">Diff</a> &mdash; <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> &mdash; <small><i>April 18, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.5...1.1.6">Diff</a> &mdash; <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> &mdash; <small><i>March 20, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.4...1.1.5">Diff</a> &mdash; <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> &mdash; <small><i>January 9, 2011</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.3...1.1.4">Diff</a> &mdash; <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> &mdash; <small><i>December 1, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.2...1.1.3">Diff</a> &mdash; <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 &mdash; 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> &mdash; <small><i>October 15, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.1...1.1.2">Diff</a> &mdash; <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> &mdash; <small><i>October 5, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.1.0...1.1.1">Diff</a> &mdash; <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> &mdash; <small><i>August 18, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.4...1.1.0">Diff</a> &mdash; <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> &mdash; <small><i>June 22, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.3...1.0.4">Diff</a> &mdash; <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> &mdash; <small><i>June 14, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.2...1.0.3">Diff</a> &mdash; <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> &mdash; <small><i>March 23, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.1...1.0.2">Diff</a> &mdash; <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> &mdash; <small><i>March 19, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/1.0.0...1.0.1">Diff</a> &mdash; <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> &mdash; <small><i>March 18, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.6.0...1.0.0">Diff</a> &mdash; <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> &mdash; <small><i>February 24, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.8...0.6.0">Diff</a> &mdash; <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> &mdash; <small><i>January 28, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.7...0.5.8">Diff</a> &mdash; <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> &mdash; <small><i>January 20, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.6...0.5.7">Diff</a> &mdash; <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> &mdash; <small><i>January 18, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.5...0.5.6">Diff</a> &mdash; <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> &mdash; <small><i>January 9, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.4...0.5.5">Diff</a> &mdash; <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> &mdash; <small><i>January 5, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.2...0.5.4">Diff</a> &mdash; <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> &mdash; <small><i>January 1, 2010</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.1...0.5.2">Diff</a> &mdash; <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> &mdash; <small><i>December 9, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.5.0...0.5.1">Diff</a> &mdash; <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> &mdash; <small><i>December 7, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.7...0.5.0">Diff</a> &mdash; <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> &mdash; <small><i>December 6, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.6...0.4.7">Diff</a> &mdash; <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%&ndash;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> &mdash; <small><i>November 30, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.5...0.4.6">Diff</a> &mdash; <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> &mdash; <small><i>November 19, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.4...0.4.5">Diff</a> &mdash; <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> &mdash; <small><i>November 18, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.3...0.4.4">Diff</a> &mdash; <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> &mdash; <small><i>November 9, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.2...0.4.3">Diff</a> &mdash; <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> &mdash; <small><i>November 9, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.1...0.4.2">Diff</a> &mdash; <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> &mdash; <small><i>November 8, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.4.0...0.4.1">Diff</a> &mdash; <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> &mdash; <small><i>November 7, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.3.3...0.4.0">Diff</a> &mdash; <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> &mdash; <small><i>October 31, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.3.2...0.3.3">Diff</a> &mdash; <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> &mdash; <small><i>October 29, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.3.1...0.3.2">Diff</a> &mdash; <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> &mdash; <small><i>October 29, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.3.0...0.3.1">Diff</a> &mdash; <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> &mdash; <small><i>October 29, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.2.0...0.3.0">Diff</a> &mdash; <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> &mdash; <small><i>October 28, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.1.1...0.2.0">Diff</a> &mdash; <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> &mdash; <small><i>October 28, 2009</i></small> &mdash; <a href="https://github.com/jashkenas/underscore/compare/0.1.0...0.1.1">Diff</a> &mdash; <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> &mdash; <small><i>October 28, 2009</i></small> &mdash; <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
deleted file mode 100644
index 70c9ac2c5..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/package.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "name": "underscore",
- "description": "JavaScript's functional programming helper library.",
- "homepage": "http://underscorejs.org",
- "keywords": [
- "util",
- "functional",
- "server",
- "client",
- "browser"
- ],
- "author": {
- "name": "Jeremy Ashkenas",
- "email": "jeremy@documentcloud.org"
- },
- "repository": {
- "type": "git",
- "url": "git://github.com/jashkenas/underscore.git"
- },
- "main": "underscore.js",
- "version": "1.6.0",
- "devDependencies": {
- "docco": "0.6.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 && 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"
- },
- "licenses": [
- {
- "type": "MIT",
- "url": "https://raw.github.com/jashkenas/underscore/master/LICENSE"
- }
- ],
- "files": [
- "underscore.js",
- "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",
- "_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
deleted file mode 100644
index 1621ad03d..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/arrays.js
+++ /dev/null
@@ -1,323 +0,0 @@
-(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 &amp; b, a&lt;b generates an array of elements a,a+1,a+2,...,b-2,b-1');
- deepEqual(_.range(8, 5), [], 'range with two arguments a &amp; b, b&lt;a generates an empty array');
- deepEqual(_.range(3, 10, 3), [3, 6, 9], 'range with three arguments a &amp; b &amp; c, c &lt; b-a, a &lt; b generates an array of elements a,a+c,a+2c,...,b - (multiplier of a) &lt; c');
- deepEqual(_.range(3, 10, 15), [3], 'range with three arguments a &amp; b &amp; c, c &gt; b-a, a &lt; b generates an array with a single element, equal to a');
- deepEqual(_.range(12, 7, -2), [12, 10, 8], 'range with three arguments a &amp; b &amp; c, a &gt; b, c &lt; 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
deleted file mode 100644
index 0f377e2bc..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/chaining.js
+++ /dev/null
@@ -1,65 +0,0 @@
-(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
deleted file mode 100644
index 0a36bfe85..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/collections.js
+++ /dev/null
@@ -1,676 +0,0 @@
-(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
deleted file mode 100644
index 47e1e456d..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/functions.js
+++ /dev/null
@@ -1,535 +0,0 @@
-(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
deleted file mode 100644
index f6e9352ef..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/index.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<!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
deleted file mode 100644
index dc53db5e3..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/objects.js
+++ /dev/null
@@ -1,665 +0,0 @@
-(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
deleted file mode 100644
index 37c90076d..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/utility.js
+++ /dev/null
@@ -1,294 +0,0 @@
-(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 &amp; Moe');
- equal(_.escape('<a href="http://moe.com">Curly & Moe\'s</a>'), '&lt;a href=&quot;http://moe.com&quot;&gt;Curly &amp; Moe&#x27;s&lt;/a&gt;');
- equal(_.escape('Curly &amp; Moe'), 'Curly &amp;amp; Moe');
- equal(_.escape(null), '');
- });
-
- test('_.unescape', function() {
- var string = 'Curly & Moe';
- equal(_.unescape('Curly &amp; Moe'), string);
- equal(_.unescape('&lt;a href=&quot;http://moe.com&quot;&gt;Curly &amp; Moe&#x27;s&lt;/a&gt;'), '<a href="http://moe.com">Curly & Moe\'s</a>');
- equal(_.unescape('Curly &amp;amp; Moe'), 'Curly &amp; 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>&lt;script&gt;</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
deleted file mode 100644
index 7ba3f9a30..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.css
+++ /dev/null
@@ -1,244 +0,0 @@
-/**
- * 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
deleted file mode 100644
index 84c73907d..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/qunit.js
+++ /dev/null
@@ -1,2212 +0,0 @@
-/**
- * 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/>&nbsp;";
- }
- },
-
- // 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 "&#039;";
- case "\"":
- return "&quot;";
- case "<":
- return "&lt;";
- case ">":
- return "&gt;";
- case "&":
- return "&amp;";
- }
- });
-}
-
-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 ? "&nbsp;" : " ";
- },
- // 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, "&nbsp;" );
- }
- 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 ? "&lt;" : "<",
- close = QUnit.jsDump.HTML ? "&gt;" : ">",
- 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
deleted file mode 100644
index 4b1d38b1b..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/test/vendor/runner.js
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.js b/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore-min.js
deleted file mode 100644
index 3434d6c59..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore-min.js
+++ /dev/null
@@ -1,6 +0,0 @@
-// Underscore.js 1.6.0
-// http://underscorejs.org
-// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
-// Underscore may be freely distributed under the MIT license.
-(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?void(this._wrapped=n):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.6.0";var A=j.each=j.forEach=function(n,t,e){if(null==n)return n;if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return;return n};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var O="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},j.find=j.detect=function(n,t,r){var e;return k(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var k=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:k(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,j.property(t))},j.where=function(n,t){return j.filter(n,j.matches(t))},j.findWhere=function(n,t){return j.find(n,j.matches(t))},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);var e=-1/0,u=-1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;o>u&&(e=n,u=o)}),e},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);var e=1/0,u=1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;u>o&&(e=n,u=o)}),e},j.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=j.random(r++),e[r-1]=e[t],e[t]=n}),e},j.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=j.values(n)),n[j.random(n.length-1)]):j.shuffle(n).slice(0,Math.max(0,t))};var E=function(n){return null==n?j.identity:j.isFunction(n)?n:j.property(n)};j.sortBy=function(n,t,r){return t=E(t),j.pluck(j.map(n,function(n,e,u){return{value:n,index:e,criteria:t.call(r,n,e,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=E(r),A(t,function(i,a){var o=r.call(e,i,a,t);n(u,o,i)}),u}};j.groupBy=F(function(n,t,r){j.has(n,t)?n[t].push(r):n[t]=[r]}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=E(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])<u?i=o+1:a=o}return i},j.toArray=function(n){return n?j.isArray(n)?o.call(n):n.length===+n.length?j.map(n,j.identity):j.values(n):[]},j.size=function(n){return null==n?0:n.length===+n.length?n.length:j.keys(n).length},j.first=j.head=j.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:0>t?[]:o.call(n,0,t)},j.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},j.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},j.rest=j.tail=j.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},j.compact=function(n){return j.filter(n,j.identity)};var M=function(n,t,r){return t&&j.every(n,j.isArray)?c.apply(r,n):(A(n,function(n){j.isArray(n)||j.isArguments(n)?t?a.apply(r,n):M(n,t,r):r.push(n)}),r)};j.flatten=function(n,t){return M(n,t,[])},j.without=function(n){return j.difference(n,o.call(arguments,1))},j.partition=function(n,t){var r=[],e=[];return A(n,function(n){(t(n)?r:e).push(n)}),[r,e]},j.uniq=j.unique=function(n,t,r,e){j.isFunction(t)&&(e=r,r=t,t=!1);var u=r?j.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:j.contains(a,r))||(a.push(r),i.push(n[e]))}),i},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(n){var t=o.call(arguments,1);return j.filter(j.uniq(n),function(n){return j.every(t,function(t){return j.contains(t,n)})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===j&&(e[u]=arguments[r++]);for(;r<arguments.length;)e.push(arguments[r++]);return n.apply(this,e)}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:j.now(),a=null,i=n.apply(e,u),e=u=null};return function(){var l=j.now();o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u),e=u=null):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o,c=function(){var l=j.now()-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u),i=u=null))};return function(){i=this,u=arguments,a=j.now();var l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u),i=u=null),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return j.partial(t,n)},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=function(n){if(!j.isObject(n))return[];if(w)return w(n);var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o)&&"constructor"in n&&"constructor"in t)return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.constant=function(n){return function(){return n}},j.property=function(n){return function(t){return t[n]}},j.matches=function(n){return function(t){if(t===n)return!0;for(var r in n)if(n[r]!==t[r])return!1;return!0}},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},j.now=Date.now||function(){return(new Date).getTime()};var T={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}};T.unescape=j.invert(T.escape);var I={escape:new RegExp("["+j.keys(T.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(T.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(I[n],function(t){return T[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return j})}).call(this);
-//# sourceMappingURL=underscore-min.map \ No newline at end of file
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
deleted file mode 100644
index 47c69bad3..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore-min.map
+++ /dev/null
@@ -1 +0,0 @@
-{"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
deleted file mode 100644
index bc4505051..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/underscore.js
+++ /dev/null
@@ -1,1412 +0,0 @@
-// Underscore.js 1.6.0
-// http://underscorejs.org
-// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
-// Underscore may be freely distributed under the MIT license.
-
-(function() {
-
- // Baseline setup
- // --------------
-
- // Establish the root object, `window` in the browser, or `exports` on the server.
- var root = this;
-
- // Save the previous value of the `_` variable.
- var previousUnderscore = root._;
-
- // Save bytes in the minified (but not gzipped) version:
- var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
-
- // Create quick reference variables for speed access to core prototypes.
- var
- push = ArrayProto.push,
- slice = ArrayProto.slice,
- concat = ArrayProto.concat,
- toString = ObjProto.toString,
- hasOwnProperty = ObjProto.hasOwnProperty;
-
- // All **ECMAScript 5** native function implementations that we hope to use
- // are declared here.
- var
- nativeIsArray = Array.isArray,
- nativeKeys = Object.keys,
- nativeBind = FuncProto.bind;
-
- // Create a safe reference to the Underscore object for use below.
- var _ = function(obj) {
- if (obj instanceof _) return obj;
- if (!(this instanceof _)) return new _(obj);
- this._wrapped = obj;
- };
-
- // Export the Underscore object for **Node.js**, with
- // backwards-compatibility for the old `require()` API. If we're in
- // the browser, add `_` as a global object via a string identifier,
- // for Closure Compiler "advanced" mode.
- if (typeof exports !== 'undefined') {
- if (typeof module !== 'undefined' && module.exports) {
- exports = module.exports = _;
- }
- exports._ = _;
- } else {
- root._ = _;
- }
-
- // 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 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;
- 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 (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.
- _.map = _.collect = function(obj, iterator, context) {
- 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`.
- _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
- var initial = arguments.length > 2;
- if (obj == null) obj = [];
- iterator = createCallback(iterator, context, 4);
- _.each(obj, function(value, index, list) {
- if (!initial) {
- memo = value;
- initial = true;
- } else {
- memo = iterator(memo, value, index, list);
- }
- });
- if (!initial) throw TypeError(reduceError);
- return memo;
- };
-
- // The right-associative version of reduce, also known as `foldr`.
- _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
- var initial = arguments.length > 2;
- if (obj == null) obj = [];
- 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) {
- index = keys ? keys[--length] : --length;
- if (!initial) {
- memo = obj[index];
- initial = true;
- } else {
- memo = iterator(memo, obj[index], index, list);
- }
- });
- 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;
- predicate = lookupIterator(predicate, context);
- _.some(obj, function(value, index, list) {
- if (predicate(value, index, list)) {
- result = value;
- return true;
- }
- });
- return result;
- };
-
- // Return all the elements that pass a truth test.
- // Aliased as `select`.
- _.filter = _.select = function(obj, predicate, context) {
- var results = [];
- if (obj == null) return results;
- 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, _.negate(lookupIterator(predicate)), context);
- };
-
- // Determine whether all of the elements match a truth test.
- // Aliased as `all`.
- _.every = _.all = function(obj, predicate, context) {
- 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.
- // Aliased as `any`.
- // 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 (obj.length !== +obj.length) obj = _.values(obj);
- return _.indexOf(obj, target) >= 0;
- };
-
- // Invoke a method (with arguments) on every item in a collection.
- _.invoke = function(obj, method) {
- var args = slice.call(arguments, 2);
- var isFunc = _.isFunction(method);
- return _.map(obj, function(value) {
- return (isFunc ? method : value[method]).apply(value, args);
- });
- };
-
- // Convenience version of a common use case of `map`: fetching a property.
- _.pluck = function(obj, key) {
- return _.map(obj, _.property(key));
- };
-
- // Convenience version of a common use case of `filter`: selecting only objects
- // containing specific `key:value` pairs.
- _.where = function(obj, attrs) {
- return _.filter(obj, _.matches(attrs));
- };
-
- // Convenience version of a common use case of `find`: getting the first object
- // containing specific `key:value` pairs.
- _.findWhere = function(obj, attrs) {
- return _.find(obj, _.matches(attrs));
- };
-
- // Return the maximum element (or element-based computation).
- _.max = function(obj, iterator, context) {
- 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) {
- 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;
- };
-
- // Shuffle an array, using the modern version of the
- // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
- _.shuffle = function(obj) {
- var rand;
- var index = 0;
- var shuffled = [];
- _.each(obj, function(value) {
- rand = _.random(index++);
- shuffled[index - 1] = shuffled[rand];
- shuffled[rand] = value;
- });
- return shuffled;
- };
-
- // Sample **n** random values from a collection.
- // If **n** is not specified, returns a single random element.
- // The internal `guard` argument allows it to work with `map`.
- _.sample = function(obj, n, guard) {
- if (n == null || guard) {
- if (obj.length !== +obj.length) obj = _.values(obj);
- return obj[_.random(obj.length - 1)];
- }
- return _.shuffle(obj).slice(0, Math.max(0, n));
- };
-
- // Sort the object's values by a criterion produced by an iterator.
- _.sortBy = function(obj, iterator, context) {
- iterator = lookupIterator(iterator, context);
- return _.pluck(_.map(obj, function(value, index, list) {
- return {
- value: value,
- index: index,
- criteria: iterator(value, index, list)
- };
- }).sort(function(left, right) {
- var a = left.criteria;
- var b = right.criteria;
- if (a !== b) {
- if (a > b || a === void 0) return 1;
- if (a < b || b === void 0) return -1;
- }
- return left.index - right.index;
- }), 'value');
- };
-
- // An internal function used for aggregate "group by" operations.
- var group = function(behavior) {
- return function(obj, iterator, context) {
- var result = {};
- iterator = lookupIterator(iterator, context);
- _.each(obj, function(value, index) {
- var key = iterator(value, index, obj);
- behavior(result, value, key);
- });
- return result;
- };
- };
-
- // 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, 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, 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, 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, context, 1);
- var value = iterator(obj);
- var low = 0, high = array.length;
- while (low < high) {
- var mid = (low + high) >>> 1;
- if (iterator(array[mid]) < value) low = mid + 1; else high = mid;
- }
- return low;
- };
-
- // Safely create a real, live array from anything iterable.
- _.toArray = function(obj) {
- if (!obj) return [];
- if (_.isArray(obj)) return slice.call(obj);
- if (obj.length === +obj.length) return _.map(obj, _.identity);
- return _.values(obj);
- };
-
- // 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;
- };
-
- // 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
- // ---------------
-
- // Get the first element of an array. Passing **n** will return the first N
- // values in the array. Aliased as `head` and `take`. The **guard** check
- // 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 < 0) return [];
- return slice.call(array, 0, n);
- };
-
- // Returns everything but the last entry of the array. Especially useful on
- // the arguments object. Passing **n** will return all the values in
- // 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, 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];
- return slice.call(array, Math.max(array.length - n, 0));
- };
-
- // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
- // Especially useful on the arguments object. Passing an **n** will return
- // 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);
- };
-
- // Trim out all falsy values from an array.
- _.compact = function(array) {
- return _.filter(array, _.identity);
- };
-
- // Internal implementation of a recursive `flatten` function.
- var flatten = function(input, shallow, strict, output) {
- if (shallow && _.every(input, _.isArray)) {
- return concat.apply(output, input);
- }
- 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 {
- 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, false, []);
- };
-
- // Return a version of the array that does not contain the specified value(s).
- _.without = function(array) {
- return _.difference(array, slice.call(arguments, 1));
- };
-
- // 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;
- }
- if (iterator) iterator = lookupIterator(iterator, context);
- var result = [];
- var seen = [];
- 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 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, true, []));
- };
-
- // Produce an array that contains every item shared between all the
- // passed-in arrays.
- _.intersection = function(array) {
- 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 = 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(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);
- }
- return results;
- };
-
- // Converts lists into objects. Pass either a single array of `[key, value]`
- // pairs, or two parallel arrays of the same length -- one of keys, and one of
- // the corresponding values.
- _.object = function(list, values) {
- if (list == null) return {};
- var result = {};
- for (var i = 0, length = list.length; i < length; i++) {
- if (values) {
- result[list[i]] = values[i];
- } else {
- result[list[i][0]] = list[i][1];
- }
- }
- return result;
- };
-
- // 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) {
- if (array == null) return -1;
- var i = 0, length = array.length;
- if (isSorted) {
- if (typeof isSorted == 'number') {
- i = isSorted < 0 ? Math.max(0, length + isSorted) : isSorted;
- } else {
- i = _.sortedIndex(array, item);
- return array[i] === item ? i : -1;
- }
- }
- for (; i < length; i++) if (array[i] === item) return i;
- return -1;
- };
-
- _.lastIndexOf = function(array, item, from) {
- if (array == null) return -1;
- var idx = array.length;
- if (typeof from == 'number') {
- idx = from < 0 ? idx + from + 1 : Math.min(idx, from + 1);
- }
- while (--idx >= 0) if (array[idx] === item) return idx;
- return -1;
- };
-
- // Generate an integer Array containing an arithmetic progression. A port of
- // the native Python `range()` function. See
- // [the Python documentation](http://docs.python.org/library/functions.html#range).
- _.range = function(start, stop, step) {
- if (arguments.length <= 1) {
- stop = start || 0;
- start = 0;
- }
- step = arguments[2] || 1;
-
- var length = Math.max(Math.ceil((stop - start) / step), 0);
- var idx = 0;
- var range = Array(length);
-
- while (idx < length) {
- range[idx++] = start;
- start += step;
- }
-
- return range;
- };
-
- // Function (ahem) Functions
- // ------------------
-
- // Reusable constructor function for prototype setting.
- 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
- // available.
- _.bind = function(func, context) {
- var args, bound;
- if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
- if (!_.isFunction(func)) throw TypeError('Bind must be called on a function');
- args = slice.call(arguments, 2);
- 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;
- 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
- // arguments pre-filled, without changing its dynamic `this` context. _ acts
- // as a placeholder, allowing any combination of arguments to be pre-filled.
- _.partial = function(func) {
- var boundArgs = slice.call(arguments, 1);
- return function() {
- var position = 0;
- var args = boundArgs.slice();
- for (var i = 0, length = args.length; i < length; i++) {
- if (args[i] === _) args[i] = arguments[position++];
- }
- while (position < arguments.length) args.push(arguments[position++]);
- return func.apply(this, args);
- };
- };
-
- // 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.
- _.bindAll = function(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 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);
- };
-
- // Defers a function, scheduling it to run after the current call stack has
- // cleared.
- _.defer = function(func) {
- return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
- };
-
- // 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 `wait` duration;
- // but if you'd like to disable the execution on the leading edge, pass
- // `{leading: false}`. To disable execution on the trailing edge, ditto.
- _.throttle = function(func, wait, options) {
- var context, args, result;
- var timeout = null;
- var previous = 0;
- if (!options) options = {};
- var later = function() {
- previous = options.leading === false ? 0 : _.now();
- timeout = null;
- result = func.apply(context, args);
- if (!timeout) context = args = null;
- };
- return function() {
- var now = _.now();
- if (!previous && options.leading === false) previous = now;
- var remaining = wait - (now - previous);
- context = this;
- args = arguments;
- if (remaining <= 0 || remaining > wait) {
- clearTimeout(timeout);
- timeout = null;
- previous = now;
- result = func.apply(context, args);
- if (!timeout) context = args = null;
- } else if (!timeout && options.trailing !== false) {
- timeout = setTimeout(later, remaining);
- }
- return result;
- };
- };
-
- // 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 `immediate` is passed, trigger the function on the
- // leading edge, instead of the trailing.
- _.debounce = function(func, wait, immediate) {
- var timeout, args, context, timestamp, result;
-
- var later = function() {
- var last = _.now() - timestamp;
-
- if (last < wait && last > 0) {
- timeout = setTimeout(later, wait - last);
- } else {
- timeout = null;
- if (!immediate) {
- result = func.apply(context, args);
- if (!timeout) context = args = null;
- }
- }
- };
-
- return function() {
- context = this;
- args = arguments;
- timestamp = _.now();
- var callNow = immediate && !timeout;
- if (!timeout) timeout = setTimeout(later, wait);
- if (callNow) {
- result = func.apply(context, args);
- context = args = null;
- }
-
- return result;
- };
- };
-
- // 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.
- _.wrap = function(func, wrapper) {
- 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 args = arguments;
- var start = args.length - 1;
- return function() {
- var i = start;
- var result = args[start].apply(this, arguments);
- while (i--) result = args[i].call(this, result);
- return result;
- };
- };
-
- // Returns a function that will only be executed after being called N times.
- _.after = function(times, func) {
- return function() {
- if (--times < 1) {
- return func.apply(this, arguments);
- }
- };
- };
-
- // 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
- // ----------------
-
- // Retrieve the names of an object's properties.
- // Delegates to **ECMAScript 5**'s native `Object.keys`
- _.keys = function(obj) {
- if (!_.isObject(obj)) return [];
- if (nativeKeys) return nativeKeys(obj);
- var keys = [];
- for (var key in obj) if (_.has(obj, key)) keys.push(key);
- return keys;
- };
-
- // Retrieve the values of an object's properties.
- _.values = function(obj) {
- var keys = _.keys(obj);
- var length = keys.length;
- var values = Array(length);
- for (var i = 0; i < length; i++) {
- values[i] = obj[keys[i]];
- }
- return values;
- };
-
- // Convert an object into a list of `[key, value]` pairs.
- _.pairs = function(obj) {
- var keys = _.keys(obj);
- var length = keys.length;
- var pairs = Array(length);
- for (var i = 0; i < length; i++) {
- pairs[i] = [keys[i], obj[keys[i]]];
- }
- return pairs;
- };
-
- // Invert the keys and values of an object. The values must be serializable.
- _.invert = function(obj) {
- var result = {};
- var keys = _.keys(obj);
- for (var i = 0, length = keys.length; i < length; i++) {
- result[obj[keys[i]]] = keys[i];
- }
- return result;
- };
-
- // Return a sorted list of the function names available on the object.
- // Aliased as `methods`
- _.functions = _.methods = function(obj) {
- var names = [];
- for (var key in obj) {
- if (_.isFunction(obj[key])) names.push(key);
- }
- return names.sort();
- };
-
- // Extend a given object with all the properties in passed-in object(s).
- _.extend = function(obj) {
- 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, 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, 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 _.pick(obj, iterator, context);
- };
-
- // Fill in a given object with default properties.
- _.defaults = function(obj) {
- 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;
- };
-
- // Create a (shallow-cloned) duplicate of an object.
- _.clone = function(obj) {
- if (!_.isObject(obj)) return obj;
- return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
- };
-
- // 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.
- _.tap = function(obj, interceptor) {
- interceptor(obj);
- return obj;
- };
-
- // Internal recursive comparison function for `isEqual`.
- 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;
- // A strict comparison is necessary because `null == undefined`.
- if (a == null || b == null) return a === b;
- // Unwrap any wrapped objects.
- if (a instanceof _) a = a._wrapped;
- if (b instanceof _) b = b._wrapped;
- // Compare `[[Class]]` names.
- var className = toString.call(a);
- if (className !== toString.call(b)) return false;
- switch (className) {
- // 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 === '' + b;
- case '[object Number]':
- // `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;
- }
- if (typeof a != 'object' || typeof b != 'object') return false;
- // Assume equality for cyclic structures. The algorithm for detecting cyclic
- // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
- var length = aStack.length;
- while (length--) {
- // Linear search. Performance is inversely proportional to the number of
- // unique nested structures.
- 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 &&
- // 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, result;
- // Recursively compare objects and arrays.
- if (className === '[object Array]') {
- // Compare array lengths to determine if a deep comparison is necessary.
- size = a.length;
- result = size === b.length;
- if (result) {
- // Deep compare the contents, ignoring non-numeric properties.
- while (size--) {
- if (!(result = eq(a[size], b[size], aStack, bStack))) break;
- }
- }
- } else {
- // Deep compare objects.
- 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) {
- while (size--) {
- // Deep compare each member
- key = keys[size];
- if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
- }
- }
- }
- // Remove the first object from the stack of traversed objects.
- aStack.pop();
- bStack.pop();
- return result;
- };
-
- // Perform a deep comparison to check if two objects are equal.
- _.isEqual = function(a, b) {
- return eq(a, b, [], []);
- };
-
- // Is a given array, string, or object empty?
- // An "empty" object has no enumerable own-properties.
- _.isEmpty = function(obj) {
- if (obj == null) return true;
- if (_.isArray(obj) || _.isString(obj) || _.isArguments(obj)) return obj.length === 0;
- for (var key in obj) if (_.has(obj, key)) return false;
- return true;
- };
-
- // Is a given value a DOM element?
- _.isElement = function(obj) {
- return !!(obj && obj.nodeType === 1);
- };
-
- // Is a given value an array?
- // Delegates to ECMA5's native Array.isArray
- _.isArray = nativeIsArray || function(obj) {
- return toString.call(obj) === '[object Array]';
- };
-
- // Is a given variable an object?
- _.isObject = function(obj) {
- return obj === Object(obj);
- };
-
- // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
- _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
- _['is' + name] = function(obj) {
- return toString.call(obj) === '[object ' + name + ']';
- };
- });
-
- // Define a fallback version of the method in browsers (ahem, IE), where
- // there isn't any inspectable "Arguments" type.
- if (!_.isArguments(arguments)) {
- _.isArguments = function(obj) {
- return _.has(obj, 'callee');
- };
- }
-
- // Optimize `isFunction` if appropriate.
- if (typeof /./ !== 'function') {
- _.isFunction = function(obj) {
- return typeof obj === 'function';
- };
- }
-
- // Is a given object a finite number?
- _.isFinite = function(obj) {
- return isFinite(obj) && !isNaN(parseFloat(obj));
- };
-
- // Is the given value `NaN`? (NaN is the only number which does not equal itself).
- _.isNaN = function(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]';
- };
-
- // Is a given value equal to null?
- _.isNull = function(obj) {
- return obj === null;
- };
-
- // Is a given variable undefined?
- _.isUndefined = function(obj) {
- return obj === void 0;
- };
-
- // 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 obj != null && hasOwnProperty.call(obj, key);
- };
-
- // Utility Functions
- // -----------------
-
- // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
- // previous owner. Returns a reference to the Underscore object.
- _.noConflict = function() {
- root._ = previousUnderscore;
- return this;
- };
-
- // Keep the identity function around for default iterators.
- _.identity = function(value) {
- return value;
- };
-
- _.constant = function(value) {
- return function() {
- return value;
- };
- };
-
- _.noop = function(){};
-
- _.property = function(key) {
- return function(obj) {
- return obj[key];
- };
- };
-
- // Returns a predicate for checking whether an object has a given set of `key:value` pairs.
- _.matches = function(attrs) {
- return function(obj) {
- 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));
- iterator = createCallback(iterator, context, 1);
- for (var i = 0; i < n; i++) accum[i] = iterator(i);
- return accum;
- };
-
- // Return a random integer between min and max (inclusive).
- _.random = function(min, max) {
- if (max == null) {
- max = min;
- min = 0;
- }
- return min + Math.floor(Math.random() * (max - min + 1));
- };
-
- // A (possibly faster) way to get the current timestamp as an integer.
- _.now = Date.now || function() {
- return new Date().getTime();
- };
-
- // List of HTML entities for escaping.
- var entityMap = {
- escape: {
- '&': '&amp;',
- '<': '&lt;',
- '>': '&gt;',
- '"': '&quot;',
- "'": '&#x27;'
- }
- };
- entityMap.unescape = _.invert(entityMap.escape);
-
- // Regexes containing the keys and values listed immediately above.
- var entityRegexes = {
- escape: RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'),
- unescape: RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g')
- };
-
- // Functions for escaping and unescaping strings to/from HTML interpolation.
- _.each(['escape', 'unescape'], function(method) {
- _[method] = function(string) {
- if (string == null) return '';
- return ('' + string).replace(entityRegexes[method], function(match) {
- return entityMap[method][match];
- });
- };
- });
-
- // If the value of the named `property` is a function then invoke it with the
- // `object` as context; otherwise, return it.
- _.result = function(object, property) {
- if (object == null) return void 0;
- var value = object[property];
- return _.isFunction(value) ? object[property]() : value;
- };
-
- // Generate a unique integer id (unique within the entire client session).
- // Useful for temporary DOM ids.
- var idCounter = 0;
- _.uniqueId = function(prefix) {
- var id = ++idCounter + '';
- return prefix ? prefix + id : id;
- };
-
- // By default, Underscore uses ERB-style template delimiters, change the
- // following template settings to use alternative delimiters.
- _.templateSettings = {
- evaluate : /<%([\s\S]+?)%>/g,
- interpolate : /<%=([\s\S]+?)%>/g,
- escape : /<%-([\s\S]+?)%>/g
- };
-
- // When customizing `templateSettings`, if you don't want to define an
- // interpolation, evaluation or escaping regex, we need one that is
- // guaranteed not to match.
- var noMatch = /(.)^/;
-
- // Certain characters need to be escaped so that they can be put into a
- // string literal.
- var escapes = {
- "'": "'",
- '\\': '\\',
- '\r': 'r',
- '\n': 'n',
- '\u2028': 'u2028',
- '\u2029': 'u2029'
- };
-
- 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) {
- settings = _.defaults({}, settings, _.templateSettings);
-
- // Combine delimiters into one regular expression via alternation.
- var matcher = RegExp([
- (settings.escape || noMatch).source,
- (settings.interpolate || noMatch).source,
- (settings.evaluate || noMatch).source
- ].join('|') + '|$', 'g');
-
- // Compile the template source, escaping string literals appropriately.
- var index = 0;
- var source = "__p+='";
- text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
- source += text.slice(index, offset).replace(escaper, escapeChar);
- index = offset + match.length;
-
- if (escape) {
- source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
- } else if (interpolate) {
- source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
- } else if (evaluate) {
- source += "';\n" + evaluate + "\n__p+='";
- }
-
- // Adobe VMs need the match returned to produce the correct offest.
- return match;
- });
- source += "';\n";
-
- // If a variable is not specified, place data values in local scope.
- if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
-
- source = "var __t,__p='',__j=Array.prototype.join," +
- "print=function(){__p+=__j.call(arguments,'');};\n" +
- source + 'return __p;\n';
-
- try {
- var render = Function(settings.variable || 'obj', '_', source);
- } catch (e) {
- e.source = source;
- throw e;
- }
-
- if (data) return render(data, _);
- var template = function(data) {
- return render.call(this, data, _);
- };
-
- // 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. Start chaining a wrapped Underscore object.
- _.chain = function(obj) {
- var instance = _(obj);
- instance._chain = true;
- return instance;
- };
-
- // OOP
- // ---------------
- // 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.
-
- // Helper function to continue chaining intermediate results.
- var result = function(obj) {
- 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) {
- 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];
- return result.call(this, obj);
- };
- });
-
- // Add all accessor Array functions to the wrapper.
- _.each(['concat', 'join', 'slice'], function(name) {
- var method = ArrayProto[name];
- _.prototype[name] = function() {
- return result.call(this, method.apply(this._wrapped, arguments));
- };
- });
-
- // 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
- // 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.
- if (typeof define === 'function' && define.amd) {
- define('underscore', [], function() {
- return _;
- });
- }
-}.call(this));
diff --git a/node_modules/columnify/node_modules/wcwidth.js/package.json b/node_modules/columnify/node_modules/wcwidth.js/package.json
deleted file mode 100644
index 9542cc97d..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/package.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- "name": "wcwidth.js",
- "version": "0.0.4",
- "description": "A JavaScript porting of C's wcwidth() and wcswidth()",
- "author": {
- "name": "Woong Jun",
- "email": "woong.jun@gmail.com",
- "url": "http://code.woong.org/"
- },
- "contributors": [],
- "homepage": "http://code.woong.org/wcwidth.js",
- "repository": {
- "type": "git",
- "url": "https://github.com/mycoboco/wcwidth.js.git"
- },
- "bugs": {
- "url": "https://github.com/mycoboco/wcwidth.js/issues",
- "email": "woong.jun@gmail.com"
- },
- "main": "wcwidth.js",
- "dependencies": {
- "underscore": ">= 1.3.0"
- },
- "devDependencies": {},
- "engines": {
- "node": ">= 0.8.0"
- },
- "licenses": "MIT",
- "keywords": [
- "wide character",
- "wc",
- "wide character string",
- "wcs",
- "terminal",
- "width",
- "wcwidth",
- "wcswidth"
- ],
- "_id": "wcwidth.js@0.0.4",
- "dist": {
- "shasum": "44298a7c899c17501990fdaddd76ef6bd081be75",
- "tarball": "http://registry.npmjs.org/wcwidth.js/-/wcwidth.js-0.0.4.tgz"
- },
- "_from": "wcwidth.js@>=0.0.4-0 <0.1.0-0",
- "_npmVersion": "1.3.11",
- "_npmUser": {
- "name": "mycoboco",
- "email": "woong.jun@gmail.com"
- },
- "maintainers": [
- {
- "name": "mycoboco",
- "email": "woong.jun@gmail.com"
- }
- ],
- "directories": {},
- "_shasum": "44298a7c899c17501990fdaddd76ef6bd081be75",
- "_resolved": "https://registry.npmjs.org/wcwidth.js/-/wcwidth.js-0.0.4.tgz",
- "readme": "ERROR: No README data found!"
-}
diff --git a/node_modules/columnify/node_modules/wcwidth.js/wcwidth.js b/node_modules/columnify/node_modules/wcwidth.js/wcwidth.js
deleted file mode 100644
index 3ce5b489a..000000000
--- a/node_modules/columnify/node_modules/wcwidth.js/wcwidth.js
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Javascript porting of Markus Kuhn's wcwidth() implementation
- *
- * The following explanation comes from the original C implementation:
- *
- * This is an implementation of wcwidth() and wcswidth() (defined in
- * IEEE Std 1002.1-2001) for Unicode.
- *
- * http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html
- * http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html
- *
- * In fixed-width output devices, Latin characters all occupy a single
- * "cell" position of equal width, whereas ideographic CJK characters
- * occupy two such cells. Interoperability between terminal-line
- * applications and (teletype-style) character terminals using the
- * UTF-8 encoding requires agreement on which character should advance
- * the cursor by how many cell positions. No established formal
- * standards exist at present on which Unicode character shall occupy
- * how many cell positions on character terminals. These routines are
- * a first attempt of defining such behavior based on simple rules
- * applied to data provided by the Unicode Consortium.
- *
- * For some graphical characters, the Unicode standard explicitly
- * defines a character-cell width via the definition of the East Asian
- * FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes.
- * In all these cases, there is no ambiguity about which width a
- * terminal shall use. For characters in the East Asian Ambiguous (A)
- * class, the width choice depends purely on a preference of backward
- * compatibility with either historic CJK or Western practice.
- * Choosing single-width for these characters is easy to justify as
- * the appropriate long-term solution, as the CJK practice of
- * displaying these characters as double-width comes from historic
- * implementation simplicity (8-bit encoded characters were displayed
- * single-width and 16-bit ones double-width, even for Greek,
- * Cyrillic, etc.) and not any typographic considerations.
- *
- * Much less clear is the choice of width for the Not East Asian
- * (Neutral) class. Existing practice does not dictate a width for any
- * of these characters. It would nevertheless make sense
- * typographically to allocate two character cells to characters such
- * as for instance EM SPACE or VOLUME INTEGRAL, which cannot be
- * represented adequately with a single-width glyph. The following
- * routines at present merely assign a single-cell width to all
- * neutral characters, in the interest of simplicity. This is not
- * entirely satisfactory and should be reconsidered before
- * establishing a formal standard in this area. At the moment, the
- * decision which Not East Asian (Neutral) characters should be
- * represented by double-width glyphs cannot yet be answered by
- * applying a simple rule from the Unicode database content. Setting
- * up a proper standard for the behavior of UTF-8 character terminals
- * will require a careful analysis not only of each Unicode character,
- * but also of each presentation form, something the author of these
- * routines has avoided to do so far.
- *
- * http://www.unicode.org/unicode/reports/tr11/
- *
- * Markus Kuhn -- 2007-05-26 (Unicode 5.0)
- *
- * Permission to use, copy, modify, and distribute this software
- * for any purpose and without fee is hereby granted. The author
- * disclaims all warranties with regard to this software.
- *
- * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
- */
-
-var _ = require('underscore');
-
-
-// The following two functions define the column width of an ISO 10646 character as follows:
-//
-// - The null character (U+0000) has a column width of 0.
-// - Other C0/C1 control characters and DEL will lead to a return value of -1.
-// - Non-spacing and enclosing combining characters (general category code Mn or Me in the
-// Unicode database) have a column width of 0.
-// - SOFT HYPHEN (U+00AD) has a column width of 1.
-// - Other format characters (general category code Cf in the Unicode database) and ZERO WIDTH
-// SPACE (U+200B) have a column width of 0.
-// - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) have a column width of 0.
-// - Spacing characters in the East Asian Wide (W) or East Asian Full-width (F) category as
-// defined in Unicode Technical Report #11 have a column width of 2.
-// - All remaining characters (including all printable ISO 8859-1 and WGL4 characters, Unicode
-// control characters, etc.) have a column width of 1.
-//
-// This implementation assumes that characters are encoded in ISO 10646.
-//
-// optional option = { null: width, control: width, monkeypatch: boolean }
-module.exports = wcwidth = function (option) {
- // sorted list of non-overlapping intervals of non-spacing characters
- // generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c"
- var combining = [
- [ 0x0300, 0x036F ], [ 0x0483, 0x0486 ], [ 0x0488, 0x0489 ],
- [ 0x0591, 0x05BD ], [ 0x05BF, 0x05BF ], [ 0x05C1, 0x05C2 ],
- [ 0x05C4, 0x05C5 ], [ 0x05C7, 0x05C7 ], [ 0x0600, 0x0603 ],
- [ 0x0610, 0x0615 ], [ 0x064B, 0x065E ], [ 0x0670, 0x0670 ],
- [ 0x06D6, 0x06E4 ], [ 0x06E7, 0x06E8 ], [ 0x06EA, 0x06ED ],
- [ 0x070F, 0x070F ], [ 0x0711, 0x0711 ], [ 0x0730, 0x074A ],
- [ 0x07A6, 0x07B0 ], [ 0x07EB, 0x07F3 ], [ 0x0901, 0x0902 ],
- [ 0x093C, 0x093C ], [ 0x0941, 0x0948 ], [ 0x094D, 0x094D ],
- [ 0x0951, 0x0954 ], [ 0x0962, 0x0963 ], [ 0x0981, 0x0981 ],
- [ 0x09BC, 0x09BC ], [ 0x09C1, 0x09C4 ], [ 0x09CD, 0x09CD ],
- [ 0x09E2, 0x09E3 ], [ 0x0A01, 0x0A02 ], [ 0x0A3C, 0x0A3C ],
- [ 0x0A41, 0x0A42 ], [ 0x0A47, 0x0A48 ], [ 0x0A4B, 0x0A4D ],
- [ 0x0A70, 0x0A71 ], [ 0x0A81, 0x0A82 ], [ 0x0ABC, 0x0ABC ],
- [ 0x0AC1, 0x0AC5 ], [ 0x0AC7, 0x0AC8 ], [ 0x0ACD, 0x0ACD ],
- [ 0x0AE2, 0x0AE3 ], [ 0x0B01, 0x0B01 ], [ 0x0B3C, 0x0B3C ],
- [ 0x0B3F, 0x0B3F ], [ 0x0B41, 0x0B43 ], [ 0x0B4D, 0x0B4D ],
- [ 0x0B56, 0x0B56 ], [ 0x0B82, 0x0B82 ], [ 0x0BC0, 0x0BC0 ],
- [ 0x0BCD, 0x0BCD ], [ 0x0C3E, 0x0C40 ], [ 0x0C46, 0x0C48 ],
- [ 0x0C4A, 0x0C4D ], [ 0x0C55, 0x0C56 ], [ 0x0CBC, 0x0CBC ],
- [ 0x0CBF, 0x0CBF ], [ 0x0CC6, 0x0CC6 ], [ 0x0CCC, 0x0CCD ],
- [ 0x0CE2, 0x0CE3 ], [ 0x0D41, 0x0D43 ], [ 0x0D4D, 0x0D4D ],
- [ 0x0DCA, 0x0DCA ], [ 0x0DD2, 0x0DD4 ], [ 0x0DD6, 0x0DD6 ],
- [ 0x0E31, 0x0E31 ], [ 0x0E34, 0x0E3A ], [ 0x0E47, 0x0E4E ],
- [ 0x0EB1, 0x0EB1 ], [ 0x0EB4, 0x0EB9 ], [ 0x0EBB, 0x0EBC ],
- [ 0x0EC8, 0x0ECD ], [ 0x0F18, 0x0F19 ], [ 0x0F35, 0x0F35 ],
- [ 0x0F37, 0x0F37 ], [ 0x0F39, 0x0F39 ], [ 0x0F71, 0x0F7E ],
- [ 0x0F80, 0x0F84 ], [ 0x0F86, 0x0F87 ], [ 0x0F90, 0x0F97 ],
- [ 0x0F99, 0x0FBC ], [ 0x0FC6, 0x0FC6 ], [ 0x102D, 0x1030 ],
- [ 0x1032, 0x1032 ], [ 0x1036, 0x1037 ], [ 0x1039, 0x1039 ],
- [ 0x1058, 0x1059 ], [ 0x1160, 0x11FF ], [ 0x135F, 0x135F ],
- [ 0x1712, 0x1714 ], [ 0x1732, 0x1734 ], [ 0x1752, 0x1753 ],
- [ 0x1772, 0x1773 ], [ 0x17B4, 0x17B5 ], [ 0x17B7, 0x17BD ],
- [ 0x17C6, 0x17C6 ], [ 0x17C9, 0x17D3 ], [ 0x17DD, 0x17DD ],
- [ 0x180B, 0x180D ], [ 0x18A9, 0x18A9 ], [ 0x1920, 0x1922 ],
- [ 0x1927, 0x1928 ], [ 0x1932, 0x1932 ], [ 0x1939, 0x193B ],
- [ 0x1A17, 0x1A18 ], [ 0x1B00, 0x1B03 ], [ 0x1B34, 0x1B34 ],
- [ 0x1B36, 0x1B3A ], [ 0x1B3C, 0x1B3C ], [ 0x1B42, 0x1B42 ],
- [ 0x1B6B, 0x1B73 ], [ 0x1DC0, 0x1DCA ], [ 0x1DFE, 0x1DFF ],
- [ 0x200B, 0x200F ], [ 0x202A, 0x202E ], [ 0x2060, 0x2063 ],
- [ 0x206A, 0x206F ], [ 0x20D0, 0x20EF ], [ 0x302A, 0x302F ],
- [ 0x3099, 0x309A ], [ 0xA806, 0xA806 ], [ 0xA80B, 0xA80B ],
- [ 0xA825, 0xA826 ], [ 0xFB1E, 0xFB1E ], [ 0xFE00, 0xFE0F ],
- [ 0xFE20, 0xFE23 ], [ 0xFEFF, 0xFEFF ], [ 0xFFF9, 0xFFFB ],
- [ 0x10A01, 0x10A03 ], [ 0x10A05, 0x10A06 ], [ 0x10A0C, 0x10A0F ],
- [ 0x10A38, 0x10A3A ], [ 0x10A3F, 0x10A3F ], [ 0x1D167, 0x1D169 ],
- [ 0x1D173, 0x1D182 ], [ 0x1D185, 0x1D18B ], [ 0x1D1AA, 0x1D1AD ],
- [ 0x1D242, 0x1D244 ], [ 0xE0001, 0xE0001 ], [ 0xE0020, 0xE007F ],
- [ 0xE0100, 0xE01EF ]
- ];
-
- // auxiliary function for binary search in interval table
- var bisearch = function(ucs) {
- var min = 0,
- max = combining.length-1;
- var mid;
-
- if (ucs < combining[0][0] || ucs > combining[max][1])
- return false;
- while (max >= min) {
- mid = Math.floor((min + max) / 2);
- if (ucs > combining[mid][1])
- min = mid + 1;
- else if (ucs < combining[mid][0])
- max = mid - 1;
- else
- return true;
- }
-
- return false;
- }
-
- // ucs = 'character' or charCode
- var wcwidth = function (ucs) {
- // test for 8-bit control characters
- if (ucs === 0)
- return option.nul;
- if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
- return option.control;
-
- // binary search in table of non-spacing characters
- if (bisearch(ucs))
- return 0;
-
- // if we arrive here, ucs is not a combining or C0/C1 control character
- return 1 +
- (ucs >= 0x1100 &&
- (ucs <= 0x115f || // Hangul Jamo init. consonants
- ucs == 0x2329 || ucs == 0x232a ||
- (ucs >= 0x2e80 && ucs <= 0xa4cf &&
- ucs != 0x303f) || // CJK ... Yi
- (ucs >= 0xac00 && ucs <= 0xd7a3) || // Hangul Syllables
- (ucs >= 0xf900 && ucs <= 0xfaff) || // CJK Compatibility Ideographs
- (ucs >= 0xfe10 && ucs <= 0xfe19) || // Vertical forms
- (ucs >= 0xfe30 && ucs <= 0xfe6f) || // CJK Compatibility Forms
- (ucs >= 0xff00 && ucs <= 0xff60) || // Fullwidth Forms
- (ucs >= 0xffe0 && ucs <= 0xffe6) ||
- (ucs >= 0x20000 && ucs <= 0x2fffd) ||
- (ucs >= 0x30000 && ucs <= 0x3fffd)));
- };
-
- var wcswidth = function (str) {
- var i, l, n, s = 0;
-
- if (_.isString(str))
- for (i=0, l=str.length; i < l; i++) {
- if ((n = wcwidth(str.charCodeAt(i))) < 0)
- return -1;
- s += n;
- }
- else
- s = wcwidth(str);
-
- return s;
- };
-
- option = _.extend({
- nul: 0,
- control: -1,
- monkeypatch: true
- }, option);
-
- if (option.monkeypatch)
- String.prototype.__defineGetter__('wcwidth', function () {
- return wcswidth(this);
- });
-
- return wcswidth;
-};
-
-
-/*
-(function () {
- var ww = wcwidth();
- var test = [
- '다섯글자임',
- 'four',
- 'ten chars',
- ' \n\t',
- '\0'
- ];
-
- for (var i = 0; i < test.length; i++)
- console.log(test[i], test[i].length, ww(test[i]), test[i].wcwidth);
- console.log(ww('한글'));
- console.log(ww('한'.charCodeAt(0)));
-}());
-*/
-
-
-/*
-(function () {
- var ww = wcwidth({
- nul: 1,
- control: 1,
- monkeypatch: false
- });
- var test = [
- '다섯글자임',
- 'four',
- 'ten chars',
- ' \n\t',
- '\0'
- ];
-
- for (var i = 0; i < test.length; i++)
- console.log(test[i], test[i].length, ww(test[i]), test[i].wcwidth);
- console.log(ww('한글'));
- console.log(ww('한'.charCodeAt(0)));
-}());
-*/
-
-// end of wcwidth.js
diff --git a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.gitignore b/node_modules/columnify/node_modules/wcwidth/.npmignore
index 029616c3c..3c3629e64 100644
--- a/node_modules/columnify/node_modules/wcwidth.js/node_modules/underscore/.gitignore
+++ b/node_modules/columnify/node_modules/wcwidth/.npmignore
@@ -1,2 +1 @@
-raw
node_modules
diff --git a/node_modules/columnify/node_modules/wcwidth.js/LICENSE.md b/node_modules/columnify/node_modules/wcwidth/LICENSE
index 14deaf94b..313ef1e88 100644
--- a/node_modules/columnify/node_modules/wcwidth.js/LICENSE.md
+++ b/node_modules/columnify/node_modules/wcwidth/LICENSE
@@ -27,3 +27,4 @@ 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/columnify/node_modules/wcwidth/Readme.md b/node_modules/columnify/node_modules/wcwidth/Readme.md
new file mode 100644
index 000000000..0649a3198
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/Readme.md
@@ -0,0 +1,33 @@
+# wcwidth
+
+Determine columns needed for a fixed-size wide-character string
+
+----
+
+wcwidth is a simple JavaScript port of [wcwidth](http://man7.org/linux/man-pages/man3/wcswidth.3.html) implemented in C by Markus Kuhn.
+
+JavaScript port [originally](https://github.com/mycoboco/wcwidth.js) written by Woong Jun <woong.jun@gmail.com> (http://code.woong.org/)
+
+## Example
+
+```js
+'한'.length // => 1
+wcwidth('한'); // => 2
+
+'한글'.length // => 2
+wcwidth('한글'); // => 4
+```
+
+`wcwidth()` and its string version, `wcswidth()` are defined by IEEE Std
+1002.1-2001, a.k.a. POSIX.1-2001, and return the number of columns used
+to represent the given wide character and string.
+
+Markus's implementation assumes the wide character given to those
+functions to be encoded in ISO 10646, which is almost true for
+JavaScript's characters.
+
+[Further explaination here](docs)
+
+## License
+
+MIT
diff --git a/node_modules/columnify/node_modules/wcwidth/combining.js b/node_modules/columnify/node_modules/wcwidth/combining.js
new file mode 100644
index 000000000..dac9789d3
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/combining.js
@@ -0,0 +1,50 @@
+module.exports = [
+ [ 0x0300, 0x036F ], [ 0x0483, 0x0486 ], [ 0x0488, 0x0489 ],
+ [ 0x0591, 0x05BD ], [ 0x05BF, 0x05BF ], [ 0x05C1, 0x05C2 ],
+ [ 0x05C4, 0x05C5 ], [ 0x05C7, 0x05C7 ], [ 0x0600, 0x0603 ],
+ [ 0x0610, 0x0615 ], [ 0x064B, 0x065E ], [ 0x0670, 0x0670 ],
+ [ 0x06D6, 0x06E4 ], [ 0x06E7, 0x06E8 ], [ 0x06EA, 0x06ED ],
+ [ 0x070F, 0x070F ], [ 0x0711, 0x0711 ], [ 0x0730, 0x074A ],
+ [ 0x07A6, 0x07B0 ], [ 0x07EB, 0x07F3 ], [ 0x0901, 0x0902 ],
+ [ 0x093C, 0x093C ], [ 0x0941, 0x0948 ], [ 0x094D, 0x094D ],
+ [ 0x0951, 0x0954 ], [ 0x0962, 0x0963 ], [ 0x0981, 0x0981 ],
+ [ 0x09BC, 0x09BC ], [ 0x09C1, 0x09C4 ], [ 0x09CD, 0x09CD ],
+ [ 0x09E2, 0x09E3 ], [ 0x0A01, 0x0A02 ], [ 0x0A3C, 0x0A3C ],
+ [ 0x0A41, 0x0A42 ], [ 0x0A47, 0x0A48 ], [ 0x0A4B, 0x0A4D ],
+ [ 0x0A70, 0x0A71 ], [ 0x0A81, 0x0A82 ], [ 0x0ABC, 0x0ABC ],
+ [ 0x0AC1, 0x0AC5 ], [ 0x0AC7, 0x0AC8 ], [ 0x0ACD, 0x0ACD ],
+ [ 0x0AE2, 0x0AE3 ], [ 0x0B01, 0x0B01 ], [ 0x0B3C, 0x0B3C ],
+ [ 0x0B3F, 0x0B3F ], [ 0x0B41, 0x0B43 ], [ 0x0B4D, 0x0B4D ],
+ [ 0x0B56, 0x0B56 ], [ 0x0B82, 0x0B82 ], [ 0x0BC0, 0x0BC0 ],
+ [ 0x0BCD, 0x0BCD ], [ 0x0C3E, 0x0C40 ], [ 0x0C46, 0x0C48 ],
+ [ 0x0C4A, 0x0C4D ], [ 0x0C55, 0x0C56 ], [ 0x0CBC, 0x0CBC ],
+ [ 0x0CBF, 0x0CBF ], [ 0x0CC6, 0x0CC6 ], [ 0x0CCC, 0x0CCD ],
+ [ 0x0CE2, 0x0CE3 ], [ 0x0D41, 0x0D43 ], [ 0x0D4D, 0x0D4D ],
+ [ 0x0DCA, 0x0DCA ], [ 0x0DD2, 0x0DD4 ], [ 0x0DD6, 0x0DD6 ],
+ [ 0x0E31, 0x0E31 ], [ 0x0E34, 0x0E3A ], [ 0x0E47, 0x0E4E ],
+ [ 0x0EB1, 0x0EB1 ], [ 0x0EB4, 0x0EB9 ], [ 0x0EBB, 0x0EBC ],
+ [ 0x0EC8, 0x0ECD ], [ 0x0F18, 0x0F19 ], [ 0x0F35, 0x0F35 ],
+ [ 0x0F37, 0x0F37 ], [ 0x0F39, 0x0F39 ], [ 0x0F71, 0x0F7E ],
+ [ 0x0F80, 0x0F84 ], [ 0x0F86, 0x0F87 ], [ 0x0F90, 0x0F97 ],
+ [ 0x0F99, 0x0FBC ], [ 0x0FC6, 0x0FC6 ], [ 0x102D, 0x1030 ],
+ [ 0x1032, 0x1032 ], [ 0x1036, 0x1037 ], [ 0x1039, 0x1039 ],
+ [ 0x1058, 0x1059 ], [ 0x1160, 0x11FF ], [ 0x135F, 0x135F ],
+ [ 0x1712, 0x1714 ], [ 0x1732, 0x1734 ], [ 0x1752, 0x1753 ],
+ [ 0x1772, 0x1773 ], [ 0x17B4, 0x17B5 ], [ 0x17B7, 0x17BD ],
+ [ 0x17C6, 0x17C6 ], [ 0x17C9, 0x17D3 ], [ 0x17DD, 0x17DD ],
+ [ 0x180B, 0x180D ], [ 0x18A9, 0x18A9 ], [ 0x1920, 0x1922 ],
+ [ 0x1927, 0x1928 ], [ 0x1932, 0x1932 ], [ 0x1939, 0x193B ],
+ [ 0x1A17, 0x1A18 ], [ 0x1B00, 0x1B03 ], [ 0x1B34, 0x1B34 ],
+ [ 0x1B36, 0x1B3A ], [ 0x1B3C, 0x1B3C ], [ 0x1B42, 0x1B42 ],
+ [ 0x1B6B, 0x1B73 ], [ 0x1DC0, 0x1DCA ], [ 0x1DFE, 0x1DFF ],
+ [ 0x200B, 0x200F ], [ 0x202A, 0x202E ], [ 0x2060, 0x2063 ],
+ [ 0x206A, 0x206F ], [ 0x20D0, 0x20EF ], [ 0x302A, 0x302F ],
+ [ 0x3099, 0x309A ], [ 0xA806, 0xA806 ], [ 0xA80B, 0xA80B ],
+ [ 0xA825, 0xA826 ], [ 0xFB1E, 0xFB1E ], [ 0xFE00, 0xFE0F ],
+ [ 0xFE20, 0xFE23 ], [ 0xFEFF, 0xFEFF ], [ 0xFFF9, 0xFFFB ],
+ [ 0x10A01, 0x10A03 ], [ 0x10A05, 0x10A06 ], [ 0x10A0C, 0x10A0F ],
+ [ 0x10A38, 0x10A3A ], [ 0x10A3F, 0x10A3F ], [ 0x1D167, 0x1D169 ],
+ [ 0x1D173, 0x1D182 ], [ 0x1D185, 0x1D18B ], [ 0x1D1AA, 0x1D1AD ],
+ [ 0x1D242, 0x1D244 ], [ 0xE0001, 0xE0001 ], [ 0xE0020, 0xE007F ],
+ [ 0xE0100, 0xE01EF ]
+]
diff --git a/node_modules/columnify/node_modules/wcwidth/docs/index.md b/node_modules/columnify/node_modules/wcwidth/docs/index.md
new file mode 100644
index 000000000..5c5126d03
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/docs/index.md
@@ -0,0 +1,65 @@
+### Javascript porting of Markus Kuhn's wcwidth() implementation
+
+The following explanation comes from the original C implementation:
+
+This is an implementation of wcwidth() and wcswidth() (defined in
+IEEE Std 1002.1-2001) for Unicode.
+
+http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html
+http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html
+
+In fixed-width output devices, Latin characters all occupy a single
+"cell" position of equal width, whereas ideographic CJK characters
+occupy two such cells. Interoperability between terminal-line
+applications and (teletype-style) character terminals using the
+UTF-8 encoding requires agreement on which character should advance
+the cursor by how many cell positions. No established formal
+standards exist at present on which Unicode character shall occupy
+how many cell positions on character terminals. These routines are
+a first attempt of defining such behavior based on simple rules
+applied to data provided by the Unicode Consortium.
+
+For some graphical characters, the Unicode standard explicitly
+defines a character-cell width via the definition of the East Asian
+FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes.
+In all these cases, there is no ambiguity about which width a
+terminal shall use. For characters in the East Asian Ambiguous (A)
+class, the width choice depends purely on a preference of backward
+compatibility with either historic CJK or Western practice.
+Choosing single-width for these characters is easy to justify as
+the appropriate long-term solution, as the CJK practice of
+displaying these characters as double-width comes from historic
+implementation simplicity (8-bit encoded characters were displayed
+single-width and 16-bit ones double-width, even for Greek,
+Cyrillic, etc.) and not any typographic considerations.
+
+Much less clear is the choice of width for the Not East Asian
+(Neutral) class. Existing practice does not dictate a width for any
+of these characters. It would nevertheless make sense
+typographically to allocate two character cells to characters such
+as for instance EM SPACE or VOLUME INTEGRAL, which cannot be
+represented adequately with a single-width glyph. The following
+routines at present merely assign a single-cell width to all
+neutral characters, in the interest of simplicity. This is not
+entirely satisfactory and should be reconsidered before
+establishing a formal standard in this area. At the moment, the
+decision which Not East Asian (Neutral) characters should be
+represented by double-width glyphs cannot yet be answered by
+applying a simple rule from the Unicode database content. Setting
+up a proper standard for the behavior of UTF-8 character terminals
+will require a careful analysis not only of each Unicode character,
+but also of each presentation form, something the author of these
+routines has avoided to do so far.
+
+http://www.unicode.org/unicode/reports/tr11/
+
+Markus Kuhn -- 2007-05-26 (Unicode 5.0)
+
+Permission to use, copy, modify, and distribute this software
+for any purpose and without fee is hereby granted. The author
+disclaims all warranties with regard to this software.
+
+Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
+
+
+
diff --git a/node_modules/columnify/node_modules/wcwidth/index.js b/node_modules/columnify/node_modules/wcwidth/index.js
new file mode 100644
index 000000000..48cbb6020
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/index.js
@@ -0,0 +1,99 @@
+"use strict"
+
+var defaults = require('defaults')
+var combining = require('./combining')
+
+var DEFAULTS = {
+ nul: 0,
+ control: 0
+}
+
+module.exports = function wcwidth(str) {
+ return wcswidth(str, DEFAULTS)
+}
+
+module.exports.config = function(opts) {
+ opts = defaults(opts || {}, DEFAULTS)
+ return function wcwidth(str) {
+ return wcswidth(str, opts)
+ }
+}
+
+/*
+ * The following functions define the column width of an ISO 10646
+ * character as follows:
+ * - The null character (U+0000) has a column width of 0.
+ * - Other C0/C1 control characters and DEL will lead to a return value
+ * of -1.
+ * - Non-spacing and enclosing combining characters (general category
+ * code Mn or Me in the
+ * Unicode database) have a column width of 0.
+ * - SOFT HYPHEN (U+00AD) has a column width of 1.
+ * - Other format characters (general category code Cf in the Unicode
+ * database) and ZERO WIDTH
+ * SPACE (U+200B) have a column width of 0.
+ * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
+ * have a column width of 0.
+ * - Spacing characters in the East Asian Wide (W) or East Asian
+ * Full-width (F) category as
+ * defined in Unicode Technical Report #11 have a column width of 2.
+ * - All remaining characters (including all printable ISO 8859-1 and
+ * WGL4 characters, Unicode control characters, etc.) have a column
+ * width of 1.
+ * This implementation assumes that characters are encoded in ISO 10646.
+*/
+
+function wcswidth(str, opts) {
+ if (typeof str !== 'string') return wcwidth(str, opts)
+
+ var s = 0
+ for (var i = 0; i < str.length; i++) {
+ var n = wcwidth(str.charCodeAt(i), opts)
+ if (n < 0) return -1
+ s += n
+ }
+
+ return s
+}
+
+function wcwidth(ucs, opts) {
+ // test for 8-bit control characters
+ if (ucs === 0) return opts.nul
+ if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) return opts.control
+
+ // binary search in table of non-spacing characters
+ if (bisearch(ucs)) return 0
+
+ // if we arrive here, ucs is not a combining or C0/C1 control character
+ return 1 +
+ (ucs >= 0x1100 &&
+ (ucs <= 0x115f || // Hangul Jamo init. consonants
+ ucs == 0x2329 || ucs == 0x232a ||
+ (ucs >= 0x2e80 && ucs <= 0xa4cf &&
+ ucs != 0x303f) || // CJK ... Yi
+ (ucs >= 0xac00 && ucs <= 0xd7a3) || // Hangul Syllables
+ (ucs >= 0xf900 && ucs <= 0xfaff) || // CJK Compatibility Ideographs
+ (ucs >= 0xfe10 && ucs <= 0xfe19) || // Vertical forms
+ (ucs >= 0xfe30 && ucs <= 0xfe6f) || // CJK Compatibility Forms
+ (ucs >= 0xff00 && ucs <= 0xff60) || // Fullwidth Forms
+ (ucs >= 0xffe0 && ucs <= 0xffe6) ||
+ (ucs >= 0x20000 && ucs <= 0x2fffd) ||
+ (ucs >= 0x30000 && ucs <= 0x3fffd)));
+}
+
+function bisearch(ucs) {
+ var min = 0
+ var max = combining.length - 1
+ var mid
+
+ if (ucs < combining[0][0] || ucs > combining[max][1]) return false
+
+ while (max >= min) {
+ mid = Math.floor((min + max) / 2)
+ if (ucs > combining[mid][1]) min = mid + 1
+ else if (ucs < combining[mid][0]) max = mid - 1
+ else return true
+ }
+
+ return false
+}
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/.npmignore b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/.npmignore
new file mode 100644
index 000000000..3c3629e64
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/.npmignore
@@ -0,0 +1 @@
+node_modules
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/README.md b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/README.md
new file mode 100644
index 000000000..a75e72e9f
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/README.md
@@ -0,0 +1,43 @@
+# defaults
+
+A simple one level options merge utility
+
+## install
+
+`npm install defaults`
+
+## use
+
+```javascript
+
+var defaults = require('defaults');
+
+var handle = function(options, fn) {
+ options = defaults(options, {
+ timeout: 100
+ });
+
+ setTimeout(function() {
+ fn(options);
+ }, options.timeout);
+}
+
+handle({ timeout: 1000 }, function() {
+ // we're here 1000 ms later
+});
+
+handle({ timeout: 10000 }, function() {
+ // we're here 10s later
+});
+
+```
+
+## summary
+
+this module exports a function that takes 2 arguments: `options` and `defaults`. When called, it overrides all of `undefined` properties in `options` with the clones of properties defined in `defaults`
+
+Sidecases: if called with a falsy `options` value, options will be initialized to a new object before being merged onto.
+
+## license
+
+MIT \ No newline at end of file
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/index.js b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/index.js
new file mode 100644
index 000000000..cb7d75c9c
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/index.js
@@ -0,0 +1,13 @@
+var clone = require('clone');
+
+module.exports = function(options, defaults) {
+ options = options || {};
+
+ Object.keys(defaults).forEach(function(key) {
+ if (typeof options[key] === 'undefined') {
+ options[key] = clone(defaults[key]);
+ }
+ });
+
+ return options;
+}; \ No newline at end of file
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/.npmignore b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/.npmignore
new file mode 100644
index 000000000..c2658d7d1
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/.npmignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/.travis.yml b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/.travis.yml
new file mode 100644
index 000000000..58f23716a
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
+ - 0.10
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/LICENSE b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/LICENSE
new file mode 100644
index 000000000..fc808cce8
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/LICENSE
@@ -0,0 +1,18 @@
+Copyright © 2011-2014 Paul Vorbach <paul@vorba.ch>
+
+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, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/README.md b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/README.md
new file mode 100644
index 000000000..527743b60
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/README.md
@@ -0,0 +1,126 @@
+# clone
+
+[![build status](https://secure.travis-ci.org/pvorb/node-clone.png)](http://travis-ci.org/pvorb/node-clone)
+
+offers foolproof _deep cloning_ of variables in JavaScript.
+
+
+## Installation
+
+ npm install clone
+
+or
+
+ ender build clone
+
+
+## Example
+
+~~~ javascript
+var clone = require('clone');
+
+var a, b;
+
+a = { foo: { bar: 'baz' } }; // inital value of a
+
+b = clone(a); // clone a -> b
+a.foo.bar = 'foo'; // change a
+
+console.log(a); // show a
+console.log(b); // show b
+~~~
+
+This will print:
+
+~~~ javascript
+{ foo: { bar: 'foo' } }
+{ foo: { bar: 'baz' } }
+~~~
+
+**clone** masters cloning simple objects (even with custom prototype), arrays,
+Date objects, and RegExp objects. Everything is cloned recursively, so that you
+can clone dates in arrays in objects, for example.
+
+
+## API
+
+`clone(val, circular, depth)`
+
+ * `val` -- the value that you want to clone, any type allowed
+ * `circular` -- boolean
+
+ Call `clone` with `circular` set to `false` if you are certain that `obj`
+ contains no circular references. This will give better performance if needed.
+ There is no error if `undefined` or `null` is passed as `obj`.
+ * `depth` -- depth to wich the object is to be cloned (optional,
+ defaults to infinity)
+
+`clone.clonePrototype(obj)`
+
+ * `obj` -- the object that you want to clone
+
+Does a prototype clone as
+[described by Oran Looney](http://oranlooney.com/functional-javascript/).
+
+
+## Circular References
+
+~~~ javascript
+var a, b;
+
+a = { hello: 'world' };
+
+a.myself = a;
+b = clone(a);
+
+console.log(b);
+~~~
+
+This will print:
+
+~~~ javascript
+{ hello: "world", myself: [Circular] }
+~~~
+
+So, `b.myself` points to `b`, not `a`. Neat!
+
+
+## Test
+
+ npm test
+
+
+## Caveat
+
+Some special objects like a socket or `process.stdout`/`stderr` are known to not
+be cloneable. If you find other objects that cannot be cloned, please [open an
+issue](https://github.com/pvorb/node-clone/issues/new).
+
+
+## Bugs and Issues
+
+If you encounter any bugs or issues, feel free to [open an issue at
+github](https://github.com/pvorb/node-clone/issues) or send me an email to
+<paul@vorba.ch>. I also always like to hear from you, if you’re using my code.
+
+## License
+
+Copyright © 2011-2014 [Paul Vorbach](http://paul.vorba.ch/) and
+[contributors](https://github.com/pvorb/node-clone/graphs/contributors).
+
+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, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/clone.js b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/clone.js
new file mode 100644
index 000000000..5d402073b
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/clone.js
@@ -0,0 +1,129 @@
+'use strict';
+
+function objectToString(o) {
+ return Object.prototype.toString.call(o);
+}
+
+// shim for Node's 'util' package
+// DO NOT REMOVE THIS! It is required for compatibility with EnderJS (http://enderjs.com/).
+var util = {
+ isArray: function (ar) {
+ return Array.isArray(ar) || (typeof ar === 'object' && objectToString(ar) === '[object Array]');
+ },
+ isDate: function (d) {
+ return typeof d === 'object' && objectToString(d) === '[object Date]';
+ },
+ isRegExp: function (re) {
+ return typeof re === 'object' && objectToString(re) === '[object RegExp]';
+ },
+ getRegExpFlags: function (re) {
+ var flags = '';
+ re.global && (flags += 'g');
+ re.ignoreCase && (flags += 'i');
+ re.multiline && (flags += 'm');
+ return flags;
+ }
+};
+
+
+if (typeof module === 'object')
+ module.exports = clone;
+
+/**
+ * Clones (copies) an Object using deep copying.
+ *
+ * This function supports circular references by default, but if you are certain
+ * there are no circular references in your object, you can save some CPU time
+ * by calling clone(obj, false).
+ *
+ * Caution: if `circular` is false and `parent` contains circular references,
+ * your program may enter an infinite loop and crash.
+ *
+ * @param `parent` - the object to be cloned
+ * @param `circular` - set to true if the object to be cloned may contain
+ * circular references. (optional - true by default)
+ * @param `depth` - set to a number if the object is only to be cloned to
+ * a particular depth. (optional - defaults to Infinity)
+ * @param `prototype` - sets the prototype to be used when cloning an object.
+ * (optional - defaults to parent prototype).
+*/
+
+function clone(parent, circular, depth, prototype) {
+ // maintain two arrays for circular references, where corresponding parents
+ // and children have the same index
+ var allParents = [];
+ var allChildren = [];
+
+ var useBuffer = typeof Buffer != 'undefined';
+
+ if (typeof circular == 'undefined')
+ circular = true;
+
+ if (typeof depth == 'undefined')
+ depth = Infinity;
+
+ // recurse this function so we don't reset allParents and allChildren
+ function _clone(parent, depth) {
+ // cloning null always returns null
+ if (parent === null)
+ return null;
+
+ if (depth == 0)
+ return parent;
+
+ var child;
+ if (typeof parent != 'object') {
+ return parent;
+ }
+
+ if (util.isArray(parent)) {
+ child = [];
+ } else if (util.isRegExp(parent)) {
+ child = new RegExp(parent.source, util.getRegExpFlags(parent));
+ if (parent.lastIndex) child.lastIndex = parent.lastIndex;
+ } else if (util.isDate(parent)) {
+ child = new Date(parent.getTime());
+ } else if (useBuffer && Buffer.isBuffer(parent)) {
+ child = new Buffer(parent.length);
+ parent.copy(child);
+ return child;
+ } else {
+ if (typeof prototype == 'undefined') child = Object.create(Object.getPrototypeOf(parent));
+ else child = Object.create(prototype);
+ }
+
+ if (circular) {
+ var index = allParents.indexOf(parent);
+
+ if (index != -1) {
+ return allChildren[index];
+ }
+ allParents.push(parent);
+ allChildren.push(child);
+ }
+
+ for (var i in parent) {
+ child[i] = _clone(parent[i], depth - 1);
+ }
+
+ return child;
+ }
+
+ return _clone(parent, depth);
+}
+
+/**
+ * Simple flat clone using prototype, accepts only objects, usefull for property
+ * override on FLAT configuration object (no nested props).
+ *
+ * USE WITH CAUTION! This may not behave as you wish if you do not know how this
+ * works.
+ */
+clone.clonePrototype = function(parent) {
+ if (parent === null)
+ return null;
+
+ var c = function () {};
+ c.prototype = parent;
+ return new c();
+};
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/package.json b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/package.json
new file mode 100644
index 000000000..3c6b77647
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/package.json
@@ -0,0 +1,121 @@
+{
+ "name": "clone",
+ "description": "deep cloning of objects and arrays",
+ "tags": [
+ "clone",
+ "object",
+ "array",
+ "function",
+ "date"
+ ],
+ "version": "0.1.18",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/pvorb/node-clone.git"
+ },
+ "bugs": {
+ "url": "https://github.com/pvorb/node-clone/issues"
+ },
+ "main": "clone.js",
+ "author": {
+ "name": "Paul Vorbach",
+ "email": "paul@vorba.ch",
+ "url": "http://paul.vorba.ch/"
+ },
+ "contributors": [
+ {
+ "name": "Blake Miner",
+ "email": "miner.blake@gmail.com",
+ "url": "http://www.blakeminer.com/"
+ },
+ {
+ "name": "Tian You",
+ "email": "axqd001@gmail.com",
+ "url": "http://blog.axqd.net/"
+ },
+ {
+ "name": "George Stagas",
+ "email": "gstagas@gmail.com",
+ "url": "http://stagas.com/"
+ },
+ {
+ "name": "Tobiasz Cudnik",
+ "email": "tobiasz.cudnik@gmail.com",
+ "url": "https://github.com/TobiaszCudnik"
+ },
+ {
+ "name": "Pavel Lang",
+ "email": "langpavel@phpskelet.org",
+ "url": "https://github.com/langpavel"
+ },
+ {
+ "name": "Dan MacTough",
+ "url": "http://yabfog.com/"
+ },
+ {
+ "name": "w1nk",
+ "url": "https://github.com/w1nk"
+ },
+ {
+ "name": "Hugh Kennedy",
+ "url": "http://twitter.com/hughskennedy"
+ },
+ {
+ "name": "Dustin Diaz",
+ "url": "http://dustindiaz.com"
+ },
+ {
+ "name": "Ilya Shaisultanov",
+ "url": "https://github.com/diversario"
+ },
+ {
+ "name": "Nathan MacInnes",
+ "email": "nathan@macinn.es",
+ "url": "http://macinn.es/"
+ },
+ {
+ "name": "Benjamin E. Coe",
+ "email": "ben@npmjs.com",
+ "url": "https://twitter.com/benjamincoe"
+ },
+ {
+ "name": "Nathan Zadoks",
+ "url": "https://github.com/nathan7"
+ }
+ ],
+ "license": "MIT",
+ "engines": {
+ "node": "*"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "underscore": "*",
+ "nodeunit": "*"
+ },
+ "optionalDependencies": {},
+ "scripts": {
+ "test": "nodeunit test.js"
+ },
+ "gitHead": "17eea36140d61d97a9954c53417d0e04a00525d9",
+ "homepage": "https://github.com/pvorb/node-clone",
+ "_id": "clone@0.1.18",
+ "_shasum": "64a0d5d57eaa85a1a8af380cd1db8c7b3a895f66",
+ "_from": "clone@>=0.1.5-0 <0.2.0-0",
+ "_npmVersion": "1.4.14",
+ "_npmUser": {
+ "name": "pvorb",
+ "email": "paul@vorba.ch"
+ },
+ "maintainers": [
+ {
+ "name": "pvorb",
+ "email": "paul@vorb.de"
+ }
+ ],
+ "dist": {
+ "shasum": "64a0d5d57eaa85a1a8af380cd1db8c7b3a895f66",
+ "tarball": "http://registry.npmjs.org/clone/-/clone-0.1.18.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/clone/-/clone-0.1.18.tgz"
+}
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/test.js b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/test.js
new file mode 100644
index 000000000..ee49ad893
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/node_modules/clone/test.js
@@ -0,0 +1,271 @@
+if(module.parent === null) {
+ console.log('Run this test file with nodeunit:');
+ console.log('$ nodeunit test.js');
+}
+
+
+var clone = require('./');
+var util = require('util');
+var _ = require('underscore');
+
+
+
+exports["clone string"] = function(test) {
+ test.expect(2); // how many tests?
+
+ var a = "foo";
+ test.strictEqual(clone(a), a);
+ a = "";
+ test.strictEqual(clone(a), a);
+
+ test.done();
+};
+
+
+
+exports["clone number"] = function(test) {
+ test.expect(5); // how many tests?
+
+ var a = 0;
+ test.strictEqual(clone(a), a);
+ a = 1;
+ test.strictEqual(clone(a), a);
+ a = -1000;
+ test.strictEqual(clone(a), a);
+ a = 3.1415927;
+ test.strictEqual(clone(a), a);
+ a = -3.1415927;
+ test.strictEqual(clone(a), a);
+
+ test.done();
+};
+
+
+
+exports["clone date"] = function(test) {
+ test.expect(3); // how many tests?
+
+ var a = new Date;
+ var c = clone(a);
+ test.ok(a instanceof Date);
+ test.ok(c instanceof Date);
+ test.equal(c.getTime(), a.getTime());
+
+ test.done();
+};
+
+
+
+exports["clone object"] = function(test) {
+ test.expect(2); // how many tests?
+
+ var a = { foo: { bar: "baz" } };
+ var b = clone(a);
+
+ test.ok(_(a).isEqual(b), "underscore equal");
+ test.deepEqual(b, a);
+
+ test.done();
+};
+
+
+
+exports["clone array"] = function(test) {
+ test.expect(2); // how many tests?
+
+ var a = [
+ { foo: "bar" },
+ "baz"
+ ];
+ var b = clone(a);
+
+ test.ok(_(a).isEqual(b), "underscore equal");
+ test.deepEqual(b, a);
+
+ test.done();
+};
+
+exports["clone buffer"] = function(test) {
+ test.expect(1);
+
+ var a = new Buffer("this is a test buffer");
+ var b = clone(a);
+
+ // no underscore equal since it has no concept of Buffers
+ test.deepEqual(b, a);
+ test.done();
+};
+
+
+
+exports["clone regexp"] = function(test) {
+ test.expect(5);
+
+ var a = /abc123/gi;
+ var b = clone(a);
+
+ test.deepEqual(b, a);
+
+ var c = /a/g;
+ test.ok(c.lastIndex === 0);
+
+ c.exec('123a456a');
+ test.ok(c.lastIndex === 4);
+
+ var d = clone(c);
+ test.ok(d.global);
+ test.ok(d.lastIndex === 4);
+
+ test.done();
+};
+
+
+exports["clone object containing array"] = function(test) {
+ test.expect(2); // how many tests?
+
+ var a = {
+ arr1: [ { a: '1234', b: '2345' } ],
+ arr2: [ { c: '345', d: '456' } ]
+ };
+ var b = clone(a);
+
+ test.ok(_(a).isEqual(b), "underscore equal");
+ test.deepEqual(b, a);
+
+ test.done();
+};
+
+
+
+exports["clone object with circular reference"] = function(test) {
+ test.expect(8); // how many tests?
+
+ var _ = test.ok;
+ var c = [1, "foo", {'hello': 'bar'}, function() {}, false, [2]];
+ var b = [c, 2, 3, 4];
+ var a = {'b': b, 'c': c};
+ a.loop = a;
+ a.loop2 = a;
+ c.loop = c;
+ c.aloop = a;
+ var aCopy = clone(a);
+ _(a != aCopy);
+ _(a.c != aCopy.c);
+ _(aCopy.c == aCopy.b[0]);
+ _(aCopy.c.loop.loop.aloop == aCopy);
+ _(aCopy.c[0] == a.c[0]);
+
+ //console.log(util.inspect(aCopy, true, null) );
+ //console.log("------------------------------------------------------------");
+ //console.log(util.inspect(a, true, null) );
+ _(eq(a, aCopy));
+ aCopy.c[0] = 2;
+ _(!eq(a, aCopy));
+ aCopy.c = "2";
+ _(!eq(a, aCopy));
+ //console.log("------------------------------------------------------------");
+ //console.log(util.inspect(aCopy, true, null) );
+
+ function eq(x, y) {
+ return util.inspect(x, true, null) === util.inspect(y, true, null);
+ }
+
+ test.done();
+};
+
+
+
+exports['clonePrototype'] = function(test) {
+ test.expect(3); // how many tests?
+
+ var a = {
+ a: "aaa",
+ x: 123,
+ y: 45.65
+ };
+ var b = clone.clonePrototype(a);
+
+ test.strictEqual(b.a, a.a);
+ test.strictEqual(b.x, a.x);
+ test.strictEqual(b.y, a.y);
+
+ test.done();
+}
+
+exports['cloneWithinNewVMContext'] = function(test) {
+ test.expect(3);
+ var vm = require('vm');
+ var ctx = vm.createContext({ clone: clone });
+ var script = "clone( {array: [1, 2, 3], date: new Date(), regex: /^foo$/ig} );";
+ var results = vm.runInContext(script, ctx);
+ test.ok(results.array instanceof Array);
+ test.ok(results.date instanceof Date);
+ test.ok(results.regex instanceof RegExp);
+ test.done();
+}
+
+exports['cloneObjectWithNoConstructor'] = function(test) {
+ test.expect(3);
+ var n = null;
+ var a = { foo: 'bar' };
+ a.__proto__ = n;
+ test.ok(typeof a === 'object');
+ test.ok(typeof a !== null);
+ var b = clone(a);
+ test.ok(a.foo, b.foo);
+ test.done();
+}
+
+exports['clone object with depth argument'] = function (test) {
+ test.expect(6);
+ var a = {
+ foo: {
+ bar : {
+ baz : 'qux'
+ }
+ }
+ };
+ var b = clone(a, false, 1);
+ test.deepEqual(b, a);
+ test.notEqual(b, a);
+ test.strictEqual(b.foo, a.foo);
+
+ b = clone(a, true, 2);
+ test.deepEqual(b, a);
+ test.notEqual(b.foo, a.foo);
+ test.strictEqual(b.foo.bar, a.foo.bar);
+ test.done();
+}
+
+exports['maintain prototype chain in clones'] = function (test) {
+ test.expect(1);
+ function Constructor() {}
+ var a = new Constructor();
+ var b = clone(a);
+ test.strictEqual(Object.getPrototypeOf(a), Object.getPrototypeOf(b));
+ test.done();
+}
+
+exports['parent prototype is overriden with prototype provided'] = function (test) {
+ test.expect(1);
+ function Constructor() {}
+ var a = new Constructor();
+ var b = clone(a, true, Infinity, null);
+ test.strictEqual(b.__defineSetter__, undefined);
+ test.done();
+}
+
+exports['clone object with null children'] = function(test) {
+ test.expect(1);
+ var a = {
+ foo: {
+ bar: null,
+ baz: {
+ qux: false
+ }
+ }
+ };
+ var b = clone(a);
+ test.deepEqual(b, a);
+ test.done();
+}
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/package.json b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/package.json
new file mode 100644
index 000000000..f9243a120
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/package.json
@@ -0,0 +1,50 @@
+{
+ "name": "defaults",
+ "version": "1.0.0",
+ "description": "merge single level defaults over a config object",
+ "main": "index.js",
+ "scripts": {
+ "test": "node test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/tmpvar/defaults.git"
+ },
+ "keywords": [
+ "config",
+ "defaults"
+ ],
+ "author": {
+ "name": "Elijah Insua",
+ "email": "tmpvar@gmail.com"
+ },
+ "license": "MIT",
+ "readmeFilename": "README.md",
+ "dependencies": {
+ "clone": "~0.1.5"
+ },
+ "devDependencies": {
+ "tap": "~0.4.0"
+ },
+ "readme": "# defaults\n\nA simple one level options merge utility\n\n## install\n\n`npm install defaults`\n\n## use\n\n```javascript\n\nvar defaults = require('defaults');\n\nvar handle = function(options, fn) {\n options = defaults(options, {\n timeout: 100\n });\n\n setTimeout(function() {\n fn(options);\n }, options.timeout);\n}\n\nhandle({ timeout: 1000 }, function() {\n // we're here 1000 ms later\n});\n\nhandle({ timeout: 10000 }, function() {\n // we're here 10s later\n});\n\n```\n\n## summary\n\nthis module exports a function that takes 2 arguments: `options` and `defaults`. When called, it overrides all of `undefined` properties in `options` with the clones of properties defined in `defaults`\n\nSidecases: if called with a falsy `options` value, options will be initialized to a new object before being merged onto.\n\n## license\n\nMIT",
+ "_id": "defaults@1.0.0",
+ "dist": {
+ "shasum": "3ae25f44416c6c01f9809a25fcdd285912d2a6b1",
+ "tarball": "http://registry.npmjs.org/defaults/-/defaults-1.0.0.tgz"
+ },
+ "_npmVersion": "1.1.65",
+ "_npmUser": {
+ "name": "tmpvar",
+ "email": "tmpvar@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "tmpvar",
+ "email": "tmpvar@gmail.com"
+ }
+ ],
+ "directories": {},
+ "_shasum": "3ae25f44416c6c01f9809a25fcdd285912d2a6b1",
+ "_from": "defaults@>=1.0.0-0 <2.0.0-0",
+ "_resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.0.tgz"
+}
diff --git a/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/test.js b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/test.js
new file mode 100644
index 000000000..60e0ffba8
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/node_modules/defaults/test.js
@@ -0,0 +1,34 @@
+var defaults = require('./'),
+ test = require('tap').test;
+
+test("ensure options is an object", function(t) {
+ var options = defaults(false, { a : true });
+ t.ok(options.a);
+ t.end()
+});
+
+test("ensure defaults override keys", function(t) {
+ var result = defaults({}, { a: false, b: true });
+ t.ok(result.b, 'b merges over undefined');
+ t.equal(result.a, false, 'a merges over undefined');
+ t.end();
+});
+
+test("ensure defined keys are not overwritten", function(t) {
+ var result = defaults({ b: false }, { a: false, b: true });
+ t.equal(result.b, false, 'b not merged');
+ t.equal(result.a, false, 'a merges over undefined');
+ t.end();
+});
+
+test("ensure defaults clone nested objects", function(t) {
+ var d = { a: [1,2,3], b: { hello : 'world' } };
+ var result = defaults({}, d);
+ t.equal(result.a.length, 3, 'objects should be clones');
+ t.ok(result.a !== d.a, 'objects should be clones');
+
+ t.equal(Object.keys(result.b).length, 1, 'objects should be clones');
+ t.ok(result.b !== d.b, 'objects should be clones');
+ t.end();
+});
+
diff --git a/node_modules/columnify/node_modules/wcwidth/package.json b/node_modules/columnify/node_modules/wcwidth/package.json
new file mode 100644
index 000000000..f12d49b78
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/package.json
@@ -0,0 +1,60 @@
+{
+ "name": "wcwidth",
+ "version": "1.0.0",
+ "description": "Port of C's wcwidth() and wcswidth()",
+ "author": {
+ "name": "Tim Oxley"
+ },
+ "contributors": [
+ {
+ "name": "Woong Jun",
+ "email": "woong.jun@gmail.com",
+ "url": "http://code.woong.org/"
+ }
+ ],
+ "main": "index.js",
+ "dependencies": {
+ "defaults": "^1.0.0"
+ },
+ "devDependencies": {
+ "tape": "^2.13.4"
+ },
+ "license": "MIT",
+ "keywords": [
+ "wide character",
+ "wc",
+ "wide character string",
+ "wcs",
+ "terminal",
+ "width",
+ "wcwidth",
+ "wcswidth"
+ ],
+ "directories": {
+ "doc": "docs",
+ "test": "test"
+ },
+ "scripts": {
+ "test": "tape test/*.js"
+ },
+ "gitHead": "5bc3aafd45c89f233c27b9479c18a23ca91ba660",
+ "_id": "wcwidth@1.0.0",
+ "_shasum": "02d059ff7a8fc741e0f6b5da1e69b2b40daeca6f",
+ "_from": "wcwidth@>=1.0.0-0 <2.0.0-0",
+ "_npmVersion": "1.4.23",
+ "_npmUser": {
+ "name": "timoxley",
+ "email": "secoif@gmail.com"
+ },
+ "maintainers": [
+ {
+ "name": "timoxley",
+ "email": "secoif@gmail.com"
+ }
+ ],
+ "dist": {
+ "shasum": "02d059ff7a8fc741e0f6b5da1e69b2b40daeca6f",
+ "tarball": "http://registry.npmjs.org/wcwidth/-/wcwidth-1.0.0.tgz"
+ },
+ "_resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.0.tgz"
+}
diff --git a/node_modules/columnify/node_modules/wcwidth/test/index.js b/node_modules/columnify/node_modules/wcwidth/test/index.js
new file mode 100644
index 000000000..5180599a2
--- /dev/null
+++ b/node_modules/columnify/node_modules/wcwidth/test/index.js
@@ -0,0 +1,64 @@
+"use strict"
+
+var wcwidth = require('../')
+var test = require('tape')
+
+test('handles regular strings', function(t) {
+ t.strictEqual(wcwidth('abc'), 3)
+ t.end()
+})
+
+test('handles multibyte strings', function(t) {
+ t.strictEqual(wcwidth('字的模块'), 8)
+ t.end()
+})
+
+test('handles multibyte characters mixed with regular characters', function(t) {
+ t.strictEqual(wcwidth('abc 字的模块'), 12)
+ t.end()
+})
+
+test('ignores control characters e.g. \\n', function(t) {
+ t.strictEqual(wcwidth('abc\n字的模块\ndef'), 14)
+ t.end()
+})
+
+test('ignores bad input', function(t) {
+ t.strictEqual(wcwidth(''), 0)
+ t.strictEqual(wcwidth(3), 0)
+ t.strictEqual(wcwidth({}), 0)
+ t.strictEqual(wcwidth([]), 0)
+ t.strictEqual(wcwidth(), 0)
+ t.end()
+})
+
+test('ignores nul (charcode 0)', function(t) {
+ t.strictEqual(wcwidth(String.fromCharCode(0)), 0)
+ t.end()
+})
+
+test('ignores nul mixed with chars', function(t) {
+ t.strictEqual(wcwidth('a' + String.fromCharCode(0) + '\n字的'), 5)
+ t.end()
+})
+
+test('can have custom value for nul', function(t) {
+ t.strictEqual(wcwidth.config({
+ nul: 10
+ })(String.fromCharCode(0) + 'a字的'), 15)
+ t.end()
+})
+
+test('can have custom control char value', function(t) {
+ t.strictEqual(wcwidth.config({
+ control: 1
+ })('abc\n字的模块\ndef'), 16)
+ t.end()
+})
+
+test('negative custom control chars == -1', function(t) {
+ t.strictEqual(wcwidth.config({
+ control: -1
+ })('abc\n字的模块\ndef'), -1)
+ t.end()
+})
diff --git a/node_modules/columnify/package.json b/node_modules/columnify/package.json
index ba3124f14..ef307b509 100644
--- a/node_modules/columnify/package.json
+++ b/node_modules/columnify/package.json
@@ -1,9 +1,10 @@
{
"name": "columnify",
- "version": "1.1.0",
+ "version": "1.2.1",
"description": "Render data in text columns, supports in-column text-wrap.",
"main": "index.js",
"scripts": {
+ "pretest": "npm prune",
"test": "faucet"
},
"author": {
@@ -33,16 +34,17 @@
},
"homepage": "https://github.com/timoxley/columnify",
"dependencies": {
- "strip-ansi": "^0.2.1",
- "wcwidth.js": "~0.0.4"
+ "strip-ansi": "^1.0.0",
+ "wcwidth": "^1.0.0"
},
"directories": {
"test": "test"
},
- "_id": "columnify@1.1.0",
- "_shasum": "0b908e6d4f1c80194358a1933aaf9dc49271c679",
- "_from": "columnify@latest",
- "_npmVersion": "1.4.10",
+ "gitHead": "14e77bef3f57acaa3f390145915a9f2d2a4f882c",
+ "_id": "columnify@1.2.1",
+ "_shasum": "921ec51c178f4126d3c07e9acecd67a55c7953e4",
+ "_from": "columnify@>=1.2.1-0 <2.0.0-0",
+ "_npmVersion": "1.4.23",
"_npmUser": {
"name": "timoxley",
"email": "secoif@gmail.com"
@@ -54,9 +56,8 @@
}
],
"dist": {
- "shasum": "0b908e6d4f1c80194358a1933aaf9dc49271c679",
- "tarball": "http://registry.npmjs.org/columnify/-/columnify-1.1.0.tgz"
+ "shasum": "921ec51c178f4126d3c07e9acecd67a55c7953e4",
+ "tarball": "http://registry.npmjs.org/columnify/-/columnify-1.2.1.tgz"
},
- "_resolved": "https://registry.npmjs.org/columnify/-/columnify-1.1.0.tgz",
- "readme": "ERROR: No README data found!"
+ "_resolved": "https://registry.npmjs.org/columnify/-/columnify-1.2.1.tgz"
}
diff --git a/node_modules/columnify/utils.js b/node_modules/columnify/utils.js
index 12c4f003c..30682af3b 100644
--- a/node_modules/columnify/utils.js
+++ b/node_modules/columnify/utils.js
@@ -3,6 +3,17 @@
var wcwidth = require('./width')
/**
+ * repeat string `str` up to total length of `len`
+ *
+ * @param String str string to repeat
+ * @param Number len total length of output string
+ */
+
+function repeatString(str, len) {
+ return Array.apply(null, {length: len + 1}).join(str).slice(0, len)
+}
+
+/**
* Pad `str` up to total length `max` with `chr`.
* If `str` is longer than `max`, padRight will return `str` unaltered.
*
@@ -15,10 +26,29 @@ var wcwidth = require('./width')
function padRight(str, max, chr) {
str = str != null ? str : ''
str = String(str)
- var length = 1 + max - wcwidth(str)
+ var length = max - wcwidth(str)
if (length <= 0) return str
- return str + Array.apply(null, {length: length})
- .join(chr || ' ')
+ return str + repeatString(chr || ' ', length)
+}
+
+/**
+ * Pad `str` up to total length `max` with `chr`.
+ * If `str` is longer than `max`, padCenter will return `str` unaltered.
+ *
+ * @param String str string to pad
+ * @param Number max total length of output string
+ * @param String chr optional. Character to pad with. default: ' '
+ * @return String padded str
+ */
+
+function padCenter(str, max, chr) {
+ str = str != null ? str : ''
+ str = String(str)
+ var length = max - wcwidth(str)
+ if (length <= 0) return str
+ var lengthLeft = Math.floor(length/2)
+ var lengthRight = length - lengthLeft
+ return repeatString(chr || ' ', lengthLeft) + str + repeatString(chr || ' ', lengthRight)
}
/**
@@ -34,9 +64,9 @@ function padRight(str, max, chr) {
function padLeft(str, max, chr) {
str = str != null ? str : ''
str = String(str)
- var length = 1 + max - wcwidth(str)
+ var length = max - wcwidth(str)
if (length <= 0) return str
- return Array.apply(null, {length: length}).join(chr || ' ') + str
+ return repeatString(chr || ' ', length) + str
}
/**
@@ -143,8 +173,8 @@ function truncateString(str, max) {
*/
module.exports.padRight = padRight
+module.exports.padCenter = padCenter
module.exports.padLeft = padLeft
module.exports.splitIntoLines = splitIntoLines
module.exports.splitLongWords = splitLongWords
module.exports.truncateString = truncateString
-
diff --git a/node_modules/columnify/width.js b/node_modules/columnify/width.js
index 8498f4083..a9f5333b4 100644
--- a/node_modules/columnify/width.js
+++ b/node_modules/columnify/width.js
@@ -1,5 +1,5 @@
var stripAnsi = require('strip-ansi')
-var wcwidth = require('wcwidth.js')({ monkeypatch: false, control: 0 })
+var wcwidth = require('wcwidth')
module.exports = function(str) {
return wcwidth(stripAnsi(str))