mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29a7bc4c81 | ||
|
|
e21e993729 |
@@ -1,18 +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
|
||||
|
||||
[**.{js,json,md}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
|
||||
[**.html]
|
||||
indent_style = tab
|
||||
insert_final_newline = false
|
||||
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -1 +1,5 @@
|
||||
* text=auto
|
||||
*.html text eol=lf
|
||||
*.js text eol=lf
|
||||
*.md text eol=lf
|
||||
*.sh text eol=lf
|
||||
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,6 +1,11 @@
|
||||
.coveralls.yml
|
||||
.DS_Store
|
||||
*.custom.*
|
||||
*.log
|
||||
*.template.*
|
||||
*.map
|
||||
lodash.compat.min.js
|
||||
/*.min.*
|
||||
modularize
|
||||
node_modules
|
||||
dist/*.backbone.*
|
||||
dist/*.legacy.*
|
||||
dist/*.mobile.*
|
||||
|
||||
112
.travis.yml
112
.travis.yml
@@ -1,73 +1,79 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.12"
|
||||
- "0.6"
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
env:
|
||||
global:
|
||||
- BIN="node" BUILD="compat" ISTANBUL=false OPTION=""
|
||||
- NPM_VERSION="^2.0.0" SAUCE_LABS=false SAUCE_USERNAME="lodash"
|
||||
- BIN="node" BUILD=false COMPAT=false MAKE=false OPTION="" SAUCE_LABS=false SAUCE_USERNAME="lodash"
|
||||
- secure: "tg1JFsIFnxzLaTboFPOnm+aJCuMm5+JdhLlESlqg9x3fwro++7KCnwHKLNovhchaPe4otC43ZMB/nfWhDnDm11dKbm/V6HlTkED+dadTsaLxVDg6J+7yK41QhokBPJOxLV78iDaNaAQVYEirAgZ0yn8kFubxmNKV+bpCGQNc9yU="
|
||||
matrix:
|
||||
- BUILD="compat"
|
||||
- BUILD="modern"
|
||||
- BUILD="modern"
|
||||
- BUILD="modern" ISTANBUL=true
|
||||
- BIN="phantomjs"
|
||||
- BIN="rhino"
|
||||
- BIN="rhino" OPTION="-require"
|
||||
- BIN="ringo"
|
||||
- BUILD="legacy"
|
||||
- BUILD="mobile"
|
||||
- BIN="phantomjs" BUILD="compat"
|
||||
- BIN="phantomjs" BUILD="legacy"
|
||||
- BIN="phantomjs" BUILD="mobile"
|
||||
matrix:
|
||||
include:
|
||||
- node_js: "io.js"
|
||||
env:
|
||||
- node_js: "io.js"
|
||||
env: BUILD="modern"
|
||||
- node_js: "0.8"
|
||||
env: NPM_VERSION="~1.4.0"
|
||||
- node_js: "0.8"
|
||||
env: BUILD="modern" NPM_VERSION="~1.4.0"
|
||||
- node_js: "0.10"
|
||||
env:
|
||||
env: BIN="istanbul"
|
||||
- node_js: "0.10"
|
||||
env: BUILD="modern"
|
||||
- node_js: "0.12"
|
||||
env: SAUCE_LABS=true
|
||||
- node_js: "0.12"
|
||||
env: BIN="narwhal" BUILD="compat"
|
||||
- node_js: "0.10"
|
||||
env: BIN="narwhal" BUILD="legacy"
|
||||
- node_js: "0.10"
|
||||
env: BIN="rhino" BUILD="compat"
|
||||
- node_js: "0.10"
|
||||
env: BIN="rhino" BUILD="legacy"
|
||||
- node_js: "0.10"
|
||||
env: BIN="rhino" BUILD="compat" OPTION="-require"
|
||||
- node_js: "0.10"
|
||||
env: BIN="rhino" BUILD="legacy" OPTION="-require"
|
||||
- node_js: "0.10"
|
||||
env: BIN="ringo" BUILD="compat"
|
||||
- node_js: "0.10"
|
||||
env: BIN="ringo" BUILD="legacy"
|
||||
- node_js: "0.8"
|
||||
env: SAUCE_LABS=true BUILD="compat"
|
||||
- node_js: "0.8"
|
||||
env: SAUCE_LABS=true BUILD="modern"
|
||||
- node_js: "0.8"
|
||||
env: SAUCE_LABS=true BUILD="legacy"
|
||||
- node_js: "0.8"
|
||||
env: SAUCE_LABS=true BUILD="mobile"
|
||||
- node_js: "0.8"
|
||||
env: SAUCE_LABS=true BUILD="underscore"
|
||||
git:
|
||||
depth: 10
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
notifications:
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/4aab6358b0e9aed0b628
|
||||
on_success: change
|
||||
on_failure: always
|
||||
before_install:
|
||||
- "nvm use $TRAVIS_NODE_VERSION"
|
||||
- "npm config set loglevel error"
|
||||
- "npm i -g npm@\"$NPM_VERSION\""
|
||||
- "[ $SAUCE_LABS == false ] || npm i chalk@\"0.5.1\" ecstatic@\"0.6.0\" request@\"^2.0.0\" sauce-tunnel@\"2.2.2\""
|
||||
- "[ $ISTANBUL == false ] || (npm i -g coveralls@\"^2.0.0\" && npm i istanbul@\"0.3.6\")"
|
||||
- "[ $BIN != 'rhino' ] || (sudo mkdir /opt/rhino-1.7R5 && sudo wget --no-check-certificate -O $_/js.jar https://lodash.com/_travis/rhino-1.7R5.jar)"
|
||||
- "[ $BIN != 'rhino' ] || (echo -e '#!/bin/sh\\njava -jar /opt/rhino-1.7R5/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino)"
|
||||
- "[ $BIN != 'ringo' ] || (wget --no-check-certificate https://lodash.com/_travis/ringojs-0.11.zip && sudo unzip ringojs-0.11 -d /opt && rm ringojs-0.11.zip)"
|
||||
- "[ $BIN != 'ringo' ] || (sudo ln -s /opt/ringojs-0.11/bin/ringo /usr/local/bin/ringo && sudo chmod +x $_)"
|
||||
- "sed -i'' 's|\"lodash\"|\"lodash-compat\"|' ./package.json"
|
||||
- "git clone --depth=10 --branch=master git://github.com/lodash/lodash-cli.git ./node_modules/lodash-cli && mkdir $_/node_modules && cd $_ && ln -s ../../../ ./lodash-compat && cd ../ && npm i && cd ../../"
|
||||
- "node ./node_modules/lodash-cli/bin/lodash $BUILD -o ./lodash.$BUILD.js"
|
||||
- "([ $BUILD == 'legacy' ] || [ $BUILD == 'mobile' ] || [ $BUILD == 'modern' ]) && MAKE=true || true"
|
||||
- "([ $BUILD == 'compat' ] || [ $BUILD == 'legacy' ]) && COMPAT=true || true"
|
||||
- "[ $SAUCE_LABS != false ] && npm i ecstatic@\"~0.4.0\" request@\"~2.27.0\" sauce-tunnel@\"~1.1.0\" || true"
|
||||
- "[ $BIN == 'istanbul' ] && npm i -g coveralls@\"~2.5.0\" istanbul@\"~0.1.0\" || true"
|
||||
- "[ $BIN == 'narwhal' ] && wget https://github.com/280north/narwhal/archive/v0.3.2.zip && sudo unzip v0.3.2 -d /opt/ && rm v0.3.2.zip || true"
|
||||
- "[ $BIN == 'narwhal' ] && sudo ln -s /opt/narwhal-0.3.2/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal || true"
|
||||
- "[ $BIN == 'rhino' ] && sudo mkdir /opt/rhino-1.7R5 && sudo wget -O /opt/rhino-1.7R5/js.jar https://oss.sonatype.org/content/repositories/snapshots/org/mozilla/rhino/1.7R5-SNAPSHOT/rhino-1.7R5-20120629.144839-4.jar || true"
|
||||
- "[ $BIN == 'rhino' ] && echo -e '#!/bin/sh\\njava -jar /opt/rhino-1.7R5/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino || true"
|
||||
- "[ $BIN == 'ringo' ] && wget http://ringojs.org/downloads/ringojs-0.9.zip && sudo unzip ringojs-0.9 -d /opt && rm ringojs-0.9.zip || true"
|
||||
- "[ $BIN == 'ringo' ] && sudo ln -s /opt/ringojs-0.9/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo || true"
|
||||
- "[ $MAKE != false ] && git clone --depth=10 --branch=master git://github.com/lodash/lodash-cli.git ./node_modules/lodash-cli || true"
|
||||
- "[ $MAKE != false ] && mkdir ./node_modules/lodash-cli/node_modules && cd ./node_modules/lodash-cli/node_modules/ && ln -s ../../../ ./lodash && cd ../ && npm i . && cd ../../ || true"
|
||||
- "[ $MAKE != false ] && node ./node_modules/lodash-cli/bin/lodash $BUILD -o ./dist/lodash.$BUILD.js || true"
|
||||
script:
|
||||
- "[ $ISTANBUL == false ] || (cp ./lodash.$BUILD.js ./lodash.js && node ./node_modules/istanbul/lib/cli.js cover -x \"**/vendor/**\" --report lcovonly ./test/test.js -- ./lodash.js)"
|
||||
- "[ $ISTANBUL == false ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || (cat ./coverage/lcov.info | coveralls)"
|
||||
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || cd ./test"
|
||||
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || $BIN $OPTION ./test.js ../lodash.$BUILD.js"
|
||||
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || $BIN $OPTION ./test.js ../lodash.$BUILD.min.js"
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.js&noglobals=true\" tags=\"$BUILD,development\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.min.js&noglobals=true\" tags=\"$BUILD,production\""
|
||||
- "[ $SAUCE_LABS == false ] || [ $BUILD != 'compat' ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.js\" tags=\"$BUILD,development,ie-compat\" compatMode=7"
|
||||
- "[ $SAUCE_LABS == false ] || [ $BUILD != 'compat' ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.min.js\" tags=\"$BUILD,production,ie-compat\" compatMode=7"
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../lodash.$BUILD.min.js\" tags=\"$BUILD,production,backbone\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../lodash.$BUILD.js\" tags=\"$BUILD,development,backbone\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../lodash.$BUILD.min.js\" tags=\"$BUILD,production,underscore\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../lodash.$BUILD.js\" tags=\"$BUILD,development,underscore\""
|
||||
- "[ $BIN == 'istanbul' ] && $BIN cover -x \"**/vendor/**\" --report lcovonly ./test/test.js -- ./dist/lodash.js && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage || true"
|
||||
- "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || cd ./test"
|
||||
- "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || $BIN $OPTION ./test.js ../dist/lodash.$BUILD.js"
|
||||
- "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || $BIN $OPTION ./test.js ../dist/lodash.$BUILD.min.js"
|
||||
- "([ $SAUCE_LABS == false ] || [ $BUILD == 'underscore' ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=lodash-$BUILD\" tags=\"$BUILD,production\""
|
||||
- "([ $SAUCE_LABS == false ] || [ $COMPAT == false ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=lodash-$BUILD\" tags=\"$BUILD,production,ie-compat\" compatMode=7"
|
||||
- "([ $SAUCE_LABS == false ] || [ $BUILD == 'underscore' ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development\""
|
||||
- "([ $SAUCE_LABS == false ] || [ $COMPAT == false ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development,ie-compat\" compatMode=7"
|
||||
- "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=lodash-$BUILD\" tags=\"$BUILD,production,backbone\""
|
||||
- "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development,backbone\""
|
||||
- "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=lodash-$BUILD\" tags=\"$BUILD,production,underscore\""
|
||||
- "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development,underscore\""
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
# Contributing to lodash
|
||||
# Contributing to Lo-Dash
|
||||
|
||||
If you’d like to contribute a feature or bug fix, you can [fork](https://help.github.com/articles/fork-a-repo/) lodash, commit your changes, & [send a pull request](https://help.github.com/articles/using-pull-requests/).
|
||||
If you’d like to contribute a feature or bug fix, you can [fork](https://help.github.com/articles/fork-a-repo) Lo-Dash, commit your changes, and [send a pull request](https://help.github.com/articles/using-pull-requests).
|
||||
Please make sure to [search the issue tracker](https://github.com/lodash/lodash/issues) first; your issue may have already been discussed or fixed in `master`.
|
||||
|
||||
## Tests
|
||||
|
||||
Include updated unit tests in the `test` directory as part of your pull request.
|
||||
Don’t worry about regenerating the documentation, lodash.js, or lodash.min.js.
|
||||
|
||||
You can run the tests from the command line via `node test/test`, or open `test/index.html` in a web browser.
|
||||
The `test/run-test.sh` script attempts to run the tests in [Rhino](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino), [RingoJS](http://ringojs.org/), [PhantomJS](http://phantomjs.org/), & [Node](http://nodejs.org/), before running them in your default browser.
|
||||
The [Backbone](http://backbonejs.org/) & [Underscore](http://underscorejs.org/) test suites are included as well.
|
||||
The `test/run-test.sh` script attempts to run the tests in [Rhino](https://developer.mozilla.org/en-US/docs/Rhino), [Narwhal](https://github.com/280north/narwhal), [RingoJS](http://ringojs.org/), [PhantomJS](http://phantomjs.org/), and [Node](http://nodejs.org/), before running them in your default browser.
|
||||
The [Backbone](http://backbonejs.org/) and [Underscore](http://http://underscorejs.org/) test suites are included as well.
|
||||
|
||||
## Contributor License Agreement
|
||||
|
||||
lodash is a member of the [Dojo Foundation](http://dojofoundation.org/).
|
||||
Lo-Dash is a member of the [Dojo Foundation](http://dojofoundation.org/).
|
||||
As such, we request that all contributors sign the Dojo Foundation [contributor license agreement](http://dojofoundation.org/about/claForm).
|
||||
|
||||
For more information about CLAs, please check out Alex Russell’s excellent post, [“Why Do I Need to Sign This?”](http://infrequently.org/2008/06/why-do-i-need-to-sign-this/).
|
||||
@@ -27,11 +25,11 @@ In addition to the following guidelines, please follow the conventions already e
|
||||
Use two spaces for indentation. No tabs.
|
||||
|
||||
- **Naming**:<br>
|
||||
Keep variable & method names concise & descriptive.<br>
|
||||
Variable names `index`, `collection`, & `callback` are preferable to `i`, `arr`, & `fn`.
|
||||
Keep variable and method names concise and descriptive.<br>
|
||||
Variable names `index`, `collection`, and `callback` are preferable to `i`, `arr`, and `fn`.
|
||||
|
||||
- **Quotes**:<br>
|
||||
Single-quoted strings are preferred to double-quoted strings; however, please use a double-quoted string if the value contains a single-quote character to avoid unnecessary escaping.
|
||||
|
||||
- **Comments**:<br>
|
||||
Please use single-line comments to annotate significant additions, & [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for new methods.
|
||||
Please use single-line comments to annotate significant additions, and [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for new methods.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas,
|
||||
Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
|
||||
Based on Underscore.js 1.5.2, copyright 2009-2013 Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -19,4 +19,4 @@ 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.
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
154
README.md
154
README.md
@@ -1,25 +1,145 @@
|
||||
# lodash v3.3.1
|
||||
# Lo-Dash v2.4.2
|
||||
A utility library delivering consistency, [customization](https://lodash.com/custom-builds), [performance](https://lodash.com/benchmarks), & [extras](https://lodash.com/#features).
|
||||
|
||||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) with packages for [Bower](http://bower.io/), [Component](http://component.github.io/), & [Volo](http://volojs.org/).
|
||||
## Download
|
||||
|
||||
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
||||
```bash
|
||||
$ lodash modern -o ./lodash.js
|
||||
Check out our [wiki]([https://github.com/lodash/lodash/wiki/build-differences]) for details over the differences between builds.
|
||||
|
||||
* Modern builds perfect for newer browsers/environments:<br>
|
||||
[Development](https://raw.github.com/lodash/lodash/2.4.2/dist/lodash.js) &
|
||||
[Production](https://raw.github.com/lodash/lodash/2.4.2/dist/lodash.min.js)
|
||||
|
||||
* Compatibility builds for older environment support too:<br>
|
||||
[Development](https://raw.github.com/lodash/lodash/2.4.2/dist/lodash.compat.js) &
|
||||
[Production](https://raw.github.com/lodash/lodash/2.4.2/dist/lodash.compat.min.js)
|
||||
|
||||
* Underscore builds to use as a drop-in replacement:<br>
|
||||
[Development](https://raw.github.com/lodash/lodash/2.4.2/dist/lodash.underscore.js) &
|
||||
[Production](https://raw.github.com/lodash/lodash/2.4.2/dist/lodash.underscore.min.js)
|
||||
|
||||
CDN copies are available on [cdnjs](http://cdnjs.com/libraries/lodash.js/) & [jsDelivr](http://www.jsdelivr.com/#!lodash). For smaller file sizes, create [custom builds](https://lodash.com/custom-builds) with only the features needed.
|
||||
|
||||
Love modules? We’ve got you covered with [lodash-amd](https://npmjs.org/package/lodash-amd), [lodash-es6](https://github.com/lodash/lodash-es6), [lodash-node](https://npmjs.org/package/lodash-node), & [npm packages](https://npmjs.org/browse/keyword/lodash-modularized) per method.
|
||||
|
||||
## Dive in
|
||||
|
||||
There’s plenty of **[documentation](https://lodash.com/docs)**, [unit tests](https://lodash.com/tests), & [benchmarks](https://lodash.com/benchmarks).<br>
|
||||
Check out <a href="http://devdocs.io/lodash/">DevDocs</a> as a fast, organized, & searchable interface for our documentation.
|
||||
|
||||
The full changelog for this release is available on our [wiki](https://github.com/lodash/lodash/wiki/Changelog).<br>
|
||||
A list of upcoming features is available on our [roadmap](https://github.com/lodash/lodash/wiki/Roadmap).
|
||||
|
||||
## Installation & usage
|
||||
|
||||
In browsers:
|
||||
|
||||
```html
|
||||
<script src="lodash.js"></script>
|
||||
```
|
||||
|
||||
## Module formats
|
||||
Using [`npm`](http://npmjs.org/):
|
||||
|
||||
lodash is also available in a variety of other builds & module formats.
|
||||
```bash
|
||||
npm i --save lodash
|
||||
|
||||
* npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds
|
||||
* AMD modules for [modern](https://github.com/lodash/lodash/tree/3.3.1-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.3.1-amd) builds
|
||||
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.3.1-es) build
|
||||
{sudo} npm i -g lodash
|
||||
npm ln lodash
|
||||
```
|
||||
|
||||
## Further Reading
|
||||
In [Node.js](http://nodejs.org/) & [Ringo](http://ringojs.org/):
|
||||
|
||||
* [API Documentation](https://lodash.com/docs)
|
||||
* [Build Differences](https://github.com/lodash/lodash/wiki/Build-Differences)
|
||||
* [Changelog](https://github.com/lodash/lodash/wiki/Changelog)
|
||||
* [Release Notes](https://github.com/lodash/lodash/releases)
|
||||
* [Roadmap](https://github.com/lodash/lodash/wiki/Roadmap)
|
||||
* [More Resources](https://github.com/lodash/lodash/wiki/Resources)
|
||||
```js
|
||||
var _ = require('lodash');
|
||||
// or as Underscore
|
||||
var _ = require('lodash/dist/lodash.underscore');
|
||||
```
|
||||
|
||||
**Notes:**
|
||||
* Don’t assign values to [special variable](http://nodejs.org/api/repl.html#repl_repl_features) `_` when in the REPL
|
||||
* If Lo-Dash is installed globally, run [`npm ln lodash`](http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/) in your project’s root directory *before* requiring it
|
||||
|
||||
In [Rhino](http://www.mozilla.org/rhino/):
|
||||
|
||||
```js
|
||||
load('lodash.js');
|
||||
```
|
||||
|
||||
In an AMD loader:
|
||||
|
||||
```js
|
||||
require({
|
||||
'packages': [
|
||||
{ 'name': 'lodash', 'location': 'path/to/lodash', 'main': 'lodash' }
|
||||
]
|
||||
},
|
||||
['lodash'], function(_) {
|
||||
console.log(_.VERSION);
|
||||
});
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
||||
* Podcasts
|
||||
- [JavaScript Jabber](http://javascriptjabber.com/079-jsj-lo-dash-with-john-david-dalton/)
|
||||
|
||||
* Posts
|
||||
- [Say “Hello” to Lo-Dash](http://kitcambridge.be/blog/say-hello-to-lo-dash/)
|
||||
- [Custom builds in Lo-Dash 2.0](http://kitcambridge.be/blog/custom-builds-in-lo-dash-2-dot-0/)
|
||||
|
||||
* Videos
|
||||
- [Introduction](https://vimeo.com/44154599)
|
||||
- [Origins](https://vimeo.com/44154600)
|
||||
- [Optimizations & builds](https://vimeo.com/44154601)
|
||||
- [Native method use](https://vimeo.com/48576012)
|
||||
- [Testing](https://vimeo.com/45865290)
|
||||
- [CascadiaJS ’12](http://www.youtube.com/watch?v=dpPy4f_SeEk)
|
||||
|
||||
A list of other community created podcasts, posts, & videos is available on our [wiki](https://github.com/lodash/lodash/wiki/Resources).
|
||||
|
||||
## Features
|
||||
|
||||
* AMD loader support ([curl](https://github.com/cujojs/curl), [dojo](http://dojotoolkit.org/), [requirejs](http://requirejs.org/), etc.)
|
||||
* [_(…)](https://lodash.com/docs#_) supports intuitive chaining
|
||||
* [_.at](https://lodash.com/docs#at) for cherry-picking collection values
|
||||
* [_.bindKey](https://lodash.com/docs#bindKey) for binding [*“lazy”*](http://michaux.ca/articles/lazy-function-definition-pattern) defined methods
|
||||
* [_.clone](https://lodash.com/docs#clone) supports shallow cloning of `Date` & `RegExp` objects
|
||||
* [_.cloneDeep](https://lodash.com/docs#cloneDeep) for deep cloning arrays & objects
|
||||
* [_.constant](https://lodash.com/docs#constant) & [_.property](https://lodash.com/docs#property) function generators for composing functions
|
||||
* [_.contains](https://lodash.com/docs#contains) accepts a `fromIndex`
|
||||
* [_.create](https://lodash.com/docs#create) for easier object inheritance
|
||||
* [_.createCallback](https://lodash.com/docs#createCallback) for extending callbacks in methods & mixins
|
||||
* [_.curry](https://lodash.com/docs#curry) for creating [curried](http://hughfdjackson.com/javascript/2013/07/06/why-curry-helps/) functions
|
||||
* [_.debounce](https://lodash.com/docs#debounce) & [_.throttle](https://lodash.com/docs#throttle) accept additional `options` for more control
|
||||
* [_.findIndex](https://lodash.com/docs#findIndex) & [_.findKey](https://lodash.com/docs#findKey) for finding indexes & keys
|
||||
* [_.forEach](https://lodash.com/docs#forEach) is chainable & supports exiting early
|
||||
* [_.forIn](https://lodash.com/docs#forIn) for iterating own & inherited properties
|
||||
* [_.forOwn](https://lodash.com/docs#forOwn) for iterating own properties
|
||||
* [_.isPlainObject](https://lodash.com/docs#isPlainObject) for checking if values are created by `Object`
|
||||
* [_.mapValues](https://lodash.com/docs#mapValues) for [mapping](https://lodash.com/docs#map) values to an object
|
||||
* [_.memoize](https://lodash.com/docs#memoize) exposes the `cache` of memoized functions
|
||||
* [_.merge](https://lodash.com/docs#merge) for a deep [_.extend](https://lodash.com/docs#extend)
|
||||
* [_.noop](https://lodash.com/docs#noop) for function placeholders
|
||||
* [_.now](https://lodash.com/docs#now) as a cross-browser `Date.now` alternative
|
||||
* [_.parseInt](https://lodash.com/docs#parseInt) for consistent behavior
|
||||
* [_.pull](https://lodash.com/docs#pull) & [_.remove](https://lodash.com/docs#remove) for mutating arrays
|
||||
* [_.random](https://lodash.com/docs#random) supports returning floating-point numbers
|
||||
* [_.runInContext](https://lodash.com/docs#runInContext) for easier mocking
|
||||
* [_.sortBy](https://lodash.com/docs#sortBy) supports sorting by multiple properties
|
||||
* [_.support](https://lodash.com/docs#support) for flagging environment features
|
||||
* [_.template](https://lodash.com/docs#template) supports [*“imports”*](https://lodash.com/docs#templateSettings_imports) options & [ES6 template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals)
|
||||
* [_.transform](https://lodash.com/docs#transform) as a powerful alternative to [_.reduce](https://lodash.com/docs#reduce) for transforming objects
|
||||
* [_.where](https://lodash.com/docs#where) supports deep object comparisons
|
||||
* [_.xor](https://lodash.com/docs#xor) as a companion to [_.difference](https://lodash.com/docs#difference), [_.intersection](https://lodash.com/docs#intersection), & [_.union](https://lodash.com/docs#union)
|
||||
* [_.zip](https://lodash.com/docs#zip) is capable of unzipping values
|
||||
* [_.omit](https://lodash.com/docs#omit), [_.pick](https://lodash.com/docs#pick), &
|
||||
[more](https://lodash.com/docs "_.assign, _.clone, _.cloneDeep, _.first, _.initial, _.isEqual, _.last, _.merge, _.rest") accept callbacks
|
||||
* [_.contains](https://lodash.com/docs#contains), [_.toArray](https://lodash.com/docs#toArray), &
|
||||
[more](https://lodash.com/docs "_.at, _.countBy, _.every, _.filter, _.find, _.forEach, _.forEachRight, _.groupBy, _.invoke, _.map, _.max, _.min, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.size, _.some, _.sortBy, _.where") accept strings
|
||||
* [_.filter](https://lodash.com/docs#filter), [_.map](https://lodash.com/docs#map), &
|
||||
[more](https://lodash.com/docs "_.countBy, _.every, _.find, _.findKey, _.findLast, _.findLastIndex, _.findLastKey, _.first, _.groupBy, _.initial, _.last, _.max, _.min, _.reject, _.rest, _.some, _.sortBy, _.sortedIndex, _.uniq") support *“_.pluck”* & *“_.where”* shorthands
|
||||
* [_.findLast](https://lodash.com/docs#findLast), [_.findLastIndex](https://lodash.com/docs#findLastIndex), &
|
||||
[more](https://lodash.com/docs "_.findLastKey, _.forEachRight, _.forInRight, _.forOwnRight, _.partialRight") right-associative methods
|
||||
|
||||
## Support
|
||||
|
||||
Tested in Chrome 5~31, Firefox 2~25, IE 6-11, Opera 9.25-17, Safari 3-7, Node.js 0.6.21-0.10.22, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, & Rhino 1.7RC5.
|
||||
|
||||
11
bower.json
11
bower.json
@@ -1,17 +1,20 @@
|
||||
{
|
||||
"name": "lodash",
|
||||
"version": "3.3.1",
|
||||
"main": "lodash.js",
|
||||
"version": "2.4.2",
|
||||
"main": "dist/lodash.compat.js",
|
||||
"ignore": [
|
||||
".*",
|
||||
"*.custom.*",
|
||||
"*.log",
|
||||
"*.template.*",
|
||||
"*.map",
|
||||
"*.md",
|
||||
"lodash.src.js",
|
||||
"/*.min.*",
|
||||
"/lodash.js",
|
||||
"index.js",
|
||||
"component.json",
|
||||
"package.json",
|
||||
"doc",
|
||||
"modularize",
|
||||
"node_modules",
|
||||
"perf",
|
||||
"test",
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"name": "lodash",
|
||||
"repo": "lodash/lodash",
|
||||
"version": "3.3.1",
|
||||
"description": "The modern build of lodash.",
|
||||
"version": "2.4.2",
|
||||
"description": "A utility library delivering consistency, customization, performance, & extras.",
|
||||
"license": "MIT",
|
||||
"main": "lodash.js",
|
||||
"keywords": ["stdlib", "util"],
|
||||
"scripts": ["lodash.js"]
|
||||
"keywords": ["amd", "browser", "client", "functional", "server", "util"],
|
||||
"scripts": [
|
||||
"index.js",
|
||||
"dist/lodash.compat.js"
|
||||
]
|
||||
}
|
||||
|
||||
7158
dist/lodash.compat.js
vendored
Normal file
7158
dist/lodash.compat.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
92
dist/lodash.compat.min.js
vendored
Normal file
92
dist/lodash.compat.min.js
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* @license
|
||||
* Lo-Dash 2.4.2 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE
|
||||
* Build: `lodash -o ./dist/lodash.compat.js`
|
||||
*/
|
||||
;(function(){function n(n,r,e){for(var t=(e||0)-1,o=n?n.length:0;++t<o;)if(n[t]===r)return t;return-1}function r(r,e){var t=typeof e;if(r=r.cache,"boolean"==t||null==e)return r[e]?0:-1;"number"!=t&&"string"!=t&&(t="object");var o="number"==t?e:m+e;return r=(r=r[t])&&r[o],"object"==t?r&&n(r,e)>-1?0:-1:r?0:-1}function e(n){var r=this.cache,e=typeof n;if("boolean"==e||null==n)r[n]=!0;else{"number"!=e&&"string"!=e&&(e="object");var t="number"==e?n:m+n,o=r[e]||(r[e]={});"object"==e?(o[t]||(o[t]=[])).push(n):o[t]=!0;
|
||||
|
||||
}}function t(n){return n.charCodeAt(0)}function o(n,r){for(var e=n.criteria,t=r.criteria,o=-1,u=e.length;++o<u;){var a=e[o],i=t[o];if(a!==i){if(a>i||"undefined"==typeof a)return 1;if(a<i||"undefined"==typeof i)return-1}}return n.index-r.index}function u(n){var r=-1,t=n.length,o=n[0],u=n[t/2|0],a=n[t-1];if(o&&"object"==typeof o&&u&&"object"==typeof u&&a&&"object"==typeof a)return!1;var i=l();i["false"]=i["null"]=i["true"]=i.undefined=!1;var c=l();for(c.array=n,c.cache=i,c.push=e;++r<t;)c.push(n[r]);
|
||||
|
||||
return c}function a(n){return"\\"+Z[n]}function i(){return v.pop()||[]}function l(){return y.pop()||{array:null,cache:null,criteria:null,"false":!1,index:0,"null":!1,number:null,object:null,push:null,string:null,"true":!1,undefined:!1,value:null}}function c(n){return"function"!=typeof n.toString&&"string"==typeof(n+"")}function f(n){n.length=0,v.length<w&&v.push(n)}function s(n){var r=n.cache;r&&s(r),n.array=n.cache=n.criteria=n.object=n.number=n.string=n.value=null,y.length<w&&y.push(n)}function p(n,r,e){
|
||||
r||(r=0),"undefined"==typeof e&&(e=n?n.length:0);for(var t=-1,o=e-r||0,u=Array(o<0?0:o);++t<o;)u[t]=n[r+t];return u}function g(e){function v(n){return n&&"object"==typeof n&&!st(n)&&Ke.call(n,"__wrapped__")?n:new y(n)}function y(n,r){this.__chain__=!!r,this.__wrapped__=n}function w(n){function r(){if(t){var n=p(t);Ue.apply(n,arguments)}if(this instanceof r){var u=rn(e.prototype),a=e.apply(u,n||arguments);return Fn(a)?a:u}return e.apply(o,n||arguments)}var e=n[0],t=n[2],o=n[4];return ft(r,n),r}function Z(n,r,e,t,o){
|
||||
if(e){var u=e(n);if("undefined"!=typeof u)return u}var a=Fn(n);if(!a)return n;var l=$e.call(n);if(!G[l]||!lt.nodeClass&&c(n))return n;var s=at[l];switch(l){case H:case W:return new s(+n);case K:case V:return new s(n);case M:return u=s(n.source,O.exec(n)),u.lastIndex=n.lastIndex,u}var g=st(n);if(r){var h=!t;t||(t=i()),o||(o=i());for(var v=t.length;v--;)if(t[v]==n)return o[v];u=g?s(n.length):{}}else u=g?p(n):xt({},n);return g&&(Ke.call(n,"index")&&(u.index=n.index),Ke.call(n,"input")&&(u.input=n.input)),
|
||||
r?(t.push(n),o.push(u),(g?wt:Ct)(n,function(n,a){u[a]=Z(n,r,e,t,o)}),h&&(f(t),f(o)),u):u}function rn(n,r){return Fn(n)?Xe(n):{}}function en(n,r,e){if("function"!=typeof n)return ue;if("undefined"==typeof r||!("prototype"in n))return n;var t=n.__bindData__;if("undefined"==typeof t&&(lt.funcNames&&(t=!n.name),t=t||!lt.funcDecomp,!t)){var o=qe.call(n);lt.funcNames||(t=!S.test(o)),t||(t=N.test(o),ft(n,t))}if(t===!1||t!==!0&&1&t[1])return n;switch(e){case 1:return function(e){return n.call(r,e)};case 2:
|
||||
return function(e,t){return n.call(r,e,t)};case 3:return function(e,t,o){return n.call(r,e,t,o)};case 4:return function(e,t,o,u){return n.call(r,e,t,o,u)}}return qr(n,r)}function tn(n){function r(){var n=l?a:this;if(o){var h=p(o);Ue.apply(h,arguments)}if((u||f)&&(h||(h=p(arguments)),u&&Ue.apply(h,u),f&&h.length<i))return t|=16,tn([e,s?t:-4&t,h,null,a,i]);if(h||(h=arguments),c&&(e=n[g]),this instanceof r){n=rn(e.prototype);var v=e.apply(n,h);return Fn(v)?v:n}return e.apply(n,h)}var e=n[0],t=n[1],o=n[2],u=n[3],a=n[4],i=n[5],l=1&t,c=2&t,f=4&t,s=8&t,g=e;
|
||||
|
||||
return ft(r,n),r}function on(e,t){var o=-1,a=yn(),i=e?e.length:0,l=i>=_&&a===n,c=[];if(l){var f=u(t);f?(a=r,t=f):l=!1}for(;++o<i;){var p=e[o];a(t,p)<0&&c.push(p)}return l&&s(t),c}function an(n,r,e,t){for(var o=(t||0)-1,u=n?n.length:0,a=[];++o<u;){var i=n[o];if(i&&"object"==typeof i&&"number"==typeof i.length&&(st(i)||_n(i))){r||(i=an(i,r,e));var l=-1,c=i.length,f=a.length;for(a.length+=c;++l<c;)a[f++]=i[l]}else e||a.push(i)}return a}function ln(n,r,e,t,o,u){if(e){var a=e(n,r);if("undefined"!=typeof a)return!!a;
|
||||
|
||||
}if(n===r)return 0!==n||1/n==1/r;var l=typeof n,s=typeof r;if(n===n&&(!n||!Y[l])&&(!r||!Y[s]))return!1;if(null==n||null==r)return n===r;var p=$e.call(n),g=$e.call(r);if(p==F&&(p=U),g==F&&(g=U),p!=g)return!1;switch(p){case H:case W:return+n==+r;case K:return n!=+n?r!=+r:0==n?1/n==1/r:n==+r;case M:case V:return n==Ae(r)}var v=p==B;if(!v){var y=Ke.call(n,"__wrapped__"),b=Ke.call(r,"__wrapped__");if(y||b)return ln(y?n.__wrapped__:n,b?r.__wrapped__:r,e,t,o,u);if(p!=U||!lt.nodeClass&&(c(n)||c(r)))return!1;
|
||||
|
||||
var d=!lt.argsObject&&_n(n)?Oe:n.constructor,m=!lt.argsObject&&_n(r)?Oe:r.constructor;if(d!=m&&!($n(d)&&d instanceof d&&$n(m)&&m instanceof m)&&"constructor"in n&&"constructor"in r)return!1}var _=!o;o||(o=i()),u||(u=i());for(var w=o.length;w--;)if(o[w]==n)return u[w]==r;var x=0;if(a=!0,o.push(n),u.push(r),v){if(w=n.length,x=r.length,a=x==w,a||t)for(;x--;){var j=w,k=r[x];if(t)for(;j--&&!(a=ln(n[j],k,e,t,o,u)););else if(!(a=ln(n[x],k,e,t,o,u)))break}}else kt(r,function(r,i,l){return Ke.call(l,i)?(x++,
|
||||
a=Ke.call(n,i)&&ln(n[i],r,e,t,o,u)):h}),a&&!t&&kt(n,function(n,r,e){return Ke.call(e,r)?a=--x>-1:h});return o.pop(),u.pop(),_&&(f(o),f(u)),a}function cn(n,r,e,t,o){(st(r)?or:Ct)(r,function(r,u){var a,i,l=r,c=n[u];if(r&&((i=st(r))||Pt(r))){for(var f=t.length;f--;)if(a=t[f]==r){c=o[f];break}if(!a){var s;e&&(l=e(c,r),(s="undefined"!=typeof l)&&(c=l)),s||(c=i?st(c)?c:[]:Pt(c)?c:{}),t.push(r),o.push(c),s||cn(c,r,e,t,o)}}else e&&(l=e(c,r),"undefined"==typeof l&&(l=r)),"undefined"!=typeof l&&(c=l);n[u]=c;
|
||||
|
||||
})}function fn(n,r){return n+We(ut()*(r-n+1))}function sn(e,t,o){var a=-1,l=yn(),c=e?e.length:0,p=[],g=!t&&c>=_&&l===n,h=o||g?i():p;if(g){var v=u(h);l=r,h=v}for(;++a<c;){var y=e[a],b=o?o(y,a,e):y;(t?!a||h[h.length-1]!==b:l(h,b)<0)&&((o||g)&&h.push(b),p.push(y))}return g?(f(h.array),s(h)):o&&f(h),p}function pn(n){return function(r,e,t){var o={};if(e=v.createCallback(e,t,3),st(r))for(var u=-1,a=r.length;++u<a;){var i=r[u];n(o,i,e(i,u,r),r)}else wt(r,function(r,t,u){n(o,r,e(r,t,u),u)});return o}}function gn(n,r,e,t,o,u){
|
||||
var a=1&r,i=2&r,l=4&r,c=16&r,f=32&r;if(!i&&!$n(n))throw new Ie;c&&!e.length&&(r&=-17,c=e=!1),f&&!t.length&&(r&=-33,f=t=!1);var s=n&&n.__bindData__;if(s&&s!==!0)return s=p(s),s[2]&&(s[2]=p(s[2])),s[3]&&(s[3]=p(s[3])),!a||1&s[1]||(s[4]=o),!a&&1&s[1]&&(r|=8),!l||4&s[1]||(s[5]=u),c&&Ue.apply(s[2]||(s[2]=[]),e),f&&Je.apply(s[3]||(s[3]=[]),t),s[1]|=r,gn.apply(null,s);var g=1==r||17===r?w:tn;return g([n,r,e,t,o,u])}function hn(){X.shadowedProps=D,X.array=X.bottom=X.loop=X.top="",X.init="iterable",X.useHas=!0;
|
||||
|
||||
for(var n,r=0;n=arguments[r];r++)for(var e in n)X[e]=n[e];var t=X.args;X.firstArg=/^[^,]+/.exec(t)[0];var o=Ce("baseCreateCallback, errorClass, errorProto, hasOwnProperty, indicatorObject, isArguments, isArray, isString, keys, objectProto, objectTypes, nonEnumProps, stringClass, stringProto, toString","return function("+t+") {\n"+ct(X)+"\n}");return o(en,q,Ne,Ke,d,_n,st,zn,X.keys,Re,Y,it,V,Te,$e)}function vn(n){return bt[n]}function yn(){var r=(r=v.indexOf)===Cr?n:r;return r}function bn(n){return"function"==typeof n&&Fe.test(n);
|
||||
|
||||
}function dn(n){var r,e;return!n||$e.call(n)!=U||(r=n.constructor,$n(r)&&!(r instanceof r))||!lt.argsClass&&_n(n)||!lt.nodeClass&&c(n)?!1:lt.ownLast?(kt(n,function(n,r,t){return e=Ke.call(t,r),!1}),e!==!1):(kt(n,function(n,r){e=r}),"undefined"==typeof e||Ke.call(n,e))}function mn(n){return dt[n]}function _n(n){return n&&"object"==typeof n&&"number"==typeof n.length&&$e.call(n)==F||!1}function wn(n,r,e,t){return"boolean"!=typeof r&&null!=r&&(t=e,e=r,r=!1),Z(n,r,"function"==typeof e&&en(e,t,1))}function xn(n,r,e){
|
||||
return Z(n,!0,"function"==typeof r&&en(r,e,1))}function jn(n,r){var e=rn(n);return r?xt(e,r):e}function kn(n,r,e){var t;return r=v.createCallback(r,e,3),Ct(n,function(n,e,o){return r(n,e,o)?(t=e,!1):h}),t}function Cn(n,r,e){var t;return r=v.createCallback(r,e,3),En(n,function(n,e,o){return r(n,e,o)?(t=e,!1):h}),t}function Pn(n,r,e){var t=[];kt(n,function(n,r){t.push(r,n)});var o=t.length;for(r=en(r,e,3);o--&&r(t[o--],t[o],n)!==!1;);return n}function En(n,r,e){var t=gt(n),o=t.length;for(r=en(r,e,3);o--;){
|
||||
var u=t[o];if(r(n[u],u,n)===!1)break}return n}function On(n){var r=[];return kt(n,function(n,e){$n(n)&&r.push(e)}),r.sort()}function Sn(n,r){return n?Ke.call(n,r):!1}function An(n){for(var r=-1,e=gt(n),t=e.length,o={};++r<t;){var u=e[r];o[n[u]]=u}return o}function In(n){return n===!0||n===!1||n&&"object"==typeof n&&$e.call(n)==H||!1}function Ln(n){return n&&"object"==typeof n&&$e.call(n)==W||!1}function Nn(n){return n&&1===n.nodeType||!1}function Rn(n){var r=!0;if(!n)return r;var e=$e.call(n),t=n.length;
|
||||
|
||||
return e==B||e==V||(lt.argsClass?e==F:_n(n))||e==U&&"number"==typeof t&&$n(n.splice)?!t:(Ct(n,function(){return r=!1}),r)}function Tn(n,r,e,t){return ln(n,r,"function"==typeof e&&en(e,t,2))}function Dn(n){return Ze(n)&&!nt(parseFloat(n))}function $n(n){return"function"==typeof n}function Fn(n){return!(!n||!Y[typeof n])}function Bn(n){return Wn(n)&&n!=+n}function Hn(n){return null===n}function Wn(n){return"number"==typeof n||n&&"object"==typeof n&&$e.call(n)==K||!1}function qn(n){return n&&Y[typeof n]&&$e.call(n)==M||!1;
|
||||
|
||||
}function zn(n){return"string"==typeof n||n&&"object"==typeof n&&$e.call(n)==V||!1}function Kn(n){return"undefined"==typeof n}function Un(n,r,e){var t={};return r=v.createCallback(r,e,3),Ct(n,function(n,e,o){t[e]=r(n,e,o)}),t}function Mn(n){var r=arguments,e=2;if(!Fn(n))return n;if("number"!=typeof r[2]&&(e=r.length),e>3&&"function"==typeof r[e-2])var t=en(r[--e-1],r[e--],2);else e>2&&"function"==typeof r[e-1]&&(t=r[--e]);for(var o=p(arguments,1,e),u=-1,a=i(),l=i();++u<e;)cn(n,o[u],t,a,l);return f(a),
|
||||
f(l),n}function Vn(n,r,e){var t={};if("function"!=typeof r){var o=[];kt(n,function(n,r){o.push(r)}),o=on(o,an(arguments,!0,!1,1));for(var u=-1,a=o.length;++u<a;){var i=o[u];t[i]=n[i]}}else r=v.createCallback(r,e,3),kt(n,function(n,e,o){r(n,e,o)||(t[e]=n)});return t}function Gn(n){for(var r=-1,e=gt(n),t=e.length,o=we(t);++r<t;){var u=e[r];o[r]=[u,n[u]]}return o}function Jn(n,r,e){var t={};if("function"!=typeof r)for(var o=-1,u=an(arguments,!0,!1,1),a=Fn(n)?u.length:0;++o<a;){var i=u[o];i in n&&(t[i]=n[i]);
|
||||
|
||||
}else r=v.createCallback(r,e,3),kt(n,function(n,e,o){r(n,e,o)&&(t[e]=n)});return t}function Qn(n,r,e,t){var o=st(n);if(null==e)if(o)e=[];else{var u=n&&n.constructor,a=u&&u.prototype;e=rn(a)}return r&&(r=v.createCallback(r,t,4),(o?wt:Ct)(n,function(n,t,o){return r(e,n,t,o)})),e}function Xn(n){for(var r=-1,e=gt(n),t=e.length,o=we(t);++r<t;)o[r]=n[e[r]];return o}function Yn(n){var r=arguments,e=-1,t=an(r,!0,!1,1),o=r[2]&&r[2][r[1]]===n?1:t.length,u=we(o);for(lt.unindexedChars&&zn(n)&&(n=n.split(""));++e<o;)u[e]=n[t[e]];
|
||||
|
||||
return u}function Zn(n,r,e){var t=-1,o=yn(),u=n?n.length:0,a=!1;return e=(e<0?et(0,u+e):e)||0,st(n)?a=o(n,r,e)>-1:"number"==typeof u?a=(zn(n)?n.indexOf(r,e):o(n,r,e))>-1:wt(n,function(n){return++t<e?h:!(a=n===r)}),a}function nr(n,r,e){var t=!0;if(r=v.createCallback(r,e,3),st(n))for(var o=-1,u=n.length;++o<u&&(t=!!r(n[o],o,n)););else wt(n,function(n,e,o){return t=!!r(n,e,o)});return t}function rr(n,r,e){var t=[];if(r=v.createCallback(r,e,3),st(n))for(var o=-1,u=n.length;++o<u;){var a=n[o];r(a,o,n)&&t.push(a);
|
||||
|
||||
}else wt(n,function(n,e,o){r(n,e,o)&&t.push(n)});return t}function er(n,r,e){if(r=v.createCallback(r,e,3),!st(n)){var t;return wt(n,function(n,e,o){return r(n,e,o)?(t=n,!1):h}),t}for(var o=-1,u=n.length;++o<u;){var a=n[o];if(r(a,o,n))return a}}function tr(n,r,e){var t;return r=v.createCallback(r,e,3),ur(n,function(n,e,o){return r(n,e,o)?(t=n,!1):h}),t}function or(n,r,e){if(r&&"undefined"==typeof e&&st(n))for(var t=-1,o=n.length;++t<o&&r(n[t],t,n)!==!1;);else wt(n,r,e);return n}function ur(n,r,e){
|
||||
var t=n,o=n?n.length:0;if(r=r&&"undefined"==typeof e?r:en(r,e,3),st(n))for(;o--&&r(n[o],o,n)!==!1;);else{if("number"!=typeof o){var u=gt(n);o=u.length}else lt.unindexedChars&&zn(n)&&(t=n.split(""));wt(n,function(n,e,a){return e=u?u[--o]:--o,r(t[e],e,a)})}return n}function ar(n,r){var e=p(arguments,2),t=-1,o="function"==typeof r,u=n?n.length:0,a=we("number"==typeof u?u:0);return or(n,function(n){a[++t]=(o?r:n[r]).apply(n,e)}),a}function ir(n,r,e){var t=-1,o=n?n.length:0,u=we("number"==typeof o?o:0);
|
||||
|
||||
if(r=v.createCallback(r,e,3),st(n))for(;++t<o;)u[t]=r(n[t],t,n);else wt(n,function(n,e,o){u[++t]=r(n,e,o)});return u}function lr(n,r,e){var o=-(1/0),u=o;if("function"!=typeof r&&e&&e[r]===n&&(r=null),null==r&&st(n))for(var a=-1,i=n.length;++a<i;){var l=n[a];l>u&&(u=l)}else r=null==r&&zn(n)?t:v.createCallback(r,e,3),wt(n,function(n,e,t){var a=r(n,e,t);a>o&&(o=a,u=n)});return u}function cr(n,r,e){var o=1/0,u=o;if("function"!=typeof r&&e&&e[r]===n&&(r=null),null==r&&st(n))for(var a=-1,i=n.length;++a<i;){
|
||||
var l=n[a];l<u&&(u=l)}else r=null==r&&zn(n)?t:v.createCallback(r,e,3),wt(n,function(n,e,t){var a=r(n,e,t);a<o&&(o=a,u=n)});return u}function fr(n,r,e,t){var o=arguments.length<3;if(r=v.createCallback(r,t,4),st(n)){var u=-1,a=n.length;for(o&&(e=n[++u]);++u<a;)e=r(e,n[u],u,n)}else wt(n,function(n,t,u){e=o?(o=!1,n):r(e,n,t,u)});return e}function sr(n,r,e,t){var o=arguments.length<3;return r=v.createCallback(r,t,4),ur(n,function(n,t,u){e=o?(o=!1,n):r(e,n,t,u)}),e}function pr(n,r,e){return r=v.createCallback(r,e,3),
|
||||
rr(n,function(n,e,t){return!r(n,e,t)})}function gr(n,r,e){if(n&&"number"!=typeof n.length?n=Xn(n):lt.unindexedChars&&zn(n)&&(n=n.split("")),null==r||e)return n?n[fn(0,n.length-1)]:h;var t=hr(n);return t.length=tt(et(0,r),t.length),t}function hr(n){var r=-1,e=n?n.length:0,t=we("number"==typeof e?e:0);return or(n,function(n){var e=fn(0,++r);t[r]=t[e],t[e]=n}),t}function vr(n){var r=n?n.length:0;return"number"==typeof r?r:gt(n).length}function yr(n,r,e){var t;if(r=v.createCallback(r,e,3),st(n))for(var o=-1,u=n.length;++o<u&&!(t=r(n[o],o,n)););else wt(n,function(n,e,o){
|
||||
return!(t=r(n,e,o))});return!!t}function br(n,r,e){var t=-1,u=st(r),a=n?n.length:0,c=we("number"==typeof a?a:0);for(u||(r=v.createCallback(r,e,3)),or(n,function(n,e,o){var a=c[++t]=l();u?a.criteria=ir(r,function(r){return n[r]}):(a.criteria=i())[0]=r(n,e,o),a.index=t,a.value=n}),a=c.length,c.sort(o);a--;){var p=c[a];c[a]=p.value,u||f(p.criteria),s(p)}return c}function dr(n){return n&&"number"==typeof n.length?lt.unindexedChars&&zn(n)?n.split(""):p(n):Xn(n)}function mr(n){for(var r=-1,e=n?n.length:0,t=[];++r<e;){
|
||||
var o=n[r];o&&t.push(o)}return t}function _r(n){return on(n,an(arguments,!0,!0,1))}function wr(n,r,e){var t=-1,o=n?n.length:0;for(r=v.createCallback(r,e,3);++t<o;)if(r(n[t],t,n))return t;return-1}function xr(n,r,e){var t=n?n.length:0;for(r=v.createCallback(r,e,3);t--;)if(r(n[t],t,n))return t;return-1}function jr(n,r,e){var t=0,o=n?n.length:0;if("number"!=typeof r&&null!=r){var u=-1;for(r=v.createCallback(r,e,3);++u<o&&r(n[u],u,n);)t++}else if(t=r,null==t||e)return n?n[0]:h;return p(n,0,tt(et(0,t),o));
|
||||
|
||||
}function kr(n,r,e,t){return"boolean"!=typeof r&&null!=r&&(t=e,e="function"!=typeof r&&t&&t[r]===n?null:r,r=!1),null!=e&&(n=ir(n,e,t)),an(n,r)}function Cr(r,e,t){if("number"==typeof t){var o=r?r.length:0;t=t<0?et(0,o+t):t||0}else if(t){var u=Rr(r,e);return r[u]===e?u:-1}return n(r,e,t)}function Pr(n,r,e){var t=0,o=n?n.length:0;if("number"!=typeof r&&null!=r){var u=o;for(r=v.createCallback(r,e,3);u--&&r(n[u],u,n);)t++}else t=null==r||e?1:r||t;return p(n,0,tt(et(0,o-t),o))}function Er(){for(var e=[],t=-1,o=arguments.length,a=i(),l=yn(),c=l===n,p=i();++t<o;){
|
||||
var g=arguments[t];(st(g)||_n(g))&&(e.push(g),a.push(c&&g.length>=_&&u(t?e[t]:p)))}var h=e[0],v=-1,y=h?h.length:0,b=[];n:for(;++v<y;){var d=a[0];if(g=h[v],(d?r(d,g):l(p,g))<0){for(t=o,(d||p).push(g);--t;)if(d=a[t],(d?r(d,g):l(e[t],g))<0)continue n;b.push(g)}}for(;o--;)d=a[o],d&&s(d);return f(a),f(p),b}function Or(n,r,e){var t=0,o=n?n.length:0;if("number"!=typeof r&&null!=r){var u=o;for(r=v.createCallback(r,e,3);u--&&r(n[u],u,n);)t++}else if(t=r,null==t||e)return n?n[o-1]:h;return p(n,et(0,o-t))}function Sr(n,r,e){
|
||||
var t=n?n.length:0;for("number"==typeof e&&(t=(e<0?et(0,t+e):tt(e,t-1))+1);t--;)if(n[t]===r)return t;return-1}function Ar(n){for(var r=arguments,e=0,t=r.length,o=n?n.length:0;++e<t;)for(var u=-1,a=r[e];++u<o;)n[u]===a&&(Ge.call(n,u--,1),o--);return n}function Ir(n,r,e){n=+n||0,e="number"==typeof e?e:+e||1,null==r&&(r=n,n=0);for(var t=-1,o=et(0,Be((r-n)/(e||1))),u=we(o);++t<o;)u[t]=n,n+=e;return u}function Lr(n,r,e){var t=-1,o=n?n.length:0,u=[];for(r=v.createCallback(r,e,3);++t<o;){var a=n[t];r(a,t,n)&&(u.push(a),
|
||||
Ge.call(n,t--,1),o--)}return u}function Nr(n,r,e){if("number"!=typeof r&&null!=r){var t=0,o=-1,u=n?n.length:0;for(r=v.createCallback(r,e,3);++o<u&&r(n[o],o,n);)t++}else t=null==r||e?1:et(0,r);return p(n,t)}function Rr(n,r,e,t){var o=0,u=n?n.length:o;for(e=e?v.createCallback(e,t,1):ue,r=e(r);o<u;){var a=o+u>>>1;e(n[a])<r?o=a+1:u=a}return o}function Tr(){return sn(an(arguments,!0,!0))}function Dr(n,r,e,t){return"boolean"!=typeof r&&null!=r&&(t=e,e="function"!=typeof r&&t&&t[r]===n?null:r,r=!1),null!=e&&(e=v.createCallback(e,t,3)),
|
||||
sn(n,r,e)}function $r(n){return on(n,p(arguments,1))}function Fr(){for(var n=-1,r=arguments.length;++n<r;){var e=arguments[n];if(st(e)||_n(e))var t=t?sn(on(t,e).concat(on(e,t))):e}return t||[]}function Br(){for(var n=arguments.length>1?arguments:arguments[0],r=-1,e=n?lr(At(n,"length")):0,t=we(e<0?0:e);++r<e;)t[r]=At(n,r);return t}function Hr(n,r){var e=-1,t=n?n.length:0,o={};for(r||!t||st(n[0])||(r=[]);++e<t;){var u=n[e];r?o[u]=r[e]:u&&(o[u[0]]=u[1])}return o}function Wr(n,r){if(!$n(r))throw new Ie;
|
||||
|
||||
return function(){return--n<1?r.apply(this,arguments):h}}function qr(n,r){return arguments.length>2?gn(n,17,p(arguments,2),null,r):gn(n,1,null,null,r)}function zr(n){for(var r=arguments.length>1?an(arguments,!0,!1,1):On(n),e=-1,t=r.length;++e<t;){var o=r[e];n[o]=gn(n[o],1,null,null,n)}return n}function Kr(n,r){return arguments.length>2?gn(r,19,p(arguments,2),null,n):gn(r,3,null,null,n)}function Ur(){for(var n=arguments,r=n.length;r--;)if(!$n(n[r]))throw new Ie;return function(){for(var r=arguments,e=n.length;e--;)r=[n[e].apply(this,r)];
|
||||
|
||||
return r[0]}}function Mr(n,r){return r="number"==typeof r?r:+r||n.length,gn(n,4,null,null,null,r)}function Vr(n,r,e){var t,o,u,a,i,l,c,f=0,s=!1,p=!0;if(!$n(n))throw new Ie;if(r=et(0,r)||0,e===!0){var g=!0;p=!1}else Fn(e)&&(g=e.leading,s="maxWait"in e&&(et(r,e.maxWait)||0),p="trailing"in e?e.trailing:p);var v=function(){var e=r-(Lt()-a);if(e>0)l=Ve(v,e);else{o&&He(o);var s=c;o=l=c=h,s&&(f=Lt(),u=n.apply(i,t),l||o||(t=i=null))}},y=function(){l&&He(l),o=l=c=h,(p||s!==r)&&(f=Lt(),u=n.apply(i,t),l||o||(t=i=null));
|
||||
|
||||
};return function(){if(t=arguments,a=Lt(),i=this,c=p&&(l||!g),s===!1)var e=g&&!l;else{o||g||(f=a);var h=s-(a-f),b=h<=0;b?(o&&(o=He(o)),f=a,u=n.apply(i,t)):o||(o=Ve(y,h))}return b&&l?l=He(l):l||r===s||(l=Ve(v,r)),e&&(b=!0,u=n.apply(i,t)),!b||l||o||(t=i=null),u}}function Gr(n){if(!$n(n))throw new Ie;var r=p(arguments,1);return Ve(function(){n.apply(h,r)},1)}function Jr(n,r){if(!$n(n))throw new Ie;var e=p(arguments,2);return Ve(function(){n.apply(h,e)},r)}function Qr(n,r){if(!$n(n))throw new Ie;var e=function(){
|
||||
var t=e.cache,o=r?r.apply(this,arguments):m+arguments[0];return Ke.call(t,o)?t[o]:t[o]=n.apply(this,arguments)};return e.cache={},e}function Xr(n){var r,e;if(!$n(n))throw new Ie;return function(){return r?e:(r=!0,e=n.apply(this,arguments),n=null,e)}}function Yr(n){return gn(n,16,p(arguments,1))}function Zr(n){return gn(n,32,null,p(arguments,1))}function ne(n,r,e){var t=!0,o=!0;if(!$n(n))throw new Ie;return e===!1?t=!1:Fn(e)&&(t="leading"in e?e.leading:t,o="trailing"in e?e.trailing:o),J.leading=t,
|
||||
J.maxWait=r,J.trailing=o,Vr(n,r,J)}function re(n,r){return gn(r,16,[n])}function ee(n){return function(){return n}}function te(n,r,e){var t=typeof n;if(null==n||"function"==t)return en(n,r,e);if("object"!=t)return ce(n);var o=gt(n),u=o[0],a=n[u];return 1!=o.length||a!==a||Fn(a)?function(r){for(var e=o.length,t=!1;e--&&(t=ln(r[o[e]],n[o[e]],null,!0)););return t}:function(n){var r=n[u];return a===r&&(0!==a||1/a==1/r)}}function oe(n){return null==n?"":Ae(n).replace(_t,vn)}function ue(n){return n}function ae(n,r,e){
|
||||
var t=!0,o=r&&On(r);r&&(e||o.length)||(null==e&&(e=r),u=y,r=n,n=v,o=On(r)),e===!1?t=!1:Fn(e)&&"chain"in e&&(t=e.chain);var u=n,a=$n(u);or(o,function(e){var o=n[e]=r[e];a&&(u.prototype[e]=function(){var r=this.__chain__,e=this.__wrapped__,a=[e];Ue.apply(a,arguments);var i=o.apply(n,a);if(t||r){if(e===i&&Fn(i))return this;i=new u(i),i.__chain__=r}return i})})}function ie(){return e._=De,this}function le(){}function ce(n){return function(r){return r[n]}}function fe(n,r,e){var t=null==n,o=null==r;if(null==e&&("boolean"==typeof n&&o?(e=n,
|
||||
n=1):o||"boolean"!=typeof r||(e=r,o=!0)),t&&o&&(r=1),n=+n||0,o?(r=n,n=0):r=+r||0,e||n%1||r%1){var u=ut();return tt(n+u*(r-n+parseFloat("1e-"+((u+"").length-1))),r)}return fn(n,r)}function se(n,r){if(n){var e=n[r];return $n(e)?n[r]():e}}function pe(n,r,e){var t=v.templateSettings;n=Ae(n||""),e=jt({},e,t);var o,u=jt({},e.imports,t.imports),i=gt(u),l=Xn(u),c=0,f=e.interpolate||L,s="__p += '",p=Se((e.escape||L).source+"|"+f.source+"|"+(f===A?E:L).source+"|"+(e.evaluate||L).source+"|$","g");n.replace(p,function(r,e,t,u,i,l){
|
||||
return t||(t=u),s+=n.slice(c,l).replace(R,a),e&&(s+="' +\n__e("+e+") +\n'"),i&&(o=!0,s+="';\n"+i+";\n__p += '"),t&&(s+="' +\n((__t = ("+t+")) == null ? '' : __t) +\n'"),c=l+r.length,r}),s+="';\n";var g=e.variable,y=g;y||(g="obj",s="with ("+g+") {\n"+s+"\n}\n"),s=(o?s.replace(j,""):s).replace(C,"$1").replace(P,"$1;"),s="function("+g+") {\n"+(y?"":g+" || ("+g+" = {});\n")+"var __t, __p = '', __e = _.escape"+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+s+"return __p\n}";
|
||||
|
||||
var b="\n/*\n//# sourceURL="+(e.sourceURL||"/lodash/template/source["+$++ +"]")+"\n*/";try{var d=Ce(i,"return "+s+b).apply(h,l)}catch(m){throw m.source=s,m}return r?d(r):(d.source=s,d)}function ge(n,r,e){n=(n=+n)>-1?n:0;var t=-1,o=we(n);for(r=en(r,e,1);++t<n;)o[t]=r(t);return o}function he(n){return null==n?"":Ae(n).replace(mt,mn)}function ve(n){var r=++b;return Ae(null==n?"":n)+r}function ye(n){return n=new y(n),n.__chain__=!0,n}function be(n,r){return r(n),n}function de(){return this.__chain__=!0,
|
||||
this}function me(){return Ae(this.__wrapped__)}function _e(){return this.__wrapped__}e=e?un.defaults(nn.Object(),e,un.pick(nn,T)):nn;var we=e.Array,xe=e.Boolean,je=e.Date,ke=e.Error,Ce=e.Function,Pe=e.Math,Ee=e.Number,Oe=e.Object,Se=e.RegExp,Ae=e.String,Ie=e.TypeError,Le=[],Ne=ke.prototype,Re=Oe.prototype,Te=Ae.prototype,De=e._,$e=Re.toString,Fe=Se("^"+Ae($e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Be=Pe.ceil,He=e.clearTimeout,We=Pe.floor,qe=Ce.prototype.toString,ze=bn(ze=Oe.getPrototypeOf)&&ze,Ke=Re.hasOwnProperty,Ue=Le.push,Me=Re.propertyIsEnumerable,Ve=e.setTimeout,Ge=Le.splice,Je=Le.unshift,Qe=function(){
|
||||
try{var n={},r=bn(r=Oe.defineProperty)&&r,e=r(n,n,n)&&r}catch(t){}return e}(),Xe=bn(Xe=Oe.create)&&Xe,Ye=bn(Ye=we.isArray)&&Ye,Ze=e.isFinite,nt=e.isNaN,rt=bn(rt=Oe.keys)&&rt,et=Pe.max,tt=Pe.min,ot=e.parseInt,ut=Pe.random,at={};at[B]=we,at[H]=xe,at[W]=je,at[z]=Ce,at[U]=Oe,at[K]=Ee,at[M]=Se,at[V]=Ae;var it={};it[B]=it[W]=it[K]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},it[H]=it[V]={constructor:!0,toString:!0,valueOf:!0},it[q]=it[z]=it[M]={constructor:!0,toString:!0},it[U]={constructor:!0
|
||||
},function(){for(var n=D.length;n--;){var r=D[n];for(var e in it)Ke.call(it,e)&&!Ke.call(it[e],r)&&(it[e][r]=!1)}}(),y.prototype=v.prototype;var lt=v.support={};!function(){var n=function(){this.x=1},r={0:1,length:1},t=[];n.prototype={valueOf:1,y:1};for(var o in new n)t.push(o);for(o in arguments);lt.argsClass=$e.call(arguments)==F,lt.argsObject=arguments.constructor==Oe&&!(arguments instanceof we),lt.enumErrorProps=Me.call(Ne,"message")||Me.call(Ne,"name"),lt.enumPrototypes=Me.call(n,"prototype"),
|
||||
lt.funcDecomp=!bn(e.WinRTError)&&N.test(g),lt.funcNames="string"==typeof Ce.name,lt.nonEnumArgs=0!=o,lt.nonEnumShadows=!/valueOf/.test(t),lt.ownLast="x"!=t[0],lt.spliceObjects=(Le.splice.call(r,0,1),!r[0]),lt.unindexedChars="x"[0]+Oe("x")[0]!="xx";try{lt.nodeClass=!($e.call(document)==U&&!({toString:0}+""))}catch(u){lt.nodeClass=!0}}(1),v.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:A,variable:"",imports:{_:v}};var ct=function(n){var r="var index, iterable = "+n.firstArg+", result = "+n.init+";\nif (!iterable) return result;\n"+n.top+";";
|
||||
|
||||
n.array?(r+="\nvar length = iterable.length; index = -1;\nif ("+n.array+") { ",lt.unindexedChars&&(r+="\n if (isString(iterable)) {\n iterable = iterable.split('')\n } "),r+="\n while (++index < length) {\n "+n.loop+";\n }\n}\nelse { "):lt.nonEnumArgs&&(r+="\n var length = iterable.length; index = -1;\n if (length && isArguments(iterable)) {\n while (++index < length) {\n index += '';\n "+n.loop+";\n }\n } else { "),lt.enumPrototypes&&(r+="\n var skipProto = typeof iterable == 'function';\n "),
|
||||
lt.enumErrorProps&&(r+="\n var skipErrorProps = iterable === errorProto || iterable instanceof Error;\n ");var e=[];if(lt.enumPrototypes&&e.push('!(skipProto && index == "prototype")'),lt.enumErrorProps&&e.push('!(skipErrorProps && (index == "message" || index == "name"))'),n.useHas&&n.keys)r+="\n var ownIndex = -1,\n ownProps = objectTypes[typeof iterable] && keys(iterable),\n length = ownProps ? ownProps.length : 0;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n",
|
||||
e.length&&(r+=" if ("+e.join(" && ")+") {\n "),r+=n.loop+"; ",e.length&&(r+="\n }"),r+="\n } ";else if(r+="\n for (index in iterable) {\n",n.useHas&&e.push("hasOwnProperty.call(iterable, index)"),e.length&&(r+=" if ("+e.join(" && ")+") {\n "),r+=n.loop+"; ",e.length&&(r+="\n }"),r+="\n } ",lt.nonEnumShadows){for(r+="\n\n if (iterable !== objectProto) {\n var ctor = iterable.constructor,\n isProto = iterable === (ctor && ctor.prototype),\n className = iterable === stringProto ? stringClass : iterable === errorProto ? errorClass : toString.call(iterable),\n nonEnum = nonEnumProps[className];\n ",
|
||||
k=0;k<7;k++)r+="\n index = '"+n.shadowedProps[k]+"';\n if ((!(isProto && nonEnum[index]) && hasOwnProperty.call(iterable, index))",n.useHas||(r+=" || (!nonEnum[index] && iterable[index] !== objectProto[index])"),r+=") {\n "+n.loop+";\n } ";r+="\n } "}return(n.array||lt.nonEnumArgs)&&(r+="\n}"),r+=n.bottom+";\nreturn result"};Xe||(rn=function(){function n(){}return function(r){if(Fn(r)){n.prototype=r;var t=new n;n.prototype=null}return t||e.Object()}}());var ft=Qe?function(n,r){
|
||||
Q.value=r,Qe(n,"__bindData__",Q),Q.value=null}:le;lt.argsClass||(_n=function(n){return n&&"object"==typeof n&&"number"==typeof n.length&&Ke.call(n,"callee")&&!Me.call(n,"callee")||!1});var st=Ye||function(n){return n&&"object"==typeof n&&"number"==typeof n.length&&$e.call(n)==B||!1},pt=hn({args:"object",init:"[]",top:"if (!(objectTypes[typeof object])) return result",loop:"result.push(index)"}),gt=rt?function(n){return Fn(n)?lt.enumPrototypes&&"function"==typeof n||lt.nonEnumArgs&&n.length&&_n(n)?pt(n):rt(n):[];
|
||||
|
||||
}:pt,ht={args:"collection, callback, thisArg",top:"callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)",array:"typeof length == 'number'",keys:gt,loop:"if (callback(iterable[index], index, collection) === false) return result"},vt={args:"object, source, guard",top:"var args = arguments,\n argsIndex = 0,\n argsLength = typeof guard == 'number' ? 2 : args.length;\nwhile (++argsIndex < argsLength) {\n iterable = args[argsIndex];\n if (iterable && objectTypes[typeof iterable]) {",
|
||||
keys:gt,loop:"if (typeof result[index] == 'undefined') result[index] = iterable[index]",bottom:" }\n}"},yt={top:"if (!objectTypes[typeof iterable]) return result;\n"+ht.top,array:!1},bt={"&":"&","<":"<",">":">",'"':""","'":"'"},dt=An(bt),mt=Se("("+gt(dt).join("|")+")","g"),_t=Se("["+gt(bt).join("")+"]","g"),wt=hn(ht),xt=hn(vt,{top:vt.top.replace(";",";\nif (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2);\n} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n callback = args[--argsLength];\n}"),
|
||||
loop:"result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]"}),jt=hn(vt),kt=hn(ht,yt,{useHas:!1}),Ct=hn(ht,yt);$n(/x/)&&($n=function(n){return"function"==typeof n&&$e.call(n)==z});var Pt=ze?function(n){if(!n||$e.call(n)!=U||!lt.argsClass&&_n(n))return!1;var r=n.valueOf,e=bn(r)&&(e=ze(r))&&ze(e);return e?n==e||ze(n)==e:dn(n)}:dn,Et=pn(function(n,r,e){Ke.call(n,e)?n[e]++:n[e]=1}),Ot=pn(function(n,r,e){(Ke.call(n,e)?n[e]:n[e]=[]).push(r)}),St=pn(function(n,r,e){n[e]=r;
|
||||
|
||||
}),At=ir,It=rr,Lt=bn(Lt=je.now)&&Lt||function(){return(new je).getTime()},Nt=8==ot(x+"08")?ot:function(n,r){return ot(zn(n)?n.replace(I,""):n,r||0)};return v.after=Wr,v.assign=xt,v.at=Yn,v.bind=qr,v.bindAll=zr,v.bindKey=Kr,v.chain=ye,v.compact=mr,v.compose=Ur,v.constant=ee,v.countBy=Et,v.create=jn,v.createCallback=te,v.curry=Mr,v.debounce=Vr,v.defaults=jt,v.defer=Gr,v.delay=Jr,v.difference=_r,v.filter=rr,v.flatten=kr,v.forEach=or,v.forEachRight=ur,v.forIn=kt,v.forInRight=Pn,v.forOwn=Ct,v.forOwnRight=En,
|
||||
v.functions=On,v.groupBy=Ot,v.indexBy=St,v.initial=Pr,v.intersection=Er,v.invert=An,v.invoke=ar,v.keys=gt,v.map=ir,v.mapValues=Un,v.max=lr,v.memoize=Qr,v.merge=Mn,v.min=cr,v.omit=Vn,v.once=Xr,v.pairs=Gn,v.partial=Yr,v.partialRight=Zr,v.pick=Jn,v.pluck=At,v.property=ce,v.pull=Ar,v.range=Ir,v.reject=pr,v.remove=Lr,v.rest=Nr,v.shuffle=hr,v.sortBy=br,v.tap=be,v.throttle=ne,v.times=ge,v.toArray=dr,v.transform=Qn,v.union=Tr,v.uniq=Dr,v.values=Xn,v.where=It,v.without=$r,v.wrap=re,v.xor=Fr,v.zip=Br,v.zipObject=Hr,
|
||||
v.collect=ir,v.drop=Nr,v.each=or,v.eachRight=ur,v.extend=xt,v.methods=On,v.object=Hr,v.select=rr,v.tail=Nr,v.unique=Dr,v.unzip=Br,ae(v),v.clone=wn,v.cloneDeep=xn,v.contains=Zn,v.escape=oe,v.every=nr,v.find=er,v.findIndex=wr,v.findKey=kn,v.findLast=tr,v.findLastIndex=xr,v.findLastKey=Cn,v.has=Sn,v.identity=ue,v.indexOf=Cr,v.isArguments=_n,v.isArray=st,v.isBoolean=In,v.isDate=Ln,v.isElement=Nn,v.isEmpty=Rn,v.isEqual=Tn,v.isFinite=Dn,v.isFunction=$n,v.isNaN=Bn,v.isNull=Hn,v.isNumber=Wn,v.isObject=Fn,
|
||||
v.isPlainObject=Pt,v.isRegExp=qn,v.isString=zn,v.isUndefined=Kn,v.lastIndexOf=Sr,v.mixin=ae,v.noConflict=ie,v.noop=le,v.now=Lt,v.parseInt=Nt,v.random=fe,v.reduce=fr,v.reduceRight=sr,v.result=se,v.runInContext=g,v.size=vr,v.some=yr,v.sortedIndex=Rr,v.template=pe,v.unescape=he,v.uniqueId=ve,v.all=nr,v.any=yr,v.detect=er,v.findWhere=er,v.foldl=fr,v.foldr=sr,v.include=Zn,v.inject=fr,ae(function(){var n={};return Ct(v,function(r,e){v.prototype[e]||(n[e]=r)}),n}(),!1),v.first=jr,v.last=Or,v.sample=gr,v.take=jr,
|
||||
v.head=jr,Ct(v,function(n,r){var e="sample"!==r;v.prototype[r]||(v.prototype[r]=function(r,t){var o=this.__chain__,u=n(this.__wrapped__,r,t);return o||null!=r&&(!t||e&&"function"==typeof r)?new y(u,o):u})}),v.VERSION="2.4.2",v.prototype.chain=de,v.prototype.toString=me,v.prototype.value=_e,v.prototype.valueOf=_e,wt(["join","pop","shift"],function(n){var r=Le[n];v.prototype[n]=function(){var n=this.__chain__,e=r.apply(this.__wrapped__,arguments);return n?new y(e,n):e}}),wt(["push","reverse","sort","unshift"],function(n){
|
||||
var r=Le[n];v.prototype[n]=function(){return r.apply(this.__wrapped__,arguments),this}}),wt(["concat","slice","splice"],function(n){var r=Le[n];v.prototype[n]=function(){return new y(r.apply(this.__wrapped__,arguments),this.__chain__)}}),lt.spliceObjects||wt(["pop","shift","splice"],function(n){var r=Le[n],e="splice"==n;v.prototype[n]=function(){var n=this.__chain__,t=this.__wrapped__,o=r.apply(t,arguments);return 0===t.length&&delete t[0],n||e?new y(o,n):o}}),v}var h,v=[],y=[],b=0,d={},m=+new Date+"",_=75,w=40,x=" \f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",j=/\b__p \+= '';/g,C=/\b(__p \+=) '' \+/g,P=/(__e\(.*?\)|\b__t\)) \+\n'';/g,E=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,O=/\w*$/,S=/^\s*function[ \n\r\t]+\w/,A=/<%=([\s\S]+?)%>/g,I=RegExp("^["+x+"]*0+(?=.$)"),L=/($^)/,N=/\bthis\b/,R=/['\n\r\t\u2028\u2029\\]/g,T=["Array","Boolean","Date","Error","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"],D=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],$=0,F="[object Arguments]",B="[object Array]",H="[object Boolean]",W="[object Date]",q="[object Error]",z="[object Function]",K="[object Number]",U="[object Object]",M="[object RegExp]",V="[object String]",G={};
|
||||
|
||||
G[z]=!1,G[F]=G[B]=G[H]=G[W]=G[K]=G[U]=G[M]=G[V]=!0;var J={leading:!1,maxWait:0,trailing:!1},Q={configurable:!1,enumerable:!1,value:null,writable:!1},X={args:"",array:null,bottom:"",firstArg:"",init:"",keys:null,loop:"",shadowedProps:null,support:null,top:"",useHas:!1},Y={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},nn=Y[typeof window]&&window||this,rn=Y[typeof exports]&&exports&&!exports.nodeType&&exports,en=Y[typeof module]&&module&&!module.nodeType&&module,tn=en&&en.exports===rn&&rn,on=Y[typeof global]&&global;
|
||||
|
||||
!on||on.global!==on&&on.window!==on||(nn=on);var un=g();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(nn._=un,define(function(){return un})):rn&&en?tn?(en.exports=un)._=un:rn._=un:nn._=un}).call(this);
|
||||
6786
dist/lodash.js
vendored
Normal file
6786
dist/lodash.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
87
dist/lodash.min.js
vendored
Normal file
87
dist/lodash.min.js
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @license
|
||||
* Lo-Dash 2.4.2 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE
|
||||
* Build: `lodash modern -o ./dist/lodash.js`
|
||||
*/
|
||||
;(function(){function n(n,r,t){for(var e=(t||0)-1,u=n?n.length:0;++e<u;)if(n[e]===r)return e;return-1}function r(r,t){var e=typeof t;if(r=r.cache,"boolean"==e||null==t)return r[t]?0:-1;"number"!=e&&"string"!=e&&(e="object");var u="number"==e?t:m+t;return r=(r=r[e])&&r[u],"object"==e?r&&n(r,t)>-1?0:-1:r?0:-1}function t(n){var r=this.cache,t=typeof n;if("boolean"==t||null==n)r[n]=!0;else{"number"!=t&&"string"!=t&&(t="object");var e="number"==t?n:m+n,u=r[t]||(r[t]={});"object"==t?(u[e]||(u[e]=[])).push(n):u[e]=!0;
|
||||
|
||||
}}function e(n){return n.charCodeAt(0)}function u(n,r){for(var t=n.criteria,e=r.criteria,u=-1,o=t.length;++u<o;){var a=t[u],i=e[u];if(a!==i){if(a>i||"undefined"==typeof a)return 1;if(a<i||"undefined"==typeof i)return-1}}return n.index-r.index}function o(n){var r=-1,e=n.length,u=n[0],o=n[e/2|0],a=n[e-1];if(u&&"object"==typeof u&&o&&"object"==typeof o&&a&&"object"==typeof a)return!1;var i=f();i["false"]=i["null"]=i["true"]=i.undefined=!1;var l=f();for(l.array=n,l.cache=i,l.push=t;++r<e;)l.push(n[r]);
|
||||
|
||||
return l}function a(n){return"\\"+G[n]}function i(){return h.pop()||[]}function f(){return g.pop()||{array:null,cache:null,criteria:null,"false":!1,index:0,"null":!1,number:null,object:null,push:null,string:null,"true":!1,undefined:!1,value:null}}function l(n){n.length=0,h.length<_&&h.push(n)}function c(n){var r=n.cache;r&&c(r),n.array=n.cache=n.criteria=n.object=n.number=n.string=n.value=null,g.length<_&&g.push(n)}function p(n,r,t){r||(r=0),"undefined"==typeof t&&(t=n?n.length:0);for(var e=-1,u=t-r||0,o=Array(u<0?0:u);++e<u;)o[e]=n[r+e];
|
||||
|
||||
return o}function s(t){function h(n){return n&&"object"==typeof n&&!Yt(n)&&Tt.call(n,"__wrapped__")?n:new g(n)}function g(n,r){this.__chain__=!!r,this.__wrapped__=n}function _(n){function r(){if(e){var n=p(e);$t.apply(n,arguments)}if(this instanceof r){var o=J(t.prototype),a=t.apply(o,n||arguments);return Sn(a)?a:o}return t.apply(u,n||arguments)}var t=n[0],e=n[2],u=n[4];return Xt(r,n),r}function G(n,r,t,e,u){if(t){var o=t(n);if("undefined"!=typeof o)return o}var a=Sn(n);if(!a)return n;var f=Nt.call(n);
|
||||
|
||||
if(!K[f])return n;var c=Jt[f];switch(f){case F:case B:return new c(+n);case q:case P:return new c(n);case L:return o=c(n.source,C.exec(n)),o.lastIndex=n.lastIndex,o}var s=Yt(n);if(r){var v=!e;e||(e=i()),u||(u=i());for(var h=e.length;h--;)if(e[h]==n)return u[h];o=s?c(n.length):{}}else o=s?p(n):oe({},n);return s&&(Tt.call(n,"index")&&(o.index=n.index),Tt.call(n,"input")&&(o.input=n.input)),r?(e.push(n),u.push(o),(s?Xn:fe)(n,function(n,a){o[a]=G(n,r,t,e,u)}),v&&(l(e),l(u)),o):o}function J(n,r){return Sn(n)?zt(n):{};
|
||||
|
||||
}function Q(n,r,t){if("function"!=typeof n)return Yr;if("undefined"==typeof r||!("prototype"in n))return n;var e=n.__bindData__;if("undefined"==typeof e&&(Qt.funcNames&&(e=!n.name),e=e||!Qt.funcDecomp,!e)){var u=At.call(n);Qt.funcNames||(e=!O.test(u)),e||(e=I.test(u),Xt(n,e))}if(e===!1||e!==!0&&1&e[1])return n;switch(t){case 1:return function(t){return n.call(r,t)};case 2:return function(t,e){return n.call(r,t,e)};case 3:return function(t,e,u){return n.call(r,t,e,u)};case 4:return function(t,e,u,o){
|
||||
return n.call(r,t,e,u,o)}}return $r(n,r)}function X(n){function r(){var n=f?a:this;if(u){var h=p(u);$t.apply(h,arguments)}if((o||c)&&(h||(h=p(arguments)),o&&$t.apply(h,o),c&&h.length<i))return e|=16,X([t,s?e:-4&e,h,null,a,i]);if(h||(h=arguments),l&&(t=n[v]),this instanceof r){n=J(t.prototype);var g=t.apply(n,h);return Sn(g)?g:n}return t.apply(n,h)}var t=n[0],e=n[1],u=n[2],o=n[3],a=n[4],i=n[5],f=1&e,l=2&e,c=4&e,s=8&e,v=t;return Xt(r,n),r}function Y(t,e){var u=-1,a=ln(),i=t?t.length:0,f=i>=b&&a===n,l=[];
|
||||
|
||||
if(f){var p=o(e);p?(a=r,e=p):f=!1}for(;++u<i;){var s=t[u];a(e,s)<0&&l.push(s)}return f&&c(e),l}function nn(n,r,t,e){for(var u=(e||0)-1,o=n?n.length:0,a=[];++u<o;){var i=n[u];if(i&&"object"==typeof i&&"number"==typeof i.length&&(Yt(i)||vn(i))){r||(i=nn(i,r,t));var f=-1,l=i.length,c=a.length;for(a.length+=l;++f<l;)a[c++]=i[f]}else t||a.push(i)}return a}function rn(n,r,t,e,u,o){if(t){var a=t(n,r);if("undefined"!=typeof a)return!!a}if(n===r)return 0!==n||1/n==1/r;var f=typeof n,c=typeof r;if(n===n&&(!n||!V[f])&&(!r||!V[c]))return!1;
|
||||
|
||||
if(null==n||null==r)return n===r;var p=Nt.call(n),s=Nt.call(r);if(p==T&&(p=z),s==T&&(s=z),p!=s)return!1;switch(p){case F:case B:return+n==+r;case q:return n!=+n?r!=+r:0==n?1/n==1/r:n==+r;case L:case P:return n==jt(r)}var h=p==$;if(!h){var g=Tt.call(n,"__wrapped__"),y=Tt.call(r,"__wrapped__");if(g||y)return rn(g?n.__wrapped__:n,y?r.__wrapped__:r,t,e,u,o);if(p!=z)return!1;var m=n.constructor,b=r.constructor;if(m!=b&&!(In(m)&&m instanceof m&&In(b)&&b instanceof b)&&"constructor"in n&&"constructor"in r)return!1;
|
||||
|
||||
}var _=!u;u||(u=i()),o||(o=i());for(var d=u.length;d--;)if(u[d]==n)return o[d]==r;var w=0;if(a=!0,u.push(n),o.push(r),h){if(d=n.length,w=r.length,a=w==d,a||e)for(;w--;){var j=d,k=r[w];if(e)for(;j--&&!(a=rn(n[j],k,t,e,u,o)););else if(!(a=rn(n[w],k,t,e,u,o)))break}}else ie(r,function(r,i,f){return Tt.call(f,i)?(w++,a=Tt.call(n,i)&&rn(n[i],r,t,e,u,o)):v}),a&&!e&&ie(n,function(n,r,t){return Tt.call(t,r)?a=--w>-1:v});return u.pop(),o.pop(),_&&(l(u),l(o)),a}function tn(n,r,t,e,u){(Yt(r)?Xn:fe)(r,function(r,o){
|
||||
var a,i,f=r,l=n[o];if(r&&((i=Yt(r))||le(r))){for(var c=e.length;c--;)if(a=e[c]==r){l=u[c];break}if(!a){var p;t&&(f=t(l,r),(p="undefined"!=typeof f)&&(l=f)),p||(l=i?Yt(l)?l:[]:le(l)?l:{}),e.push(r),u.push(l),p||tn(l,r,t,e,u)}}else t&&(f=t(l,r),"undefined"==typeof f&&(f=r)),"undefined"!=typeof f&&(l=f);n[o]=l})}function en(n,r){return n+St(Ht()*(r-n+1))}function un(t,e,u){var a=-1,f=ln(),p=t?t.length:0,s=[],v=!e&&p>=b&&f===n,h=u||v?i():s;if(v){var g=o(h);f=r,h=g}for(;++a<p;){var y=t[a],m=u?u(y,a,t):y;
|
||||
|
||||
(e?!a||h[h.length-1]!==m:f(h,m)<0)&&((u||v)&&h.push(m),s.push(y))}return v?(l(h.array),c(h)):u&&l(h),s}function on(n){return function(r,t,e){var u={};t=h.createCallback(t,e,3);var o=-1,a=r?r.length:0;if("number"==typeof a)for(;++o<a;){var i=r[o];n(u,i,t(i,o,r),r)}else fe(r,function(r,e,o){n(u,r,t(r,e,o),o)});return u}}function an(n,r,t,e,u,o){var a=1&r,i=2&r,f=4&r,l=16&r,c=32&r;if(!i&&!In(n))throw new kt;l&&!t.length&&(r&=-17,l=t=!1),c&&!e.length&&(r&=-33,c=e=!1);var s=n&&n.__bindData__;if(s&&s!==!0)return s=p(s),
|
||||
s[2]&&(s[2]=p(s[2])),s[3]&&(s[3]=p(s[3])),!a||1&s[1]||(s[4]=u),!a&&1&s[1]&&(r|=8),!f||4&s[1]||(s[5]=o),l&&$t.apply(s[2]||(s[2]=[]),t),c&&Wt.apply(s[3]||(s[3]=[]),e),s[1]|=r,an.apply(null,s);var v=1==r||17===r?_:X;return v([n,r,t,e,u,o])}function fn(n){return re[n]}function ln(){var r=(r=h.indexOf)===br?n:r;return r}function cn(n){return"function"==typeof n&&Rt.test(n)}function pn(n){var r,t;return n&&Nt.call(n)==z&&(r=n.constructor,!In(r)||r instanceof r)?(ie(n,function(n,r){t=r}),"undefined"==typeof t||Tt.call(n,t)):!1;
|
||||
|
||||
}function sn(n){return te[n]}function vn(n){return n&&"object"==typeof n&&"number"==typeof n.length&&Nt.call(n)==T||!1}function hn(n,r,t,e){return"boolean"!=typeof r&&null!=r&&(e=t,t=r,r=!1),G(n,r,"function"==typeof t&&Q(t,e,1))}function gn(n,r,t){return G(n,!0,"function"==typeof r&&Q(r,t,1))}function yn(n,r){var t=J(n);return r?oe(t,r):t}function mn(n,r,t){var e;return r=h.createCallback(r,t,3),fe(n,function(n,t,u){return r(n,t,u)?(e=t,!1):v}),e}function bn(n,r,t){var e;return r=h.createCallback(r,t,3),
|
||||
dn(n,function(n,t,u){return r(n,t,u)?(e=t,!1):v}),e}function _n(n,r,t){var e=[];ie(n,function(n,r){e.push(r,n)});var u=e.length;for(r=Q(r,t,3);u--&&r(e[u--],e[u],n)!==!1;);return n}function dn(n,r,t){var e=ne(n),u=e.length;for(r=Q(r,t,3);u--;){var o=e[u];if(r(n[o],o,n)===!1)break}return n}function wn(n){var r=[];return ie(n,function(n,t){In(n)&&r.push(t)}),r.sort()}function jn(n,r){return n?Tt.call(n,r):!1}function kn(n){for(var r=-1,t=ne(n),e=t.length,u={};++r<e;){var o=t[r];u[n[o]]=o}return u}function xn(n){
|
||||
return n===!0||n===!1||n&&"object"==typeof n&&Nt.call(n)==F||!1}function Cn(n){return n&&"object"==typeof n&&Nt.call(n)==B||!1}function On(n){return n&&1===n.nodeType||!1}function Nn(n){var r=!0;if(!n)return r;var t=Nt.call(n),e=n.length;return t==$||t==P||t==T||t==z&&"number"==typeof e&&In(n.splice)?!e:(fe(n,function(){return r=!1}),r)}function Rn(n,r,t,e){return rn(n,r,"function"==typeof t&&Q(t,e,2))}function En(n){return Pt(n)&&!Kt(parseFloat(n))}function In(n){return"function"==typeof n}function Sn(n){
|
||||
return!(!n||!V[typeof n])}function An(n){return Tn(n)&&n!=+n}function Dn(n){return null===n}function Tn(n){return"number"==typeof n||n&&"object"==typeof n&&Nt.call(n)==q||!1}function $n(n){return n&&"object"==typeof n&&Nt.call(n)==L||!1}function Fn(n){return"string"==typeof n||n&&"object"==typeof n&&Nt.call(n)==P||!1}function Bn(n){return"undefined"==typeof n}function Wn(n,r,t){var e={};return r=h.createCallback(r,t,3),fe(n,function(n,t,u){e[t]=r(n,t,u)}),e}function qn(n){var r=arguments,t=2;if(!Sn(n))return n;
|
||||
|
||||
if("number"!=typeof r[2]&&(t=r.length),t>3&&"function"==typeof r[t-2])var e=Q(r[--t-1],r[t--],2);else t>2&&"function"==typeof r[t-1]&&(e=r[--t]);for(var u=p(arguments,1,t),o=-1,a=i(),f=i();++o<t;)tn(n,u[o],e,a,f);return l(a),l(f),n}function zn(n,r,t){var e={};if("function"!=typeof r){var u=[];ie(n,function(n,r){u.push(r)}),u=Y(u,nn(arguments,!0,!1,1));for(var o=-1,a=u.length;++o<a;){var i=u[o];e[i]=n[i]}}else r=h.createCallback(r,t,3),ie(n,function(n,t,u){r(n,t,u)||(e[t]=n)});return e}function Ln(n){
|
||||
for(var r=-1,t=ne(n),e=t.length,u=ht(e);++r<e;){var o=t[r];u[r]=[o,n[o]]}return u}function Pn(n,r,t){var e={};if("function"!=typeof r)for(var u=-1,o=nn(arguments,!0,!1,1),a=Sn(n)?o.length:0;++u<a;){var i=o[u];i in n&&(e[i]=n[i])}else r=h.createCallback(r,t,3),ie(n,function(n,t,u){r(n,t,u)&&(e[t]=n)});return e}function Kn(n,r,t,e){var u=Yt(n);if(null==t)if(u)t=[];else{var o=n&&n.constructor,a=o&&o.prototype;t=J(a)}return r&&(r=h.createCallback(r,e,4),(u?Xn:fe)(n,function(n,e,u){return r(t,n,e,u)})),
|
||||
t}function Un(n){for(var r=-1,t=ne(n),e=t.length,u=ht(e);++r<e;)u[r]=n[t[r]];return u}function Mn(n){for(var r=arguments,t=-1,e=nn(r,!0,!1,1),u=r[2]&&r[2][r[1]]===n?1:e.length,o=ht(u);++t<u;)o[t]=n[e[t]];return o}function Vn(n,r,t){var e=-1,u=ln(),o=n?n.length:0,a=!1;return t=(t<0?Mt(0,o+t):t)||0,Yt(n)?a=u(n,r,t)>-1:"number"==typeof o?a=(Fn(n)?n.indexOf(r,t):u(n,r,t))>-1:fe(n,function(n){return++e<t?v:!(a=n===r)}),a}function Gn(n,r,t){var e=!0;r=h.createCallback(r,t,3);var u=-1,o=n?n.length:0;if("number"==typeof o)for(;++u<o&&(e=!!r(n[u],u,n)););else fe(n,function(n,t,u){
|
||||
return e=!!r(n,t,u)});return e}function Hn(n,r,t){var e=[];r=h.createCallback(r,t,3);var u=-1,o=n?n.length:0;if("number"==typeof o)for(;++u<o;){var a=n[u];r(a,u,n)&&e.push(a)}else fe(n,function(n,t,u){r(n,t,u)&&e.push(n)});return e}function Jn(n,r,t){r=h.createCallback(r,t,3);var e=-1,u=n?n.length:0;if("number"!=typeof u){var o;return fe(n,function(n,t,e){return r(n,t,e)?(o=n,!1):v}),o}for(;++e<u;){var a=n[e];if(r(a,e,n))return a}}function Qn(n,r,t){var e;return r=h.createCallback(r,t,3),Yn(n,function(n,t,u){
|
||||
return r(n,t,u)?(e=n,!1):v}),e}function Xn(n,r,t){var e=-1,u=n?n.length:0;if(r=r&&"undefined"==typeof t?r:Q(r,t,3),"number"==typeof u)for(;++e<u&&r(n[e],e,n)!==!1;);else fe(n,r);return n}function Yn(n,r,t){var e=n?n.length:0;if(r=r&&"undefined"==typeof t?r:Q(r,t,3),"number"==typeof e)for(;e--&&r(n[e],e,n)!==!1;);else{var u=ne(n);e=u.length,fe(n,function(n,t,o){return t=u?u[--e]:--e,r(o[t],t,o)})}return n}function Zn(n,r){var t=p(arguments,2),e=-1,u="function"==typeof r,o=n?n.length:0,a=ht("number"==typeof o?o:0);
|
||||
|
||||
return Xn(n,function(n){a[++e]=(u?r:n[r]).apply(n,t)}),a}function nr(n,r,t){var e=-1,u=n?n.length:0;if(r=h.createCallback(r,t,3),"number"==typeof u)for(var o=ht(u);++e<u;)o[e]=r(n[e],e,n);else o=[],fe(n,function(n,t,u){o[++e]=r(n,t,u)});return o}function rr(n,r,t){var u=-(1/0),o=u;if("function"!=typeof r&&t&&t[r]===n&&(r=null),null==r&&Yt(n))for(var a=-1,i=n.length;++a<i;){var f=n[a];f>o&&(o=f)}else r=null==r&&Fn(n)?e:h.createCallback(r,t,3),Xn(n,function(n,t,e){var a=r(n,t,e);a>u&&(u=a,o=n)});return o;
|
||||
|
||||
}function tr(n,r,t){var u=1/0,o=u;if("function"!=typeof r&&t&&t[r]===n&&(r=null),null==r&&Yt(n))for(var a=-1,i=n.length;++a<i;){var f=n[a];f<o&&(o=f)}else r=null==r&&Fn(n)?e:h.createCallback(r,t,3),Xn(n,function(n,t,e){var a=r(n,t,e);a<u&&(u=a,o=n)});return o}function er(n,r,t,e){if(!n)return t;var u=arguments.length<3;r=h.createCallback(r,e,4);var o=-1,a=n.length;if("number"==typeof a)for(u&&(t=n[++o]);++o<a;)t=r(t,n[o],o,n);else fe(n,function(n,e,o){t=u?(u=!1,n):r(t,n,e,o)});return t}function ur(n,r,t,e){
|
||||
var u=arguments.length<3;return r=h.createCallback(r,e,4),Yn(n,function(n,e,o){t=u?(u=!1,n):r(t,n,e,o)}),t}function or(n,r,t){return r=h.createCallback(r,t,3),Hn(n,function(n,t,e){return!r(n,t,e)})}function ar(n,r,t){if(n&&"number"!=typeof n.length&&(n=Un(n)),null==r||t)return n?n[en(0,n.length-1)]:v;var e=ir(n);return e.length=Vt(Mt(0,r),e.length),e}function ir(n){var r=-1,t=n?n.length:0,e=ht("number"==typeof t?t:0);return Xn(n,function(n){var t=en(0,++r);e[r]=e[t],e[t]=n}),e}function fr(n){var r=n?n.length:0;
|
||||
|
||||
return"number"==typeof r?r:ne(n).length}function lr(n,r,t){var e;r=h.createCallback(r,t,3);var u=-1,o=n?n.length:0;if("number"==typeof o)for(;++u<o&&!(e=r(n[u],u,n)););else fe(n,function(n,t,u){return!(e=r(n,t,u))});return!!e}function cr(n,r,t){var e=-1,o=Yt(r),a=n?n.length:0,p=ht("number"==typeof a?a:0);for(o||(r=h.createCallback(r,t,3)),Xn(n,function(n,t,u){var a=p[++e]=f();o?a.criteria=nr(r,function(r){return n[r]}):(a.criteria=i())[0]=r(n,t,u),a.index=e,a.value=n}),a=p.length,p.sort(u);a--;){
|
||||
var s=p[a];p[a]=s.value,o||l(s.criteria),c(s)}return p}function pr(n){return n&&"number"==typeof n.length?p(n):Un(n)}function sr(n){for(var r=-1,t=n?n.length:0,e=[];++r<t;){var u=n[r];u&&e.push(u)}return e}function vr(n){return Y(n,nn(arguments,!0,!0,1))}function hr(n,r,t){var e=-1,u=n?n.length:0;for(r=h.createCallback(r,t,3);++e<u;)if(r(n[e],e,n))return e;return-1}function gr(n,r,t){var e=n?n.length:0;for(r=h.createCallback(r,t,3);e--;)if(r(n[e],e,n))return e;return-1}function yr(n,r,t){var e=0,u=n?n.length:0;
|
||||
|
||||
if("number"!=typeof r&&null!=r){var o=-1;for(r=h.createCallback(r,t,3);++o<u&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n?n[0]:v;return p(n,0,Vt(Mt(0,e),u))}function mr(n,r,t,e){return"boolean"!=typeof r&&null!=r&&(e=t,t="function"!=typeof r&&e&&e[r]===n?null:r,r=!1),null!=t&&(n=nr(n,t,e)),nn(n,r)}function br(r,t,e){if("number"==typeof e){var u=r?r.length:0;e=e<0?Mt(0,u+e):e||0}else if(e){var o=Nr(r,t);return r[o]===t?o:-1}return n(r,t,e)}function _r(n,r,t){var e=0,u=n?n.length:0;if("number"!=typeof r&&null!=r){
|
||||
var o=u;for(r=h.createCallback(r,t,3);o--&&r(n[o],o,n);)e++}else e=null==r||t?1:r||e;return p(n,0,Vt(Mt(0,u-e),u))}function dr(){for(var t=[],e=-1,u=arguments.length,a=i(),f=ln(),p=f===n,s=i();++e<u;){var v=arguments[e];(Yt(v)||vn(v))&&(t.push(v),a.push(p&&v.length>=b&&o(e?t[e]:s)))}var h=t[0],g=-1,y=h?h.length:0,m=[];n:for(;++g<y;){var _=a[0];if(v=h[g],(_?r(_,v):f(s,v))<0){for(e=u,(_||s).push(v);--e;)if(_=a[e],(_?r(_,v):f(t[e],v))<0)continue n;m.push(v)}}for(;u--;)_=a[u],_&&c(_);return l(a),l(s),
|
||||
m}function wr(n,r,t){var e=0,u=n?n.length:0;if("number"!=typeof r&&null!=r){var o=u;for(r=h.createCallback(r,t,3);o--&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n?n[u-1]:v;return p(n,Mt(0,u-e))}function jr(n,r,t){var e=n?n.length:0;for("number"==typeof t&&(e=(t<0?Mt(0,e+t):Vt(t,e-1))+1);e--;)if(n[e]===r)return e;return-1}function kr(n){for(var r=arguments,t=0,e=r.length,u=n?n.length:0;++t<e;)for(var o=-1,a=r[t];++o<u;)n[o]===a&&(Bt.call(n,o--,1),u--);return n}function xr(n,r,t){n=+n||0,t="number"==typeof t?t:+t||1,
|
||||
null==r&&(r=n,n=0);for(var e=-1,u=Mt(0,Et((r-n)/(t||1))),o=ht(u);++e<u;)o[e]=n,n+=t;return o}function Cr(n,r,t){var e=-1,u=n?n.length:0,o=[];for(r=h.createCallback(r,t,3);++e<u;){var a=n[e];r(a,e,n)&&(o.push(a),Bt.call(n,e--,1),u--)}return o}function Or(n,r,t){if("number"!=typeof r&&null!=r){var e=0,u=-1,o=n?n.length:0;for(r=h.createCallback(r,t,3);++u<o&&r(n[u],u,n);)e++}else e=null==r||t?1:Mt(0,r);return p(n,e)}function Nr(n,r,t,e){var u=0,o=n?n.length:u;for(t=t?h.createCallback(t,e,1):Yr,r=t(r);u<o;){
|
||||
var a=u+o>>>1;t(n[a])<r?u=a+1:o=a}return u}function Rr(){return un(nn(arguments,!0,!0))}function Er(n,r,t,e){return"boolean"!=typeof r&&null!=r&&(e=t,t="function"!=typeof r&&e&&e[r]===n?null:r,r=!1),null!=t&&(t=h.createCallback(t,e,3)),un(n,r,t)}function Ir(n){return Y(n,p(arguments,1))}function Sr(){for(var n=-1,r=arguments.length;++n<r;){var t=arguments[n];if(Yt(t)||vn(t))var e=e?un(Y(e,t).concat(Y(t,e))):t}return e||[]}function Ar(){for(var n=arguments.length>1?arguments:arguments[0],r=-1,t=n?rr(ve(n,"length")):0,e=ht(t<0?0:t);++r<t;)e[r]=ve(n,r);
|
||||
|
||||
return e}function Dr(n,r){var t=-1,e=n?n.length:0,u={};for(r||!e||Yt(n[0])||(r=[]);++t<e;){var o=n[t];r?u[o]=r[t]:o&&(u[o[0]]=o[1])}return u}function Tr(n,r){if(!In(r))throw new kt;return function(){return--n<1?r.apply(this,arguments):v}}function $r(n,r){return arguments.length>2?an(n,17,p(arguments,2),null,r):an(n,1,null,null,r)}function Fr(n){for(var r=arguments.length>1?nn(arguments,!0,!1,1):wn(n),t=-1,e=r.length;++t<e;){var u=r[t];n[u]=an(n[u],1,null,null,n)}return n}function Br(n,r){return arguments.length>2?an(r,19,p(arguments,2),null,n):an(r,3,null,null,n);
|
||||
|
||||
}function Wr(){for(var n=arguments,r=n.length;r--;)if(!In(n[r]))throw new kt;return function(){for(var r=arguments,t=n.length;t--;)r=[n[t].apply(this,r)];return r[0]}}function qr(n,r){return r="number"==typeof r?r:+r||n.length,an(n,4,null,null,null,r)}function zr(n,r,t){var e,u,o,a,i,f,l,c=0,p=!1,s=!0;if(!In(n))throw new kt;if(r=Mt(0,r)||0,t===!0){var h=!0;s=!1}else Sn(t)&&(h=t.leading,p="maxWait"in t&&(Mt(r,t.maxWait)||0),s="trailing"in t?t.trailing:s);var g=function(){var t=r-(ge()-a);if(t>0)f=Ft(g,t);
|
||||
else{u&&It(u);var p=l;u=f=l=v,p&&(c=ge(),o=n.apply(i,e),f||u||(e=i=null))}},y=function(){f&&It(f),u=f=l=v,(s||p!==r)&&(c=ge(),o=n.apply(i,e),f||u||(e=i=null))};return function(){if(e=arguments,a=ge(),i=this,l=s&&(f||!h),p===!1)var t=h&&!f;else{u||h||(c=a);var v=p-(a-c),m=v<=0;m?(u&&(u=It(u)),c=a,o=n.apply(i,e)):u||(u=Ft(y,v))}return m&&f?f=It(f):f||r===p||(f=Ft(g,r)),t&&(m=!0,o=n.apply(i,e)),!m||f||u||(e=i=null),o}}function Lr(n){if(!In(n))throw new kt;var r=p(arguments,1);return Ft(function(){n.apply(v,r);
|
||||
|
||||
},1)}function Pr(n,r){if(!In(n))throw new kt;var t=p(arguments,2);return Ft(function(){n.apply(v,t)},r)}function Kr(n,r){if(!In(n))throw new kt;var t=function(){var e=t.cache,u=r?r.apply(this,arguments):m+arguments[0];return Tt.call(e,u)?e[u]:e[u]=n.apply(this,arguments)};return t.cache={},t}function Ur(n){var r,t;if(!In(n))throw new kt;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}}function Mr(n){return an(n,16,p(arguments,1))}function Vr(n){return an(n,32,null,p(arguments,1));
|
||||
|
||||
}function Gr(n,r,t){var e=!0,u=!0;if(!In(n))throw new kt;return t===!1?e=!1:Sn(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),U.leading=e,U.maxWait=r,U.trailing=u,zr(n,r,U)}function Hr(n,r){return an(r,16,[n])}function Jr(n){return function(){return n}}function Qr(n,r,t){var e=typeof n;if(null==n||"function"==e)return Q(n,r,t);if("object"!=e)return tt(n);var u=ne(n),o=u[0],a=n[o];return 1!=u.length||a!==a||Sn(a)?function(r){for(var t=u.length,e=!1;t--&&(e=rn(r[u[t]],n[u[t]],null,!0)););
|
||||
return e}:function(n){var r=n[o];return a===r&&(0!==a||1/a==1/r)}}function Xr(n){return null==n?"":jt(n).replace(ue,fn)}function Yr(n){return n}function Zr(n,r,t){var e=!0,u=r&&wn(r);r&&(t||u.length)||(null==t&&(t=r),o=g,r=n,n=h,u=wn(r)),t===!1?e=!1:Sn(t)&&"chain"in t&&(e=t.chain);var o=n,a=In(o);Xn(u,function(t){var u=n[t]=r[t];a&&(o.prototype[t]=function(){var r=this.__chain__,t=this.__wrapped__,a=[t];$t.apply(a,arguments);var i=u.apply(n,a);if(e||r){if(t===i&&Sn(i))return this;i=new o(i),i.__chain__=r;
|
||||
|
||||
}return i})})}function nt(){return t._=Ot,this}function rt(){}function tt(n){return function(r){return r[n]}}function et(n,r,t){var e=null==n,u=null==r;if(null==t&&("boolean"==typeof n&&u?(t=n,n=1):u||"boolean"!=typeof r||(t=r,u=!0)),e&&u&&(r=1),n=+n||0,u?(r=n,n=0):r=+r||0,t||n%1||r%1){var o=Ht();return Vt(n+o*(r-n+parseFloat("1e-"+((o+"").length-1))),r)}return en(n,r)}function ut(n,r){if(n){var t=n[r];return In(t)?n[r]():t}}function ot(n,r,t){var e=h.templateSettings;n=jt(n||""),t=ae({},t,e);var u,o=ae({},t.imports,e.imports),i=ne(o),f=Un(o),l=0,c=t.interpolate||E,p="__p += '",s=wt((t.escape||E).source+"|"+c.source+"|"+(c===N?x:E).source+"|"+(t.evaluate||E).source+"|$","g");
|
||||
|
||||
n.replace(s,function(r,t,e,o,i,f){return e||(e=o),p+=n.slice(l,f).replace(S,a),t&&(p+="' +\n__e("+t+") +\n'"),i&&(u=!0,p+="';\n"+i+";\n__p += '"),e&&(p+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),l=f+r.length,r}),p+="';\n";var g=t.variable,y=g;y||(g="obj",p="with ("+g+") {\n"+p+"\n}\n"),p=(u?p.replace(w,""):p).replace(j,"$1").replace(k,"$1;"),p="function("+g+") {\n"+(y?"":g+" || ("+g+" = {});\n")+"var __t, __p = '', __e = _.escape"+(u?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";
|
||||
|
||||
var m="\n/*\n//# sourceURL="+(t.sourceURL||"/lodash/template/source["+D++ +"]")+"\n*/";try{var b=mt(i,"return "+p+m).apply(v,f)}catch(_){throw _.source=p,_}return r?b(r):(b.source=p,b)}function at(n,r,t){n=(n=+n)>-1?n:0;var e=-1,u=ht(n);for(r=Q(r,t,1);++e<n;)u[e]=r(e);return u}function it(n){return null==n?"":jt(n).replace(ee,sn)}function ft(n){var r=++y;return jt(null==n?"":n)+r}function lt(n){return n=new g(n),n.__chain__=!0,n}function ct(n,r){return r(n),n}function pt(){return this.__chain__=!0,
|
||||
this}function st(){return jt(this.__wrapped__)}function vt(){return this.__wrapped__}t=t?Z.defaults(H.Object(),t,Z.pick(H,A)):H;var ht=t.Array,gt=t.Boolean,yt=t.Date,mt=t.Function,bt=t.Math,_t=t.Number,dt=t.Object,wt=t.RegExp,jt=t.String,kt=t.TypeError,xt=[],Ct=dt.prototype,Ot=t._,Nt=Ct.toString,Rt=wt("^"+jt(Nt).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Et=bt.ceil,It=t.clearTimeout,St=bt.floor,At=mt.prototype.toString,Dt=cn(Dt=dt.getPrototypeOf)&&Dt,Tt=Ct.hasOwnProperty,$t=xt.push,Ft=t.setTimeout,Bt=xt.splice,Wt=xt.unshift,qt=function(){
|
||||
try{var n={},r=cn(r=dt.defineProperty)&&r,t=r(n,n,n)&&r}catch(e){}return t}(),zt=cn(zt=dt.create)&&zt,Lt=cn(Lt=ht.isArray)&&Lt,Pt=t.isFinite,Kt=t.isNaN,Ut=cn(Ut=dt.keys)&&Ut,Mt=bt.max,Vt=bt.min,Gt=t.parseInt,Ht=bt.random,Jt={};Jt[$]=ht,Jt[F]=gt,Jt[B]=yt,Jt[W]=mt,Jt[z]=dt,Jt[q]=_t,Jt[L]=wt,Jt[P]=jt,g.prototype=h.prototype;var Qt=h.support={};Qt.funcDecomp=!cn(t.WinRTError)&&I.test(s),Qt.funcNames="string"==typeof mt.name,h.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,
|
||||
variable:"",imports:{_:h}},zt||(J=function(){function n(){}return function(r){if(Sn(r)){n.prototype=r;var e=new n;n.prototype=null}return e||t.Object()}}());var Xt=qt?function(n,r){M.value=r,qt(n,"__bindData__",M),M.value=null}:rt,Yt=Lt||function(n){return n&&"object"==typeof n&&"number"==typeof n.length&&Nt.call(n)==$||!1},Zt=function(n){var r,t=n,e=[];if(!t)return e;if(!V[typeof n])return e;for(r in t)Tt.call(t,r)&&e.push(r);return e},ne=Ut?function(n){return Sn(n)?Ut(n):[]}:Zt,re={"&":"&",
|
||||
"<":"<",">":">",'"':""","'":"'"},te=kn(re),ee=wt("("+ne(te).join("|")+")","g"),ue=wt("["+ne(re).join("")+"]","g"),oe=function(n,r,t){var e,u=n,o=u;if(!u)return o;var a=arguments,i=0,f="number"==typeof t?2:a.length;if(f>3&&"function"==typeof a[f-2])var l=Q(a[--f-1],a[f--],2);else f>2&&"function"==typeof a[f-1]&&(l=a[--f]);for(;++i<f;)if(u=a[i],u&&V[typeof u])for(var c=-1,p=V[typeof u]&&ne(u),s=p?p.length:0;++c<s;)e=p[c],o[e]=l?l(o[e],u[e]):u[e];return o},ae=function(n,r,t){var e,u=n,o=u;
|
||||
|
||||
if(!u)return o;for(var a=arguments,i=0,f="number"==typeof t?2:a.length;++i<f;)if(u=a[i],u&&V[typeof u])for(var l=-1,c=V[typeof u]&&ne(u),p=c?c.length:0;++l<p;)e=c[l],"undefined"==typeof o[e]&&(o[e]=u[e]);return o},ie=function(n,r,t){var e,u=n,o=u;if(!u)return o;if(!V[typeof u])return o;r=r&&"undefined"==typeof t?r:Q(r,t,3);for(e in u)if(r(u[e],e,n)===!1)return o;return o},fe=function(n,r,t){var e,u=n,o=u;if(!u)return o;if(!V[typeof u])return o;r=r&&"undefined"==typeof t?r:Q(r,t,3);for(var a=-1,i=V[typeof u]&&ne(u),f=i?i.length:0;++a<f;)if(e=i[a],
|
||||
r(u[e],e,n)===!1)return o;return o},le=Dt?function(n){if(!n||Nt.call(n)!=z)return!1;var r=n.valueOf,t=cn(r)&&(t=Dt(r))&&Dt(t);return t?n==t||Dt(n)==t:pn(n)}:pn,ce=on(function(n,r,t){Tt.call(n,t)?n[t]++:n[t]=1}),pe=on(function(n,r,t){(Tt.call(n,t)?n[t]:n[t]=[]).push(r)}),se=on(function(n,r,t){n[t]=r}),ve=nr,he=Hn,ge=cn(ge=yt.now)&&ge||function(){return(new yt).getTime()},ye=8==Gt(d+"08")?Gt:function(n,r){return Gt(Fn(n)?n.replace(R,""):n,r||0)};return h.after=Tr,h.assign=oe,h.at=Mn,h.bind=$r,h.bindAll=Fr,
|
||||
h.bindKey=Br,h.chain=lt,h.compact=sr,h.compose=Wr,h.constant=Jr,h.countBy=ce,h.create=yn,h.createCallback=Qr,h.curry=qr,h.debounce=zr,h.defaults=ae,h.defer=Lr,h.delay=Pr,h.difference=vr,h.filter=Hn,h.flatten=mr,h.forEach=Xn,h.forEachRight=Yn,h.forIn=ie,h.forInRight=_n,h.forOwn=fe,h.forOwnRight=dn,h.functions=wn,h.groupBy=pe,h.indexBy=se,h.initial=_r,h.intersection=dr,h.invert=kn,h.invoke=Zn,h.keys=ne,h.map=nr,h.mapValues=Wn,h.max=rr,h.memoize=Kr,h.merge=qn,h.min=tr,h.omit=zn,h.once=Ur,h.pairs=Ln,
|
||||
h.partial=Mr,h.partialRight=Vr,h.pick=Pn,h.pluck=ve,h.property=tt,h.pull=kr,h.range=xr,h.reject=or,h.remove=Cr,h.rest=Or,h.shuffle=ir,h.sortBy=cr,h.tap=ct,h.throttle=Gr,h.times=at,h.toArray=pr,h.transform=Kn,h.union=Rr,h.uniq=Er,h.values=Un,h.where=he,h.without=Ir,h.wrap=Hr,h.xor=Sr,h.zip=Ar,h.zipObject=Dr,h.collect=nr,h.drop=Or,h.each=Xn,h.eachRight=Yn,h.extend=oe,h.methods=wn,h.object=Dr,h.select=Hn,h.tail=Or,h.unique=Er,h.unzip=Ar,Zr(h),h.clone=hn,h.cloneDeep=gn,h.contains=Vn,h.escape=Xr,h.every=Gn,
|
||||
h.find=Jn,h.findIndex=hr,h.findKey=mn,h.findLast=Qn,h.findLastIndex=gr,h.findLastKey=bn,h.has=jn,h.identity=Yr,h.indexOf=br,h.isArguments=vn,h.isArray=Yt,h.isBoolean=xn,h.isDate=Cn,h.isElement=On,h.isEmpty=Nn,h.isEqual=Rn,h.isFinite=En,h.isFunction=In,h.isNaN=An,h.isNull=Dn,h.isNumber=Tn,h.isObject=Sn,h.isPlainObject=le,h.isRegExp=$n,h.isString=Fn,h.isUndefined=Bn,h.lastIndexOf=jr,h.mixin=Zr,h.noConflict=nt,h.noop=rt,h.now=ge,h.parseInt=ye,h.random=et,h.reduce=er,h.reduceRight=ur,h.result=ut,h.runInContext=s,
|
||||
h.size=fr,h.some=lr,h.sortedIndex=Nr,h.template=ot,h.unescape=it,h.uniqueId=ft,h.all=Gn,h.any=lr,h.detect=Jn,h.findWhere=Jn,h.foldl=er,h.foldr=ur,h.include=Vn,h.inject=er,Zr(function(){var n={};return fe(h,function(r,t){h.prototype[t]||(n[t]=r)}),n}(),!1),h.first=yr,h.last=wr,h.sample=ar,h.take=yr,h.head=yr,fe(h,function(n,r){var t="sample"!==r;h.prototype[r]||(h.prototype[r]=function(r,e){var u=this.__chain__,o=n(this.__wrapped__,r,e);return u||null!=r&&(!e||t&&"function"==typeof r)?new g(o,u):o;
|
||||
|
||||
})}),h.VERSION="2.4.2",h.prototype.chain=pt,h.prototype.toString=st,h.prototype.value=vt,h.prototype.valueOf=vt,Xn(["join","pop","shift"],function(n){var r=xt[n];h.prototype[n]=function(){var n=this.__chain__,t=r.apply(this.__wrapped__,arguments);return n?new g(t,n):t}}),Xn(["push","reverse","sort","unshift"],function(n){var r=xt[n];h.prototype[n]=function(){return r.apply(this.__wrapped__,arguments),this}}),Xn(["concat","slice","splice"],function(n){var r=xt[n];h.prototype[n]=function(){return new g(r.apply(this.__wrapped__,arguments),this.__chain__);
|
||||
|
||||
}}),h}var v,h=[],g=[],y=0,m=+new Date+"",b=75,_=40,d=" \f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",w=/\b__p \+= '';/g,j=/\b(__p \+=) '' \+/g,k=/(__e\(.*?\)|\b__t\)) \+\n'';/g,x=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,C=/\w*$/,O=/^\s*function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,R=RegExp("^["+d+"]*0+(?=.$)"),E=/($^)/,I=/\bthis\b/,S=/['\n\r\t\u2028\u2029\\]/g,A=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"],D=0,T="[object Arguments]",$="[object Array]",F="[object Boolean]",B="[object Date]",W="[object Function]",q="[object Number]",z="[object Object]",L="[object RegExp]",P="[object String]",K={};
|
||||
|
||||
K[W]=!1,K[T]=K[$]=K[F]=K[B]=K[q]=K[z]=K[L]=K[P]=!0;var U={leading:!1,maxWait:0,trailing:!1},M={configurable:!1,enumerable:!1,value:null,writable:!1},V={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},G={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},H=V[typeof window]&&window||this,J=V[typeof exports]&&exports&&!exports.nodeType&&exports,Q=V[typeof module]&&module&&!module.nodeType&&module,X=Q&&Q.exports===J&&J,Y=V[typeof global]&&global;!Y||Y.global!==Y&&Y.window!==Y||(H=Y);
|
||||
|
||||
var Z=s();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(H._=Z,define(function(){return Z})):J&&Q?X?(Q.exports=Z)._=Z:J._=Z:H._=Z}).call(this);
|
||||
4979
dist/lodash.underscore.js
vendored
Normal file
4979
dist/lodash.underscore.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
39
dist/lodash.underscore.min.js
vendored
Normal file
39
dist/lodash.underscore.min.js
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @license
|
||||
* Lo-Dash 2.4.2 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE
|
||||
* Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js`
|
||||
*/
|
||||
;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++t<e;)if(n[t]===r)return t;return-1}function r(n,r){for(var t=n.m,e=r.m,u=-1,o=t.length;++u<o;){var i=t[u],f=e[u];if(i!==f){if(i>f||typeof i=="undefined")return 1;if(i<f||typeof f=="undefined")return-1}}return n.n-r.n}function t(n){return"\\"+yr[n]}function e(n,r,t){r||(r=0),typeof t=="undefined"&&(t=n?n.length:0);var e=-1;t=t-r||0;for(var u=Array(0>t?0:t);++e<t;)u[e]=n[r+e];return u}function u(n){return n instanceof u?n:new o(n)}function o(n,r){this.__chain__=!!r,this.__wrapped__=n
|
||||
}function i(n){function r(){if(u){var n=e(u);Rr.apply(n,arguments)}if(this instanceof r){var i=f(t.prototype),n=t.apply(i,n||arguments);return O(n)?n:i}return t.apply(o,n||arguments)}var t=n[0],u=n[2],o=n[4];return r}function f(n){return O(n)?Br(n):{}}function a(n,r,t){if(typeof n!="function")return Y;if(typeof r=="undefined"||!("prototype"in n))return n;switch(t){case 1:return function(t){return n.call(r,t)};case 2:return function(t,e){return n.call(r,t,e)};case 3:return function(t,e,u){return n.call(r,t,e,u)
|
||||
};case 4:return function(t,e,u,o){return n.call(r,t,e,u,o)}}return L(n,r)}function l(n){function r(){var n=p?a:this;if(o){var y=e(o);Rr.apply(y,arguments)}return(i||g)&&(y||(y=e(arguments)),i&&Rr.apply(y,i),g&&y.length<c)?(u|=16,l([t,h?u:-4&u,y,null,a,c])):(y||(y=arguments),s&&(t=n[v]),this instanceof r?(n=f(t.prototype),y=t.apply(n,y),O(y)?y:n):t.apply(n,y))}var t=n[0],u=n[1],o=n[2],i=n[3],a=n[4],c=n[5],p=1&u,s=2&u,g=4&u,h=8&u,v=t;return r}function c(n,r){for(var t=-1,e=m(),u=n?n.length:0,o=[];++t<u;){var i=n[t];
|
||||
0>e(r,i)&&o.push(i)}return o}function p(n,r,t,e){e=(e||0)-1;for(var u=n?n.length:0,o=[];++e<u;){var i=n[e];if(i&&typeof i=="object"&&typeof i.length=="number"&&(Cr(i)||b(i))){r||(i=p(i,r,t));var f=-1,a=i.length,l=o.length;for(o.length+=a;++f<a;)o[l++]=i[f]}else t||o.push(i)}return o}function s(n,r,t,e){if(n===r)return 0!==n||1/n==1/r;if(n===n&&!(n&&vr[typeof n]||r&&vr[typeof r]))return false;if(null==n||null==r)return n===r;var o=Er.call(n),i=Er.call(r);if(o!=i)return false;switch(o){case lr:case cr:return+n==+r;
|
||||
case pr:return n!=+n?r!=+r:0==n?1/n==1/r:n==+r;case gr:case hr:return n==r+""}if(i=o==ar,!i){var f=n instanceof u,a=r instanceof u;if(f||a)return s(f?n.__wrapped__:n,a?r.__wrapped__:r,t,e);if(o!=sr)return false;if(o=n.constructor,f=r.constructor,o!=f&&!(A(o)&&o instanceof o&&A(f)&&f instanceof f)&&"constructor"in n&&"constructor"in r)return false}for(t||(t=[]),e||(e=[]),o=t.length;o--;)if(t[o]==n)return e[o]==r;var l=true,c=0;if(t.push(n),e.push(r),i){if(c=r.length,l=c==n.length)for(;c--&&(l=s(n[c],r[c],t,e)););}else Kr(r,function(r,u,o){return Nr.call(o,u)?(c++,!(l=Nr.call(n,u)&&s(n[u],r,t,e))&&er):void 0
|
||||
}),l&&Kr(n,function(n,r,t){return Nr.call(t,r)?!(l=-1<--c)&&er:void 0});return t.pop(),e.pop(),l}function g(n,r,t){for(var e=-1,u=m(),o=n?n.length:0,i=[],f=t?[]:i;++e<o;){var a=n[e],l=t?t(a,e,n):a;(r?!e||f[f.length-1]!==l:0>u(f,l))&&(t&&f.push(l),i.push(a))}return i}function h(n){return function(r,t,e){var u={};t=X(t,e,3),e=-1;var o=r?r.length:0;if(typeof o=="number")for(;++e<o;){var i=r[e];n(u,i,t(i,e,r),r)}else Lr(r,function(r,e,o){n(u,r,t(r,e,o),o)});return u}}function v(n,r,t,e,u,o){var f=16&r,a=32&r;
|
||||
if(!(2&r||A(n)))throw new TypeError;return f&&!t.length&&(r&=-17,t=false),a&&!e.length&&(r&=-33,e=false),(1==r||17===r?i:l)([n,r,t,e,u,o])}function y(n){return Vr[n]}function m(){var r=(r=u.indexOf)===G?n:r;return r}function _(n){return typeof n=="function"&&Ar.test(n)}function d(n){return Gr[n]}function b(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Er.call(n)==fr||false}function w(n){if(!n)return n;for(var r=1,t=arguments.length;r<t;r++){var e=arguments[r];if(e)for(var u in e)n[u]=e[u]}return n
|
||||
}function j(n){if(!n)return n;for(var r=1,t=arguments.length;r<t;r++){var e=arguments[r];if(e)for(var u in e)"undefined"==typeof n[u]&&(n[u]=e[u])}return n}function x(n){var r=[];return Kr(n,function(n,t){A(n)&&r.push(t)}),r.sort()}function T(n){for(var r=-1,t=Ur(n),e=t.length,u={};++r<e;){var o=t[r];u[n[o]]=o}return u}function E(n){if(!n)return true;if(Cr(n)||N(n))return!n.length;for(var r in n)if(Nr.call(n,r))return false;return true}function A(n){return typeof n=="function"}function O(n){return!(!n||!vr[typeof n])
|
||||
}function S(n){return typeof n=="number"||n&&typeof n=="object"&&Er.call(n)==pr||false}function N(n){return typeof n=="string"||n&&typeof n=="object"&&Er.call(n)==hr||false}function R(n){for(var r=-1,t=Ur(n),e=t.length,u=Array(e);++r<e;)u[r]=n[t[r]];return u}function k(n,r){var t=m(),e=n?n.length:0,u=false;return e&&typeof e=="number"?u=-1<t(n,r):Lr(n,function(n){return(u=n===r)&&er}),u}function B(n,r,t){var e=true;r=X(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++t<u&&(e=!!r(n[t],t,n)););else Lr(n,function(n,t,u){return!(e=!!r(n,t,u))&&er
|
||||
});return e}function F(n,r,t){var e=[];r=X(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++t<u;){var o=n[t];r(o,t,n)&&e.push(o)}else Lr(n,function(n,t,u){r(n,t,u)&&e.push(n)});return e}function q(n,r,t){r=X(r,t,3),t=-1;var e=n?n.length:0;if(typeof e!="number"){var u;return Lr(n,function(n,t,e){return r(n,t,e)?(u=n,er):void 0}),u}for(;++t<e;){var o=n[t];if(r(o,t,n))return o}}function D(n,r,t){var e=-1,u=n?n.length:0;if(r=r&&typeof t=="undefined"?r:a(r,t,3),typeof u=="number")for(;++e<u&&r(n[e],e,n)!==er;);else Lr(n,r)
|
||||
}function I(n,r){var t=n?n.length:0;if(typeof t=="number")for(;t--&&false!==r(n[t],t,n););else{var e=Ur(n),t=e.length;Lr(n,function(n,u,o){return u=e?e[--t]:--t,false===r(o[u],u,o)&&er})}}function M(n,r,t){var e=-1,u=n?n.length:0;if(r=X(r,t,3),typeof u=="number")for(var o=Array(u);++e<u;)o[e]=r(n[e],e,n);else o=[],Lr(n,function(n,t,u){o[++e]=r(n,t,u)});return o}function $(n,r,t){var e=-1/0,u=e;typeof r!="function"&&t&&t[r]===n&&(r=null);var o=-1,i=n?n.length:0;if(null==r&&typeof i=="number")for(;++o<i;)t=n[o],t>u&&(u=t);
|
||||
else r=X(r,t,3),D(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});return u}function W(n,r,t,e){if(!n)return t;var u=3>arguments.length;r=X(r,e,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(t=n[++o]);++o<i;)t=r(t,n[o],o,n);else Lr(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)});return t}function z(n,r,t,e){var u=3>arguments.length;return r=X(r,e,4),I(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function C(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return D(n,function(n){var t;t=++r,t=0+Sr(Wr()*(t-0+1)),e[r]=e[t],e[t]=n
|
||||
}),e}function P(n,r,t){var e;r=X(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++t<u&&!(e=r(n[t],t,n)););else Lr(n,function(n,t,u){return(e=r(n,t,u))&&er});return!!e}function U(n,r,t){return t&&E(r)?rr:(t?q:F)(n,r)}function V(n,r,t){var u=0,o=n?n.length:0;if(typeof r!="number"&&null!=r){var i=-1;for(r=X(r,t,3);++i<o&&r(n[i],i,n);)u++}else if(u=r,null==u||t)return n?n[0]:rr;return e(n,0,$r(Mr(0,u),o))}function G(r,t,e){if(typeof e=="number"){var u=r?r.length:0;e=0>e?Mr(0,u+e):e||0}else if(e)return e=J(r,t),r[e]===t?e:-1;
|
||||
return n(r,t,e)}function H(n,r,t){if(typeof r!="number"&&null!=r){var u=0,o=-1,i=n?n.length:0;for(r=X(r,t,3);++o<i&&r(n[o],o,n);)u++}else u=null==r||t?1:Mr(0,r);return e(n,u)}function J(n,r,t,e){var u=0,o=n?n.length:u;for(t=t?X(t,e,1):Y,r=t(r);u<o;)e=u+o>>>1,t(n[e])<r?u=e+1:o=e;return u}function K(n,r,t,e){return typeof r!="boolean"&&null!=r&&(e=t,t=typeof r!="function"&&e&&e[r]===n?null:r,r=false),null!=t&&(t=X(t,e,3)),g(n,r,t)}function L(n,r){return 2<arguments.length?v(n,17,e(arguments,2),null,r):v(n,1,null,null,r)
|
||||
}function Q(n,r,t){var e,u,o,i,f,a,l,c=0,p=false,s=true;if(!A(n))throw new TypeError;if(r=Mr(0,r)||0,true===t)var g=true,s=false;else O(t)&&(g=t.leading,p="maxWait"in t&&(Mr(r,t.maxWait)||0),s="trailing"in t?t.trailing:s);var h=function(){var t=r-(nt()-i);0<t?a=setTimeout(h,t):(u&&clearTimeout(u),t=l,u=a=l=rr,t&&(c=nt(),o=n.apply(f,e),a||u||(e=f=null)))},v=function(){a&&clearTimeout(a),u=a=l=rr,(s||p!==r)&&(c=nt(),o=n.apply(f,e),a||u||(e=f=null))};return function(){if(e=arguments,i=nt(),f=this,l=s&&(a||!g),false===p)var t=g&&!a;
|
||||
else{u||g||(c=i);var y=p-(i-c),m=0>=y;m?(u&&(u=clearTimeout(u)),c=i,o=n.apply(f,e)):u||(u=setTimeout(v,y))}return m&&a?a=clearTimeout(a):a||r===p||(a=setTimeout(h,r)),t&&(m=true,o=n.apply(f,e)),!m||a||u||(e=f=null),o}}function X(n,r,t){var e=typeof n;if(null==n||"function"==e)return a(n,r,t);if("object"!=e)return nr(n);var u=Ur(n);return function(r){for(var t=u.length,e=false;t--&&(e=r[u[t]]===n[u[t]]););return e}}function Y(n){return n}function Z(n){D(x(n),function(r){var t=u[r]=n[r];u.prototype[r]=function(){var n=[this.__wrapped__];
|
||||
return Rr.apply(n,arguments),n=t.apply(u,n),this.__chain__?new o(n,true):n}})}function nr(n){return function(r){return r[n]}}var rr,tr=0,er={},ur=+new Date+"",or=/($^)/,ir=/['\n\r\t\u2028\u2029\\]/g,fr="[object Arguments]",ar="[object Array]",lr="[object Boolean]",cr="[object Date]",pr="[object Number]",sr="[object Object]",gr="[object RegExp]",hr="[object String]",vr={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},yr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},mr=vr[typeof window]&&window||this,_r=vr[typeof exports]&&exports&&!exports.nodeType&&exports,dr=vr[typeof module]&&module&&!module.nodeType&&module,br=dr&&dr.exports===_r&&_r,wr=vr[typeof global]&&global;
|
||||
!wr||wr.global!==wr&&wr.window!==wr||(mr=wr);var jr=[],xr=Object.prototype,Tr=mr._,Er=xr.toString,Ar=RegExp("^"+(Er+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Or=Math.ceil,Sr=Math.floor,Nr=xr.hasOwnProperty,Rr=jr.push,kr=xr.propertyIsEnumerable,Br=_(Br=Object.create)&&Br,Fr=_(Fr=Array.isArray)&&Fr,qr=mr.isFinite,Dr=mr.isNaN,Ir=_(Ir=Object.keys)&&Ir,Mr=Math.max,$r=Math.min,Wr=Math.random;o.prototype=u.prototype;var zr={};!function(){var n={0:1,length:1};zr.spliceObjects=(jr.splice.call(n,0,1),!n[0])
|
||||
}(1),u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Br||(f=function(){function n(){}return function(r){if(O(r)){n.prototype=r;var t=new n;n.prototype=null}return t||mr.Object()}}()),b(arguments)||(b=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Nr.call(n,"callee")&&!kr.call(n,"callee")||false});var Cr=Fr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Er.call(n)==ar||false},Pr=function(n){var r,t=[];
|
||||
if(!n||!vr[typeof n])return t;for(r in n)Nr.call(n,r)&&t.push(r);return t},Ur=Ir?function(n){return O(n)?Ir(n):[]}:Pr,Vr={"&":"&","<":"<",">":">",'"':""","'":"'"},Gr=T(Vr),Hr=RegExp("("+Ur(Gr).join("|")+")","g"),Jr=RegExp("["+Ur(Vr).join("")+"]","g"),Kr=function(n,r){var t;if(!n||!vr[typeof n])return n;for(t in n)if(r(n[t],t,n)===er)break;return n},Lr=function(n,r){var t;if(!n||!vr[typeof n])return n;for(t in n)if(Nr.call(n,t)&&r(n[t],t,n)===er)break;return n};A(/x/)&&(A=function(n){return typeof n=="function"&&"[object Function]"==Er.call(n)
|
||||
});var Qr=h(function(n,r,t){Nr.call(n,t)?n[t]++:n[t]=1}),Xr=h(function(n,r,t){(Nr.call(n,t)?n[t]:n[t]=[]).push(r)}),Yr=h(function(n,r,t){n[t]=r}),Zr=M,nt=_(nt=Date.now)&&nt||function(){return(new Date).getTime()};u.after=function(n,r){if(!A(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=L,u.bindAll=function(n){for(var r=1<arguments.length?p(arguments,true,false,1):x(n),t=-1,e=r.length;++t<e;){var u=r[t];n[u]=v(n[u],1,null,null,n)}return n},u.chain=function(n){return n=new o(n),n.__chain__=true,n
|
||||
},u.compact=function(n){for(var r=-1,t=n?n.length:0,e=[];++r<t;){var u=n[r];u&&e.push(u)}return e},u.compose=function(){for(var n=arguments,r=n.length;r--;)if(!A(n[r]))throw new TypeError;return function(){for(var r=arguments,t=n.length;t--;)r=[n[t].apply(this,r)];return r[0]}},u.countBy=Qr,u.debounce=Q,u.defaults=j,u.defer=function(n){if(!A(n))throw new TypeError;var r=e(arguments,1);return setTimeout(function(){n.apply(rr,r)},1)},u.delay=function(n,r){if(!A(n))throw new TypeError;var t=e(arguments,2);
|
||||
return setTimeout(function(){n.apply(rr,t)},r)},u.difference=function(n){return c(n,p(arguments,true,true,1))},u.filter=F,u.flatten=function(n,r){return p(n,r)},u.forEach=D,u.functions=x,u.groupBy=Xr,u.indexBy=Yr,u.initial=function(n,r,t){var u=0,o=n?n.length:0;if(typeof r!="number"&&null!=r){var i=o;for(r=X(r,t,3);i--&&r(n[i],i,n);)u++}else u=null==r||t?1:r||u;return e(n,0,$r(Mr(0,o-u),o))},u.intersection=function(){for(var n=[],r=-1,t=arguments.length;++r<t;){var e=arguments[r];(Cr(e)||b(e))&&n.push(e)
|
||||
}var u=n[0],o=-1,i=m(),f=u?u.length:0,a=[];n:for(;++o<f;)if(e=u[o],0>i(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n;a.push(e)}return a},u.invert=T,u.invoke=function(n,r){var t=e(arguments,2),u=-1,o=typeof r=="function",i=n?n.length:0,f=Array(typeof i=="number"?i:0);return D(n,function(n){f[++u]=(o?r:n[r]).apply(n,t)}),f},u.keys=Ur,u.map=M,u.max=$,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):ur+arguments[0];return Nr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)
|
||||
}},u.min=function(n,r,t){var e=1/0,u=e;typeof r!="function"&&t&&t[r]===n&&(r=null);var o=-1,i=n?n.length:0;if(null==r&&typeof i=="number")for(;++o<i;)t=n[o],t<u&&(u=t);else r=X(r,t,3),D(n,function(n,t,o){t=r(n,t,o),t<e&&(e=t,u=n)});return u},u.omit=function(n){var r=[];Kr(n,function(n,t){r.push(t)});for(var r=c(r,p(arguments,true,false,1)),t=-1,e=r.length,u={};++t<e;){var o=r[t];u[o]=n[o]}return u},u.once=function(n){var r,t;if(!A(n))throw new TypeError;return function(){return r?t:(r=true,t=n.apply(this,arguments),n=null,t)
|
||||
}},u.pairs=function(n){for(var r=-1,t=Ur(n),e=t.length,u=Array(e);++r<e;){var o=t[r];u[r]=[o,n[o]]}return u},u.partial=function(n){return v(n,16,e(arguments,1))},u.pick=function(n){for(var r=-1,t=p(arguments,true,false,1),e=t.length,u={};++r<e;){var o=t[r];o in n&&(u[o]=n[o])}return u},u.pluck=Zr,u.range=function(n,r,t){n=+n||0,t=+t||1,null==r&&(r=n,n=0);var e=-1;r=Mr(0,Or((r-n)/t));for(var u=Array(r);++e<r;)u[e]=n,n+=t;return u},u.reject=function(n,r,t){return r=X(r,t,3),F(n,function(n,t,e){return!r(n,t,e)
|
||||
})},u.rest=H,u.shuffle=C,u.sortBy=function(n,t,e){var u=-1,o=n?n.length:0,i=Array(typeof o=="number"?o:0);for(t=X(t,e,3),D(n,function(n,r,e){i[++u]={m:[t(n,r,e)],n:u,o:n}}),o=i.length,i.sort(r);o--;)i[o]=i[o].o;return i},u.tap=function(n,r){return r(n),n},u.throttle=function(n,r,t){var e=true,u=true;if(!A(n))throw new TypeError;return false===t?e=false:O(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),t={},t.leading=e,t.maxWait=r,t.trailing=u,Q(n,r,t)},u.times=function(n,r,t){n=-1<(n=+n)?n:0;
|
||||
var e=-1,u=Array(n);for(r=a(r,t,1);++e<n;)u[e]=r(e);return u},u.toArray=function(n){return Cr(n)?e(n):n&&typeof n.length=="number"?M(n):R(n)},u.union=function(){return g(p(arguments,true,true))},u.uniq=K,u.values=R,u.where=U,u.without=function(n){return c(n,e(arguments,1))},u.wrap=function(n,r){return v(r,16,[n])},u.zip=function(){for(var n=-1,r=$(Zr(arguments,"length")),t=Array(0>r?0:r);++n<r;)t[n]=Zr(arguments,n);return t},u.collect=M,u.drop=H,u.each=D,u.extend=w,u.methods=x,u.object=function(n,r){var t=-1,e=n?n.length:0,u={};
|
||||
for(r||!e||Cr(n[0])||(r=[]);++t<e;){var o=n[t];r?u[o]=r[t]:o&&(u[o[0]]=o[1])}return u},u.select=F,u.tail=H,u.unique=K,u.clone=function(n){return O(n)?Cr(n)?e(n):w({},n):n},u.contains=k,u.escape=function(n){return null==n?"":(n+"").replace(Jr,y)},u.every=B,u.find=q,u.has=function(n,r){return n?Nr.call(n,r):false},u.identity=Y,u.indexOf=G,u.isArguments=b,u.isArray=Cr,u.isBoolean=function(n){return true===n||false===n||n&&typeof n=="object"&&Er.call(n)==lr||false},u.isDate=function(n){return n&&typeof n=="object"&&Er.call(n)==cr||false
|
||||
},u.isElement=function(n){return n&&1===n.nodeType||false},u.isEmpty=E,u.isEqual=function(n,r){return s(n,r)},u.isFinite=function(n){return qr(n)&&!Dr(parseFloat(n))},u.isFunction=A,u.isNaN=function(n){return S(n)&&n!=+n},u.isNull=function(n){return null===n},u.isNumber=S,u.isObject=O,u.isRegExp=function(n){return n&&vr[typeof n]&&Er.call(n)==gr||false},u.isString=N,u.isUndefined=function(n){return typeof n=="undefined"},u.lastIndexOf=function(n,r,t){var e=n?n.length:0;for(typeof t=="number"&&(e=(0>t?Mr(0,e+t):$r(t,e-1))+1);e--;)if(n[e]===r)return e;
|
||||
return-1},u.mixin=Z,u.noConflict=function(){return mr._=Tr,this},u.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Sr(Wr()*(r-n+1))},u.reduce=W,u.reduceRight=z,u.result=function(n,r){if(n){var t=n[r];return A(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Ur(n).length},u.some=P,u.sortedIndex=J,u.template=function(n,r,e){var o=u,i=o.templateSettings;n=(n||"")+"",e=j({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||or).source+"|"+(e.interpolate||or).source+"|"+(e.evaluate||or).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(ir,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";\n__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r
|
||||
}),a+="';",i||(i="obj",a="with("+i+"||{}){"+a+"}"),a="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";try{var l=Function("_","return "+a)(o)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Hr,d)},u.uniqueId=function(n){var r=++tr+"";return n?n+r:r},u.all=B,u.any=P,u.detect=q,u.findWhere=function(n,r){return U(n,r,true)},u.foldl=W,u.foldr=z,u.include=k,u.inject=W,u.first=V,u.last=function(n,r,t){var u=0,o=n?n.length:0;
|
||||
if(typeof r!="number"&&null!=r){var i=o;for(r=X(r,t,3);i--&&r(n[i],i,n);)u++}else if(u=r,null==u||t)return n?n[o-1]:rr;return e(n,Mr(0,o-u))},u.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=R(n)),null==r||t?n?n[0+Sr(Wr()*(n.length-1-0+1))]:rr:(n=C(n),n.length=$r(Mr(0,r),n.length),n)},u.take=V,u.head=V,Z(u),u.VERSION="2.4.2",u.prototype.chain=function(){return this.__chain__=true,this},u.prototype.value=function(){return this.__wrapped__},D("pop push reverse shift sort splice unshift".split(" "),function(n){var r=jr[n];
|
||||
u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),zr.spliceObjects||0!==n.length||delete n[0],this}}),D(["concat","join","slice"],function(n){var r=jr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=true),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(mr._=u, define(function(){return u})):_r&&dr?br?(dr.exports=u)._=u:_r._=u:mr._=u}).call(this);
|
||||
11026
doc/README.md
11026
doc/README.md
File diff suppressed because it is too large
Load Diff
38
doc/parse.php
Normal file
38
doc/parse.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
// cleanup requested file path
|
||||
$filePath = isset($_GET['f']) ? $_GET['f'] : 'lodash';
|
||||
$filePath = preg_replace('#(\.*[\/])+#', '', $filePath);
|
||||
$filePath .= preg_match('/\.[a-z]+$/', $filePath) ? '' : '.js';
|
||||
|
||||
// output filename
|
||||
if (isset($_GET['o'])) {
|
||||
$outputName = $_GET['o'];
|
||||
} else if (isset($_SERVER['argv'][1])) {
|
||||
$outputName = $_SERVER['argv'][1];
|
||||
} else {
|
||||
$outputName = basename($filePath);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
require('../vendor/docdown/docdown.php');
|
||||
|
||||
// get package version
|
||||
$version = json_decode(file_get_contents('../package.json'))->version;
|
||||
|
||||
// generate Markdown
|
||||
$markdown = docdown(array(
|
||||
'path' => '../' . $filePath,
|
||||
'title' => '<a href="http://lodash.com/">Lo-Dash</a> <span>v' . $version . '</span>',
|
||||
'toc' => 'categories',
|
||||
'url' => 'https://github.com/lodash/lodash/blob/' . $version . '/lodash.js'
|
||||
));
|
||||
|
||||
// save to a `.md` file
|
||||
file_put_contents($outputName . '.md', $markdown);
|
||||
|
||||
// print
|
||||
header('Content-Type: text/plain;charset=utf-8');
|
||||
echo $markdown . PHP_EOL;
|
||||
?>
|
||||
1
index.js
Executable file
1
index.js
Executable file
@@ -0,0 +1 @@
|
||||
module.exports = require('./dist/lodash.compat.js');
|
||||
89
lodash.min.js
vendored
89
lodash.min.js
vendored
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* lodash 3.3.1 (Custom Build) lodash.com/license | Underscore.js 1.8.2 underscorejs.org/LICENSE
|
||||
* Build: `lodash modern -o ./lodash.js`
|
||||
*/
|
||||
;(function(){function n(n,t){if(n!==t){var r=n===n,e=t===t;if(n>t||!r||typeof n=="undefined"&&e)return 1;if(n<t||!e||typeof t=="undefined"&&r)return-1}return 0}function t(n,t,r){if(t!==t)return h(n,r);r=(r||0)-1;for(var e=n.length;++r<e;)if(n[r]===t)return r;return-1}function r(n){return typeof n=="function"||false}function e(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;return n}function u(n){return typeof n=="string"?n:null==n?"":n+""}function o(n){return n.charCodeAt(0)}function i(n,t){for(var r=-1,e=n.length;++r<e&&-1<t.indexOf(n.charAt(r)););return r
|
||||
}function f(n,t){for(var r=n.length;r--&&-1<t.indexOf(n.charAt(r)););return r}function a(t,r){return n(t.a,r.a)||t.b-r.b}function c(t,r){for(var e=-1,u=t.a,o=r.a,i=u.length;++e<i;){var f=n(u[e],o[e]);if(f)return f}return t.b-r.b}function l(n){return Nt[n]}function s(n){return Ut[n]}function p(n){return"\\"+$t[n]}function h(n,t,r){var e=n.length;for(t=r?t||e:(t||0)-1;r?t--:++t<e;){var u=n[t];if(u!==u)return t}return-1}function _(n){return n&&typeof n=="object"||false}function g(n){return 160>=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)
|
||||
}function v(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;)n[r]===t&&(n[r]=z,o[++u]=r);return o}function y(n){for(var t=-1,r=n.length;++t<r&&g(n.charCodeAt(t)););return t}function d(n){for(var t=n.length;t--&&g(n.charCodeAt(t)););return t}function m(n){return Ft[n]}function w(g){function Nt(n){if(_(n)&&!(Wo(n)||n instanceof Lt)){if(n instanceof Ft)return n;if(Fu.call(n,"__chain__")&&Fu.call(n,"__wrapped__"))return ge(n)}return new Ft(n)}function Ut(){}function Ft(n,t,r){this.__wrapped__=n,this.__actions__=r||[],this.__chain__=!!t
|
||||
}function Lt(n){this.__wrapped__=n,this.__actions__=null,this.__dir__=1,this.__dropCount__=0,this.__filtered__=false,this.__iteratees__=null,this.__takeCount__=po,this.__views__=null}function $t(){this.__data__={}}function zt(n){var t=n?n.length:0;for(this.data={hash:ro(null),set:new Gu};t--;)this.push(n[t])}function Dt(n,t){var r=n.data;return(typeof t=="string"||He(t)?r.set.has(t):r.hash[t])?0:-1}function qt(n,t){var r=-1,e=n.length;for(t||(t=bu(e));++r<e;)t[r]=n[r];return t}function Pt(n,t){for(var r=-1,e=n.length;++r<e&&false!==t(n[r],r,n););return n
|
||||
}function Kt(n,t){for(var r=-1,e=n.length;++r<e;)if(!t(n[r],r,n))return false;return true}function Vt(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;){var i=n[r];t(i,r,n)&&(o[++u]=i)}return o}function Yt(n,t){for(var r=-1,e=n.length,u=bu(e);++r<e;)u[r]=t(n[r],r,n);return u}function Zt(n){for(var t=-1,r=n.length,e=so;++t<r;){var u=n[t];u>e&&(e=u)}return e}function Gt(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++u<o;)r=t(r,n[u],u,n);return r}function Jt(n,t,r,e){var u=n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);
|
||||
return r}function Xt(n,t){for(var r=-1,e=n.length;++r<e;)if(t(n[r],r,n))return true;return false}function Ht(n,t){return typeof n=="undefined"?t:n}function Qt(n,t,r,e){return typeof n!="undefined"&&Fu.call(e,r)?n:t}function nr(n,t,r){var e=$o(t);if(!r)return rr(t,n,e);for(var u=-1,o=e.length;++u<o;){var i=e[u],f=n[i],a=r(f,t[i],i,n,t);(a===a?a===f:f!==f)&&(typeof f!="undefined"||i in n)||(n[i]=a)}return n}function tr(n,t){for(var r=-1,e=n.length,u=fe(e),o=t.length,i=bu(o);++r<o;){var f=t[r];u?(f=parseFloat(f),i[r]=oe(f,e)?n[f]:b):i[r]=n[f]
|
||||
}return i}function rr(n,t,r){r||(r=t,t={});for(var e=-1,u=r.length;++e<u;){var o=r[e];t[o]=n[o]}return t}function er(n,t,r){var e=typeof n;if("function"==e){if(e=typeof t!="undefined"){var e=Nt.support,u=!(e.funcNames?n.name:e.funcDecomp);if(!u){var o=Nu.call(n);e.funcNames||(u=!mt.test(o)),u||(u=Et.test(o)||Qe(n),xo(n,u))}e=u}n=e?Fr(n,t,r):n}else n=null==n?yu:"object"==e?Ar(n):typeof t=="undefined"?Er(n+""):jr(n+"",t);return n}function ur(n,t,r,e,u,o,i){var f;if(r&&(f=u?r(n,e,u):r(n)),typeof f!="undefined")return f;
|
||||
if(!He(n))return n;if(e=Wo(n)){if(f=re(n),!t)return qt(n,f)}else{var a=$u.call(n),c=a==V;if(a!=Z&&a!=D&&(!c||u))return St[a]?ue(n,a,t):u?n:{};if(f=ee(c?{}:n),!t)return rr(n,f,$o(n))}for(o||(o=[]),i||(i=[]),u=o.length;u--;)if(o[u]==n)return i[u];return o.push(n),i.push(f),(e?Pt:vr)(n,function(e,u){f[u]=ur(e,t,r,u,n,o,i)}),f}function or(n,t,r,e){if(typeof n!="function")throw new Cu(B);return Ju(function(){n.apply(b,Or(r,e))},t)}function ir(n,r){var e=n?n.length:0,u=[];if(!e)return u;var o=-1,i=te(),f=i==t,a=f&&200<=r.length?Ao(r):null,c=r.length;
|
||||
a&&(i=Dt,f=false,r=a);n:for(;++o<e;)if(a=n[o],f&&a===a){for(var l=c;l--;)if(r[l]===a)continue n;u.push(a)}else 0>i(r,a)&&u.push(a);return u}function fr(n,t){var r=n?n.length:0;if(!fe(r))return vr(n,t);for(var e=-1,u=_e(n);++e<r&&false!==t(u[e],e,u););return n}function ar(n,t){var r=n?n.length:0;if(!fe(r))return yr(n,t);for(var e=_e(n);r--&&false!==t(e[r],r,e););return n}function cr(n,t){var r=true;return fr(n,function(n,e,u){return r=!!t(n,e,u)}),r}function lr(n,t){var r=[];return fr(n,function(n,e,u){t(n,e,u)&&r.push(n)
|
||||
}),r}function sr(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function pr(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++e<u;){var f=n[e];if(_(f)&&fe(f.length)&&(Wo(f)||Ge(f))){t&&(f=pr(f,t,r));var a=-1,c=f.length;for(i.length+=c;++a<c;)i[++o]=f[a]}else r||(i[++o]=f)}return i}function hr(n,t,r){var e=-1,u=_e(n);r=r(n);for(var o=r.length;++e<o;){var i=r[e];if(false===t(u[i],i,u))break}return n}function _r(n,t,r){var e=_e(n);r=r(n);for(var u=r.length;u--;){var o=r[u];
|
||||
if(false===t(e[o],o,e))break}return n}function gr(n,t){hr(n,t,iu)}function vr(n,t){return hr(n,t,$o)}function yr(n,t){return _r(n,t,$o)}function dr(n,t){for(var r=-1,e=t.length,u=-1,o=[];++r<e;){var i=t[r];Uo(n[i])&&(o[++u]=i)}return o}function mr(n,t,r){var e=-1,u=typeof t=="function",o=n?n.length:0,i=fe(o)?bu(o):[];return fr(n,function(n){var o=u?t:null!=n&&n[t];i[++e]=o?o.apply(n,r):b}),i}function wr(n,t,r,e,u,o){if(n===t)return 0!==n||1/n==1/t;var i=typeof n,f=typeof t;if("function"!=i&&"object"!=i&&"function"!=f&&"object"!=f||null==n||null==t)n=n!==n&&t!==t;
|
||||
else n:{var i=wr,f=Wo(n),a=Wo(t),c=M,l=M;f||(c=$u.call(n),c==D?c=Z:c!=Z&&(f=eu(n))),a||(l=$u.call(t),l==D?l=Z:l!=Z&&eu(t));var s=c==Z,a=l==Z,l=c==l;if(!l||f||s)if(c=s&&Fu.call(n,"__wrapped__"),a=a&&Fu.call(t,"__wrapped__"),c||a)n=i(c?n.value():n,a?t.value():t,r,e,u,o);else if(l){for(u||(u=[]),o||(o=[]),c=u.length;c--;)if(u[c]==n){n=o[c]==t;break n}u.push(n),o.push(t),n=(f?Jr:Hr)(n,t,i,r,e,u,o),u.pop(),o.pop()}else n=false;else n=Xr(n,t,c)}return n}function br(n,t,r,e,u){var o=t.length;if(null==n)return!o;
|
||||
for(var i=-1,f=!u;++i<o;)if(f&&e[i]?r[i]!==n[t[i]]:!Fu.call(n,t[i]))return false;for(i=-1;++i<o;){var a=t[i];if(f&&e[i])a=Fu.call(n,a);else{var c=n[a],l=r[i],a=u?u(c,l,a):b;typeof a=="undefined"&&(a=wr(l,c,u,true))}if(!a)return false}return true}function xr(n,t){var r=[];return fr(n,function(n,e,u){r.push(t(n,e,u))}),r}function Ar(n){var t=$o(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(ae(u))return function(n){return null!=n&&n[e]===u&&Fu.call(n,e)}}for(var o=bu(r),i=bu(r);r--;)u=n[t[r]],o[r]=u,i[r]=ae(u);return function(n){return br(n,t,o,i)
|
||||
}}function jr(n,t){return ae(t)?function(r){return null!=r&&r[n]===t}:function(r){return null!=r&&wr(t,r[n],null,true)}}function kr(n,t,r,e,u){if(!He(n))return n;var o=fe(t.length)&&(Wo(t)||eu(t));return(o?Pt:vr)(t,function(t,i,f){if(_(t)){e||(e=[]),u||(u=[]);n:{t=e;for(var a=u,c=t.length,l=f[i];c--;)if(t[c]==l){n[i]=a[c],i=void 0;break n}c=n[i],f=r?r(c,l,i,n,f):b;var s=typeof f=="undefined";s&&(f=l,fe(l.length)&&(Wo(l)||eu(l))?f=Wo(c)?c:c?qt(c):[]:Fo(l)||Ge(l)?f=Ge(c)?uu(c):Fo(c)?c:{}:s=false),t.push(l),a.push(f),s?n[i]=kr(f,l,r,t,a):(f===f?f!==c:c===c)&&(n[i]=f),i=void 0
|
||||
}return i}a=n[i],f=r?r(a,t,i,n,f):b,(l=typeof f=="undefined")&&(f=t),!o&&typeof f=="undefined"||!l&&(f===f?f===a:a!==a)||(n[i]=f)}),n}function Er(n){return function(t){return null==t?b:t[n]}}function Rr(n,t){return n+Ku(lo()*(t-n+1))}function Ir(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function Or(n,t,r){var e=-1,u=n.length;for(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=bu(u);++e<u;)r[e]=n[e+t];return r}function Cr(n,t){var r;
|
||||
return fr(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function Tr(n,r){var e=-1,u=te(),o=n.length,i=u==t,f=i&&200<=o,a=f?Ao():null,c=[];a?(u=Dt,i=false):(f=false,a=r?[]:c);n:for(;++e<o;){var l=n[e],s=r?r(l,e,n):l;if(i&&l===l){for(var p=a.length;p--;)if(a[p]===s)continue n;r&&a.push(s),c.push(l)}else 0>u(a,s)&&((r||f)&&a.push(s),c.push(l))}return c}function Sr(n,t){for(var r=-1,e=t.length,u=bu(e);++r<e;)u[r]=n[t[r]];return u}function Wr(n,t){var r=n;r instanceof Lt&&(r=r.value());for(var e=-1,u=t.length;++e<u;){var r=[r],o=t[e];
|
||||
Yu.apply(r,o.args),r=o.func.apply(o.thisArg,r)}return r}function Nr(n,t,r){var e=0,u=n?n.length:e;if(typeof t=="number"&&t===t&&u<=go){for(;e<u;){var o=e+u>>>1,i=n[o];(r?i<=t:i<t)?e=o+1:u=o}return u}return Ur(n,t,yu,r)}function Ur(n,t,r,e){t=r(t);for(var u=0,o=n?n.length:0,i=t!==t,f=typeof t=="undefined";u<o;){var a=Ku((u+o)/2),c=r(n[a]),l=c===c;(i?l||e:f?l&&(e||typeof c!="undefined"):e?c<=t:c<t)?u=a+1:o=a}return io(o,_o)}function Fr(n,t,r){if(typeof n!="function")return yu;if(typeof t=="undefined")return n;
|
||||
switch(r){case 1:return function(r){return n.call(t,r)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,o){return n.call(t,r,e,u,o)};case 5:return function(r,e,u,o,i){return n.call(t,r,e,u,o,i)}}return function(){return n.apply(t,arguments)}}function Lr(n){return Mu.call(n,0)}function $r(n,t,r){for(var e=r.length,u=-1,o=oo(n.length-e,0),i=-1,f=t.length,a=bu(o+f);++i<f;)a[i]=t[i];for(;++u<e;)a[r[u]]=n[u];for(;o--;)a[i++]=n[u++];return a}function Br(n,t,r){for(var e=-1,u=r.length,o=-1,i=oo(n.length-u,0),f=-1,a=t.length,c=bu(i+a);++o<i;)c[o]=n[o];
|
||||
for(i=o;++f<a;)c[i+f]=t[f];for(;++e<u;)c[i+r[e]]=n[o++];return c}function zr(n,t){return function(r,e,u){var o=t?t():{};if(e=ne(e,u,3),Wo(r)){u=-1;for(var i=r.length;++u<i;){var f=r[u];n(o,f,e(f,u,r),r)}}else fr(r,function(t,r,u){n(o,t,e(t,r,u),u)});return o}}function Dr(n){return function(){var t=arguments.length,r=arguments[0];if(2>t||null==r)return r;if(3<t&&ie(arguments[1],arguments[2],arguments[3])&&(t=2),3<t&&"function"==typeof arguments[t-2])var e=Fr(arguments[--t-1],arguments[t--],5);else 2<t&&"function"==typeof arguments[t-1]&&(e=arguments[--t]);
|
||||
for(var u=0;++u<t;){var o=arguments[u];o&&n(r,o,e)}return r}}function Mr(n,t){function r(){return(this instanceof r?e:n).apply(t,arguments)}var e=Pr(n);return r}function qr(n){return function(t){var r=-1;t=hu(au(t));for(var e=t.length,u="";++r<e;)u=n(u,t[r],r);return u}}function Pr(n){return function(){var t=bo(n.prototype),r=n.apply(t,arguments);return He(r)?r:t}}function Kr(n,t){return function(r,e,u){u&&ie(r,e,u)&&(e=null);var i=ne(),f=null==e;if(i===er&&f||(f=false,e=i(e,u,3)),f){if(e=Wo(r),e||!ru(r))return n(e?r:he(r));
|
||||
e=o}return Qr(r,e,t)}}function Vr(n,t,r,e,u,o,i,f,a,c){function l(){for(var w=arguments.length,x=w,k=bu(w);x--;)k[x]=arguments[x];if(e&&(k=$r(k,e,u)),o&&(k=Br(k,o,i)),_||y){var x=l.placeholder,E=v(k,x),w=w-E.length;if(w<c){var R=f?qt(f):null,w=oo(c-w,0),C=_?E:null,E=_?null:E,T=_?k:null,k=_?null:k;return t|=_?I:O,t&=~(_?O:I),g||(t&=~(A|j)),k=Vr(n,t,r,T,C,k,E,R,a,w),k.placeholder=x,k}}if(x=p?r:this,h&&(n=x[m]),f)for(R=k.length,w=io(f.length,R),C=qt(k);w--;)E=f[w],k[w]=oe(E,R)?C[E]:b;return s&&a<k.length&&(k.length=a),(this instanceof l?d||Pr(n):n).apply(x,k)
|
||||
}var s=t&T,p=t&A,h=t&j,_=t&E,g=t&k,y=t&R,d=!h&&Pr(n),m=n;return l}function Yr(n,t,r){return n=n.length,t=+t,n<t&&eo(t)?(t-=n,r=null==r?" ":r+"",su(r,qu(t/r.length)).slice(0,t)):""}function Zr(n,t,r,e){function u(){for(var t=-1,f=arguments.length,a=-1,c=e.length,l=bu(f+c);++a<c;)l[a]=e[a];for(;f--;)l[a++]=arguments[++t];return(this instanceof u?i:n).apply(o?r:this,l)}var o=t&A,i=Pr(n);return u}function Gr(n,t,r,e,u,o,i,f){var a=t&j;if(!a&&typeof n!="function")throw new Cu(B);var c=e?e.length:0;if(c||(t&=~(I|O),e=u=null),c-=u?u.length:0,t&O){var l=e,s=u;
|
||||
e=u=null}var p=!a&&jo(n);if(r=[n,t,r,e,u,l,s,o,i,f],p&&true!==p){e=r[1],t=p[1],f=e|t,o=T|C,u=A|j,i=o|u|k|R;var l=e&T&&!(t&T),s=e&C&&!(t&C),h=(s?r:p)[7],_=(l?r:p)[8];o=f>=o&&f<=i&&(e<C||(s||l)&&h.length<=_),(!(e>=C&&t>u||e>u&&t>=C)||o)&&(t&A&&(r[2]=p[2],f|=e&A?0:k),(e=p[3])&&(u=r[3],r[3]=u?$r(u,e,p[4]):qt(e),r[4]=u?v(r[3],z):qt(p[4])),(e=p[5])&&(u=r[5],r[5]=u?Br(u,e,p[6]):qt(e),r[6]=u?v(r[5],z):qt(p[6])),(e=p[7])&&(r[7]=qt(e)),t&T&&(r[8]=null==r[8]?p[8]:io(r[8],p[8])),null==r[9]&&(r[9]=p[9]),r[0]=p[0],r[1]=f),t=r[1],f=r[9]
|
||||
}return r[9]=null==f?a?0:n.length:oo(f-c,0)||0,(p?xo:ko)(t==A?Mr(r[0],r[2]):t!=I&&t!=(A|I)||r[4].length?Vr.apply(b,r):Zr.apply(b,r),r)}function Jr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length,l=true;if(a!=c&&(!u||c<=a))return false;for(;l&&++f<a;){var s=n[f],p=t[f],l=b;if(e&&(l=u?e(p,s,f):e(s,p,f)),typeof l=="undefined")if(u)for(var h=c;h--&&(p=t[h],!(l=s&&s===p||r(s,p,e,u,o,i))););else l=s&&s===p||r(s,p,e,u,o,i)}return!!l}function Xr(n,t,r){switch(r){case q:case P:return+n==+t;case K:return n.name==t.name&&n.message==t.message;
|
||||
case Y:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case G:case J:return n==t+""}return false}function Hr(n,t,r,e,u,o,i){var f=$o(n),a=f.length,c=$o(t).length;if(a!=c&&!u)return false;for(var l,c=-1;++c<a;){var s=f[c],p=Fu.call(t,s);if(p){var h=n[s],_=t[s],p=b;e&&(p=u?e(_,h,s):e(h,_,s)),typeof p=="undefined"&&(p=h&&h===_||r(h,_,e,u,o,i))}if(!p)return false;l||(l="constructor"==s)}return l||(r=n.constructor,e=t.constructor,!(r!=e&&"constructor"in n&&"constructor"in t)||typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)?true:false
|
||||
}function Qr(n,t,r){var e=r?po:so,u=e,o=u;return fr(n,function(n,i,f){i=t(n,i,f),((r?i<u:i>u)||i===e&&i===o)&&(u=i,o=n)}),o}function ne(n,t,r){var e=Nt.callback||gu,e=e===gu?er:e;return r?e(n,t,r):e}function te(n,r,e){var u=Nt.indexOf||we,u=u===we?t:u;return n?u(n,r,e):u}function re(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&Fu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function ee(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Ru),new n
|
||||
}function ue(n,t,r){var e=n.constructor;switch(t){case X:return Lr(n);case q:case P:return new e(+n);case H:case Q:case nt:case tt:case rt:case et:case ut:case ot:case it:return t=n.buffer,new e(r?Lr(t):t,n.byteOffset,n.length);case Y:case J:return new e(n);case G:var u=new e(n.source,dt.exec(n));u.lastIndex=n.lastIndex}return u}function oe(n,t){return n=+n,t=null==t?yo:t,-1<n&&0==n%1&&n<t}function ie(n,t,r){if(!He(r))return false;var e=typeof t;return"number"==e?(e=r.length,e=fe(e)&&oe(t,e)):e="string"==e&&t in r,e?(t=r[t],n===n?n===t:t!==t):false
|
||||
}function fe(n){return typeof n=="number"&&-1<n&&0==n%1&&n<=yo}function ae(n){return n===n&&(0===n?0<1/n:!He(n))}function ce(n,t){n=_e(n);for(var r=-1,e=t.length,u={};++r<e;){var o=t[r];o in n&&(u[o]=n[o])}return u}function le(n,t){var r={};return gr(n,function(n,e,u){t(n,e,u)&&(r[e]=n)}),r}function se(n){var t;if(!_(n)||$u.call(n)!=Z||!(Fu.call(n,"constructor")||(t=n.constructor,typeof t!="function"||t instanceof t)))return false;var r;return gr(n,function(n,t){r=t}),typeof r=="undefined"||Fu.call(n,r)
|
||||
}function pe(n){for(var t=iu(n),r=t.length,e=r&&n.length,u=Nt.support,u=e&&fe(e)&&(Wo(n)||u.nonEnumArgs&&Ge(n)),o=-1,i=[];++o<r;){var f=t[o];(u&&oe(f,e)||Fu.call(n,f))&&i.push(f)}return i}function he(n){return null==n?[]:fe(n.length)?He(n)?n:Ru(n):fu(n)}function _e(n){return He(n)?n:Ru(n)}function ge(n){return n instanceof Lt?n.clone():new Ft(n.__wrapped__,n.__chain__,qt(n.__actions__))}function ve(n,t,r){return n&&n.length?((r?ie(n,t,r):null==t)&&(t=1),Or(n,0>t?0:t)):[]}function ye(n,t,r){var e=n?n.length:0;
|
||||
return e?((r?ie(n,t,r):null==t)&&(t=1),t=e-(+t||0),Or(n,0,0>t?0:t)):[]}function de(n,t,r){var e=-1,u=n?n.length:0;for(t=ne(t,r,3);++e<u;)if(t(n[e],e,n))return e;return-1}function me(n){return n?n[0]:b}function we(n,r,e){var u=n?n.length:0;if(!u)return-1;if(typeof e=="number")e=0>e?oo(u+e,0):e||0;else if(e)return e=Nr(n,r),n=n[e],(r===r?r===n:n!==n)?e:-1;return t(n,r,e)}function be(n){return ve(n,1)}function xe(n,r,e,u){if(!n||!n.length)return[];null!=r&&typeof r!="boolean"&&(u=e,e=ie(n,r,u)?null:r,r=false);
|
||||
var o=ne();if((o!==er||null!=e)&&(e=o(e,u,3)),r&&te()==t){r=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e<u;){var a=n[e],c=r?r(a,e,n):a;e&&i===c||(i=c,f[++o]=a)}n=f}else n=Tr(n,e);return n}function Ae(n){for(var t=-1,r=(n&&n.length&&Zt(Yt(n,Uu)))>>>0,e=bu(r);++t<r;)e[t]=Yt(n,Er(t));return e}function je(n,t){var r=-1,e=n?n.length:0,u={};for(!e||t||Wo(n[0])||(t=[]);++r<e;){var o=n[r];t?u[o]=t[r]:o&&(u[o[0]]=o[1])}return u}function ke(n){return n=Nt(n),n.__chain__=true,n}function Ee(n,t,r){return t.call(r,n)
|
||||
}function Re(n,t,r){var e=Wo(n)?Kt:cr;return(typeof t!="function"||typeof r!="undefined")&&(t=ne(t,r,3)),e(n,t)}function Ie(n,t,r){var e=Wo(n)?Vt:lr;return t=ne(t,r,3),e(n,t)}function Oe(n,t,r){return Wo(n)?(t=de(n,t,r),-1<t?n[t]:b):(t=ne(t,r,3),sr(n,t,fr))}function Ce(n,t,r){return typeof t=="function"&&typeof r=="undefined"&&Wo(n)?Pt(n,t):fr(n,Fr(t,r,3))}function Te(n,t,r){if(typeof t=="function"&&typeof r=="undefined"&&Wo(n))for(r=n.length;r--&&false!==t(n[r],r,n););else n=ar(n,Fr(t,r,3));return n
|
||||
}function Se(n,t,r){var e=n?n.length:0;return fe(e)||(n=fu(n),e=n.length),e?(r=typeof r=="number"?0>r?oo(e+r,0):r||0:0,typeof n=="string"||!Wo(n)&&ru(n)?r<e&&-1<n.indexOf(t,r):-1<te(n,t,r)):false}function We(n,t,r){var e=Wo(n)?Yt:xr;return t=ne(t,r,3),e(n,t)}function Ne(n,t,r,e){return(Wo(n)?Gt:Ir)(n,ne(t,e,4),r,3>arguments.length,fr)}function Ue(n,t,r,e){return(Wo(n)?Jt:Ir)(n,ne(t,e,4),r,3>arguments.length,ar)}function Fe(n,t,r){return(r?ie(n,t,r):null==t)?(n=he(n),t=n.length,0<t?n[Rr(0,t-1)]:b):(n=Le(n),n.length=io(0>t?0:+t||0,n.length),n)
|
||||
}function Le(n){n=he(n);for(var t=-1,r=n.length,e=bu(r);++t<r;){var u=Rr(0,t);t!=u&&(e[t]=e[u]),e[u]=n[t]}return e}function $e(n,t,r){var e=Wo(n)?Xt:Cr;return(typeof t!="function"||typeof r!="undefined")&&(t=ne(t,r,3)),e(n,t)}function Be(n,t){var r;if(typeof t!="function"){if(typeof n!="function")throw new Cu(B);var e=n;n=t,t=e}return function(){return 0<--n?r=t.apply(this,arguments):t=null,r}}function ze(n,t){var r=A;if(2<arguments.length)var e=Or(arguments,2),u=v(e,ze.placeholder),r=r|I;return Gr(n,r,t,e,u)
|
||||
}function De(n,t){var r=A|j;if(2<arguments.length)var e=Or(arguments,2),u=v(e,De.placeholder),r=r|I;return Gr(t,r,n,e,u)}function Me(n,t,r){return r&&ie(n,t,r)&&(t=null),n=Gr(n,E,null,null,null,null,null,t),n.placeholder=Me.placeholder,n}function qe(n,t,r){return r&&ie(n,t,r)&&(t=null),n=Gr(n,R,null,null,null,null,null,t),n.placeholder=qe.placeholder,n}function Pe(n,t,r){function e(){var r=t-(So()-c);0>=r||r>t?(f&&Pu(f),r=p,f=s=p=b,r&&(h=So(),a=n.apply(l,i),s||f||(i=l=null))):s=Ju(e,r)}function u(){s&&Pu(s),f=s=p=b,(g||_!==t)&&(h=So(),a=n.apply(l,i),s||f||(i=l=null))
|
||||
}function o(){if(i=arguments,c=So(),l=this,p=g&&(s||!v),false===_)var r=v&&!s;else{f||v||(h=c);var o=_-(c-h),y=0>=o||o>_;y?(f&&(f=Pu(f)),h=c,a=n.apply(l,i)):f||(f=Ju(u,o))}return y&&s?s=Pu(s):s||t===_||(s=Ju(e,t)),r&&(y=true,a=n.apply(l,i)),!y||s||f||(i=l=null),a}var i,f,a,c,l,s,p,h=0,_=false,g=true;if(typeof n!="function")throw new Cu(B);if(t=0>t?0:+t||0,true===r)var v=true,g=false;else He(r)&&(v=r.leading,_="maxWait"in r&&oo(+r.maxWait||0,t),g="trailing"in r?r.trailing:g);return o.cancel=function(){s&&Pu(s),f&&Pu(f),f=s=p=b
|
||||
},o}function Ke(){var n=arguments,t=n.length-1;if(0>t)return function(n){return n};if(!Kt(n,r))throw new Cu(B);return function(){for(var r=t,e=n[r].apply(this,arguments);r--;)e=n[r].call(this,e);return e}}function Ve(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(typeof n!="function"||t&&typeof t!="function")throw new Cu(B);return r.cache=new Ve.Cache,r}function Ye(n){var t=Or(arguments,1),r=v(t,Ye.placeholder);
|
||||
return Gr(n,I,null,t,r)}function Ze(n){var t=Or(arguments,1),r=v(t,Ze.placeholder);return Gr(n,O,null,t,r)}function Ge(n){return fe(_(n)?n.length:b)&&$u.call(n)==D||false}function Je(n){return n&&1===n.nodeType&&_(n)&&-1<$u.call(n).indexOf("Element")||false}function Xe(n){return _(n)&&typeof n.message=="string"&&$u.call(n)==K||false}function He(n){var t=typeof n;return"function"==t||n&&"object"==t||false}function Qe(n){return null==n?false:$u.call(n)==V?zu.test(Nu.call(n)):_(n)&&bt.test(n)||false}function nu(n){return typeof n=="number"||_(n)&&$u.call(n)==Y||false
|
||||
}function tu(n){return _(n)&&$u.call(n)==G||false}function ru(n){return typeof n=="string"||_(n)&&$u.call(n)==J||false}function eu(n){return _(n)&&fe(n.length)&&Tt[$u.call(n)]||false}function uu(n){return rr(n,iu(n))}function ou(n){return dr(n,iu(n))}function iu(n){if(null==n)return[];He(n)||(n=Ru(n));for(var t=n.length,t=t&&fe(t)&&(Wo(n)||wo.nonEnumArgs&&Ge(n))&&t||0,r=n.constructor,e=-1,r=typeof r=="function"&&r.prototype===n,u=bu(t),o=0<t;++e<t;)u[e]=e+"";for(var i in n)o&&oe(i,t)||"constructor"==i&&(r||!Fu.call(n,i))||u.push(i);
|
||||
return u}function fu(n){return Sr(n,$o(n))}function au(n){return(n=u(n))&&n.replace(xt,l)}function cu(n){return(n=u(n))&&kt.test(n)?n.replace(jt,"\\$&"):n}function lu(n,t,r){return r&&ie(n,t,r)&&(t=0),co(n,t)}function su(n,t){var r="";if(n=u(n),t=+t,1>t||!n||!eo(t))return r;do t%2&&(r+=n),t=Ku(t/2),n+=n;while(t);return r}function pu(n,t,r){var e=n;return(n=u(n))?(r?ie(e,t,r):null==t)?n.slice(y(n),d(n)+1):(t+="",n.slice(i(n,t),f(n,t)+1)):n}function hu(n,t,r){return r&&ie(n,t,r)&&(t=null),n=u(n),n.match(t||It)||[]
|
||||
}function _u(){var n=arguments.length,t=arguments[0];try{for(var r=bu(n?n-1:0);0<--n;)r[n-1]=arguments[n];return t.apply(b,r)}catch(e){return Xe(e)?e:new Au(e)}}function gu(n,t,r){return r&&ie(n,t,r)&&(t=null),_(n)?du(n):er(n,t)}function vu(n){return function(){return n}}function yu(n){return n}function du(n){return Ar(ur(n,true))}function mu(n,t,r){if(null==r){var e=He(t),u=e&&$o(t);((u=u&&u.length&&dr(t,u))?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=dr(t,$o(t)));var o=true,e=-1,i=Uo(n),f=u.length;false===r?o=false:He(r)&&"chain"in r&&(o=r.chain);
|
||||
for(;++e<f;){r=u[e];var a=t[r];n[r]=a,i&&(n.prototype[r]=function(t){return function(){var r=this.__chain__;if(o||r){var e=n(this.__wrapped__);return(e.__actions__=qt(this.__actions__)).push({func:t,args:arguments,thisArg:n}),e.__chain__=r,e}return r=[this.value()],Yu.apply(r,arguments),t.apply(n,r)}}(a))}return n}function wu(){}g=g?Mt.defaults(Bt.Object(),g,Mt.pick(Bt,Ct)):Bt;var bu=g.Array,xu=g.Date,Au=g.Error,ju=g.Function,ku=g.Math,Eu=g.Number,Ru=g.Object,Iu=g.RegExp,Ou=g.String,Cu=g.TypeError,Tu=bu.prototype,Su=Ru.prototype,Wu=(Wu=g.window)&&Wu.document,Nu=ju.prototype.toString,Uu=Er("length"),Fu=Su.hasOwnProperty,Lu=0,$u=Su.toString,Bu=g._,zu=Iu("^"+cu($u).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Du=Qe(Du=g.ArrayBuffer)&&Du,Mu=Qe(Mu=Du&&new Du(0).slice)&&Mu,qu=ku.ceil,Pu=g.clearTimeout,Ku=ku.floor,Vu=Qe(Vu=Ru.getPrototypeOf)&&Vu,Yu=Tu.push,Zu=Su.propertyIsEnumerable,Gu=Qe(Gu=g.Set)&&Gu,Ju=g.setTimeout,Xu=Tu.splice,Hu=Qe(Hu=g.Uint8Array)&&Hu,Qu=Qe(Qu=g.WeakMap)&&Qu,no=function(){try{var n=Qe(n=g.Float64Array)&&n,t=new n(new Du(10),0,1)&&n
|
||||
}catch(r){}return t}(),to=Qe(to=bu.isArray)&&to,ro=Qe(ro=Ru.create)&&ro,eo=g.isFinite,uo=Qe(uo=Ru.keys)&&uo,oo=ku.max,io=ku.min,fo=Qe(fo=xu.now)&&fo,ao=Qe(ao=Eu.isFinite)&&ao,co=g.parseInt,lo=ku.random,so=Eu.NEGATIVE_INFINITY,po=Eu.POSITIVE_INFINITY,ho=ku.pow(2,32)-1,_o=ho-1,go=ho>>>1,vo=no?no.BYTES_PER_ELEMENT:0,yo=ku.pow(2,53)-1,mo=Qu&&new Qu,wo=Nt.support={};!function(n){wo.funcDecomp=!Qe(g.WinRTError)&&Et.test(w),wo.funcNames=typeof ju.name=="string";try{wo.dom=11===Wu.createDocumentFragment().nodeType
|
||||
}catch(t){wo.dom=false}try{wo.nonEnumArgs=!Zu.call(arguments,1)}catch(r){wo.nonEnumArgs=true}}(0,0),Nt.templateSettings={escape:_t,evaluate:gt,interpolate:vt,variable:"",imports:{_:Nt}};var bo=function(){function n(){}return function(t){if(He(t)){n.prototype=t;var r=new n;n.prototype=null}return r||g.Object()}}(),xo=mo?function(n,t){return mo.set(n,t),n}:yu;Mu||(Lr=Du&&Hu?function(n){var t=n.byteLength,r=no?Ku(t/vo):0,e=r*vo,u=new Du(t);if(r){var o=new no(u,0,r);o.set(new no(n,0,r))}return t!=e&&(o=new Hu(u,e),o.set(new Hu(n,e))),u
|
||||
}:vu(null));var Ao=ro&&Gu?function(n){return new zt(n)}:vu(null),jo=mo?function(n){return mo.get(n)}:wu,ko=function(){var n=0,t=0;return function(r,e){var u=So(),o=U-(u-t);if(t=u,0<o){if(++n>=N)return r}else n=0;return xo(r,e)}}(),Eo=zr(function(n,t,r){Fu.call(n,r)?++n[r]:n[r]=1}),Ro=zr(function(n,t,r){Fu.call(n,r)?n[r].push(t):n[r]=[t]}),Io=zr(function(n,t,r){n[r]=t}),Oo=Kr(Zt),Co=Kr(function(n){for(var t=-1,r=n.length,e=po;++t<r;){var u=n[t];u<e&&(e=u)}return e},true),To=zr(function(n,t,r){n[r?0:1].push(t)
|
||||
},function(){return[[],[]]}),So=fo||function(){return(new xu).getTime()},Wo=to||function(n){return _(n)&&fe(n.length)&&$u.call(n)==M||false};wo.dom||(Je=function(n){return n&&1===n.nodeType&&_(n)&&!Fo(n)||false});var No=ao||function(n){return typeof n=="number"&&eo(n)},Uo=r(/x/)||Hu&&!r(Hu)?function(n){return $u.call(n)==V}:r,Fo=Vu?function(n){if(!n||$u.call(n)!=Z)return false;var t=n.valueOf,r=Qe(t)&&(r=Vu(t))&&Vu(r);return r?n==r||Vu(n)==r:se(n)}:se,Lo=Dr(nr),$o=uo?function(n){if(n)var t=n.constructor,r=n.length;
|
||||
return typeof t=="function"&&t.prototype===n||typeof n!="function"&&r&&fe(r)?pe(n):He(n)?uo(n):[]}:pe,Bo=Dr(kr),zo=qr(function(n,t,r){return t=t.toLowerCase(),n+(r?t.charAt(0).toUpperCase()+t.slice(1):t)}),Do=qr(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()});8!=co(Ot+"08")&&(lu=function(n,t,r){return(r?ie(n,t,r):null==t)?t=0:t&&(t=+t),n=pu(n),co(n,t||(wt.test(n)?16:10))});var Mo=qr(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),qo=qr(function(n,t,r){return n+(r?" ":"")+(t.charAt(0).toUpperCase()+t.slice(1))
|
||||
});return Nt.prototype=Ut.prototype,Ft.prototype=bo(Ut.prototype),Ft.prototype.constructor=Ft,Lt.prototype=bo(Ut.prototype),Lt.prototype.constructor=Lt,$t.prototype["delete"]=function(n){return this.has(n)&&delete this.__data__[n]},$t.prototype.get=function(n){return"__proto__"==n?b:this.__data__[n]},$t.prototype.has=function(n){return"__proto__"!=n&&Fu.call(this.__data__,n)},$t.prototype.set=function(n,t){return"__proto__"!=n&&(this.__data__[n]=t),this},zt.prototype.push=function(n){var t=this.data;
|
||||
typeof n=="string"||He(n)?t.set.add(n):t.hash[n]=true},Ve.Cache=$t,Nt.after=function(n,t){if(typeof t!="function"){if(typeof n!="function")throw new Cu(B);var r=n;n=t,t=r}return n=eo(n=+n)?n:0,function(){return 1>--n?t.apply(this,arguments):void 0}},Nt.ary=function(n,t,r){return r&&ie(n,t,r)&&(t=null),t=n&&null==t?n.length:oo(+t||0,0),Gr(n,T,null,null,null,null,t)},Nt.assign=Lo,Nt.at=function(n){return fe(n?n.length:0)&&(n=he(n)),tr(n,pr(arguments,false,false,1))},Nt.before=Be,Nt.bind=ze,Nt.bindAll=function(n){for(var t=n,r=1<arguments.length?pr(arguments,false,false,1):ou(n),e=-1,u=r.length;++e<u;){var o=r[e];
|
||||
t[o]=Gr(t[o],A,t)}return t},Nt.bindKey=De,Nt.callback=gu,Nt.chain=ke,Nt.chunk=function(n,t,r){t=(r?ie(n,t,r):null==t)?1:oo(+t||1,1),r=0;for(var e=n?n.length:0,u=-1,o=bu(qu(e/t));r<e;)o[++u]=Or(n,r,r+=t);return o},Nt.compact=function(n){for(var t=-1,r=n?n.length:0,e=-1,u=[];++t<r;){var o=n[t];o&&(u[++e]=o)}return u},Nt.constant=vu,Nt.countBy=Eo,Nt.create=function(n,t,r){var e=bo(n);return r&&ie(n,t,r)&&(t=null),t?rr(t,e,$o(t)):e},Nt.curry=Me,Nt.curryRight=qe,Nt.debounce=Pe,Nt.defaults=function(n){if(null==n)return n;
|
||||
var t=qt(arguments);return t.push(Ht),Lo.apply(b,t)},Nt.defer=function(n){return or(n,1,arguments,1)},Nt.delay=function(n,t){return or(n,t,arguments,2)},Nt.difference=function(){for(var n=-1,t=arguments.length;++n<t;){var r=arguments[n];if(Wo(r)||Ge(r))break}return ir(r,pr(arguments,false,true,++n))},Nt.drop=ve,Nt.dropRight=ye,Nt.dropRightWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];for(t=ne(t,r,3);e--&&t(n[e],e,n););return Or(n,0,e+1)},Nt.dropWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];
|
||||
var u=-1;for(t=ne(t,r,3);++u<e&&t(n[u],u,n););return Or(n,u)},Nt.fill=function(n,t,r,e){var u=n?n.length:0;if(!u)return[];for(r&&typeof r!="number"&&ie(n,t,r)&&(r=0,e=u),u=n.length,r=null==r?0:+r||0,0>r&&(r=-r>u?0:u+r),e=typeof e=="undefined"||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r<u;)n[r++]=t;return n},Nt.filter=Ie,Nt.flatten=function(n,t,r){var e=n?n.length:0;return r&&ie(n,t,r)&&(t=false),e?pr(n,t):[]},Nt.flattenDeep=function(n){return n&&n.length?pr(n,true):[]},Nt.flow=function(){var n=arguments,t=n.length;
|
||||
if(!t)return function(n){return n};if(!Kt(n,r))throw new Cu(B);return function(){for(var r=0,e=n[r].apply(this,arguments);++r<t;)e=n[r].call(this,e);return e}},Nt.flowRight=Ke,Nt.forEach=Ce,Nt.forEachRight=Te,Nt.forIn=function(n,t,r){return(typeof t!="function"||typeof r!="undefined")&&(t=Fr(t,r,3)),hr(n,t,iu)},Nt.forInRight=function(n,t,r){return t=Fr(t,r,3),_r(n,t,iu)},Nt.forOwn=function(n,t,r){return(typeof t!="function"||typeof r!="undefined")&&(t=Fr(t,r,3)),vr(n,t)},Nt.forOwnRight=function(n,t,r){return t=Fr(t,r,3),_r(n,t,$o)
|
||||
},Nt.functions=ou,Nt.groupBy=Ro,Nt.indexBy=Io,Nt.initial=function(n){return ye(n,1)},Nt.intersection=function(){for(var n=[],r=-1,e=arguments.length,u=[],o=te(),i=o==t;++r<e;){var f=arguments[r];(Wo(f)||Ge(f))&&(n.push(f),u.push(i&&120<=f.length?Ao(r&&f):null))}var e=n.length,i=n[0],a=-1,c=i?i.length:0,l=[],s=u[0];n:for(;++a<c;)if(f=i[a],0>(s?Dt(s,f):o(l,f))){for(r=e;--r;){var p=u[r];if(0>(p?Dt(p,f):o(n[r],f)))continue n}s&&s.push(f),l.push(f)}return l},Nt.invert=function(n,t,r){r&&ie(n,t,r)&&(t=null),r=-1;
|
||||
for(var e=$o(n),u=e.length,o={};++r<u;){var i=e[r],f=n[i];t?Fu.call(o,f)?o[f].push(i):o[f]=[i]:o[f]=i}return o},Nt.invoke=function(n,t){return mr(n,t,Or(arguments,2))},Nt.keys=$o,Nt.keysIn=iu,Nt.map=We,Nt.mapValues=function(n,t,r){var e={};return t=ne(t,r,3),vr(n,function(n,r,u){e[r]=t(n,r,u)}),e},Nt.matches=du,Nt.matchesProperty=function(n,t){return jr(n+"",ur(t,true))},Nt.memoize=Ve,Nt.merge=Bo,Nt.mixin=mu,Nt.negate=function(n){if(typeof n!="function")throw new Cu(B);return function(){return!n.apply(this,arguments)
|
||||
}},Nt.omit=function(n,t,r){if(null==n)return{};if(typeof t!="function"){var e=Yt(pr(arguments,false,false,1),Ou);return ce(n,ir(iu(n),e))}return t=Fr(t,r,3),le(n,function(n,r,e){return!t(n,r,e)})},Nt.once=function(n){return Be(n,2)},Nt.pairs=function(n){for(var t=-1,r=$o(n),e=r.length,u=bu(e);++t<e;){var o=r[t];u[t]=[o,n[o]]}return u},Nt.partial=Ye,Nt.partialRight=Ze,Nt.partition=To,Nt.pick=function(n,t,r){return null==n?{}:typeof t=="function"?le(n,Fr(t,r,3)):ce(n,pr(arguments,false,false,1))},Nt.pluck=function(n,t){return We(n,Er(t))
|
||||
},Nt.property=function(n){return Er(n+"")},Nt.propertyOf=function(n){return function(t){return null==n?b:n[t]}},Nt.pull=function(){var n=arguments[0];if(!n||!n.length)return n;for(var t=0,r=te(),e=arguments.length;++t<e;)for(var u=0,o=arguments[t];-1<(u=r(n,o,u));)Xu.call(n,u,1);return n},Nt.pullAt=function(t){var r=t||[],e=pr(arguments,false,false,1),u=e.length,o=tr(r,e);for(e.sort(n);u--;){var i=parseFloat(e[u]);if(i!=f&&oe(i)){var f=i;Xu.call(r,i,1)}}return o},Nt.range=function(n,t,r){r&&ie(n,t,r)&&(t=r=null),n=+n||0,r=null==r?1:+r||0,null==t?(t=n,n=0):t=+t||0;
|
||||
var e=-1;t=oo(qu((t-n)/(r||1)),0);for(var u=bu(t);++e<t;)u[e]=n,n+=r;return u},Nt.rearg=function(n){var t=pr(arguments,false,false,1);return Gr(n,C,null,null,null,t)},Nt.reject=function(n,t,r){var e=Wo(n)?Vt:lr;return t=ne(t,r,3),e(n,function(n,r,e){return!t(n,r,e)})},Nt.remove=function(n,t,r){var e=-1,u=n?n.length:0,o=[];for(t=ne(t,r,3);++e<u;)r=n[e],t(r,e,n)&&(o.push(r),Xu.call(n,e--,1),u--);return o},Nt.rest=be,Nt.shuffle=Le,Nt.slice=function(n,t,r){var e=n?n.length:0;return e?(r&&typeof r!="number"&&ie(n,t,r)&&(t=0,r=e),Or(n,t,r)):[]
|
||||
},Nt.sortBy=function(n,t,r){var u=-1,o=n?n.length:0,i=fe(o)?bu(o):[];return r&&ie(n,t,r)&&(t=null),t=ne(t,r,3),fr(n,function(n,r,e){i[++u]={a:t(n,r,e),b:u,c:n}}),e(i,a)},Nt.sortByAll=function(n){var t=arguments;3<t.length&&ie(t[1],t[2],t[3])&&(t=[n,t[1]]);var r=-1,u=n?n.length:0,o=pr(t,false,false,1),i=fe(u)?bu(u):[];return fr(n,function(n){for(var t=o.length,e=bu(t);t--;)e[t]=null==n?b:n[o[t]];i[++r]={a:e,b:r,c:n}}),e(i,c)},Nt.spread=function(n){if(typeof n!="function")throw new Cu(B);return function(t){return n.apply(this,t)
|
||||
}},Nt.take=function(n,t,r){return n&&n.length?((r?ie(n,t,r):null==t)&&(t=1),Or(n,0,0>t?0:t)):[]},Nt.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?ie(n,t,r):null==t)&&(t=1),t=e-(+t||0),Or(n,0>t?0:t)):[]},Nt.takeRightWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];for(t=ne(t,r,3);e--&&t(n[e],e,n););return Or(n,e+1)},Nt.takeWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];var u=-1;for(t=ne(t,r,3);++u<e&&t(n[u],u,n););return Or(n,0,u)},Nt.tap=function(n,t,r){return t.call(r,n),n
|
||||
},Nt.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new Cu(B);return false===r?e=false:He(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),Wt.leading=e,Wt.maxWait=+t,Wt.trailing=u,Pe(n,t,Wt)},Nt.thru=Ee,Nt.times=function(n,t,r){if(n=+n,1>n||!eo(n))return[];var e=-1,u=bu(io(n,ho));for(t=Fr(t,r,1);++e<n;)e<ho?u[e]=t(e):t(e);return u},Nt.toArray=function(n){var t=n?n.length:0;return fe(t)?t?qt(n):[]:fu(n)},Nt.toPlainObject=uu,Nt.transform=function(n,t,r,e){var u=Wo(n)||eu(n);
|
||||
return t=ne(t,e,4),null==r&&(u||He(n)?(e=n.constructor,r=u?Wo(n)?new e:[]:bo(Uo(e)&&e.prototype)):r={}),(u?Pt:vr)(n,function(n,e,u){return t(r,n,e,u)}),r},Nt.union=function(){return Tr(pr(arguments,false,true))},Nt.uniq=xe,Nt.unzip=Ae,Nt.values=fu,Nt.valuesIn=function(n){return Sr(n,iu(n))},Nt.where=function(n,t){return Ie(n,Ar(t))},Nt.without=function(n){return ir(n,Or(arguments,1))},Nt.wrap=function(n,t){return t=null==t?yu:t,Gr(t,I,null,[n],[])},Nt.xor=function(){for(var n=-1,t=arguments.length;++n<t;){var r=arguments[n];
|
||||
if(Wo(r)||Ge(r))var e=e?ir(e,r).concat(ir(r,e)):r}return e?Tr(e):[]},Nt.zip=function(){for(var n=arguments.length,t=bu(n);n--;)t[n]=arguments[n];return Ae(t)},Nt.zipObject=je,Nt.backflow=Ke,Nt.collect=We,Nt.compose=Ke,Nt.each=Ce,Nt.eachRight=Te,Nt.extend=Lo,Nt.iteratee=gu,Nt.methods=ou,Nt.object=je,Nt.select=Ie,Nt.tail=be,Nt.unique=xe,mu(Nt,Nt),Nt.attempt=_u,Nt.camelCase=zo,Nt.capitalize=function(n){return(n=u(n))&&n.charAt(0).toUpperCase()+n.slice(1)},Nt.clone=function(n,t,r,e){return t&&typeof t!="boolean"&&ie(n,t,r)?t=false:typeof t=="function"&&(e=r,r=t,t=false),r=typeof r=="function"&&Fr(r,e,1),ur(n,t,r)
|
||||
},Nt.cloneDeep=function(n,t,r){return t=typeof t=="function"&&Fr(t,r,1),ur(n,true,t)},Nt.deburr=au,Nt.endsWith=function(n,t,r){n=u(n),t+="";var e=n.length;return r=(typeof r=="undefined"?e:io(0>r?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Nt.escape=function(n){return(n=u(n))&&ht.test(n)?n.replace(st,s):n},Nt.escapeRegExp=cu,Nt.every=Re,Nt.find=Oe,Nt.findIndex=de,Nt.findKey=function(n,t,r){return t=ne(t,r,3),sr(n,t,vr,true)},Nt.findLast=function(n,t,r){return t=ne(t,r,3),sr(n,t,ar)},Nt.findLastIndex=function(n,t,r){var e=n?n.length:0;
|
||||
for(t=ne(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Nt.findLastKey=function(n,t,r){return t=ne(t,r,3),sr(n,t,yr,true)},Nt.findWhere=function(n,t){return Oe(n,Ar(t))},Nt.first=me,Nt.has=function(n,t){return n?Fu.call(n,t):false},Nt.identity=yu,Nt.includes=Se,Nt.indexOf=we,Nt.inRange=function(n,t,r){return t=+t||0,"undefined"===typeof r?(r=t,t=0):r=+r||0,n>=t&&n<r},Nt.isArguments=Ge,Nt.isArray=Wo,Nt.isBoolean=function(n){return true===n||false===n||_(n)&&$u.call(n)==q||false},Nt.isDate=function(n){return _(n)&&$u.call(n)==P||false
|
||||
},Nt.isElement=Je,Nt.isEmpty=function(n){if(null==n)return true;var t=n.length;return fe(t)&&(Wo(n)||ru(n)||Ge(n)||_(n)&&Uo(n.splice))?!t:!$o(n).length},Nt.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Fr(r,e,3),!r&&ae(n)&&ae(t)?n===t:(e=r?r(n,t):b,typeof e=="undefined"?wr(n,t,r):!!e)},Nt.isError=Xe,Nt.isFinite=No,Nt.isFunction=Uo,Nt.isMatch=function(n,t,r,e){var u=$o(t),o=u.length;if(r=typeof r=="function"&&Fr(r,e,3),!r&&1==o){var i=u[0];if(e=t[i],ae(e))return null!=n&&e===n[i]&&Fu.call(n,i)
|
||||
}for(var i=bu(o),f=bu(o);o--;)e=i[o]=t[u[o]],f[o]=ae(e);return br(n,u,i,f,r)},Nt.isNaN=function(n){return nu(n)&&n!=+n},Nt.isNative=Qe,Nt.isNull=function(n){return null===n},Nt.isNumber=nu,Nt.isObject=He,Nt.isPlainObject=Fo,Nt.isRegExp=tu,Nt.isString=ru,Nt.isTypedArray=eu,Nt.isUndefined=function(n){return typeof n=="undefined"},Nt.kebabCase=Do,Nt.last=function(n){var t=n?n.length:0;return t?n[t-1]:b},Nt.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?oo(e+r,0):io(r||0,e-1))+1;
|
||||
else if(r)return u=Nr(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return h(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Nt.max=Oo,Nt.min=Co,Nt.noConflict=function(){return g._=Bu,this},Nt.noop=wu,Nt.now=So,Nt.pad=function(n,t,r){n=u(n),t=+t;var e=n.length;return e<t&&eo(t)?(e=(t-e)/2,t=Ku(e),e=qu(e),r=Yr("",e,r),r.slice(0,t)+n+r):n},Nt.padLeft=function(n,t,r){return(n=u(n))&&Yr(n,t,r)+n},Nt.padRight=function(n,t,r){return(n=u(n))&&n+Yr(n,t,r)},Nt.parseInt=lu,Nt.random=function(n,t,r){r&&ie(n,t,r)&&(t=r=null);
|
||||
var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=lo(),io(n+r*(t-n+parseFloat("1e-"+((r+"").length-1))),t)):Rr(n,t)},Nt.reduce=Ne,Nt.reduceRight=Ue,Nt.repeat=su,Nt.result=function(n,t,r){return t=null==n?b:n[t],typeof t=="undefined"&&(t=r),Uo(t)?t.call(n):t},Nt.runInContext=w,Nt.size=function(n){var t=n?n.length:0;return fe(t)?t:$o(n).length},Nt.snakeCase=Mo,Nt.some=$e,Nt.sortedIndex=function(n,t,r,e){var u=ne(r);
|
||||
return u===er&&null==r?Nr(n,t):Ur(n,t,u(r,e,1))},Nt.sortedLastIndex=function(n,t,r,e){var u=ne(r);return u===er&&null==r?Nr(n,t,true):Ur(n,t,u(r,e,1),true)},Nt.startCase=qo,Nt.startsWith=function(n,t,r){return n=u(n),r=null==r?0:io(0>r?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Nt.template=function(n,t,r){var e=Nt.templateSettings;r&&ie(n,t,r)&&(t=r=null),n=u(n),t=nr(nr({},r||t),e,Qt),r=nr(nr({},t.imports),e.imports,Qt);var o,i,f=$o(r),a=Sr(r,f),c=0;r=t.interpolate||At;var l="__p+='";r=Iu((t.escape||At).source+"|"+r.source+"|"+(r===vt?yt:At).source+"|"+(t.evaluate||At).source+"|$","g");
|
||||
var s="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Rt,p),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(ft,""):l).replace(at,"$1").replace(ct,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=_u(function(){return ju(f,s+"return "+l).apply(b,a)
|
||||
}),t.source=l,Xe(t))throw t;return t},Nt.trim=pu,Nt.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?ie(e,t,r):null==t)?y(n):i(n,t+"")):n},Nt.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?ie(e,t,r):null==t)?n.slice(0,d(n)+1):n.slice(0,f(n,t+"")+1):n},Nt.trunc=function(n,t,r){r&&ie(n,t,r)&&(t=null);var e=S;if(r=W,null!=t)if(He(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r;
|
||||
if(t=n.slice(0,e),null==o)return t+r;if(tu(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Iu(o.source,(dt.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o),-1<o&&(t=t.slice(0,o)));return t+r},Nt.unescape=function(n){return(n=u(n))&&pt.test(n)?n.replace(lt,m):n},Nt.uniqueId=function(n){var t=++Lu;return u(n)+t},Nt.words=hu,Nt.all=Re,Nt.any=$e,Nt.contains=Se,Nt.detect=Oe,Nt.foldl=Ne,Nt.foldr=Ue,Nt.head=me,Nt.include=Se,Nt.inject=Ne,mu(Nt,function(){var n={};
|
||||
return vr(Nt,function(t,r){Nt.prototype[r]||(n[r]=t)}),n}(),false),Nt.sample=Fe,Nt.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return Fe(t,n)}):Fe(this.value())},Nt.VERSION=x,Pt("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Nt[n].placeholder=Nt}),Pt(["filter","map","takeWhile"],function(n,t){var r=t==F||t==$;Lt.prototype[n]=function(n,e){var u=this.clone(),o=u.__iteratees__||(u.__iteratees__=[]);return u.__filtered__=u.__filtered__||r,o.push({iteratee:ne(n,e,3),type:t}),u
|
||||
}}),Pt(["drop","take"],function(n,t){var r="__"+n+"Count__",e=n+"While";Lt.prototype[n]=function(e){e=null==e?1:oo(Ku(e)||0,0);var u=this.clone();if(u.__filtered__){var o=u[r];u[r]=t?io(o,e):o+e}else(u.__views__||(u.__views__=[])).push({size:e,type:n+(0>u.__dir__?"Right":"")});return u},Lt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},Lt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),Pt(["first","last"],function(n,t){var r="take"+(t?"Right":"");
|
||||
Lt.prototype[n]=function(){return this[r](1).value()[0]}}),Pt(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");Lt.prototype[n]=function(){return this[r](1)}}),Pt(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?Ar:Er;Lt.prototype[n]=function(n){return this[r](e(n))}}),Lt.prototype.compact=function(){return this.filter(yu)},Lt.prototype.dropWhile=function(n,t){var r,e,u=0>this.__dir__;return n=ne(n,t,3),this.filter(function(t,o,i){return r=r&&(u?o<e:o>e),e=o,r||(r=!n(t,o,i))})
|
||||
},Lt.prototype.reject=function(n,t){return n=ne(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},Lt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},Lt.prototype.toArray=function(){return this.drop(0)},vr(Lt.prototype,function(n,t){var r=Nt[t],e=/^(?:first|last)$/.test(t);Nt.prototype[t]=function(){function t(n){return n=[n],Yu.apply(n,o),r.apply(Nt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,f=!!this.__actions__.length,a=u instanceof Lt,c=a&&!f;
|
||||
return e&&!i?c?n.call(u):r.call(Nt,this.value()):a||Wo(u)?(u=n.apply(c?u:new Lt(this),o),e||!f&&!u.__actions__||(u.__actions__||(u.__actions__=[])).push({func:Ee,args:[t],thisArg:Nt}),new Ft(u,i)):this.thru(t)}}),Pt("concat join pop push shift sort splice unshift".split(" "),function(n){var t=Tu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n);Nt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)
|
||||
})}}),Lt.prototype.clone=function(){var n=this.__actions__,t=this.__iteratees__,r=this.__views__,e=new Lt(this.__wrapped__);return e.__actions__=n?qt(n):null,e.__dir__=this.__dir__,e.__dropCount__=this.__dropCount__,e.__filtered__=this.__filtered__,e.__iteratees__=t?qt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?qt(r):null,e},Lt.prototype.reverse=function(){if(this.__filtered__){var n=new Lt(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Lt.prototype.value=function(){var n=this.__wrapped__.value();
|
||||
if(!Wo(n))return Wr(n,this.__actions__);var t,r=this.__dir__,e=0>r;t=n.length;for(var u=this.__views__,o=0,i=-1,f=u?u.length:0;++i<f;){var a=u[i],c=a.size;switch(a.type){case"drop":o+=c;break;case"dropRight":t-=c;break;case"take":t=io(t,o+c);break;case"takeRight":o=oo(o,t-c)}}t={start:o,end:t},i=t.start,f=t.end,t=f-i,u=this.__dropCount__,o=io(t,this.__takeCount__),e=e?f:i-1,f=(i=this.__iteratees__)?i.length:0,a=0,c=[];n:for(;t--&&a<o;){for(var e=e+r,l=-1,s=n[e];++l<f;){var p=i[l],h=p.iteratee(s,e,n),p=p.type;
|
||||
if(p==L)s=h;else if(!h){if(p==F)continue n;break n}}u?u--:c[a++]=s}return c},Nt.prototype.chain=function(){return ke(this)},Nt.prototype.commit=function(){return new Ft(this.value(),this.__chain__)},Nt.prototype.plant=function(n){for(var t,r=this;r instanceof Ut;){var e=ge(r);t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},Nt.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof Lt?(this.__actions__.length&&(n=new Lt(this)),new Ft(n.reverse(),this.__chain__)):this.thru(function(n){return n.reverse()
|
||||
})},Nt.prototype.toString=function(){return this.value()+""},Nt.prototype.run=Nt.prototype.toJSON=Nt.prototype.valueOf=Nt.prototype.value=function(){return Wr(this.__wrapped__,this.__actions__)},Nt.prototype.collect=Nt.prototype.map,Nt.prototype.head=Nt.prototype.first,Nt.prototype.select=Nt.prototype.filter,Nt.prototype.tail=Nt.prototype.rest,Nt}var b,x="3.3.1",A=1,j=2,k=4,E=8,R=16,I=32,O=64,C=128,T=256,S=30,W="...",N=150,U=16,F=0,L=1,$=2,B="Expected a function",z="__lodash_placeholder__",D="[object Arguments]",M="[object Array]",q="[object Boolean]",P="[object Date]",K="[object Error]",V="[object Function]",Y="[object Number]",Z="[object Object]",G="[object RegExp]",J="[object String]",X="[object ArrayBuffer]",H="[object Float32Array]",Q="[object Float64Array]",nt="[object Int8Array]",tt="[object Int16Array]",rt="[object Int32Array]",et="[object Uint8Array]",ut="[object Uint8ClampedArray]",ot="[object Uint16Array]",it="[object Uint32Array]",ft=/\b__p\+='';/g,at=/\b(__p\+=)''\+/g,ct=/(__e\(.*?\)|\b__t\))\+'';/g,lt=/&(?:amp|lt|gt|quot|#39|#96);/g,st=/[&<>"'`]/g,pt=RegExp(lt.source),ht=RegExp(st.source),_t=/<%-([\s\S]+?)%>/g,gt=/<%([\s\S]+?)%>/g,vt=/<%=([\s\S]+?)%>/g,yt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,mt=/^\s*function[ \n\r\t]+\w/,wt=/^0[xX]/,bt=/^\[object .+?Constructor\]$/,xt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,At=/($^)/,jt=/[.*+?^${}()|[\]\/\\]/g,kt=RegExp(jt.source),Et=/\bthis\b/,Rt=/['\n\r\u2028\u2029\\]/g,It=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),Ot=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",Ct="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),Tt={};
|
||||
Tt[H]=Tt[Q]=Tt[nt]=Tt[tt]=Tt[rt]=Tt[et]=Tt[ut]=Tt[ot]=Tt[it]=true,Tt[D]=Tt[M]=Tt[X]=Tt[q]=Tt[P]=Tt[K]=Tt[V]=Tt["[object Map]"]=Tt[Y]=Tt[Z]=Tt[G]=Tt["[object Set]"]=Tt[J]=Tt["[object WeakMap]"]=false;var St={};St[D]=St[M]=St[X]=St[q]=St[P]=St[H]=St[Q]=St[nt]=St[tt]=St[rt]=St[Y]=St[Z]=St[G]=St[J]=St[et]=St[ut]=St[ot]=St[it]=true,St[K]=St[V]=St["[object Map]"]=St["[object Set]"]=St["[object WeakMap]"]=false;var Wt={leading:false,maxWait:0,trailing:false},Nt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Ut={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ft={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Lt={"function":true,object:true},$t={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Bt=Lt[typeof window]&&window!==(this&&this.window)?window:this,zt=Lt[typeof exports]&&exports&&!exports.nodeType&&exports,Lt=Lt[typeof module]&&module&&!module.nodeType&&module,Dt=zt&&Lt&&typeof global=="object"&&global;
|
||||
!Dt||Dt.global!==Dt&&Dt.window!==Dt&&Dt.self!==Dt||(Bt=Dt);var Dt=Lt&&Lt.exports===zt&&zt,Mt=w();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Bt._=Mt, define(function(){return Mt})):zt&&Lt?Dt?(Lt.exports=Mt)._=Mt:zt._=Mt:Bt._=Mt}).call(this);
|
||||
11663
lodash.src.js
11663
lodash.src.js
File diff suppressed because it is too large
Load Diff
53
package.json
53
package.json
@@ -1,29 +1,56 @@
|
||||
{
|
||||
"name": "lodash",
|
||||
"version": "3.3.1",
|
||||
"main": "lodash.src.js",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"curl-amd": "0.8.12",
|
||||
"dojo": "~1.10.0",
|
||||
"jquery": "~1.11.0",
|
||||
"platform": "~1.3.0",
|
||||
"qunit-extras": "~1.4.0",
|
||||
"qunitjs": "~1.17.0",
|
||||
"requirejs": "~2.1.0"
|
||||
"version": "2.4.2",
|
||||
"description": "A utility library delivering consistency, customization, performance, & extras.",
|
||||
"homepage": "https://lodash.com/",
|
||||
"license": "MIT",
|
||||
"main": "dist/lodash.js",
|
||||
"keywords": ["amd", "browser", "client", "customize", "functional", "server", "util"],
|
||||
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||
"contributors": [
|
||||
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
|
||||
"Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)",
|
||||
"Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)",
|
||||
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"
|
||||
],
|
||||
"repository": "lodash/lodash",
|
||||
"files": [
|
||||
"LICENSE.txt",
|
||||
"lodash.js",
|
||||
"dist/lodash.js",
|
||||
"dist/lodash.min.js",
|
||||
"dist/lodash.compat.js",
|
||||
"dist/lodash.compat.min.js",
|
||||
"dist/lodash.underscore.js",
|
||||
"dist/lodash.underscore.min.js"
|
||||
],
|
||||
"jam": {
|
||||
"main": "dist/lodash.compat.js",
|
||||
"include": [
|
||||
"LICENSE.txt",
|
||||
"dist/lodash.js",
|
||||
"dist/lodash.min.js",
|
||||
"dist/lodash.compat.js",
|
||||
"dist/lodash.compat.min.js",
|
||||
"dist/lodash.underscore.js",
|
||||
"dist/lodash.underscore.min.js"
|
||||
]
|
||||
},
|
||||
"volo": {
|
||||
"type": "directory",
|
||||
"ignore": [
|
||||
".*",
|
||||
"*.custom.*",
|
||||
"*.log",
|
||||
"*.min.*",
|
||||
"*.template.*",
|
||||
"*.map",
|
||||
"*.md",
|
||||
"lodash.src.js",
|
||||
"lodash.js",
|
||||
"index.js",
|
||||
"bower.json",
|
||||
"component.json",
|
||||
"doc",
|
||||
"modularize",
|
||||
"node_modules",
|
||||
"perf",
|
||||
"test",
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
;(function(window) {
|
||||
'use strict';
|
||||
|
||||
/** The base path of the lodash builds. */
|
||||
/** The base path of the builds */
|
||||
var basePath = '../';
|
||||
|
||||
/** The lodash build to load. */
|
||||
/** The Lo-Dash build to load */
|
||||
var build = (build = /build=([^&]+)/.exec(location.search)) && decodeURIComponent(build[1]);
|
||||
|
||||
/** The other library to load. */
|
||||
/** The other library to load */
|
||||
var other = (other = /other=([^&]+)/.exec(location.search)) && decodeURIComponent(other[1]);
|
||||
|
||||
/** The `ui` object. */
|
||||
/** The `ui` object */
|
||||
var ui = {};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// Initialize controls.
|
||||
// initialize controls
|
||||
addListener(window, 'load', function() {
|
||||
function eventHandler(event) {
|
||||
var buildIndex = buildList.selectedIndex,
|
||||
@@ -58,10 +58,13 @@
|
||||
span1.innerHTML =
|
||||
'<label for="perf-build">Build: </label>' +
|
||||
'<select id="perf-build">' +
|
||||
'<option value="lodash-compat">lodash (compat)</option>' +
|
||||
'<option value="lodash-modern">lodash (modern)</option>' +
|
||||
'<option value="lodash-custom-dev">lodash (custom development)</option>' +
|
||||
'<option value="lodash-custom">lodash (custom production)</option>' +
|
||||
'<option value="lodash-compat">Lo-Dash (compat)</option>' +
|
||||
'<option value="lodash-legacy">Lo-Dash (legacy)</option>' +
|
||||
'<option value="lodash-mobile">Lo-Dash (mobile)</option>' +
|
||||
'<option value="lodash-modern">Lo-Dash (modern)</option>' +
|
||||
'<option value="lodash-underscore">Lo-Dash (underscore)</option>' +
|
||||
'<option value="lodash-custom-dev">Lo-Dash (custom development)</option>' +
|
||||
'<option value="lodash-custom">Lo-Dash (custom production)</option>' +
|
||||
'</select>';
|
||||
|
||||
var span2 = document.createElement('span');
|
||||
@@ -71,10 +74,13 @@
|
||||
'<select id="perf-other">' +
|
||||
'<option value="underscore-dev">Underscore (development)</option>' +
|
||||
'<option value="underscore">Underscore (production)</option>' +
|
||||
'<option value="lodash-compat">lodash (compat)</option>' +
|
||||
'<option value="lodash-modern">lodash (modern)</option>' +
|
||||
'<option value="lodash-custom-dev">lodash (custom development)</option>' +
|
||||
'<option value="lodash-custom">lodash (custom production)</option>' +
|
||||
'<option value="lodash-compat">Lo-Dash (compat)</option>' +
|
||||
'<option value="lodash-legacy">Lo-Dash (legacy)</option>' +
|
||||
'<option value="lodash-mobile">Lo-Dash (mobile)</option>' +
|
||||
'<option value="lodash-modern">Lo-Dash (modern)</option>' +
|
||||
'<option value="lodash-underscore">Lo-Dash (underscore)</option>' +
|
||||
'<option value="lodash-custom-dev">Lo-Dash (custom development)</option>' +
|
||||
'<option value="lodash-custom">Lo-Dash (custom production)</option>' +
|
||||
'</select>';
|
||||
|
||||
var buildList = span1.lastChild,
|
||||
@@ -87,10 +93,13 @@
|
||||
buildList.selectedIndex = (function() {
|
||||
switch (build) {
|
||||
case 'lodash-compat': return 0;
|
||||
case 'lodash-custom-dev': return 2;
|
||||
case 'lodash-custom': return 3;
|
||||
case 'lodash-legacy': return 1;
|
||||
case 'lodash-mobile': return 2;
|
||||
case 'lodash-underscore': return 4;
|
||||
case 'lodash-custom-dev': return 5;
|
||||
case 'lodash-custom': return 6;
|
||||
case 'lodash-modern':
|
||||
case null: return 1;
|
||||
case null: return 3;
|
||||
}
|
||||
return -1;
|
||||
}());
|
||||
@@ -99,9 +108,12 @@
|
||||
switch (other) {
|
||||
case 'underscore-dev': return 0;
|
||||
case 'lodash-compat': return 2;
|
||||
case 'lodash-modern': return 3;
|
||||
case 'lodash-custom-dev': return 4;
|
||||
case 'lodash-custom': return 5;
|
||||
case 'lodash-legacy': return 3;
|
||||
case 'lodash-mobile': return 4;
|
||||
case 'lodash-modern': return 5;
|
||||
case 'lodash-underscore': return 6;
|
||||
case 'lodash-custom-dev': return 7;
|
||||
case 'lodash-custom': return 8;
|
||||
case 'underscore':
|
||||
case null: return 1;
|
||||
}
|
||||
@@ -112,38 +124,49 @@
|
||||
addListener(otherList, 'change', eventHandler);
|
||||
});
|
||||
|
||||
// The lodash build file path.
|
||||
// expose Lo-Dash build file path
|
||||
ui.buildPath = (function() {
|
||||
var result;
|
||||
switch (build) {
|
||||
case 'lodash-compat': result = 'lodash.compat.min.js'; break;
|
||||
case 'lodash-compat': result = 'dist/lodash.compat.min.js'; break;
|
||||
case 'lodash-legacy': result = 'dist/lodash.legacy.min.js'; break;
|
||||
case 'lodash-mobile': result = 'dist/lodash.mobile.min.js'; break;
|
||||
case 'lodash-underscore': result = 'dist/lodash.underscore.min.js'; break;
|
||||
case 'lodash-custom-dev': result = 'lodash.custom.js'; break;
|
||||
case 'lodash-custom': result = 'lodash.custom.min.js'; break;
|
||||
case null: build = 'lodash-modern';
|
||||
case 'lodash-modern': result = 'lodash.min.js'; break;
|
||||
case null: build = 'lodash-modern';
|
||||
case 'lodash-modern': result = 'dist/lodash.min.js'; break;
|
||||
default: return build;
|
||||
}
|
||||
return basePath + result;
|
||||
}());
|
||||
|
||||
// The other library file path.
|
||||
// expose other library file path
|
||||
ui.otherPath = (function() {
|
||||
var result;
|
||||
switch (other) {
|
||||
case 'lodash-compat': result = 'lodash.compat.min.js'; break;
|
||||
case 'lodash-modern': result = 'lodash.min.js'; break;
|
||||
case 'lodash-compat': result = 'dist/lodash.compat.min.js'; break;
|
||||
case 'lodash-legacy': result = 'dist/lodash.legacy.min.js'; break;
|
||||
case 'lodash-mobile': result = 'dist/lodash.mobile.min.js'; break;
|
||||
case 'lodash-modern': result = 'dist/lodash.min.js'; break;
|
||||
case 'lodash-underscore': result = 'dist/lodash.underscore.min.js'; break;
|
||||
case 'lodash-custom-dev': result = 'lodash.custom.js'; break;
|
||||
case 'lodash-custom': result = 'lodash.custom.min.js'; break;
|
||||
case 'underscore-dev': result = 'vendor/underscore/underscore.js'; break;
|
||||
case null: other = 'underscore';
|
||||
case null: other = 'underscore';
|
||||
case 'underscore': result = 'vendor/underscore/underscore-min.js'; break;
|
||||
default: return other;
|
||||
}
|
||||
return basePath + result;
|
||||
}());
|
||||
|
||||
ui.urlParams = { 'build': build, 'other': other };
|
||||
// expose `ui.urlParams` properties
|
||||
ui.urlParams = {
|
||||
'build': build,
|
||||
'other': other
|
||||
};
|
||||
|
||||
// expose `ui`
|
||||
window.ui = ui;
|
||||
|
||||
}(this));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lodash Performance Suite</title>
|
||||
<title>Lo-Dash Performance Suite</title>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
@@ -28,8 +28,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="perf-toolbar"></div>
|
||||
<script src="../node_modules/platform/platform.js"></script>
|
||||
<script src="../lodash.src.js"></script>
|
||||
<script src="../vendor/platform.js/platform.js"></script>
|
||||
<script src="../lodash.js"></script>
|
||||
<script src="../vendor/benchmark.js/benchmark.js"></script>
|
||||
<script src="../vendor/firebug-lite/src/firebug-lite-debug.js"></script>
|
||||
<script src="./asset/perf-ui.js"></script>
|
||||
@@ -69,8 +69,8 @@
|
||||
// is the applet permitted?
|
||||
if (!/[?&]nojava=true(?:&|$)/.test(location.search)) {
|
||||
// is the applet really needed?
|
||||
while (!(measured = new Date - begin)) {}
|
||||
if (measured > 1 && !((perfNow = window.performance) && typeof (perfNow.now || perfNow.webkitNow) == 'function')) {
|
||||
while (!(measured = new Date - begin)) { }
|
||||
if (measured != 1 && !((perfNow = window.performance) && typeof (perfNow.now || perfNow.webkitNow) == 'function')) {
|
||||
// load applet
|
||||
document.write('<applet code="nano" archive="../vendor/benchmark.js/nano.jar"></applet>');
|
||||
}
|
||||
|
||||
815
perf/perf.js
815
perf/perf.js
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,12 @@
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
echo "Running performance suite in node..."
|
||||
node perf.js ../lodash.js && node perf.js ../lodash.min.js
|
||||
node perf.js ../dist/lodash.js && node perf.js ../dist/lodash.min.js
|
||||
|
||||
for cmd in rhino "rhino -require" narwhal ringo phantomjs; do
|
||||
echo ""
|
||||
echo "Running performance suite in $cmd..."
|
||||
$cmd perf.js ../lodash.src.js
|
||||
$cmd perf.js ../dist/lodash.compat.js && $cmd perf.js ../dist/lodash.compat.min.js
|
||||
done
|
||||
|
||||
echo ""
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
;(function() {
|
||||
|
||||
/** Used to determine if values are of the language type Object. */
|
||||
var objectTypes = {
|
||||
'function': true,
|
||||
'object': true
|
||||
};
|
||||
|
||||
/** Used as the `Set#toString` return value. */
|
||||
var nativeString = String(Object.prototype.toString).replace(/toString/g, 'Set');
|
||||
|
||||
/** Used as a reference to the global object. */
|
||||
var root = (objectTypes[typeof window] && window) || this;
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
||||
|
||||
/** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
|
||||
var freeGlobal = objectTypes[typeof global] && global;
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Installs `Set` on the given `context` object.
|
||||
*
|
||||
* @memberOf exports
|
||||
* @param {Object} context The context object.
|
||||
*/
|
||||
function runInContext(context) {
|
||||
|
||||
/**
|
||||
* Creates a `Set` object.
|
||||
*/
|
||||
function Set() {
|
||||
this.__cache__ = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index at which the first occurrence of `value` is found using
|
||||
* strict equality for comparisons, i.e. `===`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @param {*} value The value to search for.
|
||||
* @returns {number} Returns the index of the matched value or `-1`.
|
||||
*/
|
||||
function indexOf(array, value) {
|
||||
var index = -1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is in the set.
|
||||
*
|
||||
* @memberOf Set
|
||||
* @param {*} value The value to search for.
|
||||
* @returns {boolean} Returns `true` if `value` is found, else `false`.
|
||||
*/
|
||||
function has(value) {
|
||||
var type = typeof value,
|
||||
cache = this.__cache__;
|
||||
|
||||
if (type == 'boolean' || value == null) {
|
||||
return cache[value] || false;
|
||||
}
|
||||
if (type != 'number' && type != 'string') {
|
||||
type = 'object';
|
||||
}
|
||||
var key = type == 'number' ? value : '_' + value;
|
||||
cache = (cache = cache[type]) && cache[key];
|
||||
|
||||
return type == 'object'
|
||||
? (cache && indexOf(cache, value) > -1 ? true : false)
|
||||
: (cache || false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds `value` to the set.
|
||||
*
|
||||
* @memberOf Set
|
||||
* @param {*} value The value to add.
|
||||
*/
|
||||
function add(value) {
|
||||
var cache = this.__cache__,
|
||||
type = typeof value;
|
||||
|
||||
if (type == 'boolean' || value == null) {
|
||||
cache[value] = true;
|
||||
} else {
|
||||
if (type != 'number' && type != 'string') {
|
||||
type = 'object';
|
||||
}
|
||||
var key = type == 'number' ? value : '_' + value,
|
||||
typeCache = cache[type] || (cache[type] = {});
|
||||
|
||||
if (type == 'object') {
|
||||
var array = typeCache[key];
|
||||
if (array) {
|
||||
array.push(value);
|
||||
} else {
|
||||
typeCache[key] = [value];
|
||||
}
|
||||
} else {
|
||||
typeCache[key] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces the `toString` result of `Set`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf Set
|
||||
* @returns {string} Returns the string result.
|
||||
*/
|
||||
function toString() {
|
||||
return nativeString;
|
||||
}
|
||||
|
||||
Set.toString = toString;
|
||||
Set.prototype.add = add;
|
||||
Set.prototype.has = has;
|
||||
|
||||
if (!root.Set) {
|
||||
context.Set = Set;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
if (freeExports) {
|
||||
freeExports.runInContext = runInContext;
|
||||
} else {
|
||||
runInContext(root);
|
||||
}
|
||||
}.call(this));
|
||||
@@ -1,16 +1,16 @@
|
||||
;(function(window) {
|
||||
'use strict';
|
||||
|
||||
/** The base path of the lodash builds. */
|
||||
/** The base path of the builds */
|
||||
var basePath = '../';
|
||||
|
||||
/** The lodash build to load. */
|
||||
/** The Lo-Dash build to load */
|
||||
var build = (build = /build=([^&]+)/.exec(location.search)) && decodeURIComponent(build[1]);
|
||||
|
||||
/** The module loader to use. */
|
||||
/** The module loader to use */
|
||||
var loader = (loader = /loader=([^&]+)/.exec(location.search)) && decodeURIComponent(loader[1]);
|
||||
|
||||
/** The `ui` object. */
|
||||
/** The `ui` object */
|
||||
var ui = {};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// Initialize controls.
|
||||
// initialize controls
|
||||
addListener(window, 'load', function() {
|
||||
function eventHandler(event) {
|
||||
var buildIndex = buildList.selectedIndex,
|
||||
@@ -55,39 +55,43 @@
|
||||
|
||||
function init() {
|
||||
var toolbar = document.getElementById('qunit-testrunner-toolbar');
|
||||
if (!toolbar) {
|
||||
setTimeout(init, 15);
|
||||
return;
|
||||
if (toolbar) {
|
||||
toolbar.appendChild(span1);
|
||||
toolbar.appendChild(span2);
|
||||
|
||||
buildList.selectedIndex = (function() {
|
||||
switch (build) {
|
||||
case 'lodash-compat': return 1;
|
||||
case 'lodash-modern-dev': return 2;
|
||||
case 'lodash-modern': return 3;
|
||||
case 'lodash-legacy': return 4;
|
||||
case 'lodash-mobile': return 5;
|
||||
case 'lodash-underscore': return 6;
|
||||
case 'lodash-custom-dev': return 7;
|
||||
case 'lodash-custom': return 8;
|
||||
case 'lodash-compat-dev':
|
||||
case null: return 0;
|
||||
}
|
||||
return -1;
|
||||
}());
|
||||
|
||||
loaderList.selectedIndex = (function() {
|
||||
switch (loader) {
|
||||
case 'curl': return 1;
|
||||
case 'dojo': return 2;
|
||||
case 'requirejs': return 3;
|
||||
case 'none':
|
||||
case null: return 0;
|
||||
}
|
||||
return -1;
|
||||
}());
|
||||
|
||||
addListener(buildList, 'change', eventHandler);
|
||||
addListener(loaderList, 'change', eventHandler);
|
||||
}
|
||||
else {
|
||||
setTimeout(init, 15);
|
||||
}
|
||||
toolbar.appendChild(span1);
|
||||
toolbar.appendChild(span2);
|
||||
|
||||
buildList.selectedIndex = (function() {
|
||||
switch (build) {
|
||||
case 'lodash-compat': return 1;
|
||||
case 'lodash-modern-dev': return 2;
|
||||
case 'lodash-modern': return 3;
|
||||
case 'lodash-custom-dev': return 4;
|
||||
case 'lodash-custom': return 5;
|
||||
case 'lodash-compat-dev':
|
||||
case null: return 0;
|
||||
}
|
||||
return -1;
|
||||
}());
|
||||
|
||||
loaderList.selectedIndex = (function() {
|
||||
switch (loader) {
|
||||
case 'curl': return 1;
|
||||
case 'dojo': return 2;
|
||||
case 'requirejs': return 3;
|
||||
case 'none':
|
||||
case null: return 0;
|
||||
}
|
||||
return -1;
|
||||
}());
|
||||
|
||||
addListener(buildList, 'change', eventHandler);
|
||||
addListener(loaderList, 'change', eventHandler);
|
||||
}
|
||||
|
||||
var span1 = document.createElement('span');
|
||||
@@ -95,12 +99,15 @@
|
||||
span1.innerHTML =
|
||||
'<label for="qunit-build">Build: </label>' +
|
||||
'<select id="qunit-build">' +
|
||||
'<option value="lodash-compat-dev">lodash (compat development)</option>' +
|
||||
'<option value="lodash-compat">lodash (compat production)</option>' +
|
||||
'<option value="lodash-modern-dev">lodash (modern development)</option>' +
|
||||
'<option value="lodash-modern">lodash (modern production)</option>' +
|
||||
'<option value="lodash-custom-dev">lodash (custom development)</option>' +
|
||||
'<option value="lodash-custom">lodash (custom production)</option>' +
|
||||
'<option value="lodash-compat-dev">Lo-Dash (compat development)</option>' +
|
||||
'<option value="lodash-compat">Lo-Dash (compat production)</option>' +
|
||||
'<option value="lodash-modern-dev">Lo-Dash (modern development)</option>' +
|
||||
'<option value="lodash-modern">Lo-Dash (modern production)</option>' +
|
||||
'<option value="lodash-legacy">Lo-Dash (legacy)</option>' +
|
||||
'<option value="lodash-mobile">Lo-Dash (mobile)</option>' +
|
||||
'<option value="lodash-underscore">Lo-Dash (underscore)</option>' +
|
||||
'<option value="lodash-custom-dev">Lo-Dash (custom development)</option>' +
|
||||
'<option value="lodash-custom">Lo-Dash (custom production)</option>' +
|
||||
'</select>';
|
||||
|
||||
var span2 = document.createElement('span');
|
||||
@@ -117,57 +124,51 @@
|
||||
var buildList = span1.lastChild,
|
||||
loaderList = span2.lastChild;
|
||||
|
||||
setTimeout(function() {
|
||||
ui.timing.loadEventEnd = +new Date;
|
||||
}, 1);
|
||||
|
||||
init();
|
||||
});
|
||||
|
||||
// Used to indicate testing a foreign file.
|
||||
ui.isForeign = RegExp('^(\\w+:)?//').test(build);
|
||||
|
||||
// Used to indicate testing a modularized build.
|
||||
ui.isModularize = /\b(?:amd|commonjs|es6?|node|npm|(index|main)\.js)\b/.test([location.pathname, location.search]);
|
||||
|
||||
// Used to indicate testing in Sauce Labs' automated test cloud.
|
||||
ui.isSauceLabs = location.port == '9001';
|
||||
|
||||
// Used to indicate that lodash is in strict mode.
|
||||
ui.isStrict = /\bes6?\b/.test([location.pathname, location.search]);
|
||||
|
||||
// The lodash build file path.
|
||||
// expose Lo-Dash build file path
|
||||
ui.buildPath = (function() {
|
||||
var result;
|
||||
switch (build) {
|
||||
case 'lodash-compat': result = 'lodash.compat.min.js'; break;
|
||||
case 'lodash-modern-dev': result = 'lodash.js'; break;
|
||||
case 'lodash-modern': result = 'lodash.min.js'; break;
|
||||
case 'lodash-compat': result = 'dist/lodash.compat.min.js'; break;
|
||||
case 'lodash-modern-dev': result = 'dist/lodash.js'; break;
|
||||
case 'lodash-modern': result = 'dist/lodash.min.js'; break;
|
||||
case 'lodash-legacy': result = 'dist/lodash.legacy.min.js'; break;
|
||||
case 'lodash-mobile': result = 'dist/lodash.mobile.min.js'; break;
|
||||
case 'lodash-underscore': result = 'dist/lodash.underscore.min.js'; break;
|
||||
case 'lodash-custom-dev': result = 'lodash.custom.js'; break;
|
||||
case 'lodash-custom': result = 'lodash.custom.min.js'; break;
|
||||
case null: build = 'lodash-compat-dev';
|
||||
case 'lodash-compat-dev': result = 'lodash.src.js'; break;
|
||||
case null: build = 'lodash-compat-dev';
|
||||
case 'lodash-compat-dev': result = 'lodash.js'; break;
|
||||
default: return build;
|
||||
}
|
||||
return basePath + result;
|
||||
}());
|
||||
|
||||
// The module loader file path.
|
||||
// expose module loader file path
|
||||
ui.loaderPath = (function() {
|
||||
var result;
|
||||
switch (loader) {
|
||||
case 'curl': result = 'node_modules/curl-amd/dist/curl-kitchen-sink/curl.js'; break;
|
||||
case 'dojo': result = 'node_modules/dojo/dojo.js'; break;
|
||||
case 'requirejs': result = 'node_modules/requirejs/require.js'; break;
|
||||
case 'curl': result = 'vendor/curl/dist/curl-kitchen-sink/curl.js'; break;
|
||||
case 'dojo': result = 'vendor/dojo/dojo.js'; break;
|
||||
case 'requirejs': result = 'vendor/requirejs/require.js'; break;
|
||||
case null: loader = 'none'; return '';
|
||||
default: return loader;
|
||||
}
|
||||
return basePath + result;
|
||||
}());
|
||||
|
||||
ui.urlParams = { 'build': build, 'loader': loader };
|
||||
ui.timing = { 'loadEventEnd': 0 };
|
||||
// expose `ui.urlParams` properties
|
||||
ui.urlParams = {
|
||||
'build': build,
|
||||
'loader': loader
|
||||
};
|
||||
|
||||
// used to indicate testing a modularized build
|
||||
ui.isModularize = /\b(?:commonjs|(index|main)\.js|lodash-(?:amd|node)|modularize|npm)\b/.test([location.pathname, location.search, ui.buildPath]);
|
||||
|
||||
// expose `ui`
|
||||
window.ui = ui;
|
||||
|
||||
}(this));
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
;(function() {
|
||||
|
||||
/** Used to determine if values are of the language type Object. */
|
||||
var objectTypes = {
|
||||
'function': true,
|
||||
'object': true
|
||||
};
|
||||
|
||||
/** Used as the `WeakMap#toString` return value. */
|
||||
var nativeString = String(Object.prototype.toString).replace(/toString/g, 'WeakMap');
|
||||
|
||||
/** Used as a reference to the global object. */
|
||||
var root = (objectTypes[typeof window] && window) || this;
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
||||
|
||||
/** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
|
||||
var freeGlobal = objectTypes[typeof global] && global;
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Installs `WeakMap` on the given `context` object.
|
||||
*
|
||||
* @memberOf exports
|
||||
* @param {Object} context The context object.
|
||||
*/
|
||||
function runInContext(context) {
|
||||
|
||||
/**
|
||||
* Creates a `WeakMap` object.
|
||||
*/
|
||||
function WeakMap() {
|
||||
// No operation performed.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value associated with the given key.
|
||||
*
|
||||
* @memberOf WeakMap
|
||||
* @param {Object} key The key object.
|
||||
* @returns {*} Returns the associated value, else `undefined`.
|
||||
*/
|
||||
function get(key) {
|
||||
return key.__weakmap__;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value for the given key.
|
||||
*
|
||||
* @memberOf WeakMap
|
||||
* @param {Object} key The key object.
|
||||
* @param {*} value The value to set.
|
||||
*/
|
||||
function set(key, value) {
|
||||
key.__weakmap__ = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces the `toString` result of `WeakMap`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf WeakMap
|
||||
* @returns {string} Returns the string result.
|
||||
*/
|
||||
function toString() {
|
||||
return nativeString;
|
||||
}
|
||||
|
||||
WeakMap.toString = toString;
|
||||
WeakMap.prototype.get = get;
|
||||
WeakMap.prototype.set = set;
|
||||
|
||||
if (!root.WeakMap) {
|
||||
context.WeakMap = WeakMap;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
if (freeExports) {
|
||||
freeExports.runInContext = runInContext;
|
||||
} else {
|
||||
runInContext(root);
|
||||
}
|
||||
}.call(this));
|
||||
@@ -1,12 +1,6 @@
|
||||
self.console || (self.console = { 'log': function() {} });
|
||||
|
||||
addEventListener('message', function(e) {
|
||||
if (e.data) {
|
||||
try {
|
||||
importScripts('../' + e.data);
|
||||
} catch(e) {
|
||||
self._ = { 'VERSION': e.message };
|
||||
}
|
||||
importScripts('../' + e.data);
|
||||
postMessage(_.VERSION);
|
||||
}
|
||||
}, false);
|
||||
|
||||
@@ -3,139 +3,74 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Backbone Test Suite</title>
|
||||
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
|
||||
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css">
|
||||
<style>
|
||||
body > #qunit-header {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<h1 id="qunit-header"></h1>
|
||||
<div id="qunit-fixture">
|
||||
<div id='testElement'>
|
||||
<h1>Test</h1>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// avoid reporting tests to Sauce Labs when script errors occur
|
||||
if (location.port == '9001') {
|
||||
window.onerror = function(message) {
|
||||
if (window.QUnit) {
|
||||
QUnit.config.done.length = 0;
|
||||
}
|
||||
global_test_results = { 'message': message };
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
|
||||
<script src="../node_modules/qunit-extras/qunit-extras.js"></script>
|
||||
<script src="../vendor/qunit/qunit/qunit.js"></script>
|
||||
<script src="../vendor/qunit-extras/qunit-extras.js"></script>
|
||||
<script src="../vendor/json-js/json2.js"></script>
|
||||
<script src="../node_modules/platform/platform.js"></script>
|
||||
<script src="../vendor/jquery/jquery.js"></script>
|
||||
<script src="../vendor/platform.js/platform.js"></script>
|
||||
<script src="./asset/test-ui.js"></script>
|
||||
<script src="../lodash.src.js"></script>
|
||||
<script src="../lodash.js"></script>
|
||||
<script>
|
||||
var mixinPrereqs = (function() {
|
||||
var lodash = _.noConflict();
|
||||
return function(_) {
|
||||
_.mixin({
|
||||
'debounce': _.debounce || lodash.debounce,
|
||||
'defer': _.defer || lodash.defer,
|
||||
'pluck': _.pluck || lodash.pluck
|
||||
});
|
||||
};
|
||||
}());
|
||||
var lodash = _.noConflict();
|
||||
|
||||
QUnit.config.asyncRetries = 10;
|
||||
QUnit.config.asyncRetries = 5;
|
||||
QUnit.config.hidepassed = true;
|
||||
|
||||
// load lodash
|
||||
if (!ui.isModularize) {
|
||||
document.write('<script src="' + ui.buildPath + '"><\/script>');
|
||||
// excuse tests we intentionally fail or those with problems
|
||||
QUnit.config.excused = {
|
||||
'Backbone.Collection': {
|
||||
'set with many models does not overflow the stack': true
|
||||
},
|
||||
'Backbone.Router': {
|
||||
'#2656 - No trailing slash on root.': true,
|
||||
'#2765 - Fragment matching sans query/hash.': true
|
||||
}
|
||||
};
|
||||
|
||||
// only excuse `Backbone.Router` tests in IE < 8
|
||||
if (!(document.attachEvent && (document.documentMode || 0) < 8)) {
|
||||
delete QUnit.config.excused['Backbone.Router'];
|
||||
}
|
||||
// load test scripts
|
||||
document.write(ui.urlParams.loader != 'none'
|
||||
? '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
|
||||
: ([
|
||||
'<script src="' + ui.buildPath + '"><\/script>',
|
||||
'<script src="../node_modules/jquery/dist/jquery.js"><\/script>',
|
||||
'<script src="../vendor/backbone/backbone.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/environment.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/noconflict.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/events.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/model.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/collection.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/router.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/view.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/sync.js"><\/script>'
|
||||
].join('\n'))
|
||||
);
|
||||
|
||||
// assign results to `global_test_results` for Sauce Labs
|
||||
var global_test_results;
|
||||
QUnit.done(function(results) {
|
||||
global_test_results = results;
|
||||
});
|
||||
|
||||
// load the build of Lo-Dash
|
||||
document.write('<script src="' + ui.buildPath + '"><\/script>');
|
||||
</script>
|
||||
<script>
|
||||
(function() {
|
||||
if (window.curl) {
|
||||
curl.config({ 'apiName': 'require' });
|
||||
}
|
||||
if (!window.require) {
|
||||
mixinPrereqs(_);
|
||||
return;
|
||||
}
|
||||
var reBasename = /[\w.-]+$/,
|
||||
basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
|
||||
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
||||
locationPath = modulePath.replace(reBasename, '').replace(/^\/|\/$/g, ''),
|
||||
moduleMain = modulePath.match(reBasename)[0],
|
||||
uid = +new Date;
|
||||
|
||||
function getConfig() {
|
||||
var result = {
|
||||
'baseUrl': './',
|
||||
'urlArgs': 't=' + uid++,
|
||||
'waitSeconds': 0,
|
||||
'paths': {
|
||||
'backbone': '../vendor/backbone/backbone',
|
||||
'jquery': '../node_modules/jquery/dist/jquery'
|
||||
},
|
||||
'packages': [{
|
||||
'name': 'test',
|
||||
'location': '../vendor/backbone/test',
|
||||
'config': {
|
||||
// work around no global being exported
|
||||
'exports': 'QUnit',
|
||||
'loader': 'curl/loader/legacy'
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
if (ui.isModularize) {
|
||||
result.packages.push({
|
||||
'name': 'underscore',
|
||||
'location': locationPath,
|
||||
'main': moduleMain
|
||||
});
|
||||
} else {
|
||||
result.paths.underscore = modulePath;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
require(getConfig(), ['underscore', 'backbone'], function(lodash) {
|
||||
mixinPrereqs(lodash);
|
||||
|
||||
if (ui.isModularize) {
|
||||
window._ = lodash;
|
||||
}
|
||||
require(getConfig(), [
|
||||
'test/environment',
|
||||
'test/noconflict',
|
||||
'test/events',
|
||||
'test/model',
|
||||
'test/collection',
|
||||
'test/router',
|
||||
'test/view',
|
||||
'test/sync'
|
||||
], function() {
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
}());
|
||||
_.mixin({
|
||||
'debounce': _.debounce || lodash.debounce,
|
||||
'defer': _.defer || lodash.defer,
|
||||
'pluck': _.pluck || lodash.pluck
|
||||
});
|
||||
</script>
|
||||
<script src="../vendor/backbone/backbone.js"></script>
|
||||
<script src="../vendor/backbone/test/environment.js"></script>
|
||||
<script src="../vendor/backbone/test/noconflict.js"></script>
|
||||
<script src="../vendor/backbone/test/events.js"></script>
|
||||
<script src="../vendor/backbone/test/model.js"></script>
|
||||
<script src="../vendor/backbone/test/collection.js"></script>
|
||||
<script src="../vendor/backbone/test/router.js"></script>
|
||||
<script src="../vendor/backbone/test/view.js"></script>
|
||||
<script src="../vendor/backbone/test/sync.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
464
test/index.html
464
test/index.html
@@ -2,8 +2,8 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lodash Test Suite</title>
|
||||
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
|
||||
<title>Lo-Dash Test Suite</title>
|
||||
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css">
|
||||
<style>
|
||||
#exports {
|
||||
display: none;
|
||||
@@ -11,257 +11,99 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
// avoid reporting tests to Sauce Labs when script errors occur
|
||||
if (location.port == '9001') {
|
||||
window.onerror = function(message) {
|
||||
if (window.QUnit) {
|
||||
QUnit.config.done.length = 0;
|
||||
}
|
||||
global_test_results = { 'message': message };
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
|
||||
<script src="../node_modules/qunit-extras/qunit-extras.js"></script>
|
||||
<script src="../node_modules/platform/platform.js"></script>
|
||||
<script src="./asset/set.js"></script>
|
||||
<script src="./asset/weakmap.js"></script>
|
||||
<script src="../vendor/qunit/qunit/qunit.js"></script>
|
||||
<script src="../vendor/qunit-extras/qunit-extras.js"></script>
|
||||
<script src="../vendor/platform.js/platform.js"></script>
|
||||
<script src="./asset/test-ui.js"></script>
|
||||
<div id="qunit"></div>
|
||||
<div id="exports"></div>
|
||||
<script>
|
||||
var setProperty = (function() {
|
||||
var _defineProperty = Object.defineProperty;
|
||||
return function(object, key, value) {
|
||||
try {
|
||||
_defineProperty(object, key, {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'writable': true,
|
||||
'value': value
|
||||
});
|
||||
} catch(e) {
|
||||
object[key] = value;
|
||||
}
|
||||
};
|
||||
}());
|
||||
// set bad shims
|
||||
Array._isArray = Array.isArray;
|
||||
Array.isArray = function() {};
|
||||
|
||||
function addBizarroMethods() {
|
||||
var funcProto = Function.prototype,
|
||||
objectProto = Object.prototype,
|
||||
stringProto = String.prototype;
|
||||
Date._now = Date.now;
|
||||
Date.now = function() {};
|
||||
|
||||
var hasOwnProperty = objectProto.hasOwnProperty,
|
||||
fnToString = funcProto.toString,
|
||||
nativeString = fnToString.call(objectProto.toString),
|
||||
noop = function() {},
|
||||
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
||||
reToString = /toString/g,
|
||||
whitespace = ' \t\x0B\f\xA0\ufeff\n\r\u2028\u2029\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000';
|
||||
Function.prototype._bind = Function.prototype.bind;
|
||||
Function.prototype.bind = function() { return function() {}; };
|
||||
|
||||
function constant(value) {
|
||||
return function() {
|
||||
return value;
|
||||
};
|
||||
}
|
||||
function createToString(funcName) {
|
||||
return constant(nativeString.replace(reToString, funcName));
|
||||
}
|
||||
// allow bypassing native checks
|
||||
setProperty(funcProto, 'toString', (function() {
|
||||
function wrapper() {
|
||||
setProperty(funcProto, 'toString', fnToString);
|
||||
var result = hasOwnProperty.call(this, 'toString') ? this.toString() : fnToString.call(this);
|
||||
setProperty(funcProto, 'toString', wrapper);
|
||||
return result;
|
||||
}
|
||||
return wrapper;
|
||||
}()));
|
||||
Object._create = Object.create;
|
||||
Object.create = function() {};
|
||||
|
||||
// add extensions
|
||||
funcProto._method = noop;
|
||||
Object._defineProperty = Object.defineProperty;
|
||||
Object.defineProperty = function() {};
|
||||
|
||||
// set bad shims
|
||||
setProperty(Array, '_isArray', Array.isArray);
|
||||
setProperty(Array, 'isArray', noop);
|
||||
Object._getPrototypeOf = Object.getPrototypeOf;
|
||||
Object.getPrototypeOf = function() {};
|
||||
|
||||
setProperty(Date, '_now', Date.now);
|
||||
setProperty(Date, 'now', noop);
|
||||
Object._keys = Object.keys;
|
||||
Object.keys = function() {};
|
||||
|
||||
setProperty(Object, '_getPrototypeOf', Object.getPrototypeOf);
|
||||
setProperty(Object, 'getPrototypeOf', noop);
|
||||
|
||||
setProperty(Object, '_keys', Object.keys);
|
||||
setProperty(Object, 'keys', noop);
|
||||
|
||||
setProperty(objectProto, '_propertyIsEnumerable', propertyIsEnumerable);
|
||||
setProperty(objectProto, 'propertyIsEnumerable', function(key) {
|
||||
if (key == '1' && this && typeof this == 'object' && this.length === 2 &&
|
||||
hasOwnProperty.call(this, 'callee') &&
|
||||
!propertyIsEnumerable.call(this, 'callee') &&
|
||||
this[0] === 0 && this[1] === 0) {
|
||||
throw new Error;
|
||||
}
|
||||
return propertyIsEnumerable.call(this, key);
|
||||
});
|
||||
|
||||
setProperty(Number, '_isFinite', Number.isFinite);
|
||||
setProperty(Number, 'isFinite', noop);
|
||||
|
||||
setProperty(window, '_ArrayBuffer', window.ArrayBuffer);
|
||||
if (window.ArrayBuffer && window.Uint8Array) {
|
||||
ArrayBuffer = (function(_ArrayBuffer) {
|
||||
function ArrayBuffer(byteLength) {
|
||||
var buffer = new _ArrayBuffer(byteLength);
|
||||
if (!byteLength) {
|
||||
setProperty(buffer, 'slice', buffer.slice ? null : bufferSlice);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
function bufferSlice() {
|
||||
var newBuffer = new _ArrayBuffer(this.byteLength),
|
||||
view = new Uint8Array(newBuffer);
|
||||
|
||||
view.set(new Uint8Array(this));
|
||||
return newBuffer;
|
||||
}
|
||||
setProperty(ArrayBuffer, 'toString', createToString('ArrayBuffer'));
|
||||
setProperty(bufferSlice, 'toString', createToString('slice'));
|
||||
return ArrayBuffer;
|
||||
}(_ArrayBuffer));
|
||||
}
|
||||
if (!window.Float64Array && window.Uint8Array) {
|
||||
Float64Array = (function() {
|
||||
function Float64Array(buffer, byteOffset, length) {
|
||||
return arguments.length == 1
|
||||
? new Uint8Array(buffer)
|
||||
: new Uint8Array(buffer, byteOffset || 0, length || buffer.byteLength);
|
||||
}
|
||||
setProperty(Float64Array, 'BYTES_PER_ELEMENT', 8);
|
||||
setProperty(Float64Array, 'toString', createToString('Float64Array'));
|
||||
return Float64Array;
|
||||
}());
|
||||
}
|
||||
setProperty(window, '_Set', window.Set);
|
||||
setProperty(window, 'Set', noop);
|
||||
|
||||
setProperty(window, '_WeakMap', window.WeakMap);
|
||||
setProperty(window, 'WeakMap', noop);
|
||||
|
||||
setProperty(window, '_parseInt', parseInt);
|
||||
setProperty(window, 'parseInt', (function(_parseInt) {
|
||||
var checkStr = whitespace + '08',
|
||||
isFaked = _parseInt(checkStr) != 8,
|
||||
reHexPrefix = /^0[xX]/,
|
||||
reTrim = RegExp('^[' + whitespace + ']+|[' + whitespace + ']+$');
|
||||
|
||||
return function(value, radix) {
|
||||
if (value == checkStr && !isFaked) {
|
||||
isFaked = true;
|
||||
return 0;
|
||||
}
|
||||
value = String(value == null ? '' : value).replace(reTrim, '');
|
||||
return _parseInt(value, +radix || (reHexPrefix.test(value) ? 16 : 10));
|
||||
};
|
||||
}(_parseInt)));
|
||||
|
||||
// fake lack of DOM support
|
||||
setProperty(document, '_createDocumentFragment', document.createDocumentFragment);
|
||||
document.createDocumentFragment = noop;
|
||||
|
||||
// fake `WinRTError`
|
||||
setProperty(window, 'WinRTError', Error);
|
||||
|
||||
// fake free variable `global`
|
||||
setProperty(window, 'exports', window);
|
||||
setProperty(window, 'global', window);
|
||||
setProperty(window, 'module', {});
|
||||
}
|
||||
|
||||
function removeBizarroMethods() {
|
||||
var funcProto = Function.prototype,
|
||||
objectProto = Object.prototype,
|
||||
stringProto = String.prototype;
|
||||
|
||||
if (Array._isArray) {
|
||||
setProperty(Array, 'isArray', Array._isArray);
|
||||
} else {
|
||||
delete Array.isArray;
|
||||
}
|
||||
if (Date._now) {
|
||||
setProperty(Date, 'now', Date._now);
|
||||
} else {
|
||||
delete Date.now;
|
||||
}
|
||||
if (Object._getPrototypeOf) {
|
||||
setProperty(Object, 'getPrototypeOf', Object._getPrototypeOf);
|
||||
} else {
|
||||
delete Object.getPrototypeOf;
|
||||
}
|
||||
if (Object._keys) {
|
||||
setProperty(Object, 'keys', Object._keys);
|
||||
} else {
|
||||
delete Object.keys;
|
||||
}
|
||||
if (Number._isFinite) {
|
||||
setProperty(Number, 'isFinite', Number._isFinite);
|
||||
} else {
|
||||
delete Number.isFinite;
|
||||
}
|
||||
if (window._ArrayBuffer) {
|
||||
ArrayBuffer = _ArrayBuffer;
|
||||
}
|
||||
setProperty(window, '_ArrayBuffer', undefined);
|
||||
|
||||
if (window._Set) {
|
||||
Set = _Set;
|
||||
}
|
||||
setProperty(window, '_Set', undefined);
|
||||
|
||||
if (window._WeakMap) {
|
||||
WeakMap = _WeakMap;
|
||||
}
|
||||
setProperty(window, '_WeakMap', undefined);
|
||||
|
||||
setProperty(window, 'parseInt', window._parseInt);
|
||||
setProperty(window, '_parseInt', undefined);
|
||||
|
||||
document.createDocumentFragment = document._createDocumentFragment;
|
||||
setProperty(document, '_createDocumentFragment', undefined);
|
||||
|
||||
setProperty(window, 'WinRTError', undefined);
|
||||
|
||||
setProperty(window, 'exports', undefined);
|
||||
setProperty(window, 'global', undefined);
|
||||
setProperty(window, 'module', undefined);
|
||||
|
||||
setProperty(objectProto, 'propertyIsEnumerable', objectProto._propertyIsEnumerable);
|
||||
|
||||
delete Array._isArray;
|
||||
delete Date._now;
|
||||
delete funcProto._method;
|
||||
delete Object._create;
|
||||
delete Object._getPrototypeOf;
|
||||
delete Object._keys;
|
||||
delete objectProto._propertyIsEnumerable;
|
||||
}
|
||||
|
||||
// load lodash and expose it to the bad extensions/shims
|
||||
if (!ui.isModularize) {
|
||||
addBizarroMethods();
|
||||
document.write('<script src="' + ui.buildPath + '"><\/script>');
|
||||
}
|
||||
// load Lo-Dash and expose it to the bad shims
|
||||
document.write('<script src="' + (ui.isModularize ? '../lodash.js' : ui.buildPath) + '"><\/script>');
|
||||
</script>
|
||||
<script>
|
||||
// store lodash to test for bad extensions/shims
|
||||
if (!ui.isModularize) {
|
||||
var lodashBizarro = window._;
|
||||
window._ = undefined;
|
||||
removeBizarroMethods();
|
||||
// store Lo-Dash to test for bad shim detection
|
||||
var lodashBadShim = window._;
|
||||
|
||||
// restore native methods
|
||||
if (Array._isArray) {
|
||||
Array.isArray = Array._isArray;
|
||||
} else {
|
||||
delete Array.isArray;
|
||||
}
|
||||
// load test scripts
|
||||
document.write((ui.isForeign || ui.urlParams.loader == 'none')
|
||||
if (Date._now) {
|
||||
Date.now = Date._now;
|
||||
} else {
|
||||
delete Date.now;
|
||||
}
|
||||
if (Function.prototype._bind) {
|
||||
Function.prototype.bind = Function.prototype._bind;
|
||||
} else {
|
||||
delete Function.prototype.bind;
|
||||
}
|
||||
if (Object._create) {
|
||||
Object.create = Object._create;
|
||||
} else {
|
||||
delete Object.create;
|
||||
}
|
||||
if (Object._defineProperty) {
|
||||
Object.defineProperty = Object._defineProperty;
|
||||
} else {
|
||||
delete Object.defineProperty;
|
||||
}
|
||||
if (Object._getPrototypeOf) {
|
||||
Object.getPrototypeOf = Object._getPrototypeOf;
|
||||
} else {
|
||||
delete Object.getPrototypeOf;
|
||||
}
|
||||
if (Object._keys) {
|
||||
Object.keys = Object._keys;
|
||||
} else {
|
||||
delete Object.keys;
|
||||
}
|
||||
delete Array._isArray;
|
||||
delete Date._now;
|
||||
delete Function.prototype._bind;
|
||||
delete Object._create;
|
||||
delete Object._defineProperty;
|
||||
delete Object._getPrototypeOf;
|
||||
delete Object._keys;
|
||||
|
||||
QUnit.config.hidepassed = true;
|
||||
|
||||
// assign results to `global_test_results` for Sauce Labs
|
||||
var global_test_results;
|
||||
QUnit.done(function(results) {
|
||||
global_test_results = results;
|
||||
});
|
||||
|
||||
// clear existing `_` value
|
||||
window._ = undefined;
|
||||
|
||||
// load Lo-Dash and test scripts
|
||||
document.write(ui.urlParams.loader == 'none'
|
||||
? '<script src="' + ui.buildPath + '"><\/script><script src="test.js"><\/script>'
|
||||
: '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
|
||||
);
|
||||
@@ -275,118 +117,74 @@
|
||||
if (window.curl) {
|
||||
curl.config({ 'apiName': 'require' });
|
||||
}
|
||||
if (ui.isForeign || !window.require) {
|
||||
if (!window.require) {
|
||||
return;
|
||||
}
|
||||
var reBasename = /[\w.-]+$/,
|
||||
basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
|
||||
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
||||
moduleMain = modulePath.match(reBasename)[0],
|
||||
locationPath = modulePath.replace(reBasename, '').replace(/^\/|\/$/g, ''),
|
||||
shimmedLocationPath = './abc/../' + locationPath,
|
||||
underscoreLocationPath = './xyz/../' + locationPath,
|
||||
uid = +new Date;
|
||||
locationPath = modulePath.replace(reBasename, ''),
|
||||
moduleMain = modulePath.match(reBasename)[0];
|
||||
|
||||
function getConfig() {
|
||||
var result = {
|
||||
'baseUrl': './',
|
||||
'urlArgs': 't=' + uid++,
|
||||
'waitSeconds': 0,
|
||||
'paths': {},
|
||||
'packages': [{
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
// load Lo-Dash as a module
|
||||
require({
|
||||
'baseUrl': './',
|
||||
'urlArgs': 't=' + (+new Date),
|
||||
'packages': [
|
||||
{
|
||||
'name': 'lodash',
|
||||
'location': locationPath,
|
||||
'main': moduleMain
|
||||
},
|
||||
{
|
||||
'name': 'shimmed',
|
||||
'location': './abc/../' + locationPath,
|
||||
'main': moduleMain
|
||||
},
|
||||
{
|
||||
'name': 'underscore',
|
||||
'location': './xyz/../' + locationPath,
|
||||
'main': moduleMain
|
||||
},
|
||||
{
|
||||
'name': 'test',
|
||||
'location': basePath + 'test',
|
||||
'location': basePath + '/test',
|
||||
'main': 'test',
|
||||
'config': {
|
||||
// work around no global being exported
|
||||
'exports': 'QUnit',
|
||||
'loader': 'curl/loader/legacy'
|
||||
}
|
||||
}],
|
||||
'shim': {
|
||||
'shimmed': {
|
||||
'exports': '_'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (ui.isModularize) {
|
||||
result.packages.push({
|
||||
'name': 'lodash',
|
||||
'location': locationPath,
|
||||
'main': moduleMain
|
||||
}, {
|
||||
'name': 'shimmed',
|
||||
'location': shimmedLocationPath,
|
||||
'main': moduleMain
|
||||
}, {
|
||||
'name': 'underscore',
|
||||
'location': underscoreLocationPath,
|
||||
'main': moduleMain
|
||||
});
|
||||
} else {
|
||||
result.paths.lodash = modulePath;
|
||||
result.paths.shimmed = shimmedLocationPath + '/' + moduleMain;
|
||||
result.paths.underscore = underscoreLocationPath + '/' + moduleMain;
|
||||
],
|
||||
'shim': {
|
||||
'shimmed': {
|
||||
'exports': '_'
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function loadTests() {
|
||||
require(getConfig(), ['test'], function() {
|
||||
QUnit.start();
|
||||
});
|
||||
}
|
||||
|
||||
function loadModulesAndTests() {
|
||||
require(getConfig(), ['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
|
||||
},
|
||||
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
|
||||
if (shimmed && shimmed.noConflict) {
|
||||
shimmedModule = shimmed.noConflict();
|
||||
shimmedModule.moduleName = 'shimmed';
|
||||
}
|
||||
if (underscore && underscore.noConflict) {
|
||||
underscoreModule = underscore.noConflict();
|
||||
underscoreModule.moduleName = 'underscore';
|
||||
}
|
||||
if (lodash) {
|
||||
lodashModule = lodash;
|
||||
lodashModule.moduleName = 'lodash';
|
||||
|
||||
if (shimmed) {
|
||||
shimmedModule = shimmed.result(shimmed, 'noConflict') || shimmed;
|
||||
shimmedModule.moduleName = 'shimmed';
|
||||
}
|
||||
if (underscore) {
|
||||
underscoreModule = underscore.result(underscore, 'noConflict') || underscore;
|
||||
underscoreModule.moduleName = 'underscore';
|
||||
}
|
||||
if (ui.isModularize) {
|
||||
window._ = lodash;
|
||||
}
|
||||
if (ui.isModularize) {
|
||||
require(getConfig(), [
|
||||
'lodash/internal/baseEach',
|
||||
'lodash/internal/isIndex',
|
||||
'lodash/internal/isIterateeCall',
|
||||
'lodash/internal/isLength'
|
||||
], function(baseEach, isIndex, isIterateeCall, isLength) {
|
||||
lodash._baseEach = baseEach;
|
||||
lodash._isIndex = isIndex;
|
||||
lodash._isIterateeCall = isIterateeCall;
|
||||
lodash._isLength = isLength;
|
||||
loadTests();
|
||||
});
|
||||
} else {
|
||||
loadTests();
|
||||
}
|
||||
}
|
||||
if (ui.isModularize) {
|
||||
window._ = lodash;
|
||||
}
|
||||
require(['test'], function() {
|
||||
QUnit.start();
|
||||
});
|
||||
}
|
||||
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
if (window.requirejs) {
|
||||
addBizarroMethods();
|
||||
require(getConfig(), ['lodash'], function(lodash) {
|
||||
lodashBizarro = lodash.result(lodash, 'noConflict') || lodash;
|
||||
delete requirejs.s.contexts._;
|
||||
|
||||
removeBizarroMethods();
|
||||
loadModulesAndTests();
|
||||
});
|
||||
} else {
|
||||
loadModulesAndTests();
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
// set a more readable browser name
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
echo "Testing in node..."
|
||||
node test.js ../lodash.src.js
|
||||
|
||||
for cmd in rhino "rhino -require" ringo phantomjs; do
|
||||
echo ""
|
||||
for cmd in rhino "rhino -require" narwhal ringo phantomjs; do
|
||||
echo "Testing in $cmd..."
|
||||
$cmd test.js ../lodash.src.js
|
||||
$cmd test.js ../dist/lodash.compat.js && $cmd test.js ../dist/lodash.compat.min.js
|
||||
echo ""
|
||||
done
|
||||
|
||||
echo "Testing in node..."
|
||||
node test.js ../dist/lodash.js && node test.js ../dist/lodash.min.js
|
||||
|
||||
echo ""
|
||||
echo "Testing in a browser..."
|
||||
open index.html
|
||||
|
||||
1183
test/saucelabs.js
1183
test/saucelabs.js
File diff suppressed because it is too large
Load Diff
13214
test/test.js
13214
test/test.js
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Underscore Test Suite</title>
|
||||
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
|
||||
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css">
|
||||
<style>
|
||||
iframe {
|
||||
display: none;
|
||||
@@ -19,21 +19,10 @@
|
||||
</div>
|
||||
<img id="chart_image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==">
|
||||
</div>
|
||||
<script>
|
||||
// avoid reporting tests to Sauce Labs when script errors occur
|
||||
if (location.port == '9001') {
|
||||
window.onerror = function(message) {
|
||||
if (window.QUnit) {
|
||||
QUnit.config.done.length = 0;
|
||||
}
|
||||
global_test_results = { 'message': message };
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
|
||||
<script src="../node_modules/qunit-extras/qunit-extras.js"></script>
|
||||
<script src="../node_modules/jquery/dist/jquery.js"></script>
|
||||
<script src="../node_modules/platform/platform.js"></script>
|
||||
<script src="../vendor/qunit/qunit/qunit.js"></script>
|
||||
<script src="../vendor/qunit-extras/qunit-extras.js"></script>
|
||||
<script src="../vendor/jquery/jquery.js"></script>
|
||||
<script src="../vendor/platform.js/platform.js"></script>
|
||||
<script src="./asset/test-ui.js"></script>
|
||||
<script>
|
||||
QUnit.config.asyncRetries = 10;
|
||||
@@ -42,130 +31,103 @@
|
||||
// excuse tests we intentionally fail or those with problems
|
||||
QUnit.config.excused = {
|
||||
'Arrays': {
|
||||
'drop': [
|
||||
'alias for rest'
|
||||
],
|
||||
'first': [
|
||||
'can pass an index to first',
|
||||
'[1,2]',
|
||||
'0'
|
||||
],
|
||||
'flatten': [
|
||||
'Flattens empty arrays',
|
||||
'can flatten nested arrays',
|
||||
'can shallowly flatten nested arrays',
|
||||
'works on an arguments object',
|
||||
'can shallowly flatten arrays containing only other arrays'
|
||||
],
|
||||
'initial': [
|
||||
'initial can take an index',
|
||||
'initial can take a large index',
|
||||
'initial works on arguments object'
|
||||
],
|
||||
'intersection': [
|
||||
'can perform an OO-style intersection',
|
||||
'returns an empty array when passed null as first argument',
|
||||
'returns an empty array when passed null as argument beyond the first'
|
||||
],
|
||||
'last': [
|
||||
'can pass an index to last',
|
||||
'0'
|
||||
],
|
||||
'lastIndexOf': [
|
||||
'[0,-1,-1]'
|
||||
],
|
||||
'rest': [
|
||||
'working rest(0)',
|
||||
'rest can take an index',
|
||||
'works on arguments object'
|
||||
],
|
||||
'take': [
|
||||
'alias for first'
|
||||
'union': [
|
||||
'[null,1,2,3]'
|
||||
]
|
||||
},
|
||||
'Chaining': {
|
||||
'pop': true,
|
||||
'shift': true,
|
||||
'splice': true,
|
||||
'select/reject/sortBy': [
|
||||
'Died on test #1'
|
||||
],
|
||||
'select/reject/sortBy in functional style': [
|
||||
'Died on test #1'
|
||||
],
|
||||
'reverse/concat/unshift/pop/map': [
|
||||
'can chain together array functions.'
|
||||
'"34, 10, 8, 6, 4, 2, 10, 10"'
|
||||
]
|
||||
},
|
||||
'Collections': {
|
||||
'filter': [
|
||||
'OO-filter'
|
||||
'reduce': [
|
||||
'handles a null (without initial value) properly',
|
||||
'throws an error for empty arrays with no initial value'
|
||||
],
|
||||
'invoke': [
|
||||
'handles null & undefined'
|
||||
'reduceRight': [
|
||||
'handles a null (without initial value) properly',
|
||||
'throws an error for empty arrays with no initial value'
|
||||
],
|
||||
'map': [
|
||||
'OO-style doubled numbers'
|
||||
],
|
||||
'Resistant to collection length and properties changing while iterating': [
|
||||
'Died on test #50'
|
||||
'where': [
|
||||
'Only get the first object matched.'
|
||||
]
|
||||
},
|
||||
'Functions': {
|
||||
'bind': [
|
||||
'can bind without specifying a context',
|
||||
'Died on test #2'
|
||||
],
|
||||
'bindAll': [
|
||||
'throws an error for bindAll with no functions named'
|
||||
],
|
||||
'memoize': [
|
||||
'{"bar":"BAR","foo":"FOO"}',
|
||||
'Died on test #8'
|
||||
],
|
||||
'throttle repeatedly with results': true,
|
||||
'more throttle does not trigger leading call when leading is set to false': true,
|
||||
'throttle does not trigger trailing call when trailing is set to false': true,
|
||||
'debounce asap': true
|
||||
},
|
||||
'Objects': {
|
||||
'#1929 Typed Array constructors are functions': true,
|
||||
'allKeys': true,
|
||||
'extendOwn': true,
|
||||
'mapObject': true,
|
||||
'matcher': true,
|
||||
'matcher ': true,
|
||||
'extend': [
|
||||
'extend copies all properties from source'
|
||||
],
|
||||
'isFinite': [
|
||||
'Numeric strings are numbers',
|
||||
'Number instances can be finite'
|
||||
],
|
||||
'isMatch': [
|
||||
'inherited and own properties are checked on the test object',
|
||||
'doesnt falsey match constructor on undefined/null'
|
||||
'isEqual': [
|
||||
'Died on test #60',
|
||||
'Died on test #63'
|
||||
],
|
||||
'keys': [
|
||||
'is not fooled by sparse arrays; see issue #95',
|
||||
'[]'
|
||||
],
|
||||
'matches': [
|
||||
'inherited and own properties are checked on the test object',
|
||||
'doesnt fasley match constructor on undefined/null'
|
||||
'throws an error for `null` values',
|
||||
'throws an error for `undefined` values',
|
||||
'throws an error for number primitives',
|
||||
'throws an error for string primitives',
|
||||
'throws an error for boolean primitives'
|
||||
]
|
||||
},
|
||||
'Utility': {
|
||||
'_.templateSettings.variable': [
|
||||
'"x"'
|
||||
'_.escape': [
|
||||
'"<a href="http://moe.com">Curly & Moe's</a>"'
|
||||
],
|
||||
'_.unescape': [
|
||||
'"<a href=\\"http://moe.com\\">Curly & Moe's</a>"'
|
||||
],
|
||||
'times': [
|
||||
'works as a wrapper'
|
||||
'Died on test #1'
|
||||
],
|
||||
'uniqueId': [
|
||||
'Died on test #1'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
// only excuse in Sauce Labs (buggy Safari and timers)
|
||||
if (!ui.isSauceLabs) {
|
||||
if (location.port != '9001') {
|
||||
delete QUnit.config.excused.Chaining['select/reject/sortBy'];
|
||||
delete QUnit.config.excused.Chaining['select/reject/sortBy in functional style'];
|
||||
delete QUnit.config.excused.Functions['throttle repeatedly with results'];
|
||||
delete QUnit.config.excused.Functions['more throttle does not trigger leading call when leading is set to false'];
|
||||
delete QUnit.config.excused.Functions['throttle does not trigger trailing call when trailing is set to false'];
|
||||
delete QUnit.config.excused.Functions['debounce asap'];
|
||||
delete QUnit.config.excused.Objects.isEqual;
|
||||
delete QUnit.config.excused.Utility.times;
|
||||
delete QUnit.config.excused.Utility.uniqueId;
|
||||
}
|
||||
// load test scripts
|
||||
// only excuse in non-Underscore builds
|
||||
if (/\bunderscore\b/i.test(ui.buildPath)) {
|
||||
delete QUnit.config.excused.Chaining;
|
||||
delete QUnit.config.excused.Collections.where;
|
||||
delete QUnit.config.excused.Utility['_.escape'];
|
||||
delete QUnit.config.excused.Utility['_.unescape'];
|
||||
}
|
||||
|
||||
// assign results to `global_test_results` for Sauce Labs
|
||||
var global_test_results;
|
||||
QUnit.done(function(results) {
|
||||
global_test_results = results;
|
||||
});
|
||||
|
||||
// load Lo-Dash and test scripts
|
||||
document.write(ui.urlParams.loader != 'none'
|
||||
? '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
|
||||
: ([
|
||||
@@ -188,20 +150,24 @@
|
||||
return;
|
||||
}
|
||||
var reBasename = /[\w.-]+$/,
|
||||
basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
|
||||
basePath = ('//' + location.host + location.pathname).replace(/\btest\/$/, ''),
|
||||
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
||||
locationPath = modulePath.replace(reBasename, '').replace(/^\/|\/$/g, ''),
|
||||
moduleId = /\bunderscore\b/i.test(ui.buildPath) ? 'underscore' : 'lodash',
|
||||
moduleMain = modulePath.match(reBasename)[0],
|
||||
uid = +new Date;
|
||||
locationPath = modulePath.replace(reBasename, ''),
|
||||
moduleMain = modulePath.match(reBasename)[0];
|
||||
|
||||
function getConfig() {
|
||||
var result = {
|
||||
'baseUrl': './',
|
||||
'urlArgs': 't=' + uid++,
|
||||
'waitSeconds': 0,
|
||||
'paths': {},
|
||||
'packages': [{
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
// load Lo-Dash as a module
|
||||
require({
|
||||
'baseUrl': './',
|
||||
'urlArgs': 't=' + (+new Date),
|
||||
'packages': [
|
||||
{
|
||||
'name': 'lodash',
|
||||
'location': locationPath,
|
||||
'main': moduleMain
|
||||
},
|
||||
{
|
||||
'name': 'test',
|
||||
'location': '../vendor/underscore/test',
|
||||
'config': {
|
||||
@@ -209,28 +175,14 @@
|
||||
'exports': 'QUnit',
|
||||
'loader': 'curl/loader/legacy'
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
if (ui.isModularize) {
|
||||
result.packages.push({
|
||||
'name': moduleId,
|
||||
'location': locationPath,
|
||||
'main': moduleMain
|
||||
});
|
||||
} else {
|
||||
result.paths[moduleId] = modulePath;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
require(getConfig(), [moduleId], function(lodash) {
|
||||
}
|
||||
]
|
||||
},
|
||||
['lodash'], function(lodash) {
|
||||
if (ui.isModularize) {
|
||||
window._ = lodash;
|
||||
}
|
||||
require(getConfig(), [
|
||||
require([
|
||||
'test/collections',
|
||||
'test/arrays',
|
||||
'test/functions',
|
||||
|
||||
2
vendor/backbone/LICENSE
vendored
2
vendor/backbone/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2010-2014 Jeremy Ashkenas, DocumentCloud
|
||||
Copyright (c) 2010-2013 Jeremy Ashkenas, DocumentCloud
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
|
||||
163
vendor/backbone/backbone.js
vendored
163
vendor/backbone/backbone.js
vendored
@@ -1,35 +1,20 @@
|
||||
// Backbone.js 1.1.2
|
||||
// Backbone.js 1.1.0
|
||||
|
||||
// (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
// (c) 2010-2011 Jeremy Ashkenas, DocumentCloud Inc.
|
||||
// (c) 2011-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
// Backbone may be freely distributed under the MIT license.
|
||||
// For all details and documentation:
|
||||
// http://backbonejs.org
|
||||
|
||||
(function(root, factory) {
|
||||
|
||||
// Set up Backbone appropriately for the environment. Start with AMD.
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['underscore', 'jquery', 'exports'], function(_, $, exports) {
|
||||
// Export global even in AMD case in case this script is loaded with
|
||||
// others that may still expect a global Backbone.
|
||||
root.Backbone = factory(root, exports, _, $);
|
||||
});
|
||||
|
||||
// Next for Node.js or CommonJS. jQuery may not be needed as a module.
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
var _ = require('underscore');
|
||||
factory(root, exports, _);
|
||||
|
||||
// Finally, as a browser global.
|
||||
} else {
|
||||
root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$));
|
||||
}
|
||||
|
||||
}(this, function(root, Backbone, _, $) {
|
||||
(function(){
|
||||
|
||||
// Initial Setup
|
||||
// -------------
|
||||
|
||||
// Save a reference to the global object (`window` in the browser, `exports`
|
||||
// on the server).
|
||||
var root = this;
|
||||
|
||||
// Save the previous value of the `Backbone` variable, so that it can be
|
||||
// restored later on, if `noConflict` is used.
|
||||
var previousBackbone = root.Backbone;
|
||||
@@ -40,12 +25,25 @@
|
||||
var slice = array.slice;
|
||||
var splice = array.splice;
|
||||
|
||||
// The top-level namespace. All public Backbone classes and modules will
|
||||
// be attached to this. Exported for both the browser and the server.
|
||||
var Backbone;
|
||||
if (typeof exports !== 'undefined') {
|
||||
Backbone = exports;
|
||||
} else {
|
||||
Backbone = root.Backbone = {};
|
||||
}
|
||||
|
||||
// Current version of the library. Keep in sync with `package.json`.
|
||||
Backbone.VERSION = '1.1.2';
|
||||
Backbone.VERSION = '1.1.0';
|
||||
|
||||
// Require Underscore, if we're on the server, and it's not already present.
|
||||
var _ = root._;
|
||||
if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
|
||||
|
||||
// For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
|
||||
// the `$` variable.
|
||||
Backbone.$ = $;
|
||||
Backbone.$ = root.jQuery || root.Zepto || root.ender || root.$;
|
||||
|
||||
// Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
|
||||
// to its previous owner. Returns a reference to this Backbone object.
|
||||
@@ -111,7 +109,7 @@
|
||||
var retain, ev, events, names, i, l, j, k;
|
||||
if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
|
||||
if (!name && !callback && !context) {
|
||||
this._events = void 0;
|
||||
this._events = {};
|
||||
return this;
|
||||
}
|
||||
names = name ? [name] : _.keys(this._events);
|
||||
@@ -207,7 +205,7 @@
|
||||
case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
|
||||
case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
|
||||
case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
|
||||
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
|
||||
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -352,7 +350,7 @@
|
||||
|
||||
// Trigger all relevant attribute changes.
|
||||
if (!silent) {
|
||||
if (changes.length) this._pending = options;
|
||||
if (changes.length) this._pending = true;
|
||||
for (var i = 0, l = changes.length; i < l; i++) {
|
||||
this.trigger('change:' + changes[i], this, current[changes[i]], options);
|
||||
}
|
||||
@@ -363,7 +361,6 @@
|
||||
if (changing) return this;
|
||||
if (!silent) {
|
||||
while (this._pending) {
|
||||
options = this._pending;
|
||||
this._pending = false;
|
||||
this.trigger('change', this, options);
|
||||
}
|
||||
@@ -531,12 +528,9 @@
|
||||
// using Backbone's restful methods, override this to change the endpoint
|
||||
// that will be called.
|
||||
url: function() {
|
||||
var base =
|
||||
_.result(this, 'urlRoot') ||
|
||||
_.result(this.collection, 'url') ||
|
||||
urlError();
|
||||
var base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || urlError();
|
||||
if (this.isNew()) return base;
|
||||
return base.replace(/([^\/])$/, '$1/') + encodeURIComponent(this.id);
|
||||
return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id);
|
||||
},
|
||||
|
||||
// **parse** converts a response into the hash of attributes to be `set` on
|
||||
@@ -552,7 +546,7 @@
|
||||
|
||||
// A model is new if it has never been saved to the server, and lacks an id.
|
||||
isNew: function() {
|
||||
return !this.has(this.idAttribute);
|
||||
return this.id == null;
|
||||
},
|
||||
|
||||
// Check if the model is currently in a valid state.
|
||||
@@ -656,7 +650,7 @@
|
||||
options.index = index;
|
||||
model.trigger('remove', model, this, options);
|
||||
}
|
||||
this._removeReference(model, options);
|
||||
this._removeReference(model);
|
||||
}
|
||||
return singular ? models[0] : models;
|
||||
},
|
||||
@@ -682,11 +676,11 @@
|
||||
// Turn bare objects into model references, and prevent invalid models
|
||||
// from being added.
|
||||
for (i = 0, l = models.length; i < l; i++) {
|
||||
attrs = models[i] || {};
|
||||
attrs = models[i];
|
||||
if (attrs instanceof Model) {
|
||||
id = model = attrs;
|
||||
} else {
|
||||
id = attrs[targetModel.prototype.idAttribute || 'id'];
|
||||
id = attrs[targetModel.prototype.idAttribute];
|
||||
}
|
||||
|
||||
// If a duplicate is found, prevent it from being added and
|
||||
@@ -706,13 +700,14 @@
|
||||
model = models[i] = this._prepareModel(attrs, options);
|
||||
if (!model) continue;
|
||||
toAdd.push(model);
|
||||
this._addReference(model, options);
|
||||
}
|
||||
|
||||
// Do not add multiple models with the same `id`.
|
||||
model = existing || model;
|
||||
if (order && (model.isNew() || !modelMap[model.id])) order.push(model);
|
||||
modelMap[model.id] = true;
|
||||
// Listen to added models' events, and index models for lookup by
|
||||
// `id` and by `cid`.
|
||||
model.on('all', this._onModelEvent, this);
|
||||
this._byId[model.cid] = model;
|
||||
if (model.id != null) this._byId[model.id] = model;
|
||||
}
|
||||
if (order) order.push(existing || model);
|
||||
}
|
||||
|
||||
// Remove nonexistent models if appropriate.
|
||||
@@ -750,7 +745,7 @@
|
||||
}
|
||||
if (sort || (order && order.length)) this.trigger('sort', this, options);
|
||||
}
|
||||
|
||||
|
||||
// Return the added (or merged) model (or models).
|
||||
return singular ? models[0] : models;
|
||||
},
|
||||
@@ -762,7 +757,7 @@
|
||||
reset: function(models, options) {
|
||||
options || (options = {});
|
||||
for (var i = 0, l = this.models.length; i < l; i++) {
|
||||
this._removeReference(this.models[i], options);
|
||||
this._removeReference(this.models[i]);
|
||||
}
|
||||
options.previousModels = this.models;
|
||||
this._reset();
|
||||
@@ -803,7 +798,7 @@
|
||||
// Get a model from the set by id.
|
||||
get: function(obj) {
|
||||
if (obj == null) return void 0;
|
||||
return this._byId[obj] || this._byId[obj.id] || this._byId[obj.cid];
|
||||
return this._byId[obj.id] || this._byId[obj.cid] || this._byId[obj];
|
||||
},
|
||||
|
||||
// Get the model at the given index.
|
||||
@@ -879,7 +874,7 @@
|
||||
if (!options.wait) this.add(model, options);
|
||||
var collection = this;
|
||||
var success = options.success;
|
||||
options.success = function(model, resp) {
|
||||
options.success = function(model, resp, options) {
|
||||
if (options.wait) collection.add(model, options);
|
||||
if (success) success(model, resp, options);
|
||||
};
|
||||
@@ -909,7 +904,10 @@
|
||||
// Prepare a hash of attributes (or other model) to be added to this
|
||||
// collection.
|
||||
_prepareModel: function(attrs, options) {
|
||||
if (attrs instanceof Model) return attrs;
|
||||
if (attrs instanceof Model) {
|
||||
if (!attrs.collection) attrs.collection = this;
|
||||
return attrs;
|
||||
}
|
||||
options = options ? _.clone(options) : {};
|
||||
options.collection = this;
|
||||
var model = new this.model(attrs, options);
|
||||
@@ -918,16 +916,8 @@
|
||||
return false;
|
||||
},
|
||||
|
||||
// Internal method to create a model's ties to a collection.
|
||||
_addReference: function(model, options) {
|
||||
this._byId[model.cid] = model;
|
||||
if (model.id != null) this._byId[model.id] = model;
|
||||
if (!model.collection) model.collection = this;
|
||||
model.on('all', this._onModelEvent, this);
|
||||
},
|
||||
|
||||
// Internal method to sever a model's ties to a collection.
|
||||
_removeReference: function(model, options) {
|
||||
_removeReference: function(model) {
|
||||
if (this === model.collection) delete model.collection;
|
||||
model.off('all', this._onModelEvent, this);
|
||||
},
|
||||
@@ -956,7 +946,7 @@
|
||||
'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
|
||||
'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
|
||||
'tail', 'drop', 'last', 'without', 'difference', 'indexOf', 'shuffle',
|
||||
'lastIndexOf', 'isEmpty', 'chain', 'sample'];
|
||||
'lastIndexOf', 'isEmpty', 'chain'];
|
||||
|
||||
// Mix in each Underscore method as a proxy to `Collection#models`.
|
||||
_.each(methods, function(method) {
|
||||
@@ -968,7 +958,7 @@
|
||||
});
|
||||
|
||||
// Underscore methods that take a property name as an argument.
|
||||
var attributeMethods = ['groupBy', 'countBy', 'sortBy', 'indexBy'];
|
||||
var attributeMethods = ['groupBy', 'countBy', 'sortBy'];
|
||||
|
||||
// Use attributes instead of properties.
|
||||
_.each(attributeMethods, function(method) {
|
||||
@@ -1190,9 +1180,7 @@
|
||||
return xhr;
|
||||
};
|
||||
|
||||
var noXhrPatch =
|
||||
typeof window !== 'undefined' && !!window.ActiveXObject &&
|
||||
!(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent);
|
||||
var noXhrPatch = typeof window !== 'undefined' && !!window.ActiveXObject && !(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent);
|
||||
|
||||
// Map from CRUD to HTTP for our default `Backbone.sync` implementation.
|
||||
var methodMap = {
|
||||
@@ -1251,7 +1239,7 @@
|
||||
var router = this;
|
||||
Backbone.history.route(route, function(fragment) {
|
||||
var args = router._extractParameters(route, fragment);
|
||||
router.execute(callback, args);
|
||||
callback && callback.apply(router, args);
|
||||
router.trigger.apply(router, ['route:' + name].concat(args));
|
||||
router.trigger('route', name, args);
|
||||
Backbone.history.trigger('route', router, name, args);
|
||||
@@ -1259,12 +1247,6 @@
|
||||
return this;
|
||||
},
|
||||
|
||||
// Execute a route handler with the provided parameters. This is an
|
||||
// excellent place to do pre-route setup or post-route cleanup.
|
||||
execute: function(callback, args) {
|
||||
if (callback) callback.apply(this, args);
|
||||
},
|
||||
|
||||
// Simple proxy to `Backbone.history` to save a fragment into the history.
|
||||
navigate: function(fragment, options) {
|
||||
Backbone.history.navigate(fragment, options);
|
||||
@@ -1289,10 +1271,10 @@
|
||||
route = route.replace(escapeRegExp, '\\$&')
|
||||
.replace(optionalParam, '(?:$1)?')
|
||||
.replace(namedParam, function(match, optional) {
|
||||
return optional ? match : '([^/?]+)';
|
||||
return optional ? match : '([^\/]+)';
|
||||
})
|
||||
.replace(splatParam, '([^?]*?)');
|
||||
return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
|
||||
.replace(splatParam, '(.*?)');
|
||||
return new RegExp('^' + route + '$');
|
||||
},
|
||||
|
||||
// Given a route, and a URL fragment that it matches, return the array of
|
||||
@@ -1300,9 +1282,7 @@
|
||||
// treated as `null` to normalize cross-browser behavior.
|
||||
_extractParameters: function(route, fragment) {
|
||||
var params = route.exec(fragment).slice(1);
|
||||
return _.map(params, function(param, i) {
|
||||
// Don't decode the search params.
|
||||
if (i === params.length - 1) return param || null;
|
||||
return _.map(params, function(param) {
|
||||
return param ? decodeURIComponent(param) : null;
|
||||
});
|
||||
}
|
||||
@@ -1340,8 +1320,8 @@
|
||||
// Cached regex for removing a trailing slash.
|
||||
var trailingSlash = /\/$/;
|
||||
|
||||
// Cached regex for stripping urls of hash.
|
||||
var pathStripper = /#.*$/;
|
||||
// Cached regex for stripping urls of hash and query.
|
||||
var pathStripper = /[?#].*$/;
|
||||
|
||||
// Has the history handling already been started?
|
||||
History.started = false;
|
||||
@@ -1353,11 +1333,6 @@
|
||||
// twenty times a second.
|
||||
interval: 50,
|
||||
|
||||
// Are we at the app root?
|
||||
atRoot: function() {
|
||||
return this.location.pathname.replace(/[^\/]$/, '$&/') === this.root;
|
||||
},
|
||||
|
||||
// Gets the true hash value. Cannot use location.hash directly due to bug
|
||||
// in Firefox where location.hash will always be decoded.
|
||||
getHash: function(window) {
|
||||
@@ -1370,7 +1345,7 @@
|
||||
getFragment: function(fragment, forcePushState) {
|
||||
if (fragment == null) {
|
||||
if (this._hasPushState || !this._wantsHashChange || forcePushState) {
|
||||
fragment = decodeURI(this.location.pathname + this.location.search);
|
||||
fragment = this.location.pathname;
|
||||
var root = this.root.replace(trailingSlash, '');
|
||||
if (!fragment.indexOf(root)) fragment = fragment.slice(root.length);
|
||||
} else {
|
||||
@@ -1401,8 +1376,7 @@
|
||||
this.root = ('/' + this.root + '/').replace(rootStripper, '/');
|
||||
|
||||
if (oldIE && this._wantsHashChange) {
|
||||
var frame = Backbone.$('<iframe src="javascript:0" tabindex="-1">');
|
||||
this.iframe = frame.hide().appendTo('body')[0].contentWindow;
|
||||
this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
|
||||
this.navigate(fragment);
|
||||
}
|
||||
|
||||
@@ -1420,6 +1394,7 @@
|
||||
// opened by a non-pushState browser.
|
||||
this.fragment = fragment;
|
||||
var loc = this.location;
|
||||
var atRoot = loc.pathname.replace(/[^\/]$/, '$&/') === this.root;
|
||||
|
||||
// Transition from hashChange to pushState or vice versa if both are
|
||||
// requested.
|
||||
@@ -1427,17 +1402,17 @@
|
||||
|
||||
// If we've started off with a route from a `pushState`-enabled
|
||||
// browser, but we're currently in a browser that doesn't support it...
|
||||
if (!this._hasPushState && !this.atRoot()) {
|
||||
if (!this._hasPushState && !atRoot) {
|
||||
this.fragment = this.getFragment(null, true);
|
||||
this.location.replace(this.root + '#' + this.fragment);
|
||||
this.location.replace(this.root + this.location.search + '#' + this.fragment);
|
||||
// Return immediately as browser will do redirect to new url
|
||||
return true;
|
||||
|
||||
// Or if we've started out with a hash-based route, but we're currently
|
||||
// in a browser where it could be `pushState`-based instead...
|
||||
} else if (this._hasPushState && this.atRoot() && loc.hash) {
|
||||
} else if (this._hasPushState && atRoot && loc.hash) {
|
||||
this.fragment = this.getHash().replace(routeStripper, '');
|
||||
this.history.replaceState({}, document.title, this.root + this.fragment);
|
||||
this.history.replaceState({}, document.title, this.root + this.fragment + loc.search);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1449,7 +1424,7 @@
|
||||
// but possibly useful for unit testing Routers.
|
||||
stop: function() {
|
||||
Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl);
|
||||
if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
|
||||
clearInterval(this._checkUrlInterval);
|
||||
History.started = false;
|
||||
},
|
||||
|
||||
@@ -1497,7 +1472,7 @@
|
||||
|
||||
var url = this.root + (fragment = this.getFragment(fragment || ''));
|
||||
|
||||
// Strip the hash for matching.
|
||||
// Strip the fragment of the query and hash for matching.
|
||||
fragment = fragment.replace(pathStripper, '');
|
||||
|
||||
if (this.fragment === fragment) return;
|
||||
@@ -1603,6 +1578,4 @@
|
||||
};
|
||||
};
|
||||
|
||||
return Backbone;
|
||||
|
||||
}));
|
||||
}).call(this);
|
||||
|
||||
95
vendor/backbone/test/collection.js
vendored
95
vendor/backbone/test/collection.js
vendored
@@ -85,11 +85,6 @@
|
||||
equal(col2.get(model.clone()), col2.first());
|
||||
});
|
||||
|
||||
test('get with "undefined" id', function() {
|
||||
var collection = new Backbone.Collection([{id: 1}, {id: 'undefined'}]);
|
||||
equal(collection.get(1).id, 1);
|
||||
}),
|
||||
|
||||
test("update index when id changes", 4, function() {
|
||||
var col = new Backbone.Collection();
|
||||
col.add([
|
||||
@@ -112,7 +107,7 @@
|
||||
equal(col.pluck('label').join(' '), 'a b c d');
|
||||
});
|
||||
|
||||
test("add", 14, function() {
|
||||
test("add", 10, function() {
|
||||
var added, opts, secondAdded;
|
||||
added = opts = secondAdded = null;
|
||||
e = new Backbone.Model({id: 10, label : 'e'});
|
||||
@@ -141,18 +136,6 @@
|
||||
equal(atCol.length, 4);
|
||||
equal(atCol.at(1), e);
|
||||
equal(atCol.last(), h);
|
||||
|
||||
var coll = new Backbone.Collection(new Array(2));
|
||||
var addCount = 0;
|
||||
coll.on('add', function(){
|
||||
addCount += 1;
|
||||
});
|
||||
coll.add([undefined, f, g]);
|
||||
equal(coll.length, 5);
|
||||
equal(addCount, 3);
|
||||
coll.add(new Array(4));
|
||||
equal(coll.length, 9);
|
||||
equal(addCount, 7);
|
||||
});
|
||||
|
||||
test("add multiple models", 6, function() {
|
||||
@@ -552,7 +535,7 @@
|
||||
equal(coll.findWhere({a: 4}), void 0);
|
||||
});
|
||||
|
||||
test("Underscore methods", 16, function() {
|
||||
test("Underscore methods", 14, function() {
|
||||
equal(col.map(function(model){ return model.get('label'); }).join(' '), 'a b c d');
|
||||
equal(col.any(function(model){ return model.id === 100; }), false);
|
||||
equal(col.any(function(model){ return model.id === 0; }), true);
|
||||
@@ -571,12 +554,9 @@
|
||||
.value(),
|
||||
[4, 0]);
|
||||
deepEqual(col.difference([c, d]), [a, b]);
|
||||
ok(col.include(col.sample()));
|
||||
var first = col.first();
|
||||
ok(col.indexBy('id')[first.id] === first);
|
||||
});
|
||||
|
||||
test("reset", 16, function() {
|
||||
test("reset", 12, function() {
|
||||
var resetCount = 0;
|
||||
var models = col.models;
|
||||
col.on('reset', function() { resetCount += 1; });
|
||||
@@ -596,15 +576,6 @@
|
||||
col.reset();
|
||||
equal(col.length, 0);
|
||||
equal(resetCount, 4);
|
||||
|
||||
var f = new Backbone.Model({id: 20, label : 'f'});
|
||||
col.reset([undefined, f]);
|
||||
equal(col.length, 2);
|
||||
equal(resetCount, 5);
|
||||
|
||||
col.reset(new Array(4));
|
||||
equal(col.length, 4);
|
||||
equal(resetCount, 6);
|
||||
});
|
||||
|
||||
test ("reset with different values", function(){
|
||||
@@ -971,6 +942,20 @@
|
||||
strictEqual(c.length, 0);
|
||||
});
|
||||
|
||||
test("set with many models does not overflow the stack", function() {
|
||||
var n = 150000;
|
||||
var collection = new Backbone.Collection();
|
||||
var models = [];
|
||||
for (var i = 0; i < n; i++) {
|
||||
models.push({id: i});
|
||||
}
|
||||
collection.set(models);
|
||||
equal(collection.length, n);
|
||||
collection.reset();
|
||||
collection.set(models, {at: 0});
|
||||
equal(collection.length, n);
|
||||
});
|
||||
|
||||
test("set with only cids", 3, function() {
|
||||
var m1 = new Backbone.Model;
|
||||
var m2 = new Backbone.Model;
|
||||
@@ -1289,50 +1274,4 @@
|
||||
equal(job.items.get(2).subItems.get(3).get('subName'), 'NewThree');
|
||||
});
|
||||
|
||||
test('_addReference binds all collection events & adds to the lookup hashes', 9, function() {
|
||||
|
||||
var calls = {add: 0, remove: 0};
|
||||
|
||||
var Collection = Backbone.Collection.extend({
|
||||
|
||||
_addReference: function(model) {
|
||||
Backbone.Collection.prototype._addReference.apply(this, arguments);
|
||||
calls.add++;
|
||||
equal(model, this._byId[model.id]);
|
||||
equal(model, this._byId[model.cid]);
|
||||
equal(model._events.all.length, 1);
|
||||
},
|
||||
|
||||
_removeReference: function(model) {
|
||||
Backbone.Collection.prototype._removeReference.apply(this, arguments);
|
||||
calls.remove++;
|
||||
equal(this._byId[model.id], void 0);
|
||||
equal(this._byId[model.cid], void 0);
|
||||
equal(model.collection, void 0);
|
||||
equal(model._events.all, void 0);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var collection = new Collection();
|
||||
var model = collection.add({id: 1});
|
||||
collection.remove(model);
|
||||
|
||||
equal(calls.add, 1);
|
||||
equal(calls.remove, 1);
|
||||
|
||||
});
|
||||
|
||||
test('Do not allow duplicate models to be `add`ed or `set`', function() {
|
||||
var c = new Backbone.Collection();
|
||||
|
||||
c.add([{id: 1}, {id: 1}]);
|
||||
equal(c.length, 1);
|
||||
equal(c.models.length, 1);
|
||||
|
||||
c.set([{id: 1}, {id: 1}]);
|
||||
equal(c.length, 1);
|
||||
equal(c.models.length, 1);
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
10
vendor/backbone/test/environment.js
vendored
10
vendor/backbone/test/environment.js
vendored
@@ -4,15 +4,9 @@
|
||||
var ajax = Backbone.ajax;
|
||||
var emulateHTTP = Backbone.emulateHTTP;
|
||||
var emulateJSON = Backbone.emulateJSON;
|
||||
var history = window.history;
|
||||
var pushState = history.pushState;
|
||||
var replaceState = history.replaceState;
|
||||
|
||||
QUnit.testStart(function() {
|
||||
var env = QUnit.config.current.testEnvironment;
|
||||
|
||||
// We never want to actually call these during tests.
|
||||
history.pushState = history.replaceState = function(){};
|
||||
var env = this.config.current.testEnvironment;
|
||||
|
||||
// Capture ajax settings for comparison.
|
||||
Backbone.ajax = function(settings) {
|
||||
@@ -36,8 +30,6 @@
|
||||
Backbone.ajax = ajax;
|
||||
Backbone.emulateHTTP = emulateHTTP;
|
||||
Backbone.emulateJSON = emulateJSON;
|
||||
history.pushState = pushState;
|
||||
history.replaceState = replaceState;
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
2
vendor/backbone/test/events.js
vendored
2
vendor/backbone/test/events.js
vendored
@@ -305,7 +305,7 @@
|
||||
|
||||
test("if callback is truthy but not a function, `on` should throw an error just like jQuery", 1, function() {
|
||||
var view = _.extend({}, Backbone.Events).on('test', 'noop');
|
||||
raises(function() {
|
||||
throws(function() {
|
||||
view.trigger('test');
|
||||
});
|
||||
});
|
||||
|
||||
20
vendor/backbone/test/model.js
vendored
20
vendor/backbone/test/model.js
vendored
@@ -262,26 +262,6 @@
|
||||
model.set({result: void 0});
|
||||
});
|
||||
|
||||
test("nested set triggers with the correct options", function() {
|
||||
var model = new Backbone.Model();
|
||||
var o1 = {};
|
||||
var o2 = {};
|
||||
var o3 = {};
|
||||
model.on('change', function(__, options) {
|
||||
switch (model.get('a')) {
|
||||
case 1:
|
||||
equal(options, o1);
|
||||
return model.set('a', 2, o2);
|
||||
case 2:
|
||||
equal(options, o2);
|
||||
return model.set('a', 3, o3);
|
||||
case 3:
|
||||
equal(options, o3);
|
||||
}
|
||||
});
|
||||
model.set('a', 1, o1);
|
||||
});
|
||||
|
||||
test("multiple unsets", 1, function() {
|
||||
var i = 0;
|
||||
var counter = function(){ i++; };
|
||||
|
||||
105
vendor/backbone/test/router.js
vendored
105
vendor/backbone/test/router.js
vendored
@@ -5,10 +5,10 @@
|
||||
var lastRoute = null;
|
||||
var lastArgs = [];
|
||||
|
||||
var onRoute = function(router, route, args) {
|
||||
function onRoute(router, route, args) {
|
||||
lastRoute = route;
|
||||
lastArgs = args;
|
||||
};
|
||||
}
|
||||
|
||||
var Location = function(href) {
|
||||
this.replace(href);
|
||||
@@ -16,11 +16,8 @@
|
||||
|
||||
_.extend(Location.prototype, {
|
||||
|
||||
parser: document.createElement('a'),
|
||||
|
||||
replace: function(href) {
|
||||
this.parser.href = href;
|
||||
_.extend(this, _.pick(this.parser,
|
||||
_.extend(this, _.pick($('<a></a>', {href: href})[0],
|
||||
'href',
|
||||
'hash',
|
||||
'host',
|
||||
@@ -67,7 +64,7 @@
|
||||
this.value = value;
|
||||
}
|
||||
};
|
||||
_.bindAll(ExternalObject, 'routingFunction');
|
||||
_.bindAll(ExternalObject);
|
||||
|
||||
var Router = Backbone.Router.extend({
|
||||
|
||||
@@ -90,7 +87,7 @@
|
||||
":repo/compare/*from...*to": "github",
|
||||
"decode/:named/*splat": "decode",
|
||||
"*first/complex-*part/*rest": "complex",
|
||||
"query/:entity": "query",
|
||||
":entity?*args": "query",
|
||||
"function/:value": ExternalObject.routingFunction,
|
||||
"*anything": "anything"
|
||||
},
|
||||
@@ -211,11 +208,6 @@
|
||||
equal(router.page, '20');
|
||||
});
|
||||
|
||||
test("routes via navigate with params", 1, function() {
|
||||
Backbone.history.navigate('query/test?a=b', {trigger: true});
|
||||
equal(router.queryArgs, 'a=b');
|
||||
});
|
||||
|
||||
test("routes via navigate for backwards-compatibility", 2, function() {
|
||||
Backbone.history.navigate('search/manhattan/p20', true);
|
||||
equal(router.query, 'manhattan');
|
||||
@@ -293,7 +285,7 @@
|
||||
});
|
||||
|
||||
test("routes (query)", 5, function() {
|
||||
location.replace('http://example.com#query/mandel?a=b&c=d');
|
||||
location.replace('http://example.com#mandel?a=b&c=d');
|
||||
Backbone.history.checkUrl();
|
||||
equal(router.entity, 'mandel');
|
||||
equal(router.queryArgs, 'a=b&c=d');
|
||||
@@ -543,7 +535,7 @@
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root/x/y?a=b');
|
||||
location.replace = function(url) {
|
||||
strictEqual(url, '/root/#x/y?a=b');
|
||||
strictEqual(url, '/root/?a=b#x/y');
|
||||
};
|
||||
Backbone.history = _.extend(new Backbone.History, {
|
||||
location: location,
|
||||
@@ -560,7 +552,7 @@
|
||||
|
||||
test("#1695 - hashChange to pushState with search.", 1, function() {
|
||||
Backbone.history.stop();
|
||||
location.replace('http://example.com/root#x/y?a=b');
|
||||
location.replace('http://example.com/root?a=b#x/y');
|
||||
Backbone.history = _.extend(new Backbone.History, {
|
||||
location: location,
|
||||
history: {
|
||||
@@ -609,7 +601,7 @@
|
||||
test("#2062 - Trigger 'route' event on router instance.", 2, function() {
|
||||
router.on('route', function(name, args) {
|
||||
strictEqual(name, 'routeEvent');
|
||||
deepEqual(args, ['x', null]);
|
||||
deepEqual(args, ['x']);
|
||||
});
|
||||
location.replace('http://example.com#route-event/x');
|
||||
Backbone.history.checkUrl();
|
||||
@@ -692,7 +684,7 @@
|
||||
}
|
||||
});
|
||||
location.replace('http://example.com/root/path');
|
||||
Backbone.history.start({pushState: true, hashChange: false, root: 'root'});
|
||||
Backbone.history.start({pushState: true, root: 'root'});
|
||||
Backbone.history.navigate('');
|
||||
});
|
||||
|
||||
@@ -707,7 +699,7 @@
|
||||
}
|
||||
});
|
||||
location.replace('http://example.com/path');
|
||||
Backbone.history.start({pushState: true, hashChange: false});
|
||||
Backbone.history.start({pushState: true});
|
||||
Backbone.history.navigate('');
|
||||
});
|
||||
|
||||
@@ -730,81 +722,8 @@
|
||||
var router = new Router;
|
||||
|
||||
location.replace('http://example.com/');
|
||||
Backbone.history.start({pushState: true, hashChange: false});
|
||||
Backbone.history.start({pushState: true});
|
||||
Backbone.history.navigate('path?query#hash', true);
|
||||
});
|
||||
|
||||
test('Do not decode the search params.', function() {
|
||||
var Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
path: function(params){
|
||||
strictEqual(params, 'x=y%20z');
|
||||
}
|
||||
}
|
||||
});
|
||||
var router = new Router;
|
||||
Backbone.history.navigate('path?x=y%20z', true);
|
||||
});
|
||||
|
||||
test('Navigate to a hash url.', function() {
|
||||
Backbone.history.stop();
|
||||
Backbone.history = _.extend(new Backbone.History, {location: location});
|
||||
Backbone.history.start({pushState: true});
|
||||
var Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
path: function(params) {
|
||||
strictEqual(params, 'x=y');
|
||||
}
|
||||
}
|
||||
});
|
||||
var router = new Router;
|
||||
location.replace('http://example.com/path?x=y#hash');
|
||||
Backbone.history.checkUrl();
|
||||
});
|
||||
|
||||
test('#navigate to a hash url.', function() {
|
||||
Backbone.history.stop();
|
||||
Backbone.history = _.extend(new Backbone.History, {location: location});
|
||||
Backbone.history.start({pushState: true});
|
||||
var Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
path: function(params) {
|
||||
strictEqual(params, 'x=y');
|
||||
}
|
||||
}
|
||||
});
|
||||
var router = new Router;
|
||||
Backbone.history.navigate('path?x=y#hash', true);
|
||||
});
|
||||
|
||||
test('unicode pathname', 1, function() {
|
||||
location.replace('http://example.com/myyjä');
|
||||
Backbone.history.stop();
|
||||
Backbone.history = _.extend(new Backbone.History, {location: location});
|
||||
var Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
myyjä: function() {
|
||||
ok(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
new Router;
|
||||
Backbone.history.start({pushState: true});
|
||||
});
|
||||
|
||||
test('newline in route', 1, function() {
|
||||
location.replace('http://example.com/stuff%0Anonsense?param=foo%0Abar');
|
||||
Backbone.history.stop();
|
||||
Backbone.history = _.extend(new Backbone.History, {location: location});
|
||||
var Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
'stuff\nnonsense': function() {
|
||||
ok(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
new Router;
|
||||
Backbone.history.start({pushState: true});
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
42
vendor/backbone/test/view.js
vendored
42
vendor/backbone/test/view.js
vendored
@@ -39,23 +39,23 @@
|
||||
test("delegateEvents", 6, function() {
|
||||
var counter1 = 0, counter2 = 0;
|
||||
|
||||
var view = new Backbone.View({el: '#testElement'});
|
||||
var view = new Backbone.View({el: '<p><a id="test"></a></p>'});
|
||||
view.increment = function(){ counter1++; };
|
||||
view.$el.on('click', function(){ counter2++; });
|
||||
|
||||
var events = {'click h1': 'increment'};
|
||||
var events = {'click #test': 'increment'};
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$('h1').trigger('click');
|
||||
view.$('#test').trigger('click');
|
||||
equal(counter1, 1);
|
||||
equal(counter2, 1);
|
||||
|
||||
view.$('h1').trigger('click');
|
||||
view.$('#test').trigger('click');
|
||||
equal(counter1, 2);
|
||||
equal(counter2, 2);
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$('h1').trigger('click');
|
||||
view.$('#test').trigger('click');
|
||||
equal(counter1, 3);
|
||||
equal(counter2, 3);
|
||||
});
|
||||
@@ -92,24 +92,24 @@
|
||||
test("undelegateEvents", 6, function() {
|
||||
var counter1 = 0, counter2 = 0;
|
||||
|
||||
var view = new Backbone.View({el: '#testElement'});
|
||||
var view = new Backbone.View({el: '<p><a id="test"></a></p>'});
|
||||
view.increment = function(){ counter1++; };
|
||||
view.$el.on('click', function(){ counter2++; });
|
||||
|
||||
var events = {'click h1': 'increment'};
|
||||
var events = {'click #test': 'increment'};
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$('h1').trigger('click');
|
||||
view.$('#test').trigger('click');
|
||||
equal(counter1, 1);
|
||||
equal(counter2, 1);
|
||||
|
||||
view.undelegateEvents();
|
||||
view.$('h1').trigger('click');
|
||||
view.$('#test').trigger('click');
|
||||
equal(counter1, 1);
|
||||
equal(counter2, 2);
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$('h1').trigger('click');
|
||||
view.$('#test').trigger('click');
|
||||
equal(counter1, 2);
|
||||
equal(counter2, 3);
|
||||
});
|
||||
@@ -218,7 +218,7 @@
|
||||
$('body').trigger('fake$event').trigger('fake$event');
|
||||
equal(count, 2);
|
||||
|
||||
$('body').off('.namespaced');
|
||||
$('body').unbind('.namespaced');
|
||||
$('body').trigger('fake$event');
|
||||
equal(count, 2);
|
||||
});
|
||||
@@ -304,24 +304,28 @@
|
||||
ok(view.$el.has('a'));
|
||||
});
|
||||
|
||||
test("events passed in options", 1, function() {
|
||||
test("events passed in options", 2, function() {
|
||||
var counter = 0;
|
||||
|
||||
var View = Backbone.View.extend({
|
||||
el: '#testElement',
|
||||
el: '<p><a id="test"></a></p>',
|
||||
increment: function() {
|
||||
counter++;
|
||||
}
|
||||
});
|
||||
|
||||
var view = new View({
|
||||
events: {
|
||||
'click h1': 'increment'
|
||||
}
|
||||
});
|
||||
var view = new View({events:{'click #test':'increment'}});
|
||||
var view2 = new View({events:function(){
|
||||
return {'click #test':'increment'};
|
||||
}});
|
||||
|
||||
view.$('h1').trigger('click').trigger('click');
|
||||
view.$('#test').trigger('click');
|
||||
view2.$('#test').trigger('click');
|
||||
equal(counter, 2);
|
||||
|
||||
view.$('#test').trigger('click');
|
||||
view2.$('#test').trigger('click');
|
||||
equal(counter, 4);
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
4
vendor/benchmark.js/LICENSE.txt
vendored
4
vendor/benchmark.js/LICENSE.txt
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright 2010-2015 Mathias Bynens <http://mathiasbynens.be/>
|
||||
Copyright 2010-2013 Mathias Bynens <http://mathiasbynens.be/>
|
||||
Based on JSLitmus.js, copyright Robert Kieffer <http://broofa.com/>
|
||||
Modified by John-David Dalton <http://allyoucanleet.com/>
|
||||
|
||||
@@ -19,4 +19,4 @@ 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.
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
820
vendor/benchmark.js/benchmark.js
vendored
820
vendor/benchmark.js/benchmark.js
vendored
File diff suppressed because it is too large
Load Diff
24
vendor/curl/LICENSE.txt
vendored
Normal file
24
vendor/curl/LICENSE.txt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
Open Source Initiative OSI - The MIT License
|
||||
|
||||
http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
Copyright (c) 2010-2013 Brian Cavalier and John Hann
|
||||
|
||||
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.
|
||||
48
vendor/curl/dist/curl-kitchen-sink/curl.js
vendored
Normal file
48
vendor/curl/dist/curl-kitchen-sink/curl.js
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
(function(){/*
|
||||
MIT License (c) copyright 2010-2013 B Cavalier & J Hann MIT (c) copyright 2010-2013 B Cavalier & J Hann */
|
||||
(function(f){function k(){}function g(a,e){return 0==T.call(a).indexOf("[object "+e)}function n(a){return a&&"/"==a.charAt(a.length-1)?a.substr(0,a.length-1):a}function d(a,e){var l,h,D,m;l=1;h=a;"."==h.charAt(0)&&(D=!0,h=h.replace(U,function(a,e,h,D){h&&l++;return D||""}));if(D){D=e.split("/");m=D.length-l;if(0>m)return a;D.splice(m,l);return D.concat(h||[]).join("/")}return h}function s(a){var e=a.indexOf("!");return{g:a.substr(e+1),d:0<=e&&a.substr(0,e)}}function v(){}function q(a,e){v.prototype=
|
||||
a||Q;var l=new v;v.prototype=Q;for(var h in e)l[h]=e[h];return l}function y(){function a(a,e,l){h.push([a,e,l])}function e(a,e){for(var l,D=0;l=h[D++];)(l=l[a])&&l(e)}var l,h,D;l=this;h=[];D=function(l,m){a=l?function(a){a&&a(m)}:function(a,e){e&&e(m)};D=k;e(l?0:1,m);e=k;h=G};this.l=function(e,h,D){a(e,h,D);return l};this.k=function(a){l.H=a;D(!0,a)};this.e=function(a){l.Ba=a;D(!1,a)};this.F=function(a){e(2,a)}}function x(a){return a instanceof y||a instanceof u}function r(a,e,l,h){x(a)?a.l(e,l,h):
|
||||
e(a)}function w(a,e,l){var h;return function(){0<=--a&&e&&(h=e.apply(G,arguments));0==a&&l&&l(h);return h}}function b(){var a,e;p="";a=[].slice.call(arguments);g(a[0],"Object")&&(e=a.shift(),e=c(e));return new u(a[0],a[1],a[2],e)}function c(a,e,l){var h;p="";if(a&&(t.V(a),E=t.b(a),"preloads"in a&&(h=new u(a.preloads,G,l,J,!0),t.n(function(){J=h})),a=a.main))return new u(a,e,l)}function u(a,e,l,h,D){var m;m=t.i(E,G,[].concat(a),D);this.then=this.l=a=function(a,e){r(m,function(e){a&&a.apply(G,e)},function(a){if(e)e(a);
|
||||
else throw a;});return this};this.next=function(a,e,h){return new u(a,e,h,m)};this.config=c;(e||l)&&a(e,l);t.n(function(){r(D||J,function(){r(h,function(){t.A(m)},l)})})}function z(a){var e,l;e=a.id;e==G&&(K!==G?K={L:"Multiple anonymous defines encountered"}:(e=t.ja())||(K=a));if(e!=G){l=F[e];e in F||(l=t.o(e,E),l=t.I(l.b,e),F[e]=l);if(!x(l))throw Error("duplicate define: "+e);l.oa=!1;t.J(l,a)}}function A(){var a=t.ga(arguments);z(a)}var p,E,C,H,B=f.document,L=B&&(B.head||B.getElementsByTagName("head")[0]),
|
||||
N=L&&L.getElementsByTagName("base")[0]||null,M={},I={},m={},V="addEventListener"in f?{}:{loaded:1,complete:1},Q={},T=Q.toString,G,F={},O={},J=!1,K,S=/^\/|^[^:]+:\/\//,U=/(\.)(\.?)(?:$|\/([^\.\/]+.*)?)/g,W=/\/\*[\s\S]*?\*\/|\/\/.*?[\n\r]/g,X=/require\s*\(\s*(["'])(.*?[^\\])\1\s*\)|[^\\]?(["'])/g,Y=/\s*,\s*/,R,t;t={t:function(a,e,l){var h;a=d(a,e);if("."==a.charAt(0))return a;h=s(a);a=(e=h.d)||h.g;a in l.c&&(a=l.c[a].Q||a);e&&(0>e.indexOf("/")&&!(e in l.c)&&(a=n(l.T)+"/"+e),a=a+"!"+h.g);return a},i:function(a,
|
||||
e,l,h){function m(e,h){var l,c;l=t.t(e,b.id,a);if(!h)return l;c=s(l);if(!c.d)return l;l=F[c.d];c.g="normalize"in l?l.normalize(c.g,m,b.b)||"":m(c.g);return c.d+"!"+c.g}function c(e,l,d){var s;s=l&&function(a){l.apply(G,a)};if(g(e,"String")){if(s)throw Error("require(id, callback) not allowed");d=m(e,!0);e=F[d];if(!(d in F))throw Error("Module not resolved: "+d);return(d=x(e)&&e.a)||e}r(t.A(t.i(a,b.id,e,h)),s,d)}var b;b=new y;b.id=e||"";b.ka=h;b.K=l;b.b=a;b.s=c;c.toUrl=function(e){return t.o(m(e,!0),
|
||||
a).url};b.t=m;return b},I:function(a,e,l){var h,m,c;h=t.i(a,e,G,l);m=h.k;c=w(1,function(a){h.w=a;try{return t.ba(h)}catch(e){h.e(e)}});h.k=function(a){r(l||J,function(){m(F[h.id]=O[h.url]=c(a))})};h.M=function(a){r(l||J,function(){h.a&&(c(a),h.F(I))})};return h},$:function(a,e,l,h){return t.i(a,l,G,h)},ia:function(a){return a.s},O:function(a){return a.a||(a.a={})},ha:function(a){var e=a.B;e||(e=a.B={id:a.id,uri:t.P(a),exports:t.O(a),config:function(){return a.b}},e.a=e.exports);return e},P:function(a){return a.url||
|
||||
(a.url=t.u(a.s.toUrl(a.id),a.b))},V:function(a){var e,l,h,m,c;e="curl";l="define";h=m=f;if(a&&(c=a.overwriteApi||a.ya,e=a.apiName||a.qa||e,h=a.apiContext||a.pa||h,l=a.defineName||a.ua||l,m=a.defineContext||a.ta||m,C&&g(C,"Function")&&(f.curl=C),C=null,H&&g(H,"Function")&&(f.define=H),H=null,!c)){if(h[e]&&h[e]!=b)throw Error(e+" already exists");if(m[l]&&m[l]!=A)throw Error(l+" already exists");}h[e]=b;m[l]=A},b:function(a){function e(a,e){var l,h,b,p,f;for(f in a){b=a[f];g(b,"String")&&(b={path:a[f]});
|
||||
b.name=b.name||f;p=m;h=s(n(b.name));l=h.g;if(h=h.d)p=c[h],p||(p=c[h]=q(m),p.c=q(m.c),p.f=[]),delete a[f];h=b;var k=e,r=void 0;h.path=n(h.path||h.location||"");k&&(r=h.main||"./main","."==r.charAt(0)||(r="./"+r),h.Q=d(r,h.name+"/"));h.b=h.config;h.b&&(h.b=q(m,h.b));h.W=l.split("/").length;l?(p.c[l]=h,p.f.push(l)):p.p=t.U(b.path,m)}}function l(a){var e=a.c;a.S=RegExp("^("+a.f.sort(function(a,h){return e[h].W-e[a].W}).join("|").replace(/\/|\./g,"\\$&")+")(?=\\/|$)");delete a.f}var h,m,c,b;"baseUrl"in
|
||||
a&&(a.p=a.baseUrl);"main"in a&&(a.Q=a.main);"preloads"in a&&(a.za=a.preloads);"pluginPath"in a&&(a.T=a.pluginPath);if("dontAddFileExt"in a||a.j)a.j=RegExp(a.dontAddFileExt||a.j);h=E;m=q(h,a);m.c=q(h.c);c=a.plugins||{};m.plugins=q(h.plugins);m.D=q(h.D,a.D);m.C=q(h.C,a.C);m.f=[];e(a.packages,!0);e(a.paths,!1);for(b in c)a=t.t(b+"!","",m),m.plugins[a.substr(0,a.length-1)]=c[b];c=m.plugins;for(b in c)if(c[b]=q(m,c[b]),a=c[b].f)c[b].f=a.concat(m.f),l(c[b]);for(b in h.c)m.c.hasOwnProperty(b)||m.f.push(b);
|
||||
l(m);return m},o:function(a,e){var m,h,b,c;m=e.c;b=S.test(a)?a:a.replace(e.S,function(a){h=m[a]||{};c=h.b;return h.path||""});return{b:c||E,url:t.U(b,e)}},U:function(a,e){var m=e.p;return m&&!S.test(a)?n(m)+"/"+a:a},u:function(a,e){return a+((e||E).j.test(a)?"":".js")},m:function(a,e,l){var h=B.createElement("script");h.onload=h.onreadystatechange=function(l){l=l||f.event;if("load"==l.type||V[h.readyState])delete m[a.id],h.onload=h.onreadystatechange=h.onerror="",e()};h.onerror=function(){l(Error("Syntax or http error: "+
|
||||
a.url))};h.type=a.r||"text/javascript";h.charset="utf-8";h.async=!a.R;h.src=a.url;m[a.id]=h;L.insertBefore(h,N);return h},N:function(a){var e=[],m;("string"==typeof a?a:a.toSource?a.toSource():a.toString()).replace(W,"").replace(X,function(a,b,c,d){d?m=m==d?G:m:m||e.push(c);return""});return e},ga:function(a){var e,m,h,b,c,d;c=a.length;h=a[c-1];b=g(h,"Function")?h.length:-1;2==c?g(a[0],"Array")?m=a[0]:e=a[0]:3==c&&(e=a[0],m=a[1]);!m&&0<b&&(d=!0,m=["require","exports","module"].slice(0,b).concat(t.N(h)));
|
||||
return{id:e,w:m||[],G:0<=b?h:function(){return h},v:d}},ba:function(a){var e;e=a.G.apply(a.v?a.a:G,a.w);e===G&&a.a&&(e=a.B?a.a=a.B.a:a.a);return e},J:function(a,e){a.G=e.G;a.v=e.v;a.K=e.w;t.A(a)},A:function(a){function e(a,e,m){d[e]=a;m&&s(a,e)}function m(e,h){var b,c,l,d;b=w(1,function(a){c(a);g(a,h)});c=w(1,function(a){s(a,h)});l=t.da(e,a);(d=x(l)&&l.a)&&c(d);r(l,b,a.e,a.a&&function(a){l.a&&(a==M?c(l.a):a==I&&b(l.a))})}function h(){a.k(d)}var b,c,d,p,f,s,g;d=[];c=a.K;p=c.length;0==c.length&&h();
|
||||
s=w(p,e,function(){a.M&&a.M(d)});g=w(p,e,h);for(b=0;b<p;b++)f=c[b],f in R?(g(R[f](a),b,!0),a.a&&a.F(M)):f?m(f,b):g(G,b,!0);return a},ea:function(a){t.P(a);t.m(a,function(){var e=K;K=G;!1!==a.oa&&(!e||e.L?a.e(Error(e&&e.L||"define() missing or duplicated: "+a.url)):t.J(a,e))},a.e);return a},da:function(a,e){var m,h,b,c,d,p,f,g,q,k,n,u;m=e.t;h=e.ka;b=e.b||E;d=m(a);d in F?p=d:(c=s(d),g=c.g,p=c.d||g,q=t.o(p,b));if(!(d in F))if(u=t.o(g,b).b,c.d)f=p;else if(f=u.moduleLoader||u.xa||u.loader||u.wa)g=p,p=
|
||||
f,q=t.o(f,b);p in F?k=F[p]:q.url in O?k=F[p]=O[q.url]:(k=t.I(u,p,h),k.url=t.u(q.url,q.b),F[p]=O[q.url]=k,t.ea(k));p==f&&(c.d&&b.plugins[c.d]&&(u=b.plugins[c.d]),n=new y,r(k,function(a){var e,b,c;c=a.dynamic;g="normalize"in a?a.normalize(g,m,k.b)||"":m(g);b=f+"!"+g;e=F[b];if(!(b in F)){e=t.$(u,b,g,h);c||(F[b]=e);var d=function(a){c||(F[b]=a);e.k(a)};d.resolve=d;d.reject=d.error=e.e;a.load(g,e.s,d,u)}n!=e&&r(e,n.k,n.e,n.F)},n.e));return n||k},ja:function(){var a;if(!g(f.opera,"Opera"))for(var e in m)if("interactive"==
|
||||
m[e].readyState){a=e;break}return a},fa:function(a){var e=0,m,b;for(m=B&&(B.scripts||B.getElementsByTagName("script"));m&&(b=m[e++]);)if(a(b))return b},ca:function(){var a,e="";(a=t.fa(function(a){(a=a.getAttribute("data-curl-run"))&&(e=a);return a}))&&a.setAttribute("data-curl-run","");return e},X:function(){function a(){t.m({url:b.shift()},e,e)}function e(){p&&(b.length?(t.n(m),a()):m("run.js script did not run."))}function m(a){throw Error(a||"Primary run.js failed. Trying fallback.");}var b=p.split(Y);
|
||||
b.length&&a()},n:function(a){setTimeout(a,0)}};R={require:t.ia,exports:t.O,module:t.ha};b.version="0.8.4";b.config=c;A.amd={plugins:!0,jQuery:!0,curl:"0.8.4"};E={p:"",T:"curl/plugin",j:/\?|\.js\b/,D:{},C:{},plugins:{},c:{},S:/$^/};C=f.curl;H=f.define;C&&g(C,"Object")?(f.curl=G,c(C)):t.V();(p=t.ca())&&t.n(t.X);F.curl=b;F["curl/_privileged"]={core:t,cache:F,config:function(){return E},_define:z,_curl:b,Promise:y}})(this.window||"undefined"!=typeof global&&global||this);
|
||||
(function(f,k){function g(){if(!k.body)return!1;A||(A=k.createTextNode(""));try{return k.body.removeChild(k.body.appendChild(A)),A=z,!0}catch(b){return!1}}function n(){var d;d=v[k[s]]&&g();if(!x&&d){x=!0;for(clearTimeout(u);b=c.pop();)b();y&&(k[s]="complete");for(var f;f=q.shift();)f()}return d}function d(){n();x||(u=setTimeout(d,r))}var s="readyState",v={loaded:1,interactive:1,complete:1},q=[],y=k&&"string"!=typeof k[s],x=!1,r=10,w,b,c=[],u,z,A;w="addEventListener"in f?function(b,c){b.addEventListener(c,
|
||||
n,!1);return function(){b.removeEventListener(c,n,!1)}}:function(b,c){b.attachEvent("on"+c,n);return function(){b.detachEvent(c,n)}};k&&!n()&&(c=[w(f,"load"),w(k,"readystatechange"),w(f,"DOMContentLoaded")],u=setTimeout(d,r));define("curl/domReady",function(){function b(c){x?c():q.push(c)}b.then=b;b.amd=!0;return b})})(this,this.document);var P;
|
||||
(function(f,k){define("curl/shim/dojo18",["curl/_privileged"],function(g){function n(c){c.has||(c.has=b);c.on||(c.on=s);c.idle||(c.idle=d);c.async=!0}function d(){for(var b in q)if(q[b]instanceof y)return!1;return!0}function s(){}var v,q,y,x;v=g._curl;q=g.cache;y=g.Promise;x=g.core.i;var r,w,b;r=g.b().va||{};w=k&&k.createElement("div");b=function(b){return"function"==typeof r[b]?r[b]=r[b](f,k,w):r[b]};b.add=function(c,d,f,g){if(void 0===r[c]||g)r[c]=d;if(f)return b(c)};r["dojo-loader"]=!1;q["dojo/_base/loader"]=
|
||||
0;"undefined"==typeof P&&(n(v),P=v);g.core.i=function(){var b=x.apply(this,arguments);n(b.s);return b};return!0})})("object"==typeof global?global:this.window||this.global,"object"==typeof document&&document);
|
||||
(function(f,k,g){define("curl/plugin/js",["curl/_privileged"],function(f){function d(b,c,d){function s(){p||(k<new Date?d():setTimeout(s,10))}var k,p,q;k=(new Date).valueOf()+(b.na||3E5);d&&b.a&&setTimeout(s,10);q=f.core.m(b,function(){p=!0;b.a&&(b.H=g(b.a));!b.a||b.H?c(q):d()},function(b){p=!0;d(b)})}function s(b,c){d(b,function(){var d=q.shift();r=0<q.length;d&&s.apply(null,d);c.k(b.H||!0)},function(b){c.e(b)})}var v={},q=[],y=k&&!0==k.createElement("script").async,x,r,w=/\?|\.js\b/;x=f.Promise;
|
||||
return{dynamic:!0,normalize:function(b,c){var d=b.indexOf("!");return 0<=d?c(b.substr(0,d))+b.substr(d):c(b)},load:function(b,c,f,g){function k(b){(f.error||function(b){throw b;})(b)}var p,n,C,H,B;p=0<b.indexOf("!order");n=b.indexOf("!exports=");C=0<n?b.substr(n+9):g.a;H="prefetch"in g?g.prefetch:!0;b=p||0<n?b.substr(0,b.indexOf("!")):b;n=(n=g.dontAddFileExt||g.j)?RegExp(n):w;B=c.toUrl(b);n.test(B)||(B=B.lastIndexOf(".")<=B.lastIndexOf("/")?B+".js":B);B in v?v[B]instanceof x?v[B].l(f,k):f(v[B]):(b=
|
||||
{name:b,url:B,R:p,a:C,na:g.timeout},v[B]=c=new x,c.l(function(b){v[B]=b;f(b)},k),p&&!y&&r?(q.push([b,c]),H&&(b.r="text/cache",d(b,function(b){b&&b.parentNode.removeChild(b)},function(){}),b.r="")):(r=r||p,s(b,c)))},cramPlugin:"../cram/js"}})})(this,this.document,function(f){try{return eval(f)}catch(k){}});
|
||||
define("curl/plugin/_fetchText",[],function(){var f,k;k=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"];f=function(){if("undefined"!==typeof XMLHttpRequest)f=function(){return new XMLHttpRequest};else for(var g=f=function(){throw Error("getXhr(): XMLHttpRequest not available");};0<k.length&&f===g;)(function(g){try{new ActiveXObject(g),f=function(){return new ActiveXObject(g)}}catch(d){}})(k.shift());return f()};return function(g,k,d){var s=f();s.open("GET",g,!0);s.onreadystatechange=function(){4===
|
||||
s.readyState&&(400>s.status?k(s.responseText):d(Error("fetchText() failed. status: "+s.statusText)))};s.send(null)}});define("curl/plugin/text",["./_fetchText"],function(f){function k(f){throw f;}return{load:function(g,n,d){f(n.toUrl(g),d,d.error||k)},cramPlugin:"../cram/text"}});
|
||||
define("curl/plugin/async",function(){return{load:function(f,k,g){function n(d){"function"==typeof g.error&&g.error(d)}k([f],function(d){"function"==typeof d.l?d.l(function(f){0==arguments.length&&(f=d);g(f)},n):g(d)},g.error||function(d){throw d;})},analyze:function(f,k,g){g(f)}}});
|
||||
(function(f){function k(){var b;b=p[z]("link");b.rel="stylesheet";b.type="text/css";return b}function g(b,c){b.onload=function(){I.load=I.load||!0;c()}}function n(b,c){b.onerror=function(){I.error=I.error||!0;c()}}function d(b,c,d){B.push({url:b,Y:c,aa:function(){d(Error(M))}});(b=v())&&s(b)}function s(b){var c,d;c=B.shift();d=b.styleSheet;c?(b.onload=function(){c.Y(c.ma);s(b)},b.onerror=function(){c.aa();s(b)},c.ma=d.imports[d.addImport(c.url)]):(b.onload=b.onerror=u,H.push(b))}function v(){var b;
|
||||
b=H.shift();!b&&C.length<L&&(b=p.createElement("style"),C.push(b),E.appendChild(b));return b}function q(b){var c,d,f;if(!b.href||p.readyState&&"complete"!=p.readyState)return!1;c=!1;try{if(d=b.sheet)f=d.cssRules,c=null===f,!c&&f&&(d.insertRule("-curl-css-test {}",0),d.deleteRule(0),c=!0)}catch(g){c="[object Opera]"!=Object.prototype.toString.call(window.opera)&&/security|denied/i.test(g.message)}return c}function y(b,c,d){I.load||(q(b)?d(b.sheet):b.onload==u||!b.onload||A(function(){y(b,c,d)},c))}
|
||||
function x(c,d,f){function k(){c.onload!=u&&c.onload&&(c.onload=c.onerror=u,b(function(){f(c.sheet)}))}g(c,k);y(c,d,k)}function r(b,c){n(b,function(){b.onload!=u&&b.onload&&(b.onload=b.onerror=u,c(Error(M)))})}function w(b,c,d,f){var g;g=k();x(g,f,c);r(g,d);g.href=b;E.appendChild(g)}function b(b){function c(){p.readyState&&"complete"!=p.readyState?A(c,10):b()}c()}function c(b){return b.lastIndexOf(".")<=b.lastIndexOf("/")?b+".css":b}function u(){}var z="createElement",A=f.setTimeout,p=f.document,
|
||||
E;f=p&&p.createStyleSheet&&!(10<=p.documentMode);var C=[],H=[],B=[],L=12,N,M="HTTP or network error.",I={};p&&(E=p.head||p.getElementsByTagName("head")[0],N=f?d:w);define("curl/plugin/css",{normalize:function(b,c){var d,f;if(!b)return b;d=b.split(",");f=[];for(var g=0,k=d.length;g<k;g++)f.push(c(d[g]));return f.join(",")},load:function(b,d,f,g){function p(b){1<n.length&&q.push(b);0==--C&&f(1==n.length?b:q)}function s(b){(f.e||function(b){throw b;})(b)}var q,n,r,C,w;q=[];n=(b||"").split(",");r=g.cssWatchPeriod||
|
||||
50;g=g.cssNoWait;C=n.length;for(w=0;w<n.length;w++){b=n[w];var u;b=c(d.toUrl(b));g?(u=k(),u.href=b,E.appendChild(u),p(u.sheet||u.styleSheet)):N(b,p,s,r)}},cramPlugin:"../cram/css"})})(this);
|
||||
(function(f){var k=f.document,g=/^\/\//,n;k&&(n=k.head||(k.head=k.getElementsByTagName("head")[0]));define("curl/plugin/link",{load:function(d,f,v,q){d=f.toUrl(d);d=d.lastIndexOf(".")<=d.lastIndexOf("/")?d+".css":d;q=d=(q="fixSchemalessUrls"in q?q.fixSchemalessUrls:k.location.protocol)?d.replace(g,q+"//"):d;d=k.createElement("link");d.rel="stylesheet";d.type="text/css";d.href=q;n.appendChild(d);v(d.sheet||d.styleSheet)}})})(this);
|
||||
define("curl/plugin/domReady",["../domReady"],function(f){return{load:function(k,g,n){f(n)}}});(function(f){define("curl/shim/_fetchText",function(){function k(d,f,g){n.Aa(d,function(d,k){d?g(d):f(k.toString())})}function g(f,g,k){var n;f=s.parse(f,!1,!0);n="";d.get(f,function(d){d.h("data",function(b){n+=b}).h("end",function(){g(n)}).h("error",k)}).h("error",k)}var n,d,s;n=f("fs");d=f("http");s=f("url");var v;v=/^https?:/;return function(d,f,n){v.test(d)?g(d,f,n):k(d,f,n)}})})(P);define.amd.Da=!0;
|
||||
(function(f,k){define("curl/shim/ssjs",["curl/_privileged","./_fetchText"],function(g,n){function d(b,c,d){try{k(b.url),c()}catch(f){d(f)}}function s(b,c,d){var g;try{g=b.url.replace(/\.js$/,""),f(g),c()}catch(k){d(k)}}function v(b,c,d){var g;b=f("url").parse(b.url,!1,!0);g="";z.get(b,function(b){b.h("data",function(b){g+=b}).h("end",function(){y(g);c()}).h("error",d)}).h("error",d)}function q(b){throw Error("ssjs: unable to load module in current environment: "+b.url);}function y(b){eval(b)}function x(b){return b&&
|
||||
b.replace(c,function(b,c){return c})}var r,w,b,c,u,z,A,p;if("object"!=typeof window||!window.sa&&!window.navigator){r=g.ra;w=g.b();b=/^\w+:\/\//;c=/(^\w+:)?.*$/;"undefined"==typeof XMLHttpRequest&&(r["curl/plugin/_fetchText"]=n);u=(w.q&&":"!=w.q[w.q.length-1]?w.q+":":w.q)||x(w.p)||"http:";if(k)A=p=d;else if(f){A=s;try{z=f("http"),p=v}catch(E){p=q}}else A=p=q;"object"===typeof process&&process.la&&(g.Z.n=process.la);g.Z.m=function(c,d,f){/^\/\//.test(c.url)&&(c.url=u+c.url);return b.test(c.url)?p(c,
|
||||
d,f):A(c,d,f)}}})})(P,void 0);
|
||||
(function(f,k,g){define("curl/loader/cjsm11",["../plugin/_fetchText","curl/_privileged"],function(f,d){function s(d,b){s="text"in d?function(b,d){b.text=d}:function(b,d){b.appendChild(k.createTextNode(d))};s(d,b)}function v(d,b,c){c=c?"/*\n////@ sourceURL="+c.replace(/\s/g,"%20")+".js\n*/":"";return"define('"+b+"',['require','exports','module'],function(require,exports,module){"+d+"\n});\n"+c+"\n"}var q,y,x,r;y=(q=k&&(k.head||k.getElementsByTagName("head")[0]))&&q.getElementsByTagName("base")[0]||null;
|
||||
x=d.core.N;r=d.core.u;v.load=function(d,b,c,u){var z,A,p;z=c.error||function(b){throw b;};A=r(b.Fa(d),u);p=!1!==u.injectSourceUrl&&A;f(A,function(f){var n;n=x(f);b(n,function(){f=v(f,d,p);if(u.injectScript){var n=f,r=k.createElement("script");s(r,n);r.charset="utf-8";q.insertBefore(r,y)}else g(f);c(b(d))},z)},z)};v.cramPlugin="../cram/cjsm11";return v})})(this,this.document,function(f){eval(f)});
|
||||
define("curl/plugin/locale",function(){function f(f,d){var g;if(f&&(g=f.locale,"function"==typeof g&&(g=g(f,d)),"string"==typeof g))return g;if("undefined"==typeof window)return!1;g=window.clientInformation||window.navigator;return(g&&(g.language||g.userLanguage)||"").toLowerCase()}function k(f,d){return f.replace(g,(d?"/"+d:"")+"$&")}var g;g=/(\.js)?$/;f.toModuleId=k;f.load=function(g,d,s,v){function q(){var b=Error("Unable to find correct locale for "+g);if(s.error)s.error(b);else throw b;}var y,
|
||||
x;y=f(v,g);x=v.localeToModuleId||k;v=y?x(g,y):g;try{s(d(v))}catch(r){x=y?x(g,!1):g;if(x==v)return q();try{s(d(x))}catch(w){if(!0!==y)return q();d(["i18n!"+g],s,q)}}};return f});
|
||||
define("curl/plugin/i18n",["./locale"],function(f){function k(f,k,d,s,v){f([k],function(f){s(f,d)},v)}return{load:function(g,n,d,s){function v(b,c){w[c]=b;q()}function q(){var f;if(++b==c.length)if(0==w.length)y(Error('No i18n bundles found: "'+g+'", locale "'+r+'"'));else{f=w[0]||{};for(z=1;z<w.length;z++){var k=w[z],n={},q=void 0;for(q in f)n[q]=f[q];if(k)for(q in k)n[q]=k[q];f=n}d(f)}}var y,x,r,w,b,c,u,z;y=d.error;g||y(Error("blank i18n bundle id."));x=s.localeToModuleId||f.Ea;r=f(s,g);c=[g];w=
|
||||
[];b=0;if(r&&!1!==s.locale)for(c=c.concat(r.split("-")),u=[],z=1;z<c.length;z++)u[z-1]=c[z],s=x(g,u.join("-")),k(n,s,z,v,q);k(n,g,0,v,q)},cramPlugin:"../cram/i18n"}});
|
||||
(function(f,k,g){define("curl/loader/legacy",["curl/_privileged"],function(n){var d,s,v;d=k&&!0==k.createElement("script").async;s=n.core.m;v=/\?|\.js\b/;return{load:function(k,n,x,r){function w(){E.r="";s(E,b,c)}function b(){var b;if(!(0<--C)){if(z)try{b=z.call(f,k)}catch(d){c(Error("Factory for legacy "+k+" failed: "+d.message))}else try{b=g(u)}catch(n){c(Error("Failed to find exports "+u+" for legacy "+k))}define(k,b);x(b)}}function c(b){(x.error||function(b){throw b;})(b)}var u,z,A,p,E,C;u=r.exports||
|
||||
r.a;z=r.factory||r.factory;if(!u&&!z)throw Error("`exports` or `factory` required for legacy: "+k);A=[].concat(r.requires||r.Ca||[]);r=(r=r.dontAddFileExt||r.j)?RegExp(r):v;p=n.toUrl(k);r.test(p)||(p=p.lastIndexOf(".")<=p.lastIndexOf("/")?p+".js":p);E={url:p,R:!0,r:d||!A.length?"":"text/cache"};A.length?(C=2,n(A,d?b:w,c)):C=1;s(E,b,c)},cramPlugin:"../cram/legacy"}})})(this,this.document,function(f){return(0,eval)(f)});
|
||||
}).call(this);
|
||||
20
vendor/docdown/LICENSE.txt
vendored
Normal file
20
vendor/docdown/LICENSE.txt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright 2011-2013 John-David Dalton <http://allyoucanleet.com/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
38
vendor/docdown/docdown.php
vendored
Normal file
38
vendor/docdown/docdown.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*!
|
||||
* Docdown v1.0.0-pre
|
||||
* Copyright 2011-2013 John-David Dalton <http://allyoucanleet.com/>
|
||||
* Available under MIT license <http://mths.be/mit>
|
||||
*/
|
||||
require(dirname(__FILE__) . '/src/DocDown/MarkdownGenerator.php');
|
||||
|
||||
/**
|
||||
* Generates Markdown from JSDoc entries in a given file.
|
||||
*
|
||||
* @param {Array} [$options=array()] The options array.
|
||||
* @returns {string} The generated Markdown.
|
||||
* @example
|
||||
*
|
||||
* // specify a file path
|
||||
* $markdown = docdown(array(
|
||||
* // path to js file
|
||||
* 'path' => $filepath,
|
||||
* // url used to reference line numbers in code
|
||||
* 'url' => 'https://github.com/username/project/blob/master/my.js'
|
||||
* ));
|
||||
*
|
||||
* // or pass raw js
|
||||
* $markdown = docdown(array(
|
||||
* // raw JavaScript source
|
||||
* 'source' => $rawJS,
|
||||
* // documentation title
|
||||
* 'title' => 'My API Documentation',
|
||||
* // url used to reference line numbers in code
|
||||
* 'url' => 'https://github.com/username/project/blob/master/my.js'
|
||||
* ));
|
||||
*/
|
||||
function docdown( $options = array() ) {
|
||||
$gen = new MarkdownGenerator($options);
|
||||
return $gen->generate();
|
||||
}
|
||||
?>
|
||||
226
vendor/docdown/src/DocDown/Alias.php
vendored
Normal file
226
vendor/docdown/src/DocDown/Alias.php
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* A class to represent a JSDoc entry alias.
|
||||
*/
|
||||
class Alias {
|
||||
|
||||
/**
|
||||
* The alias owner.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @type Object
|
||||
*/
|
||||
public $owner;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The Alias constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} $name The alias name.
|
||||
* @param {Object} $owner The alias owner.
|
||||
*/
|
||||
public function __construct( $name, $owner ) {
|
||||
$this->owner = $owner;
|
||||
$this->_name = $name;
|
||||
$this->_call = $owner->getCall();
|
||||
$this->_category = $owner->getCategory();
|
||||
$this->_desc = $owner->getDesc();
|
||||
$this->_example = $owner->getExample();
|
||||
$this->_isCtor = $owner->isCtor();
|
||||
$this->_isLicense = $owner->isLicense();
|
||||
$this->_isPlugin = $owner->isPlugin();
|
||||
$this->_isPrivate = $owner->isPrivate();
|
||||
$this->_isStatic = $owner->isStatic();
|
||||
$this->_lineNumber = $owner->getLineNumber();
|
||||
$this->_members = $owner->getMembers();
|
||||
$this->_params = $owner->getParams();
|
||||
$this->_returns = $owner->getReturns();
|
||||
$this->_type = $owner->getType();
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Extracts the entry's `alias` objects.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @param {number} $index The index of the array value to return.
|
||||
* @returns {Array|string} The entry's `alias` objects.
|
||||
*/
|
||||
public function getAliases( $index = null ) {
|
||||
$result = array();
|
||||
return $index !== null
|
||||
? @$result[$index]
|
||||
: $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the function call from the owner entry.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {string} The function call.
|
||||
*/
|
||||
public function getCall() {
|
||||
return $this->_call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the owner entry's `category` data.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {string} The owner entry's `category` data.
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the owner entry's description.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {string} The owner entry's description.
|
||||
*/
|
||||
public function getDesc() {
|
||||
return $this->_desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the owner entry's `example` data.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {string} The owner entry's `example` data.
|
||||
*/
|
||||
public function getExample() {
|
||||
return $this->_example;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entry is an alias.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {boolean} Returns `true`.
|
||||
*/
|
||||
public function isAlias() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the owner entry is a constructor.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {boolean} Returns `true` if a constructor, else `false`.
|
||||
*/
|
||||
public function isCtor() {
|
||||
return $this->_isCtor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the owner entry is a license.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {boolean} Returns `true` if a license, else `false`.
|
||||
*/
|
||||
public function isLicense() {
|
||||
return $this->_isLicense;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the owner entry *is* assigned to a prototype.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {boolean} Returns `true` if assigned to a prototype, else `false`.
|
||||
*/
|
||||
public function isPlugin() {
|
||||
return $this->_isPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the owner entry is private.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {boolean} Returns `true` if private, else `false`.
|
||||
*/
|
||||
public function isPrivate() {
|
||||
return $this->_isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the owner entry is *not* assigned to a prototype.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {boolean} Returns `true` if not assigned to a prototype, else `false`.
|
||||
*/
|
||||
public function isStatic() {
|
||||
return $this->_isStatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the owner entry's line number.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {number} The owner entry's line number.
|
||||
*/
|
||||
public function getLineNumber() {
|
||||
return $this->_lineNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the owner entry's `member` data.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @param {number} $index The index of the array value to return.
|
||||
* @returns {Array|string} The owner entry's `member` data.
|
||||
*/
|
||||
public function getMembers( $index = null ) {
|
||||
return $index !== null
|
||||
? @$this->_members[$index]
|
||||
: $this->_members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the owner entry's `name` data.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {string} The owner entry's `name` data.
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the owner entry's `param` data.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @param {number} $index The index of the array value to return.
|
||||
* @returns {Array} The owner entry's `param` data.
|
||||
*/
|
||||
public function getParams( $index = null ) {
|
||||
return $index !== null
|
||||
? @$this->_params[$index]
|
||||
: $this->_params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the owner entry's `returns` data.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {string} The owner entry's `returns` data.
|
||||
*/
|
||||
public function getReturns() {
|
||||
return $this->_returns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the owner entry's `type` data.
|
||||
*
|
||||
* @memberOf Alias
|
||||
* @returns {string} The owner entry's `type` data.
|
||||
*/
|
||||
public function getType() {
|
||||
return $this->_type;
|
||||
}
|
||||
}
|
||||
?>
|
||||
452
vendor/docdown/src/DocDown/Entry.php
vendored
Normal file
452
vendor/docdown/src/DocDown/Entry.php
vendored
Normal file
@@ -0,0 +1,452 @@
|
||||
<?php
|
||||
|
||||
require(dirname(__FILE__) . "/Alias.php");
|
||||
|
||||
/**
|
||||
* A class to simplify parsing a single JSDoc entry.
|
||||
*/
|
||||
class Entry {
|
||||
|
||||
/**
|
||||
* The documentation entry.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @type string
|
||||
*/
|
||||
public $entry = '';
|
||||
|
||||
/**
|
||||
* The language highlighter used for code examples.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @type string
|
||||
*/
|
||||
public $lang = '';
|
||||
|
||||
/**
|
||||
* The source code.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @type string
|
||||
*/
|
||||
public $source = '';
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The Entry constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} $entry The documentation entry to analyse.
|
||||
* @param {string} $source The source code.
|
||||
* @param {string} [$lang ='js'] The language highlighter used for code examples.
|
||||
*/
|
||||
public function __construct( $entry, $source, $lang = 'js' ) {
|
||||
$this->entry = $entry;
|
||||
$this->lang = $lang;
|
||||
$this->source = str_replace(PHP_EOL, "\n", $source);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Extracts the documentation entries from source code.
|
||||
*
|
||||
* @static
|
||||
* @memberOf Entry
|
||||
* @param {string} $source The source code.
|
||||
* @returns {Array} The array of entries.
|
||||
*/
|
||||
public static function getEntries( $source ) {
|
||||
preg_match_all('#/\*\*(?![-!])[\s\S]*?\*/\s*.+#', $source, $result);
|
||||
return array_pop($result);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Checks if the entry is a function reference.
|
||||
*
|
||||
* @private
|
||||
* @memberOf Entry
|
||||
* @returns {boolean} Returns `true` if the entry is a function reference, else `false`.
|
||||
*/
|
||||
private function isFunction() {
|
||||
if (!isset($this->_isFunction)) {
|
||||
$this->_isFunction = !!(
|
||||
$this->isCtor() ||
|
||||
count($this->getParams()) ||
|
||||
count($this->getReturns()) ||
|
||||
preg_match('/\*[\t ]*@function\b/', $this->entry) ||
|
||||
preg_match('#\*/\s*function #', $this->entry)
|
||||
);
|
||||
}
|
||||
return $this->_isFunction;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Extracts the entry's `alias` objects.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @param {number} $index The index of the array value to return.
|
||||
* @returns {Array|string} The entry's `alias` objects.
|
||||
*/
|
||||
public function getAliases( $index = null ) {
|
||||
if (!isset($this->_aliases)) {
|
||||
preg_match('#\*[\t ]*@alias\s+(.+)#', $this->entry, $result);
|
||||
|
||||
if (count($result)) {
|
||||
$result = trim(preg_replace('/(?:^|\n)[\t ]*\*[\t ]?/', ' ', $result[1]));
|
||||
$result = preg_split('/,\s*/', $result);
|
||||
natsort($result);
|
||||
|
||||
foreach ($result as $resultIndex => $value) {
|
||||
$result[$resultIndex] = new Alias($value, $this);
|
||||
}
|
||||
}
|
||||
$this->_aliases = $result;
|
||||
}
|
||||
return $index !== null
|
||||
? @$this->_aliases[$index]
|
||||
: $this->_aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the function call from the entry.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {string} The function call.
|
||||
*/
|
||||
public function getCall() {
|
||||
if (isset($this->_call)) {
|
||||
return $this->_call;
|
||||
}
|
||||
|
||||
preg_match('#\*/\s*(?:function ([^(]*)|(.*?)(?=[:=,]|return\b))#', $this->entry, $result);
|
||||
if ($result = array_pop($result)) {
|
||||
$result = array_pop(explode('var ', trim(trim(array_pop(explode('.', $result))), "'")));
|
||||
}
|
||||
// resolve name
|
||||
// avoid $this->getName() because it calls $this->getCall()
|
||||
preg_match('#\*[\t ]*@name\s+(.+)#', $this->entry, $name);
|
||||
if (count($name)) {
|
||||
$name = trim($name[1]);
|
||||
} else {
|
||||
$name = $result;
|
||||
}
|
||||
// compile function call syntax
|
||||
if ($this->isFunction()) {
|
||||
// compose parts
|
||||
$result = array($result);
|
||||
$params = $this->getParams();
|
||||
|
||||
foreach ($params as $param) {
|
||||
// skip params that are properties of other params (e.g. `options.leading`)
|
||||
if (!preg_match('/\w+\.[\w.]+\s*=/', $param[1])) {
|
||||
$result[] = $param[1];
|
||||
}
|
||||
}
|
||||
// format
|
||||
$result = $name .'('. implode(array_slice($result, 1), ', ') .')';
|
||||
}
|
||||
|
||||
$this->_call = $result ? $result : $name;
|
||||
return $this->_call;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the entry's `category` data.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {string} The entry's `category` data.
|
||||
*/
|
||||
public function getCategory() {
|
||||
if (isset($this->_category)) {
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
preg_match('#\*[\t ]*@category\s+(.+)#', $this->entry, $result);
|
||||
if (count($result)) {
|
||||
$result = trim(preg_replace('/(?:^|\n)[\t ]*\*[\t ]?/', ' ', $result[1]));
|
||||
} else {
|
||||
$result = $this->getType() == 'Function' ? 'Methods' : 'Properties';
|
||||
}
|
||||
$this->_category = $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the entry's description.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {string} The entry's description.
|
||||
*/
|
||||
public function getDesc() {
|
||||
if (isset($this->_desc)) {
|
||||
return $this->_desc;
|
||||
}
|
||||
|
||||
preg_match('#/\*\*(?:\s*\*)?([\s\S]*?)(?=\*\s\@[a-z]|\*/)#', $this->entry, $result);
|
||||
if (count($result)) {
|
||||
$type = $this->getType();
|
||||
$result = preg_replace('/:\n[\t ]*\*[\t ]*/', ":<br>\n", $result[1]);
|
||||
$result = preg_replace('/(?:^|\n)[\t ]*\*\n[\t ]*\*[\t ]*/', "\n\n", $result);
|
||||
$result = preg_replace('/(?:^|\n)[\t ]*\*[\t ]?/', ' ', $result);
|
||||
$result = trim($result);
|
||||
$result = ($type == 'Function' ? '' : '(' . str_replace('|', ', ', trim($type, '{}')) . '): ') . $result;
|
||||
}
|
||||
$this->_desc = $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the entry's `example` data.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {string} The entry's `example` data.
|
||||
*/
|
||||
public function getExample() {
|
||||
if (isset($this->_example)) {
|
||||
return $this->_example;
|
||||
}
|
||||
|
||||
preg_match('#\*[\t ]*@example\s+([\s\S]*?)(?=\*\s\@[a-z]|\*/)#', $this->entry, $result);
|
||||
if (count($result)) {
|
||||
$result = trim(preg_replace('/(?:^|\n)[\t ]*\*[\t ]?/', "\n", $result[1]));
|
||||
$result = '```' . $this->lang . "\n" . $result . "\n```";
|
||||
}
|
||||
$this->_example = $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entry is an alias.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {boolean} Returns `false`.
|
||||
*/
|
||||
public function isAlias() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entry is a constructor.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {boolean} Returns `true` if a constructor, else `false`.
|
||||
*/
|
||||
public function isCtor() {
|
||||
if (!isset($this->_isCtor)) {
|
||||
$this->_isCtor = !!preg_match('/\*[\t ]*@constructor\b/', $this->entry);
|
||||
}
|
||||
return $this->_isCtor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entry is a license.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {boolean} Returns `true` if a license, else `false`.
|
||||
*/
|
||||
public function isLicense() {
|
||||
if (!isset($this->_isLicense)) {
|
||||
$this->_isLicense = !!preg_match('/\*[\t ]*@license\b/', $this->entry);
|
||||
}
|
||||
return $this->_isLicense;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entry *is* assigned to a prototype.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {boolean} Returns `true` if assigned to a prototype, else `false`.
|
||||
*/
|
||||
public function isPlugin() {
|
||||
if (!isset($this->_isPlugin)) {
|
||||
$this->_isPlugin = !$this->isCtor() && !$this->isPrivate() && !$this->isStatic();
|
||||
}
|
||||
return $this->_isPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entry is private.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {boolean} Returns `true` if private, else `false`.
|
||||
*/
|
||||
public function isPrivate() {
|
||||
if (!isset($this->_isPrivate)) {
|
||||
$this->_isPrivate = $this->isLicense() || !!preg_match('/\*[\t ]*@private\b/', $this->entry) || !preg_match('/\*[\t ]*@[a-z]+\b/', $this->entry);
|
||||
}
|
||||
return $this->_isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entry is *not* assigned to a prototype.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {boolean} Returns `true` if not assigned to a prototype, else `false`.
|
||||
*/
|
||||
public function isStatic() {
|
||||
if (isset($this->_isStatic)) {
|
||||
return $this->_isStatic;
|
||||
}
|
||||
|
||||
$public = !$this->isPrivate();
|
||||
$result = $public && !!preg_match('/\*[\t ]*@static\b/', $this->entry);
|
||||
|
||||
// set in cases where it isn't explicitly stated
|
||||
if ($public && !$result) {
|
||||
if ($parent = array_pop(preg_split('/[#.]/', $this->getMembers(0)))) {
|
||||
foreach (Entry::getEntries($this->source) as $entry) {
|
||||
$entry = new Entry($entry, $this->source);
|
||||
if ($entry->getName() == $parent) {
|
||||
$result = !$entry->isCtor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
$this->_isStatic = $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the entry's line number.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {number} The entry's line number.
|
||||
*/
|
||||
public function getLineNumber() {
|
||||
if (!isset($this->_lineNumber)) {
|
||||
preg_match_all('/\n/', substr($this->source, 0, strrpos($this->source, $this->entry) + strlen($this->entry)), $lines);
|
||||
$this->_lineNumber = count(array_pop($lines)) + 1;
|
||||
}
|
||||
return $this->_lineNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the entry's `member` data.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @param {number} $index The index of the array value to return.
|
||||
* @returns {Array|string} The entry's `member` data.
|
||||
*/
|
||||
public function getMembers( $index = null ) {
|
||||
if (!isset($this->_members)) {
|
||||
preg_match('#\*[\t ]*@member(?:Of)?\s+(.+)#', $this->entry, $result);
|
||||
if (count($result)) {
|
||||
$result = trim(preg_replace('/(?:^|\n)[\t ]*\*[\t ]?/', ' ', $result[1]));
|
||||
$result = preg_split('/,\s*/', $result);
|
||||
natsort($result);
|
||||
}
|
||||
$this->_members = $result;
|
||||
}
|
||||
return $index !== null
|
||||
? @$this->_members[$index]
|
||||
: $this->_members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the entry's `name` data.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {string} The entry's `name` data.
|
||||
*/
|
||||
public function getName() {
|
||||
if (isset($this->_name)) {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
preg_match('#\*[\t ]*@name\s+(.+)#', $this->entry, $result);
|
||||
if (count($result)) {
|
||||
$result = trim(preg_replace('/(?:^|\n)[\t ]*\*[\t ]?/', ' ', $result[1]));
|
||||
} else {
|
||||
$result = array_shift(explode('(', $this->getCall()));
|
||||
}
|
||||
$this->_name = $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the entry's `param` data.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @param {number} $index The index of the array value to return.
|
||||
* @returns {Array} The entry's `param` data.
|
||||
*/
|
||||
public function getParams( $index = null ) {
|
||||
if (!isset($this->_params)) {
|
||||
preg_match_all('#\*[\t ]*@param\s+\{\(?([^})]+)\)?\}\s+(\[.+\]|[$\w|]+(?:\[.+\])?)\s+([\s\S]*?)(?=\*\s\@[a-z]|\*/)#i', $this->entry, $matchTuples);
|
||||
$matchTuples = array_filter(array_slice($matchTuples, 1));
|
||||
$result = array();
|
||||
|
||||
if (count($matchTuples)) {
|
||||
foreach ($matchTuples as $tupleKey => $tuple) {
|
||||
foreach ($tuple as $key => $value) {
|
||||
if (!isset($result[$key])) {
|
||||
$result[$key] = array();
|
||||
}
|
||||
$result[$key][] = $tupleKey
|
||||
? trim(preg_replace('/(?:^|\n)[\t ]*\*[\t ]*/', ' ', $value))
|
||||
: trim($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_params = $result;
|
||||
}
|
||||
return $index !== null
|
||||
? @$this->_params[$index]
|
||||
: $this->_params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the entry's `returns` data.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {string} The entry's `returns` data.
|
||||
*/
|
||||
public function getReturns() {
|
||||
if (isset($this->_returns)) {
|
||||
return $this->_returns;
|
||||
}
|
||||
|
||||
preg_match('#\*[\t ]*@returns\s+\{([^}]+)\}\s+([\s\S]*?)(?=\*\s\@[a-z]|\*/)#', $this->entry, $result);
|
||||
if (count($result)) {
|
||||
$result = array_map('trim', array_slice($result, 1));
|
||||
$result[0] = str_replace('|', ', ', $result[0]);
|
||||
$result[1] = preg_replace('/(?:^|\n)[\t ]*\*[\t ]?/', ' ', $result[1]);
|
||||
}
|
||||
$this->_returns = $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the entry's `type` data.
|
||||
*
|
||||
* @memberOf Entry
|
||||
* @returns {string} The entry's `type` data.
|
||||
*/
|
||||
public function getType() {
|
||||
if (isset($this->_type)) {
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
preg_match('#\*[\t ]*@type\s(?:\{\(?)?([^)}\n]+)#', $this->entry, $result);
|
||||
if (count($result)) {
|
||||
$result = trim($result[1]);
|
||||
if (preg_match('/^(?:array|function|object|regexp)$/', $result)) {
|
||||
$result = ucfirst($result);
|
||||
}
|
||||
} else {
|
||||
$result = $this->isFunction() ? 'Function' : 'unknown';
|
||||
}
|
||||
$this->_type = $result;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
648
vendor/docdown/src/DocDown/MarkdownGenerator.php
vendored
Normal file
648
vendor/docdown/src/DocDown/MarkdownGenerator.php
vendored
Normal file
@@ -0,0 +1,648 @@
|
||||
<?php
|
||||
|
||||
require(dirname(__FILE__) . "/Entry.php");
|
||||
|
||||
/**
|
||||
* Generates Markdown from JSDoc entries.
|
||||
*/
|
||||
class MarkdownGenerator {
|
||||
|
||||
/**
|
||||
* The HTML for the close tag.
|
||||
*
|
||||
* @static
|
||||
* @memberOf MarkdownGenerator
|
||||
* @type string
|
||||
*/
|
||||
public $closeTag = "\n<!-- /div -->\n";
|
||||
|
||||
/**
|
||||
* An array of JSDoc entries.
|
||||
*
|
||||
* @memberOf MarkdownGenerator
|
||||
* @type Array
|
||||
*/
|
||||
public $entries = array();
|
||||
|
||||
/**
|
||||
* The HTML for the open tag.
|
||||
*
|
||||
* @memberOf MarkdownGenerator
|
||||
* @type string
|
||||
*/
|
||||
public $openTag = "\n<!-- div -->\n";
|
||||
|
||||
/**
|
||||
* An options array used to configure the generator.
|
||||
*
|
||||
* @memberOf MarkdownGenerator
|
||||
* @type Array
|
||||
*/
|
||||
public $options = array();
|
||||
|
||||
/**
|
||||
* The file's source code.
|
||||
*
|
||||
* @memberOf MarkdownGenerator
|
||||
* @type string
|
||||
*/
|
||||
public $source = '';
|
||||
|
||||
/**
|
||||
* The array of code snippets that are tokenized by `escape`.
|
||||
*
|
||||
* @private
|
||||
* @memberOf MarkdownGenerator
|
||||
* @type Array
|
||||
*/
|
||||
private $snippets = array();
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The MarkdownGenerator constructor.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} $source The source code to parse.
|
||||
* @param {Array} $options The options array.
|
||||
*/
|
||||
public function __construct( $source, $options = array() ) {
|
||||
// juggle arguments
|
||||
if (is_array($source)) {
|
||||
$options = $source;
|
||||
} else {
|
||||
$options['source'] = $source;
|
||||
}
|
||||
if (isset($options['source']) && realpath($options['source'])) {
|
||||
$options['path'] = $options['source'];
|
||||
}
|
||||
if (isset($options['path'])) {
|
||||
preg_match('/(?<=\.)[a-z]+$/', $options['path'], $ext);
|
||||
$options['source'] = file_get_contents($options['path']);
|
||||
$ext = array_pop($ext);
|
||||
|
||||
if (!isset($options['lang']) && $ext) {
|
||||
$options['lang'] = $ext;
|
||||
}
|
||||
if (!isset($options['title'])) {
|
||||
$options['title'] = ucfirst(basename($options['path'])) . ' API documentation';
|
||||
}
|
||||
}
|
||||
if (!isset($options['lang'])) {
|
||||
$options['lang'] = 'js';
|
||||
}
|
||||
if (!isset($options['toc'])) {
|
||||
$options['toc'] = 'properties';
|
||||
}
|
||||
|
||||
$this->options = $options;
|
||||
$this->source = str_replace(PHP_EOL, "\n", $options['source']);
|
||||
$this->entries = Entry::getEntries($this->source);
|
||||
|
||||
foreach ($this->entries as $index => $value) {
|
||||
$this->entries[$index] = new Entry($value, $this->source, $options['lang']);
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Performs common string formatting operations.
|
||||
*
|
||||
* @private
|
||||
* @static
|
||||
* @memberOf MarkdownGenerator
|
||||
* @param {string} $string The string to format.
|
||||
* @returns {string} The formatted string.
|
||||
*/
|
||||
private static function format( $string ) {
|
||||
$counter = 0;
|
||||
|
||||
// tokenize inline code snippets
|
||||
preg_match_all('/`[^`]+`/', $string, $tokenized);
|
||||
$tokenized = $tokenized[0];
|
||||
foreach ($tokenized as $snippet) {
|
||||
$string = str_replace($snippet, '__token' . ($counter++) .'__', $string);
|
||||
}
|
||||
|
||||
// italicize parentheses
|
||||
$string = preg_replace('/(^|\s)(\([^)]+\))/', '$1*$2*', $string);
|
||||
|
||||
// mark numbers as inline code
|
||||
$string = preg_replace('/[\t ](-?\d+(?:.\d+)?)(?!\.[^\n])/', ' `$1`', $string);
|
||||
|
||||
// detokenize inline code snippets
|
||||
$counter = 0;
|
||||
foreach ($tokenized as $snippet) {
|
||||
$string = str_replace('__token' . ($counter++) . '__', $snippet, $string);
|
||||
}
|
||||
|
||||
return trim($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a string by replacing named tokens with matching assoc. array values.
|
||||
*
|
||||
* @private
|
||||
* @static
|
||||
* @memberOf MarkdownGenerator
|
||||
* @param {string} $string The string to modify.
|
||||
* @param {Array|Object} $object The template object.
|
||||
* @returns {string} The modified string.
|
||||
*/
|
||||
private static function interpolate( $string, $object ) {
|
||||
preg_match_all('/#\{([^}]+)\}/', $string, $tokens);
|
||||
$tokens = array_unique(array_pop($tokens));
|
||||
|
||||
foreach ($tokens as $token) {
|
||||
$pattern = '/#\{' . preg_replace('/([.*+?^${}()|[\]\\\])/', '\\\$1', $token) . '\}/';
|
||||
$replacement = '';
|
||||
|
||||
if (is_object($object)) {
|
||||
preg_match('/\(([^)]+?)\)$/', $token, $args);
|
||||
$args = preg_split('/,\s*/', array_pop($args));
|
||||
$method = 'get' . ucfirst(preg_replace('/\([^)]+?\)$/', '', $token));
|
||||
|
||||
if (method_exists($object, $method)) {
|
||||
$replacement = (string) call_user_func_array(array($object, $method), $args);
|
||||
} else if (isset($object->{$token})) {
|
||||
$replacement = (string) $object->{$token};
|
||||
}
|
||||
} else if (isset($object[$token])) {
|
||||
$replacement = (string) $object[$token];
|
||||
}
|
||||
$string = preg_replace($pattern, trim($replacement), $string);
|
||||
}
|
||||
return MarkdownGenerator::format($string);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Adds the given `$entries` to the `$result` array.
|
||||
*
|
||||
* @private
|
||||
* @memberOf MarkdownGenerator
|
||||
* @param {Array} $result The result array to modify.
|
||||
* @param {Array} $entries The entries to add to the `$result`.
|
||||
*/
|
||||
private function addEntries( &$result, $entries ) {
|
||||
foreach ($entries as $entry) {
|
||||
// skip aliases
|
||||
if ($entry->isAlias()) {
|
||||
continue;
|
||||
}
|
||||
// name and description
|
||||
array_push(
|
||||
$result,
|
||||
$this->openTag,
|
||||
MarkdownGenerator::interpolate("### <a id=\"#{hash}\"></a>`#{member}#{separator}#{call}`\n<a href=\"##{hash}\">#</a> [Ⓢ](#{href} \"View in source\") [Ⓣ][1]\n\n#{desc}", array(
|
||||
'call' => $entry->getCall(),
|
||||
'desc' => $this->escape($entry->getDesc()),
|
||||
'hash' => $entry->hash,
|
||||
'href' => $entry->href,
|
||||
'member' => $entry->member,
|
||||
'separator' => $entry->separator
|
||||
))
|
||||
);
|
||||
|
||||
// @alias
|
||||
if (count($aliases = $entry->getAliases())) {
|
||||
array_push($result, '', '#### Aliases');
|
||||
foreach ($aliases as $index => $alias) {
|
||||
$aliases[$index] = MarkdownGenerator::interpolate('#{member}#{separator}#{name}', $alias);
|
||||
}
|
||||
$result[] = '*' . implode(', ', $aliases) . '*';
|
||||
}
|
||||
// @param
|
||||
if (count($params = $entry->getParams())) {
|
||||
array_push($result, '', '#### Arguments');
|
||||
foreach ($params as $index => $param) {
|
||||
$result[] = MarkdownGenerator::interpolate('#{num}. `#{name}` (#{type}): #{desc}', array(
|
||||
'desc' => $this->escape($param[2]),
|
||||
'name' => $param[1],
|
||||
'num' => $index + 1,
|
||||
'type' => $this->escape($param[0])
|
||||
));
|
||||
}
|
||||
}
|
||||
// @returns
|
||||
if (count($returns = $entry->getReturns())) {
|
||||
array_push(
|
||||
$result, '',
|
||||
'#### Returns',
|
||||
MarkdownGenerator::interpolate('(#{type}): #{desc}', array(
|
||||
'desc' => $this->escape($returns[1]),
|
||||
'type' => $this->escape($returns[0])
|
||||
))
|
||||
);
|
||||
}
|
||||
// @example
|
||||
if ($example = $entry->getExample()) {
|
||||
array_push($result, '', '#### Example', $example);
|
||||
}
|
||||
array_push($result, "\n* * *", $this->closeTag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes special Markdown characters.
|
||||
*
|
||||
* @private
|
||||
* @memberOf Entry
|
||||
* @param {string} $string The string to escape.
|
||||
* @returns {string} Returns the escaped string.
|
||||
*/
|
||||
private function escape( $string ) {
|
||||
$string = preg_replace_callback('/`.*?\`/', array($this, 'swapSnippetsToTokens'), $string);
|
||||
$string = preg_replace('/(?<!\\\)\*/', '*', $string);
|
||||
$string = preg_replace('/(?<!\\\)\[/', '[', $string);
|
||||
$string = preg_replace('/(?<!\\\)\]/', ']', $string);
|
||||
$string = preg_replace_callback('/@@token@@/', array($this, 'swapTokensToSnippets'), $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the entry's hash used to navigate the documentation.
|
||||
*
|
||||
* @private
|
||||
* @memberOf MarkdownGenerator
|
||||
* @param {number|Object} $entry The entry object.
|
||||
* @param {string} $member The name of the member.
|
||||
* @returns {string} The url hash.
|
||||
*/
|
||||
private function getHash( $entry, $member = '' ) {
|
||||
$entry = is_numeric($entry) ? $this->entries[$entry] : $entry;
|
||||
$member = !$member ? $entry->getMembers(0) : $member;
|
||||
|
||||
$result = ($member ? $member . ($entry->isPlugin() ? 'prototype' : '') : '') . $entry->getCall();
|
||||
$result = preg_replace('/\(\[|\[\]/', '', $result);
|
||||
$result = preg_replace('/[\t =|\'"{}.()\]]/', '', $result);
|
||||
$result = preg_replace('/[\[#,]+/', '-', $result);
|
||||
return strtolower($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the entry's url for the specific line number.
|
||||
*
|
||||
* @private
|
||||
* @memberOf MarkdownGenerator
|
||||
* @param {number|Object} $entry The entry object.
|
||||
* @returns {string} The url.
|
||||
*/
|
||||
private function getLineUrl( $entry ) {
|
||||
$entry = is_numeric($entry) ? $this->entries($entry) : $entry;
|
||||
return $this->options['url'] . '#L' . $entry->getLineNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the character used to separate the entry's name from its member.
|
||||
*
|
||||
* @private
|
||||
* @memberOf MarkdownGenerator
|
||||
* @param {number|Object} $entry The entry object.
|
||||
* @returns {string} The separator.
|
||||
*/
|
||||
private function getSeparator( $entry ) {
|
||||
$entry = is_numeric($entry) ? $this->entries($entry) : $entry;
|
||||
return $entry->isPlugin() ? '.prototype.' : '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps code snippets with tokens as a `preg_replace_callback` callback
|
||||
* used by `escape`.
|
||||
*
|
||||
* @private
|
||||
* @memberOf Entry
|
||||
* @param {Array} $matches The array of regexp matches.
|
||||
* @returns {string} Returns the token.
|
||||
*/
|
||||
private function swapSnippetsToTokens( $matches ) {
|
||||
$this->snippets[] = $matches[0];
|
||||
return '@@token@@';
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps tokens with code snippets as a `preg_replace_callback` callback
|
||||
* used by `escape`.
|
||||
*
|
||||
* @private
|
||||
* @memberOf Entry
|
||||
* @returns {string} Returns the code snippet.
|
||||
*/
|
||||
private function swapTokensToSnippets() {
|
||||
return array_shift($this->snippets);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Generates Markdown from JSDoc entries.
|
||||
*
|
||||
* @memberOf MarkdownGenerator
|
||||
* @returns {string} The rendered Markdown.
|
||||
*/
|
||||
public function generate() {
|
||||
$api = array();
|
||||
$byCategory = $this->options['toc'] == 'categories';
|
||||
$categories = array();
|
||||
$closeTag = $this->closeTag;
|
||||
$compiling = false;
|
||||
$openTag = $this->openTag;
|
||||
$result = array('# ' . $this->options['title']);
|
||||
$toc = 'toc';
|
||||
|
||||
// initialize $api array
|
||||
foreach ($this->entries as $entry) {
|
||||
// skip invalid or private entries
|
||||
$name = $entry->getName();
|
||||
if (!$name || $entry->isPrivate()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$members = $entry->getMembers();
|
||||
$members = count($members) ? $members : array('');
|
||||
|
||||
foreach ($members as $member) {
|
||||
// create api category arrays
|
||||
if ($member && !isset($api[$member])) {
|
||||
// create temporary entry to be replaced later
|
||||
$api[$member] = new stdClass;
|
||||
$api[$member]->static = array();
|
||||
$api[$member]->plugin = array();
|
||||
}
|
||||
|
||||
// append entry to api member
|
||||
if (!$member || $entry->isCtor() || ($entry->getType() == 'Object' &&
|
||||
!preg_match('/[=:]\s*(?:null|undefined)\s*[,;]?$/', $entry->entry))) {
|
||||
|
||||
// assign the real entry, replacing the temporary entry if it exist
|
||||
$member = ($member ? $member . ($entry->isPlugin() ? '#' : '.') : '') . $name;
|
||||
$entry->static = @$api[$member] ? $api[$member]->static : array();
|
||||
$entry->plugin = @$api[$member] ? $api[$member]->plugin : array();
|
||||
|
||||
$api[$member] = $entry;
|
||||
foreach ($entry->getAliases() as $alias) {
|
||||
$api[$member]->static[] = $alias;
|
||||
}
|
||||
}
|
||||
else if ($entry->isStatic()) {
|
||||
$api[$member]->static[] = $entry;
|
||||
foreach ($entry->getAliases() as $alias) {
|
||||
$api[$member]->static[] = $alias;
|
||||
}
|
||||
}
|
||||
else if (!$entry->isCtor()) {
|
||||
$api[$member]->plugin[] = $entry;
|
||||
foreach ($entry->getAliases() as $alias) {
|
||||
$api[$member]->plugin[] = $alias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add properties to each entry
|
||||
foreach ($api as $entry) {
|
||||
$entry->hash = $this->getHash($entry);
|
||||
$entry->href = $this->getLineUrl($entry);
|
||||
$entry->separator = '';
|
||||
|
||||
$member = $entry->getMembers(0);
|
||||
$member = ($member ? $member . $this->getSeparator($entry) : '') . $entry->getName();
|
||||
$entry->member = preg_replace('/' . $entry->getName() . '$/', '', $member);
|
||||
|
||||
// add properties to static and plugin sub-entries
|
||||
foreach (array('static', 'plugin') as $kind) {
|
||||
foreach ($entry->{$kind} as $subentry) {
|
||||
$subentry->hash = $this->getHash($subentry);
|
||||
$subentry->href = $this->getLineUrl($subentry);
|
||||
$subentry->member = $member;
|
||||
$subentry->separator = $this->getSeparator($subentry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// custom sort for root level entries
|
||||
// TODO: see how well it handles deeper namespace traversal
|
||||
function sortCompare($a, $b) {
|
||||
$score = array( 'a' => 0, 'b' => 0);
|
||||
foreach (array( 'a' => $a, 'b' => $b) as $key => $value) {
|
||||
// capitalized properties are last
|
||||
if (preg_match('/[#.][A-Z]/', $value)) {
|
||||
$score[$key] = 0;
|
||||
}
|
||||
// lowercase prototype properties are next to last
|
||||
else if (preg_match('/#[a-z]/', $value)) {
|
||||
$score[$key] = 1;
|
||||
}
|
||||
// lowercase static properties next to first
|
||||
else if (preg_match('/\.[a-z]/', $value)) {
|
||||
$score[$key] = 2;
|
||||
}
|
||||
// root properties are first
|
||||
else if (preg_match('/^[^#.]+$/', $value)) {
|
||||
$score[$key] = 3;
|
||||
}
|
||||
}
|
||||
$score = $score['b'] - $score['a'];
|
||||
return $score ? $score : strcasecmp($a, $b);
|
||||
}
|
||||
|
||||
uksort($api, 'sortCompare');
|
||||
|
||||
// sort static and plugin sub-entries
|
||||
foreach ($api as $entry) {
|
||||
foreach (array('static', 'plugin') as $kind) {
|
||||
$sortBy = array( 'a' => array(), 'b' => array(), 'c' => array() );
|
||||
foreach ($entry->{$kind} as $subentry) {
|
||||
$name = $subentry->getName();
|
||||
// functions w/o ALL-CAPs names are last
|
||||
$sortBy['a'][] = $subentry->getType() == 'Function' && !preg_match('/^[A-Z_]+$/', $name);
|
||||
// ALL-CAPs properties first
|
||||
$sortBy['b'][] = preg_match('/^[A-Z_]+$/', $name);
|
||||
// lowercase alphanumeric sort
|
||||
$sortBy['c'][] = strtolower($name);
|
||||
}
|
||||
array_multisort($sortBy['a'], SORT_ASC, $sortBy['b'], SORT_DESC, $sortBy['c'], SORT_ASC, $entry->{$kind});
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// add categories
|
||||
foreach ($api as $entry) {
|
||||
$categories[$entry->getCategory()][] = $entry;
|
||||
foreach (array('static', 'plugin') as $kind) {
|
||||
foreach ($entry->{$kind} as $subentry) {
|
||||
$categories[$subentry->getCategory()][] = $subentry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort categories
|
||||
ksort($categories);
|
||||
|
||||
foreach(array('Methods', 'Properties') as $category) {
|
||||
if (isset($categories[$category])) {
|
||||
$entries = $categories[$category];
|
||||
unset($categories[$category]);
|
||||
$categories[$category] = $entries;
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// compile TOC
|
||||
$result[] = $openTag;
|
||||
|
||||
// compile TOC by categories
|
||||
if ($byCategory) {
|
||||
foreach ($categories as $category => $entries) {
|
||||
if ($compiling) {
|
||||
$result[] = $closeTag;
|
||||
} else {
|
||||
$compiling = true;
|
||||
}
|
||||
// assign TOC hash
|
||||
if (count($result) == 2) {
|
||||
$toc = strtolower($category);
|
||||
}
|
||||
// add category
|
||||
array_push(
|
||||
$result,
|
||||
$openTag, '## ' . (count($result) == 2 ? '<a id="' . $toc . '"></a>' : '') . '`' . $category . '`'
|
||||
);
|
||||
// add entries
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry->isAlias()) {
|
||||
$result[] = MarkdownGenerator::interpolate('* <a href="##{hash}" class="alias">`#{member}#{separator}#{name}` -> `#{realName}`</a>', array(
|
||||
'hash' => $entry->hash,
|
||||
'member' => $entry->member,
|
||||
'name' => $entry->getName(),
|
||||
'realName' => $entry->owner->getName(),
|
||||
'separator' => $entry->separator
|
||||
));
|
||||
}
|
||||
else {
|
||||
$result[] = MarkdownGenerator::interpolate('* <a href="##{hash}">`#{member}#{separator}#{name}`</a>', $entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// compile TOC by namespace
|
||||
else {
|
||||
foreach ($api as $entry) {
|
||||
if ($compiling) {
|
||||
$result[] = $closeTag;
|
||||
} else {
|
||||
$compiling = true;
|
||||
}
|
||||
$member = $entry->member . $entry->getName();
|
||||
|
||||
// assign TOC hash
|
||||
if (count($result) == 2) {
|
||||
$toc = $member;
|
||||
}
|
||||
// add root entry
|
||||
array_push(
|
||||
$result,
|
||||
$openTag, '## ' . (count($result) == 2 ? '<a id="' . $toc . '"></a>' : '') . '`' . $member . '`',
|
||||
MarkdownGenerator::interpolate('* [`' . $member . '`](##{hash})', $entry)
|
||||
);
|
||||
|
||||
// add static and plugin sub-entries
|
||||
foreach (array('static', 'plugin') as $kind) {
|
||||
if ($kind == 'plugin' && count($entry->plugin)) {
|
||||
array_push(
|
||||
$result,
|
||||
$closeTag,
|
||||
$openTag,
|
||||
'## `' . $member . ($entry->isCtor() ? '.prototype`' : '`')
|
||||
);
|
||||
}
|
||||
foreach ($entry->{$kind} as $subentry) {
|
||||
$subentry->member = $member;
|
||||
if ($subentry->isAlias()) {
|
||||
$result[] = MarkdownGenerator::interpolate('* <a href="##{hash}" class="alias">`#{member}#{separator}#{name}` -> `#{realName}`</a>', array(
|
||||
'hash' => $subentry->hash,
|
||||
'member' => $subentry->member,
|
||||
'name' => $subentry->getName(),
|
||||
'realName' => $subentry->owner->getName(),
|
||||
'separator' => $subentry->separator
|
||||
));
|
||||
}
|
||||
else {
|
||||
$result[] = MarkdownGenerator::interpolate('* <a href="##{hash}">`#{member}#{separator}#{name}`</a>', $subentry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
array_push($result, $closeTag, $closeTag);
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// compile content
|
||||
$compiling = false;
|
||||
$result[] = $openTag;
|
||||
|
||||
if ($byCategory) {
|
||||
foreach ($categories as $category => $entries) {
|
||||
if ($compiling) {
|
||||
$result[] = $closeTag;
|
||||
} else {
|
||||
$compiling = true;
|
||||
}
|
||||
if ($category != 'Methods' && $category != 'Properties') {
|
||||
$category = '“' . $category . '” Methods';
|
||||
}
|
||||
array_push($result, $openTag, '## `' . $category . '`');
|
||||
$this->addEntries($result, $entries);
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($api as $entry) {
|
||||
// skip aliases
|
||||
if ($entry->isAlias()) {
|
||||
continue;
|
||||
}
|
||||
if ($compiling) {
|
||||
$result[] = $closeTag;
|
||||
} else {
|
||||
$compiling = true;
|
||||
}
|
||||
// add root entry name
|
||||
$member = $entry->member . $entry->getName();
|
||||
array_push($result, $openTag, '## `' . $member . '`');
|
||||
|
||||
foreach (array($entry, 'static', 'plugin') as $kind) {
|
||||
$subentries = is_string($kind) ? $entry->{$kind} : array($kind);
|
||||
|
||||
// add sub-entry name
|
||||
if ($kind != 'static' && $entry->getType() != 'Object' &&
|
||||
count($subentries) && $subentries[0] != $kind) {
|
||||
if ($kind == 'plugin') {
|
||||
$result[] = $closeTag;
|
||||
}
|
||||
array_push(
|
||||
$result,
|
||||
$openTag,
|
||||
'## `' . $member . ($kind == 'plugin' ? '.prototype`' : '`')
|
||||
);
|
||||
}
|
||||
$this->addEntries($result, $subentries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// close tags add TOC link reference
|
||||
array_push($result, $closeTag, $closeTag, '', ' [1]: #' . $toc . ' "Jump back to the TOC."');
|
||||
|
||||
// cleanup whitespace
|
||||
return trim(preg_replace('/[\t ]+\n/', "\n", join($result, "\n")));
|
||||
}
|
||||
}
|
||||
?>
|
||||
195
vendor/dojo/LICENSE
vendored
Normal file
195
vendor/dojo/LICENSE
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
Dojo is available under *either* the terms of the modified BSD license *or* the
|
||||
Academic Free License version 2.1. As a recipient of Dojo, you may choose which
|
||||
license to receive this code under (except as noted in per-module LICENSE
|
||||
files). Some modules may not be the copyright of the Dojo Foundation. These
|
||||
modules contain explicit declarations of copyright in both the LICENSE files in
|
||||
the directories in which they reside and in the code itself. No external
|
||||
contributions are allowed under licenses which are fundamentally incompatible
|
||||
with the AFL or BSD licenses that Dojo is distributed under.
|
||||
|
||||
The text of the AFL and BSD licenses is reproduced below.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The "New" BSD License:
|
||||
**********************
|
||||
|
||||
Copyright (c) 2005-2013, The Dojo Foundation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of the Dojo Foundation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The Academic Free License, v. 2.1:
|
||||
**********************************
|
||||
|
||||
This Academic Free License (the "License") applies to any original work of
|
||||
authorship (the "Original Work") whose owner (the "Licensor") has placed the
|
||||
following notice immediately following the copyright notice for the Original
|
||||
Work:
|
||||
|
||||
Licensed under the Academic Free License version 2.1
|
||||
|
||||
1) Grant of Copyright License. Licensor hereby grants You a world-wide,
|
||||
royalty-free, non-exclusive, perpetual, sublicenseable license to do the
|
||||
following:
|
||||
|
||||
a) to reproduce the Original Work in copies;
|
||||
|
||||
b) to prepare derivative works ("Derivative Works") based upon the Original
|
||||
Work;
|
||||
|
||||
c) to distribute copies of the Original Work and Derivative Works to the
|
||||
public;
|
||||
|
||||
d) to perform the Original Work publicly; and
|
||||
|
||||
e) to display the Original Work publicly.
|
||||
|
||||
2) Grant of Patent License. Licensor hereby grants You a world-wide,
|
||||
royalty-free, non-exclusive, perpetual, sublicenseable license, under patent
|
||||
claims owned or controlled by the Licensor that are embodied in the Original
|
||||
Work as furnished by the Licensor, to make, use, sell and offer for sale the
|
||||
Original Work and Derivative Works.
|
||||
|
||||
3) Grant of Source Code License. The term "Source Code" means the preferred
|
||||
form of the Original Work for making modifications to it and all available
|
||||
documentation describing how to modify the Original Work. Licensor hereby
|
||||
agrees to provide a machine-readable copy of the Source Code of the Original
|
||||
Work along with each copy of the Original Work that Licensor distributes.
|
||||
Licensor reserves the right to satisfy this obligation by placing a
|
||||
machine-readable copy of the Source Code in an information repository
|
||||
reasonably calculated to permit inexpensive and convenient access by You for as
|
||||
long as Licensor continues to distribute the Original Work, and by publishing
|
||||
the address of that information repository in a notice immediately following
|
||||
the copyright notice that applies to the Original Work.
|
||||
|
||||
4) Exclusions From License Grant. Neither the names of Licensor, nor the names
|
||||
of any contributors to the Original Work, nor any of their trademarks or
|
||||
service marks, may be used to endorse or promote products derived from this
|
||||
Original Work without express prior written permission of the Licensor. Nothing
|
||||
in this License shall be deemed to grant any rights to trademarks, copyrights,
|
||||
patents, trade secrets or any other intellectual property of Licensor except as
|
||||
expressly stated herein. No patent license is granted to make, use, sell or
|
||||
offer to sell embodiments of any patent claims other than the licensed claims
|
||||
defined in Section 2. No right is granted to the trademarks of Licensor even if
|
||||
such marks are included in the Original Work. Nothing in this License shall be
|
||||
interpreted to prohibit Licensor from licensing under different terms from this
|
||||
License any Original Work that Licensor otherwise would have a right to
|
||||
license.
|
||||
|
||||
5) This section intentionally omitted.
|
||||
|
||||
6) Attribution Rights. You must retain, in the Source Code of any Derivative
|
||||
Works that You create, all copyright, patent or trademark notices from the
|
||||
Source Code of the Original Work, as well as any notices of licensing and any
|
||||
descriptive text identified therein as an "Attribution Notice." You must cause
|
||||
the Source Code for any Derivative Works that You create to carry a prominent
|
||||
Attribution Notice reasonably calculated to inform recipients that You have
|
||||
modified the Original Work.
|
||||
|
||||
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that
|
||||
the copyright in and to the Original Work and the patent rights granted herein
|
||||
by Licensor are owned by the Licensor or are sublicensed to You under the terms
|
||||
of this License with the permission of the contributor(s) of those copyrights
|
||||
and patent rights. Except as expressly stated in the immediately proceeding
|
||||
sentence, the Original Work is provided under this License on an "AS IS" BASIS
|
||||
and WITHOUT WARRANTY, either express or implied, including, without limitation,
|
||||
the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU.
|
||||
This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No
|
||||
license to Original Work is granted hereunder except under this disclaimer.
|
||||
|
||||
8) Limitation of Liability. Under no circumstances and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise, shall the
|
||||
Licensor be liable to any person for any direct, indirect, special, incidental,
|
||||
or consequential damages of any character arising as a result of this License
|
||||
or the use of the Original Work including, without limitation, damages for loss
|
||||
of goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses. This limitation of liability shall not
|
||||
apply to liability for death or personal injury resulting from Licensor's
|
||||
negligence to the extent applicable law prohibits such limitation. Some
|
||||
jurisdictions do not allow the exclusion or limitation of incidental or
|
||||
consequential damages, so this exclusion and limitation may not apply to You.
|
||||
|
||||
9) Acceptance and Termination. If You distribute copies of the Original Work or
|
||||
a Derivative Work, You must make a reasonable effort under the circumstances to
|
||||
obtain the express assent of recipients to the terms of this License. Nothing
|
||||
else but this License (or another written agreement between Licensor and You)
|
||||
grants You permission to create Derivative Works based upon the Original Work
|
||||
or to exercise any of the rights granted in Section 1 herein, and any attempt
|
||||
to do so except under the terms of this License (or another written agreement
|
||||
between Licensor and You) is expressly prohibited by U.S. copyright law, the
|
||||
equivalent laws of other countries, and by international treaty. Therefore, by
|
||||
exercising any of the rights granted to You in Section 1 herein, You indicate
|
||||
Your acceptance of this License and all of its terms and conditions.
|
||||
|
||||
10) Termination for Patent Action. This License shall terminate automatically
|
||||
and You may no longer exercise any of the rights granted to You by this License
|
||||
as of the date You commence an action, including a cross-claim or counterclaim,
|
||||
against Licensor or any licensee alleging that the Original Work infringes a
|
||||
patent. This termination provision shall not apply for an action alleging
|
||||
patent infringement by combinations of the Original Work with other software or
|
||||
hardware.
|
||||
|
||||
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this
|
||||
License may be brought only in the courts of a jurisdiction wherein the
|
||||
Licensor resides or in which Licensor conducts its primary business, and under
|
||||
the laws of that jurisdiction excluding its conflict-of-law provisions. The
|
||||
application of the United Nations Convention on Contracts for the International
|
||||
Sale of Goods is expressly excluded. Any use of the Original Work outside the
|
||||
scope of this License or after its termination shall be subject to the
|
||||
requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101 et
|
||||
seq., the equivalent laws of other countries, and international treaty. This
|
||||
section shall survive the termination of this License.
|
||||
|
||||
12) Attorneys Fees. In any action to enforce the terms of this License or
|
||||
seeking damages relating thereto, the prevailing party shall be entitled to
|
||||
recover its costs and expenses, including, without limitation, reasonable
|
||||
attorneys' fees and costs incurred in connection with such action, including
|
||||
any appeal of such action. This section shall survive the termination of this
|
||||
License.
|
||||
|
||||
13) Miscellaneous. This License represents the complete agreement concerning
|
||||
the subject matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent necessary to
|
||||
make it enforceable.
|
||||
|
||||
14) Definition of "You" in This License. "You" throughout this License, whether
|
||||
in upper or lower case, means an individual or a legal entity exercising rights
|
||||
under, and complying with all of the terms of, this License. For legal
|
||||
entities, "You" includes any entity that controls, is controlled by, or is
|
||||
under common control with you. For purposes of this definition, "control" means
|
||||
(i) the power, direct or indirect, to cause the direction or management of such
|
||||
entity, whether by contract or otherwise, or (ii) ownership of fifty percent
|
||||
(50%) or more of the outstanding shares, or (iii) beneficial ownership of such
|
||||
entity.
|
||||
|
||||
15) Right to Use. You may use the Original Work in all ways not otherwise
|
||||
restricted or conditioned by this License or by law, and Licensor promises not
|
||||
to interfere with or be responsible for such uses by You.
|
||||
|
||||
This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights reserved.
|
||||
Permission is hereby granted to copy and distribute this license without
|
||||
modification. This license may not be modified without the express written
|
||||
permission of its copyright owner.
|
||||
1997
vendor/dojo/dojo.js
vendored
Normal file
1997
vendor/dojo/dojo.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
vendor/jquery/MIT-LICENSE.txt
vendored
Normal file
21
vendor/jquery/MIT-LICENSE.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
Copyright 2012 jQuery Foundation and other contributors
|
||||
http://jquery.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
9440
vendor/jquery/jquery.js
vendored
Normal file
9440
vendor/jquery/jquery.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
27
vendor/json-js/json2.js
vendored
27
vendor/json-js/json2.js
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
json2.js
|
||||
2014-02-04
|
||||
2013-05-26
|
||||
|
||||
Public Domain.
|
||||
|
||||
@@ -192,11 +192,19 @@ if (typeof JSON !== 'object') {
|
||||
};
|
||||
}
|
||||
|
||||
var cx,
|
||||
escapable,
|
||||
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
gap,
|
||||
indent,
|
||||
meta,
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
},
|
||||
rep;
|
||||
|
||||
|
||||
@@ -348,16 +356,6 @@ if (typeof JSON !== 'object') {
|
||||
// If the JSON object does not yet have a stringify method, give it one.
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
};
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
@@ -405,7 +403,6 @@ if (typeof JSON !== 'object') {
|
||||
// If the JSON object does not yet have a parse method, give it one.
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
||||
JSON.parse = function (text, reviver) {
|
||||
|
||||
// The parse method takes a text and an optional reviver function, and returns
|
||||
|
||||
20
vendor/platform.js/LICENSE.txt
vendored
Normal file
20
vendor/platform.js/LICENSE.txt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright 2011-2013 John-David Dalton <http://allyoucanleet.com/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
1007
vendor/platform.js/platform.js
vendored
Normal file
1007
vendor/platform.js/platform.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
20
vendor/qunit-extras/LICENSE.txt
vendored
Normal file
20
vendor/qunit-extras/LICENSE.txt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright 2011-2013 John-David Dalton <http://allyoucanleet.com/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
570
vendor/qunit-extras/qunit-extras.js
vendored
Normal file
570
vendor/qunit-extras/qunit-extras.js
vendored
Normal file
@@ -0,0 +1,570 @@
|
||||
/*!
|
||||
* QUnit Extras v1.0.0
|
||||
* Copyright 2011-2012 John-David Dalton <http://allyoucanleet.com/>
|
||||
* Based on a gist by Jörn Zaefferer <https://gist.github.com/722381>
|
||||
* Available under MIT license <http://mths.be/mit>
|
||||
*/
|
||||
;(function(root, undefined) {
|
||||
'use strict';
|
||||
|
||||
/** Native method shortcut */
|
||||
var unshift = Array.prototype.unshift;
|
||||
|
||||
/** Used to match HTML entities */
|
||||
var reEscapedHtml = /(&|<|>|"|')/g;
|
||||
|
||||
/** Used to match parts of the assert message */
|
||||
var reDied = /^Died on test #\d+/,
|
||||
reExpected = /Expected: *<\/th><td><pre>([\s\S]*?)<\/pre>/,
|
||||
reMessage = /^<span class='test-message'>([\s\S]*?)<\/span>/;
|
||||
|
||||
/** Used to convert HTML entities to characters */
|
||||
var htmlUnescapes = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'"
|
||||
};
|
||||
|
||||
/** Used as a horizontal rule in console output */
|
||||
var hr = '----------------------------------------';
|
||||
|
||||
/** Detect free variable `exports` */
|
||||
var freeExports = typeof exports == 'object' && exports;
|
||||
|
||||
/** Detect free variable `global`, from Node.js or Browserified code, and use it as `root` */
|
||||
var freeGlobal = typeof global == 'object' && global;
|
||||
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Checks if a given value is present in an array using strict equality
|
||||
* for comparisons, i.e. `===`.
|
||||
*
|
||||
* @oruvate
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {*} target The value to check for.
|
||||
* @returns {boolean} Returns `true` if the `target` element is found, else `false`.
|
||||
*/
|
||||
function contains(array, value) {
|
||||
var index = -1,
|
||||
length = array ? array.length : 0;
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a string with `text` repeated `n` number of times.
|
||||
*
|
||||
* @private
|
||||
* @param {string} text The text to repeat.
|
||||
* @param {number} n The number of times to repeat `text`.
|
||||
* @returns {string} The created string.
|
||||
*/
|
||||
function repeat(text, n) {
|
||||
return Array(n + 1).join(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the value of `property` on `object`. If `object` is falsey then
|
||||
* `undefined` is returned.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to inspect.
|
||||
* @param {string} property The property to get the value of.
|
||||
* @returns {*} Returns the resolved value.
|
||||
*/
|
||||
function result(object, property) {
|
||||
return object ? object[property] : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the HTML entities `&`, `<`, `>`, `"`, and `'`
|
||||
* in `string` to their corresponding characters.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to unescape.
|
||||
* @returns {string} Returns the unescaped string.
|
||||
*/
|
||||
function unescape(string) {
|
||||
return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by `unescape` to convert HTML entities to characters.
|
||||
*
|
||||
* @private
|
||||
* @param {string} match The matched character to unescape.
|
||||
* @returns {string} Returns the unescaped character.
|
||||
*/
|
||||
function unescapeHtmlChar(match) {
|
||||
return htmlUnescapes[match];
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Installs the QUnit additions on the given `context` object.
|
||||
*
|
||||
* @memberOf exports
|
||||
* @param {Object} context The context object.
|
||||
*/
|
||||
function runInContext(context) {
|
||||
// exit early if no `context` is provided or if `QUnit` does not exist
|
||||
if (!context || !context.QUnit) {
|
||||
return;
|
||||
}
|
||||
|
||||
/** Used to report the test module for failing tests */
|
||||
var moduleName,
|
||||
modulePrinted;
|
||||
|
||||
/** Object shortcuts */
|
||||
var console = context.console,
|
||||
phantom = context.phantom,
|
||||
process = phantom || context.process,
|
||||
document = !phantom && context.document;
|
||||
|
||||
/** Detects if running in a PhantomJS web page */
|
||||
var isPhantomPage = typeof context.callPhantom == 'function';
|
||||
|
||||
/** Used to display the wait throbber */
|
||||
var throbberId,
|
||||
throbberDelay = 500,
|
||||
waitCount = -1;
|
||||
|
||||
/** Shorten `context.QUnit.QUnit` to `context.QUnit` */
|
||||
var QUnit = context.QUnit = context.QUnit.QUnit || context.QUnit;
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Schedules timer-based callbacks.
|
||||
*
|
||||
* @private
|
||||
* @param {Function|string} fn The function to call.
|
||||
* @param {number} delay The number of milliseconds to delay the `fn` call.
|
||||
* @param [arg1, arg2, ...] Arguments to invoke `fn` with.
|
||||
* @param {boolean} repeated A flag to specify whether `fn` is called repeatedly.
|
||||
* @returns {number} The the ID of the timeout.
|
||||
*/
|
||||
function schedule(fn, delay, args, repeated) {
|
||||
// Rhino 1.7RC4 will error assigning `task` below
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=775566
|
||||
var task = ids[++counter] = new JavaAdapter(java.util.TimerTask, {
|
||||
'run': function() {
|
||||
fn.apply(context, args);
|
||||
}
|
||||
});
|
||||
// support non-functions
|
||||
if (typeof fn != 'function') {
|
||||
fn = (function(code) {
|
||||
code = String(code);
|
||||
return function() { eval(code); };
|
||||
}(fn));
|
||||
}
|
||||
// used by setInterval
|
||||
if (repeated) {
|
||||
timer.schedule(task, delay, delay);
|
||||
}
|
||||
// used by setTimeout
|
||||
else {
|
||||
timer.schedule(task, delay);
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the delay set by `setInterval` or `setTimeout`.
|
||||
*
|
||||
* @memberOf context
|
||||
* @param {number} id The ID of the timeout to be cleared.
|
||||
*/
|
||||
function clearTimer(id) {
|
||||
if (ids[id]) {
|
||||
ids[id].cancel();
|
||||
timer.purge();
|
||||
delete ids[id];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a code snippet or function repeatedly, with a delay between each call.
|
||||
*
|
||||
* @memberOf context
|
||||
* @param {Function|string} fn The function to call or string to evaluate.
|
||||
* @param {number} delay The number of milliseconds to delay each `fn` call.
|
||||
* @param [arg1, arg2, ...] Arguments to invoke `fn` with.
|
||||
* @returns {number} The the ID of the timeout.
|
||||
*/
|
||||
function setInterval(fn, delay) {
|
||||
return schedule(fn, delay, slice.call(arguments, 2), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a code snippet or a function after specified delay.
|
||||
*
|
||||
* @memberOf context
|
||||
* @param {Function|string} fn The function to call or string to evaluate.
|
||||
* @param {number} delay The number of milliseconds to delay the `fn` call.
|
||||
* @param [arg1, arg2, ...] Arguments to invoke `fn` with.
|
||||
* @returns {number} The the ID of the timeout.
|
||||
*/
|
||||
function setTimeout(fn, delay) {
|
||||
return schedule(fn, delay, slice.call(arguments, 2));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Writes an inline message to standard output.
|
||||
*
|
||||
* @private
|
||||
* @param {string} text The text to log.
|
||||
*/
|
||||
var logInline = (function() {
|
||||
// exit early if not Node.js
|
||||
if (!(typeof process == 'object' && process &&
|
||||
process.on && process.stdout && process.platform != 'win32')) {
|
||||
return function() {};
|
||||
}
|
||||
// cleanup any inline logs when exited via `ctrl+c`
|
||||
process.on('SIGINT', function() {
|
||||
logInline('');
|
||||
process.exit();
|
||||
});
|
||||
|
||||
var prevLine = '';
|
||||
return function(text) {
|
||||
var blankLine = repeat(' ', prevLine.length);
|
||||
if (text.length > hr.length) {
|
||||
text = text.slice(0, hr.length - 3) + '...';
|
||||
}
|
||||
prevLine = text;
|
||||
process.stdout.write(text + blankLine.slice(text.length) + '\r');
|
||||
}
|
||||
}());
|
||||
|
||||
/**
|
||||
* Writes the wait throbber to standard output.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function logThrobber() {
|
||||
logInline('Please wait' + repeat('.', (++waitCount % 3) + 1));
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The number of retries async tests have to succeed.
|
||||
*
|
||||
* @memberOf QUnit.config
|
||||
* @type number
|
||||
*/
|
||||
QUnit.config.asyncRetries = 0;
|
||||
|
||||
/**
|
||||
* An object of excused tests and assertions.
|
||||
*
|
||||
* @memberOf QUnit.config
|
||||
* @type Object
|
||||
*/
|
||||
QUnit.config.excused = {};
|
||||
|
||||
/**
|
||||
* An object used to hold information about the current running test.
|
||||
*
|
||||
* @memberOf QUnit.config
|
||||
* @type Object
|
||||
*/
|
||||
QUnit.config.testStats = {
|
||||
|
||||
/**
|
||||
* An array of test summaries.
|
||||
*
|
||||
* @memberOf QUnit.config.testStats
|
||||
* @type Array
|
||||
*/
|
||||
'assertions': []
|
||||
};
|
||||
|
||||
/**
|
||||
* A callback triggered at the start of every test.
|
||||
*
|
||||
* @memberOf QUnit
|
||||
* @param {Object} details An object with `module` and `name` properties.
|
||||
*/
|
||||
QUnit.testStart(function(details) {
|
||||
var excused = QUnit.config.excused || {},
|
||||
excusedTests = excused[details.module],
|
||||
excusedAsserts = excusedTests && excusedTests[details.name];
|
||||
|
||||
var test = QUnit.config.current,
|
||||
finish = test.finish;
|
||||
|
||||
// allow async tests to retry
|
||||
if (test.async && !test.retries) {
|
||||
test.retries = 0;
|
||||
test.finish = function() {
|
||||
var asserts = this.assertions,
|
||||
index = -1,
|
||||
length = asserts.length,
|
||||
queue = QUnit.config.queue;
|
||||
|
||||
while (++index < length) {
|
||||
var assert = asserts[index];
|
||||
if (!assert.result && this.retries < QUnit.config.asyncRetries) {
|
||||
this.retries++;
|
||||
asserts.length = 0;
|
||||
|
||||
var oldLength = queue.length;
|
||||
this.queue();
|
||||
unshift.apply(queue, queue.splice(oldLength, queue.length - oldLength));
|
||||
return;
|
||||
}
|
||||
}
|
||||
finish.call(this);
|
||||
};
|
||||
}
|
||||
// nothing to excuse
|
||||
if (!excusedAsserts) {
|
||||
return;
|
||||
}
|
||||
// excuse the entire test
|
||||
if (excusedAsserts === true) {
|
||||
test.async = false;
|
||||
test.callback = function() {};
|
||||
test.expected = 0;
|
||||
return;
|
||||
}
|
||||
// excuse specific assertions
|
||||
test.finish = function() {
|
||||
var asserts = this.assertions,
|
||||
index = -1,
|
||||
length = asserts.length;
|
||||
|
||||
while (++index < length) {
|
||||
var assert = asserts[index],
|
||||
message = unescape(result(reMessage.exec(assert.message), 1)),
|
||||
died = result(reDied.exec(message), 0),
|
||||
expected = unescape(result(reExpected.exec(assert.message), 1));
|
||||
|
||||
if ((message && contains(excusedAsserts, message)) ||
|
||||
(died && contains(excusedAsserts, died)) ||
|
||||
(expected && (
|
||||
contains(excusedAsserts, expected) ||
|
||||
contains(excusedAsserts, expected.replace(/\s+/g, ''))
|
||||
))) {
|
||||
assert.result = true;
|
||||
}
|
||||
}
|
||||
finish.call(this);
|
||||
};
|
||||
});
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// add logging extras
|
||||
if (isPhantomPage || !document) {
|
||||
|
||||
/**
|
||||
* A logging callback triggered when all testing is completed.
|
||||
*
|
||||
* @memberOf QUnit
|
||||
* @param {Object} details An object with properties `failed`, `passed`, `runtime`, and `total`.
|
||||
*/
|
||||
QUnit.done(function() {
|
||||
var ran;
|
||||
return function(details) {
|
||||
// stop `asyncTest()` from erroneously calling `done()` twice in
|
||||
// environments w/o timeouts
|
||||
if (ran) {
|
||||
return;
|
||||
}
|
||||
ran = true;
|
||||
|
||||
logInline('');
|
||||
console.log(hr);
|
||||
console.log(' PASS: ' + details.passed + ' FAIL: ' + details.failed + ' TOTAL: ' + details.total);
|
||||
console.log(' Finished in ' + details.runtime + ' milliseconds.');
|
||||
console.log(hr);
|
||||
|
||||
// exit out of Node.js or PhantomJS
|
||||
try {
|
||||
if (details.failed) {
|
||||
process.exit(1);
|
||||
} else {
|
||||
process.exit(0);
|
||||
}
|
||||
} catch(e) { }
|
||||
|
||||
// exit out of Narwhal, Rhino, or RingoJS
|
||||
try {
|
||||
if (details.failed) {
|
||||
java.lang.System.exit(1);
|
||||
} else {
|
||||
quit();
|
||||
}
|
||||
} catch(e) { }
|
||||
};
|
||||
}());
|
||||
|
||||
/**
|
||||
* A logging callback triggered after every assertion.
|
||||
*
|
||||
* @memberOf QUnit
|
||||
* @param {Object} details An object with properties `actual`, `expected`, `message`, and `result`.
|
||||
*/
|
||||
QUnit.log(function(details) {
|
||||
var expected = details.expected,
|
||||
result = details.result,
|
||||
type = typeof expected != 'undefined' ? 'EQ' : 'OK';
|
||||
|
||||
var assertion = [
|
||||
result ? 'PASS' : 'FAIL',
|
||||
type,
|
||||
details.message || 'ok'
|
||||
];
|
||||
|
||||
if (!result && type == 'EQ') {
|
||||
assertion.push('Expected: ' + expected + ', Actual: ' + details.actual);
|
||||
}
|
||||
QUnit.config.testStats.assertions.push(assertion.join(' | '));
|
||||
});
|
||||
|
||||
/**
|
||||
* A logging callback triggered at the start of every test module.
|
||||
*
|
||||
* @memberOf QUnit
|
||||
* @param {Object} details An object with property `name`.
|
||||
*/
|
||||
QUnit.moduleStart(function(details) {
|
||||
// reset the `modulePrinted` flag
|
||||
var newModuleName = details.name;
|
||||
if (moduleName != newModuleName) {
|
||||
moduleName = newModuleName;
|
||||
modulePrinted = false;
|
||||
}
|
||||
// initialize the wait throbber
|
||||
if (!throbberId) {
|
||||
throbberId = context.setInterval(logThrobber, throbberDelay);
|
||||
logThrobber();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* A logging callback triggered after a test is completed.
|
||||
*
|
||||
* @memberOf QUnit
|
||||
* @param {Object} details An object with properties `failed`, `name`, `passed`, and `total`.
|
||||
*/
|
||||
QUnit.testDone(function(details) {
|
||||
var assertions = QUnit.config.testStats.assertions,
|
||||
testName = details.name;
|
||||
|
||||
if (details.failed > 0) {
|
||||
logInline('');
|
||||
if (!modulePrinted) {
|
||||
modulePrinted = true;
|
||||
console.log(hr);
|
||||
console.log(moduleName);
|
||||
console.log(hr);
|
||||
}
|
||||
console.log(' FAIL - '+ testName);
|
||||
assertions.forEach(function(value) {
|
||||
console.log(' ' + value);
|
||||
});
|
||||
}
|
||||
assertions.length = 0;
|
||||
});
|
||||
|
||||
/**
|
||||
* Converts an object into a string representation.
|
||||
*
|
||||
* @memberOf QUnit
|
||||
* @type Function
|
||||
* @param {Object} object The object to stringify.
|
||||
* @returns {string} The result string.
|
||||
*/
|
||||
QUnit.jsDump.parsers.object = (function() {
|
||||
var func = QUnit.jsDump.parsers.object;
|
||||
return function(object) {
|
||||
// fork to support Rhino's error objects
|
||||
if (typeof object.rhinoException == 'object') {
|
||||
return object.name +
|
||||
' { message: "' + object.message +
|
||||
'", fileName: "' + object.fileName +
|
||||
'", lineNumber: ' + object.lineNumber + ' }';
|
||||
}
|
||||
return func(object);
|
||||
};
|
||||
}());
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// add CLI extras
|
||||
if (!document) {
|
||||
// Timeout fallbacks based on the work of Andrea Giammarchi and Weston C.
|
||||
// https://github.com/WebReflection/wru/blob/master/src/rhinoTimers.js
|
||||
// http://stackoverflow.com/questions/2261705/how-to-run-a-javascript-function-asynchronously-without-using-settimeout
|
||||
try {
|
||||
var counter = 0,
|
||||
ids = {},
|
||||
slice = Array.prototype.slice,
|
||||
timer = new java.util.Timer;
|
||||
|
||||
(function() {
|
||||
var getDescriptor = Object.getOwnPropertyDescriptor || function() {
|
||||
return { 'writable': true };
|
||||
};
|
||||
|
||||
var descriptor;
|
||||
if ((!context.clearInterval || ((descriptor = getDescriptor(context, 'clearInterval')) && (descriptor.writable || descriptor.set))) &&
|
||||
(!context.setInterval || ((descriptor = getDescriptor(context, 'setInterval')) && (descriptor.writable || descriptor.set)))) {
|
||||
context.clearInterval = clearTimer;
|
||||
context.setInterval = setInterval;
|
||||
}
|
||||
if ((!context.clearTimeout || ((descriptor = getDescriptor(context, 'clearTimeout')) && (descriptor.writable || descriptor.set))) &&
|
||||
(!context.setTimeout || ((descriptor = getDescriptor(context, 'setTimeout')) && (descriptor.writable || descriptor.set)))) {
|
||||
context.clearTimeout = clearTimer;
|
||||
context.setTimeout = setTimeout;
|
||||
}
|
||||
}());
|
||||
} catch(e) { }
|
||||
|
||||
// add `console.log` support to Narwhal, Rhino, and RingoJS
|
||||
console || (console = context.console = { 'log': context.print });
|
||||
|
||||
// expose shortcuts
|
||||
// exclude `module` because some environments have it as a built-in object
|
||||
('asyncTest deepEqual equal equals expect notDeepEqual notEqual notStrictEqual ' +
|
||||
'ok raises same start stop strictEqual test throws').replace(/\S+/g, function(methodName) {
|
||||
context[methodName] = QUnit[methodName];
|
||||
});
|
||||
|
||||
// must call `QUnit.start` in the test file if not loaded in a browser
|
||||
QUnit.config.autostart = false;
|
||||
QUnit.init();
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// expose QUnit extras
|
||||
if (freeExports && !freeExports.nodeType) {
|
||||
freeExports.runInContext = runInContext;
|
||||
} else {
|
||||
runInContext(root);
|
||||
}
|
||||
}(this));
|
||||
21
vendor/qunit/MIT-LICENSE.txt
vendored
Normal file
21
vendor/qunit/MIT-LICENSE.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
Copyright 2013 jQuery Foundation and other contributors
|
||||
http://jquery.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
244
vendor/qunit/qunit/qunit.css
vendored
Normal file
244
vendor/qunit/qunit/qunit.css
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
/**
|
||||
* QUnit v1.11.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;
|
||||
}
|
||||
2152
vendor/qunit/qunit/qunit.js
vendored
Normal file
2152
vendor/qunit/qunit/qunit.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
58
vendor/requirejs/LICENSE
vendored
Normal file
58
vendor/requirejs/LICENSE
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
RequireJS is released under two licenses: new BSD, and MIT. You may pick the
|
||||
license that best suits your development needs. The text of both licenses are
|
||||
provided below.
|
||||
|
||||
|
||||
The "New" BSD License:
|
||||
----------------------
|
||||
|
||||
Copyright (c) 2010-2011, The Dojo Foundation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of the Dojo Foundation nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
|
||||
MIT License
|
||||
-----------
|
||||
|
||||
Copyright (c) 2010-2011, The Dojo Foundation
|
||||
|
||||
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.
|
||||
2054
vendor/requirejs/require.js
vendored
Normal file
2054
vendor/requirejs/require.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
vendor/underscore/LICENSE
vendored
2
vendor/underscore/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative
|
||||
Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative
|
||||
Reporters & Editors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
|
||||
519
vendor/underscore/test/arrays.js
vendored
519
vendor/underscore/test/arrays.js
vendored
@@ -1,307 +1,179 @@
|
||||
(function() {
|
||||
var _ = typeof require == 'function' ? require('..') : window._;
|
||||
$(document).ready(function() {
|
||||
|
||||
QUnit.module('Arrays');
|
||||
module("Arrays");
|
||||
|
||||
test('first', function() {
|
||||
equal(_.first([1, 2, 3]), 1, 'can pull out the first element of an array');
|
||||
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(_.first([1,2,3], 0).join(', '), "", 'can pass an index to first');
|
||||
equal(_.first([1,2,3], 2).join(', '), '1, 2', 'can pass an index to first');
|
||||
equal(_.first([1,2,3], 5).join(', '), '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]);
|
||||
result = _.map([[1,2,3],[1,2,3]], _.first);
|
||||
equal(result.join(','), '1,1', 'works well with _.map');
|
||||
result = (function() { return _.take([1,2,3], 2); })();
|
||||
equal(result.join(','), '1,2', 'aliased as take');
|
||||
|
||||
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() {
|
||||
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');
|
||||
equal(_.rest(numbers).join(", "), "2, 3, 4", 'working rest()');
|
||||
equal(_.rest(numbers, 0).join(", "), "1, 2, 3, 4", 'working rest(0)');
|
||||
equal(_.rest(numbers, 2).join(', '), '3, 4', 'rest can take an index');
|
||||
var result = (function(){ return _(arguments).tail(); })(1, 2, 3, 4);
|
||||
equal(result.join(', '), '2, 3, 4', 'aliased as tail and works on arguments object');
|
||||
result = _.map([[1,2,3],[1,2,3]], _.rest);
|
||||
equal(_.flatten(result).join(','), '2,3,2,3', 'works well with _.map');
|
||||
result = (function(){ return _(arguments).drop(); })(1, 2, 3, 4);
|
||||
equal(result.join(', '), '2, 3, 4', 'aliased as drop and works on arguments object');
|
||||
});
|
||||
|
||||
test('tail', function() {
|
||||
strictEqual(_.rest, _.tail, 'alias for rest');
|
||||
test("initial", function() {
|
||||
equal(_.initial([1,2,3,4,5]).join(", "), "1, 2, 3, 4", 'working initial()');
|
||||
equal(_.initial([1,2,3,4],2).join(", "), "1, 2", 'initial can take an index');
|
||||
var result = (function(){ return _(arguments).initial(); })(1, 2, 3, 4);
|
||||
equal(result.join(", "), "1, 2, 3", 'initial works on arguments object');
|
||||
result = _.map([[1,2,3],[1,2,3]], _.initial);
|
||||
equal(_.flatten(result).join(','), '1,2,1,2', 'initial works with _.map');
|
||||
});
|
||||
|
||||
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));
|
||||
test("last", function() {
|
||||
equal(_.last([1,2,3]), 3, 'can pull out the last element of an array');
|
||||
equal(_.last([1,2,3], 0).join(', '), "", 'can pass an index to last');
|
||||
equal(_.last([1,2,3], 2).join(', '), '2, 3', 'can pass an index to last');
|
||||
equal(_.last([1,2,3], 5).join(', '), '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');
|
||||
result = _.map([[1,2,3],[1,2,3]], _.last);
|
||||
equal(result.join(','), '3,3', 'works well with _.map');
|
||||
|
||||
equal(_.last(null), undefined, 'handles nulls');
|
||||
strictEqual(_.last([1, 2, 3], -1).length, 0);
|
||||
});
|
||||
|
||||
test('compact', function() {
|
||||
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));
|
||||
var result = (function(){ return _.compact(arguments).length; })(0, 1, false, 2, false, 3);
|
||||
equal(result, 3, 'works on an arguments object');
|
||||
});
|
||||
|
||||
test('flatten', function() {
|
||||
deepEqual(_.flatten(null), [], 'Flattens supports null');
|
||||
deepEqual(_.flatten(void 0), [], 'Flattens supports undefined');
|
||||
|
||||
deepEqual(_.flatten([[], [[]], []]), [], 'Flattens empty arrays');
|
||||
deepEqual(_.flatten([[], [[]], []], true), [[]], 'Flattens empty arrays');
|
||||
|
||||
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');
|
||||
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');
|
||||
|
||||
equal(_.flatten([_.range(10), _.range(10), 5, 1, 3], true).length, 23);
|
||||
equal(_.flatten([_.range(10), _.range(10), 5, 1, 3]).length, 23);
|
||||
equal(_.flatten([new Array(1000000), _.range(56000), 5, 1, 3]).length, 1056003, 'Flatten can handle massive collections');
|
||||
equal(_.flatten([new Array(1000000), _.range(56000), 5, 1, 3], true).length, 1056003, 'Flatten can handle massive collections');
|
||||
});
|
||||
|
||||
test('without', function() {
|
||||
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');
|
||||
equal(_.without(list, 0, 1).join(', '), '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);
|
||||
equal(result.join(', '), '2, 3, 4', 'works on an arguments object');
|
||||
|
||||
list = [{one : 1}, {two : 2}];
|
||||
equal(_.without(list, {one : 1}).length, 2, 'uses real object identity for comparisons.');
|
||||
equal(_.without(list, list[0]).length, 1, 'ditto.');
|
||||
ok(_.without(list, {one : 1}).length == 2, 'uses real object identity for comparisons.');
|
||||
ok(_.without(list, list[0]).length == 1, 'ditto.');
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
var values = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647];
|
||||
var array = Array(Math.pow(2, 32) - 1);
|
||||
var length = values.length;
|
||||
while (length--) {
|
||||
array[values[length]] = values[length];
|
||||
}
|
||||
equal(_.sortedIndex(array, 2147483648), 2147483648, 'should work with large indexes');
|
||||
});
|
||||
|
||||
test('uniq', function() {
|
||||
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');
|
||||
equal(_.uniq(list).join(', '), '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');
|
||||
equal(_.uniq(list, true).join(', '), '1, 2, 3', 'can find the unique values of a sorted array faster');
|
||||
|
||||
list = [{name: 'moe'}, {name: 'curly'}, {name: 'larry'}, {name: 'curly'}];
|
||||
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');
|
||||
equal(_.map(_.uniq(list, false, iterator), iterator).join(', '), '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');
|
||||
equal(_.map(_.uniq(list, iterator), iterator).join(', '), '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; };
|
||||
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');
|
||||
equal(_.uniq(list, true, iterator).join(', '), '1, 2, 3, 4', 'iterator works with sorted array');
|
||||
|
||||
var kittens = [
|
||||
{kitten: 'Celery', cuteness: 8},
|
||||
{kitten: 'Juniper', cuteness: 10},
|
||||
{kitten: 'Spottis', cuteness: 10}
|
||||
];
|
||||
|
||||
var expected = [
|
||||
{kitten: 'Celery', cuteness: 8},
|
||||
{kitten: 'Juniper', cuteness: 10}
|
||||
];
|
||||
|
||||
deepEqual(_.uniq(kittens, true, 'cuteness'), expected, 'string 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');
|
||||
|
||||
var a = {}, b = {}, c = {};
|
||||
deepEqual(_.uniq([a, b, a, b, c]), [a, b, c], 'works on values that can be tested for equivalency but not ordered');
|
||||
|
||||
deepEqual(_.uniq(null), []);
|
||||
|
||||
var context = {};
|
||||
list = [3];
|
||||
_.uniq(list, function(value, index, array) {
|
||||
strictEqual(this, context);
|
||||
strictEqual(value, 3);
|
||||
strictEqual(index, 0);
|
||||
strictEqual(array, list);
|
||||
}, context);
|
||||
|
||||
deepEqual(_.uniq([{a: 1, b: 1}, {a: 1, b: 2}, {a: 1, b: 3}, {a: 2, b: 1}], 'a'), [{a: 1, b: 1}, {a: 2, b: 1}], 'can use pluck like iterator');
|
||||
deepEqual(_.uniq([{0: 1, b: 1}, {0: 1, b: 2}, {0: 1, b: 3}, {0: 2, b: 1}], 0), [{0: 1, b: 1}, {0: 2, b: 1}], 'can use falsey pluck like iterator');
|
||||
var result = (function(){ return _.uniq(arguments); })(1, 2, 1, 3, 1, 4);
|
||||
equal(result.join(', '), '1, 2, 3, 4', 'works on an arguments object');
|
||||
});
|
||||
|
||||
test('unique', function() {
|
||||
strictEqual(_.uniq, _.unique, 'alias for uniq');
|
||||
});
|
||||
|
||||
test('intersection', function() {
|
||||
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');
|
||||
equal(_.intersection(stooges, leaders).join(''), 'moe', 'can take the set intersection of two arrays');
|
||||
equal(_(stooges).intersection(leaders).join(''), 'moe', 'can perform an OO-style intersection');
|
||||
var result = (function(){ return _.intersection(arguments, leaders); })('moe', 'curly', 'larry');
|
||||
equal(result.join(''), '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');
|
||||
equal(_.intersection(theSixStooges, leaders).join(''), 'moe', 'returns a duplicate-free array');
|
||||
});
|
||||
|
||||
test('union', function() {
|
||||
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');
|
||||
equal(result.join(' '), '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');
|
||||
equal(result.join(' '), '1 2 3 30 40 1', 'takes the union of a list of nested arrays');
|
||||
|
||||
var args = null;
|
||||
(function(){ args = arguments; }(1, 2, 3));
|
||||
(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');
|
||||
equal(result.join(' '), '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');
|
||||
result = _.union(null, [1, 2, 3]);
|
||||
deepEqual(result, [null, 1, 2, 3]);
|
||||
});
|
||||
|
||||
test('difference', function() {
|
||||
test("difference", function() {
|
||||
var result = _.difference([1, 2, 3], [2, 30, 40]);
|
||||
deepEqual(result, [1, 3], 'takes the difference of two arrays');
|
||||
equal(result.join(' '), '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');
|
||||
equal(result.join(' '), '3 4', 'takes the difference of three arrays');
|
||||
});
|
||||
|
||||
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(names, ages, leaders);
|
||||
equal(String(stooges), 'moe,30,true,larry,40,,curly,50,', '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');
|
||||
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');
|
||||
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('unzip', function() {
|
||||
deepEqual(_.unzip(null), [], 'handles null');
|
||||
|
||||
deepEqual(_.unzip([['a', 'b'], [1, 2]]), [['a', 1], ['b', 2]]);
|
||||
|
||||
// complements zip
|
||||
var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);
|
||||
deepEqual(_.unzip(zipped), [['fred', 'barney'], [30, 40], [true, false]]);
|
||||
|
||||
zipped = _.zip(['moe', 30], ['larry', 40], ['curly', 50, 'extra data']);
|
||||
deepEqual(_.unzip(zipped), [['moe', 30, void 0], ['larry', 40, void 0], ['curly', 50, 'extra data']], 'Uses length of largest array');
|
||||
});
|
||||
|
||||
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');
|
||||
ok(_.isEqual(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');
|
||||
ok(_.isEqual(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');
|
||||
ok(_.isEqual(_.object(_.pairs(stooges)), stooges), 'an object converted to pairs and back to an object');
|
||||
|
||||
deepEqual(_.object(null), {}, 'handles nulls');
|
||||
ok(_.isEqual(_.object(null), {}), 'handles nulls');
|
||||
});
|
||||
|
||||
test('indexOf', function() {
|
||||
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));
|
||||
numbers.indexOf = null;
|
||||
equal(_.indexOf(numbers, 2), 1, 'can compute indexOf, even without the native function');
|
||||
var result = (function(){ return _.indexOf(arguments, 2); })(1, 2, 3);
|
||||
equal(result, 1, 'works on an arguments object');
|
||||
|
||||
_.each([null, void 0, [], false], function(val) {
|
||||
var msg = 'Handles: ' + (_.isArray(val) ? '[]' : val);
|
||||
equal(_.indexOf(val, 2), -1, msg);
|
||||
equal(_.indexOf(val, 2, -1), -1, msg);
|
||||
equal(_.indexOf(val, 2, -20), -1, msg);
|
||||
equal(_.indexOf(val, 2, 15), -1, msg);
|
||||
});
|
||||
equal(_.indexOf(null, 2), -1, 'handles nulls properly');
|
||||
|
||||
var num = 35;
|
||||
numbers = [10, 20, 30, 40, 50];
|
||||
@@ -313,219 +185,40 @@
|
||||
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');
|
||||
index = _.indexOf(numbers, num, true);
|
||||
equal(index, 1, '40 is in the list');
|
||||
|
||||
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);
|
||||
|
||||
index = _.indexOf([], undefined, true);
|
||||
equal(index, -1, 'empty array with truthy `isSorted` returns -1');
|
||||
});
|
||||
|
||||
test('indexOf with NaN', function() {
|
||||
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN), 2, 'Expected [1, 2, NaN] to contain NaN');
|
||||
strictEqual(_.indexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
|
||||
|
||||
(function() {
|
||||
strictEqual(_.indexOf(arguments, NaN), 2, 'Expected arguments [1, 2, NaN] to contain NaN');
|
||||
}(1, 2, NaN, NaN));
|
||||
});
|
||||
|
||||
test('indexOf with +- 0', function() {
|
||||
_.each([-0, +0], function(val) {
|
||||
strictEqual(_.indexOf([1, 2, val, val], val), 2);
|
||||
strictEqual(_.indexOf([1, 2, val, val], -val), 2);
|
||||
});
|
||||
});
|
||||
|
||||
test('lastIndexOf', function() {
|
||||
test("lastIndexOf", function() {
|
||||
var numbers = [1, 0, 1];
|
||||
var falsey = [void 0, '', 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));
|
||||
var result = (function(){ return _.lastIndexOf(arguments, 1); })(1, 0, 1, 0, 0, 1, 0, 0, 0);
|
||||
equal(result, 5, 'works on an arguments object');
|
||||
|
||||
_.each([null, void 0, [], false], function(val) {
|
||||
var msg = 'Handles: ' + (_.isArray(val) ? '[]' : val);
|
||||
equal(_.lastIndexOf(val, 2), -1, msg);
|
||||
equal(_.lastIndexOf(val, 2, -1), -1, msg);
|
||||
equal(_.lastIndexOf(val, 2, -20), -1, msg);
|
||||
equal(_.lastIndexOf(val, 2, 15), -1, msg);
|
||||
});
|
||||
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('lastIndexOf with NaN', function() {
|
||||
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN), 3, 'Expected [1, 2, NaN] to contain NaN');
|
||||
strictEqual(_.lastIndexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
|
||||
|
||||
(function() {
|
||||
strictEqual(_.lastIndexOf(arguments, NaN), 3, 'Expected arguments [1, 2, NaN] to contain NaN');
|
||||
}(1, 2, NaN, NaN));
|
||||
test("range", function() {
|
||||
equal(_.range(0).join(''), '', 'range with 0 as a first argument generates an empty array');
|
||||
equal(_.range(4).join(' '), '0 1 2 3', 'range with a single positive argument generates an array of elements 0,1,2,...,n-1');
|
||||
equal(_.range(5, 8).join(' '), '5 6 7', 'range with two arguments a & b, a<b generates an array of elements a,a+1,a+2,...,b-2,b-1');
|
||||
equal(_.range(8, 5).join(''), '', 'range with two arguments a & b, b<a generates an empty array');
|
||||
equal(_.range(3, 10, 3).join(' '), '3 6 9', 'range with three arguments a & b & c, c < b-a, a < b generates an array of elements a,a+c,a+2c,...,b - (multiplier of a) < c');
|
||||
equal(_.range(3, 10, 15).join(''), '3', 'range with three arguments a & b & c, c > b-a, a < b generates an array with a single element, equal to a');
|
||||
equal(_.range(12, 7, -2).join(' '), '12 10 8', 'range with three arguments a & b & c, a > b, c < 0 generates an array of elements a,a-c,a-2c and ends with the number not less than b');
|
||||
equal(_.range(0, -10, -1).join(' '), '0 -1 -2 -3 -4 -5 -6 -7 -8 -9', 'final example in the Python docs');
|
||||
});
|
||||
|
||||
test('lastIndexOf with +- 0', function() {
|
||||
_.each([-0, +0], function(val) {
|
||||
strictEqual(_.lastIndexOf([1, 2, val, val], val), 3);
|
||||
strictEqual(_.lastIndexOf([1, 2, val, val], -val), 3);
|
||||
strictEqual(_.lastIndexOf([-1, 1, 2], -val), -1);
|
||||
});
|
||||
});
|
||||
|
||||
test('findIndex', function() {
|
||||
var objects = [
|
||||
{'a': 0, 'b': 0},
|
||||
{'a': 1, 'b': 1},
|
||||
{'a': 2, 'b': 2},
|
||||
{'a': 0, 'b': 0}
|
||||
];
|
||||
|
||||
equal(_.findIndex(objects, function(obj) {
|
||||
return obj.a === 0;
|
||||
}), 0);
|
||||
|
||||
equal(_.findIndex(objects, function(obj) {
|
||||
return obj.b * obj.a === 4;
|
||||
}), 2);
|
||||
|
||||
equal(_.findIndex(objects, 'a'), 1, 'Uses lookupIterator');
|
||||
|
||||
equal(_.findIndex(objects, function(obj) {
|
||||
return obj.b * obj.a === 5;
|
||||
}), -1);
|
||||
|
||||
equal(_.findIndex(null, _.noop), -1);
|
||||
strictEqual(_.findIndex(objects, function(a) {
|
||||
return a.foo === null;
|
||||
}), -1);
|
||||
_.findIndex([{a: 1}], function(a, key, obj) {
|
||||
equal(key, 0);
|
||||
deepEqual(obj, [{a: 1}]);
|
||||
strictEqual(this, objects, 'called with context');
|
||||
}, objects);
|
||||
|
||||
var sparse = [];
|
||||
sparse[20] = {'a': 2, 'b': 2};
|
||||
equal(_.findIndex(sparse, function(obj) {
|
||||
return obj && obj.b * obj.a === 4;
|
||||
}), 20, 'Works with sparse arrays');
|
||||
|
||||
var array = [1, 2, 3, 4];
|
||||
array.match = 55;
|
||||
strictEqual(_.findIndex(array, function(x) { return x === 55; }), -1, 'doesn\'t match array-likes keys');
|
||||
});
|
||||
|
||||
test('findLastIndex', function() {
|
||||
var objects = [
|
||||
{'a': 0, 'b': 0},
|
||||
{'a': 1, 'b': 1},
|
||||
{'a': 2, 'b': 2},
|
||||
{'a': 0, 'b': 0}
|
||||
];
|
||||
|
||||
equal(_.findLastIndex(objects, function(obj) {
|
||||
return obj.a === 0;
|
||||
}), 3);
|
||||
|
||||
equal(_.findLastIndex(objects, function(obj) {
|
||||
return obj.b * obj.a === 4;
|
||||
}), 2);
|
||||
|
||||
equal(_.findLastIndex(objects, 'a'), 2, 'Uses lookupIterator');
|
||||
|
||||
equal(_.findLastIndex(objects, function(obj) {
|
||||
return obj.b * obj.a === 5;
|
||||
}), -1);
|
||||
|
||||
equal(_.findLastIndex(null, _.noop), -1);
|
||||
strictEqual(_.findLastIndex(objects, function(a) {
|
||||
return a.foo === null;
|
||||
}), -1);
|
||||
_.findLastIndex([{a: 1}], function(a, key, obj) {
|
||||
equal(key, 0);
|
||||
deepEqual(obj, [{a: 1}]);
|
||||
strictEqual(this, objects, 'called with context');
|
||||
}, objects);
|
||||
|
||||
var sparse = [];
|
||||
sparse[20] = {'a': 2, 'b': 2};
|
||||
equal(_.findLastIndex(sparse, function(obj) {
|
||||
return obj && obj.b * obj.a === 4;
|
||||
}), 20, 'Works with sparse arrays');
|
||||
|
||||
var array = [1, 2, 3, 4];
|
||||
array.match = 55;
|
||||
strictEqual(_.findLastIndex(array, function(x) { return x === 55; }), -1, 'doesn\'t match array-likes keys');
|
||||
});
|
||||
|
||||
test('range', function() {
|
||||
deepEqual(_.range(0), [], 'range with 0 as a first argument generates an empty array');
|
||||
deepEqual(_.range(4), [0, 1, 2, 3], 'range with a single positive argument generates an array of elements 0,1,2,...,n-1');
|
||||
deepEqual(_.range(5, 8), [5, 6, 7], 'range with two arguments a & b, a<b generates an array of elements a,a+1,a+2,...,b-2,b-1');
|
||||
deepEqual(_.range(8, 5), [], 'range with two arguments a & b, b<a generates an empty array');
|
||||
deepEqual(_.range(3, 10, 3), [3, 6, 9], 'range with three arguments a & b & c, c < b-a, a < b generates an array of elements a,a+c,a+2c,...,b - (multiplier of a) < c');
|
||||
deepEqual(_.range(3, 10, 15), [3], 'range with three arguments a & b & c, c > b-a, a < b generates an array with a single element, equal to a');
|
||||
deepEqual(_.range(12, 7, -2), [12, 10, 8], 'range with three arguments a & b & c, a > b, c < 0 generates an array of elements a,a-c,a-2c and ends with the number not less than b');
|
||||
deepEqual(_.range(0, -10, -1), [0, -1, -2, -3, -4, -5, -6, -7, -8, -9], 'final example in the Python docs');
|
||||
});
|
||||
|
||||
}());
|
||||
});
|
||||
|
||||
71
vendor/underscore/test/chaining.js
vendored
71
vendor/underscore/test/chaining.js
vendored
@@ -1,14 +1,13 @@
|
||||
(function() {
|
||||
var _ = typeof require == 'function' ? require('..') : window._;
|
||||
$(document).ready(function() {
|
||||
|
||||
QUnit.module('Chaining');
|
||||
module("Chaining");
|
||||
|
||||
test('map/flatten/reduce', function() {
|
||||
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'
|
||||
"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(''); })
|
||||
@@ -18,12 +17,11 @@
|
||||
hash[l]++;
|
||||
return hash;
|
||||
}, {}).value();
|
||||
equal(counts.a, 16, 'counted all the letters in the song');
|
||||
equal(counts.e, 10, 'counted all the letters in the song');
|
||||
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];
|
||||
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) {
|
||||
@@ -31,11 +29,11 @@
|
||||
}).sortBy(function(n) {
|
||||
return -n;
|
||||
}).value();
|
||||
deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers');
|
||||
equal(numbers.join(', '), "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];
|
||||
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) {
|
||||
@@ -43,11 +41,11 @@
|
||||
}).sortBy(function(n) {
|
||||
return -n;
|
||||
}).value();
|
||||
deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers');
|
||||
equal(numbers.join(', '), "10, 6, 2", "filtered and reversed the numbers");
|
||||
});
|
||||
|
||||
test('reverse/concat/unshift/pop/map', function() {
|
||||
var numbers = [1, 2, 3, 4, 5];
|
||||
test("reverse/concat/unshift/pop/map", function() {
|
||||
var numbers = [1,2,3,4,5];
|
||||
numbers = _(numbers).chain()
|
||||
.reverse()
|
||||
.concat([5, 5, 5])
|
||||
@@ -55,44 +53,13 @@
|
||||
.pop()
|
||||
.map(function(n){ return n * 2; })
|
||||
.value();
|
||||
deepEqual(numbers, [34, 10, 8, 6, 4, 2, 10, 10], 'can chain together array functions.');
|
||||
equal(numbers.join(', '), "34, 10, 8, 6, 4, 2, 10, 10", 'can chain together array functions.');
|
||||
});
|
||||
|
||||
test('splice', function() {
|
||||
var instance = _([1, 2, 3, 4, 5]).chain();
|
||||
deepEqual(instance.splice(1, 3).value(), [1, 5]);
|
||||
deepEqual(instance.splice(1, 0).value(), [1, 5]);
|
||||
deepEqual(instance.splice(1, 1).value(), [1]);
|
||||
deepEqual(instance.splice(0, 1).value(), [], '#397 Can create empty array');
|
||||
});
|
||||
|
||||
test('shift', function() {
|
||||
var instance = _([1, 2, 3]).chain();
|
||||
deepEqual(instance.shift().value(), [2, 3]);
|
||||
deepEqual(instance.shift().value(), [3]);
|
||||
deepEqual(instance.shift().value(), [], '#397 Can create empty array');
|
||||
});
|
||||
|
||||
test('pop', function() {
|
||||
var instance = _([1, 2, 3]).chain();
|
||||
deepEqual(instance.pop().value(), [1, 2]);
|
||||
deepEqual(instance.pop().value(), [1]);
|
||||
deepEqual(instance.pop().value(), [], '#397 Can create empty array');
|
||||
});
|
||||
|
||||
test('chaining works in small stages', function() {
|
||||
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]);
|
||||
});
|
||||
|
||||
test('#1562: Engine proxies for chained functions', function() {
|
||||
var wrapped = _(512);
|
||||
strictEqual(wrapped.toJSON(), 512);
|
||||
strictEqual(wrapped.valueOf(), 512);
|
||||
strictEqual(+wrapped, 512);
|
||||
strictEqual(wrapped.toString(), '512');
|
||||
strictEqual('' + wrapped, '512');
|
||||
});
|
||||
|
||||
}());
|
||||
});
|
||||
|
||||
687
vendor/underscore/test/collections.js
vendored
687
vendor/underscore/test/collections.js
vendored
@@ -1,26 +1,25 @@
|
||||
(function() {
|
||||
var _ = typeof require == 'function' ? require('..') : window._;
|
||||
$(document).ready(function() {
|
||||
|
||||
QUnit.module('Collections');
|
||||
module("Collections");
|
||||
|
||||
test('each', function() {
|
||||
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');
|
||||
equal(answers.join(', '), '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"');
|
||||
_.forEach([1, 2, 3], function(num){ answers.push(num); });
|
||||
equal(answers.join(', '), '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.');
|
||||
equal(answers.join(", "), 'one, two, three', 'iterating over objects works, and ignores the object prototype.');
|
||||
delete obj.constructor.prototype.four;
|
||||
|
||||
var answer = null;
|
||||
@@ -30,142 +29,34 @@
|
||||
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);
|
||||
});
|
||||
|
||||
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('Iterating objects with sketchy length properties', function() {
|
||||
var functions = [
|
||||
'each', 'map', 'filter', 'find',
|
||||
'some', 'every', 'max', 'min',
|
||||
'groupBy', 'countBy', 'partition', 'indexBy'
|
||||
];
|
||||
var reducers = ['reduce', 'reduceRight'];
|
||||
|
||||
var tricks = [
|
||||
{length: '5'},
|
||||
{
|
||||
length: {
|
||||
valueOf: _.constant(5)
|
||||
}
|
||||
},
|
||||
{length: Math.pow(2, 53) + 1},
|
||||
{length: Math.pow(2, 53)},
|
||||
{length: null},
|
||||
{length: -2},
|
||||
{length: new Number(15)}
|
||||
];
|
||||
|
||||
expect(tricks.length * (functions.length + reducers.length + 4));
|
||||
|
||||
_.each(tricks, function(trick) {
|
||||
var length = trick.length;
|
||||
strictEqual(_.size(trick), 1, 'size on obj with length: ' + length);
|
||||
deepEqual(_.toArray(trick), [length], 'toArray on obj with length: ' + length);
|
||||
deepEqual(_.shuffle(trick), [length], 'shuffle on obj with length: ' + length);
|
||||
deepEqual(_.sample(trick), length, 'sample on obj with length: ' + length);
|
||||
|
||||
|
||||
_.each(functions, function(method) {
|
||||
_[method](trick, function(val, key) {
|
||||
strictEqual(key, 'length', method + ': ran with length = ' + val);
|
||||
});
|
||||
});
|
||||
|
||||
_.each(reducers, function(method) {
|
||||
strictEqual(_[method](trick), trick.length, method);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('Resistant to collection length and properties changing while iterating', function() {
|
||||
|
||||
var collection = [
|
||||
'each', 'map', 'filter', 'find',
|
||||
'some', 'every', 'max', 'min', 'reject',
|
||||
'groupBy', 'countBy', 'partition', 'indexBy',
|
||||
'reduce', 'reduceRight'
|
||||
];
|
||||
var array = [
|
||||
'findIndex', 'findLastIndex'
|
||||
];
|
||||
var object = [
|
||||
'mapObject', 'findKey', 'pick', 'omit'
|
||||
];
|
||||
|
||||
_.each(collection.concat(array), function(method) {
|
||||
var sparseArray = [1, 2, 3];
|
||||
sparseArray.length = 100;
|
||||
var answers = 0;
|
||||
_[method](sparseArray, function(){
|
||||
++answers;
|
||||
return method === 'every' ? true : null;
|
||||
}, {});
|
||||
equal(answers, 100, method + ' enumerates [0, length)');
|
||||
|
||||
var growingCollection = [1, 2, 3], count = 0;
|
||||
_[method](growingCollection, function() {
|
||||
if (count < 10) growingCollection.push(count++);
|
||||
return method === 'every' ? true : null;
|
||||
}, {});
|
||||
equal(count, 3, method + ' is resistant to length changes');
|
||||
});
|
||||
|
||||
_.each(collection.concat(object), function(method) {
|
||||
var changingObject = {0: 0, 1: 1}, count = 0;
|
||||
_[method](changingObject, function(val) {
|
||||
if (count < 10) changingObject[++count] = val + 1;
|
||||
return method === 'every' ? true : null;
|
||||
}, {});
|
||||
|
||||
equal(count, 2, method + ' is resistant to property changes');
|
||||
});
|
||||
});
|
||||
|
||||
test('map', function() {
|
||||
var doubled = _.map([1, 2, 3], function(num){ return num * 2; });
|
||||
deepEqual(doubled, [2, 4, 6], 'doubled numbers');
|
||||
equal(doubled.join(', '), '2, 4, 6', 'doubled numbers');
|
||||
|
||||
doubled = _.collect([1, 2, 3], function(num){ return num * 2; });
|
||||
equal(doubled.join(', '), '2, 4, 6', 'aliased as "collect"');
|
||||
|
||||
var tripled = _.map([1, 2, 3], function(num){ return num * this.multiplier; }, {multiplier : 3});
|
||||
deepEqual(tripled, [3, 6, 9], 'tripled numbers with context');
|
||||
equal(tripled.join(', '), '3, 6, 9', 'tripled numbers with context');
|
||||
|
||||
doubled = _([1, 2, 3]).map(function(num){ return num * 2; });
|
||||
deepEqual(doubled, [2, 4, 6], 'OO-style doubled numbers');
|
||||
var doubled = _([1, 2, 3]).map(function(num){ return num * 2; });
|
||||
equal(doubled.join(', '), '2, 4, 6', 'OO-style doubled numbers');
|
||||
|
||||
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.');
|
||||
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.');
|
||||
}
|
||||
|
||||
deepEqual(_.map(null, _.noop), [], 'handles a null properly');
|
||||
var ids = _.map($('#map-test').children(), function(n){ return n.id; });
|
||||
deepEqual(ids, ['id1', 'id2'], 'Can use collection methods on jQuery Array-likes.');
|
||||
|
||||
deepEqual(_.map([1], function() {
|
||||
return this.length;
|
||||
}, [5]), [1], 'called with context');
|
||||
var ids = _.map(document.images, function(n){ return n.id; });
|
||||
ok(ids[0] == 'chart_image', 'can use collection methods on HTMLCollections');
|
||||
|
||||
// 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');
|
||||
var ifnull = _.map(null, function(){});
|
||||
ok(_.isArray(ifnull) && ifnull.length === 0, 'handles a null properly');
|
||||
});
|
||||
|
||||
test('reduce', function() {
|
||||
@@ -182,37 +73,50 @@
|
||||
sum = _([1, 2, 3]).reduce(function(sum, num){ return sum + num; }, 0);
|
||||
equal(sum, 6, 'OO-style reduce');
|
||||
|
||||
sum = _.reduce([1, 2, 3], function(sum, num){ return sum + num; });
|
||||
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');
|
||||
equal(_.reduce([_], _.noop), _, 'collection of length one with no initial value returns the first item');
|
||||
equal(_.reduce([], _.noop), undefined, 'returns undefined when collection is empty and no initial value');
|
||||
});
|
||||
var ifnull;
|
||||
try {
|
||||
_.reduce(null, function(){});
|
||||
} catch (ex) {
|
||||
ifnull = ex;
|
||||
}
|
||||
ok(ifnull instanceof TypeError, 'handles a null (without initial value) properly');
|
||||
|
||||
test('foldl', function() {
|
||||
strictEqual(_.reduce, _.foldl, 'alias for reduce');
|
||||
ok(_.reduce(null, function(){}, 138) === 138, 'handles a null (with initial value) properly');
|
||||
equal(_.reduce([], function(){}, undefined), undefined, 'undefined can be passed as a special case');
|
||||
raises(function() { _.reduce([], function(){}); }, TypeError, 'throws an error for empty arrays with no initial value');
|
||||
});
|
||||
|
||||
test('reduceRight', function() {
|
||||
var list = _.reduceRight(['foo', 'bar', 'baz'], function(memo, str){ return memo + str; }, '');
|
||||
var list = _.reduceRight(["foo", "bar", "baz"], function(memo, str){ return memo + str; }, '');
|
||||
equal(list, 'bazbarfoo', 'can perform right folds');
|
||||
|
||||
list = _.reduceRight(['foo', 'bar', 'baz'], function(memo, str){ return memo + str; });
|
||||
var list = _.foldr(["foo", "bar", "baz"], function(memo, str){ return memo + str; }, '');
|
||||
equal(list, 'bazbarfoo', 'aliased as "foldr"');
|
||||
|
||||
var list = _.foldr(["foo", "bar", "baz"], function(memo, str){ return memo + str; });
|
||||
equal(list, 'bazbarfoo', 'default initial value');
|
||||
|
||||
var ifnull;
|
||||
try {
|
||||
_.reduceRight(null, function(){});
|
||||
} catch (ex) {
|
||||
ifnull = ex;
|
||||
}
|
||||
ok(ifnull instanceof TypeError, 'handles a null (without initial value) properly');
|
||||
|
||||
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), _, 'collection of length one with no initial value returns the first item');
|
||||
ok(_.reduceRight(null, function(){}, 138) === 138, 'handles a null (with initial value) properly');
|
||||
|
||||
equal(_.reduceRight([], _.noop, undefined), undefined, 'undefined can be passed as a special case');
|
||||
equal(_.reduceRight([], _.noop), undefined, 'returns undefined when collection is empty and no initial value');
|
||||
equal(_.reduceRight([], function(){}, undefined), undefined, 'undefined can be passed as a special case');
|
||||
raises(function() { _.reduceRight([], function(){}); }, TypeError, 'throws an error for empty arrays with no initial value');
|
||||
|
||||
// Assert that the correct arguments are being passed.
|
||||
|
||||
@@ -221,12 +125,12 @@
|
||||
object = {a: 1, b: 2},
|
||||
lastKey = _.keys(object).pop();
|
||||
|
||||
var expected = lastKey === 'a'
|
||||
var expected = lastKey == 'a'
|
||||
? [memo, 1, 'a', object]
|
||||
: [memo, 2, 'b', object];
|
||||
|
||||
_.reduceRight(object, function() {
|
||||
if (!args) args = _.toArray(arguments);
|
||||
args || (args = _.toArray(arguments));
|
||||
}, memo);
|
||||
|
||||
deepEqual(args, expected);
|
||||
@@ -237,239 +141,96 @@
|
||||
lastKey = _.keys(object).pop();
|
||||
args = null;
|
||||
|
||||
expected = lastKey === '2'
|
||||
expected = lastKey == '2'
|
||||
? [memo, 'a', '2', object]
|
||||
: [memo, 'b', '1', object];
|
||||
|
||||
_.reduceRight(object, function() {
|
||||
if (!args) args = _.toArray(arguments);
|
||||
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');
|
||||
|
||||
array.dontmatch = 55;
|
||||
strictEqual(_.find(array, function(x) { return x === 55; }), void 0, 'iterates array-likes correctly');
|
||||
|
||||
// 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');
|
||||
|
||||
var obj = {
|
||||
a: {x: 1, z: 3},
|
||||
b: {x: 2, z: 2},
|
||||
c: {x: 3, z: 4},
|
||||
d: {x: 4, z: 1}
|
||||
};
|
||||
|
||||
deepEqual(_.find(obj, {x: 2}), {x: 2, z: 2}, 'works on objects');
|
||||
deepEqual(_.find(obj, {x: 2, z: 1}), void 0);
|
||||
deepEqual(_.find(obj, function(x) {
|
||||
return x.x === 4;
|
||||
}), {x: 4, z: 1});
|
||||
|
||||
_.findIndex([{a: 1}], function(a, key, obj) {
|
||||
equal(key, 0);
|
||||
deepEqual(obj, [{a: 1}]);
|
||||
strictEqual(this, _, 'called with context');
|
||||
}, _);
|
||||
});
|
||||
|
||||
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');
|
||||
var result = _.detect([1, 2, 3], function(num){ return num * 2 == 4; });
|
||||
equal(result, 2, 'found the first "2" and broke the loop');
|
||||
});
|
||||
|
||||
test('select', function() {
|
||||
strictEqual(_.filter, _.select, 'alias for filter');
|
||||
var evens = _.select([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
|
||||
equal(evens.join(', '), '2, 4, 6', 'selected each even number');
|
||||
|
||||
evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
|
||||
equal(evens.join(', '), '2, 4, 6', 'aliased as "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 odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
|
||||
equal(odds.join(', '), '1, 3, 5', 'rejected each even number');
|
||||
|
||||
var context = 'obj';
|
||||
var context = "obj";
|
||||
|
||||
var evens = _.reject([1, 2, 3, 4, 5, 6], function(num){
|
||||
equal(context, 'obj');
|
||||
return num % 2 !== 0;
|
||||
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');
|
||||
equal(evens.join(', '), '2, 4, 6', 'rejected each odd number');
|
||||
});
|
||||
|
||||
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');
|
||||
ok(_.all([], _.identity), 'the empty set');
|
||||
ok(_.all([true, true, true], _.identity), 'all true values');
|
||||
ok(!_.all([true, false, true], _.identity), 'one false value');
|
||||
ok(_.all([0, 10, 28], function(num){ return num % 2 == 0; }), 'even numbers');
|
||||
ok(!_.all([0, 11, 28], function(num){ return num % 2 == 0; }), 'an odd number');
|
||||
ok(_.all([1], _.identity) === true, 'cast to boolean - true');
|
||||
ok(_.all([0], _.identity) === false, 'cast to boolean - false');
|
||||
ok(_.every([true, true, true], _.identity), 'aliased as "every"');
|
||||
ok(!_.all([undefined, undefined, undefined], _.identity), 'works with arrays of undefined');
|
||||
});
|
||||
|
||||
test('any', function() {
|
||||
strictEqual(_.any, _.some, 'alias for any');
|
||||
});
|
||||
|
||||
test('includes', function() {
|
||||
_.each([null, void 0, 0, 1, NaN, {}, []], function(val) {
|
||||
strictEqual(_.includes(val, 'hasOwnProperty'), false);
|
||||
});
|
||||
strictEqual(_.includes([1, 2, 3], 2), true, 'two is in the array');
|
||||
ok(!_.includes([1, 3, 9], 2), 'two is not in the array');
|
||||
|
||||
strictEqual(_.includes([5, 4, 3, 2, 1], 5, true), true, 'doesn\'t delegate to binary search');
|
||||
|
||||
ok(_.includes({moe: 1, larry: 3, curly: 9}, 3) === true, '_.includes on objects checks their values');
|
||||
ok(_([1, 2, 3]).includes(2), 'OO-style includes');
|
||||
var nativeSome = Array.prototype.some;
|
||||
Array.prototype.some = null;
|
||||
ok(!_.any([]), 'the empty set');
|
||||
ok(!_.any([false, false, false]), 'all false values');
|
||||
ok(_.any([false, false, true]), 'one true value');
|
||||
ok(_.any([null, 0, 'yes', false]), 'a string');
|
||||
ok(!_.any([null, 0, '', false]), 'falsy values');
|
||||
ok(!_.any([1, 11, 29], function(num){ return num % 2 == 0; }), 'all odd numbers');
|
||||
ok(_.any([1, 10, 29], function(num){ return num % 2 == 0; }), 'an even number');
|
||||
ok(_.any([1], _.identity) === true, 'cast to boolean - true');
|
||||
ok(_.any([0], _.identity) === false, 'cast to boolean - false');
|
||||
ok(_.some([false, false, true]), 'aliased as "some"');
|
||||
Array.prototype.some = nativeSome;
|
||||
});
|
||||
|
||||
test('include', function() {
|
||||
strictEqual(_.includes, _.include, 'alias for includes');
|
||||
ok(_.include([1,2,3], 2), 'two is in the array');
|
||||
ok(!_.include([1,3,9], 2), 'two is not in the array');
|
||||
ok(_.contains({moe:1, larry:3, curly:9}, 3) === true, '_.include on objects checks their values');
|
||||
ok(_([1,2,3]).include(2), 'OO-style include');
|
||||
});
|
||||
|
||||
test('contains', function() {
|
||||
strictEqual(_.includes, _.contains, 'alias for includes');
|
||||
|
||||
var numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
|
||||
strictEqual(_.includes(numbers, 1, 1), true);
|
||||
strictEqual(_.includes(numbers, 1, -1), false);
|
||||
strictEqual(_.includes(numbers, 1, -2), false);
|
||||
strictEqual(_.includes(numbers, 1, -3), true);
|
||||
strictEqual(_.includes(numbers, 1, 6), true);
|
||||
strictEqual(_.includes(numbers, 1, 7), false);
|
||||
});
|
||||
|
||||
test('includes with NaN', function() {
|
||||
strictEqual(_.includes([1, 2, NaN, NaN], NaN), true, 'Expected [1, 2, NaN] to contain NaN');
|
||||
strictEqual(_.includes([1, 2, Infinity], NaN), false, 'Expected [1, 2, NaN] to contain NaN');
|
||||
});
|
||||
|
||||
test('includes with +- 0', function() {
|
||||
_.each([-0, +0], function(val) {
|
||||
strictEqual(_.includes([1, 2, val, val], val), true);
|
||||
strictEqual(_.includes([1, 2, val, val], -val), true);
|
||||
strictEqual(_.includes([-1, 1, 2], -val), false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('invoke', 5, function() {
|
||||
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');
|
||||
|
||||
_.invoke([{
|
||||
method: function() {
|
||||
deepEqual(_.toArray(arguments), [1, 2, 3], 'called with arguments');
|
||||
}
|
||||
}], 'method', 1, 2, 3);
|
||||
|
||||
deepEqual(_.invoke([{a: null}, {}, {a: _.constant(1)}], 'a'), [null, void 0, 1], 'handles null & undefined');
|
||||
|
||||
throws(function() {
|
||||
_.invoke([{a: 1}], 'a');
|
||||
}, TypeError, 'throws for non-functions');
|
||||
equal(result[0].join(', '), '1, 5, 7', 'first array sorted');
|
||||
equal(result[1].join(', '), '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');
|
||||
|
||||
deepEqual(_.invoke([1, 2, 3], function(a) {
|
||||
return a + this;
|
||||
}, 5), [6, 7, 8], 'receives params from invoke');
|
||||
equal(result[0].join(', '), '1, 5, 7', 'first array sorted');
|
||||
equal(result[1].join(', '), '1, 2, 3', 'second array sorted');
|
||||
});
|
||||
|
||||
// Relevant when using ClojureScript
|
||||
@@ -478,21 +239,18 @@
|
||||
return 42;
|
||||
};
|
||||
var list = [[5, 1, 7], [3, 2, 1]];
|
||||
var s = 'foo';
|
||||
equal(s.call(), 42, 'call function exists');
|
||||
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');
|
||||
equal(result[0].join(', '), '1, 5, 7', 'first array sorted');
|
||||
equal(result[1].join(', '), '1, 2, 3', 'second array sorted');
|
||||
delete String.prototype.call;
|
||||
equal(s.call, undefined, 'call function removed');
|
||||
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');
|
||||
deepEqual(_.pluck(people, 'address'), [undefined, undefined], 'missing properties are returned as undefined');
|
||||
//compat: most flexible handling of edge cases
|
||||
deepEqual(_.pluck([{'[object Object]': 1}], {}), [1]);
|
||||
var people = [{name : 'moe', age : 30}, {name : 'curly', age : 50}];
|
||||
equal(_.pluck(people, 'name').join(', '), 'moe, curly', 'pulls names out of objects');
|
||||
});
|
||||
|
||||
test('where', function() {
|
||||
@@ -503,12 +261,11 @@
|
||||
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');
|
||||
result = _.where(list, {a: 1}, true);
|
||||
equal(result.b, 2, "Only get the first object matched.")
|
||||
result = _.where(list, {a: 1}, false);
|
||||
equal(result.length, 3);
|
||||
});
|
||||
|
||||
test('findWhere', function() {
|
||||
@@ -518,29 +275,14 @@
|
||||
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(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');
|
||||
result = _.findWhere([], {c:1});
|
||||
ok(_.isUndefined(result), "undefined when searching empty list");
|
||||
});
|
||||
|
||||
test('max', function() {
|
||||
equal(-Infinity, _.max(null), 'can handle null/undefined');
|
||||
equal(-Infinity, _.max(undefined), 'can handle null/undefined');
|
||||
equal(-Infinity, _.max(null, _.identity), 'can handle null/undefined');
|
||||
|
||||
equal(3, _.max([1, 2, 3]), 'can perform a regular Math.max');
|
||||
|
||||
var neg = _.max([1, 2, 3], function(num){ return -num; });
|
||||
@@ -550,28 +292,10 @@
|
||||
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){ return a * this.x; }, {x: 1}), 2, 'Iterator context');
|
||||
deepEqual(_.max([[1], [2, 3], [-1, 4], [5]], 0), [5], 'Lookup falsy iterator');
|
||||
deepEqual(_.max([{0: 1}, {0: 2}, {0: -1}, {a: 1}], 0), {0: 2}, 'Lookup falsy iterator');
|
||||
equal(299999, _.max(_.range(1,300000)), "Maximum value of a too-big array");
|
||||
});
|
||||
|
||||
test('min', function() {
|
||||
equal(Infinity, _.min(null), 'can handle null/undefined');
|
||||
equal(Infinity, _.min(undefined), 'can handle null/undefined');
|
||||
equal(Infinity, _.min(null, _.identity), 'can handle null/undefined');
|
||||
|
||||
equal(1, _.min([1, 2, 3]), 'can perform a regular Math.min');
|
||||
|
||||
var neg = _.min([1, 2, 3], function(num){ return -num; });
|
||||
@@ -585,34 +309,20 @@
|
||||
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){ return a * this.x; }, {x: -1}), 2, 'Iterator context');
|
||||
deepEqual(_.min([[1], [2, 3], [-1, 4], [5]], 0), [-1, 4], 'Lookup falsy iterator');
|
||||
deepEqual(_.min([{0: 1}, {0: 2}, {0: -1}, {a: 1}], 0), {0: -1}, 'Lookup falsy iterator');
|
||||
equal(1, _.min(_.range(1,300000)), "Minimum value of a too-big array");
|
||||
});
|
||||
|
||||
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');
|
||||
equal(_.pluck(people, 'name').join(', '), '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');
|
||||
equal(_.sortBy(list, _.identity).join(','), '1,2,3,4,,', 'sortBy with undefined values');
|
||||
|
||||
list = ['one', 'two', 'three', 'four', 'five'];
|
||||
var list = ["one", "two", "three", "four", "five"];
|
||||
var sorted = _.sortBy(list, 'length');
|
||||
deepEqual(sorted, ['one', 'two', 'four', 'five', 'three'], 'sorted by length');
|
||||
equal(sorted.join(' '), 'one two four five three', 'sorted by length');
|
||||
|
||||
function Pair(x, y) {
|
||||
this.x = x;
|
||||
@@ -636,23 +346,18 @@
|
||||
});
|
||||
|
||||
deepEqual(actual, collection, 'sortBy should be stable');
|
||||
|
||||
deepEqual(_.sortBy(collection, 'x'), collection, 'sortBy accepts property string');
|
||||
|
||||
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');
|
||||
equal(parity[0].join(', '), '2, 4, 6', 'put each even number in the right group');
|
||||
|
||||
var list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
|
||||
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']);
|
||||
equal(grouped['3'].join(' '), 'one two six ten');
|
||||
equal(grouped['4'].join(' '), 'four five nine');
|
||||
equal(grouped['5'].join(' '), 'three seven eight');
|
||||
|
||||
var context = {};
|
||||
_.groupBy([{}], function(){ ok(this === context); }, context);
|
||||
@@ -666,44 +371,44 @@
|
||||
var array = [{}];
|
||||
_.groupBy(array, function(value, index, obj){ ok(obj === array); });
|
||||
|
||||
array = [1, 2, 1, 2, 3];
|
||||
grouped = _.groupBy(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]
|
||||
[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]]});
|
||||
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; });
|
||||
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 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];
|
||||
grouped = _.indexBy(array);
|
||||
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; });
|
||||
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 list = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
|
||||
var grouped = _.countBy(list, 'length');
|
||||
equal(grouped['3'], 4);
|
||||
equal(grouped['4'], 3);
|
||||
@@ -721,63 +426,72 @@
|
||||
var array = [{}];
|
||||
_.countBy(array, function(value, index, obj){ ok(obj === array); });
|
||||
|
||||
array = [1, 2, 1, 2, 3];
|
||||
grouped = _.countBy(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);
|
||||
var shuffled = _.shuffle(numbers).sort();
|
||||
notStrictEqual(numbers, shuffled, 'original object is unmodified');
|
||||
ok(_.every(_.range(10), function() { //appears consistent?
|
||||
return _.every(numbers, _.partial(_.contains, numbers));
|
||||
}), 'contains the same members before and after shuffle');
|
||||
|
||||
shuffled = _.shuffle({a: 1, b: 2, c: 3, d: 4});
|
||||
equal(shuffled.length, 4);
|
||||
deepEqual(shuffled.sort(), [1, 2, 3, 4], 'works on objects');
|
||||
equal(shuffled.join(','), numbers.join(','), 'contains the same members before and after shuffle');
|
||||
});
|
||||
|
||||
test('sample', function() {
|
||||
var numbers = _.range(10);
|
||||
var allSampled = _.sample(numbers, 10).sort();
|
||||
deepEqual(allSampled, numbers, 'contains the same members before and after sample');
|
||||
allSampled = _.sample(numbers, 20).sort();
|
||||
deepEqual(allSampled, numbers, 'also works when sampling more objects than are present');
|
||||
var all_sampled = _.sample(numbers, 10).sort();
|
||||
equal(all_sampled.join(','), numbers.join(','), 'contains the same members before and after sample');
|
||||
all_sampled = _.sample(numbers, 20).sort();
|
||||
equal(all_sampled.join(','), numbers.join(','), '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];
|
||||
var a = [1,2,3];
|
||||
ok(_.toArray(a) !== a, 'array is cloned');
|
||||
deepEqual(_.toArray(a), [1, 2, 3], 'cloned array contains same elements');
|
||||
equal(_.toArray(a).join(', '), '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');
|
||||
equal(numbers.join(', '), '1, 2, 3', 'object flattened into array');
|
||||
|
||||
if (typeof document != 'undefined') {
|
||||
// test in IE < 9
|
||||
var actual;
|
||||
try {
|
||||
actual = _.toArray(document.childNodes);
|
||||
} catch(ex) { }
|
||||
deepEqual(actual, _.map(document.childNodes, _.identity), 'works on NodeList');
|
||||
}
|
||||
// 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');
|
||||
equal(_.size($('<div>').add('<span>').add('<span>')), 3, 'can compute the size of jQuery objects');
|
||||
|
||||
var func = function() {
|
||||
return _.size(arguments);
|
||||
@@ -791,57 +505,4 @@
|
||||
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(obj, object);
|
||||
equal(this, predicate);
|
||||
}, predicate);
|
||||
});
|
||||
|
||||
if (typeof document != 'undefined') {
|
||||
test('Can use various collection methods on NodeLists', function() {
|
||||
var parent = document.createElement('div');
|
||||
parent.innerHTML = '<span id=id1></span>textnode<span id=id2></span>';
|
||||
|
||||
var elementChildren = _.filter(parent.childNodes, _.isElement);
|
||||
equal(elementChildren.length, 2);
|
||||
|
||||
deepEqual(_.map(elementChildren, 'id'), ['id1', 'id2']);
|
||||
deepEqual(_.map(parent.childNodes, 'nodeType'), [1, 3, 1]);
|
||||
|
||||
ok(!_.every(parent.childNodes, _.isElement));
|
||||
ok(_.some(parent.childNodes, _.isElement));
|
||||
|
||||
function compareNode(node) {
|
||||
return _.isElement(node) ? node.id.charAt(2) : void 0;
|
||||
}
|
||||
equal(_.max(parent.childNodes, compareNode), _.last(parent.childNodes));
|
||||
equal(_.min(parent.childNodes, compareNode), _.first(parent.childNodes));
|
||||
});
|
||||
}
|
||||
|
||||
}());
|
||||
});
|
||||
|
||||
374
vendor/underscore/test/functions.js
vendored
374
vendor/underscore/test/functions.js
vendored
@@ -1,12 +1,10 @@
|
||||
(function() {
|
||||
var _ = typeof require == 'function' ? require('..') : window._;
|
||||
$(document).ready(function() {
|
||||
|
||||
QUnit.module('Functions');
|
||||
QUnit.config.asyncRetries = 3;
|
||||
module("Functions");
|
||||
|
||||
test('bind', function() {
|
||||
test("bind", function() {
|
||||
var context = {name : 'moe'};
|
||||
var func = function(arg) { return 'name: ' + (this.name || arg); };
|
||||
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');
|
||||
|
||||
@@ -14,9 +12,7 @@
|
||||
equal(bound(), 'name: moe', 'can do OO-style binding');
|
||||
|
||||
bound = _.bind(func, null, 'curly');
|
||||
var result = bound();
|
||||
// Work around a PhantomJS bug when applying a function with null|undefined.
|
||||
ok(result === 'name: curly' || result === 'name: ' + window.name, 'can bind without specifying a context');
|
||||
equal(bound(), 'name: curly', 'can bind without specifying a context');
|
||||
|
||||
func = function(salutation, name) { return salutation + ': ' + name; };
|
||||
func = _.bind(func, this, 'hello');
|
||||
@@ -37,49 +33,22 @@
|
||||
// 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 Boundf = boundf; // make eslint happy.
|
||||
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');
|
||||
|
||||
throws(function() { _.bind('notafunction'); }, TypeError, 'throws an error when binding to a non-function');
|
||||
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");
|
||||
});
|
||||
|
||||
test('partial', 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');
|
||||
|
||||
// passes context
|
||||
function MyWidget(name, options) {
|
||||
this.name = name;
|
||||
this.options = options;
|
||||
}
|
||||
MyWidget.prototype.get = function() {
|
||||
return this.name;
|
||||
};
|
||||
var MyWidgetWithCoolOpts = _.partial(MyWidget, _, {a: 1});
|
||||
var widget = new MyWidgetWithCoolOpts('foo');
|
||||
ok(widget instanceof MyWidget, 'Can partially bind a constructor');
|
||||
equal(widget.get(), 'foo', 'keeps prototype');
|
||||
deepEqual(widget.options, {a: 1});
|
||||
});
|
||||
|
||||
test('bindAll', function() {
|
||||
test("bindAll", function() {
|
||||
var curly = {name : 'curly'}, moe = {
|
||||
name : 'moe',
|
||||
getName : function() { return 'name: ' + this.name; },
|
||||
@@ -95,23 +64,17 @@
|
||||
moe = {
|
||||
name : 'moe',
|
||||
getName : function() { return 'name: ' + this.name; },
|
||||
sayHi : function() { return 'hi: ' + this.name; },
|
||||
sayLast : function() { return this.sayHi(_.last(arguments)); }
|
||||
sayHi : function() { return 'hi: ' + this.name; }
|
||||
};
|
||||
|
||||
throws(function() { _.bindAll(moe); }, Error, 'throws an error for bindAll with no functions named');
|
||||
throws(function() { _.bindAll(moe, 'sayBye'); }, TypeError, 'throws an error for bindAll if the given key is undefined');
|
||||
throws(function() { _.bindAll(moe, 'name'); }, TypeError, 'throws an error for bindAll if the given key is not a function');
|
||||
raises(function() { _.bindAll(moe); }, Error, 'throws an error for bindAll with no functions named');
|
||||
|
||||
_.bindAll(moe, 'sayHi', 'sayLast');
|
||||
_.bindAll(moe, 'sayHi');
|
||||
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() {
|
||||
test("memoize", function() {
|
||||
var fib = function(n) {
|
||||
return n < 2 ? n : fib(n - 1) + fib(n - 2);
|
||||
};
|
||||
@@ -125,108 +88,75 @@
|
||||
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');
|
||||
|
||||
// Test that the hash function can be used to swizzle the key.
|
||||
var objCacher = _.memoize(function(value, key) {
|
||||
return {key: key, value: value};
|
||||
}, function(value, key) {
|
||||
return key;
|
||||
});
|
||||
var myObj = objCacher('a', 'alpha');
|
||||
var myObjAlias = objCacher('b', 'alpha');
|
||||
notStrictEqual(myObj, undefined, 'object is created if second argument used as key');
|
||||
strictEqual(myObj, myObjAlias, 'object is cached if second argument used as key');
|
||||
strictEqual(myObj.value, 'a', 'object is not modified if second argument used as key');
|
||||
});
|
||||
|
||||
asyncTest('delay', 2, function() {
|
||||
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() {
|
||||
asyncTest("defer", 1, function() {
|
||||
var deferred = false;
|
||||
_.defer(function(bool){ deferred = bool; }, true);
|
||||
_.delay(function(){ ok(deferred, 'deferred the function'); start(); }, 50);
|
||||
_.delay(function(){ ok(deferred, "deferred the function"); start(); }, 50);
|
||||
});
|
||||
|
||||
asyncTest('throttle', 2, function() {
|
||||
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);
|
||||
equal(counter, 1, "incr was called immediately");
|
||||
_.delay(function(){ equal(counter, 2, "incr was throttled"); start(); }, 64);
|
||||
});
|
||||
|
||||
asyncTest('throttle arguments', 2, function() {
|
||||
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);
|
||||
equal(value, 1, "updated to latest value");
|
||||
_.delay(function(){ equal(value, 3, "updated to latest value"); start(); }, 96);
|
||||
});
|
||||
|
||||
asyncTest('throttle once', 2, function() {
|
||||
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();
|
||||
equal(result, 1, "throttled functions return their value");
|
||||
equal(counter, 1, "incr was called once"); start();
|
||||
}, 64);
|
||||
});
|
||||
|
||||
asyncTest('throttle twice', 1, function() {
|
||||
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);
|
||||
_.delay(function(){ equal(counter, 2, "incr was called twice"); start(); }, 64);
|
||||
});
|
||||
|
||||
asyncTest('more throttling', 3, function() {
|
||||
asyncTest("more throttling", 3, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 30);
|
||||
throttledIncr(); throttledIncr();
|
||||
equal(counter, 1);
|
||||
ok(counter == 1);
|
||||
_.delay(function(){
|
||||
equal(counter, 2);
|
||||
ok(counter == 2);
|
||||
throttledIncr();
|
||||
equal(counter, 3);
|
||||
ok(counter == 3);
|
||||
start();
|
||||
}, 85);
|
||||
});
|
||||
|
||||
asyncTest('throttle repeatedly with results', 6, function() {
|
||||
asyncTest("throttle repeatedly with results", 6, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ return ++counter; };
|
||||
var throttledIncr = _.throttle(incr, 100);
|
||||
@@ -238,24 +168,24 @@
|
||||
_.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');
|
||||
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() {
|
||||
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) {
|
||||
while ((new Date - stamp) < limit) {
|
||||
throttledIncr();
|
||||
}
|
||||
var lastCount = counter;
|
||||
@@ -267,21 +197,21 @@
|
||||
}, 96);
|
||||
});
|
||||
|
||||
asyncTest('throttle does not trigger leading call when leading is set to false', 2, function() {
|
||||
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();
|
||||
equal(counter, 0);
|
||||
ok(counter === 0);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 1);
|
||||
ok(counter == 1);
|
||||
start();
|
||||
}, 96);
|
||||
});
|
||||
|
||||
asyncTest('more throttle does not trigger leading call when leading is set to false', 3, function() {
|
||||
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});
|
||||
@@ -290,19 +220,19 @@
|
||||
_.delay(throttledIncr, 50);
|
||||
_.delay(throttledIncr, 60);
|
||||
_.delay(throttledIncr, 200);
|
||||
equal(counter, 0);
|
||||
ok(counter === 0);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 1);
|
||||
ok(counter == 1);
|
||||
}, 250);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 2);
|
||||
ok(counter == 2);
|
||||
start();
|
||||
}, 350);
|
||||
});
|
||||
|
||||
asyncTest('one more throttle with leading: false test', 2, function() {
|
||||
asyncTest("one more throttle with leading: false test", 2, function() {
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 100, {leading: false});
|
||||
@@ -317,80 +247,37 @@
|
||||
}, 200);
|
||||
});
|
||||
|
||||
asyncTest('throttle does not trigger trailing call when trailing is set to false', 4, function() {
|
||||
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();
|
||||
equal(counter, 1);
|
||||
ok(counter === 1);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 1);
|
||||
ok(counter == 1);
|
||||
|
||||
throttledIncr(); throttledIncr();
|
||||
equal(counter, 2);
|
||||
ok(counter == 2);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 2);
|
||||
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();
|
||||
equal(counter, 1);
|
||||
_.now = function () {
|
||||
return new Date(2013, 0, 1, 1, 1, 1);
|
||||
};
|
||||
|
||||
_.delay(function() {
|
||||
throttledIncr();
|
||||
equal(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() {
|
||||
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);
|
||||
_.delay(function(){ equal(counter, 1, "incr was debounced"); start(); }, 96);
|
||||
});
|
||||
|
||||
asyncTest('debounce asap', 4, function() {
|
||||
asyncTest("debounce asap", 4, function() {
|
||||
var a, b;
|
||||
var counter = 0;
|
||||
var incr = function(){ return ++counter; };
|
||||
@@ -403,75 +290,29 @@
|
||||
_.delay(debouncedIncr, 16);
|
||||
_.delay(debouncedIncr, 32);
|
||||
_.delay(debouncedIncr, 48);
|
||||
_.delay(function(){ equal(counter, 1, 'incr was debounced'); start(); }, 128);
|
||||
_.delay(function(){ equal(counter, 1, "incr was debounced"); start(); }, 128);
|
||||
});
|
||||
|
||||
asyncTest('debounce asap recursively', 2, function() {
|
||||
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);
|
||||
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() {
|
||||
test("once", function() {
|
||||
var num = 0;
|
||||
var increment = _.once(function(){ return ++num; });
|
||||
var increment = _.once(function(){ num++; });
|
||||
increment();
|
||||
increment();
|
||||
equal(num, 1);
|
||||
|
||||
equal(increment(), 1, 'stores a memo to the last value');
|
||||
});
|
||||
|
||||
test('Recursive onced function.', 1, function() {
|
||||
test("Recursive onced function.", 1, function() {
|
||||
var f = _.once(function(){
|
||||
ok(true);
|
||||
f();
|
||||
@@ -479,55 +320,33 @@
|
||||
f();
|
||||
});
|
||||
|
||||
test('wrap', function() {
|
||||
var greet = function(name){ return 'hi: ' + name; };
|
||||
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'};
|
||||
var inner = function(){ return "Hello "; };
|
||||
var obj = {name : "Moe"};
|
||||
obj.hi = _.wrap(inner, function(fn){ return fn() + this.name; });
|
||||
equal(obj.hi(), 'Hello Moe');
|
||||
equal(obj.hi(), "Hello Moe");
|
||||
|
||||
var noop = function(){};
|
||||
var wrapped = _.wrap(noop, function(){ return Array.prototype.slice.call(arguments, 0); });
|
||||
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; };
|
||||
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; };
|
||||
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() {
|
||||
test("after", function() {
|
||||
var testAfter = function(afterAmount, timesCalled) {
|
||||
var afterCalled = 0;
|
||||
var after = _.after(afterAmount, function() {
|
||||
@@ -537,45 +356,10 @@
|
||||
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');
|
||||
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');
|
||||
});
|
||||
|
||||
test('iteratee', function() {
|
||||
var identity = _.iteratee();
|
||||
equal(identity, _.identity, '_.iteratee is exposed as an external function.');
|
||||
|
||||
function fn() {
|
||||
return arguments;
|
||||
}
|
||||
_.each([_.iteratee(fn), _.iteratee(fn, {})], function(cb) {
|
||||
equal(cb().length, 0);
|
||||
deepEqual(_.toArray(cb(1, 2, 3)), _.range(1, 4));
|
||||
deepEqual(_.toArray(cb(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), _.range(1, 11));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}());
|
||||
});
|
||||
|
||||
963
vendor/underscore/test/objects.js
vendored
963
vendor/underscore/test/objects.js
vendored
File diff suppressed because it is too large
Load Diff
266
vendor/underscore/test/utility.js
vendored
266
vendor/underscore/test/utility.js
vendored
@@ -1,8 +1,8 @@
|
||||
(function() {
|
||||
var _ = typeof require == 'function' ? require('..') : window._;
|
||||
$(document).ready(function() {
|
||||
|
||||
var templateSettings;
|
||||
|
||||
QUnit.module('Utility', {
|
||||
module("Utility", {
|
||||
|
||||
setup: function() {
|
||||
templateSettings = _.clone(_.templateSettings);
|
||||
@@ -14,93 +14,54 @@
|
||||
|
||||
});
|
||||
|
||||
test('#750 - Return _ instance.', 2, function() {
|
||||
test("#750 - Return _ instance.", 2, function() {
|
||||
var instance = _([]);
|
||||
ok(_(instance) === instance);
|
||||
ok(new _(instance) === instance);
|
||||
});
|
||||
|
||||
test('identity', function() {
|
||||
var stooge = {name : 'moe'};
|
||||
equal(_.identity(stooge), stooge, 'stooge is the same as his identity');
|
||||
test("identity", function() {
|
||||
var moe = {name : 'moe'};
|
||||
equal(_.identity(moe), moe, 'moe is the same as his identity');
|
||||
});
|
||||
|
||||
test('constant', function() {
|
||||
var stooge = {name : 'moe'};
|
||||
equal(_.constant(stooge)(), stooge, 'should create a function that returns stooge');
|
||||
});
|
||||
|
||||
test('noop', function() {
|
||||
strictEqual(_.noop('curly', 'larry', 'moe'), undefined, 'should always return undefined');
|
||||
});
|
||||
|
||||
test('property', function() {
|
||||
var stooge = {name : 'moe'};
|
||||
equal(_.property('name')(stooge), 'moe', 'should return the property with the given name');
|
||||
equal(_.property('name')(null), undefined, 'should return undefined for null values');
|
||||
equal(_.property('name')(undefined), undefined, 'should return undefined for undefined values');
|
||||
});
|
||||
|
||||
test('propertyOf', function() {
|
||||
var stoogeRanks = _.propertyOf({curly: 2, moe: 1, larry: 3});
|
||||
equal(stoogeRanks('curly'), 2, 'should return the property with the given name');
|
||||
equal(stoogeRanks(null), undefined, 'should return undefined for null values');
|
||||
equal(stoogeRanks(undefined), undefined, 'should return undefined for undefined values');
|
||||
|
||||
function MoreStooges() { this.shemp = 87; }
|
||||
MoreStooges.prototype = {curly: 2, moe: 1, larry: 3};
|
||||
var moreStoogeRanks = _.propertyOf(new MoreStooges());
|
||||
equal(moreStoogeRanks('curly'), 2, 'should return properties from further up the prototype chain');
|
||||
|
||||
var nullPropertyOf = _.propertyOf(null);
|
||||
equal(nullPropertyOf('curly'), undefined, 'should return undefined when obj is null');
|
||||
|
||||
var undefPropertyOf = _.propertyOf(undefined);
|
||||
equal(undefPropertyOf('curly'), undefined, 'should return undefined when obj is undefined');
|
||||
});
|
||||
|
||||
test('random', function() {
|
||||
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');
|
||||
}), "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`');
|
||||
}), "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() {
|
||||
test("uniqueId", function() {
|
||||
var ids = [], i = 0;
|
||||
while (i++ < 100) ids.push(_.uniqueId());
|
||||
while(i++ < 100) ids.push(_.uniqueId());
|
||||
equal(_.uniq(ids).length, ids.length, 'can generate a globally-unique stream of ids');
|
||||
});
|
||||
|
||||
test('times', function() {
|
||||
test("times", function() {
|
||||
var vals = [];
|
||||
_.times(3, function (i) { vals.push(i); });
|
||||
deepEqual(vals, [0, 1, 2], 'is 0 indexed');
|
||||
ok(_.isEqual(vals, [0,1,2]), "is 0 indexed");
|
||||
//
|
||||
vals = [];
|
||||
_(3).times(function(i) { vals.push(i); });
|
||||
deepEqual(vals, [0, 1, 2], 'works as a wrapper');
|
||||
ok(_.isEqual(vals, [0,1,2]), "works as a wrapper");
|
||||
// collects return values
|
||||
deepEqual([0, 1, 2], _.times(3, function(i) { return i; }), 'collects return values');
|
||||
ok(_.isEqual([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() {
|
||||
test("mixin", function() {
|
||||
_.mixin({
|
||||
myReverse: function(string) {
|
||||
return string.split('').reverse().join('');
|
||||
@@ -110,159 +71,126 @@
|
||||
equal(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OOP wrapper');
|
||||
});
|
||||
|
||||
test('_.escape', function() {
|
||||
test("_.escape", function() {
|
||||
equal(_.escape("Curly & Moe"), "Curly & Moe");
|
||||
equal(_.escape('<a href="http://moe.com">Curly & Moe\'s</a>'), '<a href="http://moe.com">Curly & Moe's</a>');
|
||||
equal(_.escape("Curly & Moe"), "Curly &amp; Moe");
|
||||
equal(_.escape(null), '');
|
||||
});
|
||||
|
||||
test('_.unescape', function() {
|
||||
var string = 'Curly & Moe';
|
||||
test("_.unescape", function() {
|
||||
var string = "Curly & Moe";
|
||||
equal(_.unescape("Curly & Moe"), string);
|
||||
equal(_.unescape('<a href="http://moe.com">Curly & Moe's</a>'), '<a href="http://moe.com">Curly & Moe\'s</a>');
|
||||
equal(_.unescape("Curly &amp; Moe"), "Curly & Moe");
|
||||
equal(_.unescape(null), '');
|
||||
equal(_.unescape(_.escape(string)), string);
|
||||
equal(_.unescape(string), string, 'don\'t unescape unnecessarily');
|
||||
});
|
||||
|
||||
// Don't care what they escape them to just that they're escaped and can be unescaped
|
||||
test('_.escape & unescape', function() {
|
||||
// test & (&) seperately obviously
|
||||
var escapeCharacters = ['<', '>', '"', '\'', '`'];
|
||||
|
||||
_.each(escapeCharacters, function(escapeChar) {
|
||||
var str = 'a ' + escapeChar + ' string escaped';
|
||||
var escaped = _.escape(str);
|
||||
notEqual(str, escaped, escapeChar + ' is escaped');
|
||||
equal(str, _.unescape(escaped), escapeChar + ' can be unescaped');
|
||||
|
||||
str = 'a ' + escapeChar + escapeChar + escapeChar + 'some more string' + escapeChar;
|
||||
escaped = _.escape(str);
|
||||
|
||||
equal(escaped.indexOf(escapeChar), -1, 'can escape multiple occurances of ' + escapeChar);
|
||||
equal(_.unescape(escaped), str, 'multiple occurrences of ' + escapeChar + ' can be unescaped');
|
||||
});
|
||||
|
||||
// handles multiple escape characters at once
|
||||
var joiner = ' other stuff ';
|
||||
var allEscaped = escapeCharacters.join(joiner);
|
||||
allEscaped += allEscaped;
|
||||
ok(_.every(escapeCharacters, function(escapeChar) {
|
||||
return allEscaped.indexOf(escapeChar) !== -1;
|
||||
}), 'handles multiple characters');
|
||||
ok(allEscaped.indexOf(joiner) >= 0, 'can escape multiple escape characters at the same time');
|
||||
|
||||
// test & -> &
|
||||
var str = 'some string & another string & yet another';
|
||||
var escaped = _.escape(str);
|
||||
|
||||
ok(escaped.indexOf('&') !== -1, 'handles & aka &');
|
||||
equal(_.unescape(str), str, 'can unescape &');
|
||||
});
|
||||
|
||||
test('template', function() {
|
||||
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 sansSemicolonTemplate = _.template("A <% this %> B");
|
||||
equal(sansSemicolonTemplate(), "A B");
|
||||
|
||||
var backslashTemplate = _.template('<%= thing %> is \\ridanculous');
|
||||
equal(backslashTemplate({thing: 'This'}), 'This is \\ridanculous');
|
||||
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 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 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><% }); %>');
|
||||
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'
|
||||
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>');
|
||||
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>');
|
||||
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>');
|
||||
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 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>');
|
||||
result = template({value: '<script>'});
|
||||
var template = _.template("<i><%- value %></i>");
|
||||
var result = template({value: "<script>"});
|
||||
equal(result, '<i><script></i>');
|
||||
|
||||
var stooge = {
|
||||
name: 'Moe',
|
||||
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>');
|
||||
if (!$.browser.msie) {
|
||||
var fromHTML = _.template($('#template').html());
|
||||
equal(fromHTML({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 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");
|
||||
|
||||
quoteInStatementAndBody = _.template("{{ if(foo == 'bar'){ }}Statement quotes and 'quotes'.{{ } }}");
|
||||
equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'.");
|
||||
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 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");
|
||||
|
||||
quoteInStatementAndBody = _.template("<? if(foo == 'bar'){ ?>Statement quotes and 'quotes'.<? } ?>");
|
||||
equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'.");
|
||||
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 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');
|
||||
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() {
|
||||
@@ -288,46 +216,10 @@
|
||||
strictEqual(_.result(null, 'x'), undefined);
|
||||
});
|
||||
|
||||
test('result returns a default value if object is null or undefined', function() {
|
||||
strictEqual(_.result(null, 'b', 'default'), 'default');
|
||||
strictEqual(_.result(undefined, 'c', 'default'), 'default');
|
||||
strictEqual(_.result(''.match('missing'), 1, 'default'), 'default');
|
||||
});
|
||||
|
||||
test('result returns a default value if property of object is missing', function() {
|
||||
strictEqual(_.result({d: null}, 'd', 'default'), null);
|
||||
strictEqual(_.result({e: false}, 'e', 'default'), false);
|
||||
});
|
||||
|
||||
test('result only returns the default value if the object does not have the property or is undefined', function() {
|
||||
strictEqual(_.result({}, 'b', 'default'), 'default');
|
||||
strictEqual(_.result({d: undefined}, 'd', 'default'), 'default');
|
||||
});
|
||||
|
||||
test('result does not return the default if the property of an object is found in the prototype', function() {
|
||||
var Foo = function(){};
|
||||
Foo.prototype.bar = 1;
|
||||
strictEqual(_.result(new Foo, 'bar', 2), 1);
|
||||
});
|
||||
|
||||
test('result does use the fallback when the result of invoking the property is undefined', function() {
|
||||
var obj = {a: function() {}};
|
||||
strictEqual(_.result(obj, 'a', 'failed'), undefined);
|
||||
});
|
||||
|
||||
test('result fallback can use a function', function() {
|
||||
var obj = {a: [1, 2, 3]};
|
||||
strictEqual(_.result(obj, 'b', _.constant(5)), 5);
|
||||
strictEqual(_.result(obj, 'b', function() {
|
||||
return this.a;
|
||||
}), obj.a, 'called with context');
|
||||
});
|
||||
|
||||
test('_.templateSettings.variable', function() {
|
||||
var s = '<%=data.x%>';
|
||||
var data = {x: 'x'};
|
||||
var tmp = _.template(s, {variable: 'data'});
|
||||
strictEqual(tmp(data), 'x');
|
||||
strictEqual(_.template(s, data, {variable: 'data'}), 'x');
|
||||
_.templateSettings.variable = 'data';
|
||||
strictEqual(_.template(s)(data), 'x');
|
||||
});
|
||||
@@ -348,22 +240,22 @@
|
||||
strictEqual(templateEscaped({x: undefined}), '');
|
||||
|
||||
var templateWithProperty = _.template('<%=x.foo%>');
|
||||
strictEqual(templateWithProperty({x: {}}), '');
|
||||
strictEqual(templateWithProperty({x: {}}), '');
|
||||
strictEqual(templateWithProperty({x: {} }), '');
|
||||
strictEqual(templateWithProperty({x: {} }), '');
|
||||
|
||||
var templateWithPropertyEscaped = _.template('<%-x.foo%>');
|
||||
strictEqual(templateWithPropertyEscaped({x: {}}), '');
|
||||
strictEqual(templateWithPropertyEscaped({x: {}}), '');
|
||||
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++); }});
|
||||
template({f: function(){ ok(!(count++)); }});
|
||||
|
||||
var countEscaped = 0;
|
||||
var templateEscaped = _.template('<%- f() %>');
|
||||
templateEscaped({f: function(){ ok(!countEscaped++); }});
|
||||
templateEscaped({f: function(){ ok(!(countEscaped++)); }});
|
||||
});
|
||||
|
||||
test('#746 - _.template settings are not modified.', 1, function() {
|
||||
@@ -377,4 +269,4 @@
|
||||
strictEqual(template(), '<<\nx\n>>');
|
||||
});
|
||||
|
||||
}());
|
||||
});
|
||||
|
||||
6
vendor/underscore/underscore-min.js
vendored
6
vendor/underscore/underscore-min.js
vendored
File diff suppressed because one or more lines are too long
1344
vendor/underscore/underscore.js
vendored
1344
vendor/underscore/underscore.js
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user