Compare commits

..

47 Commits

Author SHA1 Message Date
John-David Dalton
9c52ecc19b Tweak regexp in post-compile.js.
Former-commit-id: 8c6933944703a17582696fb10b45f12926fe1030
2012-12-17 08:36:02 -08:00
John-David Dalton
692c884ca2 Ensure test count is the same for dev and prod builds.
Former-commit-id: 00e24fdd70d52bc6be4ae53fed43933fcf2c35da
2012-12-17 08:21:13 -08:00
John-David Dalton
3ef51d7fae Refactor previous commit.
Former-commit-id: ad5408ad8a9e5b2caa9667994fe6748760b40fbe
2012-12-17 08:20:37 -08:00
John-David Dalton
73d95de122 Reduce _.forEach and optimize the minified builds for Safari.
Former-commit-id: d4366f1a3c5fd0751558f714384600c3bcf0f49b
2012-12-17 00:06:59 -08:00
John-David Dalton
04a568ac9b Update vendors and docs. [ci skip]
Former-commit-id: 9ca377423f4714fdf0e3fa428711e8dfe75e2e44
2012-12-16 21:41:01 -08:00
John-David Dalton
a45499cf04 Cleanup build.js and README.md.
Former-commit-id: abf5c3e3f1b0a04b8f9eeb132366f51c92c9a450
2012-12-16 14:47:00 -08:00
John-David Dalton
b847d672ab Bump to v1.0.0-rc.3.
Former-commit-id: d00d4d948fc0e2597e4ee2f2d15a9bee2dc27440
2012-12-16 12:22:04 -08:00
John-David Dalton
3ffefdf6b5 Avoid _.isArray returning true for arguments objects in browsers that report arguments.constructor as Array.
Former-commit-id: 9fccc5219e7cb6a007138f1f474d9e68504a0260
2012-12-16 10:47:22 -08:00
John-David Dalton
cca4c4be80 Fix hasObjectSpliceBug implementations of _#pop, _#shift, and _#splice.
Former-commit-id: 91a3bc259c85bd269c3d895b66204bdc4d158827
2012-12-16 00:14:08 -08:00
John-David Dalton
cb9e044cb3 Prepare v1.0.0-rc.3 bump.
Former-commit-id: d4b08cd58a7effb9e6107fe16c11ccdea032cb00
2012-12-16 00:12:01 -08:00
John-David Dalton
fd25dd83bd Coerce value to a string once in _.intersection and _.uniq.
Former-commit-id: 5cb0f0034c473ec62c3b342f45d22c0abe6c5fb3
2012-12-15 14:32:55 -08:00
John-David Dalton
584bb00cfc Use the indicatorObject instead of a boolean in the internals of _.reduce and _.reduceRight.
Former-commit-id: b83d1ef428941f15a6633c1b16b9373210149318
2012-12-15 13:01:43 -08:00
John-David Dalton
5b9369d344 Update tested Node version and reduce emphasis on performance in README.md.
Former-commit-id: 12a57f39409fa5bb5a18e3535c56c50ef767289a
2012-12-15 13:00:22 -08:00
John-David Dalton
a64506a0de More clearly label lodash underscore compatibility builds. [ci skip]
Former-commit-id: 169559848f08a5ce9228e18e647e2e26eabe8341
2012-12-14 01:55:39 -08:00
John-David Dalton
2fc83ef80b Tweak _.cloneDeep docs.
Former-commit-id: 992471067498a0be795f473fabaaf8e45581f291
2012-12-14 01:06:00 -08:00
John-David Dalton
8bee3ebd65 Update backbone method dependencies.
Former-commit-id: 1b030f0a7b2f4065ec1dfc9ef911de77ebd7d842
2012-12-14 00:54:36 -08:00
John-David Dalton
99686fdd73 Revert @license doc tag addition of #138.
Former-commit-id: a66d22c952b3a0bb45e049a80ee80aa54c4e6a33
2012-12-14 00:41:56 -08:00
John-David Dalton
33bc3d6a1e Update vendors, builds, and docs.
Former-commit-id: d57931d657ac0e73d91ac1bd1b33e24be5a16f35
2012-12-14 00:32:58 -08:00
John-David Dalton
90597530a4 Add _.cloneDeep alias of _.clone(…, true). [closes #140]
Former-commit-id: b71397d5c5b71cb28a60eb4656cbaf12f6b03d1a
2012-12-14 00:24:02 -08:00
John-David Dalton
b2af8da9a2 Merge branch 'master' of github.com:bestiejs/lodash
Former-commit-id: 502c65ac38876c5fe42c9c652ef4cb237e9c631a
2012-12-13 23:49:38 -08:00
John-David Dalton
05dbf41fdc Optimize _.intersection.
Former-commit-id: 017b20ad958a9dd7be09872456b1d26a59361c5a
2012-12-13 23:48:19 -08:00
John-David Dalton
c56bb56708 Cleanup benchmarks.
Former-commit-id: 805c0091cd6cec85729ee7511005c233545a9899
2012-12-13 23:47:48 -08:00
Kit Cambridge
4def1ea1dc Fix installation mode detection on Windows. Closes #139.
The global `node_modules` directory does not exist if no modules have been
installed globally, causing `realpathSync` to throw an exception.


Former-commit-id: 5a59e6b53c7afe5d5c5728352e9cd722744b2247
2012-12-13 10:35:29 -08:00
John-David Dalton
0ba05e4de0 Add @license to minified copyright header to preserve it in case of double minification. [closes #138]
Former-commit-id: 6c9b72f9c807daac613ff2d4339c0e3c4e7cafe3
2012-12-12 00:37:56 -08:00
John-David Dalton
24fce89155 Remove "Collections" method _.forEach dependency from "Arrays" method _.intersection.
Former-commit-id: 83197c7ac47654c6fc2d2f37df8ff77d4adb9096
2012-12-12 00:34:58 -08:00
John-David Dalton
1a3c20f91d Tweak _.throttle unit test pass more consistently.
Former-commit-id: 91063b5c6ae0c9beb2c86cc21153d75f060afef1
2012-12-11 01:10:52 -08:00
John-David Dalton
fe3e78cc1c Update vendors, rebuild minified files, update docs/license.
Former-commit-id: 689793b6e5c4bbae917e726dc646902c697ce3a7
2012-12-11 01:09:52 -08:00
John-David Dalton
749f49b1a0 Add instanceof memory leak warning to _.isArray.
Former-commit-id: f90b1ad1850fb21c1d976f037a382c7388496d1c
2012-12-11 00:54:09 -08:00
John-David Dalton
f14010a09d Make a private each function to be used by _.forEach.
Former-commit-id: da9e22a66aef1ad9f4688f4fbb07e0806f8f0445
2012-12-11 00:44:02 -08:00
John-David Dalton
0b48b9c7d4 Optimize _.isArray fallback, _.isDate, _.isFunction, and _.isRegExp.
Former-commit-id: a3e350bf1fa91a9582ba6a0effe61d4589cc8afe
2012-12-10 00:29:26 -08:00
John-David Dalton
13d62b01d1 Ensure utf-8 encoding and tweak text in CONTRIBUTING.md.
Former-commit-id: 67a3e585c0a3b815e916e0d38ed2bc113de3220d
2012-12-10 00:05:43 -08:00
John-David Dalton
4e7b71db1d Cleanup CONTRIBUTING.md and README.md.
Former-commit-id: f0dca3ffc6a23128a877ae4d7d7f409d2e6adb69
2012-12-09 22:36:19 -08:00
John-David Dalton
069fc1f97b Merge branch 'master' of github.com:bestiejs/lodash
Former-commit-id: e30fbcc10d6a5ea2bde762d91b9dd11a6f8a0dfc
2012-12-09 21:59:42 -08:00
John-David Dalton
8684f75254 Cleanup lib and build unit tests.
Former-commit-id: 96171aa70fee408f5237e0615ace4faa6541caa7
2012-12-09 21:59:05 -08:00
John-David Dalton
11cd924ce1 Rework the chaining behavior of Array wrapper methods.
Former-commit-id: fb8add58a861a19a2df63d6ff377c2a9537a38b6
2012-12-09 21:58:31 -08:00
Kit Cambridge
e2fd0cfc4e Add contributing guidelines.
Former-commit-id: 0e613d3b5136a980284b3ba3de738ba664cb7fe5
2012-12-09 14:16:15 -08:00
John-David Dalton
5eb3106706 Updating Backbone/Underscore unit tests to avoid failing tests due to different chaining implementations.
Former-commit-id: d797a3547368faae04806d61818327e7d2319309
2012-12-09 00:23:02 -08:00
John-David Dalton
1831efbe9d Cleanup build and doc comments.
Former-commit-id: 861145621113c0b6719b24d00ce0e359360ee1eb
2012-12-08 21:37:40 -08:00
John-David Dalton
38edbadca5 Update Lo-Dash description.
Former-commit-id: 75703b13b95399107b11f109dcc6d3b3dfd9eabe
2012-12-08 18:53:45 -08:00
John-David Dalton
6fcd80b979 Update builds and docs.
Former-commit-id: 647fe24574fc9bab2d32abb6e95f74d1cdd593f4
2012-12-08 18:52:59 -08:00
John-David Dalton
cf5e5dbe55 Update build to add _.chain and _#chain for backbone and underscore builds.
Former-commit-id: 2c910de419904a1285d246a3b08d87cb4daafa18
2012-12-08 18:46:09 -08:00
John-David Dalton
a451861bf1 Make "Functions" methods return wrapped values when chaining and remove _.chain and _#chain methods.
Former-commit-id: a507f9a1b76b933a7d558d2cc20177e6995dcf0d
2012-12-08 18:42:48 -08:00
John-David Dalton
7313dd74a6 Allow compiled templates loaded via AMD to set and use the private _ variable.
Former-commit-id: 746e6d8275f08dbb628e92c146fffba84df0f8c0
2012-12-08 01:26:08 -08:00
John-David Dalton
32b9de05f2 Cleanup test/test-build.js.
Former-commit-id: 4edb24bf22b8e8f9aa45b08a97289c1b83461e16
2012-12-08 01:24:25 -08:00
Kit Cambridge
c79bed22f8 Ensure that passing settings=... does not clobber the default moduleId.
Precompiling a template with `settings` previously generated a snippet
resembling `define(["undefined"], function(lodash) { ... })` if the `settings`
object did not contain a `moduleId` property. You can now pass `settings` and
`moduleId` options simultaneously; the builder will always use the `moduleId`
property in `settings` if it is provided, and default to `moduleId` otherwise.


Former-commit-id: 711b4f167dc08ce3d42029e9001ebdb2d8d60a56
2012-12-07 19:41:11 -08:00
John-David Dalton
cdeb50132d Optimize _.reduce and _.reduceRight.
Former-commit-id: 6f281aae7f285458feafb02957fcd90fb09c10bd
2012-12-07 00:20:09 -08:00
John-David Dalton
090fb09955 Optimize _.union.
Former-commit-id: 0cba8cac81a621b1fdbe8868ab406a30eb1d743f
2012-12-06 23:09:41 -08:00
34 changed files with 2198 additions and 1324 deletions

View File

@@ -4,4 +4,4 @@ node_js:
- 0.8 - 0.8
before_script: before_script:
- "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/a2787b470c577cee2404d186c562dd9835f779f5 | tar xvz -C vendor" - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/a2787b470c577cee2404d186c562dd9835f779f5 | tar xvz -C vendor"
- "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/3390b259e04829538e4d3635d12b317dd6103eca | tar xvz -C vendor" - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/7ecae09d413eb48dd5785fe877f24e60ac3bbcef | tar xvz -C vendor"

35
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,35 @@
# Contributing to Lo-Dash
If youd 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/bestiejs/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.
You can run the tests from the command line via `npm test`, or open `test/index.html` in a web browser.
The `test/run-test.sh` script attempts to run the tests in [Rhino](http://www.mozilla.org/rhino/), [RingoJS](http://ringojs.org/), [Narwhal](https://github.com/280north/narwhal), 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
Lo-Dash is preparing to join [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 Russells excellent post, ["Why Do I Need to Sign This?"](http://infrequently.org/2008/06/why-do-i-need-to-sign-this/).
## Coding Guidelines
In addition to the following guidelines, please follow the conventions already established in the code.
- **Spacing**:<br>
Use two spaces for indentation. No tabs.
- **Naming**:<br>
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, and [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for new methods.

View File

@@ -1,5 +1,5 @@
Copyright 2012 John-David Dalton <http://allyoucanleet.com/> Copyright 2012 John-David Dalton <http://allyoucanleet.com/>
Based on Underscore.js 1.3.3, copyright 2009-2012 Jeremy Ashkenas, Based on Underscore.js 1.4.3, copyright 2009-2012 Jeremy Ashkenas,
DocumentCloud Inc. <http://documentcloud.github.com/underscore> DocumentCloud Inc. <http://documentcloud.github.com/underscore>
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining

View File

@@ -1,23 +1,23 @@
# Lo-Dash <sup>v1.0.0-rc.2</sup> # Lo-Dash <sup>v1.0.0-rc.3</sup>
[![build status](https://secure.travis-ci.org/bestiejs/lodash.png)](http://travis-ci.org/bestiejs/lodash) [![build status](https://secure.travis-ci.org/bestiejs/lodash.png)](http://travis-ci.org/bestiejs/lodash)
A utility library, usable as a drop-in replacement for Underscore, delivering [performance](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#resolved-underscorejs-issues), and [additional features](http://lodash.com/#features). An alternative to Underscore.js, delivering [consistency](https://github.com/bestiejs/lodash#resolved-underscorejs-issues), [customization](https://github.com/bestiejs/lodash#custom-builds), [performance](http://lodash.com/benchmarks), and [extra features](https://github.com/bestiejs/lodash#features).
## Download ## Download
* Lo-Dash builds:<br> * Lo-Dash builds:<br>
[Development](https://raw.github.com/bestiejs/lodash/v1.0.0-rc.2/lodash.js) and [Development](https://raw.github.com/bestiejs/lodash/v1.0.0-rc.3/lodash.js) and
[Production](https://raw.github.com/bestiejs/lodash/v1.0.0-rc.2/lodash.min.js) [Production](https://raw.github.com/bestiejs/lodash/v1.0.0-rc.3/lodash.min.js)
* Underscore builds:<br> * Underscore compatibility builds:<br>
[Development](https://raw.github.com/bestiejs/lodash/v1.0.0-rc.2/lodash.underscore.js) and [Development](https://raw.github.com/bestiejs/lodash/v1.0.0-rc.3/lodash.underscore.js) and
[Production](https://raw.github.com/bestiejs/lodash/v1.0.0-rc.2/lodash.underscore.min.js) [Production](https://raw.github.com/bestiejs/lodash/v1.0.0-rc.3/lodash.underscore.min.js)
* CDN copies of ≤ v1.0.0-rc.2s builds are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/):<br> * CDN copies of ≤ v1.0.0-rc.3s builds are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/):<br>
[Lo-Dash development](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.2/lodash.js), [Lo-Dash dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.3/lodash.js),
[Lo-Dash production](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.2/lodash.min.js), [Lo-Dash prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.3/lodash.min.js),
[Underscore development](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.2/lodash.underscore.js), and [Underscore compat-dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.3/lodash.underscore.js), and
[Underscore production](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.2/lodash.underscore.min.js) [Underscore compat-prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0-rc.3/lodash.underscore.min.js)
* For optimal file size, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need * For optimal file size, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need
@@ -25,8 +25,6 @@ A utility library, usable as a drop-in replacement for Underscore, delivering [p
Weve got [API docs](http://lodash.com/docs), [benchmarks](http://lodash.com/benchmarks), and [unit tests](http://lodash.com/tests). Weve got [API docs](http://lodash.com/docs), [benchmarks](http://lodash.com/benchmarks), and [unit tests](http://lodash.com/tests).
Create your own benchmarks at [jsPerf](http://jsperf.com), or [search](http://jsperf.com/search?q=lodash) for existing ones.
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/lodash/wiki/Roadmap). For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/lodash/wiki/Roadmap).
## Screencasts ## Screencasts
@@ -43,9 +41,9 @@ For more information check out these screencasts over Lo-Dash:
## Features ## Features
* AMD loader support ([RequireJS](http://requirejs.org/), [curl.js](https://github.com/cujojs/curl), etc.) * AMD loader support ([RequireJS](http://requirejs.org/), [curl.js](https://github.com/cujojs/curl), etc.)
* [_(…)](http://lodash.com/docs#_) supports intuitive chaining without calling [_(…).chain](http://lodash.com/docs#prototype_chain) * [_(…)](http://lodash.com/docs#_) supports intuitive chaining
* [_.bindKey](http://lodash.com/docs#bindKey) for binding [*“lazy”* defined](http://michaux.ca/articles/lazy-function-definition-pattern) methods * [_.bindKey](http://lodash.com/docs#bindKey) for binding [*“lazy”* defined](http://michaux.ca/articles/lazy-function-definition-pattern) methods
* [_.clone](http://lodash.com/docs#clone) supports *“deep”* cloning * [_.cloneDeep](http://lodash.com/docs#cloneDeep) for *“deep”* cloning arrays and objects
* [_.contains](http://lodash.com/docs#contains) accepts a `fromIndex` argument * [_.contains](http://lodash.com/docs#contains) accepts a `fromIndex` argument
* [_.forEach](http://lodash.com/docs#forEach) is chainable and supports exiting iteration early * [_.forEach](http://lodash.com/docs#forEach) is chainable and supports exiting iteration early
* [_.forIn](http://lodash.com/docs#forIn) for iterating over an objects own and inherited properties * [_.forIn](http://lodash.com/docs#forIn) for iterating over an objects own and inherited properties
@@ -60,7 +58,7 @@ For more information check out these screencasts over Lo-Dash:
## Support ## Support
Lo-Dash has been tested in at least Chrome 5~23, Firefox 1~16, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.15, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. Lo-Dash has been tested in at least Chrome 5~23, Firefox 1~17, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.16, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5.
## Custom builds ## Custom builds
@@ -228,31 +226,51 @@ require({
## Resolved Underscore.js issues ## Resolved Underscore.js issues
* Allow iteration of objects with a `length` property [[#799](https://github.com/documentcloud/underscore/pull/799), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.2/test/test.js#L605-L611)] * Allow iteration of objects with a `length` property [[#799](https://github.com/documentcloud/underscore/pull/799), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.3/test/test.js#L605-L611)]
* Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.2/test/test.js#L618-L642)] * Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.3/test/test.js#L618-L642)]
* Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [#742](https://github.com/documentcloud/underscore/issues/742), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.2/test/test.js#L140-L146)] * Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [#742](https://github.com/documentcloud/underscore/issues/742), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.3/test/test.js#L140-L146)]
* `_.isEmpty` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.2/test/test.js#L807-L812)] * `_.isEmpty` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.3/test/test.js#L807-L812)]
* `_.isObject` should avoid V8 bug [#2291](http://code.google.com/p/v8/issues/detail?id=2291) [[#605](https://github.com/documentcloud/underscore/issues/605), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.2/test/test.js#L888-L900)] * `_.isObject` should avoid V8 bug [#2291](http://code.google.com/p/v8/issues/detail?id=2291) [[#605](https://github.com/documentcloud/underscore/issues/605), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.3/test/test.js#L888-L900)]
* `_.keys` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.2/test/test.js#L981-L983)] * `_.keys` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.3/test/test.js#L982-L984)]
* `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.2/test/test.js#L1382-L1385)] * `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/bestiejs/lodash/blob/v1.0.0-rc.3/test/test.js#L1383-L1386)]
## Release Notes ## Release Notes
### <sup>v1.0.0-rc.2</sup> ### ### <sup>v1.0.0-rc.3</sup>
#### Compatibility Warnings
* Made `_#join`, `_#pop`, and `_#shift` wrapper methods return unwrapped values
* Made *“Functions”* methods wrapper counterparts return wrapped values
* Removed `_.chain` and `_#chain` methods
#### Changes
* Added [_.cloneDeep](http://lodash.com/docs#cloneDeep) alias of `_.clone(…, true)`
* Added `_.once` to the `backbone` build method dependencies
* Ensured `backbone` builds implement Underscores chaining behavior
* Ensured the `settings=…` build option doesnt clobber the default `moduleId`
* Ensured Lo-Dashs `npm` package installation avoids erroring when no other modules have been globally installed
* Made compiled templates loaded via AMD use the Lo-Dash module for their `_` references
* Removed the *“Collections”* method `_.forEach` dependency from *“Arrays”* method `_.intersection`
* Optimized `_.isArray` and `_.isFunction` fallbacks as well as<br>
`_.intersection`, `_.isDate`, `_.isRegExp`, `_.reduce`, `_.reduceRight`, `_.union`, and `_.uniq`
### <sup>v1.0.0-rc.2</sup>
* Specified more method chaining behaviors * Specified more method chaining behaviors
* Updated `underscore` build compatibility to v1.4.3 * Updated `underscore` build compatibility to v1.4.3
### <sup>v1.0.0-rc.1</sup> ### ### <sup>v1.0.0-rc.1</sup>
#### Compatibility Warnings #### #### Compatibility Warnings
* Made `_(…)` chain automatically without needing to call `_#chain` * Made `_(…)` intuitively chain without needing to call `_#chain`
* Made `_.isEqual` equate `arguments` objects to similar `Object` objects * Made `_.isEqual` equate `arguments` objects to similar `Object` objects
* Made `_.clone` copy the enumerable properties of `arguments` objects and objects<br> * Made `_.clone` copy the enumerable properties of `arguments` objects and objects<br>
created by constructors other than `Object` are cloned to plain `Object` objects created by constructors other than `Object` are cloned to plain `Object` objects
#### Changes #### #### Changes
* Ensure Lo-Dash runs in the JS engine embedded in Adobe products * Ensure Lo-Dash runs in the JS engine embedded in Adobe products
* Ensured `_.reduce` and `_.reduceRight` pass the correct number of `callback` arguments * Ensured `_.reduce` and `_.reduceRight` pass the correct number of `callback` arguments

365
build.js
View File

@@ -70,11 +70,11 @@
'bind': ['isFunction', 'isObject'], 'bind': ['isFunction', 'isObject'],
'bindAll': ['bind', 'functions'], 'bindAll': ['bind', 'functions'],
'bindKey': ['isFunction', 'isObject'], 'bindKey': ['isFunction', 'isObject'],
'chain': ['mixin'],
'clone': ['assign', 'forEach', 'forOwn', 'isArray', 'isObject'], 'clone': ['assign', 'forEach', 'forOwn', 'isArray', 'isObject'],
'cloneDeep': ['clone'],
'compact': [], 'compact': [],
'compose': [], 'compose': [],
'contains': ['forEach', 'indexOf', 'isString'], 'contains': ['indexOf', 'isString'],
'countBy': ['forEach'], 'countBy': ['forEach'],
'debounce': [], 'debounce': [],
'defaults': ['isArguments'], 'defaults': ['isArguments'],
@@ -82,12 +82,12 @@
'delay': [], 'delay': [],
'difference': ['indexOf'], 'difference': ['indexOf'],
'escape': [], 'escape': [],
'every': ['forEach', 'isArray'], 'every': ['isArray'],
'filter': ['forEach', 'isArray'], 'filter': ['isArray'],
'find': ['forEach'], 'find': ['forEach'],
'first': [], 'first': [],
'flatten': ['isArray'], 'flatten': ['isArray'],
'forEach': ['identity', 'isArguments', 'isString'], 'forEach': ['identity', 'isArguments', 'isArray', 'isString'],
'forIn': ['identity', 'isArguments'], 'forIn': ['identity', 'isArguments'],
'forOwn': ['identity', 'isArguments'], 'forOwn': ['identity', 'isArguments'],
'functions': ['forIn', 'isFunction'], 'functions': ['forIn', 'isFunction'],
@@ -96,7 +96,7 @@
'identity': [], 'identity': [],
'indexOf': ['sortedIndex'], 'indexOf': ['sortedIndex'],
'initial': [], 'initial': [],
'intersection': ['filter', 'indexOf'], 'intersection': ['indexOf'],
'invert': ['forOwn'], 'invert': ['forOwn'],
'invoke': ['forEach'], 'invoke': ['forEach'],
'isArguments': [], 'isArguments': [],
@@ -119,11 +119,11 @@
'keys': ['forOwn', 'isArguments', 'isObject'], 'keys': ['forOwn', 'isArguments', 'isObject'],
'last': [], 'last': [],
'lastIndexOf': [], 'lastIndexOf': [],
'map': ['forEach', 'isArray'], 'map': ['isArray'],
'max': ['forEach', 'isArray', 'isString'], 'max': ['isArray', 'isString'],
'memoize': [], 'memoize': [],
'merge': ['forOwn', 'isArray', 'isPlainObject'], 'merge': ['forOwn', 'isArray', 'isPlainObject'],
'min': ['forEach', 'isArray', 'isString'], 'min': ['isArray', 'isString'],
'mixin': ['forEach', 'forOwn', 'functions'], 'mixin': ['forEach', 'forOwn', 'functions'],
'noConflict': [], 'noConflict': [],
'object': [], 'object': [],
@@ -135,14 +135,14 @@
'pluck': ['map'], 'pluck': ['map'],
'random': [], 'random': [],
'range': [], 'range': [],
'reduce': ['forEach'], 'reduce': ['isArray'],
'reduceRight': ['forEach', 'isString', 'keys'], 'reduceRight': ['forEach', 'isString', 'keys'],
'reject': ['filter'], 'reject': ['filter'],
'rest': [], 'rest': [],
'result': ['isFunction'], 'result': ['isFunction'],
'shuffle': ['forEach'], 'shuffle': ['forEach'],
'size': ['keys'], 'size': ['keys'],
'some': ['forEach', 'isArray'], 'some': ['isArray'],
'sortBy': ['forEach'], 'sortBy': ['forEach'],
'sortedIndex': ['identity'], 'sortedIndex': ['identity'],
'tap': ['mixin'], 'tap': ['mixin'],
@@ -159,7 +159,10 @@
'where': ['filter', 'keys'], 'where': ['filter', 'keys'],
'without': ['indexOf'], 'without': ['indexOf'],
'wrap': [], 'wrap': [],
'zip': ['max', 'pluck'] 'zip': ['max', 'pluck'],
// method used by the `backbone` and `underscore` builds
'chain': ['mixin']
}; };
/** Used to inline `iteratorTemplate` */ /** Used to inline `iteratorTemplate` */
@@ -171,7 +174,7 @@
'hasDontEnumBug', 'hasDontEnumBug',
'isKeysFast', 'isKeysFast',
'objectLoop', 'objectLoop',
'noArgsEnum', 'nonEnumArgs',
'noCharByIndex', 'noCharByIndex',
'shadowed', 'shadowed',
'top', 'top',
@@ -217,6 +220,7 @@
'max', 'max',
'min', 'min',
'mixin', 'mixin',
'once',
'pick', 'pick',
'reduce', 'reduce',
'reduceRight', 'reduceRight',
@@ -237,6 +241,7 @@
/** List of methods used by Underscore */ /** List of methods used by Underscore */
var underscoreMethods = _.without.apply(_, [allMethods].concat([ var underscoreMethods = _.without.apply(_, [allMethods].concat([
'bindKey', 'bindKey',
'cloneDeep',
'forIn', 'forIn',
'forOwn', 'forOwn',
'isPlainObject', 'isPlainObject',
@@ -255,7 +260,157 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/** /**
* Adds the given build `commands` to the copyright/license header of `source`. * Adds support for Underscore style chaining to the `source`.
*
* @private
* @param {String} source The source to process.
* @returns {String} Returns the modified source.
*/
function addChainMethods(source) {
// add `_.chain`
source = source.replace(matchFunction(source, 'tap'), function(match) {
return [
'',
' /**',
' * Creates a `lodash` object that wraps the given `value`.',
' *',
' * @static',
' * @memberOf _',
' * @category Chaining',
' * @param {Mixed} value The value to wrap.',
' * @returns {Object} Returns the wrapper object.',
' * @example',
' *',
' * var stooges = [',
" * { 'name': 'moe', 'age': 40 },",
" * { 'name': 'larry', 'age': 50 },",
" * { 'name': 'curly', 'age': 60 }",
' * ];',
' *',
' * var youngest = _.chain(stooges)',
' * .sortBy(function(stooge) { return stooge.age; })',
" * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; })",
' * .first();',
" * // => 'moe is 40'",
' */',
' function chain(value) {',
' value = new lodash(value);',
' value.__chain__ = true;',
' return value;',
' }',
'',
match
].join('\n');
});
// add `wrapperChain`
source = source.replace(matchFunction(source, 'wrapperToString'), function(match) {
return [
'',
' /**',
' * Enables method chaining on the wrapper object.',
' *',
' * @name chain',
' * @memberOf _',
' * @category Chaining',
' * @returns {Mixed} Returns the wrapper object.',
' * @example',
' *',
' * var sum = _([1, 2, 3])',
' * .chain()',
' * .reduce(function(sum, num) { return sum + num; })',
' * .value()',
' * // => 6`',
' */',
' function wrapperChain() {',
' this.__chain__ = true;',
' return this;',
' }',
'',
match
].join('\n');
});
// add `lodash.chain` assignment
source = source.replace(getMethodAssignments(source), function(match) {
return match.replace(/^(?: *\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\n)?( *)lodash\.VERSION *=/m, '$1lodash.chain = chain;\n\n$&');
});
// add `lodash.prototype.chain` assignment
source = source.replace(/^( *)lodash\.prototype\.value *=.+\n/m, '$1lodash.prototype.chain = wrapperChain;\n$&');
// remove `lodash.prototype.toString` and `lodash.prototype.valueOf` assignments
source = source.replace(/^ *lodash\.prototype\.(?:toString|valueOf) *=.+\n/gm, '');
// remove `lodash.prototype` batch method assignments
source = source.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, '');
// move `mixin(lodash)` to after the method assignments
source = source.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+/, '');
source = source.replace(getMethodAssignments(source), function(match) {
return match + [
'',
'',
' // add functions to `lodash.prototype`',
' mixin(lodash);'
].join('\n');
});
// add `__chain__` checks to `_.mixin`
source = source.replace(matchFunction(source, 'mixin'), function(match) {
return match.replace(/^( *)return new lodash.+/m, function() {
var indent = arguments[1];
return indent + [
'if (this.__chain__) {',
' result = new lodash(result);',
' result.__chain__ = true;',
'}',
'return result;'
].join('\n' + indent);
});
});
// replace wrapper `Array` method assignments
source = source.replace(/^(?: *\/\/.*\n)*( *)each\(\['[\s\S]+?\n\1}$/m, function() {
return [
' // add `Array` mutator functions to the wrapper',
" each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {",
' var func = arrayRef[methodName];',
' lodash.prototype[methodName] = function() {',
' var value = this.__wrapped__;',
' func.apply(value, arguments);',
'',
' // avoid array-like object bugs with `Array#shift` and `Array#splice`',
' // in Firefox < 10 and IE < 9',
' if (hasObjectSpliceBug && value.length === 0) {',
' delete value[0];',
' }',
' return this;',
' };',
' });',
'',
' // add `Array` accessor functions to the wrapper',
" each(['concat', 'join', 'slice'], function(methodName) {",
' var func = arrayRef[methodName];',
' lodash.prototype[methodName] = function() {',
' var value = this.__wrapped__,',
' result = func.apply(value, arguments);',
'',
' if (this.__chain__) {',
' result = new lodash(result);',
' result.__chain__ = true;',
' }',
' return result;',
' };',
' });'
].join('\n');
});
return source;
}
/**
* Adds build `commands` to the copyright/license header of the `source`.
* *
* @private * @private
* @param {String} source The source to process. * @param {String} source The source to process.
@@ -284,7 +439,8 @@
}); });
// add build commands to copyright/license header // add build commands to copyright/license header
return ( return (
parts[0] + parts[1] + parts[2] + ' (Custom Build)' + parts[3] + '\n' + parts[0] +
parts[1] + parts[2] + ' (Custom Build)' + parts[3] + '\n' +
parts[1] + ' Build: `lodash ' + commands.join(' ') + '`' parts[1] + ' Build: `lodash ' + commands.join(' ') + '`'
); );
}); });
@@ -336,6 +492,7 @@
source.push( source.push(
" if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {", " if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {",
" define(['" + options.moduleId + "'], function(lodash) {", " define(['" + options.moduleId + "'], function(lodash) {",
' _ = lodash;',
' lodash.templates = lodash.extend(lodash.templates || {}, templates);', ' lodash.templates = lodash.extend(lodash.templates || {}, templates);',
' });', ' });',
" } else if (freeExports) {", " } else if (freeExports) {",
@@ -746,6 +903,29 @@
return source; return source;
} }
/**
* Removes all `argsAreObjects` references from `source`.
*
* @private
* @param {String} source The source to process.
* @returns {String} Returns the modified source.
*/
function removeArgsAreObjects(source) {
source = removeVar(source, 'argsAreObjects');
// remove `argsAreObjects` from `_.isArray`
source = source.replace(matchFunction(source, 'isArray'), function(match) {
return match.replace(/\(argsAreObjects && *([^)]+)\)/g, '$1');
});
// remove `argsAreObjects` from `_.isEqual`
source = source.replace(matchFunction(source, 'isEqual'), function(match) {
return match.replace(/!argsAreObjects[^:]+:\s*/g, '');
});
return source;
}
/** /**
* Removes all `noArgsClass` references from `source`. * Removes all `noArgsClass` references from `source`.
* *
@@ -761,11 +941,6 @@
return match.replace(/ *\|\| *\(noArgsClass *&&[^)]+?\)\)/g, ''); return match.replace(/ *\|\| *\(noArgsClass *&&[^)]+?\)\)/g, '');
}); });
// remove `noArgsClass` from `_.isEqual`
source = source.replace(matchFunction(source, 'isEqual'), function(match) {
return match.replace(/noArgsClass[^:]+:\s*/g, '');
});
return source; return source;
} }
@@ -798,6 +973,19 @@
return source; return source;
} }
/**
* Removes all `hasObjectSpliceByg` references from `source`.
*
* @private
* @param {String} source The source to process.
* @returns {String} Returns the modified source.
*/
function removeHasObjectSpliceBug(source) {
return removeVar(source, 'hasObjectSpliceBug')
// remove `hasObjectSpliceBug` fix from the `Array` function mixins
.replace(/(?:\s*\/\/.*)*\n( *)if *\(hasObjectSpliceBug[\s\S]+?(?:{\s*}|\n\1})/, '');
}
/** /**
* Removes a given variable from `source`. * Removes a given variable from `source`.
* *
@@ -1050,7 +1238,7 @@
var templateSettings = options.reduce(function(result, value) { var templateSettings = options.reduce(function(result, value) {
var match = value.match(/settings=(.+)$/); var match = value.match(/settings=(.+)$/);
return match return match
? Function('return {' + match[1].replace(/^{|}$/g, '') + '}')() ? _.assign(result, Function('return {' + match[1].replace(/^{|}$/g, '') + '}')())
: result; : result;
}, _.assign(_.clone(_.templateSettings), { }, _.assign(_.clone(_.templateSettings), {
'moduleId': moduleId 'moduleId': moduleId
@@ -1108,11 +1296,11 @@
dependencyMap.reduceRight = ['forEach', 'keys']; dependencyMap.reduceRight = ['forEach', 'keys'];
} }
if (isUnderscore) { if (isUnderscore) {
dependencyMap.contains = ['forEach', 'indexOf']; dependencyMap.contains = ['indexOf'];
dependencyMap.isEqual = ['isArray', 'isFunction']; dependencyMap.isEqual = ['isArray', 'isFunction'];
dependencyMap.isEmpty = ['isArray', 'isString']; dependencyMap.isEmpty = ['isArray', 'isString'];
dependencyMap.max = ['forEach', 'isArray']; dependencyMap.max = ['isArray'];
dependencyMap.min = ['forEach', 'isArray']; dependencyMap.min = ['isArray'];
dependencyMap.pick = []; dependencyMap.pick = [];
dependencyMap.template = ['defaults', 'escape']; dependencyMap.template = ['defaults', 'escape'];
@@ -1174,7 +1362,11 @@
source = replaceVar(source, 'noArgsClass', 'true'); source = replaceVar(source, 'noArgsClass', 'true');
source = removeKeysOptimization(source); source = removeKeysOptimization(source);
} }
else if (isUnderscore) { if (isBackbone || isUnderscore) {
// add Underscore style chaining
source = addChainMethods(source);
}
if (isUnderscore) {
// remove unneeded variables // remove unneeded variables
source = removeVar(source, 'cloneableClasses'); source = removeVar(source, 'cloneableClasses');
source = removeVar(source, 'ctorByClass'); source = removeVar(source, 'ctorByClass');
@@ -1201,15 +1393,6 @@
' }' ' }'
].join('\n')); ].join('\n'));
// replace `_.chain`
source = replaceFunction(source, 'chain', [
' function chain(value) {',
' value = new lodash(value);',
' value.__chain__ = true;',
' return value;',
' }'
].join('\n'));
// replace `_.clone` // replace `_.clone`
if (useUnderscoreClone) { if (useUnderscoreClone) {
source = replaceFunction(source, 'clone', [ source = replaceFunction(source, 'clone', [
@@ -1229,7 +1412,7 @@
" if (typeof length == 'number') {", " if (typeof length == 'number') {",
' result = indexOf(collection, target) > -1;', ' result = indexOf(collection, target) > -1;',
' } else {', ' } else {',
' forEach(collection, function(value) {', ' each(collection, function(value) {',
' return (result = value === target) && indicatorObject;', ' return (result = value === target) && indicatorObject;',
' });', ' });',
' }', ' }',
@@ -1280,19 +1463,23 @@
' function intersection(array) {', ' function intersection(array) {',
' var args = arguments,', ' var args = arguments,',
' argsLength = args.length,', ' argsLength = args.length,',
' index = -1,',
' length = array ? array.length : 0,',
' result = [];', ' result = [];',
'', '',
' forEach(array, function(value) {', ' outer:',
' while (++index < length) {',
' var value = array[index];',
' if (indexOf(result, value) < 0) {', ' if (indexOf(result, value) < 0) {',
' var length = argsLength;', ' var argsIndex = argsLength;',
' while (--length) {', ' while (--argsIndex) {',
' if (indexOf(args[length], value) < 0) {', ' if (indexOf(args[argsIndex], value) < 0) {',
' return;', ' continue outer;',
' }', ' }',
' }', ' }',
' result.push(value);', ' result.push(value);',
' }', ' }',
' });', ' }',
' return result;', ' return result;',
' }' ' }'
].join('\n')); ].join('\n'));
@@ -1459,36 +1646,11 @@
' }' ' }'
].join('\n')); ].join('\n'));
// replace `wrapperChain` // remove `arguments` object and `argsAreObjects` check from `_.isEqual`
source = replaceFunction(source, 'wrapperChain', [
' function wrapperChain() {',
' this.__chain__ = true;',
' return this;',
' }'
].join('\n'));
// add `__chain__` checks to `_.mixin` and `Array` function wrappers
_.each([
matchFunction(source, 'mixin'),
/(?:\s*\/\/.*)*\n( *)forEach\(\['[\s\S]+?\n\1}.+/g
], function(pattern) {
source = source.replace(pattern, function(match) {
return match.replace(/( *)return new lodash\(([^)]+)\).+/, function(submatch, indent, varName) {
return indent + [
'if (this.__chain__) {',
' varName = new lodash(varName);',
' varName.__chain__ = true;',
'}',
'return varName;'
].join('\n' + indent)
.replace(/varName/g, varName);
});
});
});
// remove `arguments` object check from `_.isEqual`
source = source.replace(matchFunction(source, 'isEqual'), function(match) { source = source.replace(matchFunction(source, 'isEqual'), function(match) {
return match.replace(/^ *if *\(.+== argsClass[^}]+}\n/gm, '') return match
.replace(/^ *if *\(.+== argsClass[^}]+}\n/gm, '')
.replace(/!argsAreObjects[^:]+:\s*/g, '');
}); });
// remove conditional `charCodeCallback` use from `_.max` and `_.min` // remove conditional `charCodeCallback` use from `_.max` and `_.min`
@@ -1498,23 +1660,6 @@
}); });
}); });
// remove `lodash.prototype.toString` and `lodash.prototype.valueOf` assignments
source = source.replace(/^ *lodash\.prototype\.(?:toString|valueOf) *=.+\n/gm, '');
// remove `lodash.prototype` batch method assignments
source = source.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, '');
// move `mixin(lodash)` to after the method assignments
source = source.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+/, '');
source = source.replace(getMethodAssignments(source), function(match) {
return match + [
'',
'',
' // add functions to `lodash.prototype`',
' mixin(lodash);'
].join('\n');
});
// remove unused features from `createBound` // remove unused features from `createBound`
if (buildMethods.indexOf('partial') == -1) { if (buildMethods.indexOf('partial') == -1) {
source = source.replace(matchFunction(source, 'createBound'), function(match) { source = source.replace(matchFunction(source, 'createBound'), function(match) {
@@ -1617,7 +1762,8 @@
if (isMobile) { if (isMobile) {
// inline all functions defined with `createIterator` // inline all functions defined with `createIterator`
_.functions(lodash).forEach(function(methodName) { _.functions(lodash).forEach(function(methodName) {
var reFunc = RegExp('(\\bvar ' + methodName + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n'); // strip leading underscores to match pseudo private functions
var reFunc = RegExp('(\\bvar ' + methodName.replace(/^_/, '') + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n');
if (reFunc.test(source)) { if (reFunc.test(source)) {
// extract, format, and inject the compiled function's source code // extract, format, and inject the compiled function's source code
source = source.replace(reFunc, function(match, captured) { source = source.replace(reFunc, function(match, captured) {
@@ -1660,13 +1806,15 @@
}); });
}()); }());
// remove chainability from `_.forEach` // remove chainability from `each` and `_.forEach`
source = source.replace(matchFunction(source, 'forEach'), function(match) { _.each(['each', 'forEach'], function(methodName) {
return match.replace(/return result([};\s]+)$/, '$1'); source = source.replace(matchFunction(source, methodName), function(match) {
return match.replace(/\n *return .+?([};\s]+)$/, '$1');
});
}); });
// unexpose "exit early" feature from `_.forEach`, `_.forIn`, and `_.forOwn` // unexpose "exit early" feature of `each`, `_.forEach`, `_.forIn`, and `_.forOwn`
_.each(['forEach', 'forIn', 'forOwn'], function(methodName) { _.each(['each', 'forEach', 'forIn', 'forOwn'], function(methodName) {
source = source.replace(matchFunction(source, methodName), function(match) { source = source.replace(matchFunction(source, methodName), function(match) {
return match.replace(/=== *false\)/g, '=== indicatorObject)'); return match.replace(/=== *false\)/g, '=== indicatorObject)');
}); });
@@ -1688,10 +1836,9 @@
}); });
} }
else { else {
source = removeArgsAreObjects(source);
source = removeHasObjectSpliceBug(source);
source = removeIsArgumentsFallback(source); source = removeIsArgumentsFallback(source);
// remove `hasObjectSpliceBug` fix from the mutator Array functions mixin
source = source.replace(/(?:\s*\/\/.*)*\n( *)if *\(hasObjectSpliceBug[\s\S]+?\n\1}/, '');
} }
// remove `thisArg` from unexposed `forIn` and `forOwn` // remove `thisArg` from unexposed `forIn` and `forOwn`
@@ -1708,10 +1855,10 @@
} }
}); });
// remove `hasDontEnumBug`, `iteratesOwnLast`, and `noArgsEnum` declarations and assignments // remove `hasDontEnumBug`, `iteratesOwnLast`, and `nonEnumArgs` declarations and assignments
source = source source = source
.replace(/^ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/m, '') .replace(/^ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/m, '')
.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var (?:hasDontEnumBug|iteratesOwnLast|noArgsEnum).+\n/g, ''); .replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var (?:hasDontEnumBug|iteratesOwnLast|nonEnumArgs).+\n/g, '');
// remove `iteratesOwnLast` from `shimIsPlainObject` // remove `iteratesOwnLast` from `shimIsPlainObject`
source = source.replace(matchFunction(source, 'shimIsPlainObject'), function(match) { source = source.replace(matchFunction(source, 'shimIsPlainObject'), function(match) {
@@ -1835,7 +1982,7 @@
source = removeIsFunctionFallback(source); source = removeIsFunctionFallback(source);
} }
if (isRemoved(source, 'mixin')) { if (isRemoved(source, 'mixin')) {
source = removeVar(source, 'hasObjectSpliceBug'); source = removeHasObjectSpliceBug(source);
// simplify the `lodash` function // simplify the `lodash` function
source = replaceFunction(source, 'lodash', [ source = replaceFunction(source, 'lodash', [
@@ -1847,9 +1994,9 @@
// remove all `lodash.prototype` additions // remove all `lodash.prototype` additions
source = source source = source
.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, '') .replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, '')
.replace(/(?:\s*\/\/.*)*\n( *)forEach\(\['[\s\S]+?\n\1}.+/g, '') .replace(/(?:\s*\/\/.*)*\n( *)each\(\['[\s\S]+?\n\1}.+/g, '')
.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+\n/, '') .replace(/(?:\s*\/\/.*)*\s*lodash\.prototype.+\n/g, '')
.replace(/(?:\s*\/\/.*)*\s*lodash\.prototype.+\n/, ''); .replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+\n/, '');
} }
// assign debug source before further modifications that rely on the minifier // assign debug source before further modifications that rely on the minifier
@@ -1866,6 +2013,7 @@
} }
if (isRemoved(source, 'isPlainObject')) { if (isRemoved(source, 'isPlainObject')) {
source = removeVar(source, 'getPrototypeOf'); source = removeVar(source, 'getPrototypeOf');
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, '');
} }
if (isRemoved(source, 'keys')) { if (isRemoved(source, 'keys')) {
source = removeFunction(source, 'shimKeys'); source = removeFunction(source, 'shimKeys');
@@ -1882,7 +2030,8 @@
} }
if ((source.match(/\bcreateIterator\b/g) || []).length < 2) { if ((source.match(/\bcreateIterator\b/g) || []).length < 2) {
source = removeFunction(source, 'createIterator'); source = removeFunction(source, 'createIterator');
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var noArgsEnum;|.+?noArgsEnum *=.+/g, ''); source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasDontEnumBug;|.+?hasDontEnumBug *=.+/g, '');
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var nonEnumArgs;|.+?nonEnumArgs *=.+/g, '');
} }
if (isRemoved(source, 'createIterator', 'bind', 'keys', 'template')) { if (isRemoved(source, 'createIterator', 'bind', 'keys', 'template')) {
source = removeVar(source, 'isBindFast'); source = removeVar(source, 'isBindFast');
@@ -1891,18 +2040,12 @@
if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'isPlainObject', 'keys', 'template')) { if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'isPlainObject', 'keys', 'template')) {
source = removeVar(source, 'reNative'); source = removeVar(source, 'reNative');
} }
if (isRemoved(source, 'createIterator', 'isEqual')) {
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasDontEnumBug;|.+?hasDontEnumBug *=.+/g, '');
}
if (isRemoved(source, 'createIterator', 'isPlainObject')) {
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, '');
}
if (isRemoved(source, 'createIterator', 'keys')) { if (isRemoved(source, 'createIterator', 'keys')) {
source = removeVar(source, 'nativeKeys'); source = removeVar(source, 'nativeKeys');
source = removeKeysOptimization(source); source = removeKeysOptimization(source);
} }
if (!source.match(/var (?:hasDontEnumBug|iteratesOwnLast|noArgsEnum)\b/g)) { if (!source.match(/var (?:hasDontEnumBug|iteratesOwnLast|nonEnumArgs)\b/g)) {
// remove `hasDontEnumBug`, `iteratesOwnLast`, and `noArgsEnum` assignments // remove `hasDontEnumBug`, `iteratesOwnLast`, and `nonEnumArgs` assignments
source = source.replace(/ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/, ''); source = source.replace(/ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/, '');
} }
} }

View File

@@ -9,11 +9,11 @@
var licenseTemplate = { var licenseTemplate = {
'lodash': 'lodash':
'/*!\n' + '/*!\n' +
' Lo-Dash @VERSION lodash.com/license\n' + ' Lo-Dash <%= VERSION %> lodash.com/license\n' +
' Underscore.js 1.4.3 underscorejs.org/LICENSE\n' + ' Underscore.js 1.4.3 underscorejs.org/LICENSE\n' +
'*/', '*/',
'underscore': 'underscore':
'/*! Underscore.js @VERSION underscorejs.org/LICENSE */' '/*! Underscore.js <%= VERSION %> underscorejs.org/LICENSE */'
}; };
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@@ -32,13 +32,17 @@
// correct overly aggressive Closure Compiler advanced optimizations // correct overly aggressive Closure Compiler advanced optimizations
source = source.replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}'); source = source.replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}');
// unescape properties (i.e. foo["bar"] => foo.bar) // unescape properties (e.g. foo["bar"] => foo.bar)
source = source.replace(/(\w)\["([^."]+)"\]/g, function(match, left, right) { source = source.replace(/(\w)\["([^."]+)"\]/g, function(match, left, right) {
return /\W/.test(right) ? match : (left + '.' + right); return /\W/.test(right) ? match : (left + '.' + right);
}); });
// correct AMD module definition for AMD build optimizers // flip `typeof` expressions to help optimize Safari and
source = source.replace(/("function")\s*==\s*(typeof define)\s*&&\s*\(?\s*("object")\s*==\s*(typeof define\.amd)\s*&&\s*(define\.amd)\s*\)?/, '$2==$1&&$4==$3&&$5'); // correct the AMD module definition for AMD build optimizers
// (e.g. from `"number" == typeof x` to `typeof x == "number")
source = source.replace(/(return)?("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[\w.]+))/g, function(match, ret, type, equality, expression) {
return (ret ? ret + ' ' : '') + expression + equality + type;
});
// add trailing semicolon // add trailing semicolon
if (source) { if (source) {
@@ -51,7 +55,7 @@
} }
// add copyright/license header // add copyright/license header
return licenseTemplate[/call\(this\);?$/.test(source) ? 'underscore' : 'lodash'] return licenseTemplate[/call\(this\);?$/.test(source) ? 'underscore' : 'lodash']
.replace('@VERSION', snippet[2]) + '\n;' + source; .replace('<%= VERSION %>', snippet[2]) + '\n;' + source;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

View File

@@ -20,11 +20,14 @@
var closureId = 'a2787b470c577cee2404d186c562dd9835f779f5'; var closureId = 'a2787b470c577cee2404d186c562dd9835f779f5';
/** The Git object ID of `uglifyjs.tar.gz` */ /** The Git object ID of `uglifyjs.tar.gz` */
var uglifyId = '3390b259e04829538e4d3635d12b317dd6103eca'; var uglifyId = '7ecae09d413eb48dd5785fe877f24e60ac3bbcef';
/** The media type for raw blob data */ /** The media type for raw blob data */
var mediaType = 'application/vnd.github.v3.raw'; var mediaType = 'application/vnd.github.v3.raw';
/** Reassign `existsSync` for older versions of Node */
fs.existsSync || (fs.existsSync = path.existsSync);
/** Used to reference parts of the blob href */ /** Used to reference parts of the blob href */
var location = (function() { var location = (function() {
var host = 'api.github.com', var host = 'api.github.com',
@@ -101,7 +104,8 @@
exec('npm -g root', function(exception, stdout) { exec('npm -g root', function(exception, stdout) {
if (!exception) { if (!exception) {
try { try {
var isGlobal = path.resolve(basePath, '..') == fs.realpathSync(stdout.trim()); var root = stdout.trim(),
isGlobal = fs.existsSync(root) && path.resolve(basePath, '..') == fs.realpathSync(root);
} catch(e) { } catch(e) {
exception = e; exception = e;
} }

View File

@@ -41,7 +41,7 @@
'hasDontEnumBug', 'hasDontEnumBug',
'isKeysFast', 'isKeysFast',
'objectLoop', 'objectLoop',
'noArgsEnum', 'nonEnumArgs',
'noCharByIndex', 'noCharByIndex',
'shadowed', 'shadowed',
'top', 'top',
@@ -68,8 +68,8 @@
'bind', 'bind',
'bindAll', 'bindAll',
'bindKey', 'bindKey',
'chain',
'clone', 'clone',
'cloneDeep',
'collect', 'collect',
'compact', 'compact',
'compose', 'compose',
@@ -188,8 +188,9 @@
'wrap', 'wrap',
'zip', 'zip',
// property used by the `lodash underscore` build // properties used by the `backbone` and `underscore` builds
'__chain__', '__chain__',
'chain',
// properties used by underscore.js // properties used by underscore.js
'_chain', '_chain',

View File

@@ -1,4 +1,4 @@
# Lo-Dash <sup>v1.0.0-rc.2</sup> # Lo-Dash <sup>v1.0.0-rc.3</sup>
<!-- div --> <!-- div -->
@@ -36,9 +36,7 @@
## `Chaining` ## `Chaining`
* [`_`](#_value) * [`_`](#_value)
* [`_.chain`](#_chainvalue)
* [`_.tap`](#_tapvalue-interceptor) * [`_.tap`](#_tapvalue-interceptor)
* [`_.prototype.chain`](#_prototypechain)
* [`_.prototype.toString`](#_prototypetostring) * [`_.prototype.toString`](#_prototypetostring)
* [`_.prototype.value`](#_prototypevalueof) * [`_.prototype.value`](#_prototypevalueof)
* [`_.prototype.valueOf`](#_prototypevalueof) * [`_.prototype.valueOf`](#_prototypevalueof)
@@ -109,6 +107,7 @@
## `Objects` ## `Objects`
* [`_.assign`](#_assignobject--source1-source2-) * [`_.assign`](#_assignobject--source1-source2-)
* [`_.clone`](#_clonevalue-deep) * [`_.clone`](#_clonevalue-deep)
* [`_.cloneDeep`](#_clonedeepvalue)
* [`_.defaults`](#_defaultsobject--default1-default2-) * [`_.defaults`](#_defaultsobject--default1-default2-)
* [`_.extend`](#_assignobject--source1-source2-) * [`_.extend`](#_assignobject--source1-source2-)
* [`_.forIn`](#_forinobject--callbackidentity-thisarg) * [`_.forIn`](#_forinobject--callbackidentity-thisarg)
@@ -187,7 +186,7 @@
<!-- div --> <!-- div -->
### <a id="_compactarray"></a>`_.compact(array)` ### <a id="_compactarray"></a>`_.compact(array)`
<a href="#_compactarray">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2634 "View in source") [&#x24C9;][1] <a href="#_compactarray">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2714 "View in source") [&#x24C9;][1]
Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
@@ -211,7 +210,7 @@ _.compact([0, 1, false, 2, '', 3]);
<!-- div --> <!-- div -->
### <a id="_differencearray--array1-array2-"></a>`_.difference(array [, array1, array2, ...])` ### <a id="_differencearray--array1-array2-"></a>`_.difference(array [, array1, array2, ...])`
<a href="#_differencearray--array1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2664 "View in source") [&#x24C9;][1] <a href="#_differencearray--array1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [&#x24C9;][1]
Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`.
@@ -236,7 +235,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
<!-- div --> <!-- div -->
### <a id="_firstarray--n"></a>`_.first(array [, n])` ### <a id="_firstarray--n"></a>`_.first(array [, n])`
<a href="#_firstarray--n">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2699 "View in source") [&#x24C9;][1] <a href="#_firstarray--n">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2779 "View in source") [&#x24C9;][1]
Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`.
@@ -264,7 +263,7 @@ _.first([5, 4, 3, 2, 1]);
<!-- div --> <!-- div -->
### <a id="_flattenarray-shallow"></a>`_.flatten(array, shallow)` ### <a id="_flattenarray-shallow"></a>`_.flatten(array, shallow)`
<a href="#_flattenarray-shallow">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2726 "View in source") [&#x24C9;][1] <a href="#_flattenarray-shallow">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2806 "View in source") [&#x24C9;][1]
Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level.
@@ -292,7 +291,7 @@ _.flatten([1, [2], [3, [[4]]]], true);
<!-- div --> <!-- div -->
### <a id="_indexofarray-value--fromindex0"></a>`_.indexOf(array, value [, fromIndex=0])` ### <a id="_indexofarray-value--fromindex0"></a>`_.indexOf(array, value [, fromIndex=0])`
<a href="#_indexofarray-value--fromindex0">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2768 "View in source") [&#x24C9;][1] <a href="#_indexofarray-value--fromindex0">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "View in source") [&#x24C9;][1]
Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search.
@@ -324,7 +323,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
<!-- div --> <!-- div -->
### <a id="_initialarray--n1"></a>`_.initial(array [, n=1])` ### <a id="_initialarray--n1"></a>`_.initial(array [, n=1])`
<a href="#_initialarray--n1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2803 "View in source") [&#x24C9;][1] <a href="#_initialarray--n1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2883 "View in source") [&#x24C9;][1]
Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result.
@@ -349,7 +348,7 @@ _.initial([3, 2, 1]);
<!-- div --> <!-- div -->
### <a id="_intersectionarray1-array2-"></a>`_.intersection([array1, array2, ...])` ### <a id="_intersectionarray1-array2-"></a>`_.intersection([array1, array2, ...])`
<a href="#_intersectionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2827 "View in source") [&#x24C9;][1] <a href="#_intersectionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2907 "View in source") [&#x24C9;][1]
Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`.
@@ -357,7 +356,7 @@ Computes the intersection of all the passed-in arrays using strict equality for
1. `[array1, array2, ...]` *(Array)*: Arrays to process. 1. `[array1, array2, ...]` *(Array)*: Arrays to process.
#### Returns #### Returns
*(Array)*: Returns a new array of unique elements, in order, that are present in **all** of the arrays. *(Array)*: Returns a new array of unique elements that are present in **all** of the arrays.
#### Example #### Example
```js ```js
@@ -373,7 +372,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
<!-- div --> <!-- div -->
### <a id="_lastarray--n"></a>`_.last(array [, n])` ### <a id="_lastarray--n"></a>`_.last(array [, n])`
<a href="#_lastarray--n">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2865 "View in source") [&#x24C9;][1] <a href="#_lastarray--n">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2960 "View in source") [&#x24C9;][1]
Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`.
@@ -398,7 +397,7 @@ _.last([3, 2, 1]);
<!-- div --> <!-- div -->
### <a id="_lastindexofarray-value--fromindexarraylength-1"></a>`_.lastIndexOf(array, value [, fromIndex=array.length-1])` ### <a id="_lastindexofarray-value--fromindexarraylength-1"></a>`_.lastIndexOf(array, value [, fromIndex=array.length-1])`
<a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2892 "View in source") [&#x24C9;][1] <a href="#_lastindexofarray-value--fromindexarraylength-1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2987 "View in source") [&#x24C9;][1]
Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection.
@@ -427,7 +426,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
<!-- div --> <!-- div -->
### <a id="_objectkeys--values"></a>`_.object(keys [, values=[]])` ### <a id="_objectkeys--values"></a>`_.object(keys [, values=[]])`
<a href="#_objectkeys--values">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2922 "View in source") [&#x24C9;][1] <a href="#_objectkeys--values">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3017 "View in source") [&#x24C9;][1]
Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`.
@@ -452,7 +451,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]);
<!-- div --> <!-- div -->
### <a id="_rangestart0-end--step1"></a>`_.range([start=0], end [, step=1])` ### <a id="_rangestart0-end--step1"></a>`_.range([start=0], end [, step=1])`
<a href="#_rangestart0-end--step1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2967 "View in source") [&#x24C9;][1] <a href="#_rangestart0-end--step1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3062 "View in source") [&#x24C9;][1]
Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range.
@@ -490,7 +489,7 @@ _.range(0);
<!-- div --> <!-- div -->
### <a id="_restarray--n1"></a>`_.rest(array [, n=1])` ### <a id="_restarray--n1"></a>`_.rest(array [, n=1])`
<a href="#_restarray--n1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3006 "View in source") [&#x24C9;][1] <a href="#_restarray--n1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3101 "View in source") [&#x24C9;][1]
The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result.
@@ -518,7 +517,7 @@ _.rest([3, 2, 1]);
<!-- div --> <!-- div -->
### <a id="_sortedindexarray-value--callbackidentityproperty-thisarg"></a>`_.sortedIndex(array, value [, callback=identity|property, thisArg])` ### <a id="_sortedindexarray-value--callbackidentityproperty-thisarg"></a>`_.sortedIndex(array, value [, callback=identity|property, thisArg])`
<a href="#_sortedindexarray-value--callbackidentityproperty-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3050 "View in source") [&#x24C9;][1] <a href="#_sortedindexarray-value--callbackidentityproperty-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3145 "View in source") [&#x24C9;][1]
Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by.
@@ -562,7 +561,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
<!-- div --> <!-- div -->
### <a id="_unionarray1-array2-"></a>`_.union([array1, array2, ...])` ### <a id="_unionarray1-array2-"></a>`_.union([array1, array2, ...])`
<a href="#_unionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3081 "View in source") [&#x24C9;][1] <a href="#_unionarray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3177 "View in source") [&#x24C9;][1]
Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`.
@@ -586,7 +585,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
<!-- div --> <!-- div -->
### <a id="_uniqarray--issortedfalse-callbackidentity-thisarg"></a>`_.uniq(array [, isSorted=false, callback=identity, thisArg])` ### <a id="_uniqarray--issortedfalse-callbackidentity-thisarg"></a>`_.uniq(array [, isSorted=false, callback=identity, thisArg])`
<a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3115 "View in source") [&#x24C9;][1] <a href="#_uniqarray--issortedfalse-callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3211 "View in source") [&#x24C9;][1]
Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*.
@@ -625,7 +624,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math);
<!-- div --> <!-- div -->
### <a id="_withoutarray--value1-value2-"></a>`_.without(array [, value1, value2, ...])` ### <a id="_withoutarray--value1-value2-"></a>`_.without(array [, value1, value2, ...])`
<a href="#_withoutarray--value1-value2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3173 "View in source") [&#x24C9;][1] <a href="#_withoutarray--value1-value2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3270 "View in source") [&#x24C9;][1]
Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`.
@@ -650,7 +649,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
<!-- div --> <!-- div -->
### <a id="_ziparray1-array2-"></a>`_.zip([array1, array2, ...])` ### <a id="_ziparray1-array2-"></a>`_.zip([array1, array2, ...])`
<a href="#_ziparray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3204 "View in source") [&#x24C9;][1] <a href="#_ziparray1-array2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3301 "View in source") [&#x24C9;][1]
Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion.
@@ -681,9 +680,17 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
<!-- div --> <!-- div -->
### <a id="_value"></a>`_(value)` ### <a id="_value"></a>`_(value)`
<a href="#_value">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L254 "View in source") [&#x24C9;][1] <a href="#_value">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L278 "View in source") [&#x24C9;][1]
The `lodash` function. Creates a `lodash` object, that wraps the given `value`, to enable method chaining.
The chainable wrapper functions are:<br>
`after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip`
The non-chainable wrapper functions are:<br>
`clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId`
The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values.
#### Arguments #### Arguments
1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. 1. `value` *(Mixed)*: The value to wrap in a `lodash` instance.
@@ -696,43 +703,10 @@ The `lodash` function.
<!-- /div --> <!-- /div -->
<!-- div -->
### <a id="_chainvalue"></a>`_.chain(value)`
<a href="#_chainvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4074 "View in source") [&#x24C9;][1]
Wraps the value in a `lodash` wrapper object.
#### Arguments
1. `value` *(Mixed)*: The value to wrap.
#### Returns
*(Object)*: Returns the wrapper object.
#### Example
```js
var stooges = [
{ 'name': 'moe', 'age': 40 },
{ 'name': 'larry', 'age': 50 },
{ 'name': 'curly', 'age': 60 }
];
var youngest = _.chain(stooges)
.sortBy(function(stooge) { return stooge.age; })
.map(function(stooge) { return stooge.name + ' is ' + stooge.age; })
.first();
// => 'moe is 40'
```
* * *
<!-- /div -->
<!-- div --> <!-- div -->
### <a id="_tapvalue-interceptor"></a>`_.tap(value, interceptor)` ### <a id="_tapvalue-interceptor"></a>`_.tap(value, interceptor)`
<a href="#_tapvalue-interceptor">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4099 "View in source") [&#x24C9;][1] <a href="#_tapvalue-interceptor">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4168 "View in source") [&#x24C9;][1]
Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.
@@ -759,32 +733,10 @@ _.chain([1, 2, 3, 200])
<!-- /div --> <!-- /div -->
<!-- div -->
### <a id="_prototypechain"></a>`_.prototype.chain()`
<a href="#_prototypechain">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4122 "View in source") [&#x24C9;][1]
This function returns the wrapper object. Note: This function is defined to ensure the existing wrapper object is returned, instead of creating a new wrapper object like the `_.chain` method does.
#### Returns
*(Mixed)*: Returns the wrapper object.
#### Example
```js
var wrapped = _([1, 2, 3]);
wrapped === wrapped.chain();
// => true
```
* * *
<!-- /div -->
<!-- div --> <!-- div -->
### <a id="_prototypetostring"></a>`_.prototype.toString()` ### <a id="_prototypetostring"></a>`_.prototype.toString()`
<a href="#_prototypetostring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4138 "View in source") [&#x24C9;][1] <a href="#_prototypetostring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4185 "View in source") [&#x24C9;][1]
Produces the `toString` result of the wrapped value. Produces the `toString` result of the wrapped value.
@@ -805,7 +757,7 @@ _([1, 2, 3]).toString();
<!-- div --> <!-- div -->
### <a id="_prototypevalueof"></a>`_.prototype.valueOf()` ### <a id="_prototypevalueof"></a>`_.prototype.valueOf()`
<a href="#_prototypevalueof">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4155 "View in source") [&#x24C9;][1] <a href="#_prototypevalueof">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4202 "View in source") [&#x24C9;][1]
Extracts the wrapped value. Extracts the wrapped value.
@@ -836,7 +788,7 @@ _([1, 2, 3]).valueOf();
<!-- div --> <!-- div -->
### <a id="_containscollection-target--fromindex0"></a>`_.contains(collection, target [, fromIndex=0])` ### <a id="_containscollection-target--fromindex0"></a>`_.contains(collection, target [, fromIndex=0])`
<a href="#_containscollection-target--fromindex0">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1904 "View in source") [&#x24C9;][1] <a href="#_containscollection-target--fromindex0">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1953 "View in source") [&#x24C9;][1]
Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection.
@@ -874,7 +826,7 @@ _.contains('curly', 'ur');
<!-- div --> <!-- div -->
### <a id="_countbycollection-callbackproperty--thisarg"></a>`_.countBy(collection, callback|property [, thisArg])` ### <a id="_countbycollection-callbackproperty--thisarg"></a>`_.countBy(collection, callback|property [, thisArg])`
<a href="#_countbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1951 "View in source") [&#x24C9;][1] <a href="#_countbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2000 "View in source") [&#x24C9;][1]
Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*.
@@ -906,7 +858,7 @@ _.countBy(['one', 'two', 'three'], 'length');
<!-- div --> <!-- div -->
### <a id="_everycollection--callbackidentity-thisarg"></a>`_.every(collection [, callback=identity, thisArg])` ### <a id="_everycollection--callbackidentity-thisarg"></a>`_.every(collection [, callback=identity, thisArg])`
<a href="#_everycollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1980 "View in source") [&#x24C9;][1] <a href="#_everycollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2030 "View in source") [&#x24C9;][1]
Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
@@ -935,7 +887,7 @@ _.every([true, 1, null, 'yes'], Boolean);
<!-- div --> <!-- div -->
### <a id="_filtercollection--callbackidentity-thisarg"></a>`_.filter(collection [, callback=identity, thisArg])` ### <a id="_filtercollection--callbackidentity-thisarg"></a>`_.filter(collection [, callback=identity, thisArg])`
<a href="#_filtercollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2019 "View in source") [&#x24C9;][1] <a href="#_filtercollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2069 "View in source") [&#x24C9;][1]
Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
@@ -964,7 +916,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; })
<!-- div --> <!-- div -->
### <a id="_findcollection--callbackidentity-thisarg"></a>`_.find(collection [, callback=identity, thisArg])` ### <a id="_findcollection--callbackidentity-thisarg"></a>`_.find(collection [, callback=identity, thisArg])`
<a href="#_findcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2063 "View in source") [&#x24C9;][1] <a href="#_findcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2113 "View in source") [&#x24C9;][1]
Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
@@ -993,7 +945,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
<!-- div --> <!-- div -->
### <a id="_foreachcollection--callbackidentity-thisarg"></a>`_.forEach(collection [, callback=identity, thisArg])` ### <a id="_foreachcollection--callbackidentity-thisarg"></a>`_.forEach(collection [, callback=identity, thisArg])`
<a href="#_foreachcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2097 "View in source") [&#x24C9;][1] <a href="#_foreachcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2148 "View in source") [&#x24C9;][1]
Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`.
@@ -1025,7 +977,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
<!-- div --> <!-- div -->
### <a id="_groupbycollection-callbackproperty--thisarg"></a>`_.groupBy(collection, callback|property [, thisArg])` ### <a id="_groupbycollection-callbackproperty--thisarg"></a>`_.groupBy(collection, callback|property [, thisArg])`
<a href="#_groupbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2125 "View in source") [&#x24C9;][1] <a href="#_groupbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2190 "View in source") [&#x24C9;][1]
Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*.
@@ -1057,7 +1009,7 @@ _.groupBy(['one', 'two', 'three'], 'length');
<!-- div --> <!-- div -->
### <a id="_invokecollection-methodname--arg1-arg2-"></a>`_.invoke(collection, methodName [, arg1, arg2, ...])` ### <a id="_invokecollection-methodname--arg1-arg2-"></a>`_.invoke(collection, methodName [, arg1, arg2, ...])`
<a href="#_invokecollection-methodname--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2157 "View in source") [&#x24C9;][1] <a href="#_invokecollection-methodname--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2223 "View in source") [&#x24C9;][1]
Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`.
@@ -1086,7 +1038,7 @@ _.invoke([123, 456], String.prototype.split, '');
<!-- div --> <!-- div -->
### <a id="_mapcollection--callbackidentity-thisarg"></a>`_.map(collection [, callback=identity, thisArg])` ### <a id="_mapcollection--callbackidentity-thisarg"></a>`_.map(collection [, callback=identity, thisArg])`
<a href="#_mapcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2189 "View in source") [&#x24C9;][1] <a href="#_mapcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2255 "View in source") [&#x24C9;][1]
Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
@@ -1118,7 +1070,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
<!-- div --> <!-- div -->
### <a id="_maxcollection--callback-thisarg"></a>`_.max(collection [, callback, thisArg])` ### <a id="_maxcollection--callback-thisarg"></a>`_.max(collection [, callback, thisArg])`
<a href="#_maxcollection--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2231 "View in source") [&#x24C9;][1] <a href="#_maxcollection--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2297 "View in source") [&#x24C9;][1]
Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*.
@@ -1150,7 +1102,7 @@ _.max(stooges, function(stooge) { return stooge.age; });
<!-- div --> <!-- div -->
### <a id="_mincollection--callback-thisarg"></a>`_.min(collection [, callback, thisArg])` ### <a id="_mincollection--callback-thisarg"></a>`_.min(collection [, callback, thisArg])`
<a href="#_mincollection--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2277 "View in source") [&#x24C9;][1] <a href="#_mincollection--callback-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2343 "View in source") [&#x24C9;][1]
Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*.
@@ -1176,7 +1128,7 @@ _.min([10, 5, 100, 2, 1000]);
<!-- div --> <!-- div -->
### <a id="_pluckcollection-property"></a>`_.pluck(collection, property)` ### <a id="_pluckcollection-property"></a>`_.pluck(collection, property)`
<a href="#_pluckcollection-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2326 "View in source") [&#x24C9;][1] <a href="#_pluckcollection-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2392 "View in source") [&#x24C9;][1]
Retrieves the value of a specified property from all elements in the `collection`. Retrieves the value of a specified property from all elements in the `collection`.
@@ -1207,7 +1159,7 @@ _.pluck(stooges, 'name');
<!-- div --> <!-- div -->
### <a id="_reducecollection--callbackidentity-accumulator-thisarg"></a>`_.reduce(collection [, callback=identity, accumulator, thisArg])` ### <a id="_reducecollection--callbackidentity-accumulator-thisarg"></a>`_.reduce(collection [, callback=identity, accumulator, thisArg])`
<a href="#_reducecollection--callbackidentity-accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2350 "View in source") [&#x24C9;][1] <a href="#_reducecollection--callbackidentity-accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2416 "View in source") [&#x24C9;][1]
Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*.
@@ -1237,7 +1189,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; });
<!-- div --> <!-- div -->
### <a id="_reducerightcollection--callbackidentity-accumulator-thisarg"></a>`_.reduceRight(collection [, callback=identity, accumulator, thisArg])` ### <a id="_reducerightcollection--callbackidentity-accumulator-thisarg"></a>`_.reduceRight(collection [, callback=identity, accumulator, thisArg])`
<a href="#_reducerightcollection--callbackidentity-accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2379 "View in source") [&#x24C9;][1] <a href="#_reducerightcollection--callbackidentity-accumulator-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2458 "View in source") [&#x24C9;][1]
The right-associative version of `_.reduce`. The right-associative version of `_.reduce`.
@@ -1268,7 +1220,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
<!-- div --> <!-- div -->
### <a id="_rejectcollection--callbackidentity-thisarg"></a>`_.reject(collection [, callback=identity, thisArg])` ### <a id="_rejectcollection--callbackidentity-thisarg"></a>`_.reject(collection [, callback=identity, thisArg])`
<a href="#_rejectcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2417 "View in source") [&#x24C9;][1] <a href="#_rejectcollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2496 "View in source") [&#x24C9;][1]
The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for.
@@ -1294,7 +1246,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
<!-- div --> <!-- div -->
### <a id="_shufflecollection"></a>`_.shuffle(collection)` ### <a id="_shufflecollection"></a>`_.shuffle(collection)`
<a href="#_shufflecollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2438 "View in source") [&#x24C9;][1] <a href="#_shufflecollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2517 "View in source") [&#x24C9;][1]
Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
@@ -1318,7 +1270,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]);
<!-- div --> <!-- div -->
### <a id="_sizecollection"></a>`_.size(collection)` ### <a id="_sizecollection"></a>`_.size(collection)`
<a href="#_sizecollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2470 "View in source") [&#x24C9;][1] <a href="#_sizecollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2549 "View in source") [&#x24C9;][1]
Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects.
@@ -1348,7 +1300,7 @@ _.size('curly');
<!-- div --> <!-- div -->
### <a id="_somecollection--callbackidentity-thisarg"></a>`_.some(collection [, callback=identity, thisArg])` ### <a id="_somecollection--callbackidentity-thisarg"></a>`_.some(collection [, callback=identity, thisArg])`
<a href="#_somecollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2495 "View in source") [&#x24C9;][1] <a href="#_somecollection--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2574 "View in source") [&#x24C9;][1]
Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*.
@@ -1377,7 +1329,7 @@ _.some([null, 0, 'yes', false], Boolean);
<!-- div --> <!-- div -->
### <a id="_sortbycollection-callbackproperty--thisarg"></a>`_.sortBy(collection, callback|property [, thisArg])` ### <a id="_sortbycollection-callbackproperty--thisarg"></a>`_.sortBy(collection, callback|property [, thisArg])`
<a href="#_sortbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2541 "View in source") [&#x24C9;][1] <a href="#_sortbycollection-callbackproperty--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2620 "View in source") [&#x24C9;][1]
Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*.
@@ -1409,7 +1361,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length');
<!-- div --> <!-- div -->
### <a id="_toarraycollection"></a>`_.toArray(collection)` ### <a id="_toarraycollection"></a>`_.toArray(collection)`
<a href="#_toarraycollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2573 "View in source") [&#x24C9;][1] <a href="#_toarraycollection">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [&#x24C9;][1]
Converts the `collection` to an array. Converts the `collection` to an array.
@@ -1433,7 +1385,7 @@ Converts the `collection` to an array.
<!-- div --> <!-- div -->
### <a id="_wherecollection-properties"></a>`_.where(collection, properties)` ### <a id="_wherecollection-properties"></a>`_.where(collection, properties)`
<a href="#_wherecollection-properties">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2604 "View in source") [&#x24C9;][1] <a href="#_wherecollection-properties">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2684 "View in source") [&#x24C9;][1]
Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. Examines each element in a `collection`, returning an array of all elements that contain the given `properties`.
@@ -1471,7 +1423,7 @@ _.where(stooges, { 'age': 40 });
<!-- div --> <!-- div -->
### <a id="_aftern-func"></a>`_.after(n, func)` ### <a id="_aftern-func"></a>`_.after(n, func)`
<a href="#_aftern-func">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3237 "View in source") [&#x24C9;][1] <a href="#_aftern-func">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3334 "View in source") [&#x24C9;][1]
Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function.
@@ -1499,7 +1451,7 @@ _.forEach(notes, function(note) {
<!-- div --> <!-- div -->
### <a id="_bindfunc--thisarg-arg1-arg2-"></a>`_.bind(func [, thisArg, arg1, arg2, ...])` ### <a id="_bindfunc--thisarg-arg1-arg2-"></a>`_.bind(func [, thisArg, arg1, arg2, ...])`
<a href="#_bindfunc--thisarg-arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3270 "View in source") [&#x24C9;][1] <a href="#_bindfunc--thisarg-arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3367 "View in source") [&#x24C9;][1]
Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function.
@@ -1530,7 +1482,7 @@ func();
<!-- div --> <!-- div -->
### <a id="_bindallobject--methodname1-methodname2-"></a>`_.bindAll(object [, methodName1, methodName2, ...])` ### <a id="_bindallobject--methodname1-methodname2-"></a>`_.bindAll(object [, methodName1, methodName2, ...])`
<a href="#_bindallobject--methodname1-methodname2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3300 "View in source") [&#x24C9;][1] <a href="#_bindallobject--methodname1-methodname2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3397 "View in source") [&#x24C9;][1]
Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound.
@@ -1561,7 +1513,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick);
<!-- div --> <!-- div -->
### <a id="_bindkeyobject-key--arg1-arg2-"></a>`_.bindKey(object, key [, arg1, arg2, ...])` ### <a id="_bindkeyobject-key--arg1-arg2-"></a>`_.bindKey(object, key [, arg1, arg2, ...])`
<a href="#_bindkeyobject-key--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3346 "View in source") [&#x24C9;][1] <a href="#_bindkeyobject-key--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3443 "View in source") [&#x24C9;][1]
Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern.
@@ -1602,7 +1554,7 @@ func();
<!-- div --> <!-- div -->
### <a id="_composefunc1-func2-"></a>`_.compose([func1, func2, ...])` ### <a id="_composefunc1-func2-"></a>`_.compose([func1, func2, ...])`
<a href="#_composefunc1-func2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3369 "View in source") [&#x24C9;][1] <a href="#_composefunc1-func2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3466 "View in source") [&#x24C9;][1]
Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function.
@@ -1629,7 +1581,7 @@ welcome('moe');
<!-- div --> <!-- div -->
### <a id="_debouncefunc-wait-immediate"></a>`_.debounce(func, wait, immediate)` ### <a id="_debouncefunc-wait-immediate"></a>`_.debounce(func, wait, immediate)`
<a href="#_debouncefunc-wait-immediate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3402 "View in source") [&#x24C9;][1] <a href="#_debouncefunc-wait-immediate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3499 "View in source") [&#x24C9;][1]
Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call.
@@ -1655,7 +1607,7 @@ jQuery(window).on('resize', lazyLayout);
<!-- div --> <!-- div -->
### <a id="_deferfunc--arg1-arg2-"></a>`_.defer(func [, arg1, arg2, ...])` ### <a id="_deferfunc--arg1-arg2-"></a>`_.defer(func [, arg1, arg2, ...])`
<a href="#_deferfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3466 "View in source") [&#x24C9;][1] <a href="#_deferfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3563 "View in source") [&#x24C9;][1]
Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked.
@@ -1680,7 +1632,7 @@ _.defer(function() { alert('deferred'); });
<!-- div --> <!-- div -->
### <a id="_delayfunc-wait--arg1-arg2-"></a>`_.delay(func, wait [, arg1, arg2, ...])` ### <a id="_delayfunc-wait--arg1-arg2-"></a>`_.delay(func, wait [, arg1, arg2, ...])`
<a href="#_delayfunc-wait--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3446 "View in source") [&#x24C9;][1] <a href="#_delayfunc-wait--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3543 "View in source") [&#x24C9;][1]
Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked.
@@ -1707,7 +1659,7 @@ _.delay(log, 1000, 'logged later');
<!-- div --> <!-- div -->
### <a id="_memoizefunc--resolver"></a>`_.memoize(func [, resolver])` ### <a id="_memoizefunc--resolver"></a>`_.memoize(func [, resolver])`
<a href="#_memoizefunc--resolver">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3490 "View in source") [&#x24C9;][1] <a href="#_memoizefunc--resolver">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3587 "View in source") [&#x24C9;][1]
Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function.
@@ -1733,7 +1685,7 @@ var fibonacci = _.memoize(function(n) {
<!-- div --> <!-- div -->
### <a id="_oncefunc"></a>`_.once(func)` ### <a id="_oncefunc"></a>`_.once(func)`
<a href="#_oncefunc">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3517 "View in source") [&#x24C9;][1] <a href="#_oncefunc">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3614 "View in source") [&#x24C9;][1]
Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function.
@@ -1759,7 +1711,7 @@ initialize();
<!-- div --> <!-- div -->
### <a id="_partialfunc--arg1-arg2-"></a>`_.partial(func [, arg1, arg2, ...])` ### <a id="_partialfunc--arg1-arg2-"></a>`_.partial(func [, arg1, arg2, ...])`
<a href="#_partialfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3552 "View in source") [&#x24C9;][1] <a href="#_partialfunc--arg1-arg2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3649 "View in source") [&#x24C9;][1]
Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding.
@@ -1786,7 +1738,7 @@ hi('moe');
<!-- div --> <!-- div -->
### <a id="_throttlefunc-wait"></a>`_.throttle(func, wait)` ### <a id="_throttlefunc-wait"></a>`_.throttle(func, wait)`
<a href="#_throttlefunc-wait">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3574 "View in source") [&#x24C9;][1] <a href="#_throttlefunc-wait">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [&#x24C9;][1]
Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call.
@@ -1811,7 +1763,7 @@ jQuery(window).on('scroll', throttled);
<!-- div --> <!-- div -->
### <a id="_wrapvalue-wrapper"></a>`_.wrap(value, wrapper)` ### <a id="_wrapvalue-wrapper"></a>`_.wrap(value, wrapper)`
<a href="#_wrapvalue-wrapper">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3627 "View in source") [&#x24C9;][1] <a href="#_wrapvalue-wrapper">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3724 "View in source") [&#x24C9;][1]
Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function.
@@ -1847,7 +1799,7 @@ hello();
<!-- div --> <!-- div -->
### <a id="_assignobject--source1-source2-"></a>`_.assign(object [, source1, source2, ...])` ### <a id="_assignobject--source1-source2-"></a>`_.assign(object [, source1, source2, ...])`
<a href="#_assignobject--source1-source2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L786 "View in source") [&#x24C9;][1] <a href="#_assignobject--source1-source2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L813 "View in source") [&#x24C9;][1]
Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources.
@@ -1875,9 +1827,9 @@ _.assign({ 'name': 'moe' }, { 'age': 40 });
<!-- div --> <!-- div -->
### <a id="_clonevalue-deep"></a>`_.clone(value, deep)` ### <a id="_clonevalue-deep"></a>`_.clone(value, deep)`
<a href="#_clonevalue-deep">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L985 "View in source") [&#x24C9;][1] <a href="#_clonevalue-deep">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1003 "View in source") [&#x24C9;][1]
Creates a clone of `value`. If `deep` is `true`, all nested objects will also be cloned, otherwise they will be assigned by reference. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm. See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference.
#### Arguments #### Arguments
1. `value` *(Mixed)*: The value to clone. 1. `value` *(Mixed)*: The value to clone.
@@ -1894,9 +1846,6 @@ var stooges = [
{ 'name': 'curly', 'age': 60 } { 'name': 'curly', 'age': 60 }
]; ];
_.clone({ 'name': 'moe' });
// => { 'name': 'moe' }
var shallow = _.clone(stooges); var shallow = _.clone(stooges);
shallow[0] === stooges[0]; shallow[0] === stooges[0];
// => true // => true
@@ -1911,10 +1860,43 @@ deep[0] === stooges[0];
<!-- /div --> <!-- /div -->
<!-- div -->
### <a id="_clonedeepvalue"></a>`_.cloneDeep(value)`
<a href="#_clonedeepvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1098 "View in source") [&#x24C9;][1]
Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects.
Note: This function is loosely based on the structured clone algorithm. See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm.
#### Arguments
1. `value` *(Mixed)*: The value to deep clone.
#### Returns
*(Mixed)*: Returns the deep cloned `value`.
#### Example
```js
var stooges = [
{ 'name': 'moe', 'age': 40 },
{ 'name': 'larry', 'age': 50 },
{ 'name': 'curly', 'age': 60 }
];
var deep = _.cloneDeep(stooges);
deep[0] === stooges[0];
// => false
```
* * *
<!-- /div -->
<!-- div --> <!-- div -->
### <a id="_defaultsobject--default1-default2-"></a>`_.defaults(object [, default1, default2, ...])` ### <a id="_defaultsobject--default1-default2-"></a>`_.defaults(object [, default1, default2, ...])`
<a href="#_defaultsobject--default1-default2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1073 "View in source") [&#x24C9;][1] <a href="#_defaultsobject--default1-default2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1120 "View in source") [&#x24C9;][1]
Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored.
@@ -1940,7 +1922,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' });
<!-- div --> <!-- div -->
### <a id="_forinobject--callbackidentity-thisarg"></a>`_.forIn(object [, callback=identity, thisArg])` ### <a id="_forinobject--callbackidentity-thisarg"></a>`_.forIn(object [, callback=identity, thisArg])`
<a href="#_forinobject--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L842 "View in source") [&#x24C9;][1] <a href="#_forinobject--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L869 "View in source") [&#x24C9;][1]
Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`.
@@ -1976,7 +1958,7 @@ _.forIn(new Dog('Dagny'), function(value, key) {
<!-- div --> <!-- div -->
### <a id="_forownobject--callbackidentity-thisarg"></a>`_.forOwn(object [, callback=identity, thisArg])` ### <a id="_forownobject--callbackidentity-thisarg"></a>`_.forOwn(object [, callback=identity, thisArg])`
<a href="#_forownobject--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L866 "View in source") [&#x24C9;][1] <a href="#_forownobject--callbackidentity-thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L893 "View in source") [&#x24C9;][1]
Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`.
@@ -2004,7 +1986,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
<!-- div --> <!-- div -->
### <a id="_functionsobject"></a>`_.functions(object)` ### <a id="_functionsobject"></a>`_.functions(object)`
<a href="#_functionsobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1092 "View in source") [&#x24C9;][1] <a href="#_functionsobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1139 "View in source") [&#x24C9;][1]
Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values.
@@ -2031,7 +2013,7 @@ _.functions(_);
<!-- div --> <!-- div -->
### <a id="_hasobject-property"></a>`_.has(object, property)` ### <a id="_hasobject-property"></a>`_.has(object, property)`
<a href="#_hasobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1117 "View in source") [&#x24C9;][1] <a href="#_hasobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1164 "View in source") [&#x24C9;][1]
Checks if the specified object `property` exists and is a direct property, instead of an inherited property. Checks if the specified object `property` exists and is a direct property, instead of an inherited property.
@@ -2056,7 +2038,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
<!-- div --> <!-- div -->
### <a id="_invertobject"></a>`_.invert(object)` ### <a id="_invertobject"></a>`_.invert(object)`
<a href="#_invertobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1134 "View in source") [&#x24C9;][1] <a href="#_invertobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1181 "View in source") [&#x24C9;][1]
Creates an object composed of the inverted keys and values of the given `object`. Creates an object composed of the inverted keys and values of the given `object`.
@@ -2080,7 +2062,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' });
<!-- div --> <!-- div -->
### <a id="_isargumentsvalue"></a>`_.isArguments(value)` ### <a id="_isargumentsvalue"></a>`_.isArguments(value)`
<a href="#_isargumentsvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L804 "View in source") [&#x24C9;][1] <a href="#_isargumentsvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L831 "View in source") [&#x24C9;][1]
Checks if `value` is an `arguments` object. Checks if `value` is an `arguments` object.
@@ -2107,7 +2089,7 @@ _.isArguments([1, 2, 3]);
<!-- div --> <!-- div -->
### <a id="_isarrayvalue"></a>`_.isArray(value)` ### <a id="_isarrayvalue"></a>`_.isArray(value)`
<a href="#_isarrayvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1158 "View in source") [&#x24C9;][1] <a href="#_isarrayvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1205 "View in source") [&#x24C9;][1]
Checks if `value` is an array. Checks if `value` is an array.
@@ -2134,7 +2116,7 @@ _.isArray([1, 2, 3]);
<!-- div --> <!-- div -->
### <a id="_isbooleanvalue"></a>`_.isBoolean(value)` ### <a id="_isbooleanvalue"></a>`_.isBoolean(value)`
<a href="#_isbooleanvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1175 "View in source") [&#x24C9;][1] <a href="#_isbooleanvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1224 "View in source") [&#x24C9;][1]
Checks if `value` is a boolean *(`true` or `false`)* value. Checks if `value` is a boolean *(`true` or `false`)* value.
@@ -2158,7 +2140,7 @@ _.isBoolean(null);
<!-- div --> <!-- div -->
### <a id="_isdatevalue"></a>`_.isDate(value)` ### <a id="_isdatevalue"></a>`_.isDate(value)`
<a href="#_isdatevalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1192 "View in source") [&#x24C9;][1] <a href="#_isdatevalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1241 "View in source") [&#x24C9;][1]
Checks if `value` is a date. Checks if `value` is a date.
@@ -2182,7 +2164,7 @@ _.isDate(new Date);
<!-- div --> <!-- div -->
### <a id="_iselementvalue"></a>`_.isElement(value)` ### <a id="_iselementvalue"></a>`_.isElement(value)`
<a href="#_iselementvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1209 "View in source") [&#x24C9;][1] <a href="#_iselementvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1258 "View in source") [&#x24C9;][1]
Checks if `value` is a DOM element. Checks if `value` is a DOM element.
@@ -2206,7 +2188,7 @@ _.isElement(document.body);
<!-- div --> <!-- div -->
### <a id="_isemptyvalue"></a>`_.isEmpty(value)` ### <a id="_isemptyvalue"></a>`_.isEmpty(value)`
<a href="#_isemptyvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1234 "View in source") [&#x24C9;][1] <a href="#_isemptyvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [&#x24C9;][1]
Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty".
@@ -2236,7 +2218,7 @@ _.isEmpty('');
<!-- div --> <!-- div -->
### <a id="_isequala-b"></a>`_.isEqual(a, b)` ### <a id="_isequala-b"></a>`_.isEqual(a, b)`
<a href="#_isequala-b">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1276 "View in source") [&#x24C9;][1] <a href="#_isequala-b">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1325 "View in source") [&#x24C9;][1]
Performs a deep comparison between two values to determine if they are equivalent to each other. Performs a deep comparison between two values to determine if they are equivalent to each other.
@@ -2267,9 +2249,11 @@ _.isEqual(moe, clone);
<!-- div --> <!-- div -->
### <a id="_isfinitevalue"></a>`_.isFinite(value)` ### <a id="_isfinitevalue"></a>`_.isFinite(value)`
<a href="#_isfinitevalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1428 "View in source") [&#x24C9;][1] <a href="#_isfinitevalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1477 "View in source") [&#x24C9;][1]
Checks if `value` is, or can be coerced to, a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. Checks if `value` is, or can be coerced to, a finite number.
Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5.
#### Arguments #### Arguments
1. `value` *(Mixed)*: The value to check. 1. `value` *(Mixed)*: The value to check.
@@ -2303,7 +2287,7 @@ _.isFinite(Infinity);
<!-- div --> <!-- div -->
### <a id="_isfunctionvalue"></a>`_.isFunction(value)` ### <a id="_isfunctionvalue"></a>`_.isFunction(value)`
<a href="#_isfunctionvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1445 "View in source") [&#x24C9;][1] <a href="#_isfunctionvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1494 "View in source") [&#x24C9;][1]
Checks if `value` is a function. Checks if `value` is a function.
@@ -2327,9 +2311,11 @@ _.isFunction(_);
<!-- div --> <!-- div -->
### <a id="_isnanvalue"></a>`_.isNaN(value)` ### <a id="_isnanvalue"></a>`_.isNaN(value)`
<a href="#_isnanvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1508 "View in source") [&#x24C9;][1] <a href="#_isnanvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1557 "View in source") [&#x24C9;][1]
Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. Checks if `value` is `NaN`.
Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4.
#### Arguments #### Arguments
1. `value` *(Mixed)*: The value to check. 1. `value` *(Mixed)*: The value to check.
@@ -2360,7 +2346,7 @@ _.isNaN(undefined);
<!-- div --> <!-- div -->
### <a id="_isnullvalue"></a>`_.isNull(value)` ### <a id="_isnullvalue"></a>`_.isNull(value)`
<a href="#_isnullvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1530 "View in source") [&#x24C9;][1] <a href="#_isnullvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1579 "View in source") [&#x24C9;][1]
Checks if `value` is `null`. Checks if `value` is `null`.
@@ -2387,7 +2373,7 @@ _.isNull(undefined);
<!-- div --> <!-- div -->
### <a id="_isnumbervalue"></a>`_.isNumber(value)` ### <a id="_isnumbervalue"></a>`_.isNumber(value)`
<a href="#_isnumbervalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1547 "View in source") [&#x24C9;][1] <a href="#_isnumbervalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1596 "View in source") [&#x24C9;][1]
Checks if `value` is a number. Checks if `value` is a number.
@@ -2411,7 +2397,7 @@ _.isNumber(8.4 * 5);
<!-- div --> <!-- div -->
### <a id="_isobjectvalue"></a>`_.isObject(value)` ### <a id="_isobjectvalue"></a>`_.isObject(value)`
<a href="#_isobjectvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1475 "View in source") [&#x24C9;][1] <a href="#_isobjectvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1524 "View in source") [&#x24C9;][1]
Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)*
@@ -2441,7 +2427,7 @@ _.isObject(1);
<!-- div --> <!-- div -->
### <a id="_isplainobjectvalue"></a>`_.isPlainObject(value)` ### <a id="_isplainobjectvalue"></a>`_.isPlainObject(value)`
<a href="#_isplainobjectvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1575 "View in source") [&#x24C9;][1] <a href="#_isplainobjectvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1624 "View in source") [&#x24C9;][1]
Checks if a given `value` is an object created by the `Object` constructor. Checks if a given `value` is an object created by the `Object` constructor.
@@ -2476,7 +2462,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 });
<!-- div --> <!-- div -->
### <a id="_isregexpvalue"></a>`_.isRegExp(value)` ### <a id="_isregexpvalue"></a>`_.isRegExp(value)`
<a href="#_isregexpvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1600 "View in source") [&#x24C9;][1] <a href="#_isregexpvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [&#x24C9;][1]
Checks if `value` is a regular expression. Checks if `value` is a regular expression.
@@ -2500,7 +2486,7 @@ _.isRegExp(/moe/);
<!-- div --> <!-- div -->
### <a id="_isstringvalue"></a>`_.isString(value)` ### <a id="_isstringvalue"></a>`_.isString(value)`
<a href="#_isstringvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1617 "View in source") [&#x24C9;][1] <a href="#_isstringvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1666 "View in source") [&#x24C9;][1]
Checks if `value` is a string. Checks if `value` is a string.
@@ -2524,7 +2510,7 @@ _.isString('moe');
<!-- div --> <!-- div -->
### <a id="_isundefinedvalue"></a>`_.isUndefined(value)` ### <a id="_isundefinedvalue"></a>`_.isUndefined(value)`
<a href="#_isundefinedvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1634 "View in source") [&#x24C9;][1] <a href="#_isundefinedvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1683 "View in source") [&#x24C9;][1]
Checks if `value` is `undefined`. Checks if `value` is `undefined`.
@@ -2548,7 +2534,7 @@ _.isUndefined(void 0);
<!-- div --> <!-- div -->
### <a id="_keysobject"></a>`_.keys(object)` ### <a id="_keysobject"></a>`_.keys(object)`
<a href="#_keysobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1651 "View in source") [&#x24C9;][1] <a href="#_keysobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1700 "View in source") [&#x24C9;][1]
Creates an array composed of the own enumerable property names of `object`. Creates an array composed of the own enumerable property names of `object`.
@@ -2572,7 +2558,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 });
<!-- div --> <!-- div -->
### <a id="_mergeobject--source1-source2-"></a>`_.merge(object [, source1, source2, ...])` ### <a id="_mergeobject--source1-source2-"></a>`_.merge(object [, source1, source2, ...])`
<a href="#_mergeobject--source1-source2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1689 "View in source") [&#x24C9;][1] <a href="#_mergeobject--source1-source2-">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1738 "View in source") [&#x24C9;][1]
Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources.
@@ -2607,7 +2593,7 @@ _.merge(stooges, ages);
<!-- div --> <!-- div -->
### <a id="_omitobject-callback-prop1-prop2--thisarg"></a>`_.omit(object, callback|[prop1, prop2, ..., thisArg])` ### <a id="_omitobject-callback-prop1-prop2--thisarg"></a>`_.omit(object, callback|[prop1, prop2, ..., thisArg])`
<a href="#_omitobject-callback-prop1-prop2--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1763 "View in source") [&#x24C9;][1] <a href="#_omitobject-callback-prop1-prop2--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1812 "View in source") [&#x24C9;][1]
Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*.
@@ -2638,7 +2624,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va
<!-- div --> <!-- div -->
### <a id="_pairsobject"></a>`_.pairs(object)` ### <a id="_pairsobject"></a>`_.pairs(object)`
<a href="#_pairsobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1797 "View in source") [&#x24C9;][1] <a href="#_pairsobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1846 "View in source") [&#x24C9;][1]
Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`.
@@ -2662,7 +2648,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 });
<!-- div --> <!-- div -->
### <a id="_pickobject-callback-prop1-prop2--thisarg"></a>`_.pick(object, callback|[prop1, prop2, ..., thisArg])` ### <a id="_pickobject-callback-prop1-prop2--thisarg"></a>`_.pick(object, callback|[prop1, prop2, ..., thisArg])`
<a href="#_pickobject-callback-prop1-prop2--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1830 "View in source") [&#x24C9;][1] <a href="#_pickobject-callback-prop1-prop2--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1879 "View in source") [&#x24C9;][1]
Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*.
@@ -2693,7 +2679,7 @@ _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va
<!-- div --> <!-- div -->
### <a id="_valuesobject"></a>`_.values(object)` ### <a id="_valuesobject"></a>`_.values(object)`
<a href="#_valuesobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1867 "View in source") [&#x24C9;][1] <a href="#_valuesobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1916 "View in source") [&#x24C9;][1]
Creates an array composed of the own enumerable property values of `object`. Creates an array composed of the own enumerable property values of `object`.
@@ -2724,7 +2710,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 });
<!-- div --> <!-- div -->
### <a id="_escapestring"></a>`_.escape(string)` ### <a id="_escapestring"></a>`_.escape(string)`
<a href="#_escapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3651 "View in source") [&#x24C9;][1] <a href="#_escapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3748 "View in source") [&#x24C9;][1]
Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities.
@@ -2748,9 +2734,9 @@ _.escape('Moe, Larry & Curly');
<!-- div --> <!-- div -->
### <a id="_identityvalue"></a>`_.identity(value)` ### <a id="_identityvalue"></a>`_.identity(value)`
<a href="#_identityvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [&#x24C9;][1] <a href="#_identityvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3766 "View in source") [&#x24C9;][1]
This function returns the first argument passed to it. Note: This function is used throughout Lo-Dash as a default callback. This function returns the first argument passed to it.
#### Arguments #### Arguments
1. `value` *(Mixed)*: Any value. 1. `value` *(Mixed)*: Any value.
@@ -2773,7 +2759,7 @@ moe === _.identity(moe);
<!-- div --> <!-- div -->
### <a id="_mixinobject"></a>`_.mixin(object)` ### <a id="_mixinobject"></a>`_.mixin(object)`
<a href="#_mixinobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3697 "View in source") [&#x24C9;][1] <a href="#_mixinobject">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3792 "View in source") [&#x24C9;][1]
Adds functions properties of `object` to the `lodash` function and chainable wrapper. Adds functions properties of `object` to the `lodash` function and chainable wrapper.
@@ -2803,7 +2789,7 @@ _('curly').capitalize();
<!-- div --> <!-- div -->
### <a id="_noconflict"></a>`_.noConflict()` ### <a id="_noconflict"></a>`_.noConflict()`
<a href="#_noconflict">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3723 "View in source") [&#x24C9;][1] <a href="#_noconflict">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3818 "View in source") [&#x24C9;][1]
Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. Reverts the '_' variable to its previous value and returns a reference to the `lodash` function.
@@ -2823,7 +2809,7 @@ var lodash = _.noConflict();
<!-- div --> <!-- div -->
### <a id="_randommin0-max1"></a>`_.random([min=0, max=1])` ### <a id="_randommin0-max1"></a>`_.random([min=0, max=1])`
<a href="#_randommin0-max1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3746 "View in source") [&#x24C9;][1] <a href="#_randommin0-max1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3841 "View in source") [&#x24C9;][1]
Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned.
@@ -2851,7 +2837,7 @@ _.random(5);
<!-- div --> <!-- div -->
### <a id="_resultobject-property"></a>`_.result(object, property)` ### <a id="_resultobject-property"></a>`_.result(object, property)`
<a href="#_resultobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3784 "View in source") [&#x24C9;][1] <a href="#_resultobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3879 "View in source") [&#x24C9;][1]
Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned.
@@ -2886,9 +2872,13 @@ _.result(object, 'stuff');
<!-- div --> <!-- div -->
### <a id="_templatetext-data-options"></a>`_.template(text, data, options)` ### <a id="_templatetext-data-options"></a>`_.template(text, data, options)`
<a href="#_templatetext-data-options">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3869 "View in source") [&#x24C9;][1] <a href="#_templatetext-data-options">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3964 "View in source") [&#x24C9;][1]
A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code.
Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html
#### Arguments #### Arguments
1. `text` *(String)*: The template text. 1. `text` *(String)*: The template text.
@@ -2960,7 +2950,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\
<!-- div --> <!-- div -->
### <a id="_timesn-callback--thisarg"></a>`_.times(n, callback [, thisArg])` ### <a id="_timesn-callback--thisarg"></a>`_.times(n, callback [, thisArg])`
<a href="#_timesn-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4000 "View in source") [&#x24C9;][1] <a href="#_timesn-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4095 "View in source") [&#x24C9;][1]
Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*.
@@ -2992,7 +2982,7 @@ _.times(3, function(n) { this.cast(n); }, mage);
<!-- div --> <!-- div -->
### <a id="_unescapestring"></a>`_.unescape(string)` ### <a id="_unescapestring"></a>`_.unescape(string)`
<a href="#_unescapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4026 "View in source") [&#x24C9;][1] <a href="#_unescapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4121 "View in source") [&#x24C9;][1]
The opposite of `_.escape`, this method converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#x27;` in `string` to their corresponding characters. The opposite of `_.escape`, this method converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#x27;` in `string` to their corresponding characters.
@@ -3016,7 +3006,7 @@ _.unescape('Moe, Larry &amp; Curly');
<!-- div --> <!-- div -->
### <a id="_uniqueidprefix"></a>`_.uniqueId([prefix])` ### <a id="_uniqueidprefix"></a>`_.uniqueId([prefix])`
<a href="#_uniqueidprefix">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4046 "View in source") [&#x24C9;][1] <a href="#_uniqueidprefix">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4141 "View in source") [&#x24C9;][1]
Generates a unique ID. If `prefix` is passed, the ID will be appended to it. Generates a unique ID. If `prefix` is passed, the ID will be appended to it.
@@ -3050,7 +3040,7 @@ _.uniqueId();
<!-- div --> <!-- div -->
### <a id="_version"></a>`_.VERSION` ### <a id="_version"></a>`_.VERSION`
<a href="#_version">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4318 "View in source") [&#x24C9;][1] <a href="#_version">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4366 "View in source") [&#x24C9;][1]
*(String)*: The semantic version number. *(String)*: The semantic version number.
@@ -3062,7 +3052,7 @@ _.uniqueId();
<!-- div --> <!-- div -->
### <a id="_templatesettings"></a>`_.templateSettings` ### <a id="_templatesettings"></a>`_.templateSettings`
<a href="#_templatesettings">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L275 "View in source") [&#x24C9;][1] <a href="#_templatesettings">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L299 "View in source") [&#x24C9;][1]
*(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters.
@@ -3074,7 +3064,7 @@ _.uniqueId();
<!-- div --> <!-- div -->
### <a id="_templatesettingsescape"></a>`_.templateSettings.escape` ### <a id="_templatesettingsescape"></a>`_.templateSettings.escape`
<a href="#_templatesettingsescape">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L284 "View in source") [&#x24C9;][1] <a href="#_templatesettingsescape">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L308 "View in source") [&#x24C9;][1]
*(RegExp)*: Used to detect `data` property values to be HTML-escaped. *(RegExp)*: Used to detect `data` property values to be HTML-escaped.
@@ -3086,7 +3076,7 @@ _.uniqueId();
<!-- div --> <!-- div -->
### <a id="_templatesettingsevaluate"></a>`_.templateSettings.evaluate` ### <a id="_templatesettingsevaluate"></a>`_.templateSettings.evaluate`
<a href="#_templatesettingsevaluate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L293 "View in source") [&#x24C9;][1] <a href="#_templatesettingsevaluate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L317 "View in source") [&#x24C9;][1]
*(RegExp)*: Used to detect code to be evaluated. *(RegExp)*: Used to detect code to be evaluated.
@@ -3098,7 +3088,7 @@ _.uniqueId();
<!-- div --> <!-- div -->
### <a id="_templatesettingsinterpolate"></a>`_.templateSettings.interpolate` ### <a id="_templatesettingsinterpolate"></a>`_.templateSettings.interpolate`
<a href="#_templatesettingsinterpolate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L302 "View in source") [&#x24C9;][1] <a href="#_templatesettingsinterpolate">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L326 "View in source") [&#x24C9;][1]
*(RegExp)*: Used to detect `data` property values to inject. *(RegExp)*: Used to detect `data` property values to inject.
@@ -3110,7 +3100,7 @@ _.uniqueId();
<!-- div --> <!-- div -->
### <a id="_templatesettingsvariable"></a>`_.templateSettings.variable` ### <a id="_templatesettingsvariable"></a>`_.templateSettings.variable`
<a href="#_templatesettingsvariable">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L311 "View in source") [&#x24C9;][1] <a href="#_templatesettingsvariable">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L335 "View in source") [&#x24C9;][1]
*(String)*: Used to reference the data object in the template text. *(String)*: Used to reference the data object in the template text.

View File

@@ -21,7 +21,7 @@
// generate Markdown // generate Markdown
$markdown = docdown(array( $markdown = docdown(array(
'path' => '../' . $file, 'path' => '../' . $file,
'title' => 'Lo-Dash <sup>v1.0.0-rc.2</sup>', 'title' => 'Lo-Dash <sup>v1.0.0-rc.3</sup>',
'toc' => 'categories', 'toc' => 'categories',
'url' => 'https://github.com/bestiejs/lodash/blob/master/lodash.js' 'url' => 'https://github.com/bestiejs/lodash/blob/master/lodash.js'
)); ));

397
lodash.js
View File

@@ -1,5 +1,5 @@
/*! /*!
* Lo-Dash 1.0.0-rc.2 <http://lodash.com> * Lo-Dash 1.0.0-rc.3 <http://lodash.com>
* (c) 2012 John-David Dalton <http://allyoucanleet.com/> * (c) 2012 John-David Dalton <http://allyoucanleet.com/>
* Based on Underscore.js 1.4.3 <http://underscorejs.org> * Based on Underscore.js 1.4.3 <http://underscorejs.org>
* (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. * (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
@@ -116,8 +116,7 @@
stringClass = '[object String]'; stringClass = '[object String]';
/** Detect various environments */ /** Detect various environments */
var isFirefox = !/1/.test(Function('1')), var isIeOpera = !!window.attachEvent,
isIeOpera = !!window.attachEvent,
isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera); isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera);
/* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */ /* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */
@@ -151,20 +150,23 @@
arrayRef.splice.call(hasObjectSpliceBug, 0, 1), hasObjectSpliceBug[0]); arrayRef.splice.call(hasObjectSpliceBug, 0, 1), hasObjectSpliceBug[0]);
/** Detect if an `arguments` object's indexes are non-enumerable (IE < 9) */ /** Detect if an `arguments` object's indexes are non-enumerable (IE < 9) */
var noArgsEnum = true; var nonEnumArgs = true;
(function() { (function() {
var props = []; var props = [];
function ctor() { this.x = 1; } function ctor() { this.x = 1; }
ctor.prototype = { 'valueOf': 1, 'y': 1 }; ctor.prototype = { 'valueOf': 1, 'y': 1 };
for (var prop in new ctor) { props.push(prop); } for (var prop in new ctor) { props.push(prop); }
for (prop in arguments) { noArgsEnum = !prop; } for (prop in arguments) { nonEnumArgs = !prop; }
hasDontEnumBug = !/valueOf/.test(props); hasDontEnumBug = !/valueOf/.test(props);
iteratesOwnLast = props[0] != 'x'; iteratesOwnLast = props[0] != 'x';
}(1)); }(1));
/** Detect if an `arguments` object's [[Class]] is unresolvable (Firefox < 4, IE < 9) */ /** Detect if `arguments` objects are `Object` objects (all but Opera < 10.5) */
var argsAreObjects = arguments.constructor == Object;
/** Detect if `arguments` objects [[Class]] is unresolvable (Firefox < 4, IE < 9) */
var noArgsClass = !isArguments(arguments); var noArgsClass = !isArguments(arguments);
/** /**
@@ -243,7 +245,29 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/** /**
* The `lodash` function. * Creates a `lodash` object, that wraps the given `value`, to enable
* method chaining.
*
* The chainable wrapper functions are:
* `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`,
* `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`,
* `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`,
* `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`,
* `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`,
* `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
* `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`,
* `unshift`, `values`, `where`, `without`, `wrap`, and `zip`
*
* The non-chainable wrapper functions are:
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`,
* `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`,
* `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`,
* `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`,
* `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`,
* `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId`
*
* The wrapper functions `first` and `last` return wrapped values when `n` is
* passed, otherwise they return unwrapped values.
* *
* @name _ * @name _
* @constructor * @constructor
@@ -313,25 +337,6 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/**
* Creates a function from the given `args` and `body` strings.
*
* @private
* @param {String} args The comma separated function arguments.
* @param {String} body The function body.
* @returns {Function} The new function.
*/
function createFunction(args, body) {
// the newline, in `'\n}'`, is required to avoid errors if `body` ends
// with a single line comment
return window.eval('(function(' + args + ') {' + body + '\n})');
}
// use `eval` to avoid Firefox's unoptimized `Function` constructor
// http://bugzil.la/804933
if (isIeOpera || isV8 || !isFirefox) {
createFunction = Function;
}
/** /**
* The template used to create iterator functions. * The template used to create iterator functions.
* *
@@ -373,7 +378,7 @@
// object iteration: // object iteration:
// add support for iterating over `arguments` objects if needed // add support for iterating over `arguments` objects if needed
' <% } else if (noArgsEnum) { %>\n' + ' <% } else if (nonEnumArgs) { %>\n' +
' var length = iteratee.length; index = -1;\n' + ' var length = iteratee.length; index = -1;\n' +
' if (length && isArguments(iteratee)) {\n' + ' if (length && isArguments(iteratee)) {\n' +
' while (++index < length) {\n' + ' while (++index < length) {\n' +
@@ -436,7 +441,7 @@
' }' + ' }' +
' <% } %>' + ' <% } %>' +
' <% } %>' + ' <% } %>' +
' <% if (arrayLoop || noArgsEnum) { %>\n}<% } %>\n' + ' <% if (arrayLoop || nonEnumArgs) { %>\n}<% } %>\n' +
// add code to the bottom of the iteration function // add code to the bottom of the iteration function
'<%= bottom %>;\n' + '<%= bottom %>;\n' +
@@ -455,9 +460,9 @@
}; };
/** /**
* Reusable iterator options shared by `forEach`, `forIn`, and `forOwn`. * Reusable iterator options shared by `each`, `forIn`, and `forOwn`.
*/ */
var forEachIteratorOptions = { var eachIteratorOptions = {
'args': 'collection, callback, thisArg', 'args': 'collection, callback, thisArg',
'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)", 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)",
'arrayLoop': 'if (callback(iteratee[index], index, collection) === false) return result', 'arrayLoop': 'if (callback(iteratee[index], index, collection) === false) return result',
@@ -611,9 +616,11 @@
* @param {Function|String} [func=identity|property] The function called per * @param {Function|String} [func=identity|property] The function called per
* iteration or property name to query. * iteration or property name to query.
* @param {Mixed} [thisArg] The `this` binding of `callback`. * @param {Mixed} [thisArg] The `this` binding of `callback`.
* @param {Object} [accumulating] Used to indicate that the callback should
* accept an `accumulator` argument.
* @returns {Function} Returns a callback function. * @returns {Function} Returns a callback function.
*/ */
function createCallback(func, thisArg) { function createCallback(func, thisArg, accumulating) {
if (!func) { if (!func) {
return identity; return identity;
} }
@@ -623,6 +630,11 @@
}; };
} }
if (typeof thisArg != 'undefined') { if (typeof thisArg != 'undefined') {
if (accumulating) {
return function(accumulator, value, index, object) {
return func.call(thisArg, accumulator, value, index, object);
};
}
return function(value, index, object) { return function(value, index, object) {
return func.call(thisArg, value, index, object); return func.call(thisArg, value, index, object);
}; };
@@ -651,7 +663,7 @@
'hasDontEnumBug': hasDontEnumBug, 'hasDontEnumBug': hasDontEnumBug,
'isKeysFast': isKeysFast, 'isKeysFast': isKeysFast,
'objectLoop': '', 'objectLoop': '',
'noArgsEnum': noArgsEnum, 'nonEnumArgs': nonEnumArgs,
'noCharByIndex': noCharByIndex, 'noCharByIndex': noCharByIndex,
'shadowed': shadowed, 'shadowed': shadowed,
'top': '', 'top': '',
@@ -668,7 +680,7 @@
data.firstArg = /^[^,]+/.exec(args)[0]; data.firstArg = /^[^,]+/.exec(args)[0];
// create the function factory // create the function factory
var factory = createFunction( var factory = Function(
'createCallback, hasOwnProperty, isArguments, isString, objectTypes, ' + 'createCallback, hasOwnProperty, isArguments, isString, objectTypes, ' +
'nativeKeys, propertyIsEnumerable', 'nativeKeys, propertyIsEnumerable',
'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}' 'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}'
@@ -680,6 +692,21 @@
); );
} }
/**
* A function compiled to iterate `arguments` objects, arrays, objects, and
* strings consistenly across environments, executing the `callback` for each
* element in the `collection`. The `callback` is bound to `thisArg` and invoked
* with three arguments; (value, index|key, collection). Callbacks may exit
* iteration early by explicitly returning `false`.
*
* @private
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback=identity] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding of `callback`.
* @returns {Array|Object|String} Returns `collection`.
*/
var each = createIterator(eachIteratorOptions);
/** /**
* Used by `template` to escape characters for inclusion in compiled * Used by `template` to escape characters for inclusion in compiled
* string literals. * string literals.
@@ -839,7 +866,7 @@
* }); * });
* // => alerts 'name' and 'bark' (order is not guaranteed) * // => alerts 'name' and 'bark' (order is not guaranteed)
*/ */
var forIn = createIterator(forEachIteratorOptions, forOwnIteratorOptions, { var forIn = createIterator(eachIteratorOptions, forOwnIteratorOptions, {
'useHas': false 'useHas': false
}); });
@@ -863,7 +890,7 @@
* }); * });
* // => alerts '0', '1', and 'length' (order is not guaranteed) * // => alerts '0', '1', and 'length' (order is not guaranteed)
*/ */
var forOwn = createIterator(forEachIteratorOptions, forOwnIteratorOptions); var forOwn = createIterator(eachIteratorOptions, forOwnIteratorOptions);
/** /**
* A fallback implementation of `isPlainObject` that checks if a given `value` * A fallback implementation of `isPlainObject` that checks if a given `value`
@@ -943,14 +970,8 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/** /**
* Creates a clone of `value`. If `deep` is `true`, all nested objects will * Creates a clone of `value`. If `deep` is `true`, nested objects will also
* also be cloned, otherwise they will be assigned by reference. Functions and * be cloned, otherwise they will be assigned by reference.
* DOM nodes are **not** cloned. The enumerable properties of `arguments` objects
* and objects created by constructors other than `Object` are cloned to plain
* `Object` objects.
*
* Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm.
* See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -971,9 +992,6 @@
* { 'name': 'curly', 'age': 60 } * { 'name': 'curly', 'age': 60 }
* ]; * ];
* *
* _.clone({ 'name': 'moe' });
* // => { 'name': 'moe' }
*
* var shallow = _.clone(stooges); * var shallow = _.clone(stooges);
* shallow[0] === stooges[0]; * shallow[0] === stooges[0];
* // => true * // => true
@@ -1052,6 +1070,35 @@
return result; return result;
} }
/**
* Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned.
* The enumerable properties of `arguments` objects and objects created by
* constructors other than `Object` are cloned to plain `Object` objects.
*
* Note: This function is loosely based on the structured clone algorithm.
* See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm.
*
* @static
* @memberOf _
* @category Objects
* @param {Mixed} value The value to deep clone.
* @returns {Mixed} Returns the deep cloned `value`.
* @example
*
* var stooges = [
* { 'name': 'moe', 'age': 40 },
* { 'name': 'larry', 'age': 50 },
* { 'name': 'curly', 'age': 60 }
* ];
*
* var deep = _.cloneDeep(stooges);
* deep[0] === stooges[0];
* // => false
*/
function cloneDeep(value) {
return clone(value, true);
}
/** /**
* Assigns own enumerable properties of source object(s) to the `destination` * Assigns own enumerable properties of source object(s) to the `destination`
* object for all `destination` properties that resolve to `null`/`undefined`. * object for all `destination` properties that resolve to `null`/`undefined`.
@@ -1156,7 +1203,9 @@
* // => true * // => true
*/ */
var isArray = nativeIsArray || function(value) { var isArray = nativeIsArray || function(value) {
return toString.call(value) == arrayClass; // `instanceof` may cause a memory leak in IE 7 if `value` is a host object
// http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
return (argsAreObjects && value instanceof Array) || toString.call(value) == arrayClass;
}; };
/** /**
@@ -1190,7 +1239,7 @@
* // => true * // => true
*/ */
function isDate(value) { function isDate(value) {
return toString.call(value) == dateClass; return value instanceof Date || toString.call(value) == dateClass;
} }
/** /**
@@ -1327,8 +1376,8 @@
return false; return false;
} }
// in older versions of Opera, `arguments` objects have `Array` constructors // in older versions of Opera, `arguments` objects have `Array` constructors
var ctorA = noArgsClass && isArguments(a) ? Object : a.constructor, var ctorA = !argsAreObjects && isArguments(a) ? Object : a.constructor,
ctorB = noArgsClass && isArguments(b) ? Object : b.constructor; ctorB = !argsAreObjects && isArguments(b) ? Object : b.constructor;
// non `Object` object instances with different constructors are not equal // non `Object` object instances with different constructors are not equal
if (ctorA != ctorB && !( if (ctorA != ctorB && !(
@@ -1448,7 +1497,7 @@
// fallback for older versions of Chrome and Safari // fallback for older versions of Chrome and Safari
if (isFunction(/x/)) { if (isFunction(/x/)) {
isFunction = function(value) { isFunction = function(value) {
return toString.call(value) == funcClass; return value instanceof Function || toString.call(value) == funcClass;
}; };
} }
@@ -1598,7 +1647,7 @@
* // => true * // => true
*/ */
function isRegExp(value) { function isRegExp(value) {
return toString.call(value) == regexpClass; return value instanceof RegExp || toString.call(value) == regexpClass;
} }
/** /**
@@ -1913,7 +1962,7 @@
: indexOf(collection, target, fromIndex) : indexOf(collection, target, fromIndex)
) > -1; ) > -1;
} else { } else {
forEach(collection, function(value) { each(collection, function(value) {
if (++index >= fromIndex) { if (++index >= fromIndex) {
return !(result = value === target); return !(result = value === target);
} }
@@ -1951,6 +2000,7 @@
function countBy(collection, callback, thisArg) { function countBy(collection, callback, thisArg) {
var result = {}; var result = {};
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, key, collection) { forEach(collection, function(value, key, collection) {
key = callback(value, key, collection); key = callback(value, key, collection);
(hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1);
@@ -1991,7 +2041,7 @@
} }
} }
} else { } else {
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
return (result = !!callback(value, index, collection)); return (result = !!callback(value, index, collection));
}); });
} }
@@ -2031,7 +2081,7 @@
} }
} }
} else { } else {
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
if (callback(value, index, collection)) { if (callback(value, index, collection)) {
result.push(value); result.push(value);
} }
@@ -2063,6 +2113,7 @@
function find(collection, callback, thisArg) { function find(collection, callback, thisArg) {
var result; var result;
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { forEach(collection, function(value, index, collection) {
if (callback(value, index, collection)) { if (callback(value, index, collection)) {
result = value; result = value;
@@ -2094,7 +2145,21 @@
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
* // => alerts each number value (order is not guaranteed) * // => alerts each number value (order is not guaranteed)
*/ */
var forEach = createIterator(forEachIteratorOptions); function forEach(collection, callback, thisArg) {
if (callback && typeof thisArg == 'undefined' && isArray(collection)) {
var index = -1,
length = collection.length;
while (++index < length) {
if (callback(collection[index], index, collection) === false) {
break;
}
}
} else {
each(collection, callback, thisArg);
}
return collection;
}
/** /**
* Creates an object composed of keys returned from running each element of * Creates an object composed of keys returned from running each element of
@@ -2125,6 +2190,7 @@
function groupBy(collection, callback, thisArg) { function groupBy(collection, callback, thisArg) {
var result = {}; var result = {};
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, key, collection) { forEach(collection, function(value, key, collection) {
key = callback(value, key, collection); key = callback(value, key, collection);
(hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value);
@@ -2197,7 +2263,7 @@
result[index] = callback(collection[index], index, collection); result[index] = callback(collection[index], index, collection);
} }
} else { } else {
forEach(collection, function(value, key, collection) { each(collection, function(value, key, collection) {
result[++index] = callback(value, key, collection); result[++index] = callback(value, key, collection);
}); });
} }
@@ -2239,7 +2305,7 @@
? charAtCallback ? charAtCallback
: createCallback(callback, thisArg); : createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
var current = callback(value, index, collection); var current = callback(value, index, collection);
if (current > computed) { if (current > computed) {
computed = current; computed = current;
@@ -2285,7 +2351,7 @@
? charAtCallback ? charAtCallback
: createCallback(callback, thisArg); : createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
var current = callback(value, index, collection); var current = callback(value, index, collection);
if (current < computed) { if (current < computed) {
computed = current; computed = current;
@@ -2349,12 +2415,25 @@
*/ */
function reduce(collection, callback, accumulator, thisArg) { function reduce(collection, callback, accumulator, thisArg) {
var noaccum = arguments.length < 3; var noaccum = arguments.length < 3;
callback || (callback = identity); callback = createCallback(callback, thisArg, indicatorObject);
forEach(collection, function(value, index, collection) {
accumulator = noaccum if (isArray(collection)) {
? (noaccum = false, value) var index = -1,
: callback.call(thisArg, accumulator, value, index, collection) length = collection.length;
});
if (noaccum) {
accumulator = collection[++index];
}
while (++index < length) {
accumulator = callback(accumulator, collection[index], index, collection);
}
} else {
each(collection, function(value, index, collection) {
accumulator = noaccum
? (noaccum = false, value)
: callback(accumulator, value, index, collection)
});
}
return accumulator; return accumulator;
} }
@@ -2387,12 +2466,12 @@
} else if (noCharByIndex && isString(collection)) { } else if (noCharByIndex && isString(collection)) {
iteratee = collection.split(''); iteratee = collection.split('');
} }
callback || (callback = identity); callback = createCallback(callback, thisArg, indicatorObject);
forEach(collection, function(value, index, collection) { forEach(collection, function(value, index, collection) {
index = props ? props[--length] : --length; index = props ? props[--length] : --length;
accumulator = noaccum accumulator = noaccum
? (noaccum = false, iteratee[index]) ? (noaccum = false, iteratee[index])
: callback.call(thisArg, accumulator, iteratee[index], index, collection); : callback(accumulator, iteratee[index], index, collection);
}); });
return accumulator; return accumulator;
} }
@@ -2506,7 +2585,7 @@
} }
} }
} else { } else {
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
return !(result = callback(value, index, collection)); return !(result = callback(value, index, collection));
}); });
} }
@@ -2541,6 +2620,7 @@
function sortBy(collection, callback, thisArg) { function sortBy(collection, callback, thisArg) {
var result = []; var result = [];
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { forEach(collection, function(value, index, collection) {
result.push({ result.push({
'criteria': callback(value, index, collection), 'criteria': callback(value, index, collection),
@@ -2817,8 +2897,8 @@
* @memberOf _ * @memberOf _
* @category Arrays * @category Arrays
* @param {Array} [array1, array2, ...] Arrays to process. * @param {Array} [array1, array2, ...] Arrays to process.
* @returns {Array} Returns a new array of unique elements, in order, that are * @returns {Array} Returns a new array of unique elements that are present
* present in **all** of the arrays. * in **all** of the arrays.
* @example * @example
* *
* _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); * _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
@@ -2827,20 +2907,35 @@
function intersection(array) { function intersection(array) {
var args = arguments, var args = arguments,
argsLength = args.length, argsLength = args.length,
cache = {}, cache = { '0': {} },
result = []; index = -1,
length = array ? array.length : 0,
isLarge = length >= 100,
result = [],
seen = result;
forEach(array, function(value) { outer:
if (indexOf(result, value) < 0) { while (++index < length) {
var length = argsLength; var value = array[index];
while (--length) { if (isLarge) {
if (!(cache[length] || (cache[length] = cachedContains(args[length])))(value)) { var key = value + '';
return; var inited = hasOwnProperty.call(cache[0], key)
? !(seen = cache[0][key])
: (seen = cache[0][key] = []);
}
if (inited || indexOf(seen, value) < 0) {
if (isLarge) {
seen.push(value);
}
var argsIndex = argsLength;
while (--argsIndex) {
if (!(cache[argsIndex] || (cache[argsIndex] = cachedContains(args[argsIndex], 0, 100)))(value)) {
continue outer;
} }
} }
result.push(value); result.push(value);
} }
}); }
return result; return result;
} }
@@ -3051,9 +3146,10 @@
var low = 0, var low = 0,
high = array ? array.length : low; high = array ? array.length : low;
// explicitly reference `identity` for better engine inlining // explicitly reference `identity` for better inlining in Firefox
callback = callback ? createCallback(callback, thisArg) : identity; callback = callback ? createCallback(callback, thisArg) : identity;
value = callback(value); value = callback(value);
while (low < high) { while (low < high) {
var mid = (low + high) >>> 1; var mid = (low + high) >>> 1;
callback(array[mid]) < value callback(array[mid]) < value
@@ -3125,7 +3221,7 @@
isSorted = false; isSorted = false;
} }
// init value cache for large arrays // init value cache for large arrays
var isLarge = !isSorted && length > 74; var isLarge = !isSorted && length >= 75;
if (isLarge) { if (isLarge) {
var cache = {}; var cache = {};
} }
@@ -3138,13 +3234,14 @@
computed = callback ? callback(value, index, array) : value; computed = callback ? callback(value, index, array) : value;
if (isLarge) { if (isLarge) {
// manually coerce `computed` to a string because `hasOwnProperty`, in var key = computed + '';
// some older versions of Firefox, coerces objects incorrectly var inited = hasOwnProperty.call(cache, key)
seen = hasOwnProperty.call(cache, computed + '') ? cache[computed] : (cache[computed] = []); ? !(seen = cache[key])
: (seen = cache[key] = []);
} }
if (isSorted if (isSorted
? !index || seen[seen.length - 1] !== computed ? !index || seen[seen.length - 1] !== computed
: indexOf(seen, computed) < 0 : inited || indexOf(seen, computed) < 0
) { ) {
if (callback || isLarge) { if (callback || isLarge) {
seen.push(computed); seen.push(computed);
@@ -3655,8 +3752,6 @@
/** /**
* This function returns the first argument passed to it. * This function returns the first argument passed to it.
* *
* Note: This function is used throughout Lo-Dash as a default callback.
*
* @static * @static
* @memberOf _ * @memberOf _
* @category Utilities * @category Utilities
@@ -3958,7 +4053,7 @@
: ''; : '';
try { try {
result = createFunction('_', 'return ' + source + sourceURL)(lodash); result = Function('_', 'return ' + source + sourceURL)(lodash);
} catch(e) { } catch(e) {
e.source = source; e.source = source;
throw e; throw e;
@@ -4049,32 +4144,6 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/**
* Wraps the value in a `lodash` wrapper object.
*
* @static
* @memberOf _
* @category Chaining
* @param {Mixed} value The value to wrap.
* @returns {Object} Returns the wrapper object.
* @example
*
* var stooges = [
* { 'name': 'moe', 'age': 40 },
* { 'name': 'larry', 'age': 50 },
* { 'name': 'curly', 'age': 60 }
* ];
*
* var youngest = _.chain(stooges)
* .sortBy(function(stooge) { return stooge.age; })
* .map(function(stooge) { return stooge.name + ' is ' + stooge.age; })
* .first();
* // => 'moe is 40'
*/
function chain(value) {
return new lodash(value);
}
/** /**
* Invokes `interceptor` with the `value` as the first argument, and then * Invokes `interceptor` with the `value` as the first argument, and then
* returns `value`. The purpose of this method is to "tap into" a method chain, * returns `value`. The purpose of this method is to "tap into" a method chain,
@@ -4101,28 +4170,6 @@
return value; return value;
} }
/**
* This function returns the wrapper object.
*
* Note: This function is defined to ensure the existing wrapper object is
* returned, instead of creating a new wrapper object like the `_.chain`
* method does.
*
* @name chain
* @deprecated
* @memberOf _
* @category Chaining
* @returns {Mixed} Returns the wrapper object.
* @example
*
* var wrapped = _([1, 2, 3]);
* wrapped === wrapped.chain();
* // => true
*/
function wrapperChain() {
return this;
}
/** /**
* Produces the `toString` result of the wrapped value. * Produces the `toString` result of the wrapped value.
* *
@@ -4136,7 +4183,7 @@
* // => '1,2,3' * // => '1,2,3'
*/ */
function wrapperToString() { function wrapperToString() {
return String(this.__wrapped__); return this.__wrapped__ + '';
} }
/** /**
@@ -4159,12 +4206,18 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
// add functions that return wrapped values when chaining // add functions that return wrapped values when chaining
lodash.after = after;
lodash.assign = assign; lodash.assign = assign;
lodash.bind = bind;
lodash.bindAll = bindAll; lodash.bindAll = bindAll;
lodash.chain = chain; lodash.bindKey = bindKey;
lodash.compact = compact; lodash.compact = compact;
lodash.compose = compose;
lodash.countBy = countBy; lodash.countBy = countBy;
lodash.debounce = debounce;
lodash.defaults = defaults; lodash.defaults = defaults;
lodash.defer = defer;
lodash.delay = delay;
lodash.difference = difference; lodash.difference = difference;
lodash.filter = filter; lodash.filter = filter;
lodash.flatten = flatten; lodash.flatten = flatten;
@@ -4180,11 +4233,14 @@
lodash.keys = keys; lodash.keys = keys;
lodash.map = map; lodash.map = map;
lodash.max = max; lodash.max = max;
lodash.memoize = memoize;
lodash.merge = merge; lodash.merge = merge;
lodash.min = min; lodash.min = min;
lodash.object = object; lodash.object = object;
lodash.omit = omit; lodash.omit = omit;
lodash.once = once;
lodash.pairs = pairs; lodash.pairs = pairs;
lodash.partial = partial;
lodash.pick = pick; lodash.pick = pick;
lodash.pluck = pluck; lodash.pluck = pluck;
lodash.range = range; lodash.range = range;
@@ -4193,6 +4249,7 @@
lodash.shuffle = shuffle; lodash.shuffle = shuffle;
lodash.sortBy = sortBy; lodash.sortBy = sortBy;
lodash.tap = tap; lodash.tap = tap;
lodash.throttle = throttle;
lodash.times = times; lodash.times = times;
lodash.toArray = toArray; lodash.toArray = toArray;
lodash.union = union; lodash.union = union;
@@ -4200,6 +4257,7 @@
lodash.values = values; lodash.values = values;
lodash.where = where; lodash.where = where;
lodash.without = without; lodash.without = without;
lodash.wrap = wrap;
lodash.zip = zip; lodash.zip = zip;
// add aliases // add aliases
@@ -4218,15 +4276,9 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
// add functions that return unwrapped values when chaining // add functions that return unwrapped values when chaining
lodash.after = after;
lodash.bind = bind;
lodash.bindKey = bindKey;
lodash.clone = clone; lodash.clone = clone;
lodash.compose = compose; lodash.cloneDeep = cloneDeep;
lodash.contains = contains; lodash.contains = contains;
lodash.debounce = debounce;
lodash.defer = defer;
lodash.delay = delay;
lodash.escape = escape; lodash.escape = escape;
lodash.every = every; lodash.every = every;
lodash.find = find; lodash.find = find;
@@ -4251,11 +4303,8 @@
lodash.isString = isString; lodash.isString = isString;
lodash.isUndefined = isUndefined; lodash.isUndefined = isUndefined;
lodash.lastIndexOf = lastIndexOf; lodash.lastIndexOf = lastIndexOf;
lodash.memoize = memoize;
lodash.mixin = mixin; lodash.mixin = mixin;
lodash.noConflict = noConflict; lodash.noConflict = noConflict;
lodash.once = once;
lodash.partial = partial;
lodash.random = random; lodash.random = random;
lodash.reduce = reduce; lodash.reduce = reduce;
lodash.reduceRight = reduceRight; lodash.reduceRight = reduceRight;
@@ -4264,10 +4313,8 @@
lodash.some = some; lodash.some = some;
lodash.sortedIndex = sortedIndex; lodash.sortedIndex = sortedIndex;
lodash.template = template; lodash.template = template;
lodash.throttle = throttle;
lodash.unescape = unescape; lodash.unescape = unescape;
lodash.uniqueId = uniqueId; lodash.uniqueId = uniqueId;
lodash.wrap = wrap;
// add aliases // add aliases
lodash.all = every; lodash.all = every;
@@ -4316,42 +4363,60 @@
* @memberOf _ * @memberOf _
* @type String * @type String
*/ */
lodash.VERSION = '1.0.0-rc.2'; lodash.VERSION = '1.0.0-rc.3';
// add "Chaining" functions to the wrapper // add "Chaining" functions to the wrapper
lodash.prototype.chain = wrapperChain;
lodash.prototype.toString = wrapperToString; lodash.prototype.toString = wrapperToString;
lodash.prototype.value = wrapperValueOf; lodash.prototype.value = wrapperValueOf;
lodash.prototype.valueOf = wrapperValueOf; lodash.prototype.valueOf = wrapperValueOf;
// add mutator `Array` functions to the wrapper // add `Array` functions that return unwrapped values
forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { each(['join', 'pop', 'shift'], function(methodName) {
var func = arrayRef[methodName]; var func = arrayRef[methodName];
lodash.prototype[methodName] = function() { lodash.prototype[methodName] = function() {
var value = this.__wrapped__; return func.apply(this.__wrapped__, arguments);
func.apply(value, arguments); };
});
// avoid array-like object bugs with `Array#shift` and `Array#splice` // add `Array` functions that return the wrapped value
// in Firefox < 10 and IE < 9 each(['push', 'reverse', 'sort', 'unshift'], function(methodName) {
if (hasObjectSpliceBug && value.length === 0) { var func = arrayRef[methodName];
delete value[0]; lodash.prototype[methodName] = function() {
} func.apply(this.__wrapped__, arguments);
return this; return this;
}; };
}); });
// add accessor `Array` functions to the wrapper // add `Array` functions that return new wrapped values
forEach(['concat', 'join', 'slice'], function(methodName) { each(['concat', 'slice', 'splice'], function(methodName) {
var func = arrayRef[methodName]; var func = arrayRef[methodName];
lodash.prototype[methodName] = function() { lodash.prototype[methodName] = function() {
var value = this.__wrapped__, var result = func.apply(this.__wrapped__, arguments);
result = func.apply(value, arguments);
return new lodash(result); return new lodash(result);
}; };
}); });
// avoid array-like object bugs with `Array#shift` and `Array#splice`
// in Firefox < 10 and IE < 9
if (hasObjectSpliceBug) {
each(['pop', 'shift', 'splice'], function(methodName) {
var func = arrayRef[methodName],
isSplice = methodName == 'splice';
lodash.prototype[methodName] = function() {
var value = this.__wrapped__,
result = func.apply(value, arguments);
if (value.length === 0) {
delete value[0];
}
return isSplice ? new lodash(result) : result;
};
});
}
// add pseudo private property to be used and removed during the build process // add pseudo private property to be used and removed during the build process
lodash._each = each;
lodash._iteratorTemplate = iteratorTemplate; lodash._iteratorTemplate = iteratorTemplate;
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

77
lodash.min.js vendored
View File

@@ -1,41 +1,42 @@
/*! /*!
Lo-Dash 1.0.0-rc.2 lodash.com/license Lo-Dash 1.0.0-rc.3 lodash.com/license
Underscore.js 1.4.3 underscorejs.org/LICENSE Underscore.js 1.4.3 underscorejs.org/LICENSE
*/ */
;(function(e,t){function s(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof s))return new s(e);this.__wrapped__=e}function o(t,n){return e.eval("(function("+t+"){"+n+"})")}function u(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||it);if(i)for(var s={},n=t-1;++n<r;){var o=e[n]+"";(Tt.call(s,o)?s[o]:s[o]=[]).push(e[n])}return function(n){if(i){var r=n+"";return Tt.call(s,r)&&-1<W(s[r],n)}return-1<W(e,n,t)}}function a(e){return e.charCodeAt(0)}function f(e,t){var n=e.b,r=t.b,e=e.a, ;(function(e,t){function n(e){if(e&&typeof e=="object"&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||tt);if(i)for(var s={},n=t-1;++n<r;){var o=e[n]+"";(Et.call(s,o)?s[o]:s[o]=[]).push(e[n])}return function(n){if(i){var r=n+"";return Et.call(s,r)&&-1<R(s[r],n)}return-1<R(e,n,t)}}function i(e){return e.charCodeAt(0)}function s(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||typeof e=="undefined")return 1;if(
t=t.a;if(e!==t){if(e>t||"undefined"==typeof e)return 1;if(e<t||"undefined"==typeof t)return-1}return n<r?-1:1}function l(e,t,n){function i(){var a=arguments,f=o?this:t;return s||(e=t[u]),n.length&&(a=a.length?n.concat(g(a)):n),this instanceof i?(m.prototype=e.prototype,f=new m,m.prototype=r,a=e.apply(f,a),k(a)?a:f):e.apply(f,a)}var s=C(e),o=!n,u=t;return o&&(n=t),s||(t=e),i}function c(e,t){return e?"function"!=typeof e?function(t){return t[e]}:"undefined"!=typeof t?function(n,r,i){return e.call(t e<t||typeof t=="undefined")return-1}return n<r?-1:1}function o(e,t,n){function r(){var u=arguments,a=s?this:t;return i||(e=t[o]),n.length&&(u=u.length?n.concat(p(u)):n),this instanceof r?(h.prototype=e.prototype,a=new h,h.prototype=null,u=e.apply(a,u),x(u)?u:a):e.apply(a,u)}var i=S(e),s=!n,o=t;return s&&(n=t),i||(t=e),r}function u(e,t,n){return e?typeof e!="function"?function(t){return t[e]}:typeof t!="undefined"?n?function(n,r,i,s){return e.call(t,n,r,i,s)}:function(n,r,i){return e.call(t,n,r,i)
,n,r,i)}:e:K}function h(){for(var e={b:"",c:"",e:Kt,f:Jt,g:"",h:Yt,i:en,j:bt,k:"",l:n},t,r=0;t=arguments[r];r++)for(var i in t)e[i]=t[i];t=e.a,e.d=/^[^,]+/.exec(t)[0],r="var i,l="+e.d+",t="+e.d+";if(!"+e.d+")return t;"+e.k+";",e.b?(r+="var m=l.length;i=-1;if(typeof m=='number'){",e.i&&(r+="if(k(l)){l=l.split('')}"),r+="while(++i<m){"+e.b+"}}else {"):e.h&&(r+="var m=l.length;i=-1;if(m&&j(l)){while(++i<m){i+='';"+e.g+"}}else {"),e.e||(r+="var u=typeof l=='function'&&s.call(l,'prototype');");if(e.f&& }:e:V}function a(){for(var e={b:"",c:"",e:Xt,f:Wt,g:"",h:Jt,i:Gt,j:mt,k:"",l:!0},t,n=0;t=arguments[n];n++)for(var r in t)e[r]=t[r];t=e.a,e.d=/^[^,]+/.exec(t)[0],n=Function,r="var i,l="+e.d+",t="+e.d+";if(!"+e.d+")return t;"+e.k+";",e.b?(r+="var m=l.length;i=-1;if(typeof m=='number'){",e.i&&(r+="if(k(l)){l=l.split('')}"),r+="while(++i<m){"+e.b+"}}else {"):e.h&&(r+="var m=l.length;i=-1;if(m&&j(l)){while(++i<m){i+='';"+e.g+"}}else {"),e.e||(r+="var u=typeof l=='function'&&s.call(l,'prototype');");if(
e.l)r+="var q=-1,r=p[typeof l]?n(l):[],m=r.length;while(++q<m){i=r[q];",e.e||(r+="if(!(u&&i=='prototype')){"),r+=e.g+"",e.e||(r+="}");else{r+="for(i in l){";if(!e.e||e.l)r+="if(",e.e||(r+="!(u&&i=='prototype')"),!e.e&&e.l&&(r+="&&"),e.l&&(r+="h.call(l,i)"),r+="){";r+=e.g+";";if(!e.e||e.l)r+="}"}r+="}";if(e.e){r+="var f=l.constructor;";for(i=0;7>i;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" e.f&&e.l)r+="var q=-1,r=p[typeof l]?n(l):[],m=r.length;while(++q<m){i=r[q];",e.e||(r+="if(!(u&&i=='prototype')){"),r+=e.g+"",e.e||(r+="}");else{r+="for(i in l){";if(!e.e||e.l)r+="if(",e.e||(r+="!(u&&i=='prototype')"),!e.e&&e.l&&(r+="&&"),e.l&&(r+="h.call(l,i)"),r+="){";r+=e.g+";";if(!e.e||e.l)r+="}"}r+="}";if(e.e){r+="var f=l.constructor;";for(var i=0;7>i;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t"
,o("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(c,Tt,b,A,on,_t,Ct)}function p(e){return"\\"+un[e]}function d(e){return dn[e]}function v(e){return"function"!=typeof e.toString&&"string"==typeof (e+"")}function m(){}function g(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++r<n;)i[r]=e[t+r];return i}function y(e){return vn[e]}function b(e){return kt.call(e)==Bt}function w(e){var t=i;if(!e||"object"!=typeof e||b(e))return t;var n=e.constructor;return! ,n("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(u,Et,v,N,nn,At,xt)}function f(e){return"\\"+rn[e]}function l(e){return hn[e]}function c(e){return typeof e.toString!="function"&&typeof (e+"")=="string"}function h(){}function p(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++r<n;)i[r]=e[t+r];return i}function d(e){return pn[e]}function v(e){return Tt.call(e)==Dt}function m(e){var t=!1;if(!e||typeof e!="object"||v(e))return t;var n=e.constructor;return!
C(n)&&(!tn||!v(e))||n instanceof n?Qt?(hn(e,function(e,n,r){return t=!Tt.call(r,n),i}),t===i):(hn(e,function(e,n){t=n}),t===i||Tt.call(e,t)):t}function E(e){var t=[];return pn(e,function(e,n){t.push(n)}),t}function S(e,t,n,s,o){if(e==r)return e;n&&(t=i);if(n=k(e)){var u=kt.call(e);if(!rn[u]||tn&&v(e))return e;var a=gn(e)}if(!n||!t)return n?a?g(e):cn({},e):e;n=sn[u];switch(u){case Ft:case It:return new n(+e);case qt:case zt:return new n(e);case Ut:return n(e.source,ct.exec(e))}s||(s=[]),o||(o=[]); S(n)&&(!Yt||!c(e))||n instanceof n?Vt?(ln(e,function(e,n,r){return t=!Et.call(r,n),!1}),!1===t):(ln(e,function(e,n){t=n}),!1===t||Et.call(e,t)):t}function g(e){var t=[];return cn(e,function(e,n){t.push(n)}),t}function y(e,t,n,r,i){if(null==e)return e;n&&(t=!1);if(n=x(e)){var s=Tt.call(e);if(!en[s]||Yt&&c(e))return e;var o=vn(e)}if(!n||!t)return n?o?p(e):fn({},e):e;n=tn[s];switch(s){case Ht:case Bt:return new n(+e);case jt:case qt:return new n(e);case It:return n(e.source,at.exec(e))}r||(r=[]),i||
for(u=s.length;u--;)if(s[u]==e)return o[u];var f=a?n(e.length):{};return s.push(e),o.push(f),(a?wn:pn)(e,function(e,n){f[n]=S(e,t,r,s,o)}),a&&(Tt.call(e,"index")&&(f.index=e.index),Tt.call(e,"input")&&(f.input=e.input)),f}function x(e){var t=[];return hn(e,function(e,n){C(e)&&t.push(n)}),t.sort()}function T(e){var t={};return pn(e,function(e,n){t[e]=n}),t}function N(e,t,s,o){if(e===t)return 0!==e||1/e==1/t;if(e==r||t==r)return e===t;var u=kt.call(e),a=kt.call(t);u==Bt&&(u=Rt),a==Bt&&(a=Rt);if(u!= (i=[]);for(s=r.length;s--;)if(r[s]==e)return i[s];var u=o?n(e.length):{};return r.push(e),i.push(u),(o?_:cn)(e,function(e,n){u[n]=y(e,t,null,r,i)}),o&&(Et.call(e,"index")&&(u.index=e.index),Et.call(e,"input")&&(u.input=e.input)),u}function b(e){var t=[];return ln(e,function(e,n){S(e)&&t.push(n)}),t.sort()}function w(e){var t={};return cn(e,function(e,n){t[e]=n}),t}function E(e,t,n,r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;var i=Tt.call(e),s=Tt.call(t);i==Dt&&(i=Ft),s==Dt&&
a)return i;switch(u){case Ft:case It:return+e==+t;case qt:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case Ut:case zt:return e==t+""}a=u==jt;if(!a){if(e.__wrapped__||t.__wrapped__)return N(e.__wrapped__||e,t.__wrapped__||t);if(u!=Rt||tn&&(v(e)||v(t)))return i;var u=Zt&&b(e)?Object:e.constructor,f=Zt&&b(t)?Object:t.constructor;if(u!=f&&(!C(u)||!(u instanceof u&&C(f)&&f instanceof f)))return i}s||(s=[]),o||(o=[]);for(u=s.length;u--;)if(s[u]==e)return o[u]==t;var l=n,c=0;s.push(e),o.push(t);if(a){c=e.length (s=Ft);if(i!=s)return!1;switch(i){case Ht:case Bt:return+e==+t;case jt:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case It:case qt:return e==t+""}s=i==Pt;if(!s){if(e.__wrapped__||t.__wrapped__)return E(e.__wrapped__||e,t.__wrapped__||t);if(i!=Ft||Yt&&(c(e)||c(t)))return!1;var i=!Kt&&v(e)?Object:e.constructor,o=!Kt&&v(t)?Object:t.constructor;if(i!=o&&(!S(i)||!(i instanceof i&&S(o)&&o instanceof o)))return!1}n||(n=[]),r||(r=[]);for(i=n.length;i--;)if(n[i]==e)return r[i]==t;var u=!0,a=0;n.push(e),r.push(
;if(l=c==t.length)for(;c--&&(l=N(e[c],t[c],s,o)););return l}return hn(e,function(e,n,r){if(Tt.call(r,n))return c++,l=Tt.call(t,n)&&N(e,t[n],s,o)}),l&&hn(t,function(e,t,n){if(Tt.call(n,t))return l=-1<--c}),l}function C(e){return"function"==typeof e}function k(e){return e?on[typeof e]:i}function L(e){return"number"==typeof e||kt.call(e)==qt}function A(e){return"string"==typeof e||kt.call(e)==zt}function O(e,t,n){var i=arguments,s=0,o=2,u=i[3],a=i[4];n!==rt&&(u=[],a=[],"number"!=typeof n&&(o=i.length t);if(s){a=e.length;if(u=a==t.length)for(;a--&&(u=E(e[a],t[a],n,r)););return u}return ln(e,function(e,i,s){if(Et.call(s,i))return a++,u=Et.call(t,i)&&E(e,t[i],n,r)}),u&&ln(t,function(e,t,n){if(Et.call(n,t))return u=-1<--a}),u}function S(e){return typeof e=="function"}function x(e){return e?nn[typeof e]:!1}function T(e){return typeof e=="number"||Tt.call(e)==jt}function N(e){return typeof e=="string"||Tt.call(e)==qt}function C(e,t,n){var r=arguments,i=0,s=2,o=r[3],u=r[4];n!==et&&(o=[],u=[],typeof
));for(;++s<o;)pn(i[s],function(t,n){var i,s,o;if(t&&((s=gn(t))||yn(t))){for(var f=u.length;f--;)if(i=u[f]==t)break;i?e[n]=a[f]:(u.push(t),a.push(o=(o=e[n],s)?gn(o)?o:[]:yn(o)?o:{}),e[n]=O(o,t,rt,u,a))}else t!=r&&(e[n]=t)});return e}function M(e){var t=[];return pn(e,function(e){t.push(e)}),t}function _(e,t,n){var r=-1,s=e?e.length:0,o=i,n=(0>n?Dt(0,s+n):n)||0;return"number"==typeof s?o=-1<(A(e)?e.indexOf(t,n):W(e,t,n)):wn(e,function(e){if(++r>=n)return!(o=e===t)}),o}function D(e,t,r){var i=n,t=c n!="number"&&(s=r.length));for(;++i<s;)cn(r[i],function(t,n){var r,i,s;if(t&&((i=vn(t))||mn(t))){for(var a=o.length;a--;)if(r=o[a]==t)break;r?e[n]=u[a]:(o.push(t),u.push(s=(s=e[n],i)?vn(s)?s:[]:mn(s)?s:{}),e[n]=C(s,t,et,o,u))}else t!=null&&(e[n]=t)});return e}function k(e){var t=[];return cn(e,function(e){t.push(e)}),t}function L(e,t,n){var r=-1,i=e?e.length:0,s=!1,n=(0>n?Ot(0,i+n):n)||0;return typeof i=="number"?s=-1<(N(e)?e.indexOf(t,n):R(e,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s}
(t,r);if(gn(e))for(var r=-1,s=e.length;++r<s&&(i=!!t(e[r],r,e)););else wn(e,function(e,n,r){return i=!!t(e,n,r)});return i}function P(e,t,n){var r=[],t=c(t,n);if(gn(e))for(var n=-1,i=e.length;++n<i;){var s=e[n];t(s,n,e)&&r.push(s)}else wn(e,function(e,n,i){t(e,n,i)&&r.push(e)});return r}function H(e,t,n){var r,t=c(t,n);return wn(e,function(e,n,s){if(t(e,n,s))return r=e,i}),r}function B(e,t,n){var r=-1,i=e?e.length:0,s=Array("number"==typeof i?i:0),t=c(t,n);if(gn(e))for(;++r<i;)s[r]=t(e[r],r,e);else wn function A(e,t,n){var r=!0,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++n<i&&(r=!!t(e[n],n,e)););else an(e,function(e,n,i){return r=!!t(e,n,i)});return r}function O(e,t,n){var r=[],t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++n<i;){var s=e[n];t(s,n,e)&&r.push(s)}else an(e,function(e,n,i){t(e,n,i)&&r.push(e)});return r}function M(e,t,n){var r,t=u(t,n);return _(e,function(e,n,i){if(t(e,n,i))return r=e,!1}),r}function _(e,t,n){if(t&&typeof n=="undefined"&&vn(e))for(var n=-1,r=e.length;++n<r&&!1!==t(e[
(e,function(e,n,i){s[++r]=t(e,n,i)});return s}function j(e,t,n){var r=-Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&A(e)?a:c(t,n),wn(e,function(e,n,i){n=t(e,n,i),n>r&&(r=n,o=e)});else for(;++i<s;)e[i]>o&&(o=e[i]);return o}function F(e,t){return B(e,t+"")}function I(e,t,n,r){var s=3>arguments.length;return t||(t=K),wn(e,function(e,o,u){n=s?(s=i,e):t.call(r,n,e,o,u)}),n}function q(e,t,n,r){var s=e,o=e?e.length:0,u=3>arguments.length;if("number"!=typeof o)var a=bn(e),o=a.length;else en&&A(e)&& n],n,e););else an(e,t,n);return e}function D(e,t,n){var r=-1,i=e?e.length:0,s=Array(typeof i=="number"?i:0),t=u(t,n);if(vn(e))for(;++r<i;)s[r]=t(e[r],r,e);else an(e,function(e,n,i){s[++r]=t(e,n,i)});return s}function P(e,t,n){var r=-Infinity,s=-1,o=e?e.length:0,a=r;if(t||!vn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),n>r&&(r=n,a=e)});else for(;++s<o;)e[s]>a&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments.length,t=u(t,r,et);if(vn(e)){var s=-1,o=
(s=e.split(""));return t||(t=K),wn(e,function(e,f,l){f=a?a[--o]:--o,n=u?(u=i,s[f]):t.call(r,n,s[f],f,l)}),n}function R(e,t,n){var r,t=c(t,n);if(gn(e))for(var n=-1,i=e.length;++n<i&&!(r=t(e[n],n,e)););else wn(e,function(e,n,i){return!(r=t(e,n,i))});return!!r}function U(e,t,n){if(e){var i=e.length;return t==r||n?e[0]:g(e,0,Pt(Dt(0,t),i))}}function z(e,t){for(var n=-1,r=e?e.length:0,i=[];++n<r;){var s=e[n];gn(s)?Nt.apply(i,t?s:z(s)):i.push(s)}return i}function W(e,t,n){var r=-1,i=e?e.length:0;if("number"==typeof e.length;for(i&&(n=e[++s]);++s<o;)n=t(n,e[s],s,e)}else an(e,function(e,r,s){n=i?(i=!1,e):t(n,e,r,s)});return n}function j(e,t,n,r){var i=e,s=e?e.length:0,o=3>arguments.length;if(typeof s!="number")var a=gn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++n<i&&!(r=t(e[n],n,e)););else an(e,function(e,n,i){return!(r=t(e,n,i))});return!!r}function I(e
n)r=(0>n?Dt(0,i+n):n||0)-1;else if(n)return r=V(e,t),e[r]===t?r:-1;for(;++r<i;)if(e[r]===t)return r;return-1}function X(e,t,n){return g(e,t==r||n?1:Dt(0,t))}function V(e,t,n,r){for(var i=0,s=e?e.length:i,n=n?c(n,r):K,t=n(t);i<s;)r=i+s>>>1,n(e[r])<t?i=r+1:s=r;return i}function $(e,t,n,r){var s=-1,o=e?e.length:0,u=[],a=u;"function"==typeof t&&(r=n,n=t,t=i);var f=!t&&74<o;if(f)var l={};n&&(a=[],n=c(n,r));for(;++s<o;){var r=e[s],h=n?n(r,s,e):r;f&&(a=Tt.call(l,h+"")?l[h]:l[h]=[]);if(t?!s||a[a.length-1 ,t,n){if(e){var r=e.length;return null==t||n?e[0]:p(e,0,Mt(Ot(0,t),r))}}function q(e,t){for(var n=-1,r=e?e.length:0,i=[];++n<r;){var s=e[n];vn(s)?St.apply(i,t?s:q(s)):i.push(s)}return i}function R(e,t,n){var r=-1,i=e?e.length:0;if(typeof n=="number")r=(0>n?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r<i;)if(e[r]===t)return r;return-1}function U(e,t,n){return p(e,null==t||n?1:Ot(0,t))}function z(e,t,n,r){for(var i=0,s=e?e.length:i,n=n?u(n,r):V,t=n(t);i<s;)r=i+s>>>1,n(e[r])<t?i=
]!==h:0>W(a,h))(n||f)&&a.push(h),u.push(r)}return u}function J(e,t){return $t||Lt&&2<arguments.length?Lt.call.apply(Lt,arguments):l(e,t,g(arguments,2))}function K(e){return e}function Q(e){wn(x(e),function(t){var n=s[t]=e[t];s.prototype[t]=function(){var e=[this.__wrapped__];return Nt.apply(e,arguments),e=n.apply(s,e),new s(e)}})}function G(){return this.__wrapped__}var n=!0,r=null,i=!1,Y="object"==typeof exports&&exports,Z="object"==typeof global&&global;Z.global===Z&&(e=Z);var et=[],tt=new function( r+1:s=r;return i}function W(e,t,n,r){var i=-1,s=e?e.length:0,o=[],a=o;typeof t=="function"&&(r=n,n=t,t=!1);var f=!t&&75<=s;if(f)var l={};n&&(a=[],n=u(n,r));for(;++i<s;){var r=e[i],c=n?n(r,i,e):r;if(f)var h=c+"",h=Et.call(l,h)?!(a=l[h]):a=l[h]=[];if(t?!i||a[a.length-1]!==c:h||0>R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2<arguments.length?Nt.call.apply(Nt,arguments):o(e,t,p(arguments,2))}function V(e){return e}function $(e){_(b(e),function(t){var r=n[t]=e[t];n.prototype
){},nt=0,rt=tt,it=30,st=e._,ot=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ut=/&(?:amp|lt|gt|quot|#x27);/g,at=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,lt=/(__e\(.*?\)|\b__t\))\+'';/g,ct=/\w*$/,ht=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,pt=RegExp("^"+(tt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),dt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,vt=/<%=([\s\S]+?)%>/g,mt=/($^)/,gt=/[&<>"']/g,yt=/['\n\r\t\u2028\u2029\\]/g,bt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf" [t]=function(){var e=[this.__wrapped__];return St.apply(e,arguments),e=r.apply(n,e),new n(e)}})}function J(){return this.__wrapped__}var K=typeof exports=="object"&&exports,Q=typeof global=="object"&&global;Q.global===Q&&(e=Q);var G=[],Y=new function(){},Z=0,et=Y,tt=30,nt=e._,rt=/[-?+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g
.split(" "),wt=Math.ceil,Et=et.concat,St=Math.floor,xt=pt.test(xt=Object.getPrototypeOf)&&xt,Tt=tt.hasOwnProperty,Nt=et.push,Ct=tt.propertyIsEnumerable,kt=tt.toString,Lt=pt.test(Lt=g.bind)&&Lt,At=pt.test(At=Array.isArray)&&At,Ot=e.isFinite,Mt=e.isNaN,_t=pt.test(_t=Object.keys)&&_t,Dt=Math.max,Pt=Math.min,Ht=Math.random,Bt="[object Arguments]",jt="[object Array]",Ft="[object Boolean]",It="[object Date]",qt="[object Number]",Rt="[object Object]",Ut="[object RegExp]",zt="[object String]",Wt=!/1/.test ,lt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable,Tt=Y.toString,Nt=lt.test(Nt=
(Function("1")),Xt=!!e.attachEvent,Vt=Lt&&!/\n|true/.test(Lt+Xt),$t=Lt&&!Vt,Jt=_t&&(Xt||Vt),Kt,Qt,Gt=(Gt={0:1,length:1},et.splice.call(Gt,0,1),Gt[0]),Yt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Yt=!n;Kt=!/valueOf/.test(t),Qt="x"!=t[0]})(1);var Zt=!b(arguments),en="xx"!="x"[0]+Object("x")[0];try{var tn=("[object Object]",kt.call(document)==Rt)}catch(nn){}var rn={"[object Function]":i};rn[Bt]=rn[jt]=rn[Ft]=rn[It]=rn[qt]= p.bind)&&Nt,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e(){this.x=1}var t=[];e.prototype=
rn[Rt]=rn[Ut]=rn[zt]=n;var sn={};sn[jt]=Array,sn[Ft]=Boolean,sn[It]=Date,sn[Rt]=Object,sn[qt]=Number,sn[Ut]=RegExp,sn[zt]=String;var on={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},un={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:vt,variable:""};if(Xt||Vt||!Wt)o=Function;var an={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a<b;a++){if((l=arguments[a])){" {valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean":!1,"function":!0,object:!0,
,g:"t[i]=l[i]",c:"}}"},fn={a:"d,c,w",k:"c=c&&typeof w=='undefined'?c:e(c,w)",b:"if(c(l[i],i,d)===false)return t",g:"if(c(l[i],i,d)===false)return t"},ln={b:r},cn=h(an);Zt&&(b=function(e){return e?Tt.call(e,"callee"):i});var hn=h(fn,ln,{l:i}),pn=h(fn,ln),dn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},vn=T(dn),mn=h(an,{g:"if(t[i]==null)"+an.g}),gn=At||function(e){return kt.call(e)==jt};C(/x/)&&(C=function(e){return"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a<b;a++){if((l=arguments[a])){",g:"t[i]=l[i]",c:"}}"},on={a:"d,c,w",k:"c=c&&typeof w=='undefined'?c:e(c,w)",b:"if(c(l[i],i,d)===false)return t",g:"if(c(l[i],i,d)===false)return t"},un={b:null},an=a(on),fn=a(sn
e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!b(e):w(e)}:w,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?E(e):k(e)?_t(e):[]}:E,wn=h(fn);s.assign=cn,s.bindAll=function(e){for(var t=arguments,n=1<t.length?0:(t=x(e),-1),r=t.length;++n<r;){var i=t[n];e[i]=J(e[i],e)}return e},s.chain=function(e){return new s(e)},s.compact=function(e){for(var t=-1,n=e?e.length:0,r=[];++t<n;){var i=e[t];i&&r.push(i)}return r},s.countBy=function(e,t,n );Qt&&(v=function(e){return e?Et.call(e,"callee"):!1});var ln=a(on,un,{l:!1}),cn=a(on,un),hn={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},pn=w(hn),dn=a(sn,{g:"if(t[i]==null)"+sn.g}),vn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var mn=wt?function(e){if(!e||typeof e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e)
){var r={},t=c(t,n);return wn(e,function(e,n,i){n=t(e,n,i),Tt.call(r,n)?r[n]++:r[n]=1}),r},s.defaults=mn,s.difference=function(e){for(var t=-1,n=e?e.length:0,r=Et.apply(et,arguments),r=u(r,n),i=[];++t<n;){var s=e[t];r(s)||i.push(s)}return i},s.filter=P,s.flatten=z,s.forEach=wn,s.forIn=hn,s.forOwn=pn,s.functions=x,s.groupBy=function(e,t,n){var r={},t=c(t,n);return wn(e,function(e,n,i){n=t(e,n,i),(Tt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},s.initial=function(e,t,n){if(!e)return[];var i=e.length;return g }:m,gn=At?function(e){return typeof e=="function"&&xt.call(e,"prototype")?g(e):x(e)?At(e):[]}:g;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1<t.length?0:(t=b(e),-1),r=t.length;++n<r;){var i=t[n];e[i]=X(e[i],e)}return e},n.bindKey=function(e,t){return o(e,t,p(arguments,2))},n.compact=function(e){for(var t=-1,n=e?e.length:0,r=[];++t<n;){var i=e[t];i&&r.push(i)}return r},n.compose=function(
(e,0,Pt(Dt(0,i-(t==r||n?1:t||0)),i))},s.intersection=function(e){var t=arguments,n=t.length,r={},i=[];return wn(e,function(e){if(0>W(i,e)){for(var s=n;--s;)if(!(r[s]||(r[s]=u(t[s])))(e))return;i.push(e)}}),i},s.invert=T,s.invoke=function(e,t){var n=g(arguments,2),r="function"==typeof t,i=[];return wn(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.merge=O,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&A(e)?a:c(t,n),wn(e,function(e,n,i) ){var e=arguments;return function(){for(var t=arguments,n=e.length;n--;)t=[e[n].apply(this,t)];return t[0]}},n.countBy=function(e,t,n){var r={},t=u(t,n);return _(e,function(e,n,i){n=t(e,n,i),Et.call(r,n)?r[n]++:r[n]=1}),r},n.debounce=function(e,t,n){function r(){u=null,n||(s=e.apply(o,i))}var i,s,o,u;return function(){var a=n&&!u;return i=arguments,o=this,clearTimeout(u),u=setTimeout(r,t),a&&(s=e.apply(o,i)),s}},n.defaults=dn,n.defer=function(e){var n=p(arguments,1);return setTimeout(function(){e
{n=t(e,n,i),n<r&&(r=n,o=e)});else for(;++i<s;)e[i]<o&&(o=e[i]);return o},s.object=function(e,t){for(var n=-1,r=e?e.length:0,i={};++n<r;){var s=e[n];t?i[s]=t[n]:i[s[0]]=s[1]}return i},s.omit=function(e,t,n){var r="function"==typeof t,i={};if(r)t=c(t,n);else var s=Et.apply(et,arguments);return hn(e,function(e,n,o){if(r?!t(e,n,o):0>W(s,n,1))i[n]=e}),i},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([n,e])}),t},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply .apply(t,n)},1)},n.delay=function(e,n){var r=p(arguments,2);return setTimeout(function(){e.apply(t,r)},n)},n.difference=function(e){for(var t=-1,n=e?e.length:0,i=yt.apply(G,arguments),i=r(i,n),s=[];++t<n;){var o=e[t];i(o)||s.push(o)}return s},n.filter=O,n.flatten=q,n.forEach=_,n.forIn=ln,n.forOwn=cn,n.functions=b,n.groupBy=function(e,t,n){var r={},t=u(t,n);return _(e,function(e,n,i){n=t(e,n,i),(Et.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return p
(et,arguments),o=s.length;++i<o;){var u=s[i];u in e&&(r[u]=e[u])}else t=c(t,n),hn(e,function(e,n,i){t(e,n,i)&&(r[n]=e)});return r},s.pluck=F,s.range=function(e,t,n){e=+e||0,n=+n||1,t==r&&(t=e,e=0);for(var i=-1,t=Dt(0,wt((t-e)/n)),s=Array(t);++i<t;)s[i]=e,e+=n;return s},s.reject=function(e,t,n){return t=c(t,n),P(e,function(e,n,r){return!t(e,n,r)})},s.rest=X,s.shuffle=function(e){var t=-1,n=Array(e?e.length:0);return wn(e,function(e){var r=St(Ht()*(++t+1));n[t]=n[r],n[r]=e}),n},s.sortBy=function(e, (e,0,Mt(Ot(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,i={0:{}},s=-1,o=e?e.length:0,u=100<=o,a=[],f=a;e:for(;++s<o;){var l=e[s];if(u)var c=l+"",c=Et.call(i[0],c)?!(f=i[0][c]):f=i[0][c]=[];if(c||0>R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r=typeof t=="function",i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=gn,n.map=D,
t,n){var r=[],t=c(t,n);wn(e,function(e,n,i){r.push({a:t(e,n,i),b:n,c:e})}),e=r.length;for(r.sort(f);e--;)r[e]=r[e].c;return r},s.tap=function(e,t){return t(e),e},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++r<e;)i[r]=t.call(n,r);return i},s.toArray=function(e){return"number"==typeof (e?e.length:0)?en&&A(e)?e.split(""):g(e):M(e)},s.union=function(){return $(Et.apply(et,arguments))},s.uniq=$,s.values=M,s.where=function(e,t){var n=bn(t);return P(e,function(e){for(var r=n.length;r--;){var i= n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!vn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),n<r&&(r=n,a=e)});else for(;++s<o;)e[s]<a&&(a=e[s]);return a},n.object=function(e,t){for(var n=-1,r=e?e.length:0,i={};++n<r;){var s=e[n];t?i[s]=t[n]:i[s[0]]=s[1]}return i},n.omit=function(e,t,n){var r=typeof
e[n[r]]===t[n[r]];if(!i)break}return!!i})},s.without=function(e){for(var t=-1,n=e?e.length:0,r=u(arguments,1,20),i=[];++t<n;){var s=e[t];r(s)||i.push(s)}return i},s.zip=function(e){for(var t=-1,n=e?j(F(arguments,"length")):0,r=Array(n);++t<n;)r[t]=F(arguments,t);return r},s.collect=B,s.drop=X,s.each=wn,s.extend=cn,s.methods=x,s.select=P,s.tail=X,s.unique=$,Q(s),s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},s.bind=J,s.bindKey=function(e,t){return l(e,t,g t=="function",i={};if(r)t=u(t,n);else var s=yt.apply(G,arguments);return ln(e,function(e,n,o){if(r?!t(e,n,o):0>R(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return cn(e,function(e,n){t.push([n,e])}),t},n.partial=function(e){return o(e,p(arguments,1))},n.pick=function(e,t,n){var r={};if(typeof t!="function")for(var i=0,s=yt.apply(G,arguments),o=s.length;++i<o;){var a=s[i];a in e&&(r[a]=e[a])}
(arguments,2))},s.clone=S,s.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length;n--;)t=[e[n].apply(this,t)];return t[0]}},s.contains=_,s.debounce=function(e,t,n){function i(){a=r,n||(o=e.apply(u,s))}var s,o,u,a;return function(){var r=n&&!a;return s=arguments,u=this,clearTimeout(a),a=setTimeout(i,t),r&&(o=e.apply(u,s)),o}},s.defer=function(e){var n=g(arguments,1);return setTimeout(function(){e.apply(t,n)},1)},s.delay=function(e,n){var r=g(arguments,2);return setTimeout else t=u(t,n),ln(e,function(e,n,i){t(e,n,i)&&(r[n]=e)});return r},n.pluck=H,n.range=function(e,t,n){e=+e||0,n=+n||1,null==t&&(t=e,e=0);for(var r=-1,t=Ot(0,gt((t-e)/n)),i=Array(t);++r<t;)i[r]=e,e+=n;return i},n.reject=function(e,t,n){return t=u(t,n),O(e,function(e,n,r){return!t(e,n,r)})},n.rest=U,n.shuffle=function(e){var t=-1,n=Array(e?e.length:0);return _(e,function(e){var r=bt(_t()*(++t+1));n[t]=n[r],n[r]=e}),n},n.sortBy=function(e,t,n){var r=[],t=u(t,n);_(e,function(e,n,i){r.push({a:t(e,n,i),b
(function(){e.apply(t,r)},n)},s.escape=function(e){return e==r?"":(e+"").replace(gt,d)},s.every=D,s.find=H,s.has=function(e,t){return e?Tt.call(e,t):i},s.identity=K,s.indexOf=W,s.isArguments=b,s.isArray=gn,s.isBoolean=function(e){return e===n||e===i||kt.call(e)==Ft},s.isDate=function(e){return kt.call(e)==It},s.isElement=function(e){return e?1===e.nodeType:i},s.isEmpty=function(e){var t=n;if(!e)return t;var r=kt.call(e),s=e.length;return r==jt||r==zt||r==Bt||Zt&&b(e)||r==Rt&&"number"==typeof s&&C :n,c:e})}),e=r.length;for(r.sort(s);e--;)r[e]=r[e].c;return r},n.tap=function(e,t){return t(e),e},n.throttle=function(e,t){function n(){u=new Date,o=null,i=e.apply(s,r)}var r,i,s,o,u=0;return function(){var a=new Date,f=t-(a-u);return r=arguments,s=this,0>=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++r<e;)i[r]=t.call(n,r);return i},n.toArray=function(e){return typeof (e?e.length:0)=="number"?Gt&&N(e)?e.split("")
(e.splice)?!s:(pn(e,function(){return t=i}),t)},s.isEqual=N,s.isFinite=function(e){return Ot(e)&&!Mt(parseFloat(e))},s.isFunction=C,s.isNaN=function(e){return L(e)&&e!=+e},s.isNull=function(e){return e===r},s.isNumber=L,s.isObject=k,s.isPlainObject=yn,s.isRegExp=function(e){return kt.call(e)==Ut},s.isString=A,s.isUndefined=function(e){return"undefined"==typeof e},s.lastIndexOf=function(e,t,n){var r=e?e.length:0;for("number"==typeof n&&(r=(0>n?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1 :p(e):k(e)},n.union=function(){return W(yt.apply(G,arguments))},n.uniq=W,n.values=k,n.where=function(e,t){var n=gn(t);return O(e,function(e){for(var r=n.length;r--;){var i=e[n[r]]===t[n[r]];if(!i)break}return!!i})},n.without=function(e){for(var t=-1,n=e?e.length:0,i=r(arguments,1,20),s=[];++t<n;){var o=e[t];i(o)||s.push(o)}return s},n.wrap=function(e,t){return function(){var n=[e];return St.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?P(H(arguments,"length")):0,r=Array(
},s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.partial=function(e){return l(e,g(arguments,1))},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e, n);++t<n;)r[t]=H(arguments,t);return r},n.collect=D,n.drop=U,n.each=_,n.extend=fn,n.methods=b,n.select=O,n.tail=U,n.unique=W,$(n),n.clone=y,n.cloneDeep=function(e){return y(e,!0)},n.contains=L,n.escape=function(e){return null==e?"":(e+"").replace(dt,l)},n.every=A,n.find=M,n.has=function(e,t){return e?Et.call(e,t):!1},n.identity=V,n.indexOf=R,n.isArguments=v,n.isArray=vn,n.isBoolean=function(e){return!0===e||!1===e||Tt.call(e)==Ht},n.isDate=function(e){return e instanceof Date||Tt.call(e)==Bt},n.isElement=
t){var n=e?e[t]:r;return C(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,u=s.templateSettings,a=0,f=n.interpolate||u.interpolate||mt,l="__p+='",c=n.variable||u.variable,h=c;e.replace(RegExp((n.escape||u.escape||mt).source+"|"+f.source+"|"+(f===vt?dt:mt).source+"|"+(n.evaluate||u.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,u){return i||(i=s),l+=e.slice(a,u).replace(yt function(e){return e?1===e.nodeType:!1},n.isEmpty=function(e){var t=!0;if(!e)return t;var n=Tt.call(e),r=e.length;return n==Pt||n==qt||n==Dt||Qt&&v(e)||n==Ft&&typeof r=="number"&&S(e.splice)?!r:(cn(e,function(){return t=!1}),t)},n.isEqual=E,n.isFinite=function(e){return kt(e)&&!Lt(parseFloat(e))},n.isFunction=S,n.isNaN=function(e){return T(e)&&e!=+e},n.isNull=function(e){return null===e},n.isNumber=T,n.isObject=x,n.isPlainObject=mn,n.isRegExp=function(e){return e instanceof RegExp||Tt.call(e)==It
,p),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),i&&(l+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),a=u+t.length,t}),l+="';\n",h||(c="obj",r?l="with("+c+"){"+l+"}":(n=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ht,"$&"+c+".").replace(n,"$1__d"))),l=(r?l.replace(at,""):l).replace(ft,"$1").replace(lt,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+ },n.isString=N,n.isUndefined=function(e){return typeof e=="undefined"},n.lastIndexOf=function(e,t,n){var r=e?e.length:0;for(typeof n=="number"&&(r=(0>n?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;
c+"."+c+"||"+c)+";")+l+"return __p}";try{i=o("_","return "+l)(s)}catch(d){throw d.source=l,d}return t?i(t):(i.source=l,i)},s.throttle=function(e,t){function n(){a=new Date,u=r,s=e.apply(o,i)}var i,s,o,u,a=0;return function(){var f=new Date,l=t-(f-a);return i=arguments,o=this,0>=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.unescape=function(e){return e==r?"":(e+"").replace(ut,y)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.wrap=function(e,t){return function(){var n= return typeof t=="number"?t:gn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"
[e];return Nt.apply(n,arguments),t.apply(this,n)}},s.all=D,s.any=R,s.detect=H,s.foldl=I,s.foldr=q,s.include=_,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:g(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2" ),i||(i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source=
,s.prototype.chain=function(){return this},s.prototype.toString=function(){return""+this.__wrapped__},s.prototype.value=G,s.prototype.valueOf=G,wn("pop push reverse shift sort splice unshift".split(" "),function(e){var t=et[e];s.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Gt&&e.length===0&&delete e[0],this}}),wn(["concat","join","slice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),typeof define=="function"&&typeof l,p}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]||
define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); (n.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice"
],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?typeof module=="object"&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this);

View File

@@ -1,5 +1,5 @@
/*! /*!
* Lo-Dash 1.0.0-rc.2 (Custom Build) <http://lodash.com> * Lo-Dash 1.0.0-rc.3 (Custom Build) <http://lodash.com>
* Build: `lodash underscore -d -o ./lodash.underscore.js` * Build: `lodash underscore -d -o ./lodash.underscore.js`
* (c) 2012 John-David Dalton <http://allyoucanleet.com/> * (c) 2012 John-David Dalton <http://allyoucanleet.com/>
* Based on Underscore.js 1.4.3 <http://underscorejs.org> * Based on Underscore.js 1.4.3 <http://underscorejs.org>
@@ -133,6 +133,9 @@
var hasObjectSpliceBug = (hasObjectSpliceBug = { '0': 1, 'length': 1 }, var hasObjectSpliceBug = (hasObjectSpliceBug = { '0': 1, 'length': 1 },
arrayRef.splice.call(hasObjectSpliceBug, 0, 1), hasObjectSpliceBug[0]); arrayRef.splice.call(hasObjectSpliceBug, 0, 1), hasObjectSpliceBug[0]);
/** Detect if `arguments` objects are `Object` objects (all but Opera < 10.5) */
var argsAreObjects = arguments.constructor == Object;
/** /**
* Detect lack of support for accessing string characters by index: * Detect lack of support for accessing string characters by index:
* *
@@ -182,7 +185,29 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/** /**
* The `lodash` function. * Creates a `lodash` object, that wraps the given `value`, to enable
* method chaining.
*
* The chainable wrapper functions are:
* `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`,
* `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`,
* `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`,
* `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`,
* `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`,
* `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
* `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`,
* `unshift`, `values`, `where`, `without`, `wrap`, and `zip`
*
* The non-chainable wrapper functions are:
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`,
* `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`,
* `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`,
* `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`,
* `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`,
* `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId`
*
* The wrapper functions `first` and `last` return wrapped values when `n` is
* passed, otherwise they return unwrapped values.
* *
* @name _ * @name _
* @constructor * @constructor
@@ -251,6 +276,7 @@
}; };
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/** Reusable iterator options for `assign` and `defaults` */ /** Reusable iterator options for `assign` and `defaults` */
var assignIteratorOptions = { var assignIteratorOptions = {
'args': 'object, source, guard', 'args': 'object, source, guard',
@@ -262,9 +288,9 @@
}; };
/** /**
* Reusable iterator options shared by `forEach`, `forIn`, and `forOwn`. * Reusable iterator options shared by `each`, `forIn`, and `forOwn`.
*/ */
var forEachIteratorOptions = { var eachIteratorOptions = {
'args': 'collection, callback, thisArg', 'args': 'collection, callback, thisArg',
'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)", 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)",
'arrayLoop': 'if (callback(iteratee[index], index, collection) === false) return result', 'arrayLoop': 'if (callback(iteratee[index], index, collection) === false) return result',
@@ -366,9 +392,11 @@
* @param {Function|String} [func=identity|property] The function called per * @param {Function|String} [func=identity|property] The function called per
* iteration or property name to query. * iteration or property name to query.
* @param {Mixed} [thisArg] The `this` binding of `callback`. * @param {Mixed} [thisArg] The `this` binding of `callback`.
* @param {Object} [accumulating] Used to indicate that the callback should
* accept an `accumulator` argument.
* @returns {Function} Returns a callback function. * @returns {Function} Returns a callback function.
*/ */
function createCallback(func, thisArg) { function createCallback(func, thisArg, accumulating) {
if (!func) { if (!func) {
return identity; return identity;
} }
@@ -378,6 +406,11 @@
}; };
} }
if (typeof thisArg != 'undefined') { if (typeof thisArg != 'undefined') {
if (accumulating) {
return function(accumulator, value, index, object) {
return func.call(thisArg, accumulator, value, index, object);
};
}
return function(value, index, object) { return function(value, index, object) {
return func.call(thisArg, value, index, object); return func.call(thisArg, value, index, object);
}; };
@@ -405,7 +438,7 @@
'bottom': '', 'bottom': '',
'hasDontEnumBug': hasDontEnumBug, 'hasDontEnumBug': hasDontEnumBug,
'objectLoop': '', 'objectLoop': '',
'noArgsEnum': noArgsEnum, 'nonEnumArgs': nonEnumArgs,
'noCharByIndex': noCharByIndex, 'noCharByIndex': noCharByIndex,
'shadowed': shadowed, 'shadowed': shadowed,
'top': '', 'top': '',
@@ -434,6 +467,38 @@
); );
} }
/**
* A function compiled to iterate `arguments` objects, arrays, objects, and
* strings consistenly across environments, executing the `callback` for each
* element in the `collection`. The `callback` is bound to `thisArg` and invoked
* with three arguments; (value, index|key, collection). Callbacks may exit
* iteration early by explicitly returning `false`.
*
* @private
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Function} [callback=identity] The function called per iteration.
* @param {Mixed} [thisArg] The `this` binding of `callback`.
* @returns {Array|Object|String} Returns `collection`.
*/
var each = function (collection, callback, thisArg) {
var index, iteratee = collection, result = collection;
if (!collection) return result;
callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg);
var length = iteratee.length; index = -1;
if (typeof length == 'number') {
while (++index < length) {
if (callback(iteratee[index], index, collection) === indicatorObject) return result
}
}
else {
for (index in iteratee) {
if (hasOwnProperty.call(iteratee, index)) {
if (callback(iteratee[index], index, collection) === indicatorObject) return result;
}
}
}
};
/** /**
* Used by `template` to escape characters for inclusion in compiled * Used by `template` to escape characters for inclusion in compiled
* string literals. * string literals.
@@ -718,14 +783,8 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/** /**
* Creates a clone of `value`. If `deep` is `true`, all nested objects will * Creates a clone of `value`. If `deep` is `true`, nested objects will also
* also be cloned, otherwise they will be assigned by reference. Functions and * be cloned, otherwise they will be assigned by reference.
* DOM nodes are **not** cloned. The enumerable properties of `arguments` objects
* and objects created by constructors other than `Object` are cloned to plain
* `Object` objects.
*
* Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm.
* See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -746,9 +805,6 @@
* { 'name': 'curly', 'age': 60 } * { 'name': 'curly', 'age': 60 }
* ]; * ];
* *
* _.clone({ 'name': 'moe' });
* // => { 'name': 'moe' }
*
* var shallow = _.clone(stooges); * var shallow = _.clone(stooges);
* shallow[0] === stooges[0]; * shallow[0] === stooges[0];
* // => true * // => true
@@ -880,7 +936,9 @@
* // => true * // => true
*/ */
var isArray = nativeIsArray || function(value) { var isArray = nativeIsArray || function(value) {
return toString.call(value) == arrayClass; // `instanceof` may cause a memory leak in IE 7 if `value` is a host object
// http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
return (argsAreObjects && value instanceof Array) || toString.call(value) == arrayClass;
}; };
/** /**
@@ -914,7 +972,7 @@
* // => true * // => true
*/ */
function isDate(value) { function isDate(value) {
return toString.call(value) == dateClass; return value instanceof Date || toString.call(value) == dateClass;
} }
/** /**
@@ -1162,7 +1220,7 @@
// fallback for older versions of Chrome and Safari // fallback for older versions of Chrome and Safari
if (isFunction(/x/)) { if (isFunction(/x/)) {
isFunction = function(value) { isFunction = function(value) {
return toString.call(value) == funcClass; return value instanceof Function || toString.call(value) == funcClass;
}; };
} }
@@ -1276,7 +1334,7 @@
* // => true * // => true
*/ */
function isRegExp(value) { function isRegExp(value) {
return toString.call(value) == regexpClass; return value instanceof RegExp || toString.call(value) == regexpClass;
} }
/** /**
@@ -1485,7 +1543,7 @@
if (typeof length == 'number') { if (typeof length == 'number') {
result = indexOf(collection, target) > -1; result = indexOf(collection, target) > -1;
} else { } else {
forEach(collection, function(value) { each(collection, function(value) {
return (result = value === target) && indicatorObject; return (result = value === target) && indicatorObject;
}); });
} }
@@ -1521,6 +1579,7 @@
function countBy(collection, callback, thisArg) { function countBy(collection, callback, thisArg) {
var result = {}; var result = {};
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, key, collection) { forEach(collection, function(value, key, collection) {
key = callback(value, key, collection); key = callback(value, key, collection);
(hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1);
@@ -1561,7 +1620,7 @@
} }
} }
} else { } else {
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
return !(result = !!callback(value, index, collection)) && indicatorObject; return !(result = !!callback(value, index, collection)) && indicatorObject;
}); });
} }
@@ -1601,7 +1660,7 @@
} }
} }
} else { } else {
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
if (callback(value, index, collection)) { if (callback(value, index, collection)) {
result.push(value); result.push(value);
} }
@@ -1633,6 +1692,7 @@
function find(collection, callback, thisArg) { function find(collection, callback, thisArg) {
var result; var result;
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { forEach(collection, function(value, index, collection) {
if (callback(value, index, collection)) { if (callback(value, index, collection)) {
result = value; result = value;
@@ -1664,25 +1724,20 @@
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
* // => alerts each number value (order is not guaranteed) * // => alerts each number value (order is not guaranteed)
*/ */
var forEach = function (collection, callback, thisArg) { function forEach(collection, callback, thisArg) {
var index, iteratee = collection, result = collection; if (callback && typeof thisArg == 'undefined' && isArray(collection)) {
if (!collection) return result; var index = -1,
callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg); length = collection.length;
var length = iteratee.length; index = -1;
if (typeof length == 'number') {
while (++index < length) { while (++index < length) {
if (callback(iteratee[index], index, collection) === indicatorObject) return result if (callback(collection[index], index, collection) === indicatorObject) {
} break;
}
else {
for (index in iteratee) {
if (hasOwnProperty.call(iteratee, index)) {
if (callback(iteratee[index], index, collection) === indicatorObject) return result;
} }
} }
} } else {
each(collection, callback, thisArg);
}; };
}
/** /**
* Creates an object composed of keys returned from running each element of * Creates an object composed of keys returned from running each element of
@@ -1713,6 +1768,7 @@
function groupBy(collection, callback, thisArg) { function groupBy(collection, callback, thisArg) {
var result = {}; var result = {};
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, key, collection) { forEach(collection, function(value, key, collection) {
key = callback(value, key, collection); key = callback(value, key, collection);
(hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value);
@@ -1785,7 +1841,7 @@
result[index] = callback(collection[index], index, collection); result[index] = callback(collection[index], index, collection);
} }
} else { } else {
forEach(collection, function(value, key, collection) { each(collection, function(value, key, collection) {
result[++index] = callback(value, key, collection); result[++index] = callback(value, key, collection);
}); });
} }
@@ -1825,7 +1881,7 @@
if (callback || !isArray(collection)) { if (callback || !isArray(collection)) {
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
var current = callback(value, index, collection); var current = callback(value, index, collection);
if (current > computed) { if (current > computed) {
computed = current; computed = current;
@@ -1869,7 +1925,7 @@
if (callback || !isArray(collection)) { if (callback || !isArray(collection)) {
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
var current = callback(value, index, collection); var current = callback(value, index, collection);
if (current < computed) { if (current < computed) {
computed = current; computed = current;
@@ -1933,12 +1989,25 @@
*/ */
function reduce(collection, callback, accumulator, thisArg) { function reduce(collection, callback, accumulator, thisArg) {
var noaccum = arguments.length < 3; var noaccum = arguments.length < 3;
callback || (callback = identity); callback = createCallback(callback, thisArg, indicatorObject);
forEach(collection, function(value, index, collection) {
accumulator = noaccum if (isArray(collection)) {
? (noaccum = false, value) var index = -1,
: callback.call(thisArg, accumulator, value, index, collection) length = collection.length;
});
if (noaccum) {
accumulator = collection[++index];
}
while (++index < length) {
accumulator = callback(accumulator, collection[index], index, collection);
}
} else {
each(collection, function(value, index, collection) {
accumulator = noaccum
? (noaccum = false, value)
: callback(accumulator, value, index, collection)
});
}
return accumulator; return accumulator;
} }
@@ -1969,12 +2038,12 @@
var props = keys(collection); var props = keys(collection);
length = props.length; length = props.length;
} }
callback || (callback = identity); callback = createCallback(callback, thisArg, indicatorObject);
forEach(collection, function(value, index, collection) { forEach(collection, function(value, index, collection) {
index = props ? props[--length] : --length; index = props ? props[--length] : --length;
accumulator = noaccum accumulator = noaccum
? (noaccum = false, iteratee[index]) ? (noaccum = false, iteratee[index])
: callback.call(thisArg, accumulator, iteratee[index], index, collection); : callback(accumulator, iteratee[index], index, collection);
}); });
return accumulator; return accumulator;
} }
@@ -2088,7 +2157,7 @@
} }
} }
} else { } else {
forEach(collection, function(value, index, collection) { each(collection, function(value, index, collection) {
return (result = callback(value, index, collection)) && indicatorObject; return (result = callback(value, index, collection)) && indicatorObject;
}); });
} }
@@ -2123,6 +2192,7 @@
function sortBy(collection, callback, thisArg) { function sortBy(collection, callback, thisArg) {
var result = []; var result = [];
callback = createCallback(callback, thisArg); callback = createCallback(callback, thisArg);
forEach(collection, function(value, index, collection) { forEach(collection, function(value, index, collection) {
result.push({ result.push({
'criteria': callback(value, index, collection), 'criteria': callback(value, index, collection),
@@ -2396,8 +2466,8 @@
* @memberOf _ * @memberOf _
* @category Arrays * @category Arrays
* @param {Array} [array1, array2, ...] Arrays to process. * @param {Array} [array1, array2, ...] Arrays to process.
* @returns {Array} Returns a new array of unique elements, in order, that are * @returns {Array} Returns a new array of unique elements that are present
* present in **all** of the arrays. * in **all** of the arrays.
* @example * @example
* *
* _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); * _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
@@ -2406,19 +2476,23 @@
function intersection(array) { function intersection(array) {
var args = arguments, var args = arguments,
argsLength = args.length, argsLength = args.length,
index = -1,
length = array ? array.length : 0,
result = []; result = [];
forEach(array, function(value) { outer:
while (++index < length) {
var value = array[index];
if (indexOf(result, value) < 0) { if (indexOf(result, value) < 0) {
var length = argsLength; var argsIndex = argsLength;
while (--length) { while (--argsIndex) {
if (indexOf(args[length], value) < 0) { if (indexOf(args[argsIndex], value) < 0) {
return; continue outer;
} }
} }
result.push(value); result.push(value);
} }
}); }
return result; return result;
} }
@@ -2629,9 +2703,10 @@
var low = 0, var low = 0,
high = array ? array.length : low; high = array ? array.length : low;
// explicitly reference `identity` for better engine inlining // explicitly reference `identity` for better inlining in Firefox
callback = callback ? createCallback(callback, thisArg) : identity; callback = callback ? createCallback(callback, thisArg) : identity;
value = callback(value); value = callback(value);
while (low < high) { while (low < high) {
var mid = (low + high) >>> 1; var mid = (low + high) >>> 1;
callback(array[mid]) < value callback(array[mid]) < value
@@ -3161,8 +3236,6 @@
/** /**
* This function returns the first argument passed to it. * This function returns the first argument passed to it.
* *
* Note: This function is used throughout Lo-Dash as a default callback.
*
* @static * @static
* @memberOf _ * @memberOf _
* @category Utilities * @category Utilities
@@ -3501,7 +3574,7 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/** /**
* Wraps the value in a `lodash` wrapper object. * Creates a `lodash` object that wraps the given `value`.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -3555,22 +3628,19 @@
} }
/** /**
* This function returns the wrapper object. * Enables method chaining on the wrapper object.
*
* Note: This function is defined to ensure the existing wrapper object is
* returned, instead of creating a new wrapper object like the `_.chain`
* method does.
* *
* @name chain * @name chain
* @deprecated
* @memberOf _ * @memberOf _
* @category Chaining * @category Chaining
* @returns {Mixed} Returns the wrapper object. * @returns {Mixed} Returns the wrapper object.
* @example * @example
* *
* var wrapped = _([1, 2, 3]); * var sum = _([1, 2, 3])
* wrapped === wrapped.chain(); * .chain()
* // => true * .reduce(function(sum, num) { return sum + num; })
* .value()
* // => 6`
*/ */
function wrapperChain() { function wrapperChain() {
this.__chain__ = true; this.__chain__ = true;
@@ -3590,7 +3660,7 @@
* // => '1,2,3' * // => '1,2,3'
*/ */
function wrapperToString() { function wrapperToString() {
return String(this.__wrapped__); return this.__wrapped__ + '';
} }
/** /**
@@ -3612,11 +3682,17 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
// add functions that return wrapped values when chaining
lodash.after = after;
lodash.bind = bind;
lodash.bindAll = bindAll; lodash.bindAll = bindAll;
lodash.chain = chain;
lodash.compact = compact; lodash.compact = compact;
lodash.compose = compose;
lodash.countBy = countBy; lodash.countBy = countBy;
lodash.debounce = debounce;
lodash.defaults = defaults; lodash.defaults = defaults;
lodash.defer = defer;
lodash.delay = delay;
lodash.difference = difference; lodash.difference = difference;
lodash.filter = filter; lodash.filter = filter;
lodash.flatten = flatten; lodash.flatten = flatten;
@@ -3630,9 +3706,11 @@
lodash.keys = keys; lodash.keys = keys;
lodash.map = map; lodash.map = map;
lodash.max = max; lodash.max = max;
lodash.memoize = memoize;
lodash.min = min; lodash.min = min;
lodash.object = object; lodash.object = object;
lodash.omit = omit; lodash.omit = omit;
lodash.once = once;
lodash.pairs = pairs; lodash.pairs = pairs;
lodash.pick = pick; lodash.pick = pick;
lodash.pluck = pluck; lodash.pluck = pluck;
@@ -3642,6 +3720,7 @@
lodash.shuffle = shuffle; lodash.shuffle = shuffle;
lodash.sortBy = sortBy; lodash.sortBy = sortBy;
lodash.tap = tap; lodash.tap = tap;
lodash.throttle = throttle;
lodash.times = times; lodash.times = times;
lodash.toArray = toArray; lodash.toArray = toArray;
lodash.union = union; lodash.union = union;
@@ -3649,6 +3728,7 @@
lodash.values = values; lodash.values = values;
lodash.where = where; lodash.where = where;
lodash.without = without; lodash.without = without;
lodash.wrap = wrap;
lodash.zip = zip; lodash.zip = zip;
// add aliases // add aliases
@@ -3664,14 +3744,8 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
// add functions that return unwrapped values when chaining // add functions that return unwrapped values when chaining
lodash.after = after;
lodash.bind = bind;
lodash.clone = clone; lodash.clone = clone;
lodash.compose = compose;
lodash.contains = contains; lodash.contains = contains;
lodash.debounce = debounce;
lodash.defer = defer;
lodash.delay = delay;
lodash.escape = escape; lodash.escape = escape;
lodash.every = every; lodash.every = every;
lodash.find = find; lodash.find = find;
@@ -3694,10 +3768,8 @@
lodash.isString = isString; lodash.isString = isString;
lodash.isUndefined = isUndefined; lodash.isUndefined = isUndefined;
lodash.lastIndexOf = lastIndexOf; lodash.lastIndexOf = lastIndexOf;
lodash.memoize = memoize;
lodash.mixin = mixin; lodash.mixin = mixin;
lodash.noConflict = noConflict; lodash.noConflict = noConflict;
lodash.once = once;
lodash.random = random; lodash.random = random;
lodash.reduce = reduce; lodash.reduce = reduce;
lodash.reduceRight = reduceRight; lodash.reduceRight = reduceRight;
@@ -3706,10 +3778,8 @@
lodash.some = some; lodash.some = some;
lodash.sortedIndex = sortedIndex; lodash.sortedIndex = sortedIndex;
lodash.template = template; lodash.template = template;
lodash.throttle = throttle;
lodash.unescape = unescape; lodash.unescape = unescape;
lodash.uniqueId = uniqueId; lodash.uniqueId = uniqueId;
lodash.wrap = wrap;
// add aliases // add aliases
lodash.all = every; lodash.all = every;
@@ -3732,6 +3802,8 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
lodash.chain = chain;
/** /**
* The semantic version number. * The semantic version number.
* *
@@ -3739,7 +3811,7 @@
* @memberOf _ * @memberOf _
* @type String * @type String
*/ */
lodash.VERSION = '1.0.0-rc.2'; lodash.VERSION = '1.0.0-rc.3';
// add functions to `lodash.prototype` // add functions to `lodash.prototype`
mixin(lodash); mixin(lodash);
@@ -3748,8 +3820,8 @@
lodash.prototype.chain = wrapperChain; lodash.prototype.chain = wrapperChain;
lodash.prototype.value = wrapperValueOf; lodash.prototype.value = wrapperValueOf;
// add mutator `Array` functions to the wrapper // add `Array` mutator functions to the wrapper
forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
var func = arrayRef[methodName]; var func = arrayRef[methodName];
lodash.prototype[methodName] = function() { lodash.prototype[methodName] = function() {
var value = this.__wrapped__; var value = this.__wrapped__;
@@ -3764,8 +3836,8 @@
}; };
}); });
// add accessor `Array` functions to the wrapper // add `Array` accessor functions to the wrapper
forEach(['concat', 'join', 'slice'], function(methodName) { each(['concat', 'join', 'slice'], function(methodName) {
var func = arrayRef[methodName]; var func = arrayRef[methodName];
lodash.prototype[methodName] = function() { lodash.prototype[methodName] = function() {
var value = this.__wrapped__, var value = this.__wrapped__,

View File

@@ -1,33 +1,33 @@
/*! /*!
Lo-Dash 1.0.0-rc.2 (Custom Build) lodash.com/license Lo-Dash 1.0.0-rc.3 (Custom Build) lodash.com/license
Build: `lodash underscore -m -o ./lodash.underscore.min.js` Build: `lodash underscore -m -o ./lodash.underscore.min.js`
Underscore.js 1.4.3 underscorejs.org/LICENSE Underscore.js 1.4.3 underscorejs.org/LICENSE
*/ */
;(function(e,t){function n(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||"undefined"==typeof e)return 1;if(e<t||"undefined"==typeof t)return-1}return n<r?-1:1}function i(e,t,n){function r(){var i=arguments,s=t;return n.length&&(i=i.length?n.concat(f(i)):n),this instanceof r?(a.prototype=e.prototype,s=new a,a.prototype=null,i=e.apply(s,i),y(i)?i:s):e.apply(s,i)}return r}function s ;(function(e,t){function n(e){if(e&&typeof e=="object"&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||typeof e=="undefined")return 1;if(e<t||typeof t=="undefined")return-1}return n<r?-1:1}function i(e,t,n){function r(){var i=arguments,s=t;return n.length&&(i=i.length?n.concat(f(i)):n),this instanceof r?(a.prototype=e.prototype,s=new a,a.prototype=null,i=e.apply(s,i),y(i)?i:s):e.apply(s,i)}return r}function s
(e,t){return e?"function"!=typeof e?function(t){return t[e]}:"undefined"!=typeof t?function(n,r,i){return e.call(t,n,r,i)}:e:I}function o(e){return"\\"+St[e]}function u(e){return Nt[e]}function a(){}function f(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++r<n;)i[r]=e[t+r];return i}function l(e){return Ct[e]}function c(e){if(!e)return e;for(var t=1,n=arguments.length;t<n;t++){var r=arguments[t];if(r)for(var i in r)e[i]=r[i]}return e}function h(e){ (e,t,n){return e?typeof e!="function"?function(t){return t[e]}:typeof t!="undefined"?n?function(n,r,i,s){return e.call(t,n,r,i,s)}:function(n,r,i){return e.call(t,n,r,i)}:e:q}function o(e){return"\\"+Tt[e]}function u(e){return Lt[e]}function a(){}function f(e,t,n){t||(t=0),typeof n=="undefined"&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++r<n;)i[r]=e[t+r];return i}function l(e){return At[e]}function c(e){if(!e)return e;for(var t=1,n=arguments.length;t<n;t++){var r=arguments[t];if(r)
var t=[];return Tt(e,function(e,n){t.push(n)}),t}function p(e){if(!e)return e;for(var t=1,n=arguments.length;t<n;t++){var r=arguments[t];if(r)for(var i in r)null==e[i]&&(e[i]=r[i])}return e}function d(e){var t=[];return xt(e,function(e,n){g(e)&&t.push(n)}),t.sort()}function v(e){var t={};return Tt(e,function(e,n){t[e]=n}),t}function m(e,t,n,r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;var i=rt.call(e),s=rt.call(t);if(i!=s)return!1;switch(i){case pt:case dt:return+e==+t;case vt for(var i in r)e[i]=r[i]}return e}function h(e){var t=[];return kt(e,function(e,n){t.push(n)}),t}function p(e){if(!e)return e;for(var t=1,n=arguments.length;t<n;t++){var r=arguments[t];if(r)for(var i in r)null==e[i]&&(e[i]=r[i])}return e}function d(e){var t=[];return Ct(e,function(e,n){g(e)&&t.push(n)}),t.sort()}function v(e){var t={};return kt(e,function(e,n){t[e]=n}),t}function m(e,t,n,r){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;var i=it.call(e),s=it.call(t);if(i!=s)return!1
:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case gt:case yt:return e==t+""}s=i==ht;if(!s){if(e.__wrapped__||t.__wrapped__)return m(e.__wrapped__||e,t.__wrapped__||t);if(i!=mt)return!1;var i=e.constructor,o=t.constructor;if(i!=o&&(!g(i)||!(i instanceof i&&g(o)&&o instanceof o)))return!1}n||(n=[]),r||(r=[]);for(i=n.length;i--;)if(n[i]==e)return r[i]==t;var u=!0,a=0;n.push(e),r.push(t);if(s){a=e.length;if(u=a==t.length)for(;a--&&(u=m(e[a],t[a],n,r)););return u}return xt(e,function(e,i,s){if(tt.call(s,i) ;switch(i){case dt:case vt:return+e==+t;case mt:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case yt:case bt:return e==t+""}s=i==pt;if(!s){if(e.__wrapped__||t.__wrapped__)return m(e.__wrapped__||e,t.__wrapped__||t);if(i!=gt)return!1;var i=e.constructor,o=t.constructor;if(i!=o&&(!g(i)||!(i instanceof i&&g(o)&&o instanceof o)))return!1}n||(n=[]),r||(r=[]);for(i=n.length;i--;)if(n[i]==e)return r[i]==t;var u=!0,a=0;n.push(e),r.push(t);if(s){a=e.length;if(u=a==t.length)for(;a--&&(u=m(e[a],t[a],n,r)););return u
)return a++,!(u=tt.call(t,i)&&m(e,t[i],n,r))&&X}),u&&xt(t,function(e,t,n){if(tt.call(n,t))return!(u=-1<--a)&&X}),u}function g(e){return"function"==typeof e}function y(e){return e?Et[typeof e]:!1}function b(e){return"number"==typeof e||rt.call(e)==vt}function w(e){return"string"==typeof e||rt.call(e)==yt}function E(e){var t=[];return Tt(e,function(e){t.push(e)}),t}function S(e,t){var n=!1;return"number"==typeof (e?e.length:0)?n=-1<P(e,t):At(e,function(e){return(n=e===t)&&X}),n}function x(e,t,n){var r=!0 }return Ct(e,function(e,i,s){if(nt.call(s,i))return a++,!(u=nt.call(t,i)&&m(e,t[i],n,r))&&V}),u&&Ct(t,function(e,t,n){if(nt.call(n,t))return!(u=-1<--a)&&V}),u}function g(e){return typeof e=="function"}function y(e){return e?xt[typeof e]:!1}function b(e){return typeof e=="number"||it.call(e)==mt}function w(e){return typeof e=="string"||it.call(e)==bt}function E(e){var t=[];return kt(e,function(e){t.push(e)}),t}function S(e,t){var n=!1;return typeof (e?e.length:0)=="number"?n=-1<H(e,t):Nt(e,function(
,t=s(t,n);if(kt(e))for(var n=-1,i=e.length;++n<i&&(r=!!t(e[n],n,e)););else At(e,function(e,n,i){return!(r=!!t(e,n,i))&&X});return r}function T(e,t,n){var r=[],t=s(t,n);if(kt(e))for(var n=-1,i=e.length;++n<i;){var o=e[n];t(o,n,e)&&r.push(o)}else At(e,function(e,n,i){t(e,n,i)&&r.push(e)});return r}function N(e,t,n){var r,t=s(t,n);return At(e,function(e,n,i){if(t(e,n,i))return r=e,X}),r}function C(e,t,n){var r=-1,i=e?e.length:0,o=Array("number"==typeof i?i:0),t=s(t,n);if(kt(e))for(;++r<i;)o[r]=t(e[r e){return(n=e===t)&&V}),n}function x(e,t,n){var r=!0,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++n<i&&(r=!!t(e[n],n,e)););else Nt(e,function(e,n,i){return!(r=!!t(e,n,i))&&V});return r}function T(e,t,n){var r=[],t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++n<i;){var o=e[n];t(o,n,e)&&r.push(o)}else Nt(e,function(e,n,i){t(e,n,i)&&r.push(e)});return r}function N(e,t,n){var r,t=s(t,n);return C(e,function(e,n,i){if(t(e,n,i))return r=e,V}),r}function C(e,t,n){if(t&&typeof n=="undefined"&&Ot(e))for(var n=-1
],r,e);else At(e,function(e,n,i){o[++r]=t(e,n,i)});return o}function k(e,t,n){var r=-Infinity,i=-1,o=e?e.length:0,u=r;if(t||!kt(e))t=s(t,n),At(e,function(e,n,i){n=t(e,n,i),n>r&&(r=n,u=e)});else for(;++i<o;)e[i]>u&&(u=e[i]);return u}function L(e,t){return C(e,t+"")}function A(e,t,n,r){var i=3>arguments.length;return t||(t=I),At(e,function(e,s,o){n=i?(i=!1,e):t.call(r,n,e,s,o)}),n}function O(e,t,n,r){var i=e?e.length:0,s=3>arguments.length;if("number"!=typeof i)var o=Lt(e),i=o.length;return t||(t=I ,r=e.length;++n<r&&t(e[n],n,e)!==V;);else Nt(e,t,n)}function k(e,t,n){var r=-1,i=e?e.length:0,o=Array(typeof i=="number"?i:0),t=s(t,n);if(Ot(e))for(;++r<i;)o[r]=t(e[r],r,e);else Nt(e,function(e,n,i){o[++r]=t(e,n,i)});return o}function L(e,t,n){var r=-Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Ot(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),n>r&&(r=n,u=e)});else for(;++i<o;)e[i]>u&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,V);if(Ot(e)){var o=-1
),At(e,function(u,a,f){a=o?o[--i]:--i,n=s?(s=!1,e[a]):t.call(r,n,e[a],a,f)}),n}function M(e,t,n){var r,t=s(t,n);if(kt(e))for(var n=-1,i=e.length;++n<i&&!(r=t(e[n],n,e)););else At(e,function(e,n,i){return(r=t(e,n,i))&&X});return!!r}function _(e,t,n){if(e){var r=e.length;return null==t||n?e[0]:f(e,0,lt(ft(0,t),r))}}function D(e,t){for(var n=-1,r=e?e.length:0,i=[];++n<r;){var s=e[n];kt(s)?nt.apply(i,t?s:D(s)):i.push(s)}return i}function P(e,t,n){var r=-1,i=e?e.length:0;if("number"==typeof n)r=(0>n?ft ,u=e.length;for(i&&(n=e[++o]);++o<u;)n=t(n,e[o],o,e)}else Nt(e,function(e,r,s){n=i?(i=!1,e):t(n,e,r,s)});return n}function M(e,t,n,r){var i=e?e.length:0,o=3>arguments.length;if(typeof i!="number")var u=Mt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++n<i&&!(r=t(e[n],n,e)););else Nt(e,function(e,n,i){return(r=t(e,n,i))&&V});return!!r}function D(e,t,n){if(e){var r=e.length;return null==
(0,i+n):n||0)-1;else if(n)return r=B(e,t),e[r]===t?r:-1;for(;++r<i;)if(e[r]===t)return r;return-1}function H(e,t,n){return f(e,null==t||n?1:ft(0,t))}function B(e,t,n,r){for(var i=0,o=e?e.length:i,n=n?s(n,r):I,t=n(t);i<o;)r=i+o>>>1,n(e[r])<t?i=r+1:o=r;return i}function j(e,t,n,r){var i=-1,o=e?e.length:0,u=[],a=u;"function"==typeof t&&(r=n,n=t,t=!1),n&&(a=[],n=s(n,r));for(;++i<o;){var r=e[i],f=n?n(r,i,e):r;if(t?!i||a[a.length-1]!==f:0>P(a,f))n&&a.push(f),u.push(r)}return u}function F(e,t){return bt|| t||n?e[0]:f(e,0,ct(lt(0,t),r))}}function P(e,t){for(var n=-1,r=e?e.length:0,i=[];++n<r;){var s=e[n];Ot(s)?rt.apply(i,t?s:P(s)):i.push(s)}return i}function H(e,t,n){var r=-1,i=e?e.length:0;if(typeof n=="number")r=(0>n?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r<i;)if(e[r]===t)return r;return-1}function B(e,t,n){return f(e,null==t||n?1:lt(0,t))}function j(e,t,n,r){for(var i=0,o=e?e.length:i,n=n?s(n,r):q,t=n(t);i<o;)r=i+o>>>1,n(e[r])<t?i=r+1:o=r;return i}function F(e,t,n,r){var i=-1
it&&2<arguments.length?it.call.apply(it,arguments):i(e,t,f(arguments,2))}function I(e){return e}function q(e){At(d(e),function(t){var r=n[t]=e[t];n.prototype[t]=function(){var e=[this.__wrapped__];return nt.apply(e,arguments),e=r.apply(n,e),this.__chain__&&(e=new n(e),e.__chain__=!0),e}})}var R="object"==typeof exports&&exports,U="object"==typeof global&&global;U.global===U&&(e=U);var z=[],U=new function(){},W=0,X=U,V=e._,$=/&(?:amp|lt|gt|quot|#x27);/g,J=RegExp("^"+(U.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g ,o=e?e.length:0,u=[],a=u;typeof t=="function"&&(r=n,n=t,t=!1),n&&(a=[],n=s(n,r));for(;++i<o;){var r=e[i],f=n?n(r,i,e):r;if(t?!i||a[a.length-1]!==f:0>H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2<arguments.length?st.call.apply(st,arguments):i(e,t,f(arguments,2))}function q(e){return e}function R(e){C(d(e),function(t){var r=n[t]=e[t];n.prototype[t]=function(){var e=[this.__wrapped__];return rt.apply(e,arguments),e=r.apply(n,e),this.__chain__&&(e=new n(e),e.__chain__=!0),e}
,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),K=/($^)/,Q=/[&<>"']/g,G=/['\n\r\t\u2028\u2029\\]/g,Y=Math.ceil,Z=z.concat,et=Math.floor,tt=U.hasOwnProperty,nt=z.push,rt=U.toString,it=J.test(it=f.bind)&&it,st=J.test(st=Array.isArray)&&st,ot=e.isFinite,ut=e.isNaN,at=J.test(at=Object.keys)&&at,ft=Math.max,lt=Math.min,ct=Math.random,ht="[object Array]",pt="[object Boolean]",dt="[object Date]",vt="[object Number]",mt="[object Object]",gt="[object RegExp]",yt="[object String]",U=!!e.attachEvent,U=it&&!/\n|true/ })}var U=typeof exports=="object"&&exports,z=typeof global=="object"&&global;z.global===z&&(e=z);var W=[],z=new function(){},X=0,V=z,$=e._,J=/&(?:amp|lt|gt|quot|#x27);/g,K=RegExp("^"+(z.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Q=/($^)/,G=/[&<>"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st=f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite,at=e.isNaN,ft=
.test(it+U),bt=it&&!U,wt=(wt={0:1,length:1},z.splice.call(wt,0,1),wt[0]),Et={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},St={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},n.isArguments=function(e){return"[object Arguments]"==rt.call(e)},n.isArguments(arguments)||(n.isArguments=function(e){return e?tt.call(e,"callee"):!1} K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029"
);var xt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(t(e[n],n,e)===X)break;return e},Tt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(tt.call(e,n)&&t(e[n],n,e)===X)break;return e},Nt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},Ct=v(Nt),kt=st||function(e){return rt.call(e)==ht};g(/x/)&&(g=function(e){return"[object Function]"==rt.call(e)});var Lt=at?function(e){return y(e)?at(e):[]}:h,At=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t :"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&typeof n=="undefined"?t:s(t,n),r=e.length,n=-1;if(typeof r=="number"){for(;++n<r;)if(t(e[n],n,e)===V)return e}else for(n in e)if(nt.call(e,n)&&t(e[n],n,e)===V)return e};n.isArguments=function(e){return"[object Arguments]"==it.call(e)},n.isArguments(arguments)||(n.isArguments=function(e){return e?nt.call(e,"callee"):!1});var Ct=
,n),r=e.length,n=-1;if("number"==typeof r){for(;++n<r;)if(t(e[n],n,e)===X)return e}else for(n in e)if(tt.call(e,n)&&t(e[n],n,e)===X)return e};n.bindAll=function(e){for(var t=arguments,n=1<t.length?0:(t=d(e),-1),r=t.length;++n<r;){var i=t[n];e[i]=F(e[i],e)}return e},n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.compact=function(e){for(var t=-1,n=e?e.length:0,r=[];++t<n;){var i=e[t];i&&r.push(i)}return r},n.countBy=function(e,t,n){var r={},t=s(t,n);return At(e,function(e,n,i){n=t(e,n,i) function(e,t){var n;if(!e)return e;t||(t=q);for(n in e)if(t(e[n],n,e)===V)break;return e},kt=function(e,t){var n;if(!e)return e;t||(t=q);for(n in e)if(nt.call(e,n)&&t(e[n],n,e)===V)break;return e},Lt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},At=v(Lt),Ot=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Mt=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t){return 1>
,tt.call(r,n)?r[n]++:r[n]=1}),r},n.defaults=p,n.difference=function(e){for(var t=-1,n=e.length,r=Z.apply(z,arguments),i=[];++t<n;){var s=e[t];0>P(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=D,n.forEach=At,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return At(e,function(e,n,i){n=t(e,n,i),(tt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,lt(ft(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1<t.length?0:(t=d(e),-1),r=t.length;++n<r;){var i=t[n];e[i]=I(e[i],e)}return e},n.compact=function(e){for(var t=-1,n=e?e.length:0,r=[];++t<n;){var i=e[t];i&&r.push(i)}return r},n.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length;n--;)t=[e[n].apply(this,t)];return t[0]}},n.countBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),nt
,r=[];return At(e,function(e){if(0>P(r,e)){for(var i=n;--i;)if(0>P(t[i],e))return;r.push(e)}}),r},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return At(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Lt,n.map=C,n.max=k,n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!kt(e))t=s(t,n),At(e,function(e,n,i){n=t(e,n,i),n<r&&(r=n,u=e)});else for(;++i<o;)e[i]<u&&(u=e[i]);return u},n.object=function(e,t){for(var n=-1,r=e?e.length:0,i={};++n< .call(r,n)?r[n]++:r[n]=1}),r},n.debounce=function(e,t,n){function r(){u=null,n||(s=e.apply(o,i))}var i,s,o,u;return function(){var a=n&&!u;return i=arguments,o=this,clearTimeout(u),u=setTimeout(r,t),a&&(s=e.apply(o,i)),s}},n.defaults=p,n.defer=function(e){var n=f(arguments,1);return setTimeout(function(){e.apply(t,n)},1)},n.delay=function(e,n){var r=f(arguments,2);return setTimeout(function(){e.apply(t,r)},n)},n.difference=function(e){for(var t=-1,n=e.length,r=et.apply(W,arguments),i=[];++t<n;){var s=
r;){var s=e[n];t?i[s]=t[n]:i[s[0]]=s[1]}return i},n.omit=function(e){var t=Z.apply(z,arguments),n={};return xt(e,function(e,r){0>P(t,r,1)&&(n[r]=e)}),n},n.pairs=function(e){var t=[];return Tt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=Z.apply(z,arguments),r=n.length,i={};++t<r;){var s=n[t];s in e&&(i[s]=e[s])}return i},n.pluck=L,n.range=function(e,t,n){e=+e||0,n=+n||1,null==t&&(t=e,e=0);for(var r=-1,t=ft(0,Y((t-e)/n)),i=Array(t);++r<t;)i[r]=e,e+=n;return i},n.reject=function( e[t];0>H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++r<i;){var o=e[r];if(0>H(s,o)){for(var u=n;--u;)if(0>H(t[u],o))continue e;s.push(o)}}return s},n.invert=
e,t,n){return t=s(t,n),T(e,function(e,n,r){return!t(e,n,r)})},n.rest=H,n.shuffle=function(e){var t=-1,n=Array(e?e.length:0);return At(e,function(e){var r=et(ct()*(++t+1));n[t]=n[r],n[r]=e}),n},n.sortBy=function(e,t,n){var i=[],t=s(t,n);At(e,function(e,n,r){i.push({a:t(e,n,r),b:n,c:e})}),e=i.length;for(i.sort(r);e--;)i[e]=i[e].c;return i},n.tap=function(e,t){return t(e),e},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++r<e;)i[r]=t.call(n,r);return i},n.toArray=function(e){return"number"==typeof v,n.invoke=function(e,t){var n=f(arguments,2),r=typeof t=="function",i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Mt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Ot(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),n<r&&(r=n,u=e)});else for(;++i<o;)e[i]<u&&(u=e[i]);return u},n.object=function(
(e?e.length:0)?f(e):E(e)},n.union=function(){return j(Z.apply(z,arguments))},n.uniq=j,n.values=E,n.where=function(e,t){var n=Lt(t);return T(e,function(e){for(var r=n.length;r--;){var i=e[n[r]]===t[n[r]];if(!i)break}return!!i})},n.without=function(e){for(var t=-1,n=e.length,r=[];++t<n;){var i=e[t];0>P(arguments,i,1)&&r.push(i)}return r},n.zip=function(e){for(var t=-1,n=e?k(L(arguments,"length")):0,r=Array(n);++t<n;)r[t]=L(arguments,t);return r},n.collect=C,n.drop=H,n.each=At,n.extend=c,n.methods=d e,t){for(var n=-1,r=e?e.length:0,i={};++n<r;){var s=e[n];t?i[s]=t[n]:i[s[0]]=s[1]}return i},n.omit=function(e){var t=et.apply(W,arguments),n={};return Ct(e,function(e,r){0>H(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return kt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t<r;){var s=n[t];s in e&&(i[s]=e[s])}return i},n.pluck=
,n.select=T,n.tail=H,n.unique=j,n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=F,n.clone=function(e){return e&&Et[typeof e]?kt(e)?f(e):c({},e):e},n.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length;n--;)t=[e[n].apply(this,t)];return t[0]}},n.contains=S,n.debounce=function(e,t,n){function r(){u=null,n||(s=e.apply(o,i))}var i,s,o,u;return function(){var a=n&&!u;return i=arguments,o=this,clearTimeout(u),u=setTimeout( A,n.range=function(e,t,n){e=+e||0,n=+n||1,null==t&&(t=e,e=0);for(var r=-1,t=lt(0,Z((t-e)/n)),i=Array(t);++r<t;)i[r]=e,e+=n;return i},n.reject=function(e,t,n){return t=s(t,n),T(e,function(e,n,r){return!t(e,n,r)})},n.rest=B,n.shuffle=function(e){var t=-1,n=Array(e?e.length:0);return C(e,function(e){var r=tt(ht()*(++t+1));n[t]=n[r],n[r]=e}),n},n.sortBy=function(e,t,n){var i=[],t=s(t,n);C(e,function(e,n,r){i.push({a:t(e,n,r),b:n,c:e})}),e=i.length;for(i.sort(r);e--;)i[e]=i[e].c;return i},n.tap=function(
r,t),a&&(s=e.apply(o,i)),s}},n.defer=function(e){var n=f(arguments,1);return setTimeout(function(){e.apply(t,n)},1)},n.delay=function(e,n){var r=f(arguments,2);return setTimeout(function(){e.apply(t,r)},n)},n.escape=function(e){return null==e?"":(e+"").replace(Q,u)},n.every=x,n.find=N,n.has=function(e,t){return e?tt.call(e,t):!1},n.identity=I,n.indexOf=P,n.isArray=kt,n.isBoolean=function(e){return!0===e||!1===e||rt.call(e)==pt},n.isDate=function(e){return rt.call(e)==dt},n.isElement=function(e){return e?1=== e,t){return t(e),e},n.throttle=function(e,t){function n(){u=new Date,o=null,i=e.apply(s,r)}var r,i,s,o,u=0;return function(){var a=new Date,f=t-(a-u);return r=arguments,s=this,0>=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++r<e;)i[r]=t.call(n,r);return i},n.toArray=function(e){return typeof (e?e.length:0)=="number"?f(e):E(e)},n.union=function(){return F(et.apply(W,arguments))},n.uniq=F,n.values=E,n.where=function(
e.nodeType:!1},n.isEmpty=function(e){if(!e)return!0;if(kt(e)||w(e))return!e.length;for(var t in e)if(tt.call(e,t))return!1;return!0},n.isEqual=m,n.isFinite=function(e){return ot(e)&&!ut(parseFloat(e))},n.isFunction=g,n.isNaN=function(e){return b(e)&&e!=+e},n.isNull=function(e){return null===e},n.isNumber=b,n.isObject=y,n.isRegExp=function(e){return rt.call(e)==gt},n.isString=w,n.isUndefined=function(e){return"undefined"==typeof e},n.lastIndexOf=function(e,t,n){var r=e?e.length:0;for("number"==typeof e,t){var n=Mt(t);return T(e,function(e){for(var r=n.length;r--;){var i=e[n[r]]===t[n[r]];if(!i)break}return!!i})},n.without=function(e){for(var t=-1,n=e.length,r=[];++t<n;){var i=e[t];0>H(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++t<n;)r[t]=A(arguments,t);return r},n.collect=k,n.drop=B,n.each=C,n.extend=c,n.methods=d,n.select=T,n.tail=
n&&(r=(0>n?ft(0,r+n):lt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.mixin=q,n.noConflict=function(){return e._=V,this},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+et(ct()*((+t||0)-e+1))},n.reduce=A,n.reduceRight= B,n.unique=F,n.clone=function(e){return e&&xt[typeof e]?Ot(e)?f(e):c({},e):e},n.contains=S,n.escape=function(e){return null==e?"":(e+"").replace(G,u)},n.every=x,n.find=N,n.has=function(e,t){return e?nt.call(e,t):!1},n.identity=q,n.indexOf=H,n.isArray=Ot,n.isBoolean=function(e){return!0===e||!1===e||it.call(e)==dt},n.isDate=function(e){return e instanceof Date||it.call(e)==vt},n.isElement=function(e){return e?1===e.nodeType:!1},n.isEmpty=function(e){if(!e)return!0;if(Ot(e)||w(e))return!e.length;for(
O,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Lt(e).length},n.some=M,n.sortedIndex=B,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||K).source+"|"+(r.interpolate||K).source+"|"+(r.evaluate||K).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(G,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'" var t in e)if(nt.call(e,t))return!1;return!0},n.isEqual=m,n.isFinite=function(e){return ut(e)&&!at(parseFloat(e))},n.isFunction=g,n.isNaN=function(e){return b(e)&&e!=+e},n.isNull=function(e){return null===e},n.isNumber=b,n.isObject=y,n.isRegExp=function(e){return e instanceof RegExp||it.call(e)==yt},n.isString=w,n.isUndefined=function(e){return typeof e=="undefined"},n.lastIndexOf=function(e,t,n){var r=e?e.length:0;for(typeof n=="number"&&(r=(0>n?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;
:"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.throttle=function(e,t){function n(){u=new Date,o=null,i=e.apply(s,r)}var r,i,s,o,u=0;return function(){var a=new Date,f=t-(a-u);return r=arguments,s=this,0>=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return typeof t=="number"?t:Mt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+
(n,f)),i}},n.unescape=function(e){return null==e?"":(e+"").replace($,l)},n.uniqueId=function(e){var t=++W+"";return e?e+t:t},n.wrap=function(e,t){return function(){var n=[e];return nt.apply(n,arguments),t.apply(this,n)}},n.all=x,n.any=M,n.detect=N,n.foldl=A,n.foldr=O,n.include=S,n.inject=A,n.first=_,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,ft(0,r-t))}},n.take=_,n.head=_,n.VERSION="1.0.0-rc.2",q(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype (r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(
.value=function(){return this.__wrapped__},At("pop push reverse shift sort splice unshift".split(" "),function(e){var t=z[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),wt&&e.length===0&&delete e[0],this}}),At(["concat","join","slice"],function(e){var t=z[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),R?"object"==typeof module&&module&&module.exports==R?(module.exports=n)._=n:R._=n:e._= e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift"
n})(this); .split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?typeof module=="object"&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this);

View File

@@ -1,7 +1,7 @@
{ {
"name": "lodash", "name": "lodash",
"version": "1.0.0-rc.2", "version": "1.0.0-rc.3",
"description": "A utility library, usable as a drop-in replacement for Underscore, delivering performance, bug fixes, and additional features.", "description": "An alternative to Underscore.js, delivering consistency, customization, performance, and extra features.",
"homepage": "http://lodash.com", "homepage": "http://lodash.com",
"main": "./lodash", "main": "./lodash",
"keywords": [ "keywords": [

View File

@@ -297,41 +297,77 @@
nestedNumbers2 = [1, [2], [3, [[4]]]];\ nestedNumbers2 = [1, [2], [3, [[4]]]];\
\ \
for (index = 0; index < limit; index++) {\ for (index = 0; index < limit; index++) {\
numbers2[index] = index;\
object2["key" + index] = index;\ object2["key" + index] = index;\
objects2[index] = { "num": index };\ objects2[index] = { "num": index };\
numbers2[index] = index;\
}\ }\
}\ }\
\ \
if (typeof multiArrays != "undefined") {\ if (typeof multiArrays != "undefined") {\
var twentyFiveValues = Array(25),\ var twentyValues = Array(20),\
twentyValues2 = Array(20),\
twentyFiveValues = Array(25),\
twentyFiveValues2 = Array(25),\ twentyFiveValues2 = Array(25),\
thirtyValues = Array(30),\
thirtyValues2 = Array(30),\
fortyValues = Array(40),\
fortyValues2 = Array(40),\
fiftyValues = Array(50),\ fiftyValues = Array(50),\
fiftyValues2 = Array(50),\
seventyFiveValues = Array(75),\ seventyFiveValues = Array(75),\
seventyFiveValues2 = Array(75),\ seventyFiveValues2 = Array(75),\
hundredValues = Array(100),\
hundredValues2 = Array(100),\
lowerChars = "abcdefghijklmnopqrstuvwxyz".split(""),\ lowerChars = "abcdefghijklmnopqrstuvwxyz".split(""),\
upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");\ upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");\
\ \
for (index = 0; index < 75; index++) {\ for (index = 0; index < 100; index++) {\
if (index < 26) {\ if (index < 15) {\
if (index < 20) {\ twentyValues[index] = lowerChars[index];\
twentyFiveValues[index] = lowerChars[index];\ twentyValues2[index] = upperChars[index];\
twentyFiveValues2[index] = upperChars[index];\ }\
}\ if (index < 20) {\
else if (index < 25) {\ twentyValues[index] =\
twentyFiveValues[index] =\ twentyValues2[index] = index;\
twentyFiveValues2[index] = index;\ \
}\ twentyFiveValues[index] = lowerChars[index];\
twentyFiveValues2[index] = upperChars[index];\
}\
if (index < 25) {\
twentyFiveValues[index] =\
twentyFiveValues2[index] = index;\
\
thirtyValues[index] =\
fortyValues[index] =\
fiftyValues[index] =\ fiftyValues[index] =\
seventyFiveValues[index] = lowerChars[index];\ seventyFiveValues[index] =\
seventyFiveValues2[index] = upperChars[index];\ hundredValues[index] = lowerChars[index];\
\
thirtyValues2[index] =\
fortyValues2[index] =\
fiftyValues2[index] =\
seventyFiveValues2[index] =\
hundredValues2[index] = upperChars[index];\
}\ }\
else {\ else {\
if (index < 50) {\ if (index < 30) {\
fiftyValues[index] = index;\ thirtyValues[index] =\
thirtyValues2[index] = index;\
}\ }\
seventyFiveValues[index] = index;\ if (index < 40) {\
seventyFiveValues2[index] = index + (index < 60 ? 75 : 0);\ fortyValues[index] =\
fortyValues2[index] = index;\
}\
if (index < 50) {\
fiftyValues[index] =\
fiftyValues2[index] = index;\
}\
if (index < 75) {\
seventyFiveValues[index] =\
seventyFiveValues2[index] = index;\
}\
hundredValues[index] =\
hundredValues2[index] = index;\
}\ }\
}\ }\
}\ }\
@@ -630,45 +666,33 @@
suites.push( suites.push(
Benchmark.Suite('`_.difference`') Benchmark.Suite('`_.difference`')
.add(buildName, '\ .add(buildName, '\
lodash.difference(numbers, fourNumbers, twoNumbers)' lodash.difference(numbers, twoNumbers, fourNumbers)'
) )
.add(otherName, '\ .add(otherName, '\
_.difference(numbers, fourNumbers, twoNumbers)' _.difference(numbers, twoNumbers, fourNumbers)'
) )
); );
suites.push( suites.push(
Benchmark.Suite('`_.difference` iterating 25 elements') Benchmark.Suite('`_.difference` iterating 30 elements')
.add(buildName, { .add(buildName, {
'fn': 'lodash.difference(twentyFiveValues, twentyFiveValues2)', 'fn': 'lodash.difference(thirtyValues, thirtyValues2)',
'teardown': 'function multiArrays(){}' 'teardown': 'function multiArrays(){}'
}) })
.add(otherName, { .add(otherName, {
'fn': '_.difference(twentyFiveValues, twentyFiveValues2)', 'fn': '_.difference(thirtyValues, thirtyValues2)',
'teardown': 'function multiArrays(){}' 'teardown': 'function multiArrays(){}'
}) })
); );
suites.push( suites.push(
Benchmark.Suite('`_.difference` iterating 50 and 75 elements') Benchmark.Suite('`_.difference` iterating 20 and 40 elements')
.add(buildName, { .add(buildName, {
'fn': 'lodash.difference(fiftyValues, seventyFiveValues2)', 'fn': 'lodash.difference(twentyValues, fortyValues2)',
'teardown': 'function multiArrays(){}' 'teardown': 'function multiArrays(){}'
}) })
.add(otherName, { .add(otherName, {
'fn': '_.difference(fiftyValues, seventyFiveValues2)', 'fn': '_.difference(twentyValues, fortyValues2)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.difference` iterating 75 elements')
.add(buildName, {
'fn': 'lodash.difference(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.difference(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}' 'teardown': 'function multiArrays(){}'
}) })
); );
@@ -936,45 +960,21 @@
suites.push( suites.push(
Benchmark.Suite('`_.intersection`') Benchmark.Suite('`_.intersection`')
.add(buildName, '\ .add(buildName, '\
lodash.intersection(numbers, fourNumbers, twoNumbers)' lodash.intersection(numbers, twoNumbers, fourNumbers)'
) )
.add(otherName, '\ .add(otherName, '\
_.intersection(numbers, fourNumbers, twoNumbers)' _.intersection(numbers, twoNumbers, fourNumbers)'
) )
); );
suites.push( suites.push(
Benchmark.Suite('`_.intersection` iterating 25 elements') Benchmark.Suite('`_.intersection` iterating 100 elements')
.add(buildName, { .add(buildName, {
'fn': 'lodash.intersection(twentyFiveValues, twentyFiveValues2)', 'fn': 'lodash.intersection(hundredValues, hundredValues2)',
'teardown': 'function multiArrays(){}' 'teardown': 'function multiArrays(){}'
}) })
.add(otherName, { .add(otherName, {
'fn': '_.intersection(twentyFiveValues, twentyFiveValues2)', 'fn': '_.intersection(hundredValues, hundredValues2)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.intersection` iterating 50 and 75 elements')
.add(buildName, {
'fn': 'lodash.intersection(fiftyValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.intersection(fiftyValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.intersection` iterating 75 elements')
.add(buildName, {
'fn': 'lodash.intersection(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.intersection(seventyFiveValues, seventyFiveValues2)',
'teardown': 'function multiArrays(){}' 'teardown': 'function multiArrays(){}'
}) })
); );
@@ -1624,51 +1624,51 @@
suites.push( suites.push(
Benchmark.Suite('`_.union`') Benchmark.Suite('`_.union`')
.add(buildName, '\ .add(buildName, '\
lodash.union(numbers, fourNumbers, twoNumbers)' lodash.union(numbers, twoNumbers, fourNumbers)'
) )
.add(otherName, '\ .add(otherName, '\
_.union(numbers, fourNumbers, twoNumbers)' _.union(numbers, twoNumbers, fourNumbers)'
) )
); );
suites.push(
Benchmark.Suite('`_.union` iterating an array of 75 elements')
.add(buildName, {
'fn': 'lodash.union(fiftyValues, twentyFiveValues2);',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.union(fiftyValues, twentyFiveValues2);',
'teardown': 'function multiArrays(){}'
})
);
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
suites.push( suites.push(
Benchmark.Suite('`_.uniq`') Benchmark.Suite('`_.uniq`')
.add(buildName, '\ .add(buildName, '\
lodash.uniq(numbers.concat(fourNumbers, twoNumbers))' lodash.uniq(numbers.concat(twoNumbers, fourNumbers))'
) )
.add(otherName, '\ .add(otherName, '\
_.uniq(numbers.concat(fourNumbers, twoNumbers))' _.uniq(numbers.concat(twoNumbers, fourNumbers))'
) )
); );
suites.push( suites.push(
Benchmark.Suite('`_.uniq` with `callback`') Benchmark.Suite('`_.uniq` with `callback`')
.add(buildName, '\ .add(buildName, '\
lodash.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {\ lodash.uniq(numbers.concat(twoNumbers, fourNumbers), function(num) {\
return num % 2;\ return num % 2;\
});' });'
) )
.add(otherName, '\ .add(otherName, '\
_.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {\ _.uniq(numbers.concat(twoNumbers, fourNumbers), function(num) {\
return num % 2;\ return num % 2;\
})' })'
) )
); );
suites.push(
Benchmark.Suite('`_.uniq` iterating an array of 50 elements')
.add(buildName, {
'fn': 'lodash.uniq(twentyFiveValues.concat(twentyFiveValues2));',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.uniq(twentyFiveValues.concat(twentyFiveValues2));',
'teardown': 'function multiArrays(){}'
})
);
suites.push( suites.push(
Benchmark.Suite('`_.uniq` iterating an array of 75 elements') Benchmark.Suite('`_.uniq` iterating an array of 75 elements')
.add(buildName, { .add(buildName, {
@@ -1681,18 +1681,6 @@
}) })
); );
suites.push(
Benchmark.Suite('`_.uniq` iterating an array of 100 elements')
.add(buildName, {
'fn': 'lodash.uniq(seventyFiveValues.concat(twentyFiveValues2));',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.uniq(seventyFiveValues.concat(twentyFiveValues2));',
'teardown': 'function multiArrays(){}'
})
);
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
suites.push( suites.push(
@@ -1730,37 +1718,13 @@
); );
suites.push( suites.push(
Benchmark.Suite('`_.without` iterating an array of 25 elements') Benchmark.Suite('`_.without` iterating an array of 20 elements')
.add(buildName, { .add(buildName, {
'fn': 'lodash.without.apply(lodash, [twentyFiveValues].concat(twentyFiveValues2));', 'fn': 'lodash.without.apply(lodash, [twentyValues].concat(twentyValues2));',
'teardown': 'function multiArrays(){}' 'teardown': 'function multiArrays(){}'
}) })
.add(otherName, { .add(otherName, {
'fn': '_.without.apply(_, [twentyFiveValues].concat(twentyFiveValues2));', 'fn': '_.without.apply(_, [twentyValues].concat(twentyValues2));',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.without` iterating an array of 75 and 50 elements')
.add(buildName, {
'fn': 'lodash.without.apply(lodash, [seventyFiveValues2].concat(fiftyValues));',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.without.apply(_, [seventyFiveValues2].concat(fiftyValues));',
'teardown': 'function multiArrays(){}'
})
);
suites.push(
Benchmark.Suite('`_.without` iterating an array of 75 elements')
.add(buildName, {
'fn': 'lodash.without.apply(lodash, [seventyFiveValues].concat(seventyFiveValues2));',
'teardown': 'function multiArrays(){}'
})
.add(otherName, {
'fn': '_.without.apply(_, [seventyFiveValues].concat(seventyFiveValues2));',
'teardown': 'function multiArrays(){}' 'teardown': 'function multiArrays(){}'
}) })
); );

View File

@@ -12,7 +12,7 @@
</head> </head>
<body> <body>
<div id="qunit"></div> <div id="qunit"></div>
<h1 id="qunit-header"><a href="#">Backbone Speed Suite</a></h1> <h1 id="qunit-header"></h1>
<div id="qunit-fixture"> <div id="qunit-fixture">
<div id='testElement'> <div id='testElement'>
<h1>Test</h1> <h1>Test</h1>
@@ -29,9 +29,23 @@
); );
</script> </script>
<script src="test-ui.js"></script> <script src="test-ui.js"></script>
<script src="../lodash.js"></script>
<script> <script>
var lodash = _.noConflict();
document.write('<script src="../' + ui.buildPath + '"><\/script>'); document.write('<script src="../' + ui.buildPath + '"><\/script>');
</script> </script>
<script>
_.mixin({
'debounce': lodash.debounce
});
if (!_.chain) {
_.mixin({
'chain': function(value) {
return new _(value);
}
});
}
</script>
<script src="../vendor/backbone/backbone.js"></script> <script src="../vendor/backbone/backbone.js"></script>
<script src="../vendor/backbone/test/environment.js"></script> <script src="../vendor/backbone/test/environment.js"></script>
<script src="../vendor/backbone/test/noconflict.js"></script> <script src="../vendor/backbone/test/noconflict.js"></script>

View File

@@ -54,9 +54,9 @@
}; };
/** List of all Lo-Dash methods */ /** List of all Lo-Dash methods */
var allMethods = _.functions(_).filter(function(methodName) { var allMethods = _.functions(_)
return !/^_/.test(methodName); .filter(function(methodName) { return !/^_/.test(methodName); })
}); .concat('chain');
/** List of "Arrays" category methods */ /** List of "Arrays" category methods */
var arraysMethods = [ var arraysMethods = [
@@ -86,7 +86,6 @@
/** List of "Chaining" category methods */ /** List of "Chaining" category methods */
var chainingMethods = [ var chainingMethods = [
'chain',
'mixin', 'mixin',
'tap', 'tap',
'value' 'value'
@@ -148,6 +147,7 @@
var objectsMethods = [ var objectsMethods = [
'assign', 'assign',
'clone', 'clone',
'cloneDeep',
'defaults', 'defaults',
'extend', 'extend',
'forIn', 'forIn',
@@ -229,6 +229,7 @@
'max', 'max',
'min', 'min',
'mixin', 'mixin',
'once',
'pick', 'pick',
'reduce', 'reduce',
'reduceRight', 'reduceRight',
@@ -249,6 +250,7 @@
/** List of methods used by Underscore */ /** List of methods used by Underscore */
var underscoreMethods = _.without.apply(_, [allMethods].concat([ var underscoreMethods = _.without.apply(_, [allMethods].concat([
'bindKey', 'bindKey',
'cloneDeep',
'forIn', 'forIn',
'forOwn', 'forOwn',
'isPlainObject', 'isPlainObject',
@@ -445,7 +447,7 @@
console.log(e); console.log(e);
pass = false; pass = false;
} }
equal(pass, true, '_.' + methodName + ': ' + message); ok(pass, '_.' + methodName + ': ' + message);
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@@ -489,61 +491,69 @@
context._ = _; context._ = _;
vm.runInContext(source, context); vm.runInContext(source, context);
var templates = context._.templates;
equal(templates.a(data.a).replace(/[\r\n]+/g, ''), '<ul><li>moe</li><li>larry</li><li>curly</li></ul>', basename); equal(_.templates.a(data.a).replace(/[\r\n]+/g, ''), '<ul><li>moe</li><li>larry</li><li>curly</li></ul>', basename);
equal(templates.b(data.b), 'Hello stooge.', basename); equal(_.templates.b(data.b), 'Hello stooge.', basename);
equal(templates.c(data.c), 'Hello ES6!', basename); equal(_.templates.c(data.c), 'Hello ES6!', basename);
delete _.templates; delete _.templates;
start(); start();
}); });
}); });
['', 'moduleId=underscore'].forEach(function(command) { var commands = [
'',
'moduleId=underscore'
];
commands.forEach(function(command) {
asyncTest('`lodash template=*.jst` exports=amd' + (command ? ' ' + command : ''), function() { asyncTest('`lodash template=*.jst` exports=amd' + (command ? ' ' + command : ''), function() {
var start = _.after(2, _.once(QUnit.start)); var start = _.after(2, _.once(QUnit.start));
build(['-s', 'template=' + templatePath + '/*.jst', 'exports=amd'].concat(command || []), function(source, filePath) { build(['-s', 'template=' + templatePath + '/*.jst', 'exports=amd'].concat(command || []), function(source, filePath) {
var moduleId, var moduleId,
basename = path.basename(filePath, '.js'), basename = path.basename(filePath, '.js'),
context = createContext(), context = createContext();
pass = false;
(context.define = function(requires, factory) { context.define = function(requires, factory) {
factory(_); factory(_);
var templates = _.templates; moduleId = requires[0];
moduleId = requires + ''; };
pass = 'a' in templates && 'b' in templates;
})
.amd = {};
context.define.amd = {};
vm.runInContext(source, context); vm.runInContext(source, context);
equal(moduleId, command ? 'underscore' : 'lodash'); equal(moduleId, (command ? 'underscore' : 'lodash'), basename);
ok(pass, basename); ok('a' in _.templates && 'b' in _.templates, basename);
delete _.templates; delete _.templates;
start(); start();
}); });
}); });
});
asyncTest('`lodash settings=...`', function() { asyncTest('`lodash settings=...`' + (command ? ' ' + command : ''), function() {
var start = _.after(2, _.once(QUnit.start)); var start = _.after(2, _.once(QUnit.start));
build(['-s', 'template=' + templatePath + '/*.tpl', 'settings={interpolate:/\\{\\{([\\s\\S]+?)\\}\\}/}'], function(source, filePath) { build(['-s', 'template=' + templatePath + '/*.tpl', 'settings={interpolate:/\\{\\{([\\s\\S]+?)\\}\\}/}'].concat(command || []), function(source, filePath) {
var basename = path.basename(filePath, '.js'), var moduleId,
context = createContext(); basename = path.basename(filePath, '.js'),
context = createContext();
var data = { var data = {
'd': { 'name': 'Mustache' } 'd': { 'name': 'Mustache' }
}; };
context._ = _; context.define = function(requires, factory) {
vm.runInContext(source, context); factory(_);
var templates = context._.templates; moduleId = requires[0];
};
equal(templates.d(data.d), 'Hello Mustache!', basename); context.define.amd = {};
start(); vm.runInContext(source, context);
equal(moduleId, (command ? 'underscore' : 'lodash'), basename);
equal(_.templates.d(data.d), 'Hello Mustache!', basename);
delete _.templates;
start();
});
}); });
}); });
}()); }());
@@ -553,6 +563,9 @@
QUnit.module('independent builds'); QUnit.module('independent builds');
(function() { (function() {
var reComment = /\/\*![\s\S]+?\*\//,
reCustom = /Custom Build/;
asyncTest('debug only', function() { asyncTest('debug only', function() {
var start = _.once(QUnit.start); var start = _.once(QUnit.start);
build(['-d', '-s'], function(source, filePath) { build(['-d', '-s'], function(source, filePath) {
@@ -565,6 +578,9 @@
var start = _.once(QUnit.start); var start = _.once(QUnit.start);
build(['-d', '-s', 'backbone'], function(source, filePath) { build(['-d', '-s', 'backbone'], function(source, filePath) {
equal(path.basename(filePath, '.js'), 'lodash.custom'); equal(path.basename(filePath, '.js'), 'lodash.custom');
var comment = source.match(reComment);
ok(reCustom.test(comment));
start(); start();
}); });
}); });
@@ -581,6 +597,9 @@
var start = _.once(QUnit.start); var start = _.once(QUnit.start);
build(['-m', '-s', 'backbone'], function(source, filePath) { build(['-m', '-s', 'backbone'], function(source, filePath) {
equal(path.basename(filePath, '.js'), 'lodash.custom.min'); equal(path.basename(filePath, '.js'), 'lodash.custom.min');
var comment = source.match(reComment);
ok(reCustom.test(comment));
start(); start();
}); });
}); });
@@ -625,7 +644,51 @@
return pass; return pass;
}); });
equal(actual, true, basename); ok(actual, basename);
start();
});
});
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('underscore chaining methods');
(function() {
var commands = [
'backbone',
'underscore'
];
commands.forEach(function(command) {
asyncTest('`lodash ' + command +'`', function() {
var start = _.after(2, _.once(QUnit.start));
build(['-s', command], function(source, filePath) {
var basename = path.basename(filePath, '.js'),
context = createContext();
vm.runInContext(source, context);
var lodash = context._;
ok(lodash.chain(1) instanceof lodash, '_.chain: ' + basename);
ok(lodash(1).chain() instanceof lodash, '_#chain: ' + basename);
var wrapped = lodash(1);
strictEqual(wrapped.identity(), 1, '_(...) wrapped values are not chainable by default: ' + basename);
equal(String(wrapped) === '1', false, '_#toString should not be implemented: ' + basename);
equal(Number(wrapped) === 1 , false, '_#valueOf should not be implemented: ' + basename);
wrapped.chain();
ok(wrapped.has('x') instanceof lodash, '_#has returns wrapped values when chaining: ' + basename);
ok(wrapped.join() instanceof lodash, '_#join returns wrapped values when chaining: ' + basename);
wrapped = lodash([1, 2, 3]);
ok(wrapped.pop() instanceof lodash, '_#pop returns wrapped values: ' + basename);
ok(wrapped.shift() instanceof lodash, '_#shift returns wrapped values: ' + basename);
deepEqual(wrapped.splice(0, 0).value(), [2], '_#splice returns wrapper: ' + basename);
start(); start();
}); });
}); });
@@ -652,10 +715,10 @@
var object = { 'fn': lodash.bind(function(foo) { return foo + this.bar; }, { 'bar': 1 }, 1) }; var object = { 'fn': lodash.bind(function(foo) { return foo + this.bar; }, { 'bar': 1 }, 1) };
equal(object.fn(), 2, '_.bind: ' + basename); equal(object.fn(), 2, '_.bind: ' + basename);
ok(lodash.clone(array, true)[0] === array[0], '_.clone should be shallow: ' + basename); strictEqual(lodash.clone(array, true)[0], array[0], '_.clone should be shallow: ' + basename);
equal(lodash.contains({ 'a': 1, 'b': 2 }, 1), true, '_.contains should work with objects: ' + basename); ok(lodash.contains({ 'a': 1, 'b': 2 }, 1), '_.contains should work with objects: ' + basename);
equal(lodash.contains([1, 2, 3], 1, 2), true, '_.contains should ignore `fromIndex`: ' + basename); ok(lodash.contains([1, 2, 3], 1, 2), '_.contains should ignore `fromIndex`: ' + basename);
equal(lodash.every([true, false, true]), false, '_.every: ' + basename); ok(!lodash.every([true, false, true]), '_.every: ' + basename);
function Foo() {} function Foo() {}
Foo.prototype = { 'a': 1 }; Foo.prototype = { 'a': 1 };
@@ -694,18 +757,10 @@
actual = lodash.pick(object, function(value) { return value != 3; }); actual = lodash.pick(object, function(value) { return value != 3; });
deepEqual(_.keys(actual), [], '_.pick should not accept a `callback`: ' + basename); deepEqual(_.keys(actual), [], '_.pick should not accept a `callback`: ' + basename);
equal(lodash.some([false, true, false]), true, '_.some: ' + basename); ok(lodash.some([false, true, false]), '_.some: ' + basename);
equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename); equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename);
equal(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename); equal(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename);
var wrapped = lodash(1);
equal(wrapped.clone() instanceof lodash, false, '_(...) wrapped values are not chainable by default: ' + basename);
equal(String(wrapped) === '1', false, '_#toString should not be implemented: ' + basename);
equal(Number(wrapped) === 1 , false, '_#valueOf should not be implemented: ' + basename);
wrapped.chain();
equal(wrapped.has('x') instanceof lodash, true, '_#has returns wrapped values when chaining: ' + basename);
start(); start();
}); });
}); });
@@ -806,8 +861,8 @@
case 1: case 1:
context.exports = {}; context.exports = {};
vm.runInContext(source, context); vm.runInContext(source, context);
ok(context._ === undefined, basename); ok(_.isFunction(context.exports._), basename);
ok(_.isFunction(context.exports._), basename) strictEqual(context._, undefined, basename);
break; break;
case 2: case 2:
@@ -819,13 +874,13 @@
context.exports = {}; context.exports = {};
context.module = { 'exports': context.exports }; context.module = { 'exports': context.exports };
vm.runInContext(source, context); vm.runInContext(source, context);
ok(context._ === undefined, basename);
ok(_.isFunction(context.module.exports), basename); ok(_.isFunction(context.module.exports), basename);
strictEqual(context._, undefined, basename);
break; break;
case 4: case 4:
vm.runInContext(source, context); vm.runInContext(source, context);
ok(context._ === undefined, basename); strictEqual(context._, undefined, basename);
} }
start(); start();
}); });
@@ -874,7 +929,12 @@
QUnit.module('output options'); QUnit.module('output options');
(function() { (function() {
['-o a.js', '--output a.js'].forEach(function(command, index) { var commands = [
'-o a.js',
'--output a.js'
];
commands.forEach(function(command, index) {
asyncTest('`lodash ' + command +'`', function() { asyncTest('`lodash ' + command +'`', function() {
var start = _.once(QUnit.start); var start = _.once(QUnit.start);
@@ -891,7 +951,12 @@
QUnit.module('stdout options'); QUnit.module('stdout options');
(function() { (function() {
['-c', '--stdout'].forEach(function(command, index) { var commands = [
'-c',
'--stdout'
];
commands.forEach(function(command, index) {
asyncTest('`lodash ' + command +'`', function() { asyncTest('`lodash ' + command +'`', function() {
var written, var written,
start = _.once(QUnit.start), start = _.once(QUnit.start),
@@ -931,7 +996,6 @@
} catch(e) { } catch(e) {
console.log(e); console.log(e);
} }
var underscore = context._ || {}; var underscore = context._ || {};
ok(_.isString(underscore.VERSION)); ok(_.isString(underscore.VERSION));
ok(!/Lo-Dash/.test(result) && result.match(/\n/g).length < source.match(/\n/g).length); ok(!/Lo-Dash/.test(result) && result.match(/\n/g).length < source.match(/\n/g).length);
@@ -972,7 +1036,7 @@
deepEqual(lodash.merge(object1, object2), object3, basename); deepEqual(lodash.merge(object1, object2), object3, basename);
deepEqual(lodash.sortBy([3, 2, 1], _.identity), array, basename); deepEqual(lodash.sortBy([3, 2, 1], _.identity), array, basename);
equal(lodash.isEqual(circular1, circular2), true, basename); ok(lodash.isEqual(circular1, circular2), basename);
var actual = lodash.clone(circular1, true); var actual = lodash.clone(circular1, true);
ok(actual != circular1 && actual.b == actual, basename); ok(actual != circular1 && actual.b == actual, basename);

View File

@@ -243,7 +243,7 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
QUnit.module('lodash.clone'); QUnit.module('cloning');
(function() { (function() {
function Klass() { this.a = 1; } function Klass() { this.a = 1; }
@@ -277,11 +277,11 @@
_.forOwn(objects, function(object, key) { _.forOwn(objects, function(object, key) {
test('should deep clone ' + key, function() { test('should deep clone ' + key, function() {
var clone = _.clone(object, true); var clone = _.cloneDeep(object);
ok(_.isEqual(object, clone)); ok(_.isEqual(object, clone));
if (_.isObject(object)) { if (_.isObject(object)) {
ok(clone !== object); notStrictEqual(clone, object);
} else { } else {
skipTest(); skipTest();
} }
@@ -290,8 +290,8 @@
_.forOwn(nonCloneable, function(object, key) { _.forOwn(nonCloneable, function(object, key) {
test('should not clone ' + key, function() { test('should not clone ' + key, function() {
ok(_.clone(object) === object); strictEqual(_.clone(object), object);
ok(_.clone(object, true) === object); strictEqual(_.cloneDeep(object), object);
}); });
}); });
@@ -304,7 +304,7 @@
test('should deep clone `index` and `input` array properties', function() { test('should deep clone `index` and `input` array properties', function() {
var array = /x/.exec('x'), var array = /x/.exec('x'),
actual = _.clone(array, true); actual = _.cloneDeep(array);
equal(actual.index, 0); equal(actual.index, 0);
equal(actual.input, 'x'); equal(actual.input, 'x');
@@ -319,15 +319,15 @@
object.foo.b.foo.c = object; object.foo.b.foo.c = object;
object.bar.b = object.foo.b; object.bar.b = object.foo.b;
var clone = _.clone(object, true); var clone = _.cloneDeep(object);
ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c && clone !== object); ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c && clone !== object);
}); });
test('should clone problem JScript properties (test in IE < 9)', function() { test('should clone problem JScript properties (test in IE < 9)', function() {
deepEqual(_.clone(shadowed), shadowed); deepEqual(_.clone(shadowed), shadowed);
ok(_.clone(shadowed) != shadowed); notEqual(_.clone(shadowed), shadowed);
deepEqual(_.clone(shadowed, true), shadowed); deepEqual(_.cloneDeep(shadowed), shadowed);
ok(_.clone(shadowed, true) != shadowed); notEqual(_.cloneDeep(shadowed), shadowed);
}); });
}(1, 2, 3)); }(1, 2, 3));
@@ -343,7 +343,7 @@
}, },
function(collection, key) { function(collection, key) {
test('should work with ' + key + ' and a positive `fromIndex`', function() { test('should work with ' + key + ' and a positive `fromIndex`', function() {
equal(_.contains(collection, 1, 2), true); ok(_.contains(collection, 1, 2));
}); });
test('should work with ' + key + ' and a `fromIndex` >= collection\'s length', function() { test('should work with ' + key + ' and a `fromIndex` >= collection\'s length', function() {
@@ -354,12 +354,12 @@
}); });
test('should work with ' + key + ' and a negative `fromIndex`', function() { test('should work with ' + key + ' and a negative `fromIndex`', function() {
equal(_.contains(collection, 2, -3), true); ok(_.contains(collection, 2, -3));
}); });
test('should work with ' + key + ' and a negative `fromIndex` <= negative collection\'s length', function() { test('should work with ' + key + ' and a negative `fromIndex` <= negative collection\'s length', function() {
equal(_.contains(collection, 1, -6), true); ok(_.contains(collection, 1, -6));
equal(_.contains(collection, 2, -8), true); ok(_.contains(collection, 2, -8));
}); });
}); });
@@ -369,8 +369,8 @@
}, },
function(collection, key) { function(collection, key) {
test('should work with a string ' + key + ' for `collection`', function() { test('should work with a string ' + key + ' for `collection`', function() {
equal(_.contains(collection, 'bc'), true); ok(_.contains(collection, 'bc'));
equal(_.contains(collection, 'd'), false); ok(!_.contains(collection, 'd'));
}); });
}); });
}()); }());
@@ -453,7 +453,7 @@
(function() { (function() {
test('should return `false` as soon as the `callback` result is falsey', function() { test('should return `false` as soon as the `callback` result is falsey', function() {
equal(_.every([true, null, true], _.identity), false); ok(!_.every([true, null, true], _.identity));
}); });
}()); }());
@@ -770,7 +770,7 @@
(function() { (function() {
test('should use strict equality in its duck type check', function() { test('should use strict equality in its duck type check', function() {
var element = window.document ? document.body : { 'nodeType': 1 }; var element = window.document ? document.body : { 'nodeType': 1 };
equal(_.isElement(element), true); ok(_.isElement(element));
equal(_.isElement({ 'nodeType': new Number(1) }), false); equal(_.isElement({ 'nodeType': new Number(1) }), false);
equal(_.isElement({ 'nodeType': true }), false); equal(_.isElement({ 'nodeType': true }), false);
@@ -794,21 +794,21 @@
test('skips the prototype property of functions (test in Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1)', function() { test('skips the prototype property of functions (test in Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1)', function() {
function Foo() {} function Foo() {}
Foo.prototype.a = 1; Foo.prototype.a = 1;
equal(_.isEmpty(Foo), true); ok(_.isEmpty(Foo));
Foo.prototype = { 'a': 1 }; Foo.prototype = { 'a': 1 };
equal(_.isEmpty(Foo), true); ok(_.isEmpty(Foo));
}); });
test('should work with an object that has a `length` property', function() { test('should work with an object that has a `length` property', function() {
equal(_.isEmpty({ 'length': 0 }), false); ok(!_.isEmpty({ 'length': 0 }));
}); });
test('should work with jQuery/MooTools DOM query collections', function() { test('should work with jQuery/MooTools DOM query collections', function() {
function Foo(elements) { Array.prototype.push.apply(this, elements); } function Foo(elements) { Array.prototype.push.apply(this, elements); }
Foo.prototype = { 'length': 0, 'splice': Array.prototype.splice }; Foo.prototype = { 'length': 0, 'splice': Array.prototype.splice };
equal(_.isEmpty(new Foo([])), true); ok(_.isEmpty(new Foo([])));
}); });
test('should work with `arguments` objects (test in IE < 9)', function() { test('should work with `arguments` objects (test in IE < 9)', function() {
@@ -826,8 +826,8 @@
args2 = (function() { return arguments; }(1, 2, 3)), args2 = (function() { return arguments; }(1, 2, 3)),
args3 = (function() { return arguments; }(1, 2)); args3 = (function() { return arguments; }(1, 2));
equal(_.isEqual(args1, args2), true); ok(_.isEqual(args1, args2));
equal(_.isEqual(args1, args3), false); ok(!_.isEqual(args1, args3));
}); });
test('fixes the JScript [[DontEnum]] bug (test in IE < 9)', function() { test('fixes the JScript [[DontEnum]] bug (test in IE < 9)', function() {
@@ -838,7 +838,7 @@
// ensure `_._object` is assigned (unassigned in Opera 10.00) // ensure `_._object` is assigned (unassigned in Opera 10.00)
if (_._object) { if (_._object) {
var object = { 'a': 1, 'b': 2, 'c': 3 }; var object = { 'a': 1, 'b': 2, 'c': 3 };
equal(_.isEqual(object, _._object), true); ok(_.isEqual(object, _._object));
} }
else { else {
skipTest(); skipTest();
@@ -865,18 +865,18 @@
(function() { (function() {
test('should return `false` for non-numeric values', function() { test('should return `false` for non-numeric values', function() {
equal(_.isFinite(null), false); ok(!_.isFinite(null));
equal(_.isFinite([]), false); ok(!_.isFinite([]));
equal(_.isFinite(true), false); ok(!_.isFinite(true));
equal(_.isFinite(''), false); ok(!_.isFinite(''));
equal(_.isFinite(' '), false); ok(!_.isFinite(' '));
equal(_.isFinite('2px'), false); ok(!_.isFinite('2px'));
}); });
test('should return `true` for numeric string values', function() { test('should return `true` for numeric string values', function() {
equal(_.isFinite('2'), true); ok(_.isFinite('2'));
equal(_.isFinite('0'), true); ok(_.isFinite('0'));
equal(_.isFinite('08'), true); ok(_.isFinite('08'));
}); });
}()); }());
@@ -906,7 +906,7 @@
(function() { (function() {
test('returns `true` for `new Number(NaN)`', function() { test('returns `true` for `new Number(NaN)`', function() {
equal(_.isNaN(new Number(NaN)), true) ok(_.isNaN(new Number(NaN)));
}); });
}()); }());
@@ -920,9 +920,9 @@
this.a = 1; this.a = 1;
} }
equal(_.isPlainObject(new Foo(1)), false); ok(!_.isPlainObject(new Foo(1)));
equal(_.isPlainObject([1, 2, 3]), false); ok(!_.isPlainObject([1, 2, 3]));
equal(_.isPlainObject({ 'a': 1 }), true); ok(_.isPlainObject({ 'a': 1 }));
}); });
}()); }());
@@ -947,7 +947,8 @@
'isRegExp', 'isRegExp',
'isString', 'isString',
'isUndefined' 'isUndefined'
], function(methodName) { ],
function(methodName) {
var func = _[methodName]; var func = _[methodName];
test('lodash.' + methodName + ' should return a boolean', function() { test('lodash.' + methodName + ' should return a boolean', function() {
@@ -1357,7 +1358,7 @@
while ((new Date - start) < 50 && actual == 5) { while ((new Date - start) < 50 && actual == 5) {
actual = _.random(5); actual = _.random(5);
} }
ok(actual != 5); notEqual(actual, 5);
}); });
}()); }());
@@ -1540,7 +1541,7 @@
(function() { (function() {
test('should return `true` as soon as the `callback` result is truthy', function() { test('should return `true` as soon as the `callback` result is truthy', function() {
equal(_.some([null, true, null], _.identity), true); ok(_.some([null, true, null], _.identity));
}); });
}()); }());
@@ -1667,7 +1668,8 @@
'<%= new Boolean %>': 'false', '<%= new Boolean %>': 'false',
'<%= typeof a %>': 'number', '<%= typeof a %>': 'number',
'<%= void a %>': '' '<%= void a %>': ''
}, function(value, key) { },
function(value, key) {
var compiled = _.template(key), var compiled = _.template(key),
data = { 'a': 1, 'b': 2 }; data = { 'a': 1, 'b': 2 };
@@ -1816,12 +1818,12 @@
actual = counter + 2; actual = counter + 2;
throttled(); throttled();
throttled(); throttled();
}, 64); }, 128);
setTimeout(function() { setTimeout(function() {
equal(counter, actual); equal(counter, actual);
QUnit.start(); QUnit.start();
}, 128); }, 256);
ok(counter > 1); ok(counter > 1);
}); });
@@ -1938,7 +1940,7 @@
test('should coerce the prefix argument to a string', function() { test('should coerce the prefix argument to a string', function() {
var actual = [_.uniqueId(3), _.uniqueId(2), _.uniqueId(1)]; var actual = [_.uniqueId(3), _.uniqueId(2), _.uniqueId(1)];
equal(/3\d+,2\d+,1\d+/.test(actual), true); ok(/3\d+,2\d+,1\d+/.test(actual));
}); });
}()); }());
@@ -2045,6 +2047,78 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
QUnit.module('lodash(...) methods that return wrapped values');
(function() {
var array = [1, 2, 3],
wrapped = _(array);
var funcs = [
'concat',
'splice'
];
_.each(funcs, function(methodName) {
test('_.' + methodName + ' should return a wrapped value', function() {
ok(wrapped[methodName]() instanceof _);
});
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash(...) methods that return unwrapped values');
(function() {
var array = [1, 2, 3],
wrapped = _(array);
var funcs = [
'clone',
'contains',
'every',
'find',
'first',
'has',
'isArguments',
'isArray',
'isBoolean',
'isDate',
'isElement',
'isEmpty',
'isEqual',
'isFinite',
'isFunction',
'isNaN',
'isNull',
'isNumber',
'isObject',
'isPlainObject',
'isRegExp',
'isString',
'isUndefined',
'join',
'last',
'pop',
'shift',
'reduce',
'reduceRight',
'some'
];
_.each(funcs, function(methodName) {
test('_.' + methodName + ' should return an unwrapped value', function() {
var result = methodName == 'reduceRight'
? wrapped[methodName](_.identity)
: wrapped[methodName]();
equal(result instanceof _, false);
});
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash(...) methods capable of returning wrapped and unwrapped values'); QUnit.module('lodash(...) methods capable of returning wrapped and unwrapped values');
(function() { (function() {
@@ -2069,72 +2143,25 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
QUnit.module('lodash(...) methods that return unwrapped values');
(function() {
var array = [1, 2, 3],
wrapped = _(array);
var funcs = [
'contains',
'every',
'find',
'first',
'has',
'isArguments',
'isArray',
'isBoolean',
'isDate',
'isElement',
'isEmpty',
'isEqual',
'isFinite',
'isFunction',
'isNaN',
'isNull',
'isNumber',
'isObject',
'isPlainObject',
'isRegExp',
'isString',
'isUndefined',
'last',
'reduce',
'reduceRight',
'some'
];
_.each(funcs, function(methodName) {
test('_.' + methodName + ' should return unwrapped values', function() {
var result = methodName == 'reduceRight'
? wrapped[methodName](_.identity)
: wrapped[methodName];
notEqual(typeof result, 'object', '_.' + methodName + ' returns unwrapped values');
});
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash methods'); QUnit.module('lodash methods');
(function() { (function() {
test('should allow falsey arguments', function() { test('should allow falsey arguments', function() {
var returnArrays = [ var returnArrays = [
'filter', 'filter',
'invoke', 'invoke',
'map', 'map',
'pluck', 'pluck',
'reject', 'reject',
'shuffle', 'shuffle',
'sortBy', 'sortBy',
'toArray', 'toArray',
'where' 'where'
]; ];
var funcs = _.without.apply(_, [_.functions(_)].concat([ var funcs = _.without.apply(_, [_.functions(_)].concat([
'_', '_',
'_each',
'_iteratorTemplate', '_iteratorTemplate',
'after', 'after',
'bind', 'bind',
@@ -2220,7 +2247,7 @@
} }
if (expected === null) { if (expected === null) {
deepEqual(thisArg, null, message); strictEqual(thisArg, null, message);
} else { } else {
equal(thisArg, expected, message); equal(thisArg, expected, message);
} }

View File

@@ -5,7 +5,7 @@
<title>Underscore Test Suite</title> <title>Underscore Test Suite</title>
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css"> <link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css">
<style> <style>
iframe, img { iframe {
display: none; display: none;
} }
</style> </style>
@@ -32,6 +32,62 @@
<script> <script>
document.write('<script src="../' + ui.buildPath + '"><\/script>'); document.write('<script src="../' + ui.buildPath + '"><\/script>');
</script> </script>
<script>
(function() {
var arrayProto = Array.prototype,
concat = arrayProto.concat,
pop = arrayProto.pop,
push = arrayProto.push,
slice = arrayProto.slice;
if (_.chain) {
return;
}
_.mixin = function(object) {
_.forEach(_.functions(object), function(methodName) {
var func = _[methodName] = object[methodName];
_.prototype[methodName] = function() {
var args = [this.__wrapped__];
push.apply(args, arguments);
var result = func.apply(_, args);
if (this.__chain__) {
result = new _(result);
result.__chain__ = true;
}
return result;
};
});
};
_.mixin(_);
_.chain = function(value) {
value = new _(value);
value.__chain__ = true;
return value;
};
_.prototype.chain = function() {
this.__chain__ = true;
return this;
};
_.prototype.concat = function() {
var result = concat.apply(this.__wrapped__, arguments);
if (this.__chain__) {
result = new _(result);
result.__chain__ = true;
}
return result;
};
_.prototype.pop = function() {
pop.apply(this.__wrapped__, arguments);
return this;
};
}());
</script>
<script src="../vendor/underscore/test/collections.js"></script> <script src="../vendor/underscore/test/collections.js"></script>
<script src="../vendor/underscore/test/arrays.js"></script> <script src="../vendor/underscore/test/arrays.js"></script>
<script src="../vendor/underscore/test/functions.js"></script> <script src="../vendor/underscore/test/functions.js"></script>

View File

@@ -1,4 +1,4 @@
// Backbone.js 0.9.2 // Backbone.js 0.9.9
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. // (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Backbone may be freely distributed under the MIT license. // Backbone may be freely distributed under the MIT license.
@@ -19,10 +19,10 @@
var previousBackbone = root.Backbone; var previousBackbone = root.Backbone;
// Create a local reference to array methods. // Create a local reference to array methods.
var ArrayProto = Array.prototype; var array = [];
var push = ArrayProto.push; var push = array.push;
var slice = ArrayProto.slice; var slice = array.slice;
var splice = ArrayProto.splice; var splice = array.splice;
// The top-level namespace. All public Backbone classes and modules will // The top-level namespace. All public Backbone classes and modules will
// be attached to this. Exported for both CommonJS and the browser. // be attached to this. Exported for both CommonJS and the browser.
@@ -34,7 +34,7 @@
} }
// Current version of the library. Keep in sync with `package.json`. // Current version of the library. Keep in sync with `package.json`.
Backbone.VERSION = '0.9.2'; Backbone.VERSION = '0.9.9';
// Require Underscore, if we're on the server, and it's not already present. // Require Underscore, if we're on the server, and it's not already present.
var _ = root._; var _ = root._;
@@ -64,12 +64,49 @@
// Backbone.Events // Backbone.Events
// --------------- // ---------------
// Regular expression used to split event strings // Regular expression used to split event strings.
var eventSplitter = /\s+/; var eventSplitter = /\s+/;
// Implement fancy features of the Events API such as multiple event
// names `"change blur"` and jQuery-style event maps `{change: action}`
// in terms of the existing API.
var eventsApi = function(obj, action, name, rest) {
if (!name) return true;
if (typeof name === 'object') {
for (var key in name) {
obj[action].apply(obj, [key, name[key]].concat(rest));
}
} else if (eventSplitter.test(name)) {
var names = name.split(eventSplitter);
for (var i = 0, l = names.length; i < l; i++) {
obj[action].apply(obj, [names[i]].concat(rest));
}
} else {
return true;
}
};
// Optimized internal dispatch function for triggering events. Tries to
// keep the usual cases speedy (most Backbone events have 3 arguments).
var triggerEvents = function(obj, events, args) {
var ev, i = -1, l = events.length;
switch (args.length) {
case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx);
return;
case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0]);
return;
case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1]);
return;
case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1], args[2]);
return;
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
}
};
// A module that can be mixed in to *any object* in order to provide it with // A module that can be mixed in to *any object* in order to provide it with
// custom events. You may bind with `on` or remove with `off` callback functions // custom events. You may bind with `on` or remove with `off` callback
// to an event; `trigger`-ing an event fires all callbacks in succession. // functions to an event; `trigger`-ing an event fires all callbacks in
// succession.
// //
// var object = {}; // var object = {};
// _.extend(object, Backbone.Events); // _.extend(object, Backbone.Events);
@@ -78,49 +115,58 @@
// //
var Events = Backbone.Events = { var Events = Backbone.Events = {
// Bind one or more space separated events, `events`, to a `callback` // Bind one or more space separated events, or an events map,
// function. Passing `"all"` will bind the callback to all events fired. // to a `callback` function. Passing `"all"` will bind the callback to
on: function(events, callback, context) { // all events fired.
var calls, event, list; on: function(name, callback, context) {
if (!callback) return this; if (!(eventsApi(this, 'on', name, [callback, context]) && callback)) return this;
this._events || (this._events = {});
events = events.split(eventSplitter); var list = this._events[name] || (this._events[name] = []);
calls = this._callbacks || (this._callbacks = {}); list.push({callback: callback, context: context, ctx: context || this});
while (event = events.shift()) {
list = calls[event] || (calls[event] = []);
list.push(callback, context);
}
return this; return this;
}, },
// Remove one or many callbacks. If `context` is null, removes all callbacks // Bind events to only be triggered a single time. After the first time
// with that function. If `callback` is null, removes all callbacks for the // the callback is invoked, it will be removed.
// event. If `events` is null, removes all bound callbacks for all events. once: function(name, callback, context) {
off: function(events, callback, context) { if (!(eventsApi(this, 'once', name, [callback, context]) && callback)) return this;
var event, calls, list, i; var self = this;
var once = _.once(function() {
self.off(name, once);
callback.apply(this, arguments);
});
once._callback = callback;
this.on(name, once, context);
return this;
},
// No events, or removing *all* events. // Remove one or many callbacks. If `context` is null, removes all
if (!(calls = this._callbacks)) return this; // callbacks with that function. If `callback` is null, removes all
if (!(events || callback || context)) { // callbacks for the event. If `events` is null, removes all bound
delete this._callbacks; // callbacks for all events.
off: function(name, callback, context) {
var list, ev, events, names, i, l, j, k;
if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
if (!name && !callback && !context) {
this._events = {};
return this; return this;
} }
events = events ? events.split(eventSplitter) : _.keys(calls); names = name ? [name] : _.keys(this._events);
for (i = 0, l = names.length; i < l; i++) {
// Loop through the callback list, splicing where appropriate. name = names[i];
while (event = events.shift()) { if (list = this._events[name]) {
if (!(list = calls[event]) || !(callback || context)) { events = [];
delete calls[event]; if (callback || context) {
continue; for (j = 0, k = list.length; j < k; j++) {
} ev = list[j];
if ((callback && callback !== (ev.callback._callback || ev.callback)) ||
for (i = list.length - 2; i >= 0; i -= 2) { (context && context !== ev.context)) {
if (!(callback && list[i] !== callback || context && list[i + 1] !== context)) { events.push(ev);
list.splice(i, 2); }
}
} }
this._events[name] = events;
} }
} }
@@ -131,51 +177,53 @@
// passed the same arguments as `trigger` is, apart from the event name // passed the same arguments as `trigger` is, apart from the event name
// (unless you're listening on `"all"`, which will cause your callback to // (unless you're listening on `"all"`, which will cause your callback to
// receive the true name of the event as the first argument). // receive the true name of the event as the first argument).
trigger: function(events) { trigger: function(name) {
var event, calls, list, i, length, args, all, rest; if (!this._events) return this;
if (!(calls = this._callbacks)) return this; var args = slice.call(arguments, 1);
if (!eventsApi(this, 'trigger', name, args)) return this;
var events = this._events[name];
var allEvents = this._events.all;
if (events) triggerEvents(this, events, args);
if (allEvents) triggerEvents(this, allEvents, arguments);
return this;
},
rest = []; // An inversion-of-control version of `on`. Tell *this* object to listen to
events = events.split(eventSplitter); // an event in another object ... keeping track of what it's listening to.
listenTo: function(object, events, callback) {
var listeners = this._listeners || (this._listeners = {});
var id = object._listenerId || (object._listenerId = _.uniqueId('l'));
listeners[id] = object;
object.on(events, callback || this, this);
return this;
},
// Fill up `rest` with the callback arguments. Since we're only copying // Tell this object to stop listening to either specific events ... or
// the tail of `arguments`, a loop is much faster than Array#slice. // to every object it's currently listening to.
for (i = 1, length = arguments.length; i < length; i++) { stopListening: function(object, events, callback) {
rest[i - 1] = arguments[i]; var listeners = this._listeners;
} if (!listeners) return;
if (object) {
// For each event, walk through the list of callbacks twice, first to object.off(events, callback, this);
// trigger the event, then to trigger any `"all"` callbacks. if (!events && !callback) delete listeners[object._listenerId];
while (event = events.shift()) { } else {
// Copy callback lists to prevent modification. for (var id in listeners) {
if (all = calls.all) all = all.slice(); listeners[id].off(null, null, this);
if (list = calls[event]) list = list.slice();
// Execute event callbacks.
if (list) {
for (i = 0, length = list.length; i < length; i += 2) {
list[i].apply(list[i + 1] || this, rest);
}
}
// Execute "all" callbacks.
if (all) {
args = [event].concat(rest);
for (i = 0, length = all.length; i < length; i += 2) {
all[i].apply(all[i + 1] || this, args);
}
} }
this._listeners = {};
} }
return this; return this;
} }
}; };
// Aliases for backwards compatibility. // Aliases for backwards compatibility.
Events.bind = Events.on; Events.bind = Events.on;
Events.unbind = Events.off; Events.unbind = Events.off;
// Allow the `Backbone` object to serve as a global event bus, for folks who
// want global "pubsub" in a convenient place.
_.extend(Backbone, Events);
// Backbone.Model // Backbone.Model
// -------------- // --------------
@@ -187,17 +235,12 @@
this.cid = _.uniqueId('c'); this.cid = _.uniqueId('c');
this.changed = {}; this.changed = {};
this.attributes = {}; this.attributes = {};
this._escapedAttributes = {}; this._changes = [];
this._modelState = [];
if (options && options.collection) this.collection = options.collection; if (options && options.collection) this.collection = options.collection;
if (options && options.parse) attrs = this.parse(attrs); if (options && options.parse) attrs = this.parse(attrs);
if (defaults = _.result(this, 'defaults')) { if (defaults = _.result(this, 'defaults')) _.defaults(attrs, defaults);
attrs = _.extend({}, defaults, attrs);
}
this.set(attrs, {silent: true}); this.set(attrs, {silent: true});
this._cleanChange = true; this._currentAttributes = _.clone(this.attributes);
this._modelState = [];
this._currentState = _.clone(this.attributes);
this._previousAttributes = _.clone(this.attributes); this._previousAttributes = _.clone(this.attributes);
this.initialize.apply(this, arguments); this.initialize.apply(this, arguments);
}; };
@@ -208,27 +251,6 @@
// A hash of attributes whose current and previous value differ. // A hash of attributes whose current and previous value differ.
changed: null, changed: null,
// Whether there is a pending request to fire in the final `change` loop.
_pending: false,
// Whether the model is in the midst of a change cycle.
_changing: false,
// Whether there has been a `set` call since the last
// calculation of the changed hash, for efficiency.
_cleanChange: true,
// The model state used for comparison in determining if a
// change should be fired.
_currentState: null,
// An array queue of all changes attributed to a model
// on the next non-silent change event.
_modelState: null,
// A hash of the model's attributes when the last `change` occured.
_previousAttributes: null,
// The default name for the JSON `id` attribute is `"id"`. MongoDB and // The default name for the JSON `id` attribute is `"id"`. MongoDB and
// CouchDB users may want to set this to `"_id"`. // CouchDB users may want to set this to `"_id"`.
idAttribute: 'id', idAttribute: 'id',
@@ -254,10 +276,7 @@
// Get the HTML-escaped value of an attribute. // Get the HTML-escaped value of an attribute.
escape: function(attr) { escape: function(attr) {
var html; return _.escape(this.get(attr));
if (html = this._escapedAttributes[attr]) return html;
var val = this.get(attr);
return this._escapedAttributes[attr] = _.escape(val == null ? '' : '' + val);
}, },
// Returns `true` if the attribute contains a value that is not null // Returns `true` if the attribute contains a value that is not null
@@ -284,9 +303,6 @@
var silent = options && options.silent; var silent = options && options.silent;
var unset = options && options.unset; var unset = options && options.unset;
if (attrs instanceof Model) attrs = attrs.attributes;
if (unset) for (attr in attrs) attrs[attr] = void 0;
// Run validation. // Run validation.
if (!this._validate(attrs, options)) return false; if (!this._validate(attrs, options)) return false;
@@ -294,24 +310,19 @@
if (this.idAttribute in attrs) this.id = attrs[this.idAttribute]; if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
var now = this.attributes; var now = this.attributes;
var esc = this._escapedAttributes;
// For each `set` attribute... // For each `set` attribute...
for (attr in attrs) { for (attr in attrs) {
val = attrs[attr]; val = attrs[attr];
// If an escaped attr exists, and the new and current value differ, remove the escaped attr. // Update or delete the current value, and track the change.
if (esc[attr] && !_.isEqual(now[attr], val) || (unset && _.has(now, attr))) delete esc[attr];
// Update or delete the current value.
unset ? delete now[attr] : now[attr] = val; unset ? delete now[attr] : now[attr] = val;
this._changes.push(attr, val);
// Track any action on the attribute.
this._modelState.push(attr, val, unset);
} }
// Signal that the model's state has potentially changed. // Signal that the model's state has potentially changed, and we need
this._cleanChange = false; // to recompute the actual changes.
this._hasComputed = false;
// Fire the `"change"` events. // Fire the `"change"` events.
if (!silent) this.change(options); if (!silent) this.change(options);
@@ -321,15 +332,15 @@
// Remove an attribute from the model, firing `"change"` unless you choose // Remove an attribute from the model, firing `"change"` unless you choose
// to silence it. `unset` is a noop if the attribute doesn't exist. // to silence it. `unset` is a noop if the attribute doesn't exist.
unset: function(attr, options) { unset: function(attr, options) {
options = _.extend({}, options, {unset: true}); return this.set(attr, void 0, _.extend({}, options, {unset: true}));
return this.set(attr, null, options);
}, },
// Clear all attributes on the model, firing `"change"` unless you choose // Clear all attributes on the model, firing `"change"` unless you choose
// to silence it. // to silence it.
clear: function(options) { clear: function(options) {
options = _.extend({}, options, {unset: true}); var attrs = {};
return this.set(_.clone(this.attributes), options); for (var key in this.attributes) attrs[key] = void 0;
return this.set(attrs, _.extend({}, options, {unset: true}));
}, },
// Fetch the model from the server. If the server's representation of the // Fetch the model from the server. If the server's representation of the
@@ -341,7 +352,7 @@
var model = this; var model = this;
var success = options.success; var success = options.success;
options.success = function(resp, status, xhr) { options.success = function(resp, status, xhr) {
if (!model.set(model.parse(resp, xhr), options)) return false; if (!model.set(model.parse(resp), options)) return false;
if (success) success(model, resp, options); if (success) success(model, resp, options);
}; };
return this.sync('read', this, options); return this.sync('read', this, options);
@@ -383,14 +394,16 @@
var success = options.success; var success = options.success;
options.success = function(resp, status, xhr) { options.success = function(resp, status, xhr) {
done = true; done = true;
var serverAttrs = model.parse(resp, xhr); var serverAttrs = model.parse(resp);
if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs);
if (!model.set(serverAttrs, options)) return false; if (!model.set(serverAttrs, options)) return false;
if (success) success(model, resp, options); if (success) success(model, resp, options);
}; };
// Finish configuring and sending the Ajax request. // Finish configuring and sending the Ajax request.
var xhr = this.sync(this.isNew() ? 'create' : 'update', this, options); var method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update');
if (method == 'patch') options.attrs = attrs;
var xhr = this.sync(method, this, options);
// When using `wait`, reset attributes to original values unless // When using `wait`, reset attributes to original values unless
// `success` has been called already. // `success` has been called already.
@@ -440,7 +453,7 @@
// **parse** converts a response into the hash of attributes to be `set` on // **parse** converts a response into the hash of attributes to be `set` on
// the model. The default implementation is just to pass the response along. // the model. The default implementation is just to pass the response along.
parse: function(resp, xhr) { parse: function(resp) {
return resp; return resp;
}, },
@@ -458,14 +471,15 @@
// a `"change:attribute"` event for each changed attribute. // a `"change:attribute"` event for each changed attribute.
// Calling this will cause all objects observing the model to update. // Calling this will cause all objects observing the model to update.
change: function(options) { change: function(options) {
var i, changing = this._changing; var changing = this._changing;
this._changing = true; this._changing = true;
// Generate the changes to be triggered on the model. // Generate the changes to be triggered on the model.
var triggers = this._changeCenter(true); var triggers = this._computeChanges(true);
this._pending = triggers.length;
for (i = triggers.length - 2; i >= 0; i -= 2) { this._pending = !!triggers.length;
for (var i = triggers.length - 2; i >= 0; i -= 2) {
this.trigger('change:' + triggers[i], this, triggers[i + 1], options); this.trigger('change:' + triggers[i], this, triggers[i + 1], options);
} }
@@ -478,14 +492,14 @@
this._previousAttributes = _.clone(this.attributes); this._previousAttributes = _.clone(this.attributes);
} }
this._changing = null; this._changing = false;
return this; return this;
}, },
// Determine if the model has changed since the last `"change"` event. // Determine if the model has changed since the last `"change"` event.
// If you specify an attribute name, determine if that attribute has changed. // If you specify an attribute name, determine if that attribute has changed.
hasChanged: function(attr) { hasChanged: function(attr) {
if (!this._cleanChange) this._changeCenter(); if (!this._hasComputed) this._computeChanges();
if (attr == null) return !_.isEmpty(this.changed); if (attr == null) return !_.isEmpty(this.changed);
return _.has(this.changed, attr); return _.has(this.changed, attr);
}, },
@@ -506,39 +520,36 @@
return changed; return changed;
}, },
// Calculates and handles any changes in `this._modelState`, // Looking at the built up list of `set` attribute changes, compute how
// checking against `this._currentState` to determine current changes. // many of the attributes have actually changed. If `loud`, return a
_changeCenter: function (change) { // boiled-down list of only the real changes.
_computeChanges: function(loud) {
this.changed = {}; this.changed = {};
var local = {}; var already = {};
var triggers = []; var triggers = [];
var modelState = this._modelState; var current = this._currentAttributes;
var currentState = this._currentState; var changes = this._changes;
// Loop through the current queue of potential model changes. // Loop through the current queue of potential model changes.
for (var i = modelState.length - 3; i >= 0; i -= 3) { for (var i = changes.length - 2; i >= 0; i -= 2) {
var key = modelState[i], val = modelState[i + 1], unset = modelState[i + 2]; var key = changes[i], val = changes[i + 1];
if (already[key]) continue;
already[key] = true;
// If the item hasn't been set locally this round, proceed. // Check if the attribute has been modified since the last change,
if (!local[key]) { // and update `this.changed` accordingly. If we're inside of a `change`
local[key] = val; // call, also add a trigger to the list.
if (!_.isEqual(current[key], val)) {
// Check if the attribute has been modified since the last change, this.changed[key] = val;
// and update `this.changed` accordingly. if (!loud) continue;
if (currentState[key] !== val || (_.has(currentState, key) && unset)) { triggers.push(key, val);
this.changed[key] = val; current[key] = val;
// Triggers & modifications are only created inside a `change` call.
if (!change) continue;
triggers.push(key, val);
(!unset) ? currentState[key] = val : delete currentState[key];
}
} }
modelState.splice(i,3);
} }
if (loud) this._changes = [];
// Signals `this.changed` is current to prevent duplicate calls from `this.hasChanged`. // Signals `this.changed` is current to prevent duplicate calls from `this.hasChanged`.
this._cleanChange = true; this._hasComputed = true;
return triggers; return triggers;
}, },
@@ -555,17 +566,11 @@
return _.clone(this._previousAttributes); return _.clone(this._previousAttributes);
}, },
// Check if the model is currently in a valid state. It's only possible to
// get into an *invalid* state if you're using silent changes.
isValid: function(options) {
return !this.validate || !this.validate(this.attributes, options);
},
// Run validation against the next complete set of model attributes, // Run validation against the next complete set of model attributes,
// returning `true` if all is well. If a specific `error` callback has // returning `true` if all is well. If a specific `error` callback has
// been passed, call that instead of firing the general `"error"` event. // been passed, call that instead of firing the general `"error"` event.
_validate: function(attrs, options) { _validate: function(attrs, options) {
if (options && options.silent || !this.validate) return true; if (!this.validate) return true;
attrs = _.extend({}, this.attributes, attrs); attrs = _.extend({}, this.attributes, attrs);
var error = this.validate(attrs, options); var error = this.validate(attrs, options);
if (!error) return true; if (!error) return true;
@@ -588,10 +593,7 @@
if (options.comparator !== void 0) this.comparator = options.comparator; if (options.comparator !== void 0) this.comparator = options.comparator;
this._reset(); this._reset();
this.initialize.apply(this, arguments); this.initialize.apply(this, arguments);
if (models) { if (models) this.reset(models, _.extend({silent: true}, options));
if (options.parse) models = this.parse(models);
this.reset(models, {silent: true, parse: options.parse});
}
}; };
// Define the Collection's inheritable methods. // Define the Collection's inheritable methods.
@@ -619,8 +621,9 @@
// Add a model, or list of models to the set. Pass **silent** to avoid // Add a model, or list of models to the set. Pass **silent** to avoid
// firing the `add` event for every new model. // firing the `add` event for every new model.
add: function(models, options) { add: function(models, options) {
var i, args, length, model, existing, sort; var i, args, length, model, existing, needsSort;
var at = options && options.at; var at = options && options.at;
var sort = ((options && options.sort) == null ? true : options.sort);
models = _.isArray(models) ? models.slice() : [models]; models = _.isArray(models) ? models.slice() : [models];
// Turn bare objects into model references, and prevent invalid models // Turn bare objects into model references, and prevent invalid models
@@ -638,8 +641,8 @@
// optionally merge it into the existing model. // optionally merge it into the existing model.
if (existing || this._byCid[model.cid]) { if (existing || this._byCid[model.cid]) {
if (options && options.merge && existing) { if (options && options.merge && existing) {
existing.set(model, options); existing.set(model.attributes, options);
sort = true; needsSort = sort;
} }
models.splice(i, 1); models.splice(i, 1);
continue; continue;
@@ -653,14 +656,14 @@
} }
// See if sorting is needed, update `length` and splice in new models. // See if sorting is needed, update `length` and splice in new models.
if (models.length) sort = true; if (models.length) needsSort = sort;
this.length += models.length; this.length += models.length;
args = [at != null ? at : this.models.length, 0]; args = [at != null ? at : this.models.length, 0];
push.apply(args, models); push.apply(args, models);
splice.apply(this.models, args); splice.apply(this.models, args);
// Sort the collection if appropriate. // Sort the collection if appropriate.
if (sort && this.comparator && at == null) this.sort({silent: true}); if (needsSort && this.comparator && at == null) this.sort({silent: true});
if (options && options.silent) return this; if (options && options.silent) return this;
@@ -679,7 +682,7 @@
options || (options = {}); options || (options = {});
models = _.isArray(models) ? models.slice() : [models]; models = _.isArray(models) ? models.slice() : [models];
for (i = 0, l = models.length; i < l; i++) { for (i = 0, l = models.length; i < l; i++) {
model = this.getByCid(models[i]) || this.get(models[i]); model = this.get(models[i]);
if (!model) continue; if (!model) continue;
delete this._byId[model.id]; delete this._byId[model.id];
delete this._byCid[model.cid]; delete this._byCid[model.cid];
@@ -698,7 +701,7 @@
// Add a model to the end of the collection. // Add a model to the end of the collection.
push: function(model, options) { push: function(model, options) {
model = this._prepareModel(model, options); model = this._prepareModel(model, options);
this.add(model, options); this.add(model, _.extend({at: this.length}, options));
return model; return model;
}, },
@@ -729,14 +732,9 @@
}, },
// Get a model from the set by id. // Get a model from the set by id.
get: function(id) { get: function(obj) {
if (id == null) return void 0; if (obj == null) return void 0;
return this._byId[id.id != null ? id.id : id]; return this._byId[obj.id != null ? obj.id : obj] || this._byCid[obj.cid || obj];
},
// Get a model from the set by client id.
getByCid: function(cid) {
return cid && this._byCid[cid.cid || cid];
}, },
// Get the model at the given index. // Get the model at the given index.
@@ -769,7 +767,7 @@
this.models.sort(_.bind(this.comparator, this)); this.models.sort(_.bind(this.comparator, this));
} }
if (!options || !options.silent) this.trigger('reset', this, options); if (!options || !options.silent) this.trigger('sort', this, options);
return this; return this;
}, },
@@ -778,16 +776,56 @@
return _.invoke(this.models, 'get', attr); return _.invoke(this.models, 'get', attr);
}, },
// Smartly update a collection with a change set of models, adding,
// removing, and merging as necessary.
update: function(models, options) {
var model, i, l, existing;
var add = [], remove = [], modelMap = {};
var idAttr = this.model.prototype.idAttribute;
options = _.extend({add: true, merge: true, remove: true}, options);
if (options.parse) models = this.parse(models);
// Allow a single model (or no argument) to be passed.
if (!_.isArray(models)) models = models ? [models] : [];
// Proxy to `add` for this case, no need to iterate...
if (options.add && !options.remove) return this.add(models, options);
// Determine which models to add and merge, and which to remove.
for (i = 0, l = models.length; i < l; i++) {
model = models[i];
existing = this.get(model.id || model.cid || model[idAttr]);
if (options.remove && existing) modelMap[existing.cid] = true;
if ((options.add && !existing) || (options.merge && existing)) {
add.push(model);
}
}
if (options.remove) {
for (i = 0, l = this.models.length; i < l; i++) {
model = this.models[i];
if (!modelMap[model.cid]) remove.push(model);
}
}
// Remove models (if applicable) before we add and merge the rest.
if (remove.length) this.remove(remove, options);
if (add.length) this.add(add, options);
return this;
},
// When you have more items than you want to add or remove individually, // When you have more items than you want to add or remove individually,
// you can reset the entire set with a new list of models, without firing // you can reset the entire set with a new list of models, without firing
// any `add` or `remove` events. Fires `reset` when finished. // any `add` or `remove` events. Fires `reset` when finished.
reset: function(models, options) { reset: function(models, options) {
options || (options = {});
if (options.parse) models = this.parse(models);
for (var i = 0, l = this.models.length; i < l; i++) { for (var i = 0, l = this.models.length; i < l; i++) {
this._removeReference(this.models[i]); this._removeReference(this.models[i]);
} }
options.previousModels = this.models;
this._reset(); this._reset();
if (models) this.add(models, _.extend({silent: true}, options)); if (models) this.add(models, _.extend({silent: true}, options));
if (!options || !options.silent) this.trigger('reset', this, options); if (!options.silent) this.trigger('reset', this, options);
return this; return this;
}, },
@@ -800,7 +838,8 @@
var collection = this; var collection = this;
var success = options.success; var success = options.success;
options.success = function(resp, status, xhr) { options.success = function(resp, status, xhr) {
collection[options.add ? 'add' : 'reset'](collection.parse(resp, xhr), options); var method = options.update ? 'update' : 'reset';
collection[method](resp, options);
if (success) success(collection, resp, options); if (success) success(collection, resp, options);
}; };
return this.sync('read', this, options); return this.sync('read', this, options);
@@ -826,7 +865,7 @@
// **parse** converts a response into a list of models to be added to the // **parse** converts a response into a list of models to be added to the
// collection. The default implementation is just to pass it through. // collection. The default implementation is just to pass it through.
parse: function(resp, xhr) { parse: function(resp) {
return resp; return resp;
}, },
@@ -859,7 +898,7 @@
options || (options = {}); options || (options = {});
options.collection = this; options.collection = this;
var model = new this.model(attrs, options); var model = new this.model(attrs, options);
if (!model._validate(model.attributes, options)) return false; if (!model._validate(attrs, options)) return false;
return model; return model;
}, },
@@ -932,7 +971,7 @@
var optionalParam = /\((.*?)\)/g; var optionalParam = /\((.*?)\)/g;
var namedParam = /:\w+/g; var namedParam = /:\w+/g;
var splatParam = /\*\w+/g; var splatParam = /\*\w+/g;
var escapeRegExp = /[-{}[\]+?.,\\^$|#\s]/g; var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
// Set up all inheritable **Backbone.Router** properties and methods. // Set up all inheritable **Backbone.Router** properties and methods.
_.extend(Router.prototype, Events, { _.extend(Router.prototype, Events, {
@@ -1003,7 +1042,7 @@
this.handlers = []; this.handlers = [];
_.bindAll(this, 'checkUrl'); _.bindAll(this, 'checkUrl');
// #1653 - Ensure that `History` can be used outside of the browser. // Ensure that `History` can be used outside of the browser.
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
this.location = window.location; this.location = window.location;
this.history = window.history; this.history = window.history;
@@ -1051,7 +1090,7 @@
fragment = this.getHash(); fragment = this.getHash();
} }
} }
return decodeURIComponent(fragment.replace(routeStripper, '')); return fragment.replace(routeStripper, '');
}, },
// Start the hash change handling, returning `true` if the current URL matches // Start the hash change handling, returning `true` if the current URL matches
@@ -1199,7 +1238,7 @@
var href = location.href.replace(/(javascript:|#).*$/, ''); var href = location.href.replace(/(javascript:|#).*$/, '');
location.replace(href + '#' + fragment); location.replace(href + '#' + fragment);
} else { } else {
// #1649 - Some browsers require that `hash` contains a leading #. // Some browsers require that `hash` contains a leading #.
location.hash = '#' + fragment; location.hash = '#' + fragment;
} }
} }
@@ -1251,20 +1290,11 @@
return this; return this;
}, },
// Clean up references to this view in order to prevent latent effects and // Remove this view by taking the element out of the DOM, and removing any
// memory leaks. // applicable Backbone.Events listeners.
dispose: function() {
this.undelegateEvents();
if (this.model && this.model.off) this.model.off(null, null, this);
if (this.collection && this.collection.off) this.collection.off(null, null, this);
return this;
},
// Remove this view from the DOM. Note that the view isn't present in the
// DOM by default, so calling this method may be a no-op.
remove: function() { remove: function() {
this.dispose();
this.$el.remove(); this.$el.remove();
this.stopListening();
return this; return this;
}, },
@@ -1364,6 +1394,7 @@
var methodMap = { var methodMap = {
'create': 'POST', 'create': 'POST',
'update': 'PUT', 'update': 'PUT',
'patch': 'PATCH',
'delete': 'DELETE', 'delete': 'DELETE',
'read': 'GET' 'read': 'GET'
}; };
@@ -1401,9 +1432,9 @@
} }
// Ensure that we have the appropriate request data. // Ensure that we have the appropriate request data.
if (!options.data && model && (method === 'create' || method === 'update')) { if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
params.contentType = 'application/json'; params.contentType = 'application/json';
params.data = JSON.stringify(model.toJSON(options)); params.data = JSON.stringify(options.attrs || model.toJSON(options));
} }
// For older servers, emulate JSON by encoding the request into an HTML-form. // For older servers, emulate JSON by encoding the request into an HTML-form.
@@ -1414,7 +1445,7 @@
// For older servers, emulate HTTP by mimicking the HTTP method with `_method` // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
// And an `X-HTTP-Method-Override` header. // And an `X-HTTP-Method-Override` header.
if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE')) { if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) {
params.type = 'POST'; params.type = 'POST';
if (options.emulateJSON) params.data._method = type; if (options.emulateJSON) params.data._method = type;
var beforeSend = options.beforeSend; var beforeSend = options.beforeSend;
@@ -1442,7 +1473,9 @@
}; };
// Make the request, allowing the user to override any Ajax options. // Make the request, allowing the user to override any Ajax options.
return Backbone.ajax(_.extend(params, options)); var xhr = Backbone.ajax(_.extend(params, options));
model.trigger('request', model, xhr, options);
return xhr;
}; };
// Set the default implementation of `Backbone.ajax` to proxy through to `$`. // Set the default implementation of `Backbone.ajax` to proxy through to `$`.

View File

@@ -18,17 +18,21 @@ $(document).ready(function() {
})); }));
test("new and sort", 7, function() { test("new and sort", 9, function() {
var counter = 0;
col.on('sort', function(){ counter++; });
equal(col.first(), a, "a should be first"); equal(col.first(), a, "a should be first");
equal(col.last(), d, "d should be last"); equal(col.last(), d, "d should be last");
col.comparator = function(a, b) { col.comparator = function(a, b) {
return a.id > b.id ? -1 : 1; return a.id > b.id ? -1 : 1;
}; };
col.sort(); col.sort();
equal(counter, 1);
equal(col.first(), a, "a should be first"); equal(col.first(), a, "a should be first");
equal(col.last(), d, "d should be last"); equal(col.last(), d, "d should be last");
col.comparator = function(model) { return model.id; }; col.comparator = function(model) { return model.id; };
col.sort(); col.sort();
equal(counter, 2);
equal(col.first(), d, "d should be first"); equal(col.first(), d, "d should be first");
equal(col.last(), a, "a should be last"); equal(col.last(), a, "a should be last");
equal(col.length, 4); equal(col.length, 4);
@@ -58,10 +62,10 @@ $(document).ready(function() {
strictEqual(collection.last().get('a'), 4); strictEqual(collection.last().get('a'), 4);
}); });
test("get, getByCid", 3, function() { test("get", 3, function() {
equal(col.get(0), d); equal(col.get(0), d);
equal(col.get(2), b); equal(col.get(2), b);
equal(col.getByCid(col.first().cid), col.first()); equal(col.get(col.first().cid), col.first());
}); });
test("get with non-default ids", 2, function() { test("get with non-default ids", 2, function() {
@@ -304,13 +308,13 @@ $(document).ready(function() {
var colE = new Backbone.Collection([e]); var colE = new Backbone.Collection([e]);
var colF = new Backbone.Collection([f]); var colF = new Backbone.Collection([f]);
ok(e != f); ok(e != f);
ok(colE.length == 1); ok(colE.length === 1);
ok(colF.length == 1); ok(colF.length === 1);
colE.remove(e); colE.remove(e);
equal(passed, false); equal(passed, false);
ok(colE.length == 0); ok(colE.length === 0);
colF.remove(e); colF.remove(e);
ok(colF.length == 0); ok(colF.length === 0);
equal(passed, true); equal(passed, true);
}); });
@@ -338,13 +342,13 @@ $(document).ready(function() {
}); });
equal(colE, e.collection); equal(colE, e.collection);
colF.remove(e); colF.remove(e);
ok(colF.length == 0); ok(colF.length === 0);
ok(colE.length == 1); ok(colE.length === 1);
equal(counter, 1); equal(counter, 1);
equal(colE, e.collection); equal(colE, e.collection);
colE.remove(e); colE.remove(e);
equal(null, e.collection); equal(null, e.collection);
ok(colE.length == 0); ok(colE.length === 0);
equal(counter, 2); equal(counter, 2);
}); });
@@ -354,8 +358,8 @@ $(document).ready(function() {
var colE = new Backbone.Collection([e]); var colE = new Backbone.Collection([e]);
var colF = new Backbone.Collection([e]); var colF = new Backbone.Collection([e]);
e.destroy(); e.destroy();
ok(colE.length == 0); ok(colE.length === 0);
ok(colF.length == 0); ok(colF.length === 0);
equal(undefined, e.collection); equal(undefined, e.collection);
}); });
@@ -365,8 +369,8 @@ $(document).ready(function() {
var colE = new Backbone.Collection([e]); var colE = new Backbone.Collection([e]);
var colF = new Backbone.Collection([e]); var colF = new Backbone.Collection([e]);
e.destroy(); e.destroy();
ok(colE.length == 0); ok(colE.length === 0);
ok(colF.length == 0); ok(colF.length === 0);
equal(undefined, e.collection); equal(undefined, e.collection);
}); });
@@ -382,6 +386,19 @@ $(document).ready(function() {
equal(this.syncArgs.options.parse, false); equal(this.syncArgs.options.parse, false);
}); });
test("ensure fetch only parses once", 1, function() {
var collection = new Backbone.Collection;
var counter = 0;
collection.parse = function(models) {
counter++;
return models;
};
collection.url = '/test';
collection.fetch();
this.syncArgs.options.success([]);
equal(counter, 1);
});
test("create", 4, function() { test("create", 4, function() {
var collection = new Backbone.Collection; var collection = new Backbone.Collection;
collection.url = '/test'; collection.url = '/test';
@@ -542,7 +559,7 @@ $(document).ready(function() {
equal(col.length, 0); equal(col.length, 0);
}); });
test("#861, adding models to a collection which do not pass validation", 2, function() { test("#861, adding models to a collection which do not pass validation", function() {
var Model = Backbone.Model.extend({ var Model = Backbone.Model.extend({
validate: function(attrs) { validate: function(attrs) {
if (attrs.id == 3) return "id can't be 3"; if (attrs.id == 3) return "id can't be 3";
@@ -567,9 +584,9 @@ $(document).ready(function() {
validate: function(attrs){ if (!attrs.valid) return 'invalid'; } validate: function(attrs){ if (!attrs.valid) return 'invalid'; }
}); });
var model = new collection.model({id: 1, valid: true}); var model = new collection.model({id: 1, valid: true});
collection.add([model, {id: 2}]);; collection.add([model, {id: 2}]);
model.trigger('test'); model.trigger('test');
ok(collection.getByCid(model.cid)); ok(collection.get(model.cid));
ok(collection.get(1)); ok(collection.get(1));
ok(!collection.get(2)); ok(!collection.get(2));
equal(collection.length, 1); equal(collection.length, 1);
@@ -726,4 +743,171 @@ $(document).ready(function() {
c.add({id: 4}); c.add({id: 4});
}); });
test("#1407 parse option on constructor parses collection and models", 2, function() {
var model = {
namespace : [{id: 1}, {id:2}]
};
var Collection = Backbone.Collection.extend({
model: Backbone.Model.extend({
parse: function(model) {
model.name = 'test';
return model;
}
}),
parse: function(model) {
return model.namespace;
}
});
var c = new Collection(model, {parse:true});
equal(c.length, 2);
equal(c.at(0).get('name'), 'test');
});
test("#1407 parse option on reset parses collection and models", 2, function() {
var model = {
namespace : [{id: 1}, {id:2}]
};
var Collection = Backbone.Collection.extend({
model: Backbone.Model.extend({
parse: function(model) {
model.name = 'test';
return model;
}
}),
parse: function(model) {
return model.namespace;
}
});
var c = new Collection();
c.reset(model, {parse:true});
equal(c.length, 2);
equal(c.at(0).get('name'), 'test');
});
test("Reset includes previous models in triggered event.", 1, function() {
var model = new Backbone.Model();
var collection = new Backbone.Collection([model])
.on('reset', function(collection, options) {
deepEqual(options.previousModels, [model]);
});
collection.reset([]);
});
test("update", function() {
var m1 = new Backbone.Model();
var m2 = new Backbone.Model({id: 2});
var m3 = new Backbone.Model();
var c = new Backbone.Collection([m1, m2]);
// Test add/change/remove events
c.on('add', function(model) {
strictEqual(model, m3);
});
c.on('change', function(model) {
strictEqual(model, m2);
});
c.on('remove', function(model) {
strictEqual(model, m1);
});
// remove: false doesn't remove any models
c.update([], {remove: false});
strictEqual(c.length, 2);
// add: false doesn't add any models
c.update([m1, m2, m3], {add: false});
strictEqual(c.length, 2);
// merge: false doesn't change any models
c.update([m1, {id: 2, a: 1}], {merge: false});
strictEqual(m2.get('a'), void 0);
// add: false, remove: false only merges existing models
c.update([m1, {id: 2, a: 0}, m3, {id: 4}], {add: false, remove: false});
strictEqual(c.length, 2);
strictEqual(m2.get('a'), 0);
// default options add/remove/merge as appropriate
c.update([{id: 2, a: 1}, m3]);
strictEqual(c.length, 2);
strictEqual(m2.get('a'), 1);
// Test removing models not passing an argument
c.off('remove').on('remove', function(model) {
ok(model === m2 || model === m3);
});
c.update([]);
strictEqual(c.length, 0);
});
test("update with only cids", 3, function() {
var m1 = new Backbone.Model;
var m2 = new Backbone.Model;
var c = new Backbone.Collection;
c.update([m1, m2]);
equal(c.length, 2);
c.update([m1]);
equal(c.length, 1);
c.update([m1, m1, m1, m2, m2], {remove: false});
equal(c.length, 2);
});
test("update with only idAttribute", 3, function() {
var m1 = { _id: 1 };
var m2 = { _id: 2 };
var col = Backbone.Collection.extend({
model: Backbone.Model.extend({
idAttribute: '_id'
})
});
var c = new col;
c.update([m1, m2]);
equal(c.length, 2);
c.update([m1]);
equal(c.length, 1);
c.update([m1, m1, m1, m2, m2], {remove: false});
equal(c.length, 2);
});
test("#1894 - Push should not trigger a sort", 0, function() {
var Collection = Backbone.Collection.extend({
comparator: 'id',
sort: function() {
ok(false);
}
});
new Collection().push({id: 1});
});
// test("`update` with non-normal id", function() {
// var Collection = Backbone.Collection.extend({
// model: Backbone.Model.extend({idAttribute: '_id'})
// });
// var collection = new Collection({_id: 1});
// collection.update([{_id: 1, a: 1}], {add: false});
// equal(collection.first().get('a'), 1);
// });
test("#1894 - `sort` can optionally be turned off", 0, function() {
var Collection = Backbone.Collection.extend({
comparator: 'id',
sort: function() { ok(true); }
});
new Collection().add({id: 1}, {sort: false});
});
test("#1915 - `parse` data in the right order in `update`", function() {
var collection = new (Backbone.Collection.extend({
parse: function (data) {
strictEqual(data.status, 'ok');
return data.data;
}
}));
var res = {status: 'ok', data:[{id: 1}]}
collection.update(res, {parse: true});
});
}); });

View File

@@ -17,7 +17,7 @@ $(document).ready(function() {
test("binding and triggering multiple events", 4, function() { test("binding and triggering multiple events", 4, function() {
var obj = { counter: 0 }; var obj = { counter: 0 };
_.extend(obj,Backbone.Events); _.extend(obj, Backbone.Events);
obj.on('a b c', function() { obj.counter += 1; }); obj.on('a b c', function() { obj.counter += 1; });
@@ -35,6 +35,57 @@ $(document).ready(function() {
equal(obj.counter, 5); equal(obj.counter, 5);
}); });
test("binding and triggering with event maps", function() {
var obj = { counter: 0 };
_.extend(obj, Backbone.Events);
var increment = function() {
this.counter += 1;
};
obj.on({
a: increment,
b: increment,
c: increment
}, obj);
obj.trigger('a');
equal(obj.counter, 1);
obj.trigger('a b');
equal(obj.counter, 3);
obj.trigger('c');
equal(obj.counter, 4);
obj.off({
a: increment,
c: increment
}, obj);
obj.trigger('a b c');
equal(obj.counter, 5);
});
test("listenTo and stopListening", 1, function() {
var a = _.extend({}, Backbone.Events);
var b = _.extend({}, Backbone.Events);
a.listenTo(b, 'all', function(){ ok(true); });
b.trigger('anything');
a.listenTo(b, 'all', function(){ ok(false); });
a.stopListening();
b.trigger('anything');
});
test("listenTo and stopListening with event maps", 1, function() {
var a = _.extend({}, Backbone.Events);
var b = _.extend({}, Backbone.Events);
a.listenTo(b, {change: function(){ ok(true); }});
b.trigger('change');
a.listenTo(b, {change: function(){ ok(false); }});
a.stopListening();
b.trigger('change');
});
test("trigger all for each event", 3, function() { test("trigger all for each event", 3, function() {
var a, b, obj = { counter: 0 }; var a, b, obj = { counter: 0 };
_.extend(obj, Backbone.Events); _.extend(obj, Backbone.Events);
@@ -192,4 +243,121 @@ $(document).ready(function() {
obj.trigger('event'); obj.trigger('event');
}); });
test("once", 2, function() {
// Same as the previous test, but we use once rather than having to explicitly unbind
var obj = { counterA: 0, counterB: 0 };
_.extend(obj, Backbone.Events);
var incrA = function(){ obj.counterA += 1; obj.trigger('event'); };
var incrB = function(){ obj.counterB += 1; };
obj.once('event', incrA);
obj.once('event', incrB);
obj.trigger('event');
equal(obj.counterA, 1, 'counterA should have only been incremented once.');
equal(obj.counterB, 1, 'counterB should have only been incremented once.');
});
test("once variant one", 3, function() {
var f = function(){ ok(true); };
var a = _.extend({}, Backbone.Events).once('event', f);
var b = _.extend({}, Backbone.Events).on('event', f);
a.trigger('event');
b.trigger('event');
b.trigger('event');
});
test("once variant two", 3, function() {
var f = function(){ ok(true); };
var obj = _.extend({}, Backbone.Events);
obj
.once('event', f)
.on('event', f)
.trigger('event')
.trigger('event');
});
test("once with off", 0, function() {
var f = function(){ ok(true); };
var obj = _.extend({}, Backbone.Events);
obj.once('event', f);
obj.off('event', f);
obj.trigger('event');
});
test("once with event maps", function() {
var obj = { counter: 0 };
_.extend(obj, Backbone.Events);
var increment = function() {
this.counter += 1;
};
obj.once({
a: increment,
b: increment,
c: increment
}, obj);
obj.trigger('a');
equal(obj.counter, 1);
obj.trigger('a b');
equal(obj.counter, 2);
obj.trigger('c');
equal(obj.counter, 3);
obj.trigger('a b c');
equal(obj.counter, 3);
});
test("once with off only by context", 0, function() {
var context = {};
var obj = _.extend({}, Backbone.Events);
obj.once('event', function(){ ok(false); }, context);
obj.off(null, null, context);
obj.trigger('event');
});
test("Backbone object inherits Events", function() {
ok(Backbone.on === Backbone.Events.on);
});
asyncTest("once with asynchronous events", 1, function() {
var func = _.debounce(function() { ok(true); start(); }, 50);
var obj = _.extend({}, Backbone.Events).once('async', func);
obj.trigger('async');
obj.trigger('async');
});
test("once with multiple events.", 2, function() {
var obj = _.extend({}, Backbone.Events);
obj.once('x y', function() { ok(true); });
obj.trigger('x y');
});
test("Off during iteration with once.", 2, function() {
var obj = _.extend({}, Backbone.Events);
var f = function(){ this.off('event', f); };
obj.on('event', f);
obj.once('event', function(){});
obj.on('event', function(){ ok(true); });
obj.trigger('event');
obj.trigger('event');
});
test("`once` on `all` should work as expected", 1, function() {
Backbone.once('all', function() {
ok(true);
Backbone.trigger('all');
});
Backbone.trigger('all');
});
}); });

View File

@@ -55,6 +55,18 @@ $(document).ready(function() {
equal(model.get('value'), 2); equal(model.get('value'), 2);
}); });
test("initialize with defaults", 2, function() {
var Model = Backbone.Model.extend({
defaults: {
first_name: 'Unknown',
last_name: 'Unknown'
}
});
var model = new Model({'first_name': 'John'});
equal(model.get('first_name'), 'John');
equal(model.get('last_name'), 'Unknown');
});
test("parse can return null", 1, function() { test("parse can return null", 1, function() {
var Model = Backbone.Model.extend({ var Model = Backbone.Model.extend({
parse: function(obj) { parse: function(obj) {
@@ -114,7 +126,7 @@ $(document).ready(function() {
var foo = new Backbone.Model({p: 1}); var foo = new Backbone.Model({p: 1});
var bar = new Backbone.Model({p: 2}); var bar = new Backbone.Model({p: 2});
bar.set(foo.clone(), {unset: true}); bar.set(foo.clone().attributes, {unset: true});
equal(foo.get('p'), 1); equal(foo.get('p'), 1);
equal(bar.get('p'), undefined); equal(bar.get('p'), undefined);
}); });
@@ -201,6 +213,27 @@ $(document).ready(function() {
equal(a.id, undefined, "Unsetting the id should remove the id property."); equal(a.id, undefined, "Unsetting the id should remove the id property.");
}); });
test("set triggers changes in the correct order", function() {
var value = null;
var model = new Backbone.Model;
model.on('last', function(){ value = 'last'; });
model.on('first', function(){ value = 'first'; });
model.trigger('first');
model.trigger('last');
equal(value, 'last');
});
test("set falsy values in the correct order", 1, function() {
var model = new Backbone.Model({result: 'result'});
model.on('change', function() {
equal(model.changed.result, false);
});
model.set({result: void 0}, {silent: true});
model.set({result: null}, {silent: true});
model.set({result: false}, {silent: true});
model.change();
});
test("multiple unsets", 1, function() { test("multiple unsets", 1, function() {
var i = 0; var i = 0;
var counter = function(){ i++; }; var counter = function(){ i++; };
@@ -261,7 +294,7 @@ $(document).ready(function() {
}); });
var model = new Defaulted({two: null}); var model = new Defaulted({two: null});
equal(model.get('one'), 1); equal(model.get('one'), 1);
equal(model.get('two'), null); equal(model.get('two'), 2);
Defaulted = Backbone.Model.extend({ Defaulted = Backbone.Model.extend({
defaults: function() { defaults: function() {
return { return {
@@ -270,9 +303,9 @@ $(document).ready(function() {
}; };
} }
}); });
var model = new Defaulted({two: null}); model = new Defaulted({two: null});
equal(model.get('one'), 3); equal(model.get('one'), 3);
equal(model.get('two'), null); equal(model.get('two'), 4);
}); });
test("change, hasChanged, changedAttributes, previous, previousAttributes", 12, function() { test("change, hasChanged, changedAttributes, previous, previousAttributes", 12, function() {
@@ -293,7 +326,6 @@ $(document).ready(function() {
equal(model.hasChanged('name'), true); equal(model.hasChanged('name'), true);
model.change(); model.change();
equal(model.get('name'), 'Rob'); equal(model.get('name'), 'Rob');
}); });
test("changedAttributes", 3, function() { test("changedAttributes", 3, function() {
@@ -351,24 +383,26 @@ $(document).ready(function() {
equal(lastError, "Can't change admin status."); equal(lastError, "Can't change admin status.");
}); });
test("isValid", 5, function() {
var model = new Backbone.Model({valid: true});
model.validate = function(attrs) {
if (!attrs.valid) return "invalid";
};
equal(model.isValid(), true);
equal(model.set({valid: false}), false);
equal(model.isValid(), true);
ok(model.set('valid', false, {silent: true}));
equal(model.isValid(), false);
});
test("save", 2, function() { test("save", 2, function() {
doc.save({title : "Henry V"}); doc.save({title : "Henry V"});
equal(this.syncArgs.method, 'update'); equal(this.syncArgs.method, 'update');
ok(_.isEqual(this.syncArgs.model, doc)); ok(_.isEqual(this.syncArgs.model, doc));
}); });
test("save with PATCH", function() {
doc.clear().set({id: 1, a: 1, b: 2, c: 3, d: 4});
doc.save();
equal(this.syncArgs.method, 'update');
equal(this.syncArgs.options.attrs, undefined);
doc.save({b: 2, d: 4}, {patch: true});
equal(this.syncArgs.method, 'patch');
equal(_.size(this.syncArgs.options.attrs), 2);
equal(this.syncArgs.options.attrs.d, 4);
equal(this.syncArgs.options.attrs.a, undefined);
equal(this.ajaxSettings.data, "{\"b\":2,\"d\":4}");
});
test("save in positional style", 1, function() { test("save in positional style", 1, function() {
var model = new Backbone.Model(); var model = new Backbone.Model();
model.sync = function(method, model, options) { model.sync = function(method, model, options) {
@@ -402,7 +436,7 @@ $(document).ready(function() {
ok(true, "non-persisted model should not call sync"); ok(true, "non-persisted model should not call sync");
}); });
test("validate", 7, function() { test("validate", function() {
var lastError; var lastError;
var model = new Backbone.Model(); var model = new Backbone.Model();
model.validate = function(attrs) { model.validate = function(attrs) {
@@ -415,8 +449,6 @@ $(document).ready(function() {
equal(result, model); equal(result, model);
equal(model.get('a'), 100); equal(model.get('a'), 100);
equal(lastError, undefined); equal(lastError, undefined);
result = model.set({admin: true}, {silent: true});
equal(model.get('admin'), true);
result = model.set({a: 200, admin: false}); result = model.set({a: 200, admin: false});
equal(lastError, "Can't change admin status."); equal(lastError, "Can't change admin status.");
equal(result, false); equal(result, false);
@@ -560,9 +592,9 @@ $(document).ready(function() {
ok(model.get('x') === a); ok(model.get('x') === a);
}); });
test("unset fires change for undefined attributes", 1, function() { test("unset does not fire a change for undefined attributes", 0, function() {
var model = new Backbone.Model({x: undefined}); var model = new Backbone.Model({x: undefined});
model.on('change:x', function(){ ok(true); }); model.on('change:x', function(){ ok(false); });
model.unset('x'); model.unset('x');
}); });
@@ -639,7 +671,7 @@ $(document).ready(function() {
equal(model.get('x'), 3); equal(model.get('x'), 3);
}); });
test("save with wait validates attributes", 1, function() { test("save with wait validates attributes", function() {
var model = new Backbone.Model(); var model = new Backbone.Model();
model.url = '/test'; model.url = '/test';
model.validate = function() { ok(true); }; model.validate = function() { ok(true); };
@@ -774,12 +806,6 @@ $(document).ready(function() {
model.set({a: true}); model.set({a: true});
}); });
test("#1179 - isValid returns true in the absence of validate.", 1, function() {
var model = new Backbone.Model();
model.validate = null;
ok(model.isValid());
});
test("#1122 - clear does not alter options.", 1, function() { test("#1122 - clear does not alter options.", 1, function() {
var model = new Backbone.Model(); var model = new Backbone.Model();
var options = {}; var options = {};
@@ -917,4 +943,10 @@ $(document).ready(function() {
deepEqual(changes, ['a']); deepEqual(changes, ['a']);
}); });
test("#1943 change calculations should use _.isEqual", function() {
var model = new Backbone.Model({a: {key: 'value'}});
model.set('a', {key:'value'}, {silent:true});
equal(model.changedAttributes(), false);
});
}); });

View File

@@ -107,7 +107,7 @@ $(document).ready(function() {
}, },
optionalItem: function(arg){ optionalItem: function(arg){
this.arg = arg !== undefined ? arg : null; this.arg = arg != void 0 ? arg : null;
}, },
splat : function(args) { splat : function(args) {
@@ -139,7 +139,7 @@ $(document).ready(function() {
location.replace('http://example.com#search/news'); location.replace('http://example.com#search/news');
Backbone.history.checkUrl(); Backbone.history.checkUrl();
equal(router.query, 'news'); equal(router.query, 'news');
equal(router.page, undefined); equal(router.page, void 0);
equal(lastRoute, 'search'); equal(lastRoute, 'search');
equal(lastArgs[0], 'news'); equal(lastArgs[0], 'news');
}); });
@@ -207,7 +207,7 @@ $(document).ready(function() {
test("routes (optional)", 2, function() { test("routes (optional)", 2, function() {
location.replace('http://example.com#optional'); location.replace('http://example.com#optional');
Backbone.history.checkUrl(); Backbone.history.checkUrl();
equal(router.arg, null); ok(!router.arg);
location.replace('http://example.com#optional/thing'); location.replace('http://example.com#optional/thing');
Backbone.history.checkUrl(); Backbone.history.checkUrl();
equal(router.arg, 'thing'); equal(router.arg, 'thing');
@@ -265,12 +265,12 @@ $(document).ready(function() {
if (!Backbone.history.iframe) ok(true); if (!Backbone.history.iframe) ok(true);
}); });
test("route callback gets passed decoded values", 3, function() { test("#967 - Route callback gets passed encoded values.", 3, function() {
var route = 'has%2Fslash/complex-has%23hash/has%20space'; var route = 'has%2Fslash/complex-has%23hash/has%20space';
Backbone.history.navigate(route, {trigger: true}); Backbone.history.navigate(route, {trigger: true});
equal(router.first, 'has/slash'); strictEqual(router.first, 'has%2Fslash');
equal(router.part, 'has#hash'); strictEqual(router.part, 'has%23hash');
equal(router.rest, 'has space'); strictEqual(router.rest, 'has%20space');
}); });
test("correctly handles URLs with % (#868)", 3, function() { test("correctly handles URLs with % (#868)", 3, function() {
@@ -279,7 +279,7 @@ $(document).ready(function() {
location.replace('http://example.com#search/fat'); location.replace('http://example.com#search/fat');
Backbone.history.checkUrl(); Backbone.history.checkUrl();
equal(router.query, 'fat'); equal(router.query, 'fat');
equal(router.page, undefined); equal(router.page, void 0);
equal(lastRoute, 'search'); equal(lastRoute, 'search');
}); });

View File

@@ -41,7 +41,7 @@ $(document).ready(function() {
var div = view.make('div', {id: 'test-div'}, 0); var div = view.make('div', {id: 'test-div'}, 0);
equal($(div).text(), '0'); equal($(div).text(), '0');
var div = view.make('div', {id: 'test-div'}, ''); div = view.make('div', {id: 'test-div'}, '');
equal($(div).text(), ''); equal($(div).text(), '');
}); });
@@ -171,7 +171,7 @@ $(document).ready(function() {
return { return {
title: 'title1', title: 'title1',
acceptText: 'confirm' acceptText: 'confirm'
} };
} }
}); });
@@ -310,14 +310,11 @@ $(document).ready(function() {
ok(new View().$el.is('p')); ok(new View().$el.is('p'));
}); });
test("dispose", 0, function() { test("views stopListening", 0, function() {
var View = Backbone.View.extend({ var View = Backbone.View.extend({
events: {
click: function() { ok(false); }
},
initialize: function() { initialize: function() {
this.model.on('all x', function(){ ok(false); }, this); this.listenTo(this.model, 'all x', function(){ ok(false); }, this);
this.collection.on('all x', function(){ ok(false); }, this); this.listenTo(this.collection, 'all x', function(){ ok(false); }, this);
} }
}); });
@@ -326,22 +323,9 @@ $(document).ready(function() {
collection: new Backbone.Collection collection: new Backbone.Collection
}); });
view.dispose(); view.stopListening();
view.model.trigger('x'); view.model.trigger('x');
view.collection.trigger('x'); view.collection.trigger('x');
view.$el.click();
});
test("dispose with non Backbone objects", 0, function() {
var view = new Backbone.View({model: {}, collection: {}});
view.dispose();
});
test("view#remove calls dispose.", 1, function() {
var view = new Backbone.View();
view.dispose = function() { ok(true); };
view.remove();
}); });
test("Provide function for el.", 1, function() { test("Provide function for el.", 1, function() {

View File

@@ -25,6 +25,9 @@
/** Detect free variable `require` */ /** Detect free variable `require` */
var freeRequire = typeof require == 'function' && require; var freeRequire = typeof require == 'function' && require;
/** Used to store the `Object` built-in in case it's overwritten later */
var Object = window.Object;
/** Used to crawl all properties regardless of enumerability */ /** Used to crawl all properties regardless of enumerability */
var getAllKeys = Object.getOwnPropertyNames; var getAllKeys = Object.getOwnPropertyNames;

View File

@@ -187,7 +187,10 @@ class Entry {
preg_match('#/\*\*(?:\s*\*)?([\s\S]*?)(?=\*\s\@[a-z]|\*/)#', $this->entry, $result); preg_match('#/\*\*(?:\s*\*)?([\s\S]*?)(?=\*\s\@[a-z]|\*/)#', $this->entry, $result);
if (count($result)) { if (count($result)) {
$type = $this->getType(); $type = $this->getType();
$result = trim(preg_replace('/(?:^|\n)\s*\* ?/', ' ', $result[1])); $result = preg_replace('/:\n *\* */', ":<br>\n", $result[1]);
$result = preg_replace('/(?:^|\n) *\*\n *\* */', "\n\n", $result);
$result = preg_replace('/(?:^|\n) *\* ?/', ' ', $result);
$result = trim($result);
$result = ($type == 'Function' ? '' : '(' . str_replace('|', ', ', trim($type, '{}')) . '): ') . $result; $result = ($type == 'Function' ? '' : '(' . str_replace('|', ', ', trim($type, '{}')) . '): ') . $result;
} }
$this->_desc = $result; $this->_desc = $result;

View File

@@ -555,4 +555,16 @@ $(document).ready(function() {
value(); value();
ok(returned == 6 && intercepted == 6, 'can use tapped objects in a chain'); ok(returned == 6 && intercepted == 6, 'can use tapped objects in a chain');
}); });
test("has", function () {
var obj = {foo: "bar", func: function () {} };
ok (_.has(obj, "foo"), "has() checks that the object has a property.");
ok (_.has(obj, "baz") == false, "has() returns false if the object doesn't have the property.");
ok (_.has(obj, "func"), "has() works for functions too.");
obj.hasOwnProperty = null;
ok (_.has(obj, "foo"), "has() works even when the hasOwnProperty method is deleted.");
child = {};
child.prototype = obj;
ok (_.has(child, "foo") == false, "has() does not check the prototype chain for a property.")
});
}); });

File diff suppressed because one or more lines are too long

View File

@@ -594,7 +594,7 @@
// all callbacks defined on an object belong to it. // all callbacks defined on an object belong to it.
_.bindAll = function(obj) { _.bindAll = function(obj) {
var funcs = slice.call(arguments, 1); var funcs = slice.call(arguments, 1);
if (funcs.length == 0) funcs = _.functions(obj); if (funcs.length === 0) funcs = _.functions(obj);
each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
return obj; return obj;
}; };
@@ -1075,7 +1075,7 @@
// Useful for temporary DOM ids. // Useful for temporary DOM ids.
var idCounter = 0; var idCounter = 0;
_.uniqueId = function(prefix) { _.uniqueId = function(prefix) {
var id = '' + ++idCounter; var id = '' + (++idCounter);
return prefix ? prefix + id : id; return prefix ? prefix + id : id;
}; };
@@ -1110,6 +1110,7 @@
// Underscore templating handles arbitrary delimiters, preserves whitespace, // Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code. // and correctly escapes quotes within interpolated code.
_.template = function(text, data, settings) { _.template = function(text, data, settings) {
var render;
settings = _.defaults({}, settings, _.templateSettings); settings = _.defaults({}, settings, _.templateSettings);
// Combine delimiters into one regular expression via alternation. // Combine delimiters into one regular expression via alternation.
@@ -1148,7 +1149,7 @@
source + "return __p;\n"; source + "return __p;\n";
try { try {
var render = new Function(settings.variable || 'obj', '_', source); render = new Function(settings.variable || 'obj', '_', source);
} catch (e) { } catch (e) {
e.source = source; e.source = source;
throw e; throw e;