mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Compare commits
122 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf075df7d1 | ||
|
|
11cd9905c4 | ||
|
|
cf462542e9 | ||
|
|
b63f25a1ae | ||
|
|
7de69a21c5 | ||
|
|
21783e4ea0 | ||
|
|
53e5a756d7 | ||
|
|
8c911a2fd0 | ||
|
|
ce440e9f43 | ||
|
|
6465f8d8e6 | ||
|
|
4bdf28059a | ||
|
|
21010c6540 | ||
|
|
a5a6cabac6 | ||
|
|
f460c77f2c | ||
|
|
1c69d9213e | ||
|
|
c02c2d3b2c | ||
|
|
7adf5e763b | ||
|
|
0e4afefc7f | ||
|
|
c7f290f42e | ||
|
|
bb553b8a6a | ||
|
|
21eda2a1a3 | ||
|
|
48c13c990f | ||
|
|
a2665529f6 | ||
|
|
8d35d78eff | ||
|
|
a82a364c22 | ||
|
|
cc150ff9d2 | ||
|
|
feeb38293d | ||
|
|
5b9271ccfe | ||
|
|
e60bbc2fb7 | ||
|
|
387cc184e6 | ||
|
|
a830ddcb43 | ||
|
|
35fea30191 | ||
|
|
24b672b968 | ||
|
|
de6a3c5ab1 | ||
|
|
260ff6de3e | ||
|
|
7cb37411c9 | ||
|
|
e4e41e5ef8 | ||
|
|
985f4aafca | ||
|
|
0c25dd44b3 | ||
|
|
285f0bc6dd | ||
|
|
07a370fd24 | ||
|
|
95f07ea38a | ||
|
|
2890b92b21 | ||
|
|
8b80c5d0b5 | ||
|
|
04425786a1 | ||
|
|
15b14e12e2 | ||
|
|
b328972c4d | ||
|
|
da3156047f | ||
|
|
f9f08ba54f | ||
|
|
b43684262f | ||
|
|
2120f78bd7 | ||
|
|
2d896f22d6 | ||
|
|
9fa0aebfe9 | ||
|
|
2ddc3af5ff | ||
|
|
fd80e096ea | ||
|
|
fab2d69fce | ||
|
|
83d08e3aba | ||
|
|
bfea6bcacf | ||
|
|
feff34b021 | ||
|
|
79fbade92a | ||
|
|
bf508e453e | ||
|
|
47b51c22fa | ||
|
|
ebd16105f2 | ||
|
|
01fb1a5775 | ||
|
|
b8c2a05db9 | ||
|
|
4087dc5fe4 | ||
|
|
408029e6e0 | ||
|
|
23ff403529 | ||
|
|
be4f81f584 | ||
|
|
361c91e610 | ||
|
|
2aa2ea9675 | ||
|
|
e084225edf | ||
|
|
9ce342205b | ||
|
|
0edf50e00e | ||
|
|
1ea19daad9 | ||
|
|
32b302314e | ||
|
|
ee197e02a2 | ||
|
|
7cd6ffec2a | ||
|
|
0077580838 | ||
|
|
4d85a79fd1 | ||
|
|
a35139bb61 | ||
|
|
f72b833724 | ||
|
|
0e16bac6e2 | ||
|
|
e17564b362 | ||
|
|
90b66eddf5 | ||
|
|
2862a5849f | ||
|
|
7e839231ed | ||
|
|
fa56a4bb73 | ||
|
|
dff950748c | ||
|
|
b7374e3f8e | ||
|
|
4244b92b08 | ||
|
|
4f688028ad | ||
|
|
5a9a18501d | ||
|
|
896b8f7cf1 | ||
|
|
95bd1b014f | ||
|
|
dbdf8642bb | ||
|
|
c3cd9007d2 | ||
|
|
8079fb5bc5 | ||
|
|
80d0b5d4ed | ||
|
|
86bd847bf9 | ||
|
|
943004844a | ||
|
|
4ff12e0426 | ||
|
|
0d7bdb6fa8 | ||
|
|
6d488b6a81 | ||
|
|
f1d0263ffa | ||
|
|
24035caadb | ||
|
|
ed89a3e0f8 | ||
|
|
7088ab89f1 | ||
|
|
d4688bd76b | ||
|
|
befe0fccaf | ||
|
|
a192410498 | ||
|
|
d43ede3a11 | ||
|
|
9848ffb77f | ||
|
|
7487497d1f | ||
|
|
be11c848f4 | ||
|
|
9836b274b9 | ||
|
|
a96d14566f | ||
|
|
1c8cd8c168 | ||
|
|
5f5806a98e | ||
|
|
624b045ac0 | ||
|
|
0f8bae950e | ||
|
|
fcede42903 |
7
.jamignore
Normal file
7
.jamignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
*.custom.*
|
||||||
|
.*
|
||||||
|
dist/
|
||||||
|
doc/*.php
|
||||||
|
node_modules/
|
||||||
|
perf/*.sh
|
||||||
|
test/*.sh
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
*.custom.*
|
*.custom.*
|
||||||
*.min.*
|
|
||||||
.*
|
.*
|
||||||
dist/
|
dist/
|
||||||
doc/*.php
|
doc/*.php
|
||||||
@@ -11,7 +10,7 @@ test/*-ui.js
|
|||||||
test/*.sh
|
test/*.sh
|
||||||
vendor/backbone/
|
vendor/backbone/
|
||||||
vendor/docdown/
|
vendor/docdown/
|
||||||
vendor/qunit/qunit/*.css
|
|
||||||
vendor/underscore/
|
|
||||||
vendor/requirejs/
|
|
||||||
vendor/firebug-lite/
|
vendor/firebug-lite/
|
||||||
|
vendor/qunit/qunit/*.css
|
||||||
|
vendor/requirejs/
|
||||||
|
vendor/underscore/test/
|
||||||
|
|||||||
200
README.md
200
README.md
@@ -1,14 +1,14 @@
|
|||||||
# Lo-Dash <sup>v0.4.2</sup>
|
# Lo-Dash <sup>v0.6.0</sup>
|
||||||
|
|
||||||
A drop-in replacement<sup>[*](https://github.com/bestiejs/lodash/wiki/Drop-in-Disclaimer)</sup> for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), that delivers [performance improvements](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#closed-underscorejs-issues), and [additional features](https://github.com/bestiejs/lodash#features).
|
A drop-in replacement<sup>[*](https://github.com/bestiejs/lodash/wiki/Drop-in-Disclaimer)</sup> for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), delivering [performance](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#resolved-underscorejs-issues-30), and [additional features](https://github.com/bestiejs/lodash#features).
|
||||||
|
|
||||||
Lo-Dash’s performance is gained by avoiding slower native methods, instead opting for simplified non-ES5 compliant methods optimized for common usage, and by leveraging function compilation to reduce the number of overall function calls.
|
Lo-Dash’s performance is gained by avoiding slower native methods, instead opting for simplified non-ES5 compliant methods optimized for common usage, and by leveraging function compilation to reduce the number of overall function calls.
|
||||||
|
|
||||||
## Download
|
## Download
|
||||||
|
|
||||||
* [Development source](https://raw.github.com/bestiejs/lodash/v0.4.2/lodash.js)
|
* [Development source](https://raw.github.com/bestiejs/lodash/v0.6.0/lodash.js)
|
||||||
* [Production source](https://raw.github.com/bestiejs/lodash/v0.4.2/lodash.min.js)
|
* [Production source](https://raw.github.com/bestiejs/lodash/v0.6.0/lodash.min.js)
|
||||||
* CDN copies of ≤ [v0.4.1](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.4.1/lodash.min.js) are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/)
|
* CDN copies of ≤ [v0.6.0](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.6.0/lodash.min.js) are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/)
|
||||||
* For optimal performance, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need
|
* For optimal performance, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need
|
||||||
|
|
||||||
## Dive in
|
## Dive in
|
||||||
@@ -24,27 +24,37 @@ For a list of upcoming features, check out our [roadmap](https://github.com/best
|
|||||||
For more information check out these screencasts over Lo-Dash:
|
For more information check out these screencasts over Lo-Dash:
|
||||||
|
|
||||||
* [Introducing Lo-Dash](https://vimeo.com/44154599)
|
* [Introducing Lo-Dash](https://vimeo.com/44154599)
|
||||||
* [Optimizations and custom builds](https://vimeo.com/44154601)
|
* [Lo-Dash optimizations and custom builds](https://vimeo.com/44154601)
|
||||||
* [Lo-Dash’s origin and why it’s a better utility belt](https://vimeo.com/44154600)
|
* [Lo-Dash’s origin and why it’s a better utility belt](https://vimeo.com/44154600)
|
||||||
|
* [Unit testing in Lo-Dash](https://vimeo.com/45865290)
|
||||||
|
|
||||||
## 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.)
|
||||||
* [_.bind](http://lodash.com/docs#bind) supports *"lazy"* binding
|
* [_.bind](http://lodash.com/docs#bind) supports *“lazy”* binding
|
||||||
|
* [_.clone](http://lodash.com/docs#clone) supports *“deep”* cloning
|
||||||
|
* [_.countBy](http://lodash.com/docs#countBy) as a companion function for [_.groupBy](http://lodash.com/docs#groupBy) and [_.sortBy](http://lodash.com/docs#sortBy)
|
||||||
* [_.debounce](http://lodash.com/docs#debounce)’ed functions match [_.throttle](http://lodash.com/docs#throttle)’ed functions’ return value behavior
|
* [_.debounce](http://lodash.com/docs#debounce)’ed functions match [_.throttle](http://lodash.com/docs#throttle)’ed functions’ return value behavior
|
||||||
* [_.forEach](http://lodash.com/docs#forEach) is chainable
|
* [_.drop](http://lodash.com/docs#drop) for the inverse functionality of [_.pick](http://lodash.com/docs#pick)
|
||||||
|
* [_.forEach](http://lodash.com/docs#forEach) is chainable and supports exiting iteration early
|
||||||
* [_.forIn](http://lodash.com/docs#forIn) for iterating over an object’s own and inherited properties
|
* [_.forIn](http://lodash.com/docs#forIn) for iterating over an object’s own and inherited properties
|
||||||
* [_.forOwn](http://lodash.com/docs#forOwn) for iterating over an object’s own properties
|
* [_.forOwn](http://lodash.com/docs#forOwn) for iterating over an object’s own properties
|
||||||
* [_.groupBy](http://lodash.com/docs#groupBy), [_.sortedIndex](http://lodash.com/docs#sortedIndex), and [_.uniq](http://lodash.com/docs#uniq) accept a `thisArg` argument
|
* [_.groupBy](http://lodash.com/docs#groupBy), [_.sortedIndex](http://lodash.com/docs#sortedIndex), and [_.uniq](http://lodash.com/docs#uniq) accept a `thisArg` argument
|
||||||
* [_.indexOf](http://lodash.com/docs#indexOf) and [_.lastIndexOf](http://lodash.com/docs#lastIndexOf) accept a `fromIndex` argument
|
* [_.indexOf](http://lodash.com/docs#indexOf) and [_.lastIndexOf](http://lodash.com/docs#lastIndexOf) accept a `fromIndex` argument
|
||||||
* [_.partial](http://lodash.com/docs#partial) for more functional fun
|
* [_.merge](http://lodash.com/docs#merge) for a *“deep”* [_.extend](http://lodash.com/docs#extend)
|
||||||
|
* [_.partial](http://lodash.com/docs#partial) for partial application without `this` binding
|
||||||
|
* [_.pick](http://lodash.com/docs#pick) and [_.drop](http://lodash.com/docs#drop) accept `callback` and `thisArg` arguments
|
||||||
|
* [_.sortBy](http://lodash.com/docs#sortBy) performs a [stable](http://en.wikipedia.org/wiki/Sorting_algorithm#Stability) sort
|
||||||
* [_.template](http://lodash.com/docs#template) utilizes [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier debugging
|
* [_.template](http://lodash.com/docs#template) utilizes [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier debugging
|
||||||
|
* [_.unescape](http://lodash.com/docs#unescape) to unescape strings escaped by [_.escape](http://lodash.com/docs#escape)
|
||||||
|
* [_.where](http://lodash.com/docs#where) for filtering collections by contained properties
|
||||||
|
* [_.zipObject](http://lodash.com/docs#zipObject) for composing objects
|
||||||
* [_.contains](http://lodash.com/docs#contains), [_.size](http://lodash.com/docs#size), [_.toArray](http://lodash.com/docs#toArray),
|
* [_.contains](http://lodash.com/docs#contains), [_.size](http://lodash.com/docs#size), [_.toArray](http://lodash.com/docs#toArray),
|
||||||
[and more…](http://lodash.com/docs "_.every, _.filter, _.find, _.forEach, _.groupBy, _.invoke, _.map, _.pluck, _.reduce, _.reduceRight, _.reject, _.some, _sortBy") accept strings
|
[and more…](http://lodash.com/docs "_.every, _.filter, _.find, _.forEach, _.groupBy, _.invoke, _.map, _.pluck, _.reduce, _.reduceRight, _.reject, _.some, _sortBy") accept strings
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
Lo-Dash has been tested in at least Chrome 5-20, Firefox 1.5-13, IE 6-9, Opera 9.25-12, Safari 3.0.4-5.1.7, Node.js 0.4.8-0.8.2, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC3.
|
Lo-Dash has been tested in at least Chrome 5-21, Firefox 1-14, IE 6-9, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.8, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5.
|
||||||
|
|
||||||
## Custom builds
|
## Custom builds
|
||||||
|
|
||||||
@@ -52,52 +62,62 @@ Custom builds make it easy to create lightweight versions of Lo-Dash containing
|
|||||||
We handle all the method dependency and alias mapping for you.
|
We handle all the method dependency and alias mapping for you.
|
||||||
|
|
||||||
* Backbone builds, containing all methods required by Backbone, may be created using the `backbone` modifier argument.
|
* Backbone builds, containing all methods required by Backbone, may be created using the `backbone` modifier argument.
|
||||||
~~~ bash
|
```bash
|
||||||
lodash backbone
|
lodash backbone
|
||||||
~~~
|
```
|
||||||
|
|
||||||
|
* CSP builds, supporting default Content Security Policy restrictions, may be created using the `csp` modifier argument.
|
||||||
|
```bash
|
||||||
|
lodash csp
|
||||||
|
```
|
||||||
|
|
||||||
* Legacy builds, tailored for older browsers without [ES5 support](http://es5.github.com/), may be created using the `legacy` modifier argument.
|
* Legacy builds, tailored for older browsers without [ES5 support](http://es5.github.com/), may be created using the `legacy` modifier argument.
|
||||||
~~~ bash
|
```bash
|
||||||
lodash legacy
|
lodash legacy
|
||||||
~~~
|
```
|
||||||
|
|
||||||
* Mobile builds, with IE < 9 bug fixes and method compilation removed, may be created using the `mobile` modifier argument.
|
* Mobile builds, with IE < 9 bug fixes and method compilation removed, may be created using the `mobile` modifier argument.
|
||||||
~~~ bash
|
```bash
|
||||||
lodash mobile
|
lodash mobile
|
||||||
~~~
|
```
|
||||||
|
|
||||||
* Strict builds, with `_.bindAll`, `_.extend`, and `_.defaults` in [strict mode](http://es5.github.com/#C), may be created using the `strict` modifier argument.
|
* Strict builds, with `_.bindAll`, `_.defaults`, and `_.extend` in [strict mode](http://es5.github.com/#C), may be created using the `strict` modifier argument.
|
||||||
~~~ bash
|
```bash
|
||||||
lodash strict
|
lodash strict
|
||||||
~~~
|
```
|
||||||
|
|
||||||
|
* Underscore builds, containing only methods included in Underscore, may be created using the `underscore` modifier argument.
|
||||||
|
```bash
|
||||||
|
lodash underscore
|
||||||
|
```
|
||||||
|
|
||||||
Custom builds may be created in three ways:
|
Custom builds may be created in three ways:
|
||||||
|
|
||||||
1. Use the `category` argument to pass the categories of methods to include in the build.<br>
|
1. Use the `category` argument to pass the categories of methods to include in the build.<br>
|
||||||
Valid categories are *"arrays"*, *"chaining"*, *"collections"*, *"functions"*, *"objects"*, and *"utilities"*.
|
Valid categories are *“arrays”*, *“chaining”*, *“collections”*, *“functions”*, *“objects”*, and *“utilities”*.
|
||||||
~~~ bash
|
```bash
|
||||||
lodash category=collections,functions
|
lodash category=collections,functions
|
||||||
lodash category="collections, functions"
|
lodash category="collections, functions"
|
||||||
~~~
|
```
|
||||||
|
|
||||||
2. Use the `exclude` argument to pass the names of methods to exclude from the build.
|
2. Use the `exclude` argument to pass the names of methods to exclude from the build.
|
||||||
~~~ bash
|
```bash
|
||||||
lodash exclude=union,uniq,zip
|
lodash exclude=union,uniq,zip
|
||||||
lodash exclude="union, uniq, zip"
|
lodash exclude="union, uniq, zip"
|
||||||
~~~
|
```
|
||||||
|
|
||||||
3. Use the `include` argument to pass the names of methods to include in the build.
|
3. Use the `include` argument to pass the names of methods to include in the build.
|
||||||
~~~ bash
|
```bash
|
||||||
lodash include=each,filter,map
|
lodash include=each,filter,map
|
||||||
lodash include="each, filter, map"
|
lodash include="each, filter, map"
|
||||||
~~~
|
```
|
||||||
|
|
||||||
All arguments, except `exclude` with `include` and `legacy` with `mobile`, may be combined.
|
All arguments, except `backbone` with `underscore`, `exclude` with `include`, and `legacy` with `csp`/`mobile`, may be combined.
|
||||||
|
|
||||||
~~~ bash
|
```bash
|
||||||
lodash backbone legacy category=utilities exclude=first,last
|
lodash backbone legacy category=utilities exclude=first,last
|
||||||
lodash backbone mobile strict category=functions include=pick,uniq
|
lodash underscore mobile strict category=functions include=pick,uniq
|
||||||
~~~
|
```
|
||||||
|
|
||||||
The `lodash` command-line utility is available when Lo-Dash is installed as a global package (i.e. `npm install -g lodash`).
|
The `lodash` command-line utility is available when Lo-Dash is installed as a global package (i.e. `npm install -g lodash`).
|
||||||
|
|
||||||
@@ -107,38 +127,38 @@ Custom builds are saved to `lodash.custom.js` and `lodash.custom.min.js`.
|
|||||||
|
|
||||||
In browsers:
|
In browsers:
|
||||||
|
|
||||||
~~~ html
|
```html
|
||||||
<script src="lodash.js"></script>
|
<script src="lodash.js"></script>
|
||||||
~~~
|
```
|
||||||
|
|
||||||
Using [npm](http://npmjs.org/):
|
Using [npm](http://npmjs.org/):
|
||||||
|
|
||||||
~~~ bash
|
```bash
|
||||||
npm install lodash
|
npm install lodash
|
||||||
npm install -g lodash
|
npm install -g lodash
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/):
|
In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In [Narwhal](http://narwhaljs.org/) and [RingoJS v0.7.0-](http://ringojs.org/):
|
In [RingoJS v0.7.0-](http://ringojs.org/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
var _ = require('lodash')._;
|
var _ = require('lodash')._;
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In [Rhino](http://www.mozilla.org/rhino/):
|
In [Rhino](http://www.mozilla.org/rhino/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
load('lodash.js');
|
load('lodash.js');
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In an AMD loader like [RequireJS](http://requirejs.org/):
|
In an AMD loader like [RequireJS](http://requirejs.org/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
require({
|
require({
|
||||||
'paths': {
|
'paths': {
|
||||||
'underscore': 'path/to/lodash'
|
'underscore': 'path/to/lodash'
|
||||||
@@ -147,33 +167,42 @@ require({
|
|||||||
['underscore'], function(_) {
|
['underscore'], function(_) {
|
||||||
console.log(_.VERSION);
|
console.log(_.VERSION);
|
||||||
});
|
});
|
||||||
~~~
|
```
|
||||||
|
|
||||||
## Closed Underscore.js issues <sup>(20+)</sup>
|
## Resolved Underscore.js issues <sup>(30+)</sup>
|
||||||
|
|
||||||
* Allow iteration of objects with a `length` property [[#148](https://github.com/documentcloud/underscore/issues/148), [#154](https://github.com/documentcloud/underscore/issues/154), [#252](https://github.com/documentcloud/underscore/issues/252), [#448](https://github.com/documentcloud/underscore/issues/448), [#659](https://github.com/documentcloud/underscore/issues/659), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L364-370)]
|
* Allow iteration of objects with a `length` property [[#148](https://github.com/documentcloud/underscore/issues/148), [#154](https://github.com/documentcloud/underscore/issues/154), [#252](https://github.com/documentcloud/underscore/issues/252), [#448](https://github.com/documentcloud/underscore/issues/448), [#659](https://github.com/documentcloud/underscore/issues/659), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L578-584)]
|
||||||
* Ensure array-like objects with invalid `length` properties are treated like regular objects [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L315-321), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L665-679), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L921-924)]
|
* Ensure array-like objects with invalid `length` properties are treated like regular objects [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L526-536)]
|
||||||
* Ensure *"Arrays"* methods allow falsey `array` arguments [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L989-1027)]
|
* Ensure *“Arrays”*, “Collections”, and “Objects” methods don’t error when passed falsey arguments [[#650](https://github.com/documentcloud/underscore/pull/650), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L1668-1703)]
|
||||||
* Ensure *"Collections"* methods allow string `collection` arguments [[#247](https://github.com/documentcloud/underscore/issues/247), [#276](https://github.com/documentcloud/underscore/issues/276), [#561](https://github.com/documentcloud/underscore/pull/561), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L148-157), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L323-341), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L681-698), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L926-929)]
|
* Ensure *“Collections”* methods allow string `collection` arguments [[#247](https://github.com/documentcloud/underscore/issues/247), [#276](https://github.com/documentcloud/underscore/issues/276), [#561](https://github.com/documentcloud/underscore/pull/561), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L538-555)]
|
||||||
* Ensure templates compiled with errors are inspectable [[#666](https://github.com/documentcloud/underscore/issues/666), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L795-802)]
|
* Ensure templates compiled with errors are inspectable [[#666](https://github.com/documentcloud/underscore/issues/666), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L1383-1386)]
|
||||||
* Fix cross-browser object iteration bugs [[#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L224-236), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L375-400), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L496-507), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L515-517), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L535-555), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L725-727)]
|
* 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/v0.6.0/test/test.js#L589-614)]
|
||||||
* Handle arrays with `undefined` values correctly in IE < 9 [[#601](https://github.com/documentcloud/underscore/issues/601)]
|
* Handle arrays with `undefined` values correctly in IE < 9 [[#601](https://github.com/documentcloud/underscore/issues/601)]
|
||||||
* Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L96-102)]
|
* Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L117-123)]
|
||||||
* Register as an AMD module, but still export to global [[#431](https://github.com/documentcloud/underscore/pull/431), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L80-94)]
|
* Register as an AMD module, but still export to global [[#431](https://github.com/documentcloud/underscore/pull/431), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L101-115)]
|
||||||
* `_(…)` should return passed wrapper instances [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L114-117)]
|
* `_(…)` should return passed wrapper instances [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L135-138)]
|
||||||
* `_.contains` should work with strings [[#667](https://github.com/documentcloud/underscore/pull/667), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L148-157)]
|
* `_.clone` should allow `deep` cloning [[#595](https://github.com/documentcloud/underscore/pull/595), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L205-220)]
|
||||||
* `_.escape` should return an empty string when passed `null` or `undefined` [[#407](https://github.com/documentcloud/underscore/issues/427), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L205-208)]
|
* `_.contains` should work with strings [[#667](https://github.com/documentcloud/underscore/pull/667), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L275-284)]
|
||||||
* `_.forEach` should be chainable [[#142](https://github.com/documentcloud/underscore/issues/142), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L310-313)]
|
* `_.countBy` and `_.groupBy` should only add values to own, not inherited, properties [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L292-299)]
|
||||||
* `_.groupBy` should add values to own, not inherited, properties [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L415-422)]
|
* `_.escape` should return an empty string when passed `null` or `undefined` [[#427](https://github.com/documentcloud/underscore/issues/427), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L402-405)]
|
||||||
* `_isNaN(new Number(NaN))` should return `true` [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L525-527)]
|
* `_.extend` should recursively extend objects [[#379](https://github.com/documentcloud/underscore/pull/379), [#718](https://github.com/documentcloud/underscore/issues/718), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L979-1001)]
|
||||||
* `_.reduceRight` should pass correct callback arguments when iterating objects [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L649-663)]
|
* `_.forEach` should be chainable [[#142](https://github.com/documentcloud/underscore/issues/142), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L521-524)]
|
||||||
* `_.size` should return the `length` of string values [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L708-710)]
|
* `_.forEach` should allow exiting iteration early [[#211](https://github.com/documentcloud/underscore/issues/211), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L616-635)]
|
||||||
* `_.size` shouldn't error on falsey values [[#650](https://github.com/documentcloud/underscore/pull/650), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L712-719)]
|
* `_.isElement` should use strict equality for its duck type check [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L731-740)]
|
||||||
* `_.size` should work with `arguments` objects cross-browser [[#653](https://github.com/documentcloud/underscore/issues/653), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L721-723)]
|
* `_.isEmpty` and `_.size` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L767-772)]
|
||||||
* `_.sortedIndex` should support arrays with high `length` values [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L765-774)]
|
* `_.isEqual` should return `true` for like-objects from different documents [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L808-828)]
|
||||||
* `_.template` should not augment the `options` object [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L789-793)]
|
* `_.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/v0.6.0/test/test.js#L836-848)]
|
||||||
* `_.throttle` should work when called in a loop [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L872-882)]
|
* `_.isNaN(new Number(NaN))` should return `true` [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L856-858)]
|
||||||
* `_.zipObject` should accept less than two arguments [[test](https://github.com/bestiejs/lodash/blob/v0.4.2/test/test.js#L951-953)]
|
* `_.keys` and `_.size` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [#653](https://github.com/documentcloud/underscore/issues/653), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L912-914)]
|
||||||
|
* `_.once` should free the given function for garbage collection [[#693](https://github.com/documentcloud/underscore/pull/693)]
|
||||||
|
* `_.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/v0.6.0/test/test.js#L1170-1173)]
|
||||||
|
* `_.reduceRight` should pass correct callback arguments when iterating objects [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L1205-1219)]
|
||||||
|
* `_.size` should return the `length` of string values [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L1263-1265)]
|
||||||
|
* `_.sortedIndex` should support arrays with high `length` values [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L1353-1362)]
|
||||||
|
* `_.template` should not augment the `options` object [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L1377-1381)]
|
||||||
|
* `_.throttle` should work when called in a loop [[#502](https://github.com/documentcloud/underscore/issues/502), [test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L1473-1483)]
|
||||||
|
* `_.toArray` uses custom `toArray` methods of arrays and strings [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L1510-1518)]
|
||||||
|
* `_.zipObject` should accept less than two arguments [[test](https://github.com/bestiejs/lodash/blob/v0.6.0/test/test.js#L1630-1632)]
|
||||||
|
|
||||||
## Optimized methods <sup>(50+)</sup>
|
## Optimized methods <sup>(50+)</sup>
|
||||||
|
|
||||||
@@ -185,6 +214,7 @@ require({
|
|||||||
* `_.defaults`
|
* `_.defaults`
|
||||||
* `_.defer`
|
* `_.defer`
|
||||||
* `_.difference`
|
* `_.difference`
|
||||||
|
* `_.drop`, `_.omit`
|
||||||
* `_.each`
|
* `_.each`
|
||||||
* `_.escape`
|
* `_.escape`
|
||||||
* `_.every`, `_.all`
|
* `_.every`, `_.all`
|
||||||
@@ -201,7 +231,6 @@ require({
|
|||||||
* `_.isArguments`
|
* `_.isArguments`
|
||||||
* `_.isDate`
|
* `_.isDate`
|
||||||
* `_.isEmpty`
|
* `_.isEmpty`
|
||||||
* `_.isEqual`
|
|
||||||
* `_.isFinite`
|
* `_.isFinite`
|
||||||
* `_.isFunction`
|
* `_.isFunction`
|
||||||
* `_.isObject`
|
* `_.isObject`
|
||||||
@@ -238,39 +267,22 @@ require({
|
|||||||
|
|
||||||
## Release Notes
|
## Release Notes
|
||||||
|
|
||||||
### <sup>v0.4.2</sup>
|
### <sup>v0.6.0</sup>
|
||||||
|
|
||||||
* Added `strict` build
|
* Added `callback` and `thisArg` arguments to `_.drop` and `_.pick`
|
||||||
* Ensured `_.bindAll`, `_.extend`, and `_.defaults` avoid strict mode errors when attempting to augment read-only properties
|
* Added `hasObjectSpliceBug` test to avoid `delete` operator use
|
||||||
* Optimized the iteration of large arrays in `_.difference`, `_.intersection`, and `_.without`
|
* Added `_.omit` alias for `_.drop`
|
||||||
* Fixed build bugs related to removing variables
|
* Added [_.unescape](http://lodash.com/docs#unescape)
|
||||||
|
* Ensured `_.reduce` works with string objects in IE < 9
|
||||||
### <sup>v0.4.1</sup>
|
* Made compiled methods take advantage of engines with strict mode optimizations
|
||||||
|
* Optimized `_.intersection` and removed its dependency on `_.every`
|
||||||
* Fixed `_.template` regression
|
* Reduced the file size of the `underscore` build
|
||||||
* Optimized build process to detect and remove more unused variables
|
|
||||||
|
|
||||||
### <sup>v0.4.0</sup>
|
|
||||||
|
|
||||||
* Added `bin` and `scripts` entries to package.json
|
|
||||||
* Added `legacy` build option
|
|
||||||
* Added cross-browser support for passing strings to *"Collections"* methods
|
|
||||||
* Added `_.zipObject`
|
|
||||||
* Leveraged `_.indexOf`'s `fromIndex` in `_.difference` and `_.without`
|
|
||||||
* Optimized compiled templates
|
|
||||||
* Optimized inlining the `iteratorTemplate` for builds
|
|
||||||
* Optimized object iteration for *"Collections"* methods
|
|
||||||
* Optimized partially applied `_.bind` in V8
|
|
||||||
* Made compiled templates more debuggable
|
|
||||||
* Made `_.size` work with falsey values and consistent cross-browser with `arguments` objects
|
|
||||||
* Moved `_.groupBy` and `_.sortBy` back to the *"Collections"* category
|
|
||||||
* Removed `arguments` object from `_.range`
|
|
||||||
|
|
||||||
The full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog).
|
The full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog).
|
||||||
|
|
||||||
## BestieJS
|
## BestieJS
|
||||||
|
|
||||||
Lo-Dash is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.
|
Lo-Dash is part of the BestieJS *“Best in Class”* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
|
|||||||
375
build.js
375
build.js
@@ -2,6 +2,9 @@
|
|||||||
;(function() {
|
;(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/** The debug version of `source` */
|
||||||
|
var debugSource;
|
||||||
|
|
||||||
/** Load modules */
|
/** Load modules */
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
@@ -11,14 +14,20 @@
|
|||||||
/** The current working directory */
|
/** The current working directory */
|
||||||
var cwd = process.cwd();
|
var cwd = process.cwd();
|
||||||
|
|
||||||
/** Flag used to specify a backbone build */
|
/** Flag used to specify a Backbone build */
|
||||||
var isBackbone = process.argv.indexOf('backbone') > -1;
|
var isBackbone = process.argv.indexOf('backbone') > -1;
|
||||||
|
|
||||||
|
/** Flag used to specify a Content Security Policy build */
|
||||||
|
var isCSP = process.argv.indexOf('csp') > -1 || process.argv.indexOf('CSP') > -1;
|
||||||
|
|
||||||
/** Flag used to specify a legacy build */
|
/** Flag used to specify a legacy build */
|
||||||
var isLegacy = process.argv.indexOf('legacy') > -1;
|
var isLegacy = process.argv.indexOf('legacy') > -1;
|
||||||
|
|
||||||
|
/** Flag used to specify an Underscore build */
|
||||||
|
var isUnderscore = process.argv.indexOf('underscore') > -1;
|
||||||
|
|
||||||
/** Flag used to specify a mobile build */
|
/** Flag used to specify a mobile build */
|
||||||
var isMobile = !isLegacy && process.argv.indexOf('mobile') > -1;
|
var isMobile = !isLegacy && (isCSP || isUnderscore || process.argv.indexOf('mobile') > -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag used to specify `_.bindAll`, `_.extend`, and `_.defaults` are
|
* Flag used to specify `_.bindAll`, `_.extend`, and `_.defaults` are
|
||||||
@@ -41,18 +50,25 @@
|
|||||||
|
|
||||||
if (isStrict) {
|
if (isStrict) {
|
||||||
source = setUseStrictOption(source, true);
|
source = setUseStrictOption(source, true);
|
||||||
}
|
} else {
|
||||||
else if (!useStrict) {
|
|
||||||
source = removeUseStrictDirective(source);
|
source = removeUseStrictDirective(source);
|
||||||
source = setUseStrictOption(source, false);
|
if (!useStrict) {
|
||||||
|
source = setUseStrictOption(source, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLegacy) {
|
if (isLegacy) {
|
||||||
['isBindFast', 'isKeysFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'].forEach(function(varName) {
|
source = replaceVar(source, 'noArgsClass', 'true');
|
||||||
|
['isBindFast', 'isKeysFast', 'isStrictFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'].forEach(function(varName) {
|
||||||
source = replaceVar(source, varName, 'false');
|
source = replaceVar(source, varName, 'false');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (isMobile) {
|
else if (isUnderscore) {
|
||||||
|
// remove `prototype` [[Enumerable]] fix from `iteratorTemplate`
|
||||||
|
source = source
|
||||||
|
.replace(/(?: *\/\/.*\n)*\s*' *(?:<% *)?if *\(!hasDontEnumBug *(?:&&|\))[\s\S]+?<% *} *(?:%>|').+/g, '')
|
||||||
|
.replace(/!hasDontEnumBug *\|\|/g, '');
|
||||||
|
}
|
||||||
|
if (isMobile) {
|
||||||
source = replaceVar(source, 'isKeysFast', 'false');
|
source = replaceVar(source, 'isKeysFast', 'false');
|
||||||
}
|
}
|
||||||
vm.runInNewContext(source, sandbox);
|
vm.runInNewContext(source, sandbox);
|
||||||
@@ -72,6 +88,7 @@
|
|||||||
'include': 'contains',
|
'include': 'contains',
|
||||||
'inject': 'reduce',
|
'inject': 'reduce',
|
||||||
'methods': 'functions',
|
'methods': 'functions',
|
||||||
|
'omit': 'drop',
|
||||||
'select': 'filter',
|
'select': 'filter',
|
||||||
'tail': 'rest',
|
'tail': 'rest',
|
||||||
'take': 'first',
|
'take': 'first',
|
||||||
@@ -81,6 +98,7 @@
|
|||||||
/** Used to associate real names with their aliases */
|
/** Used to associate real names with their aliases */
|
||||||
var realToAliasMap = {
|
var realToAliasMap = {
|
||||||
'contains': ['include'],
|
'contains': ['include'],
|
||||||
|
'drop': ['omit'],
|
||||||
'every': ['all'],
|
'every': ['all'],
|
||||||
'filter': ['select'],
|
'filter': ['select'],
|
||||||
'find': ['detect'],
|
'find': ['detect'],
|
||||||
@@ -143,43 +161,45 @@
|
|||||||
/** Used to track function dependencies */
|
/** Used to track function dependencies */
|
||||||
var dependencyMap = {
|
var dependencyMap = {
|
||||||
'after': [],
|
'after': [],
|
||||||
'bind': [],
|
'bind': ['isFunction'],
|
||||||
'bindAll': ['bind', 'functions'],
|
'bindAll': ['bind', 'isFunction'],
|
||||||
'chain': ['mixin'],
|
'chain': ['mixin'],
|
||||||
'clone': ['extend', 'isArray'],
|
'clone': ['extend', 'forIn', 'forOwn', 'isArguments', 'isFunction'],
|
||||||
'compact': [],
|
'compact': [],
|
||||||
'compose': [],
|
'compose': [],
|
||||||
'contains': [],
|
'contains': [],
|
||||||
|
'countBy': [],
|
||||||
'debounce': [],
|
'debounce': [],
|
||||||
'defaults': [],
|
'defaults': ['isArguments'],
|
||||||
'defer': [],
|
'defer': [],
|
||||||
'delay': [],
|
'delay': [],
|
||||||
'difference': ['indexOf'],
|
'difference': ['indexOf'],
|
||||||
|
'drop': ['indexOf', 'isArguments'],
|
||||||
'escape': [],
|
'escape': [],
|
||||||
'every': ['identity'],
|
'every': ['identity'],
|
||||||
'extend': [],
|
'extend': ['isArguments'],
|
||||||
'filter': ['identity'],
|
'filter': ['identity'],
|
||||||
'find': [],
|
'find': [],
|
||||||
'first': [],
|
'first': [],
|
||||||
'flatten': ['isArray'],
|
'flatten': ['isArray'],
|
||||||
'forEach': [],
|
'forEach': [],
|
||||||
'forIn': [],
|
'forIn': ['isArguments'],
|
||||||
'forOwn': [],
|
'forOwn': ['isArguments'],
|
||||||
'functions': [],
|
'functions': ['isArguments', 'isFunction'],
|
||||||
'groupBy': [],
|
'groupBy': [],
|
||||||
'has': [],
|
'has': [],
|
||||||
'identity': [],
|
'identity': [],
|
||||||
'indexOf': ['sortedIndex'],
|
'indexOf': ['sortedIndex'],
|
||||||
'initial': [],
|
'initial': [],
|
||||||
'intersection': ['every', 'indexOf'],
|
'intersection': ['indexOf'],
|
||||||
'invoke': [],
|
'invoke': [],
|
||||||
'isArguments': [],
|
'isArguments': [],
|
||||||
'isArray': [],
|
'isArray': [],
|
||||||
'isBoolean': [],
|
'isBoolean': [],
|
||||||
'isDate': [],
|
'isDate': [],
|
||||||
'isElement': [],
|
'isElement': [],
|
||||||
'isEmpty': [],
|
'isEmpty': ['isArguments', 'isFunction'],
|
||||||
'isEqual': [],
|
'isEqual': ['isArguments', 'isFunction'],
|
||||||
'isFinite': [],
|
'isFinite': [],
|
||||||
'isFunction': [],
|
'isFunction': [],
|
||||||
'isNaN': [],
|
'isNaN': [],
|
||||||
@@ -189,12 +209,13 @@
|
|||||||
'isRegExp': [],
|
'isRegExp': [],
|
||||||
'isString': [],
|
'isString': [],
|
||||||
'isUndefined': [],
|
'isUndefined': [],
|
||||||
'keys': [],
|
'keys': ['isArguments'],
|
||||||
'last': [],
|
'last': [],
|
||||||
'lastIndexOf': [],
|
'lastIndexOf': [],
|
||||||
'map': ['identity'],
|
'map': ['identity'],
|
||||||
'max': [],
|
'max': [],
|
||||||
'memoize': [],
|
'memoize': [],
|
||||||
|
'merge': ['isArguments', 'isArray', 'forIn'],
|
||||||
'min': [],
|
'min': [],
|
||||||
'mixin': ['forEach', 'functions'],
|
'mixin': ['forEach', 'functions'],
|
||||||
'noConflict': [],
|
'noConflict': [],
|
||||||
@@ -207,9 +228,9 @@
|
|||||||
'reduceRight': ['keys'],
|
'reduceRight': ['keys'],
|
||||||
'reject': ['identity'],
|
'reject': ['identity'],
|
||||||
'rest': [],
|
'rest': [],
|
||||||
'result': [],
|
'result': ['isFunction'],
|
||||||
'shuffle': [],
|
'shuffle': [],
|
||||||
'size': ['keys'],
|
'size': ['isArguments', 'isFunction', 'keys'],
|
||||||
'some': ['identity'],
|
'some': ['identity'],
|
||||||
'sortBy': [],
|
'sortBy': [],
|
||||||
'sortedIndex': ['bind'],
|
'sortedIndex': ['bind'],
|
||||||
@@ -217,11 +238,13 @@
|
|||||||
'template': ['escape'],
|
'template': ['escape'],
|
||||||
'throttle': [],
|
'throttle': [],
|
||||||
'times': [],
|
'times': [],
|
||||||
'toArray': ['values'],
|
'toArray': ['isFunction', 'values'],
|
||||||
|
'unescape': [],
|
||||||
'union': ['indexOf'],
|
'union': ['indexOf'],
|
||||||
'uniq': ['identity', 'indexOf'],
|
'uniq': ['identity', 'indexOf'],
|
||||||
'uniqueId': [],
|
'uniqueId': [],
|
||||||
'values': [],
|
'values': ['isArguments'],
|
||||||
|
'where': ['forIn'],
|
||||||
'without': ['indexOf'],
|
'without': ['indexOf'],
|
||||||
'wrap': [],
|
'wrap': [],
|
||||||
'zip': ['max', 'pluck'],
|
'zip': ['max', 'pluck'],
|
||||||
@@ -243,6 +266,7 @@
|
|||||||
'isKeysFast',
|
'isKeysFast',
|
||||||
'object',
|
'object',
|
||||||
'objectBranch',
|
'objectBranch',
|
||||||
|
'noArgsEnum',
|
||||||
'noCharByIndex',
|
'noCharByIndex',
|
||||||
'shadowed',
|
'shadowed',
|
||||||
'top',
|
'top',
|
||||||
@@ -251,10 +275,22 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
/** Collections of method names */
|
/** Collections of method names */
|
||||||
var excludeMethods,
|
var excludeMethods = [],
|
||||||
includeMethods,
|
includeMethods = [],
|
||||||
allMethods = Object.keys(dependencyMap);
|
allMethods = Object.keys(dependencyMap);
|
||||||
|
|
||||||
|
var underscoreMethods = lodash.without.apply(lodash, [allMethods].concat([
|
||||||
|
'countBy',
|
||||||
|
'drop',
|
||||||
|
'forIn',
|
||||||
|
'forOwn',
|
||||||
|
'merge',
|
||||||
|
'partial',
|
||||||
|
'unescape',
|
||||||
|
'where',
|
||||||
|
'zipObject'
|
||||||
|
]));
|
||||||
|
|
||||||
/** Used to specify whether filtering is for exclusion or inclusion */
|
/** Used to specify whether filtering is for exclusion or inclusion */
|
||||||
var filterType = process.argv.reduce(function(result, value) {
|
var filterType = process.argv.reduce(function(result, value) {
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -289,14 +325,17 @@
|
|||||||
' Commands:',
|
' Commands:',
|
||||||
'',
|
'',
|
||||||
' lodash backbone Build containing all methods required by Backbone',
|
' lodash backbone Build containing all methods required by Backbone',
|
||||||
|
' lodash csp Build supporting default Content Security Policy restrictions',
|
||||||
' lodash legacy Build tailored for older browsers without ES5 support',
|
' lodash legacy Build tailored for older browsers without ES5 support',
|
||||||
' lodash mobile Build with IE < 9 bug fixes and method compilation removed',
|
' lodash mobile Build with IE < 9 bug fixes and method compilation removed',
|
||||||
' lodash strict Build with `_.bindAll`, `_.extend`, and `_.defaults` in strict mode',
|
' lodash strict Build with `_.bindAll`, `_.defaults`, and `_.extend` in strict mode',
|
||||||
|
' lodash underscore Build containing only methods included in Underscore',
|
||||||
' lodash category=... Comma separated categories of methods to include in the build',
|
' lodash category=... Comma separated categories of methods to include in the build',
|
||||||
' lodash exclude=... Comma separated names of methods to exclude from the build',
|
' lodash exclude=... Comma separated names of methods to exclude from the build',
|
||||||
' lodash include=... Comma separated names of methods to include in the build',
|
' lodash include=... Comma separated names of methods to include in the build',
|
||||||
'',
|
'',
|
||||||
' All arguments, except `exclude` with `include` and `legacy` with `mobile`, may be combined.',
|
' All arguments, except `backbone` with `underscore`, `exclude` with `include`,',
|
||||||
|
' and `legacy` with `csp`/`mobile`, may be combined.',
|
||||||
'',
|
'',
|
||||||
' Options:',
|
' Options:',
|
||||||
'',
|
'',
|
||||||
@@ -317,6 +356,17 @@
|
|||||||
return realToAliasMap[funcName] || [];
|
return realToAliasMap[funcName] || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Lo-Dash method assignments snippet from `source`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to inspect.
|
||||||
|
* @returns {String} Returns the method assignments snippet.
|
||||||
|
*/
|
||||||
|
function getMethodAssignments(source) {
|
||||||
|
return (source.match(/lodash\.VERSION *= *[\s\S]+?\/\*-+\*\/\n/) || [''])[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an array of depenants for a function by a given name.
|
* Gets an array of depenants for a function by a given name.
|
||||||
*
|
*
|
||||||
@@ -385,7 +435,7 @@
|
|||||||
* @returns {String} Returns the `isArguments` fallback snippet.
|
* @returns {String} Returns the `isArguments` fallback snippet.
|
||||||
*/
|
*/
|
||||||
function getIsArgumentsFallback(source) {
|
function getIsArgumentsFallback(source) {
|
||||||
return (source.match(/(?:\s*\/\/.*)*\s*if *\(!(?:lodash\.)?isArguments[^)]+\)[\s\S]+?};\s*}/) || [''])[0];
|
return (source.match(/(?:\s*\/\/.*)*\s*if *\(noArgsClass[\s\S]+?};\s*}/) || [''])[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -452,7 +502,7 @@
|
|||||||
function removeFromCreateIterator(source, refName) {
|
function removeFromCreateIterator(source, refName) {
|
||||||
var snippet = matchFunction(source, 'createIterator');
|
var snippet = matchFunction(source, 'createIterator');
|
||||||
if (snippet) {
|
if (snippet) {
|
||||||
// clip the snippet the `factory` assignment
|
// clip the snippet at the `factory` assignment
|
||||||
snippet = snippet.match(/Function\([\s\S]+$/)[0];
|
snippet = snippet.match(/Function\([\s\S]+$/)[0];
|
||||||
var modified = snippet.replace(RegExp('\\b' + refName + '\\b,? *', 'g'), '');
|
var modified = snippet.replace(RegExp('\\b' + refName + '\\b,? *', 'g'), '');
|
||||||
source = source.replace(snippet, modified);
|
source = source.replace(snippet, modified);
|
||||||
@@ -481,7 +531,7 @@
|
|||||||
source = source.replace(matchFunction(source, funcName), '');
|
source = source.replace(matchFunction(source, funcName), '');
|
||||||
|
|
||||||
// grab the method assignments snippet
|
// grab the method assignments snippet
|
||||||
snippet = source.match(/lodash\.VERSION *= *[\s\S]+?\/\*-+\*\/\n/)[0];
|
snippet = getMethodAssignments(source);
|
||||||
|
|
||||||
// remove assignment and aliases
|
// remove assignment and aliases
|
||||||
modified = getAliases(funcName).concat(funcName).reduce(function(result, otherName) {
|
modified = getAliases(funcName).concat(funcName).reduce(function(result, otherName) {
|
||||||
@@ -505,6 +555,17 @@
|
|||||||
return source.replace(getIsArgumentsFallback(source), '');
|
return source.replace(getIsArgumentsFallback(source), '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the `_.isFunction` fallback from `source`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to process.
|
||||||
|
* @returns {String} Returns the source with the `isFunction` fallback removed.
|
||||||
|
*/
|
||||||
|
function removeIsFunctionFallback(source) {
|
||||||
|
return source.replace(/(?:\s*\/\/.*)*\s*if *\(isFunction\(\/x\/[\s\S]+?};\s*}/, '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the `Object.keys` object iteration optimization from `source`.
|
* Removes the `Object.keys` object iteration optimization from `source`.
|
||||||
*
|
*
|
||||||
@@ -524,6 +585,38 @@
|
|||||||
.replace(/\s*.+?\.isKeysFast *=.+/, '');
|
.replace(/\s*.+?\.isKeysFast *=.+/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all `noArgsClass` references from `source`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to process.
|
||||||
|
* @returns {String} Returns the modified source.
|
||||||
|
*/
|
||||||
|
function removeNoArgsClass(source) {
|
||||||
|
return removeVar(source, 'noArgsClass')
|
||||||
|
// remove `noArgsClass` from `_.clone`, `_.isEqual`, and `_.size`
|
||||||
|
.replace(/ *\|\| *\(noArgsClass *&&[^)]+?\)\)/g, '')
|
||||||
|
// remove `noArgsClass` from `_.isEqual`
|
||||||
|
.replace(/if *\(noArgsClass[^}]+?}\n/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all `noNodeClass` references from `source`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to process.
|
||||||
|
* @returns {String} Returns the modified source.
|
||||||
|
*/
|
||||||
|
function removeNoNodeClass(source) {
|
||||||
|
return source
|
||||||
|
// remove `noNodeClass` assignment
|
||||||
|
.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *\{(?:\s*\/\/.*)*\n *var noNodeClass[\s\S]+?catch[^}]+}\n/, '')
|
||||||
|
// remove `noNodeClass` from `isPlainObject`
|
||||||
|
.replace(/\(!noNodeClass *\|\|[\s\S]+?\)\) *&&/, '')
|
||||||
|
// remove `noNodeClass` from `_.isEqual`
|
||||||
|
.replace(/ *\|\| *\(noNodeClass *&&[\s\S]+?\)\)\)/, '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the "use strict" directive from `source`.
|
* Removes the "use strict" directive from `source`.
|
||||||
*
|
*
|
||||||
@@ -563,6 +656,9 @@
|
|||||||
// remove a variable at the end of a variable declaration list
|
// remove a variable at the end of a variable declaration list
|
||||||
source = source.replace(RegExp(',\\s*' + varName + ' *=.+?;'), ';');
|
source = source.replace(RegExp(',\\s*' + varName + ' *=.+?;'), ';');
|
||||||
|
|
||||||
|
// remove variable reference from `arrayLikeClasses` and `cloneableClasses` assignments
|
||||||
|
source = source.replace(RegExp('(?:arrayLikeClasses|cloneableClasses)\\[' + varName + '\\] *= *(?:false|true)?', 'g'), '');
|
||||||
|
|
||||||
return removeFromCreateIterator(source, varName);
|
return removeFromCreateIterator(source, varName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,15 +696,37 @@
|
|||||||
* @returns {String} Returns the modified source.
|
* @returns {String} Returns the modified source.
|
||||||
*/
|
*/
|
||||||
function setUseStrictOption(source, value) {
|
function setUseStrictOption(source, value) {
|
||||||
return source
|
// remove `isStrictFast` assignment
|
||||||
|
return removeVar(source, 'isStrictFast')
|
||||||
// replace `useStrict` branch in `value` with hard-coded option
|
// replace `useStrict` branch in `value` with hard-coded option
|
||||||
.replace(/(?: *\/\/.*\n)*(\s*)' *<% *if *\(useStrict\).+/, value ? "$1'\\'use strict\\';\\n' +" : '')
|
.replace(/(?: *\/\/.*\n)*(\s*)' *<% *if *\(useStrict\).+/, value ? "$1'\\'use strict\\';\\n' +" : '')
|
||||||
// remove `useStrict` from iterator options
|
// remove `useStrict` from iterator options
|
||||||
.replace(/ *'useStrict': *false,\n/g, '')
|
.replace(/ *'useStrict': *false,\n/g, '')
|
||||||
|
// remove `useStrict` variable assignment in `createIterator`
|
||||||
|
.replace(/,\s*useStrict *=[^;]+/, '')
|
||||||
// remove `useStrict` data object property assignment in `createIterator`
|
// remove `useStrict` data object property assignment in `createIterator`
|
||||||
.replace(/\s*.+?\.useStrict *=.+/, '');
|
.replace(/\s*.+?\.useStrict *=.+/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes `source` to a file with the given `filename` to the current
|
||||||
|
* working directory.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to write.
|
||||||
|
* @param {String} filename The name of the file.
|
||||||
|
*/
|
||||||
|
function writeFile(source, filename) {
|
||||||
|
// correct overly aggressive Closure Compiler minification
|
||||||
|
source = source.replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}');
|
||||||
|
|
||||||
|
// re-remove "use strict" added by the minifier
|
||||||
|
if (!isStrict) {
|
||||||
|
source = removeUseStrictDirective(source);
|
||||||
|
}
|
||||||
|
fs.writeFileSync(path.join(cwd, filename), source);
|
||||||
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// display help message
|
// display help message
|
||||||
@@ -629,25 +747,47 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Backbone build
|
// don't expose `_.forIn` or `_.forOwn` if `isUnderscore` is `true` unless
|
||||||
if (isBackbone) {
|
// requested by `include`
|
||||||
|
if (isUnderscore) {
|
||||||
|
if (includeMethods.indexOf('forIn') == -1) {
|
||||||
|
source = source.replace(/ *lodash\.forIn *=.+\n/, '');
|
||||||
|
}
|
||||||
|
if (includeMethods.indexOf('forOwn') == -1) {
|
||||||
|
source = source.replace(/ *lodash\.forOwn *=.+\n/, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add methods required by Backbone or Underscore
|
||||||
|
[
|
||||||
|
{ 'flag': isBackbone, 'methodNames': backboneDependencies },
|
||||||
|
{ 'flag': isUnderscore, 'methodNames': underscoreMethods }
|
||||||
|
]
|
||||||
|
.some(function(data) {
|
||||||
|
var flag = data.flag,
|
||||||
|
methodNames = data.methodNames;
|
||||||
|
|
||||||
|
if (!flag) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// add any additional sub-dependencies
|
// add any additional sub-dependencies
|
||||||
backboneDependencies = getDependencies(backboneDependencies);
|
methodNames = getDependencies(methodNames);
|
||||||
|
|
||||||
if (filterType == 'exclude') {
|
if (filterType == 'exclude') {
|
||||||
// remove excluded methods from `backboneDependencies`
|
// remove excluded methods from `methodNames`
|
||||||
includeMethods = lodash.without.apply(lodash, [backboneDependencies].concat(excludeMethods));
|
includeMethods = lodash.without.apply(lodash, [methodNames].concat(excludeMethods));
|
||||||
}
|
}
|
||||||
else if (filterType) {
|
else if (filterType) {
|
||||||
// merge backbone dependencies into `includeMethods`
|
// merge `methodNames` into `includeMethods`
|
||||||
includeMethods = lodash.union(includeMethods, backboneDependencies);
|
includeMethods = lodash.union(includeMethods, methodNames);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// include only the Backbone dependencies
|
// include only the `methodNames`
|
||||||
includeMethods = backboneDependencies;
|
includeMethods = methodNames;
|
||||||
}
|
}
|
||||||
filterType = 'include';
|
filterType = 'include';
|
||||||
}
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -717,14 +857,13 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// simplify template snippets
|
// simplify template snippets by removing unnecessary brackets
|
||||||
source = source.replace(
|
source = source.replace(
|
||||||
RegExp(
|
RegExp("{(\\\\n' *\\+\\s*.*?\\+\\n\\s*' *)}(?:\\\\n)?' *([,\\n])", 'g'), "$1'$2"
|
||||||
"'else if \\(thisArg\\) \\{\\\\n' \\+\\s*" +
|
);
|
||||||
"' callback = iteratorBind\\(callback, thisArg\\)\\\\n' \\+\\s*" +
|
|
||||||
"'}'"
|
source = source.replace(
|
||||||
, 'g'),
|
RegExp("{(\\\\n' *\\+\\s*.*?\\+\\n\\s*' *)}(?:\\\\n)?' *\\+", 'g'), "$1;\\n'+"
|
||||||
"'else if (thisArg) callback = iteratorBind(callback, thisArg)'"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -739,32 +878,20 @@
|
|||||||
if (!iteratorName) {
|
if (!iteratorName) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var snippet,
|
var funcNames = [],
|
||||||
funcNames = [],
|
objectSnippets = [];
|
||||||
objectSnippets = [],
|
|
||||||
token = '__isTypeToken__';
|
|
||||||
|
|
||||||
// build replacement code
|
// build replacement code
|
||||||
lodash.forOwn({
|
lodash.forOwn({
|
||||||
'Arguments': "'[object Arguments]'",
|
|
||||||
'Date': 'dateClass',
|
'Date': 'dateClass',
|
||||||
'Function': 'funcClass',
|
|
||||||
'Number': 'numberClass',
|
'Number': 'numberClass',
|
||||||
'RegExp': 'regexpClass',
|
'RegExp': 'regexpClass',
|
||||||
'String': 'stringClass'
|
'String': 'stringClass'
|
||||||
}, function(value, key) {
|
}, function(value, key) {
|
||||||
// skip `isArguments` if a legacy build
|
|
||||||
if (isLegacy && key == 'Arguments') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var funcName = 'is' + key,
|
var funcName = 'is' + key,
|
||||||
funcCode = matchFunction(source, funcName);
|
funcCode = matchFunction(source, funcName);
|
||||||
|
|
||||||
if (funcCode) {
|
if (funcCode) {
|
||||||
if (!snippet) {
|
|
||||||
// use snippet to mark the insert position
|
|
||||||
snippet = funcCode;
|
|
||||||
}
|
|
||||||
funcNames.push(funcName);
|
funcNames.push(funcName);
|
||||||
objectSnippets.push("'" + key + "': " + value);
|
objectSnippets.push("'" + key + "': " + value);
|
||||||
}
|
}
|
||||||
@@ -774,30 +901,22 @@
|
|||||||
if (funcNames.length < 2) {
|
if (funcNames.length < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// add a token to mark the position to insert new code
|
|
||||||
source = source.replace(snippet, '\n' + token + '\n' + snippet);
|
|
||||||
|
|
||||||
// remove existing isType functions
|
// remove existing isType functions
|
||||||
funcNames.forEach(function(funcName) {
|
funcNames.forEach(function(funcName) {
|
||||||
source = removeFunction(source, funcName);
|
source = removeFunction(source, funcName);
|
||||||
});
|
});
|
||||||
|
|
||||||
// replace token with new DRY code
|
// insert new DRY code after the method assignments
|
||||||
source = source.replace(token,
|
var snippet = getMethodAssignments(source);
|
||||||
|
source = source.replace(snippet, snippet + '\n' +
|
||||||
' // add `_.' + funcNames.join('`, `_.') + '`\n' +
|
' // add `_.' + funcNames.join('`, `_.') + '`\n' +
|
||||||
' ' + iteratorName + '({\n ' + objectSnippets.join(',\n ') + '\n }, function(className, key) {\n' +
|
' ' + iteratorName + '({\n ' + objectSnippets.join(',\n ') + '\n }, function(className, key) {\n' +
|
||||||
" lodash['is' + key] = function(value) {\n" +
|
" lodash['is' + key] = function(value) {\n" +
|
||||||
' return toString.call(value) == className;\n' +
|
' return toString.call(value) == className;\n' +
|
||||||
' };\n' +
|
' };\n' +
|
||||||
' });'
|
' });\n'
|
||||||
);
|
);
|
||||||
|
|
||||||
// tweak `isArguments` fallback
|
|
||||||
snippet = !isLegacy && getIsArgumentsFallback(source);
|
|
||||||
if (snippet) {
|
|
||||||
var modified = '\n' + snippet.replace(/isArguments/g, 'lodash.$&');
|
|
||||||
source = source.replace(snippet, modified);
|
|
||||||
}
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
@@ -812,11 +931,11 @@
|
|||||||
modified = snippet;
|
modified = snippet;
|
||||||
|
|
||||||
// remove native `Function#bind` branch in `_.bind`
|
// remove native `Function#bind` branch in `_.bind`
|
||||||
if (funcName == 'bind' ) {
|
if (funcName == 'bind') {
|
||||||
modified = modified.replace(/(?:\s*\/\/.*)*\s*else if *\(isBindFast[^}]+}/, '');
|
modified = modified.replace(/(?:\s*\/\/.*)*\s*else if *\(isBindFast[^}]+}/, '');
|
||||||
}
|
}
|
||||||
// remove native `Array.isArray` branch in `_.isArray`
|
// remove native `Array.isArray` branch in `_.isArray`
|
||||||
else if (funcName == 'isArray') {
|
else {
|
||||||
modified = modified.replace(/nativeIsArray * \|\|/, '');
|
modified = modified.replace(/nativeIsArray * \|\|/, '');
|
||||||
}
|
}
|
||||||
source = source.replace(snippet, modified);
|
source = source.replace(snippet, modified);
|
||||||
@@ -834,8 +953,8 @@
|
|||||||
// replace `_.isArguments` with fallback
|
// replace `_.isArguments` with fallback
|
||||||
if (!isRemoved(source, 'isArguments')) {
|
if (!isRemoved(source, 'isArguments')) {
|
||||||
source = source.replace(
|
source = source.replace(
|
||||||
matchFunction(source, 'isArguments').replace(/[\s\S]+?var isArguments *=/, ''),
|
matchFunction(source, 'isArguments').replace(/[\s\S]+?function isArguments/, ''),
|
||||||
getIsArgumentsFallback(source).match(/isArguments *=([\s\S]+?) *};/)[1] + ' };\n'
|
getIsArgumentsFallback(source).match(/isArguments *= *function([\s\S]+?) *};/)[1] + ' }\n'
|
||||||
);
|
);
|
||||||
|
|
||||||
source = removeIsArgumentsFallback(source);
|
source = removeIsArgumentsFallback(source);
|
||||||
@@ -860,25 +979,37 @@
|
|||||||
source = source.replace(reFunc, '$1' + getFunctionSource(lodash[funcName]) + ';\n');
|
source = source.replace(reFunc, '$1' + getFunctionSource(lodash[funcName]) + ';\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// replace `callee` in `_.merge` with `merge`
|
||||||
|
source = source.replace(matchFunction(source, 'merge'), function(match) {
|
||||||
|
return match.replace(/\bcallee\b/g, 'merge');
|
||||||
|
});
|
||||||
|
|
||||||
|
// remove `hasDontEnumBug`, `hasObjectSpliceBug`, `iteratesOwnLast`, `noArgsEnum` assignment
|
||||||
|
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasDontEnumBug\b[\s\S]+?}\(1\)\);\n/, '');
|
||||||
|
|
||||||
|
// remove `iteratesOwnLast` from `isPlainObject`
|
||||||
|
source = source.replace(/(?:\s*\/\/.*)*\n( +)if *\(iteratesOwnLast[\s\S]+?\n\1}/, '');
|
||||||
|
|
||||||
// remove JScript [[DontEnum]] fix from `_.isEqual`
|
// remove JScript [[DontEnum]] fix from `_.isEqual`
|
||||||
source = source.replace(/(?:\s*\/\/.*)*\n( +)if *\(result *&& *hasDontEnumBug[\s\S]+?\n\1}/, '');
|
source = source.replace(/(?:\s*\/\/.*)*\n( +)if *\(hasDontEnumBug[\s\S]+?\n\1}/, '');
|
||||||
|
|
||||||
// remove IE `shift` and `splice` fix from mutator Array functions mixin
|
// remove `hasObjectSpliceBug` fix from the mutator Array functions mixin
|
||||||
source = source.replace(/(?:\s*\/\/.*)*\n( +)if *\(value.length *=== *0[\s\S]+?\n\1}/, '');
|
source = source.replace(/(?:\s*\/\/.*)*\n( +)if *\(hasObjectSpliceBug[\s\S]+?\n\1}/, '');
|
||||||
|
|
||||||
// remove `noCharByIndex` from `_.reduceRight`
|
|
||||||
source = source.replace(/noCharByIndex *&&[^:]+: *([^;]+)/g, '$1');
|
|
||||||
|
|
||||||
// remove `noArraySliceOnStrings` from `_.toArray`
|
// remove `noArraySliceOnStrings` from `_.toArray`
|
||||||
source = source.replace(/noArraySliceOnStrings *\?[^:]+: *([^)]+)/g, '$1');
|
source = source.replace(/noArraySliceOnStrings *\?[^:]+: *([^)]+)/g, '$1');
|
||||||
|
|
||||||
|
// remove `noCharByIndex` from `_.reduceRight`
|
||||||
|
source = source.replace(/noCharByIndex *&&[^:]+: *([^;]+)/g, '$1');
|
||||||
|
|
||||||
source = removeVar(source, 'extendIteratorOptions');
|
source = removeVar(source, 'extendIteratorOptions');
|
||||||
source = removeVar(source, 'hasDontEnumBug');
|
|
||||||
source = removeVar(source, 'iteratorTemplate');
|
source = removeVar(source, 'iteratorTemplate');
|
||||||
source = removeVar(source, 'noArraySliceOnStrings');
|
source = removeVar(source, 'noArraySliceOnStrings');
|
||||||
source = removeVar(source, 'noCharByIndex');
|
source = removeVar(source, 'noCharByIndex');
|
||||||
source = removeIsArgumentsFallback(source);
|
source = removeIsArgumentsFallback(source);
|
||||||
source = removeKeysOptimization(source);
|
source = removeKeysOptimization(source);
|
||||||
|
source = removeNoArgsClass(source);
|
||||||
|
source = removeNoNodeClass(source);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// inline `iteratorTemplate` template
|
// inline `iteratorTemplate` template
|
||||||
@@ -918,16 +1049,12 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// remove associated functions, variables, and code snippets that the minifier may miss
|
// modify/remove references to removed methods/variables
|
||||||
if (isRemoved(source, 'bind')) {
|
if (isRemoved(source, 'isArguments')) {
|
||||||
source = removeVar(source, 'nativeBind');
|
source = replaceVar(source, 'noArgsClass', 'false');
|
||||||
source = removeVar(source, 'isBindFast');
|
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'isArray')) {
|
if (isRemoved(source, 'isFunction')) {
|
||||||
source = removeVar(source, 'nativeIsArray');
|
source = removeIsFunctionFallback(source);
|
||||||
}
|
|
||||||
if (isRemoved(source, 'keys')) {
|
|
||||||
source = removeFunction(source, 'shimKeys');
|
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'mixin')) {
|
if (isRemoved(source, 'mixin')) {
|
||||||
// remove `LoDash` constructor
|
// remove `LoDash` constructor
|
||||||
@@ -936,9 +1063,20 @@
|
|||||||
source = source.replace(/(?:new +LoDash(?!\()|(?:new +)?LoDash\([^)]*\));?/g, '');
|
source = source.replace(/(?:new +LoDash(?!\()|(?:new +)?LoDash\([^)]*\));?/g, '');
|
||||||
// remove `LoDash.prototype` additions
|
// remove `LoDash.prototype` additions
|
||||||
source = source.replace(/(?:\s*\/\/.*)*\s*LoDash.prototype *=[\s\S]+?\/\*-+\*\//, '');
|
source = source.replace(/(?:\s*\/\/.*)*\s*LoDash.prototype *=[\s\S]+?\/\*-+\*\//, '');
|
||||||
|
// remove `hasObjectSpliceBug` assignment
|
||||||
|
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasObjectSpliceBug;|.+?hasObjectSpliceBug *=.+/g, '');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'sortBy')) {
|
|
||||||
source = removeFunction(source, 'compareAscending');
|
// assign debug source before further modifications that rely on the minifier
|
||||||
|
// to remove unused variables and other dead code
|
||||||
|
debugSource = source;
|
||||||
|
|
||||||
|
// remove associated functions, variables, and code snippets that the minifier may miss
|
||||||
|
if (isRemoved(source, 'isArray')) {
|
||||||
|
source = removeVar(source, 'nativeIsArray');
|
||||||
|
}
|
||||||
|
if (isRemoved(source, 'keys')) {
|
||||||
|
source = removeFunction(source, 'shimKeys');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'template')) {
|
if (isRemoved(source, 'template')) {
|
||||||
// remove `templateSettings` assignment
|
// remove `templateSettings` assignment
|
||||||
@@ -947,32 +1085,39 @@
|
|||||||
if (isRemoved(source, 'toArray')) {
|
if (isRemoved(source, 'toArray')) {
|
||||||
source = removeVar(source, 'noArraySliceOnStrings');
|
source = removeVar(source, 'noArraySliceOnStrings');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'isArray', 'isEmpty', 'isEqual')) {
|
if (isRemoved(source, 'clone', 'merge')) {
|
||||||
source = removeVar(source, 'arrayClass');
|
source = removeFunction(source, 'isPlainObject');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'bind', 'bindAll', 'functions', 'isEqual', 'isFunction', 'result', 'toArray')) {
|
if (isRemoved(source, 'clone', 'isArguments', 'isEmpty', 'isEqual', 'size')) {
|
||||||
source = removeVar(source, 'funcClass');
|
source = removeNoArgsClass(source);
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'bind', 'clone', 'isObject', 'keys')) {
|
if (isRemoved(source, 'isEqual', 'isPlainObject')) {
|
||||||
source = removeVar(source, 'objectTypes');
|
source = removeNoNodeClass(source);
|
||||||
}
|
}
|
||||||
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, '');
|
||||||
|
}
|
||||||
|
if (isRemoved(source, 'createIterator', 'bind')) {
|
||||||
|
source = removeVar(source, 'isBindFast');
|
||||||
|
source = removeVar(source, 'isStrictFast');
|
||||||
|
source = removeVar(source, 'nativeBind');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'keys')) {
|
if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'keys')) {
|
||||||
source = removeVar(source, 'reNative');
|
source = removeVar(source, 'reNative');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'createIterator', 'extend', 'isEqual')) {
|
if (isRemoved(source, 'createIterator', 'clone', 'merge')) {
|
||||||
source = removeVar(source, 'hasDontEnumBug');
|
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, '');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'createIterator', 'contains', 'isEmpty', 'isEqual', 'isString')) {
|
if (isRemoved(source, 'createIterator', 'isEqual')) {
|
||||||
source = removeVar(source, 'stringClass');
|
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasDontEnumBug;|.+?hasDontEnumBug *=.+/g, '');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'createIterator', 'keys')) {
|
if (isRemoved(source, 'createIterator', 'keys')) {
|
||||||
source = removeVar(source, 'nativeKeys');
|
source = removeVar(source, 'nativeKeys');
|
||||||
}
|
}
|
||||||
if (isRemoved(source, 'createIterator', 'reduceRight')) {
|
if (!source.match(/var (?:hasDontEnumBug|hasObjectSpliceBug|iteratesOwnLast|noArgsEnum)\b/g)) {
|
||||||
source = removeVar(source, 'noCharByIndex');
|
// remove `hasDontEnumBug`, `hasObjectSpliceBug`, `iteratesOwnLast`, and `noArgsEnum` assignment
|
||||||
|
source = source.replace(/ *\(function\(\) *{[\s\S]+?}\(1\)\);/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove pseudo private properties
|
// remove pseudo private properties
|
||||||
@@ -987,20 +1132,16 @@
|
|||||||
source = source.replace(/^ *;\n/gm, '');
|
source = source.replace(/^ *;\n/gm, '');
|
||||||
|
|
||||||
// begin the minification process
|
// begin the minification process
|
||||||
if (filterType || isBackbone || isLegacy || isMobile || isStrict) {
|
if (filterType || isBackbone || isLegacy || isMobile || isStrict || isUnderscore) {
|
||||||
fs.writeFileSync(path.join(cwd, 'lodash.custom.js'), source);
|
writeFile(debugSource, 'lodash.custom.js');
|
||||||
|
|
||||||
minify(source, 'lodash.custom.min', function(result) {
|
minify(source, 'lodash.custom.min', function(result) {
|
||||||
// re-remove "use strict" added by the minifier
|
writeFile(result, 'lodash.custom.min.js');
|
||||||
if (!useStrict) {
|
|
||||||
result = removeUseStrictDirective(result);
|
|
||||||
}
|
|
||||||
fs.writeFileSync(path.join(cwd, 'lodash.custom.min.js'), result);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
minify(source, 'lodash.min', function(result) {
|
minify(source, 'lodash.min', function(result) {
|
||||||
fs.writeFileSync(path.join(cwd, 'lodash.min.js'), result);
|
writeFile(result, 'lodash.min.js');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
source = source.replace(/(\w)\["([^."]+)"\]/g, '$1.$2');
|
source = source.replace(/(\w)\["([^."]+)"\]/g, '$1.$2');
|
||||||
|
|
||||||
// correct AMD module definition for AMD build optimizers
|
// correct AMD module definition for AMD build optimizers
|
||||||
source = source.replace(/("function")==(typeof define)&&\(?("object")==(typeof define\.amd)(&&define\.amd)\)?/, '$2==$1&&$4==$3$5');
|
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');
|
||||||
|
|
||||||
// add license
|
// add license
|
||||||
source = license + '\n;' + source;
|
source = license + '\n;' + source;
|
||||||
|
|||||||
@@ -7,43 +7,69 @@
|
|||||||
|
|
||||||
/** Used to minify variables embedded in compiled strings */
|
/** Used to minify variables embedded in compiled strings */
|
||||||
var compiledVars = [
|
var compiledVars = [
|
||||||
'accumulator',
|
'argsIndex',
|
||||||
'args',
|
'argsLength',
|
||||||
'arrayClass',
|
|
||||||
'bind',
|
|
||||||
'callback',
|
'callback',
|
||||||
'className',
|
|
||||||
'collection',
|
'collection',
|
||||||
'compareAscending',
|
'concat',
|
||||||
'ctor',
|
'ctor',
|
||||||
'funcClass',
|
|
||||||
'funcs',
|
|
||||||
'hasOwnProperty',
|
'hasOwnProperty',
|
||||||
'identity',
|
'identity',
|
||||||
'index',
|
'index',
|
||||||
'isFunc',
|
|
||||||
'iteratee',
|
'iteratee',
|
||||||
'iterateeIndex',
|
|
||||||
'iteratorBind',
|
'iteratorBind',
|
||||||
'length',
|
'length',
|
||||||
'methodName',
|
|
||||||
'nativeKeys',
|
'nativeKeys',
|
||||||
'noaccum',
|
|
||||||
'object',
|
'object',
|
||||||
'objectTypes',
|
'ownIndex',
|
||||||
|
'ownProps',
|
||||||
'prop',
|
'prop',
|
||||||
|
'propertyIsEnumerable',
|
||||||
'propIndex',
|
'propIndex',
|
||||||
'props',
|
'props',
|
||||||
'property',
|
|
||||||
'propertyIsEnumerable',
|
|
||||||
'result',
|
'result',
|
||||||
'skipProto',
|
'skipProto',
|
||||||
'slice',
|
'slice',
|
||||||
'stringClass',
|
'stringClass',
|
||||||
'target',
|
|
||||||
'thisArg',
|
'thisArg',
|
||||||
'toString',
|
'toString',
|
||||||
'value'
|
'value',
|
||||||
|
|
||||||
|
// lesser used variables
|
||||||
|
'accumulator',
|
||||||
|
'args',
|
||||||
|
'arrayLikeClasses',
|
||||||
|
'ArrayProto',
|
||||||
|
'bind',
|
||||||
|
'callee',
|
||||||
|
'className',
|
||||||
|
'compareAscending',
|
||||||
|
'destValue',
|
||||||
|
'forIn',
|
||||||
|
'found',
|
||||||
|
'funcs',
|
||||||
|
'indexOf',
|
||||||
|
'indicator',
|
||||||
|
'isArguments',
|
||||||
|
'isArr',
|
||||||
|
'isArray',
|
||||||
|
'isFunc',
|
||||||
|
'isFunction',
|
||||||
|
'isPlainObject',
|
||||||
|
'methodName',
|
||||||
|
'noaccum',
|
||||||
|
'objectClass',
|
||||||
|
'objectTypes',
|
||||||
|
'pass',
|
||||||
|
'properties',
|
||||||
|
'property',
|
||||||
|
'propsLength',
|
||||||
|
'recursive',
|
||||||
|
'source',
|
||||||
|
'stack',
|
||||||
|
'stackLength',
|
||||||
|
'target',
|
||||||
|
'valueProp'
|
||||||
];
|
];
|
||||||
|
|
||||||
/** Used to minify `compileIterator` option properties */
|
/** Used to minify `compileIterator` option properties */
|
||||||
@@ -61,6 +87,7 @@
|
|||||||
'isKeysFast',
|
'isKeysFast',
|
||||||
'object',
|
'object',
|
||||||
'objectBranch',
|
'objectBranch',
|
||||||
|
'noArgsEnum',
|
||||||
'noCharByIndex',
|
'noCharByIndex',
|
||||||
'shadowed',
|
'shadowed',
|
||||||
'top',
|
'top',
|
||||||
@@ -70,6 +97,9 @@
|
|||||||
|
|
||||||
/** Used to minify variables and string values to a single character */
|
/** Used to minify variables and string values to a single character */
|
||||||
var minNames = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
|
var minNames = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
|
||||||
|
minNames.push.apply(minNames, minNames.map(function(value) {
|
||||||
|
return value + value;
|
||||||
|
}));
|
||||||
|
|
||||||
/** Used to protect the specified properties from getting minified */
|
/** Used to protect the specified properties from getting minified */
|
||||||
var propWhitelist = [
|
var propWhitelist = [
|
||||||
@@ -90,6 +120,7 @@
|
|||||||
'compact',
|
'compact',
|
||||||
'compose',
|
'compose',
|
||||||
'contains',
|
'contains',
|
||||||
|
'countBy',
|
||||||
'criteria',
|
'criteria',
|
||||||
'debounce',
|
'debounce',
|
||||||
'defaults',
|
'defaults',
|
||||||
@@ -97,10 +128,10 @@
|
|||||||
'delay',
|
'delay',
|
||||||
'detect',
|
'detect',
|
||||||
'difference',
|
'difference',
|
||||||
|
'drop',
|
||||||
'each',
|
'each',
|
||||||
'environment',
|
'environment',
|
||||||
'escape',
|
'escape',
|
||||||
'escape',
|
|
||||||
'evaluate',
|
'evaluate',
|
||||||
'every',
|
'every',
|
||||||
'extend',
|
'extend',
|
||||||
@@ -119,6 +150,7 @@
|
|||||||
'head',
|
'head',
|
||||||
'identity',
|
'identity',
|
||||||
'include',
|
'include',
|
||||||
|
'index',
|
||||||
'indexOf',
|
'indexOf',
|
||||||
'initial',
|
'initial',
|
||||||
'inject',
|
'inject',
|
||||||
@@ -149,10 +181,12 @@
|
|||||||
'map',
|
'map',
|
||||||
'max',
|
'max',
|
||||||
'memoize',
|
'memoize',
|
||||||
|
'merge',
|
||||||
'methods',
|
'methods',
|
||||||
'min',
|
'min',
|
||||||
'mixin',
|
'mixin',
|
||||||
'noConflict',
|
'noConflict',
|
||||||
|
'omit',
|
||||||
'once',
|
'once',
|
||||||
'opera',
|
'opera',
|
||||||
'partial',
|
'partial',
|
||||||
@@ -180,6 +214,7 @@
|
|||||||
'throttle',
|
'throttle',
|
||||||
'times',
|
'times',
|
||||||
'toArray',
|
'toArray',
|
||||||
|
'unescape',
|
||||||
'union',
|
'union',
|
||||||
'uniq',
|
'uniq',
|
||||||
'unique',
|
'unique',
|
||||||
@@ -188,6 +223,7 @@
|
|||||||
'values',
|
'values',
|
||||||
'variable',
|
'variable',
|
||||||
'VERSION',
|
'VERSION',
|
||||||
|
'where',
|
||||||
'without',
|
'without',
|
||||||
'wrap',
|
'wrap',
|
||||||
'zip',
|
'zip',
|
||||||
@@ -209,15 +245,28 @@
|
|||||||
// remove unrecognized JSDoc tags so Closure Compiler won't complain
|
// remove unrecognized JSDoc tags so Closure Compiler won't complain
|
||||||
source = source.replace(/@(?:alias|category)\b.*/g, '');
|
source = source.replace(/@(?:alias|category)\b.*/g, '');
|
||||||
|
|
||||||
|
// manually convert `arrayLikeClasses` property assignments because
|
||||||
|
// Closure Compiler errors trying to minify them
|
||||||
|
source = source.replace(/(arrayLikeClasses =)[\s\S]+?= *true/,
|
||||||
|
"$1{'[object Arguments]': true, '[object Array]': true, '[object Boolean]': false, " +
|
||||||
|
"'[object Date]': false, '[object Function]': false, '[object Number]': false, " +
|
||||||
|
"'[object Object]': false, '[object RegExp]': false, '[object String]': true }"
|
||||||
|
);
|
||||||
|
|
||||||
|
// manually convert `cloneableClasses` property assignments because
|
||||||
|
// Closure Compiler errors trying to minify them
|
||||||
|
source = source.replace(/(cloneableClasses =)[\s\S]+?= *true/,
|
||||||
|
"$1{'[object Arguments]': false, '[object Array]': true, '[object Boolean]': true, " +
|
||||||
|
"'[object Date]': true, '[object Function]': false, '[object Number]': true, " +
|
||||||
|
"'[object Object]': true, '[object RegExp]': true, '[object String]': true }"
|
||||||
|
);
|
||||||
|
|
||||||
// add brackets to whitelisted properties so Closure Compiler won't mung them
|
// add brackets to whitelisted properties so Closure Compiler won't mung them
|
||||||
// http://code.google.com/closure/compiler/docs/api-tutorial3.html#export
|
// http://code.google.com/closure/compiler/docs/api-tutorial3.html#export
|
||||||
source = source.replace(RegExp('\\.(' + propWhitelist.join('|') + ')\\b', 'g'), "['$1']");
|
source = source.replace(RegExp('\\.(' + propWhitelist.join('|') + ')\\b', 'g'), "['$1']");
|
||||||
|
|
||||||
// remove brackets from `_.escape()` in `tokenizeEscape`
|
|
||||||
source = source.replace(/_\['escape']\("/, '_.escape("');
|
|
||||||
|
|
||||||
// remove brackets from `_.escape()` in `_.template`
|
// remove brackets from `_.escape()` in `_.template`
|
||||||
source = source.replace(/__e *= *_\['escape']/, '__e=_.escape');
|
source = source.replace(/__e *= *_\['escape']/g, '__e=_.escape');
|
||||||
|
|
||||||
// remove brackets from `collection.indexOf` in `_.contains`
|
// remove brackets from `collection.indexOf` in `_.contains`
|
||||||
source = source.replace("collection['indexOf'](target)", 'collection.indexOf(target)');
|
source = source.replace("collection['indexOf'](target)", 'collection.indexOf(target)');
|
||||||
@@ -228,12 +277,12 @@
|
|||||||
// remove whitespace from string literals
|
// remove whitespace from string literals
|
||||||
source = source.replace(/'(?:(?=(\\?))\1.)*?'/g, function(string) {
|
source = source.replace(/'(?:(?=(\\?))\1.)*?'/g, function(string) {
|
||||||
// avoids removing the '\n' of the `stringEscapes` object
|
// avoids removing the '\n' of the `stringEscapes` object
|
||||||
return string.replace(/\[object |else if|function | in |return\s+[\w']|throw |typeof |use strict|var |@ |'\\n'|\\\\n|\\n|\s+/g, function(match) {
|
return string.replace(/\[object |delete |else if|function | in |return\s+[\w']|throw |typeof |use strict|var |@ |'\\n'|\\\\n|\\n|\s+/g, function(match) {
|
||||||
return match == false || match == '\\n' ? '' : match;
|
return match == false || match == '\\n' ? '' : match;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove whitespace from `_.template` related regexpes
|
// remove whitespace from `_.template` related regexes
|
||||||
source = source.replace(/(?:reDelimiterCode\w+|reEmptyString\w+|reInsertVariable) *=.+/g, function(match) {
|
source = source.replace(/(?:reDelimiterCode\w+|reEmptyString\w+|reInsertVariable) *=.+/g, function(match) {
|
||||||
return match.replace(/ |\\n/g, '');
|
return match.replace(/ |\\n/g, '');
|
||||||
});
|
});
|
||||||
@@ -247,35 +296,59 @@
|
|||||||
.replace("') {\\n'", "'){'")
|
.replace("') {\\n'", "'){'")
|
||||||
|
|
||||||
// remove `useSourceURL` variable
|
// remove `useSourceURL` variable
|
||||||
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *\{(?:\s*\/\/.*\n)* *var useSourceURL[\s\S]+?catch[^}]+}\n/, '');
|
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *\{(?:\s*\/\/.*)*\n *var useSourceURL[\s\S]+?catch[^}]+}\n/, '');
|
||||||
|
|
||||||
// remove debug sourceURL use in `_.template`
|
// remove debug sourceURL use in `_.template`
|
||||||
source = source.replace(/(?:\s*\/\/.*\n)* *if *\(useSourceURL[^}]+}/, '');
|
source = source.replace(/(?:\s*\/\/.*\n)* *if *\(useSourceURL[^}]+}/, '');
|
||||||
|
|
||||||
// minify internal properties used by `_.sortBy`
|
// minify internal properties used by 'compareAscending', `_.clone`, `_.merge`, and `_.sortBy`
|
||||||
(function() {
|
(function() {
|
||||||
var properties = ['criteria', 'value'],
|
var properties = ['criteria', 'index', 'source', 'value'],
|
||||||
snippets = source.match(/( +)(?:function compareAscending|var sortBy)\b[\s\S]+?\n\1}/g);
|
snippets = source.match(/( +)(?:function clone|function compareAscending|var merge|var sortBy)\b[\s\S]+?\n\1}/g);
|
||||||
|
|
||||||
if (!snippets) {
|
if (!snippets) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
snippets.forEach(function(snippet) {
|
snippets.forEach(function(snippet) {
|
||||||
var modified = snippet,
|
var modified = snippet,
|
||||||
isSortBy = /var sortBy\b/.test(modified),
|
isCompilable = /(?:var merge|var sortBy)\b/.test(modified),
|
||||||
isInlined = !/\bcreateIterator\b/.test(modified);
|
isInlined = !/\bcreateIterator\b/.test(modified);
|
||||||
|
|
||||||
// minify properties
|
// minify properties
|
||||||
properties.forEach(function(property, index) {
|
properties.forEach(function(property, index) {
|
||||||
// add quotes around properties in the inlined `_.sortBy` of the mobile
|
var reBracketProp = RegExp("\\['(" + property + ")'\\]", 'g'),
|
||||||
// build so Closure Compiler won't mung them
|
reDotProp = RegExp('\\.' + property + '\\b', 'g'),
|
||||||
if (isSortBy && isInlined) {
|
rePropColon = RegExp("(')?\\b" + property + "\\1 *:", 'g');
|
||||||
modified = modified
|
|
||||||
.replace(RegExp('\\.' + property + '\\b', 'g'), "['" + minNames[index] + "']")
|
if (isCompilable) {
|
||||||
.replace(RegExp('\\b' + property + ' *:', 'g'), "'" + minNames[index] + "':");
|
// add quotes around properties in the inlined `_.merge` and `_.sortBy`
|
||||||
|
// of the mobile build so Closure Compiler won't mung them
|
||||||
|
if (isInlined) {
|
||||||
|
modified = modified
|
||||||
|
.replace(reBracketProp, "['" + minNames[index] + "']")
|
||||||
|
.replace(reDotProp, "['" + minNames[index] + "']")
|
||||||
|
.replace(rePropColon, "'" + minNames[index] + "':");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modified = modified
|
||||||
|
.replace(reBracketProp, '.' + minNames[index])
|
||||||
|
.replace(reDotProp, '.' + minNames[index])
|
||||||
|
.replace(rePropColon, minNames[index] + ':');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modified = modified
|
||||||
|
.replace(reBracketProp, "['" + minNames[index] + "']")
|
||||||
|
.replace(reDotProp, '.' + minNames[index])
|
||||||
|
.replace(rePropColon, "'" + minNames[index] + "':")
|
||||||
|
|
||||||
|
// correct `value.source` in regexp branch of `_.clone`
|
||||||
|
if (property == 'source') {
|
||||||
|
modified = modified.replace("value['" + minNames[index] + "']", "value['source']");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
modified = modified.replace(RegExp('\\b' + property + '\\b', 'g'), minNames[index]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// replace with modified snippet
|
// replace with modified snippet
|
||||||
source = source.replace(snippet, modified);
|
source = source.replace(snippet, modified);
|
||||||
});
|
});
|
||||||
@@ -340,7 +413,7 @@
|
|||||||
else {
|
else {
|
||||||
// minify property name strings
|
// minify property name strings
|
||||||
modified = modified.replace(RegExp("'" + property + "'", 'g'), "'" + minNames[index] + "'");
|
modified = modified.replace(RegExp("'" + property + "'", 'g'), "'" + minNames[index] + "'");
|
||||||
// minify property names in regexps and accessors
|
// minify property names in regexes and accessors
|
||||||
if (isCreateIterator) {
|
if (isCreateIterator) {
|
||||||
modified = modified.replace(RegExp('([\\.|/])' + property + '\\b' , 'g'), '$1' + minNames[index]);
|
modified = modified.replace(RegExp('([\\.|/])' + property + '\\b' , 'g'), '$1' + minNames[index]);
|
||||||
}
|
}
|
||||||
|
|||||||
1006
doc/README.md
1006
doc/README.md
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@
|
|||||||
// generate Markdown
|
// generate Markdown
|
||||||
$markdown = docdown(array(
|
$markdown = docdown(array(
|
||||||
'path' => '../' . $file,
|
'path' => '../' . $file,
|
||||||
'title' => 'Lo-Dash <sup>v0.4.2</sup>',
|
'title' => 'Lo-Dash <sup>v0.6.0</sup>',
|
||||||
'url' => 'https://github.com/bestiejs/lodash/blob/master/lodash.js'
|
'url' => 'https://github.com/bestiejs/lodash/blob/master/lodash.js'
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
70
lodash.min.js
vendored
70
lodash.min.js
vendored
@@ -1,35 +1,41 @@
|
|||||||
/*!
|
/*!
|
||||||
Lo-Dash 0.4.2 lodash.com/license
|
Lo-Dash 0.6.0 lodash.com/license
|
||||||
Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE
|
Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
;(function(e,t){"use strict";function s(e){return new o(e)}function o(e){if(e&&e._wrapped)return e;this._wrapped=e}function u(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||30),s=i?{}:e;if(i)for(var o=t-1;++o<r;)n=e[o]+"",(Y.call(s,n)?s[n]:s[n]=[]).push(e[o]);return function(e){if(i){var n=e+"";return Y.call(s,n)&&-1<E(s[n],e)}return-1<E(s,e,t)}}function a(){for(var e,t,n,s=-1,o=arguments.length,u={e:"",f:"",j:"",p:"",c:{d:""},m:{d:""}};++s<o;)for(t in e=arguments[s],e)n=(n=e[t])==r?"":n,/d|i/.test(t)?
|
;(function(e,t){function s(e){return new o(e)}function o(e){if(e&&e._wrapped)return e;this._wrapped=e}function u(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||V),s=i?{}:e;if(i)for(var o=t-1;++o<r;)n=e[o]+"",(ft.call(s,n)?s[n]:s[n]=[]).push(e[o]);return function(e){if(i){var n=e+"";return ft.call(s,n)&&-1<k(s[n],e)}return-1<k(s,e,t)}}function a(){for(var e,t,n,s=-1,o=arguments.length,u={e:"",f:"",j:"",q:"",c:{d:""},m:{d:""}};++s<o;)for(t in e=arguments[s],e)n=(n=e[t])==r?"":n,/d|i/.test(t)?
|
||||||
("string"==typeof n&&(n={b:n,l:n}),u.c[t]=n.b,u.m[t]=n.l):u[t]=n;e=u.a,t=/^[^,]+/.exec(e)[0],u.g=t,u.h=mt,u.k=wt,u.o=J,u.q=u.q!==i,u.r=u.r!==i,"n"in u||(u.n=yt),u.f||(u.f="if(!"+t+")return D");if("g"!=t||!u.c.i)u.c=r;t="",u.r&&(t+="'use strict';"),t+="var n,p="+u.g+",D",u.j&&(t+="="+u.j),t+=";"+u.f+";"+u.p+";",u.c&&(t+="var s=p.length;n=-1;",u.m&&(t+="if(s===s>>>0){"),u.n&&(t+="if(J.call(p)==G){p=p.split('')}"),t+=u.c.d+";while(++n<s){"+u.c.i+"}",u.m&&(t+="}"));if(u.m){u.c&&(t+="else{"),u.h||(t+="var E=typeof p=='function'&&C.call(p,'prototype');"
|
("string"==typeof n&&(n={b:n,l:n}),u.c[t]=n.b||"",u.m[t]=n.l||""):u[t]=n;e=u.a,t=/^[^,]+/.exec(e)[0],n=u.s,u.g=t,u.h=Lt,u.k=Ft,u.n=Mt,u.p=st,u.r=u.r!==i,u.s=n==r?It:n,u.o==r&&(u.o=Pt),u.f||(u.f="if(!"+t+")return u");if("d"!=t||!u.c.i)u.c=r;t="",u.s&&(t+="'use strict';"),t+="var i,A,j="+u.g+",u",u.j&&(t+="="+u.j),t+=";"+u.f+";"+u.q+";",u.c&&(t+="var l=j.length;i=-1;",u.m&&(t+="if(l>-1&&l===l>>>0){"),u.o&&(t+="if(z.call(j)==x){j=j.split('')}"),t+=u.c.d+";while(++i<l){A=j[i];"+u.c.i+"}",u.m&&(t+="}"
|
||||||
),u.k&&u.q?t+="var A=u(p),z=-1,s=A.length;"+u.m.d+";while(++z<s){n=A[z];if(!(E&&n=='prototype')){"+u.m.i+"}}":(t+=u.m.d+";for(n in p){",u.h?(u.q&&(t+="if(l.call(p,n)){"),t+=u.m.i+";",u.q&&(t+="}")):(t+="if(!(E&&n=='prototype')",u.q&&(t+="&&l.call(p,n)"),t+="){"+u.m.i+"}"),t+="}");if(u.h){t+="var i=p.constructor;";for(n=0;7>n;n++)t+="n='"+u.o[n]+"';if(","constructor"==u.o[n]&&(t+="!(i&&i.prototype===p)&&"),t+="l.call(p,n)){"+u.m.i+"}"}u.c&&(t+="}")}return t+=u.e+";return D",Function("c,d,h,j,l,m,r,x,u,C,F,G,J"
|
));if(u.m){u.c?t+="else{":u.n&&(t+="var l=j.length;i=-1;if(l&&P(j)){while(++i<l){A=j[i+=''];"+u.m.i+"}}else{"),u.h||(t+="var v=typeof j=='function'&&r.call(j,'prototype');");if(u.k&&u.r)t+="var o=-1,p=Y[typeof j]?m(j):[],l=p.length;"+u.m.d+";while(++o<l){i=p[o];",u.h||(t+="if(!(v&&i=='prototype')){"),t+="A=j[i];"+u.m.i+"",u.h||(t+="}");else{t+=u.m.d+";for(i in j){";if(!u.h||u.r)t+="if(",u.h||(t+="!(v&&i=='prototype')"),!u.h&&u.r&&(t+="&&"),u.r&&(t+="g.call(j,i)"),t+="){";t+="A=j[i];"+u.m.i+";";if(!
|
||||||
,"return function("+e+"){"+t+"}")(ut,C,f,lt,Y,L,p,St,ot,et,tt,pt,nt)}function f(e,n){return e=e.a,n=n.a,e===t?1:n===t?-1:e<n?-1:e>n?1:0}function l(e,t){return Q[t]}function c(e){return"\\"+xt[e]}function h(e){return Et[e]}function p(e,t){return function(n,r,i){return e.call(t,n,r,i)}}function d(){}function v(e,t){if(I.test(t))return"<e%-"+t+"%>";var n=Q.length;return Q[n]="'+__e("+t+")+'",K+n}function m(e,t,n,r){return e=Q.length,t?Q[e]="';"+t+";__p+='":n?Q[e]="'+__e("+n+")+'":r&&(Q[e]="'+((__t=("+
|
u.h||u.r)t+="}"}t+="}";if(u.h){t+="var f=j.constructor;";for(n=0;7>n;n++)t+="i='"+u.p[n]+"';if(","constructor"==u.p[n]&&(t+="!(f&&f.prototype===j)&&"),t+="g.call(j,i)){A=j[i];"+u.m.i+"}"}if(u.c||u.n)t+="}"}return t+=u.e+";return u",Function("D,E,F,I,e,K,g,h,N,P,R,T,U,k,X,Y,m,r,w,x,z","var G=function("+e+"){"+t+"};return G")(qt,q,_,f,at,un,ft,D,k,w,tn,E,p,d,xt,Wt,gt,ct,ht,Nt,pt)}function f(e,n){var r=e.b,i=n.b,e=e.a,n=n.a;return e===t?1:n===t?-1:e<n?-1:e>n?1:r<i?-1:1}function l(e,t){return ut[t]}function c
|
||||||
r+"))==null?'':__t)+'"),K+e}function g(e,t){if(I.test(t))return"<e%="+t+"%>";var n=Q.length;return Q[n]="'+((__t=("+t+"))==null?'':__t)+'",K+n}function y(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=p(t,r));if(i===i>>>0){var o=yt&&nt.call(e)==pt?e.split(""):e;for(i&&s&&(n=o[--i]);i--;)n=t(n,o[i],i,e);return n}o=Zt(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function b(e,t,n){if(e)return t==r||n?e[0]:tt.call(e,0,t)}function w(e,t){var n=[];if(!e)
|
(e){return"\\"+Xt[e]}function h(e){return Ut[e]}function p(e,t){var n=i;if(!e||"object"!=typeof e||!t&&w(e))return n;var r=e.constructor;return(!Ht||"function"==typeof e.toString||"string"!=typeof (e+""))&&(!E(r)||r instanceof r)?Ot?(un(e,function(t,r){return n=!ft.call(e,r),i}),n===i):(un(e,function(e,t){n=t}),n===i||ft.call(e,n)):n}function d(e,t){return function(n,r,i){return e.call(t,n,r,i)}}function v(){}function m(e,t){if(e&&J.test(t))return"<e%-"+t+"%>";var n=ut.length;return ut[n]="'+__e("+
|
||||||
return n;for(var r,i=-1,s=e.length;++i<s;)r=e[i],Gt(r)?Z.apply(n,t?r:w(r)):n.push(r);return n}function E(e,t,n){if(!e)return-1;var r=-1,i=e.length;if(n){if("number"!=typeof n)return r=T(e,t),e[r]===t?r:-1;r=(0>n?Math.max(0,i+n):n)-1}for(;++r<i;)if(e[r]===t)return r;return-1}function S(e,t,n){var r=-Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]>i&&(i=e[s]);return i}for(n&&(t=p(t,n));++s<o;)n=t(e[s],s,e),n>r&&(r=n,i=e[s]);return i}function x(e,t,n){return e?tt.call(e,t==r||
|
t+")+'",ot+n}function g(e,t,n,i){return i?(e=ut.length,ut[e]="';"+i+";__p+='",ot+e):t?m(r,t):y(r,n)}function y(e,t){if(e&&J.test(t))return"<e%="+t+"%>";var n=ut.length;return ut[n]="'+((__t=("+t+"))==null?'':__t)+'",ot+n}function b(e){return zt[e]}function w(e){return pt.call(e)==yt}function E(e){return"function"==typeof e}function S(e,t,s,o,u){if(e==r)return e;s&&(t=i),u||(u={d:r}),u.d==r&&(u.d=!(!R.clone&&!z.clone&&!W.clone));if(((s=Wt[typeof e])||u.d)&&e.clone&&E(e.clone))return u.d=r,e.clone(
|
||||||
n?1:t):[]}function T(e,t,n,r){if(!e)return 0;var i=0,s=e.length;if(n){r&&(n=C(n,r));for(t=n(t);i<s;)r=i+s>>>1,n(e[r])<t?i=r+1:s=r}else for(;i<s;)r=i+s>>>1,e[r]<t?i=r+1:s=r;return i}function N(e,t,n,r){var s=[];if(!e)return s;var o=-1,u=e.length,a=[];"function"==typeof t&&(r=n,n=t,t=i);for(n?r&&(n=p(n,r)):n=L;++o<u;)if(r=n(e[o],o,e),t?!o||a[a.length-1]!==r:0>E(a,r))a.push(r),s.push(e[o]);return s}function C(e,t){function n(){var o=arguments,u=t;return i||(e=t[r]),s.length&&(o=o.length?G.apply(s,o)
|
t);if(s){var a=pt.call(e);if(!Rt[a]||_t&&w(e))return e;var f=a==bt,s=f||(a==xt?p(e,n):s)}if(!s||!t)return s?f?ht.call(e):on({},e):e;s=e.constructor;switch(a){case wt:return new s(e==n);case Et:return new s(+e);case St:case Nt:return new s(e);case Tt:return s(e.source,Z.exec(e))}o||(o=[]);for(a=o.length;a--;)if(o[a].c==e)return o[a].d;var a=e.length,l=f?s(a):{};o.push({d:l,c:e});if(f)for(f=-1;++f<a;)l[f]=S(e[f],t,r,o,u);else an(e,function(e,n){l[n]=S(e,t,r,o,u)});return l}function x(e,t,s,o){if(e==
|
||||||
:s),this instanceof n?(d.prototype=e.prototype,u=new d,(o=e.apply(u,o))&&St[typeof o]?o:u):e.apply(u,o)}var r,i=nt.call(e)==lt;if(i){if(bt||rt&&2<arguments.length)return rt.call.apply(rt,arguments)}else r=t,t=e;var s=tt.call(arguments,2);return n}function k(e,t,s){s||(s=[]);if(e===t)return 0!==e||1/e==1/t;if(e==r||t==r)return e===t;e._chain&&(e=e._wrapped),t._chain&&(t=t._wrapped);if(e.isEqual&&nt.call(e.isEqual)==lt)return e.isEqual(t);if(t.isEqual&&nt.call(t.isEqual)==lt)return t.isEqual(e);var o=
|
r||t==r)return e===t;o||(o={value:r}),o.value==r&&(o.value=!(!R.isEqual&&!z.isEqual&&!W.isEqual));if(Wt[typeof e]||Wt[typeof t]||o.value){e._chain&&(e=e._wrapped),t._chain&&(t=t._wrapped);if(e.isEqual&&E(e.isEqual))return o.value=r,e.isEqual(t);if(t.isEqual&&E(t.isEqual))return o.value=r,t.isEqual(e)}if(e===t)return 0!==e||1/e==1/t;var u=pt.call(e);if(u!=pt.call(t))return i;switch(u){case wt:case Et:return+e==+t;case St:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case Tt:case Nt:return e==t+""}var a=qt
|
||||||
nt.call(e);if(o!=nt.call(t))return i;switch(o){case pt:return e==""+t;case ct:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case at:case ft:return+e==+t;case ht:return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return i;for(var u=s.length;u--;)if(s[u]==e)return n;var u=-1,a=n,f=0;s.push(e);if(o==ut){if(f=e.length,a=f==t.length)for(;f--&&(a=k(e[f],t[f],s)););}else{if("constructor"in e!="constructor"in t||e.constructor!=
|
[u];if(_t&&!a&&(a=w(e))&&!w(t)||!a&&(u!=xt||Ht&&("function"!=typeof e.toString&&"string"==typeof (e+"")||"function"!=typeof t.toString&&"string"==typeof (t+""))))return i;s||(s=[]);for(u=s.length;u--;)if(s[u]==e)return n;var u=-1,f=n,l=0;s.push(e);if(a){l=e.length;if(f=l==t.length)for(;l--&&(f=x(e[l],t[l],s,o)););return f}a=e.constructor,f=t.constructor;if(a!=f&&(!E(a)||!(a instanceof a&&E(f)&&f instanceof f)))return i;for(var c in e)if(ft.call(e,c)&&(l++,!ft.call(t,c)||!x(e[c],t[c],s,o)))return i
|
||||||
t.constructor)return i;for(var l in e)if(Y.call(e,l)&&(f++,!(a=Y.call(t,l)&&k(e[l],t[l],s))))break;if(a){for(l in t)if(Y.call(t,l)&&!(f--))break;a=!f}if(a&&mt)for(;7>++u&&(l=J[u],!Y.call(e,l)||!!(a=Y.call(t,l)&&k(e[l],t[l],s))););}return s.pop(),a}function L(e){return e}function A(e){Bt(Qt(e),function(t){var r=s[t]=e[t];o.prototype[t]=function(){var e=[this._wrapped];return arguments.length&&Z.apply(e,arguments),e=r.apply(s,e),this._chain&&(e=new o(e),e._chain=n),e}})}var n=!0,r=null,i=!1,O,M,_,D
|
;for(c in t)if(ft.call(t,c)&&!(l--))return i;if(Lt)for(;7>++u;)if(c=st[u],ft.call(e,c)&&(!ft.call(t,c)||!x(e[c],t[c],s,o)))return i;return n}function T(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=d(t,r));if(-1<i&&i===i>>>0){var o=Pt&&pt.call(e)==Nt?e.split(""):e;for(i&&s&&(n=o[--i]);i--;)n=t(n,o[i],i,e);return n}o=cn(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function N(e,t,n){if(e)return t==r||n?e[0]:ht.call(e,0,t)}function C(e,t){var n=[];if(!
|
||||||
,P="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(e=global),exports),H=Array.prototype,B=Object.prototype,j=0,F=e._,I=/[-+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,q=/\b__p\+='';/g,R=/\b(__p\+=)''\+/g,U=/(__e\(.*?\)|\b__t\))\+'';/g,z=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,W=RegExp("^"+(B.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),X=/__token__(\d+)/g,V=/[&<"']/g,$=/['\n\r\t\u2028\u2029\\]/g
|
e)return n;for(var r,i=-1,s=e.length;++i<s;)r=e[i],tn(r)?lt.apply(n,t?r:C(r)):n.push(r);return n}function k(e,t,n){if(!e)return-1;var r=-1,i=e.length;if(n){if("number"!=typeof n)return r=O(e,t),e[r]===t?r:-1;r=(0>n?Math.max(0,i+n):n)-1}for(;++r<i;)if(e[r]===t)return r;return-1}function L(e,t,n){var r=-Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]>i&&(i=e[s]);return i}for(n&&(t=d(t,n));++s<o;)n=t(e[s],s,e),n>r&&(r=n,i=e[s]);return i}function A(e,t,n){return e?ht.call(e,t==
|
||||||
,J="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),K="__token__",Q=[],G=H.concat,Y=B.hasOwnProperty,Z=H.push,et=B.propertyIsEnumerable,tt=H.slice,nt=B.toString,rt=W.test(rt=tt.bind)&&rt,it=W.test(it=Array.isArray)&&it,st=e.isFinite,ot=W.test(ot=Object.keys)&&ot,ut="[object Array]",at="[object Boolean]",ft="[object Date]",lt="[object Function]",ct="[object Number]",ht="[object RegExp]",pt="[object String]",dt=e.clearTimeout,vt=e.setTimeout
|
r||n?1:t):[]}function O(e,t,n,r){if(!e)return 0;var i=0,s=e.length;if(n){r&&(n=_(n,r));for(t=n(t);i<s;)r=i+s>>>1,n(e[r])<t?i=r+1:s=r}else for(;i<s;)r=i+s>>>1,e[r]<t?i=r+1:s=r;return i}function M(e,t,n,r){var s=[];if(!e)return s;var o=-1,u=e.length,a=[];"function"==typeof t&&(r=n,n=t,t=i);for(n?r&&(n=d(n,r)):n=D;++o<u;)if(r=n(e[o],o,e),t?!o||a[a.length-1]!==r:0>k(a,r))a.push(r),s.push(e[o]);return s}function _(e,t){function n(){var o=arguments,u=t;return i||(e=t[r]),s.length&&(o=o.length?s.concat(
|
||||||
,mt=!et.call({valueOf:0},"valueOf"),gt="x"!=tt.call("x")[0],yt="xx"!="x"[0]+Object("x")[0],bt=rt&&/\n|Opera/.test(rt+nt.call(e.opera)),wt=ot&&/^.+$|true/.test(ot+!!e.attachEvent),Et={"&":"&","<":"<",'"':""","'":"'"},St={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},xt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:"obj"
|
ht.call(o)):s),this instanceof n?(v.prototype=e.prototype,u=new v,(o=e.apply(u,o))&&Wt[typeof o]?o:u):e.apply(u,o)}var r,i=E(e);if(i){if(jt||dt&&2<arguments.length)return dt.call.apply(dt,arguments)}else r=t,t=e;var s=ht.call(arguments,2);return n}function D(e){return e}function P(e){wn(fn(e),function(t){var r=s[t]=e[t];o.prototype[t]=function(){var e=[this._wrapped];return arguments.length&<.apply(e,arguments),e=r.apply(s,e),this._chain&&(e=new o(e),e._chain=n),e}})}var n=!0,r=null,i=!1,H,B,j,
|
||||||
};var Tt={a:"g,e,I",j:"g",p:"if(!e){e=m}else if(I)e=r(e,I)",i:"e(p[n],n,g)"},Nt={j:"true",i:"if(!e(p[n],n,g))return!D"},Ct={q:i,r:i,a:"w",j:"w",p:"for(var q=1,s=arguments.length;q<s;q++){p=arguments[q];"+(mt?"if(p){":""),i:"D[n]=p[n]",e:(mt?"}":"")+"}"},kt={j:"[]",i:"e(p[n],n,g)&&D.push(p[n])"},Lt={p:"if(I)e=r(e,I)"},At={i:{l:Tt.i}},Ot={j:"",f:"if(!g)return[]",d:{b:"D=Array(s)",l:"D="+(wt?"Array(s)":"[]")},i:{b:"D[n]=e(p[n],n,g)",l:"D"+(wt?"[z]=":".push")+"(e(p[n],n,g))"}},Mt=a({a:"w",f:"if(!(w&&x[typeof w]))throw TypeError()"
|
F,I="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(e=global),exports),q=Array.prototype,R=Boolean.prototype,U=Object.prototype,z=Number.prototype,W=String.prototype,X=0,V=30,$=e._,J=/[-+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,K=/&(?:amp|lt|gt|quot|#x27);/g,Q=/\b__p\+='';/g,G=/\b(__p\+=)''\+/g,Y=/(__e\(.*?\)|\b__t\))\+'';/g,Z=/\w*$/,et=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,tt=RegExp("^"+(U.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g
|
||||||
,j:"[]",i:"D.push(n)"}),_t=a({a:"g,H",j:"false",n:i,d:{b:"if(J.call(p)==G)return g.indexOf(H)>-1"},i:"if(p[n]===H)return true"}),Dt=a(Tt,Nt),Pt=a(Tt,kt),Ht=a(Tt,Lt,{j:"",i:"if(e(p[n],n,g))return p[n]"}),Bt=a(Tt,Lt),jt=a(Tt,{j:"{}",p:"var y,o=typeof e=='function';if(o&&I)e=r(e,I)",i:"y=o?e(p[n],n,g):p[n][e];(l.call(D,y)?D[y]:D[y]=[]).push(p[n])"}),Ft=a(Ot,{a:"g,t",p:"var b=F.call(arguments,2),o=typeof t=='function'",i:{b:"D[n]=(o?t:p[n][t]).apply(p[n],b)",l:"D"+(wt?"[z]=":".push")+"((o?t:p[n][t]).apply(p[n],b))"
|
,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),nt=/__token__(\d+)/g,rt=/[&<>"']/g,it=/['\n\r\t\u2028\u2029\\]/g,st="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),ot="__token__",ut=[],at=q.concat,ft=U.hasOwnProperty,lt=q.push,ct=U.propertyIsEnumerable,ht=q.slice,pt=U.toString,dt=tt.test(dt=ht.bind)&&dt,vt=tt.test(vt=Array.isArray)&&vt,mt=e.isFinite,gt=tt.test(gt=Object.keys)&>,yt="[object Arguments]",bt="[object Array]",wt="[object Boolean]"
|
||||||
}}),It=a(Tt,Ot),qt=a(Ot,{a:"g,B",i:{b:"D[n]=p[n][B]",l:"D"+(wt?"[z]=":".push")+"(p[n][B])"}}),Rt=a({a:"g,e,a,I",j:"a",p:"var v=arguments.length<3;if(I)e=r(e,I)",d:{b:"if(v)D=g[++n]"},i:{b:"D=e(D,p[n],n,g)",l:"D=v?(v=false,p[n]):e(D,p[n],n,g)"}}),Ut=a(Tt,kt,{i:"!"+kt.i}),zt=a(Tt,Nt,{j:"false",i:Nt.i.replace("!","")}),Wt=a(Tt,Ot,{p:"if(typeof e=='string'){var y=e;e=function(g){return g[y]}}else if(I)e=r(e,I)",i:{b:"D[n]={a:e(p[n],n,g),b:p[n]}",l:"D"+(wt?"[z]=":".push")+"({a:e(p[n],n,g),b:p[n]})"},e
|
,Et="[object Date]",St="[object Number]",xt="[object Object]",Tt="[object RegExp]",Nt="[object String]",Ct=e.clearTimeout,kt=e.setTimeout,Lt,At,Ot,Mt=n;(function(){function e(){this.x=1}var t={0:1,length:1},n=[];e.prototype={valueOf:1,y:1};for(var r in new e)n.push(r);for(r in arguments)Mt=!r;Lt=4>(n+"").length,Ot="x"!=n[0],At=(n.splice.call(t,0,1),t[0])})(1);var _t=!w(arguments),Dt="x"!=ht.call("x")[0],Pt="xx"!="x"[0]+Object("x")[0];try{var Ht=("[object Object]",pt.call(e.document||0)==xt)}catch(Bt)
|
||||||
:"D.sort(h);s=D.length;while(s--){D[s]=D[s].b}"}),Xt=a({q:i,r:i,a:"w",j:"w",p:"var k=arguments,s=k.length;if(s>1){for(var n=1;n<s;n++)D[k[n]]=d(D[k[n]],D);return D}",i:"if(J.call(D[n])==j)D[n]=d(D[n],D)"}),Vt=a(Ct,{i:"if(D[n]==null)"+Ct.i}),$t=a(Ct),Jt=a(Tt,Lt,At,{q:i}),Kt=a(Tt,Lt,At),Qt=a({q:i,a:"w",j:"[]",i:"if(J.call(p[n])==j)D.push(n)",e:"D.sort()"});Bt({Arguments:"[object Arguments]",Date:ft,Function:lt,Number:ct,RegExp:ht,String:pt},function(e,t){s["is"+t]=function(t){return nt.call(t)==e}}
|
{}var jt=dt&&/\n|Opera/.test(dt+pt.call(e.opera)),Ft=gt&&/^.+$|true/.test(gt+!!e.attachEvent),It=!jt,qt={"[object Arguments]":n,"[object Array]":n,"[object Boolean]":i,"[object Date]":i,"[object Function]":i,"[object Number]":i,"[object Object]":i,"[object RegExp]":i,"[object String]":n},Rt={"[object Arguments]":i,"[object Array]":n,"[object Boolean]":n,"[object Date]":n,"[object Function]":i,"[object Number]":n,"[object Object]":n,"[object RegExp]":n,"[object String]":n},Ut={"&":"&","<":"<"
|
||||||
),s.isArguments(arguments)||(s.isArguments=function(e){return!!e&&!!Y.call(e,"callee")});var Gt=it||function(e){return nt.call(e)==ut},Yt=a({a:"K",j:"true",p:"var f=J.call(K);if(f==c||f==G)return!K.length",i:{l:"return false"}}),Zt=ot?function(e){return"function"==typeof e&&et.call(e,"prototype")?Mt(e):ot(e)}:Mt,en=a({a:"w",j:"[]",i:"D.push(p[n])"});s.VERSION="0.4.2",s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},s.bind=C,s.bindAll=Xt,s.chain=function(e)
|
,">":">",'"':""","'":"'"},zt={"&":"&","<":"<",">":">",""":'"',"'":"'"},Wt={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i,unknown:n},Xt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Vt={a:"d,c,y",j:"d",q:"if(!c)c=h;else if(y)c=k(c,y)",i:"if(c(A,i,d)===false)return u"},$t={j:"{}",q:"var q;if(typeof c!='function'){var ii=c;c=function(A){return A[ii]}}else if(y)c=k(c,y)"
|
||||||
{return e=new o(e),e._chain=n,e},s.clone=function(e){return e&&St[typeof e]?Gt(e)?e.slice():$t({},e):e},s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++n<r;)e[n]&&t.push(e[n]);return t},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=_t,s.debounce=function(e,t,n){function i(){a=r,n||e.apply(u,s)}var s,o,u,a;return function(){var r=n&&!a;return s=arguments,u=this,dt(a),a=vt(i,t),r&&(o=
|
,i:"q=c(A,i,d);(g.call(u,q)?u[q]++:u[q]=1)"},Jt={r:i,a:"n,c,y",j:"{}",q:"var S=typeof c=='function';if(!S){var t=e.apply(E,arguments)}else if(y)c=k(c,y)",i:"if(S?!c(A,i,n):N(t,i)<0)u[i]=A"},Kt={j:"true",i:"if(!c(A,i,d))return!u"},Qt={r:i,s:i,a:"n",j:"n",q:"for(var a=1,b=arguments.length;a<b;a++){if(j=arguments[a]){",i:"u[i]=A",e:"}}"},Gt={j:"[]",i:"c(A,i,d)&&u.push(A)"},Yt={q:"if(y)c=k(c,y)"},Zt={i:{l:Vt.i}},en={j:"",f:"if(!d)return[]",d:{b:"u=Array(l)",l:"u="+(Ft?"Array(l)":"[]")},i:{b:"u[i]=c(A,i,d)"
|
||||||
e.apply(u,s)),o}},s.defaults=Vt,s.defer=function(e){var n=tt.call(arguments,1);return vt(function(){return e.apply(t,n)},1)},s.delay=function(e,n){var r=tt.call(arguments,2);return vt(function(){return e.apply(t,r)},n)},s.difference=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=G.apply(t,arguments),i=u(i,r);++n<r;)i(e[n])||t.push(e[n]);return t},s.escape=function(e){return e==r?"":(e+"").replace(V,h)},s.every=Dt,s.extend=$t,s.filter=Pt,s.find=Ht,s.first=b,s.flatten=w,s.forEach=Bt,
|
,l:"u"+(Ft?"[o]=":".push")+"(c(A,i,d))"}};_t&&(w=function(e){return!!e&&!!ft.call(e,"callee")});var tn=vt||function(e){return pt.call(e)==bt};E(/x/)&&(E=function(e){return"[object Function]"==pt.call(e)});var nn=a({a:"n",j:"[]",i:"u.push(i)"}),rn=a(Qt,{i:"if(u[i]==null)"+Qt.i}),sn=a(Jt),on=a(Qt),un=a(Vt,Yt,Zt,{r:i}),an=a(Vt,Yt,Zt),fn=a({r:i,a:"n",j:"[]",i:"if(T(A))u.push(i)",e:"u.sort()"}),ln=a({a:"A",j:"true",q:"var H=z.call(A),l=A.length;if(D[H]"+(_t?"||P(A)":"")+"||(H==X&&l>-1&&l===l>>>0&&T(A.splice)))return!l"
|
||||||
s.forIn=Jt,s.forOwn=Kt,s.functions=Qt,s.groupBy=jt,s.has=function(e,t){return Y.call(e,t)},s.identity=L,s.indexOf=E,s.initial=function(e,t,n){return e?tt.call(e,0,-(t==r||n?1:t)):[]},s.intersection=function(e){var t=[];if(!e)return t;for(var n,r=-1,i=e.length,s=tt.call(arguments,1),o=[];++r<i;)n=e[r],0>E(t,n)&&Dt(s,function(e,t){return(o[t]||(o[t]=u(e)))(n)})&&t.push(n);return t},s.invoke=Ft,s.isArray=Gt,s.isBoolean=function(e){return e===n||e===i||nt.call(e)==at},s.isElement=function(e){return!!
|
,i:{l:"return false"}}),cn=gt?function(e){var t=typeof e;return"function"==t&&ct.call(e,"prototype")?nn(e):e&&Wt[t]?gt(e):[]}:nn,hn=a(Qt,{a:"n,ee,O,ff",q:"var J,L,Q,gg,dd=O==U;if(!dd)ff=[];for(var a=1,b=dd?2:arguments.length;a<b;a++){if(j=arguments[a]){",i:"if(A&&((Q=R(A))||U(A))){L=false;gg=ff.length;while(gg--)if(L=ff[gg].c==A)break;if(L){u[i]=ff[gg].d}else{J=(J=u[i])&&Q?(R(J)?J:[]):(U(J)?J:{});ff.push({d:J,c:A});u[i]=G(J,A,U,ff)}}else if(A!=null)u[i]=A"}),pn=a(Jt,{q:"if(typeof c!='function'){var q,t=e.apply(E,arguments),l=t.length;for(i=1;i<l;i++){q=t[i];if(q in n)u[q]=n[q]}}else{if(y)c=k(c,y)"
|
||||||
e&&1==e.nodeType},s.isEmpty=Yt,s.isEqual=k,s.isFinite=function(e){return st(e)&&nt.call(e)==ct},s.isNaN=function(e){return nt.call(e)==ct&&e!=+e},s.isNull=function(e){return e===r},s.isObject=function(e){return e&&St[typeof e]},s.isUndefined=function(e){return e===t},s.keys=Zt,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:tt.call(e,-t||i)}},s.lastIndexOf=function(e,t,n){if(!e)return-1;var r=e.length;for(n&&"number"==typeof n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(
|
,i:"if(c(A,i,n))u[i]=A",e:"}"}),dn=a({a:"n",j:"[]",i:"u.push(A)"}),vn=a({a:"d,hh",j:"false",o:i,d:{b:"if(z.call(d)==x)return d.indexOf(hh)>-1"},i:"if(A===hh)return true"}),mn=a(Vt,$t),gn=a(Vt,Kt),yn=a(Vt,Gt),bn=a(Vt,Yt,{j:"",i:"if(c(A,i,d))return A"}),wn=a(Vt,Yt),En=a(Vt,$t,{i:"q=c(A,i,d);(g.call(u,q)?u[q]:u[q]=[]).push(A)"}),Sn=a(en,{a:"d,V",q:"var C=w.call(arguments,2),S=typeof V=='function'",i:{b:"u[i]=(S?V:A[V]).apply(A,C)",l:"u"+(Ft?"[o]=":".push")+"((S?V:A[V]).apply(A,C))"}}),xn=a(Vt,en),Tn=
|
||||||
e[r]===t)return r;return-1},s.map=It,s.max=S,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Y.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]<i&&(i=e[s]);return i}for(n&&(t=p(t,n));++s<o;)n=t(e[s],s,e),n<r&&(r=n,i=e[s]);return i},s.mixin=A,s.noConflict=function(){return e._=F,this},s.once=function(e){var t,r=i;return function(){return r?t:(r=n,t=
|
a(en,{a:"d,bb",i:{b:"u[i]=A[bb]",l:"u"+(Ft?"[o]=":".push")+"(A[bb])"}}),Nn=a({a:"d,c,B,y",j:"B",q:"var W=arguments.length<3;if(y)c=k(c,y)",d:{b:"if(W)u=j[++i]"},i:{b:"u=c(u,A,i,d)",l:"u=W?(W=false,A):c(u,A,i,d)"}}),Cn=a(Vt,Gt,{i:"!"+Gt.i}),kn=a(Vt,Kt,{j:"false",i:Kt.i.replace("!","")}),Ln=a(Vt,$t,en,{i:{b:"u[i]={a:c(A,i,d),b:i,d:A}",l:"u"+(Ft?"[o]=":".push")+"({a:c(A,i,d),b:i,d:A})"},e:"u.sort(I);l=u.length;while(l--)u[l]=u[l].d"}),An=a(Gt,{a:"d,aa",q:"var t=[];K(aa,function(A,q){t.push(q)});var cc=t.length"
|
||||||
e.apply(this,arguments))}},s.partial=function(e){var t=tt.call(arguments,1),n=t.length;return function(){var r;return r=arguments,r.length&&(t.length=n,Z.apply(t,r)),r=1==t.length?e.call(this,t[0]):e.apply(this,t),t.length=n,r}},s.pick=function(e){for(var t,n=0,r=G.apply(H,arguments),i=r.length,s={};++n<i;)t=r[n],t in e&&(s[t]=e[t]);return s},s.pluck=qt,s.range=function(e,t,n){n||(n=1),t==r&&(t=e||0,e=0);for(var i=-1,t=Math.max(0,Math.ceil((t-e)/n)),s=Array(t);++i<t;)s[i]=e,e+=n;return s},s.reduce=
|
,i:"for(var q,Z=true,s=0;s<cc;s++){q=t[s];if(!(Z=A[q]===aa[q]))break}Z&&u.push(A)"}),On=a({r:i,s:i,a:"n",j:"n",q:"var M=arguments,l=M.length;if(l>1){for(var i=1;i<l;i++)u[M[i]]=F(u[M[i]],u);return u}",i:"if(T(u[i]))u[i]=F(u[i],u)"});s.VERSION="0.6.0",s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},s.bind=_,s.bindAll=On,s.chain=function(e){return e=new o(e),e._chain=n,e},s.clone=S,s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++n<r;
|
||||||
Rt,s.reduceRight=y,s.reject=Ut,s.rest=x,s.result=function(e,t){if(!e)return r;var n=e[t];return nt.call(n)==lt?e[t]():n},s.shuffle=function(e){if(!e)return[];for(var t,n=-1,r=e.length,i=Array(r);++n<r;)t=Math.floor(Math.random()*(n+1)),i[n]=i[t],i[t]=e[n];return i},s.size=function(e){if(!e)return 0;var t=e.length;return t===t>>>0?e.length:Zt(e).length},s.some=zt,s.sortBy=Wt,s.sortedIndex=T,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var i,o;i=n.escape;var u=n.evaluate,
|
)e[n]&&t.push(e[n]);return t},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=vn,s.countBy=mn,s.debounce=function(e,t,n){function i(){a=r,n||e.apply(u,s)}var s,o,u,a;return function(){var r=n&&!a;return s=arguments,u=this,Ct(a),a=kt(i,t),r&&(o=e.apply(u,s)),o}},s.defaults=rn,s.defer=function(e){var n=ht.call(arguments,1);return kt(function(){return e.apply(t,n)},1)},s.delay=function(e,n){var r=ht.call(arguments
|
||||||
a=n.interpolate,f=s.templateSettings,n=n.variable;i==r&&(i=f.escape),u==r&&(u=f.evaluate),a==r&&(a=f.interpolate),i&&(e=e.replace(i,v)),a&&(e=e.replace(a,g)),u!=O&&(O=u,D=RegExp((u?u.source:"($^)")+"|<e%-([\\s\\S]+?)%>|<e%=([\\s\\S]+?)%>","g")),i=Q.length,e=e.replace(D,m),i=i!=Q.length,e="__p += '"+e.replace($,c).replace(X,l)+"';",Q.length=0,n||(n=f.variable||M||"obj",i?e="with("+n+"){"+e+"}":(n!=M&&(M=n,_=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(z,"$&"+n+".").replace(_,"$1__d"))),e=(
|
,2);return kt(function(){return e.apply(t,r)},n)},s.difference=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=at.apply(t,arguments),i=u(i,r);++n<r;)i(e[n])||t.push(e[n]);return t},s.drop=sn,s.escape=function(e){return e==r?"":(e+"").replace(rt,h)},s.every=gn,s.extend=on,s.filter=yn,s.find=bn,s.first=N,s.flatten=C,s.forEach=wn,s.forIn=un,s.forOwn=an,s.functions=fn,s.groupBy=En,s.has=function(e,t){return e?ft.call(e,t):i},s.identity=D,s.indexOf=k,s.initial=function(e,t,n){return e?ht
|
||||||
i?e.replace(q,""):e).replace(R,"$1").replace(U,"$1;"),e="function("+n+"){"+n+"||("+n+"={});var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":",__d="+n+"."+n+"||"+n+";")+e+"return __p}";try{o=Function("_","return "+e)(s)}catch(h){o=function(){throw h}}return t?o(t):(o.source=e,o)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e
|
.call(e,0,-(t==r||n?1:t)):[]},s.intersection=function(e){var t=[];if(!e)return t;var n,r=arguments.length,i=[],s=-1,o=e.length;e:for(;++s<o;)if(n=e[s],0>k(t,n)){for(var a=1;a<r;a++)if(!(i[a]||(i[a]=u(arguments[a])))(n))continue e;t.push(n)}return t},s.invoke=Sn,s.isArguments=w,s.isArray=tn,s.isBoolean=function(e){return e===n||e===i||pt.call(e)==wt},s.isElement=function(e){return e?1===e.nodeType:i},s.isEmpty=ln,s.isEqual=x,s.isFinite=function(e){return mt(e)&&pt.call(e)==St},s.isFunction=E,s.isNaN=
|
||||||
.apply(o,i)):u||(u=vt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r<e;)t.call(n,r);else for(;++r<e;)t(r)},s.toArray=function(e){if(!e)return[];if(e.toArray&&nt.call(e.toArray)==lt)return e.toArray();var t=e.length;return t===t>>>0?(gt?nt.call(e)==pt:"string"==typeof e)?e.split(""):tt.call(e):en(e)},s.union=function(){for(var e=-1,t=[],n=G.apply(t,arguments),r=n.length;++e<r;)0>E(t,n[e])&&t.push(n[e]);return t},s.uniq=N,s.uniqueId=function(e){var t=j++;return e?e+t:t},s.values=en,s.without=
|
function(e){return pt.call(e)==St&&e!=+e},s.isNull=function(e){return e===r},s.isObject=function(e){return e?Wt[typeof e]:i},s.isUndefined=function(e){return e===t},s.keys=cn,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:ht.call(e,-t||i)}},s.lastIndexOf=function(e,t,n){if(!e)return-1;var r=e.length;for(n&&"number"==typeof n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=xn,s.max=L,s.memoize=function(e,t){var n={};return function(){var r=
|
||||||
function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments,1,20);++n<r;)i(e[n])||t.push(e[n]);return t},s.wrap=function(e,t){return function(){var n=[e];return arguments.length&&Z.apply(n,arguments),t.apply(this,n)}},s.zip=function(e){if(!e)return[];for(var t=-1,n=S(qt(arguments,"length")),r=Array(n);++t<n;)r[t]=qt(arguments,t);return r},s.zipObject=function(e,t){if(!e)return{};var n=-1,r=e.length,i={};for(t||(t=[]);++n<r;)i[e[n]]=t[n];return i},s.all=Dt,s.any=zt,s.collect=It,s.detect=
|
t?t.apply(this,arguments):arguments[0];return ft.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=hn,s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]<i&&(i=e[s]);return i}for(n&&(t=d(t,n));++s<o;)n=t(e[s],s,e),n<r&&(r=n,i=e[s]);return i},s.mixin=P,s.noConflict=function(){return e._=$,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){var t=ht.call(arguments,1),n=t.length
|
||||||
Ht,s.each=Bt,s.foldl=Rt,s.foldr=y,s.head=b,s.include=_t,s.inject=Rt,s.methods=Qt,s.select=Pt,s.tail=x,s.take=b,s.unique=N,o.prototype=s.prototype,A(s),o.prototype.chain=function(){return this._chain=n,this},o.prototype.value=function(){return this._wrapped},Bt("pop push reverse shift sort splice unshift".split(" "),function(e){var t=H[e];o.prototype[e]=function(){var e=this._wrapped;return t.apply(e,arguments),e.length===0&&delete e[0],this._chain&&(e=new o(e),e._chain=n),e}}),Bt(["concat","join"
|
;return function(){var r;return r=arguments,r.length&&(t.length=n,lt.apply(t,r)),r=1==t.length?e.call(this,t[0]):e.apply(this,t),t.length=n,r}},s.pick=pn,s.pluck=Tn,s.range=function(e,t,n){e=+e||0,n=+n||1,t==r&&(t=e,e=0);for(var i=-1,t=Math.max(0,Math.ceil((t-e)/n)),s=Array(t);++i<t;)s[i]=e,e+=n;return s},s.reduce=Nn,s.reduceRight=T,s.reject=Cn,s.rest=A,s.result=function(e,t){if(!e)return r;var n=e[t];return E(n)?e[t]():n},s.shuffle=function(e){if(!e)return[];for(var t,n=-1,r=e.length,i=Array(r);++
|
||||||
,"slice"],function(e){var t=H[e];o.prototype[e]=function(){var e=t.apply(this._wrapped,arguments);return this._chain&&(e=new o(e),e._chain=n),e}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):P?"object"==typeof module&&module&&module.s==P?(module.s=s)._=s:P._=s:e._=s})(this);
|
n<r;)t=Math.floor(Math.random()*(n+1)),i[n]=i[t],i[t]=e[n];return i},s.size=function(e){if(!e)return 0;var t=pt.call(e),n=e.length;return qt[t]||_t&&w(e)||t==xt&&-1<n&&n===n>>>0&&E(e.splice)?n:cn(e).length},s.some=kn,s.sortBy=Ln,s.sortedIndex=O,s.tap=function(e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var e=e+"",o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,p=n=n.variable||h.variable;o==r&&(o=h.escape),a==r&&(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace
|
||||||
|
(o,m)),f&&(e=e.replace(f,y)),a!=H&&(H=a,F=RegExp("<e%-([\\s\\S]+?)%>|<e%=([\\s\\S]+?)%>"+(a?"|"+a.source:""),"g")),o=ut.length,e=e.replace(F,g),o=o!=ut.length,e="__p += '"+e.replace(it,c).replace(nt,l)+"';",ut.length=0,p||(n=B||"obj",o?e="with("+n+"){"+e+"}":(n!=B&&(B=n,j=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(et,"$&"+n+".").replace(j,"$1__d"))),e=(o?e.replace(Q,""):e).replace(G,"$1").replace(Y,"$1;"),e="function("+n+"){"+(p?"":n+"||("+n+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"
|
||||||
|
:(p?"":",__d="+n+"."+n+"||"+n)+";")+e+"return __p}";try{u=Function("_","return "+e)(s)}catch(d){u=function(){throw d}}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=kt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r<e;)t.call(n,r);else for(;++r<e;)t(r)},s.toArray=function(e){if(!e)return[];if(e.toArray&&E(e.toArray))return e
|
||||||
|
.toArray();var t=e.length;return-1<t&&t===t>>>0?(Dt?pt.call(e)==Nt:"string"==typeof e)?e.split(""):ht.call(e):dn(e)},s.unescape=function(e){return e==r?"":(e+"").replace(K,b)},s.union=function(){for(var e=-1,t=[],n=at.apply(t,arguments),r=n.length;++e<r;)0>k(t,n[e])&&t.push(n[e]);return t},s.uniq=M,s.uniqueId=function(e){var t=X++;return e?e+t:t},s.values=dn,s.where=An,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments,1,20);++n<r;)i(e[n])||t.push(e[n]);return t},
|
||||||
|
s.wrap=function(e,t){return function(){var n=[e];return arguments.length&<.apply(n,arguments),t.apply(this,n)}},s.zip=function(e){if(!e)return[];for(var t=-1,n=L(Tn(arguments,"length")),r=Array(n);++t<n;)r[t]=Tn(arguments,t);return r},s.zipObject=function(e,t){if(!e)return{};var n=-1,r=e.length,i={};for(t||(t=[]);++n<r;)i[e[n]]=t[n];return i},s.all=gn,s.any=kn,s.collect=xn,s.detect=bn,s.each=wn,s.foldl=Nn,s.foldr=T,s.head=N,s.include=vn,s.inject=Nn,s.methods=fn,s.omit=sn,s.select=yn,s.tail=A,s.
|
||||||
|
take=N,s.unique=M,wn({Date:Et,Number:St,RegExp:Tt,String:Nt},function(e,t){s["is"+t]=function(t){return pt.call(t)==e}}),o.prototype=s.prototype,P(s),o.prototype.chain=function(){return this._chain=n,this},o.prototype.value=function(){return this._wrapped},wn("pop push reverse shift sort splice unshift".split(" "),function(e){var t=q[e];o.prototype[e]=function(){var e=this._wrapped;return t.apply(e,arguments),At&&e.length===0&&delete e[0],this._chain&&(e=new o(e),e._chain=n),e}}),wn(["concat","join"
|
||||||
|
,"slice"],function(e){var t=q[e];o.prototype[e]=function(){var e=t.apply(this._wrapped,arguments);return this._chain&&(e=new o(e),e._chain=n),e}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):I?"object"==typeof module&&module&&module.t==I?(module.t=s)._=s:I._=s:e._=s})(this);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash",
|
"name": "lodash",
|
||||||
"version": "0.4.2",
|
"version": "0.6.0",
|
||||||
"description": "A drop-in replacement for Underscore.js that delivers performance improvements, bug fixes, and additional features.",
|
"description": "A drop-in replacement for Underscore.js delivering performance, bug fixes, and additional features.",
|
||||||
"homepage": "http://lodash.com",
|
"homepage": "http://lodash.com",
|
||||||
"main": "lodash",
|
"main": "lodash",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
],
|
],
|
||||||
"author": {
|
"author": {
|
||||||
"name": "John-David Dalton",
|
"name": "John-David Dalton",
|
||||||
"email": "john@fusejs.com",
|
"email": "john.david.dalton@gmail.com",
|
||||||
"web": "http://allyoucanleet.com/"
|
"web": "http://allyoucanleet.com/"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@@ -42,6 +42,9 @@
|
|||||||
"node",
|
"node",
|
||||||
"rhino"
|
"rhino"
|
||||||
],
|
],
|
||||||
|
"jam": {
|
||||||
|
"main": "lodash.min.js"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node build",
|
"build": "node build",
|
||||||
"test": "node test/test"
|
"test": "node test/test"
|
||||||
|
|||||||
@@ -20,14 +20,16 @@
|
|||||||
<script>
|
<script>
|
||||||
var lodash = _.noConflict();
|
var lodash = _.noConflict();
|
||||||
</script>
|
</script>
|
||||||
<script src="../vendor/underscore/underscore.js"></script>
|
<script src="../vendor/underscore/underscore-min.js"></script>
|
||||||
<script src="../vendor/platform.js/platform.js"></script>
|
<script src="../vendor/platform.js/platform.js"></script>
|
||||||
<script src="../vendor/benchmark.js/benchmark.js"></script>
|
<script src="../vendor/benchmark.js/benchmark.js"></script>
|
||||||
<script src="../vendor/firebug-lite/src/firebug-lite-debug.js"></script>
|
<script src="../vendor/firebug-lite/src/firebug-lite-debug.js"></script>
|
||||||
<script src="perf.js"></script>
|
<script src="perf.js"></script>
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
var useApplet = !/[?&]nojava=true(?:&|$)/.test(location.search);
|
var measured,
|
||||||
|
perfNow,
|
||||||
|
begin = new Date;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
var fbUI = document.getElementById('FirebugUI'),
|
var fbUI = document.getElementById('FirebugUI'),
|
||||||
@@ -38,18 +40,18 @@
|
|||||||
return setTimeout(init, 15);
|
return setTimeout(init, 15);
|
||||||
}
|
}
|
||||||
fbUI.style.height = fbDoc.body.style.height = fbDoc.documentElement.style.height = '100%';
|
fbUI.style.height = fbDoc.body.style.height = fbDoc.documentElement.style.height = '100%';
|
||||||
|
setTimeout(run, 15);
|
||||||
// give applet time to initialize
|
|
||||||
lodash.delay(run, useApplet ? 500 : 15);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useApplet) {
|
// is the applet permitted?
|
||||||
// using innerHTML avoids an alert in some versions of IE6
|
if (!/[?&]nojava=true(?:&|$)/.test(location.search)) {
|
||||||
var div = document.createElement('div');
|
// is the applet really needed?
|
||||||
div.innerHTML = '<applet code=nano archive="../vendor/benchmark.js/nano.jar">';
|
while (!(measured = new Date - begin)) { }
|
||||||
document.body.insertBefore(div.lastChild, document.body.firstChild);
|
if (measured != 1 && !((perfNow = window.performance) && typeof (perfNow.now || perfNow.webkitNow) == 'function')) {
|
||||||
|
// load applet
|
||||||
|
document.write('<applet code="nano" archive="../vendor/benchmark.js/nano.jar"></applet>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = init;
|
window.onload = init;
|
||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
1561
perf/perf.js
1561
perf/perf.js
File diff suppressed because it is too large
Load Diff
@@ -70,10 +70,10 @@
|
|||||||
|
|
||||||
var label1 = document.createElement('label');
|
var label1 = document.createElement('label');
|
||||||
label1.innerHTML =
|
label1.innerHTML =
|
||||||
'<input name="norequire" type="checkbox">No RequireJS</label>';
|
'<input name="norequire" type="checkbox">No RequireJS';
|
||||||
|
|
||||||
var label2 = document.createElement('label');
|
var label2 = document.createElement('label');
|
||||||
label2.innerHTML = ' ' +
|
label2.innerHTML = ' ' +
|
||||||
'<select name="build">' +
|
'<select name="build">' +
|
||||||
'<option value="dev">Developement</option>' +
|
'<option value="dev">Developement</option>' +
|
||||||
'<option value="prod">Production</option>' +
|
'<option value="prod">Production</option>' +
|
||||||
|
|||||||
914
test/test.js
914
test/test.js
File diff suppressed because it is too large
Load Diff
101
vendor/backbone/backbone.js
vendored
101
vendor/backbone/backbone.js
vendored
@@ -134,6 +134,9 @@
|
|||||||
|
|
||||||
rest = [];
|
rest = [];
|
||||||
events = events.split(eventSplitter);
|
events = events.split(eventSplitter);
|
||||||
|
|
||||||
|
// Fill up `rest` with the callback arguments. Since we're only copying
|
||||||
|
// the tail of `arguments`, a loop is much faster than Array#slice.
|
||||||
for (i = 1, length = arguments.length; i < length; i++) {
|
for (i = 1, length = arguments.length; i < length; i++) {
|
||||||
rest[i - 1] = arguments[i];
|
rest[i - 1] = arguments[i];
|
||||||
}
|
}
|
||||||
@@ -295,7 +298,7 @@
|
|||||||
|
|
||||||
// If the new and previous value differ, record the change. If not,
|
// If the new and previous value differ, record the change. If not,
|
||||||
// then remove changes for this attribute.
|
// then remove changes for this attribute.
|
||||||
if (!_.isEqual(prev[attr], val) || (_.has(now, attr) != _.has(prev, attr))) {
|
if (!_.isEqual(prev[attr], val) || (_.has(now, attr) !== _.has(prev, attr))) {
|
||||||
this.changed[attr] = val;
|
this.changed[attr] = val;
|
||||||
if (!options.silent) this._pending[attr] = true;
|
if (!options.silent) this._pending[attr] = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -432,7 +435,7 @@
|
|||||||
url: function() {
|
url: function() {
|
||||||
var base = getValue(this, 'urlRoot') || getValue(this.collection, 'url') || urlError();
|
var base = getValue(this, 'urlRoot') || getValue(this.collection, 'url') || urlError();
|
||||||
if (this.isNew()) return base;
|
if (this.isNew()) return base;
|
||||||
return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + encodeURIComponent(this.id);
|
return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id);
|
||||||
},
|
},
|
||||||
|
|
||||||
// **parse** converts a response into the hash of attributes to be `set` on
|
// **parse** converts a response into the hash of attributes to be `set` on
|
||||||
@@ -555,10 +558,13 @@
|
|||||||
var Collection = Backbone.Collection = function(models, options) {
|
var Collection = Backbone.Collection = function(models, options) {
|
||||||
options || (options = {});
|
options || (options = {});
|
||||||
if (options.model) this.model = options.model;
|
if (options.model) this.model = options.model;
|
||||||
if (options.comparator !== undefined) 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) this.reset(models, {silent: true, parse: options.parse});
|
if (models) {
|
||||||
|
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.
|
||||||
@@ -628,9 +634,7 @@
|
|||||||
// Merge in duplicate models.
|
// Merge in duplicate models.
|
||||||
if (options.merge) {
|
if (options.merge) {
|
||||||
for (i = 0, length = dups.length; i < length; i++) {
|
for (i = 0, length = dups.length; i < length; i++) {
|
||||||
if (model = this._byId[dups[i].id]) {
|
if (model = this._byId[dups[i].id]) model.set(dups[i], options);
|
||||||
model.set(dups[i], options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -737,7 +741,7 @@
|
|||||||
options || (options = {});
|
options || (options = {});
|
||||||
if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
|
if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
|
||||||
var boundComparator = _.bind(this.comparator, this);
|
var boundComparator = _.bind(this.comparator, this);
|
||||||
if (this.comparator.length == 1) {
|
if (this.comparator.length === 1) {
|
||||||
this.models = this.sortBy(boundComparator);
|
this.models = this.sortBy(boundComparator);
|
||||||
} else {
|
} else {
|
||||||
this.models.sort(boundComparator);
|
this.models.sort(boundComparator);
|
||||||
@@ -771,7 +775,7 @@
|
|||||||
// models to the collection instead of resetting.
|
// models to the collection instead of resetting.
|
||||||
fetch: function(options) {
|
fetch: function(options) {
|
||||||
options = options ? _.clone(options) : {};
|
options = options ? _.clone(options) : {};
|
||||||
if (options.parse === undefined) options.parse = true;
|
if (options.parse === void 0) options.parse = true;
|
||||||
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) {
|
||||||
@@ -787,14 +791,14 @@
|
|||||||
// collection immediately, unless `wait: true` is passed, in which case we
|
// collection immediately, unless `wait: true` is passed, in which case we
|
||||||
// wait for the server to agree.
|
// wait for the server to agree.
|
||||||
create: function(model, options) {
|
create: function(model, options) {
|
||||||
var coll = this;
|
var collection = this;
|
||||||
options = options ? _.clone(options) : {};
|
options = options ? _.clone(options) : {};
|
||||||
model = this._prepareModel(model, options);
|
model = this._prepareModel(model, options);
|
||||||
if (!model) return false;
|
if (!model) return false;
|
||||||
if (!options.wait) coll.add(model, options);
|
if (!options.wait) collection.add(model, options);
|
||||||
var success = options.success;
|
var success = options.success;
|
||||||
options.success = function(model, resp, options) {
|
options.success = function(model, resp, options) {
|
||||||
if (options.wait) coll.add(model, options);
|
if (options.wait) collection.add(model, options);
|
||||||
if (success) success(model, resp, options);
|
if (success) success(model, resp, options);
|
||||||
};
|
};
|
||||||
model.save(null, options);
|
model.save(null, options);
|
||||||
@@ -842,9 +846,7 @@
|
|||||||
|
|
||||||
// Internal method to remove a model's ties to a collection.
|
// Internal method to remove a model's ties to a collection.
|
||||||
_removeReference: function(model) {
|
_removeReference: function(model) {
|
||||||
if (this == model.collection) {
|
if (this === model.collection) delete model.collection;
|
||||||
delete model.collection;
|
|
||||||
}
|
|
||||||
model.off('all', this._onModelEvent, this);
|
model.off('all', this._onModelEvent, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -853,10 +855,8 @@
|
|||||||
// events simply proxy through. "add" and "remove" events that originate
|
// events simply proxy through. "add" and "remove" events that originate
|
||||||
// in other collections are ignored.
|
// in other collections are ignored.
|
||||||
_onModelEvent: function(event, model, collection, options) {
|
_onModelEvent: function(event, model, collection, options) {
|
||||||
if ((event == 'add' || event == 'remove') && collection != this) return;
|
if ((event === 'add' || event === 'remove') && collection !== this) return;
|
||||||
if (event == 'destroy') {
|
if (event === 'destroy') this.remove(model, options);
|
||||||
this.remove(model, options);
|
|
||||||
}
|
|
||||||
if (model && event === 'change:' + model.idAttribute) {
|
if (model && event === 'change:' + model.idAttribute) {
|
||||||
delete this._byId[model.previous(model.idAttribute)];
|
delete this._byId[model.previous(model.idAttribute)];
|
||||||
if (model.id != null) this._byId[model.id] = model;
|
if (model.id != null) this._byId[model.id] = model;
|
||||||
@@ -867,11 +867,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Underscore methods that we want to implement on the Collection.
|
// Underscore methods that we want to implement on the Collection.
|
||||||
var methods = ['forEach', 'each', 'map', 'reduce', 'reduceRight', 'find',
|
var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
|
||||||
'detect', 'filter', 'select', 'reject', 'every', 'all', 'some', 'any',
|
'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
|
||||||
'include', 'contains', 'invoke', 'max', 'min', 'sortBy', 'sortedIndex',
|
'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
|
||||||
'toArray', 'size', 'first', 'initial', 'rest', 'last', 'without', 'indexOf',
|
'max', 'min', 'sortBy', 'sortedIndex', 'toArray', 'size', 'first', 'head',
|
||||||
'shuffle', 'lastIndexOf', 'isEmpty', 'groupBy'];
|
'take', 'initial', 'rest', 'tail', 'last', 'without', 'indexOf', 'shuffle',
|
||||||
|
'lastIndexOf', 'isEmpty', 'groupBy'];
|
||||||
|
|
||||||
// Mix in each Underscore method as a proxy to `Collection#models`.
|
// Mix in each Underscore method as a proxy to `Collection#models`.
|
||||||
_.each(methods, function(method) {
|
_.each(methods, function(method) {
|
||||||
@@ -1029,6 +1030,9 @@
|
|||||||
var docMode = document.documentMode;
|
var docMode = document.documentMode;
|
||||||
var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
|
var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
|
||||||
|
|
||||||
|
// Normalize root to always include trailing slash
|
||||||
|
if (!trailingSlash.test(this.options.root)) this.options.root += '/';
|
||||||
|
|
||||||
if (oldIE && this._wantsHashChange) {
|
if (oldIE && this._wantsHashChange) {
|
||||||
this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
|
this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
|
||||||
this.navigate(fragment);
|
this.navigate(fragment);
|
||||||
@@ -1048,7 +1052,7 @@
|
|||||||
// opened by a non-pushState browser.
|
// opened by a non-pushState browser.
|
||||||
this.fragment = fragment;
|
this.fragment = fragment;
|
||||||
var loc = this.location;
|
var loc = this.location;
|
||||||
var atRoot = (loc.pathname == this.options.root) && !loc.search;
|
var atRoot = (loc.pathname.replace(/[^/]$/, '$&/') === this.options.root) && !loc.search;
|
||||||
|
|
||||||
// If we've started off with a route from a `pushState`-enabled browser,
|
// If we've started off with a route from a `pushState`-enabled browser,
|
||||||
// but we're currently in a browser that doesn't support it...
|
// but we're currently in a browser that doesn't support it...
|
||||||
@@ -1065,9 +1069,7 @@
|
|||||||
this.history.replaceState({}, document.title, loc.protocol + '//' + loc.host + this.options.root + this.fragment);
|
this.history.replaceState({}, document.title, loc.protocol + '//' + loc.host + this.options.root + this.fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.options.silent) {
|
if (!this.options.silent) return this.loadUrl();
|
||||||
return this.loadUrl();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Disable Backbone.history, perhaps temporarily. Not useful in a real app,
|
// Disable Backbone.history, perhaps temporarily. Not useful in a real app,
|
||||||
@@ -1088,10 +1090,10 @@
|
|||||||
// calls `loadUrl`, normalizing across the hidden iframe.
|
// calls `loadUrl`, normalizing across the hidden iframe.
|
||||||
checkUrl: function(e) {
|
checkUrl: function(e) {
|
||||||
var current = this.getFragment();
|
var current = this.getFragment();
|
||||||
if (current == this.fragment && this.iframe) {
|
if (current === this.fragment && this.iframe) {
|
||||||
current = this.getFragment(this.getHash(this.iframe));
|
current = this.getFragment(this.getHash(this.iframe));
|
||||||
}
|
}
|
||||||
if (current == this.fragment) return false;
|
if (current === this.fragment) return false;
|
||||||
if (this.iframe) this.navigate(current);
|
if (this.iframe) this.navigate(current);
|
||||||
this.loadUrl() || this.loadUrl(this.getHash());
|
this.loadUrl() || this.loadUrl(this.getHash());
|
||||||
},
|
},
|
||||||
@@ -1121,9 +1123,9 @@
|
|||||||
if (!History.started) return false;
|
if (!History.started) return false;
|
||||||
if (!options || options === true) options = {trigger: options};
|
if (!options || options === true) options = {trigger: options};
|
||||||
var frag = (fragment || '').replace(routeStripper, '');
|
var frag = (fragment || '').replace(routeStripper, '');
|
||||||
if (this.fragment == frag) return;
|
if (this.fragment === frag) return;
|
||||||
this.fragment = frag;
|
this.fragment = frag;
|
||||||
var url = (frag.indexOf(this.options.root) != 0 ? this.options.root : '') + frag;
|
var url = (frag.indexOf(this.options.root) !== 0 ? this.options.root : '') + frag;
|
||||||
|
|
||||||
// If pushState is available, we use it to set the fragment as a real URL.
|
// If pushState is available, we use it to set the fragment as a real URL.
|
||||||
if (this._hasPushState) {
|
if (this._hasPushState) {
|
||||||
@@ -1133,7 +1135,7 @@
|
|||||||
// fragment to store history.
|
// fragment to store history.
|
||||||
} else if (this._wantsHashChange) {
|
} else if (this._wantsHashChange) {
|
||||||
this._updateHash(this.location, frag, options.replace);
|
this._updateHash(this.location, frag, options.replace);
|
||||||
if (this.iframe && (frag != this.getFragment(this.getHash(this.iframe)))) {
|
if (this.iframe && (frag !== this.getFragment(this.getHash(this.iframe)))) {
|
||||||
// Opening and closing the iframe tricks IE7 and earlier to push a
|
// Opening and closing the iframe tricks IE7 and earlier to push a
|
||||||
// history entry on hash-tag change. When replace is true, we don't
|
// history entry on hash-tag change. When replace is true, we don't
|
||||||
// want this.
|
// want this.
|
||||||
@@ -1158,6 +1160,7 @@
|
|||||||
location.hash = fragment;
|
location.hash = fragment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Backbone.View
|
// Backbone.View
|
||||||
@@ -1202,9 +1205,19 @@
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Clean up references to this view in order to prevent latent effects and
|
||||||
|
// memory leaks.
|
||||||
|
dispose: function() {
|
||||||
|
this.undelegateEvents();
|
||||||
|
if (this.model) this.model.off(null, null, this);
|
||||||
|
if (this.collection) this.collection.off(null, null, this);
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
// Remove this view from the DOM. Note that the view isn't present in the
|
// 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.
|
// DOM by default, so calling this method may be a no-op.
|
||||||
remove: function() {
|
remove: function() {
|
||||||
|
this.dispose();
|
||||||
this.$el.remove();
|
this.$el.remove();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
@@ -1291,8 +1304,8 @@
|
|||||||
_ensureElement: function() {
|
_ensureElement: function() {
|
||||||
if (!this.el) {
|
if (!this.el) {
|
||||||
var attrs = _.extend({}, getValue(this, 'attributes'));
|
var attrs = _.extend({}, getValue(this, 'attributes'));
|
||||||
if (this.id) attrs.id = this.id;
|
if (this.id) attrs.id = getValue(this, 'id');
|
||||||
if (this.className) attrs['class'] = this.className;
|
if (this.className) attrs['class'] = getValue(this, 'className');
|
||||||
this.setElement(this.make(getValue(this, 'tagName'), attrs), false);
|
this.setElement(this.make(getValue(this, 'tagName'), attrs), false);
|
||||||
} else {
|
} else {
|
||||||
this.setElement(this.el, false);
|
this.setElement(this.el, false);
|
||||||
@@ -1301,16 +1314,6 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// The self-propagating extend function that Backbone classes use.
|
|
||||||
var extend = function(protoProps, classProps) {
|
|
||||||
var child = inherits(this, protoProps, classProps);
|
|
||||||
child.extend = this.extend;
|
|
||||||
return child;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set up inheritance for the model, collection, and view.
|
|
||||||
Model.extend = Collection.extend = Router.extend = View.extend = extend;
|
|
||||||
|
|
||||||
// Backbone.sync
|
// Backbone.sync
|
||||||
// -------------
|
// -------------
|
||||||
|
|
||||||
@@ -1352,7 +1355,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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 && model && (method === 'create' || method === 'update')) {
|
||||||
params.contentType = 'application/json';
|
params.contentType = 'application/json';
|
||||||
params.data = JSON.stringify(model);
|
params.data = JSON.stringify(model);
|
||||||
}
|
}
|
||||||
@@ -1410,7 +1413,8 @@
|
|||||||
// Helper function to correctly set up the prototype chain, for subclasses.
|
// Helper function to correctly set up the prototype chain, for subclasses.
|
||||||
// Similar to `goog.inherits`, but uses a hash of prototype properties and
|
// Similar to `goog.inherits`, but uses a hash of prototype properties and
|
||||||
// class properties to be extended.
|
// class properties to be extended.
|
||||||
var inherits = function(parent, protoProps, staticProps) {
|
var extend = function(protoProps, staticProps) {
|
||||||
|
var parent = this;
|
||||||
var child;
|
var child;
|
||||||
|
|
||||||
// The constructor function for the new subclass is either defined by you
|
// The constructor function for the new subclass is either defined by you
|
||||||
@@ -1446,6 +1450,9 @@
|
|||||||
return child;
|
return child;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set up inheritance for the model, collection, and view.
|
||||||
|
Model.extend = Collection.extend = Router.extend = View.extend = extend;
|
||||||
|
|
||||||
// Helper function to get a value from a Backbone object as a property
|
// Helper function to get a value from a Backbone object as a property
|
||||||
// or as a function.
|
// or as a function.
|
||||||
var getValue = function(object, prop) {
|
var getValue = function(object, prop) {
|
||||||
|
|||||||
23
vendor/backbone/test/collection.js
vendored
23
vendor/backbone/test/collection.js
vendored
@@ -47,6 +47,29 @@ $(document).ready(function() {
|
|||||||
equal(col.length, 4);
|
equal(col.length, 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Collection: new and parse", 3, function() {
|
||||||
|
var MyCol = Backbone.Collection.extend({
|
||||||
|
// only save the models that have an even value.
|
||||||
|
parse : function(data) {
|
||||||
|
var onlyEven = [];
|
||||||
|
_.each(data, function(datum) {
|
||||||
|
if (datum.a % 2 === 0) {
|
||||||
|
onlyEven.push(datum);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return onlyEven;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
anotherCol = new MyCol([
|
||||||
|
{ a : 1 },{ a : 2 },{ a : 3 },{ a : 4 }
|
||||||
|
], { parse : true });
|
||||||
|
|
||||||
|
equal(anotherCol.length, 2);
|
||||||
|
equal(anotherCol.first().get('a'), 2)
|
||||||
|
equal(anotherCol.last().get('a'), 4);
|
||||||
|
});
|
||||||
|
|
||||||
test("Collection: get, getByCid", 3, function() {
|
test("Collection: get, getByCid", 3, function() {
|
||||||
equal(col.get(0), d);
|
equal(col.get(0), d);
|
||||||
equal(col.get(2), b);
|
equal(col.get(2), b);
|
||||||
|
|||||||
52
vendor/backbone/test/router.js
vendored
52
vendor/backbone/test/router.js
vendored
@@ -20,9 +20,11 @@ $(document).ready(function() {
|
|||||||
_.extend(this, _.pick($('<a></a>', {href: href})[0],
|
_.extend(this, _.pick($('<a></a>', {href: href})[0],
|
||||||
'href',
|
'href',
|
||||||
'hash',
|
'hash',
|
||||||
|
'host',
|
||||||
'search',
|
'search',
|
||||||
'fragment',
|
'fragment',
|
||||||
'pathname'
|
'pathname',
|
||||||
|
'protocol'
|
||||||
));
|
));
|
||||||
// In IE, anchor.pathname does not contain a leading slash though
|
// In IE, anchor.pathname does not contain a leading slash though
|
||||||
// window.location.pathname does.
|
// window.location.pathname does.
|
||||||
@@ -318,4 +320,52 @@ $(document).ready(function() {
|
|||||||
strictEqual(Backbone.history.fragment, 'x');
|
strictEqual(Backbone.history.fragment, 'x');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Router: Normalize root.", 1, function() {
|
||||||
|
Backbone.history.stop();
|
||||||
|
location.replace('http://example.com/root');
|
||||||
|
Backbone.history = new Backbone.History({
|
||||||
|
location: location,
|
||||||
|
history: {
|
||||||
|
pushState: function(state, title, url) {
|
||||||
|
strictEqual(url, '/root/fragment');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Backbone.history.start({
|
||||||
|
pushState: true,
|
||||||
|
root: '/root',
|
||||||
|
hashChange: false
|
||||||
|
});
|
||||||
|
Backbone.history.navigate('fragment');
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Router: Normalize root.", 1, function() {
|
||||||
|
Backbone.history.stop();
|
||||||
|
location.replace('http://example.com/root#fragment');
|
||||||
|
Backbone.history = new Backbone.History({
|
||||||
|
location: location,
|
||||||
|
history: {
|
||||||
|
pushState: function(state, title, url) {},
|
||||||
|
replaceState: function(state, title, url) {
|
||||||
|
strictEqual(url, 'http://example.com/root/fragment');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Backbone.history.start({
|
||||||
|
pushState: true,
|
||||||
|
root: '/root'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Router: Normalize root.", 1, function() {
|
||||||
|
Backbone.history.stop();
|
||||||
|
location.replace('http://example.com/root');
|
||||||
|
Backbone.history = new Backbone.History({location: location});
|
||||||
|
Backbone.history.loadUrl = function() { ok(true); };
|
||||||
|
Backbone.history.start({
|
||||||
|
pushState: true,
|
||||||
|
root: '/root'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
38
vendor/backbone/test/view.js
vendored
38
vendor/backbone/test/view.js
vendored
@@ -135,6 +135,20 @@ $(document).ready(function() {
|
|||||||
ok(!view.el);
|
ok(!view.el);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("View: with className and id functions", 2, function() {
|
||||||
|
var View = Backbone.View.extend({
|
||||||
|
className: function() {
|
||||||
|
return 'className';
|
||||||
|
},
|
||||||
|
id: function() {
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var view = new View();
|
||||||
|
strictEqual(view.el.className, 'className');
|
||||||
|
strictEqual(view.el.id, 'id');
|
||||||
|
});
|
||||||
|
|
||||||
test("View: with attributes", 2, function() {
|
test("View: with attributes", 2, function() {
|
||||||
var view = new Backbone.View({attributes : {'class': 'one', id: 'two'}});
|
var view = new Backbone.View({attributes : {'class': 'one', id: 'two'}});
|
||||||
equal(view.el.className, 'one');
|
equal(view.el.className, 'one');
|
||||||
@@ -227,4 +241,28 @@ $(document).ready(function() {
|
|||||||
ok(new View().$el.is('p'));
|
ok(new View().$el.is('p'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("dispose", 0, function() {
|
||||||
|
var View = Backbone.View.extend({
|
||||||
|
events: {click: function(){ ok(false); }},
|
||||||
|
initialize: function() {
|
||||||
|
this.model.on('all x', function(){ ok(false); }, this);
|
||||||
|
this.collection.on('all x', function(){ ok(false); }, this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var view = new View({
|
||||||
|
model: new Backbone.Model,
|
||||||
|
collection: new Backbone.Collection
|
||||||
|
});
|
||||||
|
view.dispose();
|
||||||
|
view.model.trigger('x');
|
||||||
|
view.collection.trigger('x');
|
||||||
|
view.$el.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("view#remove calls dispose.", 1, function() {
|
||||||
|
var view = new Backbone.View();
|
||||||
|
view.dispose = function() { ok(true); };
|
||||||
|
view.remove();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
57
vendor/benchmark.js/README.md
vendored
57
vendor/benchmark.js/README.md
vendored
@@ -1,30 +1,34 @@
|
|||||||
# Benchmark.js <sup>v1.0.0-pre</sup>
|
# Benchmark.js <sup>v1.0.0</sup>
|
||||||
|
|
||||||
A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/).
|
A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/).
|
||||||
|
|
||||||
## BestieJS
|
## Download
|
||||||
|
|
||||||
Benchmark.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.
|
* [Development source](https://raw.github.com/bestiejs/benchmark.js/v1.0.0/benchmark.js)
|
||||||
|
|
||||||
## Documentation
|
## Dive in
|
||||||
|
|
||||||
The documentation for Benchmark.js can be viewed here: <http://benchmarkjs.com/docs>
|
We’ve got [API docs](http://benchmarkjs.com/docs) and [unit tests](http://benchmarkjs.com/tests).
|
||||||
|
|
||||||
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/benchmark.js/wiki/Roadmap).
|
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/benchmark.js/wiki/Roadmap).
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Benchmark.js has been tested in at least Adobe AIR 3.1, Chrome 5-21, Firefox 1-14, IE 6-9, Opera 9.25-12, Safari 3-6, Node.js 0.8.7, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5.
|
||||||
|
|
||||||
## Installation and usage
|
## Installation and usage
|
||||||
|
|
||||||
In a browser or Adobe AIR:
|
In a browser or Adobe AIR:
|
||||||
|
|
||||||
~~~ html
|
```html
|
||||||
<script src="benchmark.js"></script>
|
<script src="benchmark.js"></script>
|
||||||
~~~
|
```
|
||||||
|
|
||||||
Optionally, expose Java’s nanosecond timer by adding the `nano` applet to the `<body>`:
|
Optionally, expose Java’s nanosecond timer by adding the `nano` applet to the `<body>`:
|
||||||
|
|
||||||
~~~ html
|
```html
|
||||||
<applet code="nano" archive="nano.jar"></applet>
|
<applet code="nano" archive="nano.jar"></applet>
|
||||||
~~~
|
```
|
||||||
|
|
||||||
Or enable Chrome’s microsecond timer by using the [command line switch](http://peter.sh/experiments/chromium-command-line-switches/#enable-benchmarking):
|
Or enable Chrome’s microsecond timer by using the [command line switch](http://peter.sh/experiments/chromium-command-line-switches/#enable-benchmarking):
|
||||||
|
|
||||||
@@ -32,37 +36,37 @@ Or enable Chrome’s microsecond timer by using the [command line switch](http:/
|
|||||||
|
|
||||||
Via [npm](http://npmjs.org/):
|
Via [npm](http://npmjs.org/):
|
||||||
|
|
||||||
~~~ bash
|
```bash
|
||||||
npm install benchmark
|
npm install benchmark
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/):
|
In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
var Benchmark = require('benchmark');
|
var Benchmark = require('benchmark');
|
||||||
~~~
|
```
|
||||||
|
|
||||||
Optionally, use the [microtime module](https://github.com/wadey/node-microtime) by Wade Simmons:
|
Optionally, use the [microtime module](https://github.com/wadey/node-microtime) by Wade Simmons:
|
||||||
|
|
||||||
~~~ bash
|
```bash
|
||||||
npm install microtime
|
npm install microtime
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In [Narwhal](http://narwhaljs.org/) and [RingoJS v0.7.0-](http://ringojs.org/):
|
In [RingoJS v0.7.0-](http://ringojs.org/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
var Benchmark = require('benchmark').Benchmark;
|
var Benchmark = require('benchmark').Benchmark;
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In [Rhino](http://www.mozilla.org/rhino/):
|
In [Rhino](http://www.mozilla.org/rhino/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
load('benchmark.js');
|
load('benchmark.js');
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In an AMD loader like [RequireJS](http://requirejs.org/):
|
In an AMD loader like [RequireJS](http://requirejs.org/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
require({
|
require({
|
||||||
'paths': {
|
'paths': {
|
||||||
'benchmark': 'path/to/benchmark'
|
'benchmark': 'path/to/benchmark'
|
||||||
@@ -84,11 +88,11 @@ require({
|
|||||||
Benchmark.platform = platform;
|
Benchmark.platform = platform;
|
||||||
console.log(Benchmark.platform.name);
|
console.log(Benchmark.platform.name);
|
||||||
});
|
});
|
||||||
~~~
|
```
|
||||||
|
|
||||||
Usage example:
|
Usage example:
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
var suite = new Benchmark.Suite;
|
var suite = new Benchmark.Suite;
|
||||||
|
|
||||||
// add tests
|
// add tests
|
||||||
@@ -112,12 +116,11 @@ suite.add('RegExp#test', function() {
|
|||||||
// > RegExp#test x 4,161,532 +-0.99% (59 cycles)
|
// > RegExp#test x 4,161,532 +-0.99% (59 cycles)
|
||||||
// > String#indexOf x 6,139,623 +-1.00% (131 cycles)
|
// > String#indexOf x 6,139,623 +-1.00% (131 cycles)
|
||||||
// > Fastest is String#indexOf
|
// > Fastest is String#indexOf
|
||||||
~~~
|
```
|
||||||
|
|
||||||
## Footnotes
|
## BestieJS
|
||||||
|
|
||||||
1. Benchmark.js has been tested in at least Adobe AIR 2.6, Chrome 5-15, Firefox 1.5-8, IE 6-10, Opera 9.25-11.52, Safari 2-5.1.1, Node.js 0.4.8-0.6.1, Narwhal 0.3.2, RingoJS 0.7-0.8, and Rhino 1.7RC3.
|
Benchmark.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.
|
||||||
<a name="fn1" title="Jump back to footnote 1 in the text." href="#fnref1">↩</a>
|
|
||||||
|
|
||||||
## Authors
|
## Authors
|
||||||
|
|
||||||
|
|||||||
238
vendor/benchmark.js/benchmark.js
vendored
238
vendor/benchmark.js/benchmark.js
vendored
@@ -1,5 +1,5 @@
|
|||||||
/*!
|
/*!
|
||||||
* Benchmark.js v1.0.0-pre <http://benchmarkjs.com/>
|
* Benchmark.js v1.0.0 <http://benchmarkjs.com/>
|
||||||
* Copyright 2010-2012 Mathias Bynens <http://mths.be/>
|
* Copyright 2010-2012 Mathias Bynens <http://mths.be/>
|
||||||
* Based on JSLitmus.js, copyright Robert Kieffer <http://broofa.com/>
|
* Based on JSLitmus.js, copyright Robert Kieffer <http://broofa.com/>
|
||||||
* Modified by John-David Dalton <http://allyoucanleet.com/>
|
* Modified by John-David Dalton <http://allyoucanleet.com/>
|
||||||
@@ -244,6 +244,36 @@
|
|||||||
} catch(e) {
|
} catch(e) {
|
||||||
support.getAllKeys = false;
|
support.getAllKeys = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect if own properties are iterated before inherited properties (all but IE < 9).
|
||||||
|
*
|
||||||
|
* @name iteratesOwnLast
|
||||||
|
* @memberOf Benchmark.support
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
support.iteratesOwnFirst = (function() {
|
||||||
|
var props = [];
|
||||||
|
function ctor() { this.x = 1; }
|
||||||
|
ctor.prototype = { 'y': 1 };
|
||||||
|
for (var prop in new ctor) { props.push(prop); }
|
||||||
|
return props[0] == 'x';
|
||||||
|
}());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect if a node's [[Class]] is resolvable (all but IE < 9)
|
||||||
|
* and that the JS engine errors when attempting to coerce an object to a
|
||||||
|
* string without a `toString` property value of `typeof` "function".
|
||||||
|
*
|
||||||
|
* @name nodeClass
|
||||||
|
* @memberOf Benchmark.support
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
support.nodeClass = ({ 'toString': 0 } + '', toString.call(doc || 0) != '[object Object]');
|
||||||
|
} catch(e) {
|
||||||
|
support.nodeClass = true;
|
||||||
|
}
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -583,14 +613,17 @@
|
|||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
if ((index - start) in tail) {
|
if ((index - start) in tail) {
|
||||||
object[index] = tail[index - start];
|
object[index] = tail[index - start];
|
||||||
} else {
|
} else if (index in object) {
|
||||||
delete object[index];
|
delete object[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// delete excess elements
|
// delete excess elements
|
||||||
deleteCount = deleteCount > elementCount ? deleteCount - elementCount : 0;
|
deleteCount = deleteCount > elementCount ? deleteCount - elementCount : 0;
|
||||||
while (deleteCount--) {
|
while (deleteCount--) {
|
||||||
delete object[length + deleteCount];
|
index = length + deleteCount;
|
||||||
|
if (index in object) {
|
||||||
|
delete object[index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
object.length = length;
|
object.length = length;
|
||||||
return result;
|
return result;
|
||||||
@@ -941,7 +974,13 @@
|
|||||||
// escape the `{` for Firefox 1
|
// escape the `{` for Firefox 1
|
||||||
result = (/^[^{]+\{([\s\S]*)}\s*$/.exec(fn) || 0)[1];
|
result = (/^[^{]+\{([\s\S]*)}\s*$/.exec(fn) || 0)[1];
|
||||||
}
|
}
|
||||||
return (result || '').replace(/^\s+|\s+$/g, '');
|
// trim string
|
||||||
|
result = (result || '').replace(/^\s+|\s+$/g, '');
|
||||||
|
|
||||||
|
// detect strings containing only the "use strict" directive
|
||||||
|
return /^(?:\/\*+[\w|\W]*?\*\/|\/\/.*?[\n\r\u2028\u2029]|\s)*(["'])use strict\1;?$/.test(result)
|
||||||
|
? ''
|
||||||
|
: result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -994,36 +1033,43 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified `value` is an object created by the `Object`
|
* Checks if a given `value` is an object created by the `Object` constructor
|
||||||
* constructor assuming objects created by the `Object` constructor have no
|
* assuming objects created by the `Object` constructor have no inherited
|
||||||
* inherited enumerable properties and assuming there are no `Object.prototype`
|
* enumerable properties and that there are no `Object.prototype` extensions.
|
||||||
* extensions.
|
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Mixed} value The value to check.
|
* @param {Mixed} value The value to check.
|
||||||
* @returns {Boolean} Returns `true` if `value` is an object, else `false`.
|
* @returns {Boolean} Returns `true` if the `value` is a plain `Object` object, else `false`.
|
||||||
*/
|
*/
|
||||||
function isObject(value) {
|
function isPlainObject(value) {
|
||||||
var ctor,
|
// avoid non-objects and false positives for `arguments` objects in IE < 9
|
||||||
result = !!value && toString.call(value) == '[object Object]';
|
var result = false;
|
||||||
|
if (!(value && typeof value == 'object') || isArguments(value)) {
|
||||||
if (result && noArgumentsClass) {
|
return result;
|
||||||
// avoid false positives for `arguments` objects in IE < 9
|
|
||||||
result = !isArguments(value);
|
|
||||||
}
|
}
|
||||||
if (result) {
|
// IE < 9 presents DOM nodes as `Object` objects except they have `toString`
|
||||||
// IE < 9 presents nodes like `Object` objects:
|
// methods that are `typeof` "string" and still can coerce nodes to strings.
|
||||||
// IE < 8 are missing the node's constructor property
|
// Also check that the constructor is `Object` (i.e. `Object instanceof Object`)
|
||||||
// IE 8 node constructors are typeof "object"
|
var ctor = value.constructor;
|
||||||
ctor = value.constructor;
|
if ((support.nodeClass || !(typeof value.toString != 'function' && typeof (value + '') == 'string')) &&
|
||||||
// check if the constructor is `Object` as `Object instanceof Object` is `true`
|
(!isClassOf(ctor, 'Function') || ctor instanceof ctor)) {
|
||||||
if ((result = isClassOf(ctor, 'Function') && ctor instanceof ctor)) {
|
// In most environments an object's own properties are iterated before
|
||||||
// An object's own properties are iterated before inherited properties.
|
// its inherited properties. If the last iterated property is an object's
|
||||||
// If the last iterated key belongs to an object's own property then
|
// own property then there are no inherited enumerable properties.
|
||||||
// there are no inherited enumerable properties.
|
if (support.iteratesOwnFirst) {
|
||||||
forProps(value, function(subValue, subKey) { result = subKey; });
|
forProps(value, function(subValue, subKey) {
|
||||||
result = result === true || hasKey(value, result);
|
result = subKey;
|
||||||
|
});
|
||||||
|
return result === false || hasKey(value, result);
|
||||||
}
|
}
|
||||||
|
// IE < 9 iterates inherited properties before own properties. If the first
|
||||||
|
// iterated property is an object's own property then there are no inherited
|
||||||
|
// enumerable properties.
|
||||||
|
forProps(value, function(subValue, subKey) {
|
||||||
|
result = !hasKey(value, subKey);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return result === false;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1265,7 +1311,7 @@
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '[object Object]':
|
case '[object Object]':
|
||||||
isObject(value) && (clone = new ctor);
|
isPlainObject(value) && (clone = {});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '[object Number]':
|
case '[object Number]':
|
||||||
@@ -2405,13 +2451,12 @@
|
|||||||
|
|
||||||
var source = {
|
var source = {
|
||||||
'setup': getSource(bench.setup, preprocess('m$.setup()')),
|
'setup': getSource(bench.setup, preprocess('m$.setup()')),
|
||||||
'fn': getSource(fn, preprocess('f$(' + fnArg + ')')),
|
'fn': getSource(fn, preprocess('m$.fn(' + fnArg + ')')),
|
||||||
'fnArg': fnArg,
|
'fnArg': fnArg,
|
||||||
'teardown': getSource(bench.teardown, preprocess('m$.teardown()'))
|
'teardown': getSource(bench.teardown, preprocess('m$.teardown()'))
|
||||||
};
|
};
|
||||||
|
|
||||||
var compiled = bench.compiled,
|
var count = bench.count = clone.count,
|
||||||
count = bench.count = clone.count,
|
|
||||||
decompilable = support.decompilation || stringable,
|
decompilable = support.decompilation || stringable,
|
||||||
id = bench.id,
|
id = bench.id,
|
||||||
isEmpty = !(source.fn || stringable),
|
isEmpty = !(source.fn || stringable),
|
||||||
@@ -2433,77 +2478,77 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!compiled) {
|
// Compile in setup/teardown functions and the test loop.
|
||||||
// compile in setup/teardown functions and the test loop
|
// Create a new compiled test, instead of using the cached `bench.compiled`,
|
||||||
compiled = bench.compiled = createFunction(preprocess('t$'), interpolate(
|
// to avoid potential engine optimizations enabled over the life of the test.
|
||||||
preprocess(deferred
|
var compiled = bench.compiled = createFunction(preprocess('t$'), interpolate(
|
||||||
? 'var d$=this,#{fnArg}=d$,m$=d$.benchmark._original,f$=m$.fn,su$=m$.setup,td$=m$.teardown;' +
|
preprocess(deferred
|
||||||
// when `deferred.cycles` is `0` then...
|
? 'var d$=this,#{fnArg}=d$,m$=d$.benchmark._original,f$=m$.fn,su$=m$.setup,td$=m$.teardown;' +
|
||||||
'if(!d$.cycles){' +
|
// when `deferred.cycles` is `0` then...
|
||||||
// set `deferred.fn`
|
'if(!d$.cycles){' +
|
||||||
'd$.fn=function(){var #{fnArg}=d$;if(typeof f$=="function"){try{#{fn}\n}catch(e$){f$(d$)}}else{#{fn}\n}};' +
|
// set `deferred.fn`
|
||||||
// set `deferred.teardown`
|
'd$.fn=function(){var #{fnArg}=d$;if(typeof f$=="function"){try{#{fn}\n}catch(e$){f$(d$)}}else{#{fn}\n}};' +
|
||||||
'd$.teardown=function(){d$.cycles=0;if(typeof td$=="function"){try{#{teardown}\n}catch(e$){td$()}}else{#{teardown}\n}};' +
|
// set `deferred.teardown`
|
||||||
// execute the benchmark's `setup`
|
'd$.teardown=function(){d$.cycles=0;if(typeof td$=="function"){try{#{teardown}\n}catch(e$){td$()}}else{#{teardown}\n}};' +
|
||||||
'if(typeof su$=="function"){try{#{setup}\n}catch(e$){su$()}}else{#{setup}\n};' +
|
// execute the benchmark's `setup`
|
||||||
// start timer
|
'if(typeof su$=="function"){try{#{setup}\n}catch(e$){su$()}}else{#{setup}\n};' +
|
||||||
't$.start(d$);' +
|
// start timer
|
||||||
// execute `deferred.fn` and return a dummy object
|
't$.start(d$);' +
|
||||||
'}d$.fn();return{}'
|
// execute `deferred.fn` and return a dummy object
|
||||||
|
'}d$.fn();return{}'
|
||||||
|
|
||||||
: 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count,n$=t$.ns;#{setup}\n#{begin};' +
|
: 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count,n$=t$.ns;#{setup}\n#{begin};' +
|
||||||
'while(i$--){#{fn}\n}#{end};#{teardown}\nreturn{elapsed:r$,uid:"#{uid}"}'),
|
'while(i$--){#{fn}\n}#{end};#{teardown}\nreturn{elapsed:r$,uid:"#{uid}"}'),
|
||||||
|
source
|
||||||
|
));
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isEmpty) {
|
||||||
|
// Firefox may remove dead code from Function#toString results
|
||||||
|
// http://bugzil.la/536085
|
||||||
|
throw new Error('The test "' + name + '" is empty. This may be the result of dead code removal.');
|
||||||
|
}
|
||||||
|
else if (!deferred) {
|
||||||
|
// pretest to determine if compiled code is exits early, usually by a
|
||||||
|
// rogue `return` statement, by checking for a return object with the uid
|
||||||
|
bench.count = 1;
|
||||||
|
compiled = (compiled.call(bench, timer) || {}).uid == uid && compiled;
|
||||||
|
bench.count = count;
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
compiled = null;
|
||||||
|
clone.error = e || new Error(String(e));
|
||||||
|
bench.count = count;
|
||||||
|
}
|
||||||
|
// fallback when a test exits early or errors during pretest
|
||||||
|
if (decompilable && !compiled && !deferred && !isEmpty) {
|
||||||
|
compiled = createFunction(preprocess('t$'), interpolate(
|
||||||
|
preprocess(
|
||||||
|
(clone.error && !stringable
|
||||||
|
? 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count'
|
||||||
|
: 'function f$(){#{fn}\n}var r$,s$,m$=this,i$=m$.count'
|
||||||
|
) +
|
||||||
|
',n$=t$.ns;#{setup}\n#{begin};m$.f$=f$;while(i$--){m$.f$()}#{end};' +
|
||||||
|
'delete m$.f$;#{teardown}\nreturn{elapsed:r$}'
|
||||||
|
),
|
||||||
source
|
source
|
||||||
));
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isEmpty) {
|
// pretest one more time to check for errors
|
||||||
// Firefox may remove dead code from Function#toString results
|
bench.count = 1;
|
||||||
// http://bugzil.la/536085
|
compiled.call(bench, timer);
|
||||||
throw new Error('The test "' + name + '" is empty. This may be the result of dead code removal.');
|
bench.compiled = compiled;
|
||||||
}
|
|
||||||
else if (!deferred) {
|
|
||||||
// pretest to determine if compiled code is exits early, usually by a
|
|
||||||
// rogue `return` statement, by checking for a return object with the uid
|
|
||||||
bench.count = 1;
|
|
||||||
compiled = (compiled.call(bench, timer) || {}).uid == uid && compiled;
|
|
||||||
bench.count = count;
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
compiled = null;
|
|
||||||
clone.error = e || new Error(String(e));
|
|
||||||
bench.count = count;
|
bench.count = count;
|
||||||
|
delete clone.error;
|
||||||
}
|
}
|
||||||
// fallback when a test exits early or errors during pretest
|
catch(e) {
|
||||||
if (decompilable && !compiled && !deferred && !isEmpty) {
|
bench.count = count;
|
||||||
compiled = createFunction(preprocess('t$'), interpolate(
|
if (clone.error) {
|
||||||
preprocess(
|
compiled = null;
|
||||||
(clone.error && !stringable
|
} else {
|
||||||
? 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count'
|
|
||||||
: 'function f$(){#{fn}\n}var r$,s$,m$=this,i$=m$.count'
|
|
||||||
) +
|
|
||||||
',n$=t$.ns;#{setup}\n#{begin};m$.f$=f$;while(i$--){m$.f$()}#{end};' +
|
|
||||||
'delete m$.f$;#{teardown}\nreturn{elapsed:r$}'
|
|
||||||
),
|
|
||||||
source
|
|
||||||
));
|
|
||||||
|
|
||||||
try {
|
|
||||||
// pretest one more time to check for errors
|
|
||||||
bench.count = 1;
|
|
||||||
compiled.call(bench, timer);
|
|
||||||
bench.compiled = compiled;
|
bench.compiled = compiled;
|
||||||
bench.count = count;
|
clone.error = e || new Error(String(e));
|
||||||
delete clone.error;
|
|
||||||
}
|
|
||||||
catch(e) {
|
|
||||||
bench.count = count;
|
|
||||||
if (clone.error) {
|
|
||||||
compiled = null;
|
|
||||||
} else {
|
|
||||||
bench.compiled = compiled;
|
|
||||||
clone.error = e || new Error(String(e));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3046,6 +3091,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum time a benchmark is allowed to run before finishing (secs).
|
* The maximum time a benchmark is allowed to run before finishing (secs).
|
||||||
|
*
|
||||||
* Note: Cycle delays aren't counted toward the maximum time.
|
* Note: Cycle delays aren't counted toward the maximum time.
|
||||||
*
|
*
|
||||||
* @memberOf Benchmark.options
|
* @memberOf Benchmark.options
|
||||||
@@ -3219,7 +3265,7 @@
|
|||||||
* @memberOf Benchmark
|
* @memberOf Benchmark
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
'version': '1.0.0-pre',
|
'version': '1.0.0',
|
||||||
|
|
||||||
// an object of environment/feature detection flags
|
// an object of environment/feature detection flags
|
||||||
'support': support,
|
'support': support,
|
||||||
|
|||||||
17
vendor/docdown/README.md
vendored
17
vendor/docdown/README.md
vendored
@@ -1,4 +1,4 @@
|
|||||||
# Docdown <sup>v1.0.0-pre</sup>
|
# Docdown <sup>v1.0.0</sup>
|
||||||
|
|
||||||
A simple JSDoc to Markdown documentation generator.
|
A simple JSDoc to Markdown documentation generator.
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ For a list of upcoming features, check out our [roadmap](https://github.com/jdal
|
|||||||
|
|
||||||
Usage example:
|
Usage example:
|
||||||
|
|
||||||
~~~ php
|
```php
|
||||||
require("docdown.php");
|
require("docdown.php");
|
||||||
|
|
||||||
// generate Markdown
|
// generate Markdown
|
||||||
@@ -20,18 +20,7 @@ $markdown = docdown(array(
|
|||||||
"path" => $filepath,
|
"path" => $filepath,
|
||||||
"url" => "https://github.com/username/project/blob/master/my.js"
|
"url" => "https://github.com/username/project/blob/master/my.js"
|
||||||
));
|
));
|
||||||
~~~
|
```
|
||||||
|
|
||||||
## Cloning this repo
|
|
||||||
|
|
||||||
To clone this repository just use:
|
|
||||||
|
|
||||||
~~~ bash
|
|
||||||
git clone https://github.com/docdown/docdown.git
|
|
||||||
cd docdown
|
|
||||||
~~~
|
|
||||||
|
|
||||||
Feel free to fork and send pull requests if you see improvements!
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
|
|||||||
6
vendor/docdown/src/DocDown/Entry.php
vendored
6
vendor/docdown/src/DocDown/Entry.php
vendored
@@ -140,7 +140,7 @@ class Entry {
|
|||||||
preg_match('#\*\s*@example\s+([\s\S]*?)(?=\*\s\@[a-z]|\*/)#', $this->entry, $result);
|
preg_match('#\*\s*@example\s+([\s\S]*?)(?=\*\s\@[a-z]|\*/)#', $this->entry, $result);
|
||||||
if (count($result)) {
|
if (count($result)) {
|
||||||
$result = trim(preg_replace('/(?:^|\n)\s*\* ?/', "\n", $result[1]));
|
$result = trim(preg_replace('/(?:^|\n)\s*\* ?/', "\n", $result[1]));
|
||||||
$result = '~~~ ' . $this->lang . "\n" . $result . "\n~~~";
|
$result = '```' . $this->lang . "\n" . $result . "\n```";
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ class Entry {
|
|||||||
* @returns {Array} The entry `param` data.
|
* @returns {Array} The entry `param` data.
|
||||||
*/
|
*/
|
||||||
public function getParams( $index = null ) {
|
public function getParams( $index = null ) {
|
||||||
preg_match_all('#\*\s*@param\s+\{([^}]+)\}\s+(\[[^]]+\]|[$\w]+)\s+([\s\S]*?)(?=\*\s\@[a-z]|\*/)#i', $this->entry, $result);
|
preg_match_all('#\*\s*@param\s+\{([^}]+)\}\s+(\[.+\]|[$\w|]+(?:\[.+\])?)\s+([\s\S]*?)(?=\*\s\@[a-z]|\*/)#i', $this->entry, $result);
|
||||||
if (count($result = array_filter(array_slice($result, 1)))) {
|
if (count($result = array_filter(array_slice($result, 1)))) {
|
||||||
// repurpose array
|
// repurpose array
|
||||||
foreach ($result as $param) {
|
foreach ($result as $param) {
|
||||||
@@ -204,7 +204,7 @@ class Entry {
|
|||||||
if (!is_array($result[0][$key])) {
|
if (!is_array($result[0][$key])) {
|
||||||
$result[0][$key] = array();
|
$result[0][$key] = array();
|
||||||
}
|
}
|
||||||
$result[0][$key][] = trim(preg_replace('/(?:^|\n)\s*\* ?/', ' ', $value));
|
$result[0][$key][] = trim(preg_replace('/(?:^|\n)\s*\* */', ' ', $value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result = $result[0];
|
$result = $result[0];
|
||||||
|
|||||||
10
vendor/docdown/src/DocDown/Generator.php
vendored
10
vendor/docdown/src/DocDown/Generator.php
vendored
@@ -208,6 +208,7 @@ class Generator {
|
|||||||
$openTag = "\n<!-- div -->\n";
|
$openTag = "\n<!-- div -->\n";
|
||||||
$closeTag = "\n<!-- /div -->\n";
|
$closeTag = "\n<!-- /div -->\n";
|
||||||
$result = array('# ' . $this->options['title']);
|
$result = array('# ' . $this->options['title']);
|
||||||
|
$toc = 'toc';
|
||||||
|
|
||||||
// initialize $api array
|
// initialize $api array
|
||||||
foreach ($this->entries as $entry) {
|
foreach ($this->entries as $entry) {
|
||||||
@@ -304,10 +305,15 @@ class Generator {
|
|||||||
|
|
||||||
$compiling = $compiling ? ($result[] = $closeTag) : true;
|
$compiling = $compiling ? ($result[] = $closeTag) : true;
|
||||||
|
|
||||||
|
// assign TOC hash
|
||||||
|
if (count($result) == 2) {
|
||||||
|
$toc = $member;
|
||||||
|
}
|
||||||
|
|
||||||
// add root entry
|
// add root entry
|
||||||
array_push(
|
array_push(
|
||||||
$result,
|
$result,
|
||||||
$openTag, '## ' . (count($result) == 2 ? '<a id="toc"></a>' : '') . '`' . $member . '`',
|
$openTag, '## ' . (count($result) == 2 ? '<a id="' . $toc . '"></a>' : '') . '`' . $member . '`',
|
||||||
Generator::interpolate('* [`' . $member . '`](##{hash})', $entry)
|
Generator::interpolate('* [`' . $member . '`](##{hash})', $entry)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -401,7 +407,7 @@ class Generator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// close tags add TOC link reference
|
// close tags add TOC link reference
|
||||||
array_push($result, $closeTag, $closeTag, '', ' [1]: #toc "Jump back to the TOC."');
|
array_push($result, $closeTag, $closeTag, '', ' [1]: #' . $toc . ' "Jump back to the TOC."');
|
||||||
|
|
||||||
// cleanup whitespace
|
// cleanup whitespace
|
||||||
return trim(preg_replace('/ +\n/', "\n", join($result, "\n")));
|
return trim(preg_replace('/ +\n/', "\n", join($result, "\n")));
|
||||||
|
|||||||
37
vendor/platform.js/README.md
vendored
37
vendor/platform.js/README.md
vendored
@@ -1,4 +1,4 @@
|
|||||||
# Platform.js <sup>v1.0.0-pre</sup>
|
# Platform.js <sup>v1.0.0</sup>
|
||||||
|
|
||||||
A platform detection library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>.
|
A platform detection library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>.
|
||||||
|
|
||||||
@@ -16,35 +16,39 @@ The documentation for Platform.js can be viewed here: [/doc/README.md](https://g
|
|||||||
|
|
||||||
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/platform.js/wiki/Roadmap).
|
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/platform.js/wiki/Roadmap).
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Platform.js has been tested in at least Adobe AIR 3.1, Chrome 5-21, Firefox 1-14, IE 6-9, Opera 9.25-12, Safari 3-6, Node.js 0.8.6, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5.
|
||||||
|
|
||||||
## Installation and usage
|
## Installation and usage
|
||||||
|
|
||||||
In a browser or Adobe AIR:
|
In a browser or Adobe AIR:
|
||||||
|
|
||||||
~~~ html
|
```html
|
||||||
<script src="platform.js"></script>
|
<script src="platform.js"></script>
|
||||||
~~~
|
```
|
||||||
|
|
||||||
Via [npm](http://npmjs.org/):
|
Via [npm](http://npmjs.org/):
|
||||||
|
|
||||||
~~~ bash
|
```bash
|
||||||
npm install platform
|
npm install platform
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In [Narwhal](http://narwhaljs.org/), [Node.js](http://nodejs.org/), and [RingoJS](http://ringojs.org/):
|
In [Node.js](http://nodejs.org/) and [RingoJS](http://ringojs.org/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
var platform = require('platform');
|
var platform = require('platform');
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In [Rhino](http://www.mozilla.org/rhino/):
|
In [Rhino](http://www.mozilla.org/rhino/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
load('platform.js');
|
load('platform.js');
|
||||||
~~~
|
```
|
||||||
|
|
||||||
In an AMD loader like [RequireJS](http://requirejs.org/):
|
In an AMD loader like [RequireJS](http://requirejs.org/):
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
require({
|
require({
|
||||||
'paths': {
|
'paths': {
|
||||||
'platform': 'path/to/platform'
|
'platform': 'path/to/platform'
|
||||||
@@ -53,11 +57,11 @@ require({
|
|||||||
['platform'], function(platform) {
|
['platform'], function(platform) {
|
||||||
console.log(platform.name);
|
console.log(platform.name);
|
||||||
});
|
});
|
||||||
~~~
|
```
|
||||||
|
|
||||||
Usage example:
|
Usage example:
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
// on IE10 x86 platform preview running in IE7 compatibility mode on Windows 7 64 bit edition
|
// on IE10 x86 platform preview running in IE7 compatibility mode on Windows 7 64 bit edition
|
||||||
platform.name; // 'IE'
|
platform.name; // 'IE'
|
||||||
platform.version; // '10.0'
|
platform.version; // '10.0'
|
||||||
@@ -81,12 +85,7 @@ info.version; // '11.52'
|
|||||||
info.layout; // 'Presto'
|
info.layout; // 'Presto'
|
||||||
info.os; // 'Mac OS X 10.7.2'
|
info.os; // 'Mac OS X 10.7.2'
|
||||||
info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2'
|
info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2'
|
||||||
~~~
|
```
|
||||||
|
|
||||||
## Footnotes
|
|
||||||
|
|
||||||
1. Platform.js has been tested in at least Adobe AIR 2.6, Chrome 5-15, Firefox 1.5-8, IE 6-10, Opera 9.25-11.52, Safari 2-5.1.1, Node.js 0.4.8-0.6.1, Narwhal 0.3.2, RingoJS 0.7-0.8, and Rhino 1.7RC3.
|
|
||||||
<a name="fn1" title="Jump back to footnote 1 in the text." href="#fnref1">↩</a>
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
|
|||||||
104
vendor/platform.js/platform.js
vendored
104
vendor/platform.js/platform.js
vendored
@@ -1,5 +1,5 @@
|
|||||||
/*!
|
/*!
|
||||||
* Platform.js v1.0.0-pre <http://mths.be/platform>
|
* Platform.js v1.0.0 <http://mths.be/platform>
|
||||||
* Copyright 2010-2012 John-David Dalton <http://allyoucanleet.com/>
|
* Copyright 2010-2012 John-David Dalton <http://allyoucanleet.com/>
|
||||||
* Available under MIT license <http://mths.be/mit>
|
* Available under MIT license <http://mths.be/mit>
|
||||||
*/
|
*/
|
||||||
@@ -297,7 +297,7 @@
|
|||||||
'Opera Mini',
|
'Opera Mini',
|
||||||
'Opera',
|
'Opera',
|
||||||
'Chrome',
|
'Chrome',
|
||||||
{ 'label': 'Chrome Mobile', 'pattern': 'CrMo' },
|
{ 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
|
||||||
{ 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
|
{ 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
|
||||||
{ 'label': 'IE', 'pattern': 'MSIE' },
|
{ 'label': 'IE', 'pattern': 'MSIE' },
|
||||||
'Safari'
|
'Safari'
|
||||||
@@ -512,12 +512,11 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return platform description when the platform object is coerced to a string.
|
* Returns `platform.description` when the platform object is coerced to a string.
|
||||||
*
|
*
|
||||||
* @name toString
|
* @name toString
|
||||||
* @memberOf platform
|
* @memberOf platform
|
||||||
* @type Function
|
* @returns {String} Returns `platform.description` if available, else an empty string.
|
||||||
* @returns {String} The platform description.
|
|
||||||
*/
|
*/
|
||||||
function toStringPlatform() {
|
function toStringPlatform() {
|
||||||
return this.description || '';
|
return this.description || '';
|
||||||
@@ -573,7 +572,7 @@
|
|||||||
// detect non-Opera versions (order is important)
|
// detect non-Opera versions (order is important)
|
||||||
if (!version) {
|
if (!version) {
|
||||||
version = getVersion([
|
version = getVersion([
|
||||||
'(?:Cloud9|CrMo|Opera ?Mini|Raven|Silk(?!/[\\d.]+$))',
|
'(?:Cloud9|CriOS|CrMo|Opera ?Mini|Raven|Silk(?!/[\\d.]+$))',
|
||||||
'Version',
|
'Version',
|
||||||
qualify(name),
|
qualify(name),
|
||||||
'(?:Firefox|Minefield|NetFront)'
|
'(?:Firefox|Minefield|NetFront)'
|
||||||
@@ -708,7 +707,7 @@
|
|||||||
))
|
))
|
||||||
) && !reOpera.test(data = parse.call(forOwn, ua.replace(reOpera, '') + ';')) && data.name) {
|
) && !reOpera.test(data = parse.call(forOwn, ua.replace(reOpera, '') + ';')) && data.name) {
|
||||||
|
|
||||||
// when "indentifying" the UA contains both Opera and the other browser's name
|
// when "indentifying", the UA contains both Opera and the other browser's name
|
||||||
data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
|
data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
|
||||||
if (reOpera.test(name)) {
|
if (reOpera.test(name)) {
|
||||||
if (/IE/.test(data) && os == 'Mac OS') {
|
if (/IE/.test(data) && os == 'Mac OS') {
|
||||||
@@ -716,7 +715,7 @@
|
|||||||
}
|
}
|
||||||
data = 'identify' + data;
|
data = 'identify' + data;
|
||||||
}
|
}
|
||||||
// when "masking" the UA contains only the other browser's name
|
// when "masking", the UA contains only the other browser's name
|
||||||
else {
|
else {
|
||||||
data = 'mask' + data;
|
data = 'mask' + data;
|
||||||
if (operaClass) {
|
if (operaClass) {
|
||||||
@@ -760,7 +759,7 @@
|
|||||||
data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : '5');
|
data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : '5');
|
||||||
} else {
|
} else {
|
||||||
layout[1] = 'like Chrome';
|
layout[1] = 'like Chrome';
|
||||||
data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 535.21 ? 18 : '19');
|
data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : '21');
|
||||||
}
|
}
|
||||||
// add the postfix of ".x" or "+" for approximate versions
|
// add the postfix of ".x" or "+" for approximate versions
|
||||||
layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+');
|
layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+');
|
||||||
@@ -769,6 +768,30 @@
|
|||||||
version = data;
|
version = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// detect Opera desktop modes
|
||||||
|
if (name == 'Opera' && (data = /(?:zbov|zvav)$/.exec(os))) {
|
||||||
|
name += ' ';
|
||||||
|
description.unshift('desktop mode');
|
||||||
|
if (data == 'zvav') {
|
||||||
|
name += 'Mini';
|
||||||
|
version = null;
|
||||||
|
} else {
|
||||||
|
name += 'Mobile';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// detect Chrome desktop mode
|
||||||
|
else if (name == 'Safari' && /Chrome/.exec(layout[1])) {
|
||||||
|
description.unshift('desktop mode');
|
||||||
|
name = 'Chrome Mobile';
|
||||||
|
version = null;
|
||||||
|
|
||||||
|
if (/Mac OS X/.test(os)) {
|
||||||
|
manufacturer = 'Apple';
|
||||||
|
os = 'iOS 4.3+';
|
||||||
|
} else {
|
||||||
|
os = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
// strip incorrect OS versions
|
// strip incorrect OS versions
|
||||||
if (version && version.indexOf(data = /[\d.]+$/.exec(os)) == 0 &&
|
if (version && version.indexOf(data = /[\d.]+$/.exec(os)) == 0 &&
|
||||||
ua.indexOf('/' + data + '-') > -1) {
|
ua.indexOf('/' + data + '-') > -1) {
|
||||||
@@ -793,9 +816,25 @@
|
|||||||
if (product) {
|
if (product) {
|
||||||
description.push((/^on /.test(description[description.length -1]) ? '' : 'on ') + product);
|
description.push((/^on /.test(description[description.length -1]) ? '' : 'on ') + product);
|
||||||
}
|
}
|
||||||
|
// parse OS into an object
|
||||||
|
if (os) {
|
||||||
|
data = / ([\d.+]+)$/.exec(os);
|
||||||
|
os = {
|
||||||
|
'architecture': 32,
|
||||||
|
'family': data ? os.replace(data[0], '') : os,
|
||||||
|
'version': data ? data[1] : null,
|
||||||
|
'toString': function() {
|
||||||
|
var version = this.version;
|
||||||
|
return this.family + (version ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
// add browser/OS architecture
|
// add browser/OS architecture
|
||||||
if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i).test(arch) && !/\bi686\b/i.test(arch)) {
|
if ((data = / (?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) {
|
||||||
os = os && os + (data.test(os) ? '' : ' 64-bit');
|
if (os) {
|
||||||
|
os.architecture = 64;
|
||||||
|
os.family = os.family.replace(data, '');
|
||||||
|
}
|
||||||
if (name && (/WOW64/i.test(ua) ||
|
if (name && (/WOW64/i.test(ua) ||
|
||||||
(useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform)))) {
|
(useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform)))) {
|
||||||
description.unshift('32-bit');
|
description.unshift('32-bit');
|
||||||
@@ -834,11 +873,46 @@
|
|||||||
* The name of the operating system.
|
* The name of the operating system.
|
||||||
*
|
*
|
||||||
* @memberOf platform
|
* @memberOf platform
|
||||||
* @type String|Null
|
* @type Object
|
||||||
*/
|
*/
|
||||||
'os': os && (name &&
|
'os': os
|
||||||
!(os == os.split(' ')[0] && (os == name.split(' ')[0] || product)) &&
|
? (name &&
|
||||||
description.push(product ? '(' + os + ')' : 'on ' + os), os),
|
!(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product)) &&
|
||||||
|
description.push(product ? '(' + os + ')' : 'on ' + os), os)
|
||||||
|
: {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CPU architecture the OS is built for.
|
||||||
|
*
|
||||||
|
* @memberOf platform.os
|
||||||
|
* @type String|Null
|
||||||
|
*/
|
||||||
|
'architecture': null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The family of the OS.
|
||||||
|
*
|
||||||
|
* @memberOf platform.os
|
||||||
|
* @type String|Null
|
||||||
|
*/
|
||||||
|
'family': null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version of the OS.
|
||||||
|
*
|
||||||
|
* @memberOf platform.os
|
||||||
|
* @type String|Null
|
||||||
|
*/
|
||||||
|
'version': null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the OS string.
|
||||||
|
*
|
||||||
|
* @memberOf platform.os
|
||||||
|
* @returns {String} The OS string.
|
||||||
|
*/
|
||||||
|
'toString': function() { return 'null'; }
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The platform description.
|
* The platform description.
|
||||||
|
|||||||
28
vendor/qunit-clib/README.md
vendored
28
vendor/qunit-clib/README.md
vendored
@@ -1,15 +1,19 @@
|
|||||||
# QUnit CLIB <sup>v1.0.0-pre</sup>
|
# QUnit CLIB <sup>v1.0.0</sup>
|
||||||
## command-line interface boilerplate
|
## command-line interface boilerplate
|
||||||
|
|
||||||
QUnit CLIB helps extend QUnit's CLI support to many common CLI environments<sup><a name="fnref1" href="#fn1">1</a></sup>.
|
QUnit CLIB helps extend QUnit's CLI support to many common CLI environments.
|
||||||
|
|
||||||
## Screenshot
|
## Screenshot
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
QUnit CLIB has been tested in at least Node.js 0.4.8-0.8.6, Narwhal v0.3.2, RingoJS v0.8.0, and Rhino v1.7RC3-RC5.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
~~~ js
|
```js
|
||||||
(function(window) {
|
(function(window) {
|
||||||
|
|
||||||
// use a single load function
|
// use a single load function
|
||||||
@@ -39,25 +43,13 @@ QUnit CLIB helps extend QUnit's CLI support to many common CLI environments<sup>
|
|||||||
QUnit.start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
}(typeof global == 'object' && global || this));
|
}(typeof global == 'object' && global || this));
|
||||||
~~~
|
```
|
||||||
|
|
||||||
## Cloning this repo
|
|
||||||
|
|
||||||
To clone this repository just use:
|
|
||||||
|
|
||||||
~~~ bash
|
|
||||||
git clone https://github.com/jdalton/qunit-clib.git
|
|
||||||
cd qunit-clib
|
|
||||||
~~~
|
|
||||||
|
|
||||||
Feel free to fork and send pull requests if you see improvements!
|
|
||||||
|
|
||||||
## Footnotes
|
## Footnotes
|
||||||
|
|
||||||
1. QUnit CLIB has been tested in at least Node.js v0.4.8-0.6.1, Narwhal v0.3.2, RingoJS v0.7.0-0.8.0, and Rhino v1.7RC3.
|
1. QUnit v1.3.0 does not work with Narwhal or Ringo < v0.8.0
|
||||||
<a name="fn1" title="Jump back to footnote 1 in the text." href="#fnref1">↩</a>
|
|
||||||
|
|
||||||
2. QUnit v1.3.0 does not work with Narwhal or Ringo < v0.8.0
|
2. Rhino v1.7RC4 does not support timeout fallbacks `clearTimeout` and `setTimeout`
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
|
|||||||
4
vendor/qunit-clib/qunit-clib.js
vendored
4
vendor/qunit-clib/qunit-clib.js
vendored
@@ -1,5 +1,5 @@
|
|||||||
/*!
|
/*!
|
||||||
* QUnit CLI Boilerplate v1.0.0-pre
|
* QUnit CLI Boilerplate v1.0.0
|
||||||
* Copyright 2011-2012 John-David Dalton <http://allyoucanleet.com/>
|
* Copyright 2011-2012 John-David Dalton <http://allyoucanleet.com/>
|
||||||
* Based on a gist by Jörn Zaefferer <https://gist.github.com/722381>
|
* Based on a gist by Jörn Zaefferer <https://gist.github.com/722381>
|
||||||
* Available under MIT license <http://mths.be/mit>
|
* Available under MIT license <http://mths.be/mit>
|
||||||
@@ -92,6 +92,8 @@
|
|||||||
* @returns {Number} The the ID of the timeout.
|
* @returns {Number} The the ID of the timeout.
|
||||||
*/
|
*/
|
||||||
function schedule(fn, delay, args, repeated) {
|
function schedule(fn, delay, args, repeated) {
|
||||||
|
// Rhino 1.7RC4 will error assigning `task` below
|
||||||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=775566
|
||||||
var task = ids[++counter] = new JavaAdapter(java.util.TimerTask, {
|
var task = ids[++counter] = new JavaAdapter(java.util.TimerTask, {
|
||||||
'run': function() {
|
'run': function() {
|
||||||
fn.apply(global, args);
|
fn.apply(global, args);
|
||||||
|
|||||||
227
vendor/requirejs/require.js
vendored
227
vendor/requirejs/require.js
vendored
@@ -1,21 +1,25 @@
|
|||||||
/** vim: et:ts=4:sw=4:sts=4
|
/** vim: et:ts=4:sw=4:sts=4
|
||||||
* @license RequireJS 2.0.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
* @license RequireJS 2.0.6 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
||||||
* Available via the MIT or new BSD license.
|
* Available via the MIT or new BSD license.
|
||||||
* see: http://github.com/jrburke/requirejs for details
|
* see: http://github.com/jrburke/requirejs for details
|
||||||
*/
|
*/
|
||||||
/*jslint regexp: true, nomen: true */
|
//Not using strict: uneven strict support in browsers, #392, and causes
|
||||||
|
//problems with requirejs.exec()/transpiler plugins that may not be strict.
|
||||||
|
/*jslint regexp: true, nomen: true, sloppy: true */
|
||||||
/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */
|
/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */
|
||||||
|
|
||||||
var requirejs, require, define;
|
var requirejs, require, define;
|
||||||
(function (global) {
|
(function (global) {
|
||||||
'use strict';
|
var req, s, head, baseElement, dataMain, src,
|
||||||
|
interactiveScript, currentlyAddingScript, mainScript, subPath,
|
||||||
var version = '2.0.4',
|
version = '2.0.6',
|
||||||
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
||||||
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
|
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
|
||||||
jsSuffixRegExp = /\.js$/,
|
jsSuffixRegExp = /\.js$/,
|
||||||
currDirRegExp = /^\.\//,
|
currDirRegExp = /^\.\//,
|
||||||
ostring = Object.prototype.toString,
|
op = Object.prototype,
|
||||||
|
ostring = op.toString,
|
||||||
|
hasOwn = op.hasOwnProperty,
|
||||||
ap = Array.prototype,
|
ap = Array.prototype,
|
||||||
aps = ap.slice,
|
aps = ap.slice,
|
||||||
apsp = ap.splice,
|
apsp = ap.splice,
|
||||||
@@ -33,9 +37,7 @@ var requirejs, require, define;
|
|||||||
contexts = {},
|
contexts = {},
|
||||||
cfg = {},
|
cfg = {},
|
||||||
globalDefQueue = [],
|
globalDefQueue = [],
|
||||||
useInteractive = false,
|
useInteractive = false;
|
||||||
req, s, head, baseElement, dataMain, src,
|
|
||||||
interactiveScript, currentlyAddingScript, mainScript, subPath;
|
|
||||||
|
|
||||||
function isFunction(it) {
|
function isFunction(it) {
|
||||||
return ostring.call(it) === '[object Function]';
|
return ostring.call(it) === '[object Function]';
|
||||||
@@ -76,7 +78,7 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hasProp(obj, prop) {
|
function hasProp(obj, prop) {
|
||||||
return obj.hasOwnProperty(prop);
|
return hasOwn.call(obj, prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,7 +154,7 @@ var requirejs, require, define;
|
|||||||
//look up paths relative to the moduleName
|
//look up paths relative to the moduleName
|
||||||
var args = aps.call(arguments, 0), lastArg;
|
var args = aps.call(arguments, 0), lastArg;
|
||||||
if (enableBuildCallback &&
|
if (enableBuildCallback &&
|
||||||
isFunction((lastArg = args[args.length - 1]))) {
|
isFunction((lastArg = args[args.length - 1]))) {
|
||||||
lastArg.__requireJsBuild = true;
|
lastArg.__requireJsBuild = true;
|
||||||
}
|
}
|
||||||
args.push(relMap);
|
args.push(relMap);
|
||||||
@@ -169,14 +171,14 @@ var requirejs, require, define;
|
|||||||
], function (item) {
|
], function (item) {
|
||||||
var prop = item[1] || item[0];
|
var prop = item[1] || item[0];
|
||||||
req[item[0]] = context ? makeContextModuleFunc(context[prop], relMap) :
|
req[item[0]] = context ? makeContextModuleFunc(context[prop], relMap) :
|
||||||
//If no context, then use default context. Reference from
|
//If no context, then use default context. Reference from
|
||||||
//contexts instead of early binding to default context, so
|
//contexts instead of early binding to default context, so
|
||||||
//that during builds, the latest instance of the default
|
//that during builds, the latest instance of the default
|
||||||
//context with its config gets used.
|
//context with its config gets used.
|
||||||
function () {
|
function () {
|
||||||
var ctx = contexts[defContextName];
|
var ctx = contexts[defContextName];
|
||||||
return ctx[prop].apply(ctx, arguments);
|
return ctx[prop].apply(ctx, arguments);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +223,9 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function newContext(contextName) {
|
function newContext(contextName) {
|
||||||
var config = {
|
var inCheckLoaded, Module, context, handlers,
|
||||||
|
checkLoadedTimeoutId,
|
||||||
|
config = {
|
||||||
waitSeconds: 7,
|
waitSeconds: 7,
|
||||||
baseUrl: './',
|
baseUrl: './',
|
||||||
paths: {},
|
paths: {},
|
||||||
@@ -239,9 +243,7 @@ var requirejs, require, define;
|
|||||||
//should be executed, by the order they
|
//should be executed, by the order they
|
||||||
//load. Important for consistent cycle resolution
|
//load. Important for consistent cycle resolution
|
||||||
//behavior.
|
//behavior.
|
||||||
waitAry = [],
|
waitAry = [];
|
||||||
inCheckLoaded, Module, context, handlers,
|
|
||||||
checkLoadedTimeoutId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trims the . and .. from an array of path segments.
|
* Trims the . and .. from an array of path segments.
|
||||||
@@ -254,7 +256,7 @@ var requirejs, require, define;
|
|||||||
*/
|
*/
|
||||||
function trimDots(ary) {
|
function trimDots(ary) {
|
||||||
var i, part;
|
var i, part;
|
||||||
for (i = 0; ary[i]; i+= 1) {
|
for (i = 0; ary[i]; i += 1) {
|
||||||
part = ary[i];
|
part = ary[i];
|
||||||
if (part === '.') {
|
if (part === '.') {
|
||||||
ary.splice(i, 1);
|
ary.splice(i, 1);
|
||||||
@@ -287,12 +289,12 @@ var requirejs, require, define;
|
|||||||
* @returns {String} normalized name
|
* @returns {String} normalized name
|
||||||
*/
|
*/
|
||||||
function normalize(name, baseName, applyMap) {
|
function normalize(name, baseName, applyMap) {
|
||||||
var baseParts = baseName && baseName.split('/'),
|
var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
|
||||||
|
foundMap, foundI, foundStarMap, starI,
|
||||||
|
baseParts = baseName && baseName.split('/'),
|
||||||
normalizedBaseParts = baseParts,
|
normalizedBaseParts = baseParts,
|
||||||
map = config.map,
|
map = config.map,
|
||||||
starMap = map && map['*'],
|
starMap = map && map['*'];
|
||||||
pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
|
|
||||||
foundMap;
|
|
||||||
|
|
||||||
//Adjust any relative paths.
|
//Adjust any relative paths.
|
||||||
if (name && name.charAt(0) === '.') {
|
if (name && name.charAt(0) === '.') {
|
||||||
@@ -343,28 +345,41 @@ var requirejs, require, define;
|
|||||||
for (j = baseParts.length; j > 0; j -= 1) {
|
for (j = baseParts.length; j > 0; j -= 1) {
|
||||||
mapValue = map[baseParts.slice(0, j).join('/')];
|
mapValue = map[baseParts.slice(0, j).join('/')];
|
||||||
|
|
||||||
//baseName segment has config, find if it has one for
|
//baseName segment has config, find if it has one for
|
||||||
//this name.
|
//this name.
|
||||||
if (mapValue) {
|
if (mapValue) {
|
||||||
mapValue = mapValue[nameSegment];
|
mapValue = mapValue[nameSegment];
|
||||||
if (mapValue) {
|
if (mapValue) {
|
||||||
//Match, update name to the new value.
|
//Match, update name to the new value.
|
||||||
foundMap = mapValue;
|
foundMap = mapValue;
|
||||||
|
foundI = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundMap && starMap && starMap[nameSegment]) {
|
|
||||||
foundMap = starMap[nameSegment];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (foundMap) {
|
if (foundMap) {
|
||||||
nameParts.splice(0, i, foundMap);
|
|
||||||
name = nameParts.join('/');
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check for a star map match, but just hold on to it,
|
||||||
|
//if there is a shorter segment match later in a matching
|
||||||
|
//config, then favor over this star map.
|
||||||
|
if (!foundStarMap && starMap && starMap[nameSegment]) {
|
||||||
|
foundStarMap = starMap[nameSegment];
|
||||||
|
starI = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundMap && foundStarMap) {
|
||||||
|
foundMap = foundStarMap;
|
||||||
|
foundI = starI;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundMap) {
|
||||||
|
nameParts.splice(0, foundI, foundMap);
|
||||||
|
name = nameParts.join('/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +390,7 @@ var requirejs, require, define;
|
|||||||
if (isBrowser) {
|
if (isBrowser) {
|
||||||
each(scripts(), function (scriptNode) {
|
each(scripts(), function (scriptNode) {
|
||||||
if (scriptNode.getAttribute('data-requiremodule') === name &&
|
if (scriptNode.getAttribute('data-requiremodule') === name &&
|
||||||
scriptNode.getAttribute('data-requirecontext') === context.contextName) {
|
scriptNode.getAttribute('data-requirecontext') === context.contextName) {
|
||||||
scriptNode.parentNode.removeChild(scriptNode);
|
scriptNode.parentNode.removeChild(scriptNode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -412,13 +427,13 @@ var requirejs, require, define;
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
|
function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
|
||||||
var index = name ? name.indexOf('!') : -1,
|
var url, pluginModule, suffix,
|
||||||
|
index = name ? name.indexOf('!') : -1,
|
||||||
prefix = null,
|
prefix = null,
|
||||||
parentName = parentModuleMap ? parentModuleMap.name : null,
|
parentName = parentModuleMap ? parentModuleMap.name : null,
|
||||||
originalName = name,
|
originalName = name,
|
||||||
isDefine = true,
|
isDefine = true,
|
||||||
normalizedName = '',
|
normalizedName = '';
|
||||||
url, pluginModule, suffix;
|
|
||||||
|
|
||||||
//If no name, then it means it is a require call, generate an
|
//If no name, then it means it is a require call, generate an
|
||||||
//internal name.
|
//internal name.
|
||||||
@@ -471,8 +486,8 @@ var requirejs, require, define;
|
|||||||
originalName: originalName,
|
originalName: originalName,
|
||||||
isDefine: isDefine,
|
isDefine: isDefine,
|
||||||
id: (prefix ?
|
id: (prefix ?
|
||||||
prefix + '!' + normalizedName :
|
prefix + '!' + normalizedName :
|
||||||
normalizedName) + suffix
|
normalizedName) + suffix
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,7 +507,7 @@ var requirejs, require, define;
|
|||||||
mod = registry[id];
|
mod = registry[id];
|
||||||
|
|
||||||
if (hasProp(defined, id) &&
|
if (hasProp(defined, id) &&
|
||||||
(!mod || mod.defineEmitComplete)) {
|
(!mod || mod.defineEmitComplete)) {
|
||||||
if (name === 'defined') {
|
if (name === 'defined') {
|
||||||
fn(defined[id]);
|
fn(defined[id]);
|
||||||
}
|
}
|
||||||
@@ -597,7 +612,7 @@ var requirejs, require, define;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function findCycle(mod, traced) {
|
function findCycle(mod, traced, processed) {
|
||||||
var id = mod.map.id,
|
var id = mod.map.id,
|
||||||
depArray = mod.depMaps,
|
depArray = mod.depMaps,
|
||||||
foundModule;
|
foundModule;
|
||||||
@@ -620,28 +635,16 @@ var requirejs, require, define;
|
|||||||
var depId = depMap.id,
|
var depId = depMap.id,
|
||||||
depMod = registry[depId];
|
depMod = registry[depId];
|
||||||
|
|
||||||
if (!depMod) {
|
if (!depMod || processed[depId] ||
|
||||||
|
!depMod.inited || !depMod.enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!depMod.inited || !depMod.enabled) {
|
return (foundModule = findCycle(depMod, traced, processed));
|
||||||
//Dependency is not inited, so this cannot
|
|
||||||
//be used to determine a cycle.
|
|
||||||
foundModule = null;
|
|
||||||
delete traced[id];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//mixin traced to a new object for each dependency, so that
|
|
||||||
//sibling dependencies in this object to not generate a
|
|
||||||
//false positive match on a cycle. Ideally an Object.create
|
|
||||||
//type of prototype delegation would be used here, but
|
|
||||||
//optimizing for file size vs. execution speed since hopefully
|
|
||||||
//the trees are small for circular dependency scans relative
|
|
||||||
//to the full app perf.
|
|
||||||
return (foundModule = findCycle(depMod, mixin({}, traced)));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
processed[id] = true;
|
||||||
|
|
||||||
return foundModule;
|
return foundModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,7 +662,7 @@ var requirejs, require, define;
|
|||||||
|
|
||||||
traced[id] = mod;
|
traced[id] = mod;
|
||||||
|
|
||||||
each(depArray, function(depMap) {
|
each(depArray, function (depMap) {
|
||||||
var depId = depMap.id,
|
var depId = depMap.id,
|
||||||
depMod = registry[depId],
|
depMod = registry[depId],
|
||||||
value;
|
value;
|
||||||
@@ -699,13 +702,13 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkLoaded() {
|
function checkLoaded() {
|
||||||
var waitInterval = config.waitSeconds * 1000,
|
var map, modId, err, usingPathFallback,
|
||||||
|
waitInterval = config.waitSeconds * 1000,
|
||||||
//It is possible to disable the wait interval by using waitSeconds of 0.
|
//It is possible to disable the wait interval by using waitSeconds of 0.
|
||||||
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
|
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
|
||||||
noLoads = [],
|
noLoads = [],
|
||||||
stillLoading = false,
|
stillLoading = false,
|
||||||
needCycleCheck = true,
|
needCycleCheck = true;
|
||||||
map, modId, err, usingPathFallback;
|
|
||||||
|
|
||||||
//Do not bother if this call was a result of a cycle break.
|
//Do not bother if this call was a result of a cycle break.
|
||||||
if (inCheckLoaded) {
|
if (inCheckLoaded) {
|
||||||
@@ -764,7 +767,7 @@ var requirejs, require, define;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cycleMod = findCycle(mod, {}),
|
var cycleMod = findCycle(mod, {}, {}),
|
||||||
traced = {};
|
traced = {};
|
||||||
|
|
||||||
if (cycleMod) {
|
if (cycleMod) {
|
||||||
@@ -819,7 +822,7 @@ var requirejs, require, define;
|
|||||||
};
|
};
|
||||||
|
|
||||||
Module.prototype = {
|
Module.prototype = {
|
||||||
init: function(depMaps, factory, errback, options) {
|
init: function (depMaps, factory, errback, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
//Do not do more inits if already done. Can happen if there
|
//Do not do more inits if already done. Can happen if there
|
||||||
@@ -916,7 +919,7 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
load: function() {
|
load: function () {
|
||||||
var url = this.map.url;
|
var url = this.map.url;
|
||||||
|
|
||||||
//Regular dependency.
|
//Regular dependency.
|
||||||
@@ -937,11 +940,11 @@ var requirejs, require, define;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var id = this.map.id,
|
var err, cjsModule,
|
||||||
|
id = this.map.id,
|
||||||
depExports = this.depExports,
|
depExports = this.depExports,
|
||||||
exports = this.exports,
|
exports = this.exports,
|
||||||
factory = this.factory,
|
factory = this.factory;
|
||||||
err, cjsModule;
|
|
||||||
|
|
||||||
if (!this.inited) {
|
if (!this.inited) {
|
||||||
this.fetch();
|
this.fetch();
|
||||||
@@ -974,9 +977,9 @@ var requirejs, require, define;
|
|||||||
//favor a non-undefined return value over exports use.
|
//favor a non-undefined return value over exports use.
|
||||||
cjsModule = this.module;
|
cjsModule = this.module;
|
||||||
if (cjsModule &&
|
if (cjsModule &&
|
||||||
cjsModule.exports !== undefined &&
|
cjsModule.exports !== undefined &&
|
||||||
//Make sure it is not already the exports value
|
//Make sure it is not already the exports value
|
||||||
cjsModule.exports !== this.exports) {
|
cjsModule.exports !== this.exports) {
|
||||||
exports = cjsModule.exports;
|
exports = cjsModule.exports;
|
||||||
} else if (exports === undefined && this.usingExports) {
|
} else if (exports === undefined && this.usingExports) {
|
||||||
//exports already set the defined value.
|
//exports already set the defined value.
|
||||||
@@ -1032,15 +1035,15 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
callPlugin: function() {
|
callPlugin: function () {
|
||||||
var map = this.map,
|
var map = this.map,
|
||||||
id = map.id,
|
id = map.id,
|
||||||
pluginMap = makeModuleMap(map.prefix, null, false, true);
|
pluginMap = makeModuleMap(map.prefix, null, false, true);
|
||||||
|
|
||||||
on(pluginMap, 'defined', bind(this, function (plugin) {
|
on(pluginMap, 'defined', bind(this, function (plugin) {
|
||||||
var name = this.map.name,
|
var load, normalizedMap, normalizedMod,
|
||||||
parentName = this.map.parentMap ? this.map.parentMap.name : null,
|
name = this.map.name,
|
||||||
load, normalizedMap, normalizedMod;
|
parentName = this.map.parentMap ? this.map.parentMap.name : null;
|
||||||
|
|
||||||
//If current map is not normalized, wait for that
|
//If current map is not normalized, wait for that
|
||||||
//normalized name to load instead of continuing.
|
//normalized name to load instead of continuing.
|
||||||
@@ -1057,12 +1060,12 @@ var requirejs, require, define;
|
|||||||
false,
|
false,
|
||||||
true);
|
true);
|
||||||
on(normalizedMap,
|
on(normalizedMap,
|
||||||
'defined', bind(this, function (value) {
|
'defined', bind(this, function (value) {
|
||||||
this.init([], function () { return value; }, null, {
|
this.init([], function () { return value; }, null, {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
ignore: true
|
ignore: true
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
normalizedMod = registry[normalizedMap.id];
|
normalizedMod = registry[normalizedMap.id];
|
||||||
if (normalizedMod) {
|
if (normalizedMod) {
|
||||||
if (this.events.error) {
|
if (this.events.error) {
|
||||||
@@ -1127,9 +1130,9 @@ var requirejs, require, define;
|
|||||||
//Use parentName here since the plugin's name is not reliable,
|
//Use parentName here since the plugin's name is not reliable,
|
||||||
//could be some weird string with no path that actually wants to
|
//could be some weird string with no path that actually wants to
|
||||||
//reference the parentName's path.
|
//reference the parentName's path.
|
||||||
plugin.load(map.name, makeRequire(map.parentMap, true, function (deps, cb) {
|
plugin.load(map.name, makeRequire(map.parentMap, true, function (deps, cb, er) {
|
||||||
deps.rjsSkipMap = true;
|
deps.rjsSkipMap = true;
|
||||||
return context.require(deps, cb);
|
return context.require(deps, cb, er);
|
||||||
}), load, config);
|
}), load, config);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -1209,7 +1212,7 @@ var requirejs, require, define;
|
|||||||
this.check();
|
this.check();
|
||||||
},
|
},
|
||||||
|
|
||||||
on: function(name, cb) {
|
on: function (name, cb) {
|
||||||
var cbs = this.events[name];
|
var cbs = this.events[name];
|
||||||
if (!cbs) {
|
if (!cbs) {
|
||||||
cbs = this.events[name] = [];
|
cbs = this.events[name] = [];
|
||||||
@@ -1362,7 +1365,12 @@ var requirejs, require, define;
|
|||||||
//update the maps for them, since their info, like URLs to load,
|
//update the maps for them, since their info, like URLs to load,
|
||||||
//may have changed.
|
//may have changed.
|
||||||
eachProp(registry, function (mod, id) {
|
eachProp(registry, function (mod, id) {
|
||||||
mod.map = makeModuleMap(id);
|
//If module already has init called, since it is too
|
||||||
|
//late to modify them, and ignore unnormalized ones
|
||||||
|
//since they are transient.
|
||||||
|
if (!mod.inited && !mod.map.unnormalized) {
|
||||||
|
mod.map = makeModuleMap(id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//If a deps array or a config callback is specified, then call
|
//If a deps array or a config callback is specified, then call
|
||||||
@@ -1471,6 +1479,10 @@ var requirejs, require, define;
|
|||||||
},
|
},
|
||||||
|
|
||||||
undef: function (id) {
|
undef: function (id) {
|
||||||
|
//Bind any waiting define() calls to this context,
|
||||||
|
//fix for #408
|
||||||
|
takeGlobalQueue();
|
||||||
|
|
||||||
var map = makeModuleMap(id, null, true),
|
var map = makeModuleMap(id, null, true),
|
||||||
mod = registry[id];
|
mod = registry[id];
|
||||||
|
|
||||||
@@ -1509,9 +1521,9 @@ var requirejs, require, define;
|
|||||||
* @param {String} moduleName the name of the module to potentially complete.
|
* @param {String} moduleName the name of the module to potentially complete.
|
||||||
*/
|
*/
|
||||||
completeLoad: function (moduleName) {
|
completeLoad: function (moduleName) {
|
||||||
var shim = config.shim[moduleName] || {},
|
var found, args, mod,
|
||||||
shExports = shim.exports && shim.exports.exports,
|
shim = config.shim[moduleName] || {},
|
||||||
found, args, mod;
|
shExports = shim.exports && shim.exports.exports;
|
||||||
|
|
||||||
takeGlobalQueue();
|
takeGlobalQueue();
|
||||||
|
|
||||||
@@ -1538,9 +1550,7 @@ var requirejs, require, define;
|
|||||||
//of those calls/init calls changes the registry.
|
//of those calls/init calls changes the registry.
|
||||||
mod = registry[moduleName];
|
mod = registry[moduleName];
|
||||||
|
|
||||||
if (!found &&
|
if (!found && !defined[moduleName] && mod && !mod.inited) {
|
||||||
!defined[moduleName] &&
|
|
||||||
mod && !mod.inited) {
|
|
||||||
if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
|
if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
|
||||||
if (hasPathFallback(moduleName)) {
|
if (hasPathFallback(moduleName)) {
|
||||||
return;
|
return;
|
||||||
@@ -1633,7 +1643,8 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Join the path parts together, then figure out if baseUrl is needed.
|
//Join the path parts together, then figure out if baseUrl is needed.
|
||||||
url = syms.join('/') + (ext || '.js');
|
url = syms.join('/');
|
||||||
|
url += (ext || (/\?/.test(url) ? '' : '.js'));
|
||||||
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
|
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1670,7 +1681,7 @@ var requirejs, require, define;
|
|||||||
//all old browsers will be supported, but this one was easy enough
|
//all old browsers will be supported, but this one was easy enough
|
||||||
//to support and still makes sense.
|
//to support and still makes sense.
|
||||||
if (evt.type === 'load' ||
|
if (evt.type === 'load' ||
|
||||||
(readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
|
(readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
|
||||||
//Reset interactive script so a script node is not held onto for
|
//Reset interactive script so a script node is not held onto for
|
||||||
//to long.
|
//to long.
|
||||||
interactiveScript = null;
|
interactiveScript = null;
|
||||||
@@ -1710,8 +1721,8 @@ var requirejs, require, define;
|
|||||||
req = requirejs = function (deps, callback, errback, optional) {
|
req = requirejs = function (deps, callback, errback, optional) {
|
||||||
|
|
||||||
//Find the right context, use default
|
//Find the right context, use default
|
||||||
var contextName = defContextName,
|
var context, config,
|
||||||
context, config;
|
contextName = defContextName;
|
||||||
|
|
||||||
// Determine if have config object in the call.
|
// Determine if have config object in the call.
|
||||||
if (!isArray(deps) && typeof deps !== 'string') {
|
if (!isArray(deps) && typeof deps !== 'string') {
|
||||||
@@ -1810,8 +1821,8 @@ var requirejs, require, define;
|
|||||||
if (isBrowser) {
|
if (isBrowser) {
|
||||||
//In the browser so use a script tag
|
//In the browser so use a script tag
|
||||||
node = config.xhtml ?
|
node = config.xhtml ?
|
||||||
document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
|
document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
|
||||||
document.createElement('script');
|
document.createElement('script');
|
||||||
node.type = config.scriptType || 'text/javascript';
|
node.type = config.scriptType || 'text/javascript';
|
||||||
node.charset = 'utf-8';
|
node.charset = 'utf-8';
|
||||||
node.async = true;
|
node.async = true;
|
||||||
@@ -1828,15 +1839,15 @@ var requirejs, require, define;
|
|||||||
//UNFORTUNATELY Opera implements attachEvent but does not follow the script
|
//UNFORTUNATELY Opera implements attachEvent but does not follow the script
|
||||||
//script execution mode.
|
//script execution mode.
|
||||||
if (node.attachEvent &&
|
if (node.attachEvent &&
|
||||||
//Check if node.attachEvent is artificially added by custom script or
|
//Check if node.attachEvent is artificially added by custom script or
|
||||||
//natively supported by browser
|
//natively supported by browser
|
||||||
//read https://github.com/jrburke/requirejs/issues/187
|
//read https://github.com/jrburke/requirejs/issues/187
|
||||||
//if we can NOT find [native code] then it must NOT natively supported.
|
//if we can NOT find [native code] then it must NOT natively supported.
|
||||||
//in IE8, node.attachEvent does not have toString()
|
//in IE8, node.attachEvent does not have toString()
|
||||||
//Note the test for "[native code" with no closing brace, see:
|
//Note the test for "[native code" with no closing brace, see:
|
||||||
//https://github.com/jrburke/requirejs/issues/273
|
//https://github.com/jrburke/requirejs/issues/273
|
||||||
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
|
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
|
||||||
!isOpera) {
|
!isOpera) {
|
||||||
//Probably IE. IE (at least 6-8) do not fire
|
//Probably IE. IE (at least 6-8) do not fire
|
||||||
//script onload right after executing the script, so
|
//script onload right after executing the script, so
|
||||||
//we cannot tie the anonymous define call to a name.
|
//we cannot tie the anonymous define call to a name.
|
||||||
|
|||||||
12
vendor/underscore/test/collections.js
vendored
12
vendor/underscore/test/collections.js
vendored
@@ -253,6 +253,18 @@ $(document).ready(function() {
|
|||||||
equal(grouped['5'].join(' '), 'three seven eight');
|
equal(grouped['5'].join(' '), 'three seven eight');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('collections: countBy', function() {
|
||||||
|
var parity = _.countBy([1, 2, 3, 4, 5], function(num){ return num % 2 == 0; });
|
||||||
|
equal(parity['true'], 2);
|
||||||
|
equal(parity['false'], 3);
|
||||||
|
|
||||||
|
var list = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
|
||||||
|
var grouped = _.countBy(list, 'length');
|
||||||
|
equal(grouped['3'], 4);
|
||||||
|
equal(grouped['4'], 3);
|
||||||
|
equal(grouped['5'], 3);
|
||||||
|
});
|
||||||
|
|
||||||
test('collections: sortedIndex', function() {
|
test('collections: sortedIndex', function() {
|
||||||
var numbers = [10, 20, 30, 40, 50], num = 35;
|
var numbers = [10, 20, 30, 40, 50], num = 35;
|
||||||
var indexForNum = _.sortedIndex(numbers, num);
|
var indexForNum = _.sortedIndex(numbers, num);
|
||||||
|
|||||||
18
vendor/underscore/test/objects.js
vendored
18
vendor/underscore/test/objects.js
vendored
@@ -48,6 +48,24 @@ $(document).ready(function() {
|
|||||||
ok(_.isEqual(result, {b:2, c:3}), 'can restrict properties to those named in an array');
|
ok(_.isEqual(result, {b:2, c:3}), 'can restrict properties to those named in an array');
|
||||||
result = _.pick({a:1, b:2, c:3}, ['a'], 'b');
|
result = _.pick({a:1, b:2, c:3}, ['a'], 'b');
|
||||||
ok(_.isEqual(result, {a:1, b:2}), 'can restrict properties to those named in mixed args');
|
ok(_.isEqual(result, {a:1, b:2}), 'can restrict properties to those named in mixed args');
|
||||||
|
|
||||||
|
var Obj = function(){};
|
||||||
|
Obj.prototype = {a: 1, b: 2, c: 3};
|
||||||
|
ok(_.isEqual(_.pick(new Obj, 'a', 'c'), {a:1, c: 3}), 'include prototype props');
|
||||||
|
});
|
||||||
|
|
||||||
|
test("objects: omit", function() {
|
||||||
|
var result;
|
||||||
|
result = _.omit({a:1, b:2, c:3}, 'b');
|
||||||
|
ok(_.isEqual(result, {a:1, c:3}), 'can omit a single named property');
|
||||||
|
result = _.omit({a:1, b:2, c:3}, 'a', 'c');
|
||||||
|
ok(_.isEqual(result, {b:2}), 'can omit several named properties');
|
||||||
|
result = _.omit({a:1, b:2, c:3}, ['b', 'c']);
|
||||||
|
ok(_.isEqual(result, {a:1}), 'can omit properties named in an array');
|
||||||
|
|
||||||
|
var Obj = function(){};
|
||||||
|
Obj.prototype = {a: 1, b: 2, c: 3};
|
||||||
|
ok(_.isEqual(_.omit(new Obj, 'b'), {a:1, c: 3}), 'include prototype props');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("objects: defaults", function() {
|
test("objects: defaults", function() {
|
||||||
|
|||||||
32
vendor/underscore/underscore-min.js
vendored
Normal file
32
vendor/underscore/underscore-min.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Underscore.js 1.3.3
|
||||||
|
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
||||||
|
// Underscore may be freely distributed under the MIT license.
|
||||||
|
// Portions of Underscore are inspired or borrowed from Prototype,
|
||||||
|
// Oliver Steele's Functional, and John Resig's Micro-Templating.
|
||||||
|
// For all details and documentation:
|
||||||
|
// http://documentcloud.github.com/underscore
|
||||||
|
(function(){var s=this,L=s._,o={},k=Array.prototype,p=Object.prototype,M=k.push,h=k.slice,N=k.unshift,m=p.toString,O=p.hasOwnProperty,z=k.forEach,A=k.map,B=k.reduce,C=k.reduceRight,D=k.filter,E=k.every,F=k.some,q=k.indexOf,G=k.lastIndexOf,p=Array.isArray,P=Object.keys,t=Function.prototype.bind,b=function(a){return new l(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var i=b.each=b.forEach=function(a,c,
|
||||||
|
d){if(a!=null)if(z&&a.forEach===z)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,d){var b=[];if(a==null)return b;if(A&&a.map===A)return a.map(c,d);i(a,function(a,g,j){b[b.length]=c.call(d,a,g,j)});return b};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduce===B){e&&(c=b.bind(c,e));return f?a.reduce(c,
|
||||||
|
d):a.reduce(c)}i(a,function(a,b,h){if(f)d=c.call(e,d,a,b,h);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(C&&a.reduceRight===C){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,c,b){var e;H(a,function(a,g,j){if(c.call(b,a,g,j)){e=
|
||||||
|
a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(D&&a.filter===D)return a.filter(c,b);i(a,function(a,g,j){c.call(b,a,g,j)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;i(a,function(a,g,j){c.call(b,a,g,j)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(E&&a.every===E)return a.every(c,b);i(a,function(a,g,j){if(!(e=e&&c.call(b,a,g,j)))return o});return!!e};var H=b.some=b.any=
|
||||||
|
function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(F&&a.some===F)return a.some(c,d);i(a,function(a,b,j){if(e||(e=c.call(d,a,b,j)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=H(a,function(a){return a===c})};b.invoke=function(a,c){var d=h.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c:a[c]).apply(a,d)})};b.pluck=function(a,c){return b.map(a,function(a){return a[c]})};
|
||||||
|
b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};i(a,function(a,b,j){b=c?c.call(d,a,b,j):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};i(a,function(a,b,j){b=c?c.call(d,a,b,j):a;b<e.computed&&(e={value:a,computed:b})});
|
||||||
|
return e.value};b.shuffle=function(a){var c,b=0,e=[];i(a,function(a){c=Math.floor(Math.random()*++b);e[b-1]=e[c];e[c]=a});return e};b.sortBy=function(a,c,d){var e=I(a,c);return b.pluck(b.map(a,function(a,c,b){return{value:a,criteria:e.call(d,a,c,b)}}).sort(function(a,c){var b=a.criteria,d=c.criteria;return b===void 0?1:d===void 0?-1:b<d?-1:b>d?1:0}),"value")};var I=function(a,c){return b.isFunction(c)?c:function(a){return a[c]}},J=function(a,c,b){var e={},f=I(a,c);i(a,function(a,c){var h=f(a,c);b(e,
|
||||||
|
h,a)});return e};b.groupBy=function(a,c){return J(a,c,function(a,c,b){(a[c]||(a[c]=[])).push(b)})};b.countBy=function(a,c){return J(a,c,function(a,c){a[c]||(a[c]=0);a[c]++})};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var c=d(c),e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<c?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?h.call(a):b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=
|
||||||
|
b.take=function(a,c,b){return c!=null&&!b?h.call(a,0,c):a[0]};b.initial=function(a,c,b){return h.call(a,0,a.length-(c==null||b?1:c))};b.last=function(a,c,b){return c!=null&&!b?h.call(a,Math.max(a.length-c,0)):a[a.length-1]};b.rest=b.tail=function(a,c,b){return h.call(a,c==null||b?1:c)};b.compact=function(a){return b.filter(a,function(a){return!!a})};var r=function(a,c,d){i(a,function(a){b.isArray(a)?c?M.apply(d,a):r(a,c,d):d.push(a)});return d};b.flatten=function(a,c){return r(a,c,[])};b.without=
|
||||||
|
function(a){return b.difference(a,h.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,j){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[j])}return d},[]);return e};b.union=function(){return b.uniq(r(arguments,true,[]))};b.intersection=function(a){var c=h.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=r(h.call(arguments,1),true,[]);
|
||||||
|
return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=h.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.zipObject=function(a,c){for(var b={},e=0,f=a.length;e<f;e++)b[a[e]]=c[e];return b};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(a[d]===c)return d;return-1};b.lastIndexOf=function(a,c){if(a==null)return-1;
|
||||||
|
if(G&&a.lastIndexOf===G)return a.lastIndexOf(c);for(var b=a.length;b--;)if(a[b]===c)return b;return-1};b.range=function(a,c,b){if(arguments.length<=1){c=a||0;a=0}for(var b=arguments[2]||1,e=Math.max(Math.ceil((c-a)/b),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+b}return g};var K=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,h.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=h.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(h.call(arguments)));
|
||||||
|
K.prototype=a.prototype;var b=new K,g=a.apply(b,e.concat(h.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=h.call(arguments,1);c.length==0&&(c=b.functions(a));i(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=h.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,
|
||||||
|
[a,1].concat(h.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,j,h,i=b.debounce(function(){j=g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;j&&a.apply(d,e);i()},c));if(g)j=true;else{g=true;h=a.apply(d,e)}i();return h}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments,h=d&&!e;clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b);h&&a.apply(f,g)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;
|
||||||
|
return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(h.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=P||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=
|
||||||
|
function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){i(h.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={},d=b.flatten(h.call(arguments,1));i(d,function(b){b in a&&(c[b]=a[b])});return c};b.omit=function(a){var c={},d=b.flatten(h.call(arguments,1)),e;for(e in a)b.include(d,e)||(c[e]=a[e]);return c};b.defaults=function(a){i(h.call(arguments,1),
|
||||||
|
function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};var u=function(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=m.call(a);if(e!=m.call(c))return false;switch(e){case "[object String]":return a==
|
||||||
|
""+c;case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){f=a.length;if(g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&u(a[f],c[f],d)))break}else{if("constructor"in
|
||||||
|
a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)){f++;if(!(g=b.has(c,h)&&u(a[h],c[h],d)))break}if(g){for(h in c)if(b.has(c,h)&&!f--)break;g=!f}}d.pop();return g};b.isEqual=function(a,b){return u(a,b,[])};b.isEmpty=function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return m.call(a)=="[object Array]"};
|
||||||
|
b.isObject=function(a){return a===Object(a)};i("Arguments,Function,String,Number,Date,RegExp".split(","),function(a){b["is"+a]=function(b){return m.call(b)=="[object "+a+"]"}});b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||m.call(a)=="[object Boolean]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===
|
||||||
|
void 0};b.has=function(a,b){return O.call(a,b)};b.noConflict=function(){s._=L;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};var Q={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},R=/[&<>"'\/]/g;b.escape=function(a){return(""+a).replace(R,function(a){return Q[a]})};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){i(b.functions(a),function(c){S(c,b[c]=a[c])})};
|
||||||
|
var T=0;b.uniqueId=function(a){var b=T++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var v=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},w;for(w in n)n[n[w]]=w;var U=/\\|'|\r|\n|\t|\u2028|\u2029/g,V=/\\(\\|'|r|n|t|u2028|u2029)/g,x=function(a){return a.replace(V,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(U,function(a){return"\\"+
|
||||||
|
n[a]}).replace(d.escape||v,function(a,b){return"'+\n((__t=("+x(b)+"))==null?'':_.escape(__t))+\n'"}).replace(d.interpolate||v,function(a,b){return"'+\n((__t=("+x(b)+"))==null?'':__t)+\n'"}).replace(d.evaluate||v,function(a,b){return"';\n"+x(b)+"\n__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,
|
||||||
|
a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};b.chain=function(a){return b(a).chain()};var l=function(a){this._wrapped=a};b.prototype=l.prototype;var y=function(a,c){return c?b(a).chain():a},S=function(a,c){l.prototype[a]=function(){var a=h.call(arguments);N.call(a,this._wrapped);return y(c.apply(b,a),this._chain)}};b.mixin(b);i("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];l.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);
|
||||||
|
(a=="shift"||a=="splice")&&d.length===0&&delete d[0];return y(d,this._chain)}});i(["concat","join","slice"],function(a){var b=k[a];l.prototype[a]=function(){return y(b.apply(this._wrapped,arguments),this._chain)}});l.prototype.chain=function(){this._chain=true;return this};l.prototype.value=function(){return this._wrapped}}).call(this);
|
||||||
68
vendor/underscore/underscore.js
vendored
68
vendor/underscore/underscore.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
// Underscore.js 1.3.3
|
// Underscore.js 1.3.3
|
||||||
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
||||||
// Underscore is freely distributable under the MIT license.
|
// Underscore may be freely distributed under the MIT license.
|
||||||
// Portions of Underscore are inspired or borrowed from Prototype,
|
// Portions of Underscore are inspired or borrowed from Prototype,
|
||||||
// Oliver Steele's Functional, and John Resig's Micro-Templating.
|
// Oliver Steele's Functional, and John Resig's Micro-Templating.
|
||||||
// For all details and documentation:
|
// For all details and documentation:
|
||||||
@@ -267,7 +267,7 @@
|
|||||||
|
|
||||||
// Sort the object's values by a criterion produced by an iterator.
|
// Sort the object's values by a criterion produced by an iterator.
|
||||||
_.sortBy = function(obj, val, context) {
|
_.sortBy = function(obj, val, context) {
|
||||||
var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
|
var iterator = lookupIterator(obj, val);
|
||||||
return _.pluck(_.map(obj, function(value, index, list) {
|
return _.pluck(_.map(obj, function(value, index, list) {
|
||||||
return {
|
return {
|
||||||
value : value,
|
value : value,
|
||||||
@@ -281,16 +281,38 @@
|
|||||||
}), 'value');
|
}), 'value');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// An internal function to generate lookup iterators.
|
||||||
|
var lookupIterator = function(obj, val) {
|
||||||
|
return _.isFunction(val) ? val : function(obj) { return obj[val]; };
|
||||||
|
};
|
||||||
|
|
||||||
|
// An internal function used for aggregate "group by" operations.
|
||||||
|
var group = function(obj, val, behavior) {
|
||||||
|
var result = {};
|
||||||
|
var iterator = lookupIterator(obj, val);
|
||||||
|
each(obj, function(value, index) {
|
||||||
|
var key = iterator(value, index);
|
||||||
|
behavior(result, key, value);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
// Groups the object's values by a criterion. Pass either a string attribute
|
// Groups the object's values by a criterion. Pass either a string attribute
|
||||||
// to group by, or a function that returns the criterion.
|
// to group by, or a function that returns the criterion.
|
||||||
_.groupBy = function(obj, val) {
|
_.groupBy = function(obj, val) {
|
||||||
var result = {};
|
return group(obj, val, function(result, key, value) {
|
||||||
var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
|
|
||||||
each(obj, function(value, index) {
|
|
||||||
var key = iterator(value, index);
|
|
||||||
(result[key] || (result[key] = [])).push(value);
|
(result[key] || (result[key] = [])).push(value);
|
||||||
});
|
});
|
||||||
return result;
|
};
|
||||||
|
|
||||||
|
// Counts instances of an object that group by a certain criterion. Pass
|
||||||
|
// either a string attribute to count by, or a function that returns the
|
||||||
|
// criterion.
|
||||||
|
_.countBy = function(obj, val) {
|
||||||
|
return group(obj, val, function(result, key, value) {
|
||||||
|
result[key] || (result[key] = 0);
|
||||||
|
result[key]++;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Use a comparator function to figure out the smallest index at which
|
// Use a comparator function to figure out the smallest index at which
|
||||||
@@ -308,10 +330,9 @@
|
|||||||
|
|
||||||
// Safely convert anything iterable into a real, live array.
|
// Safely convert anything iterable into a real, live array.
|
||||||
_.toArray = function(obj) {
|
_.toArray = function(obj) {
|
||||||
if (!obj) return [];
|
if (!obj) return [];
|
||||||
if (_.isArray(obj)) return slice.call(obj);
|
if (_.isArray(obj) || _.isArguments(obj)) return slice.call(obj);
|
||||||
if (_.isArguments(obj)) return slice.call(obj);
|
if (_.isFunction(obj.toArray)) return obj.toArray();
|
||||||
if (obj.toArray && _.isFunction(obj.toArray)) return obj.toArray();
|
|
||||||
return _.values(obj);
|
return _.values(obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -677,11 +698,22 @@
|
|||||||
|
|
||||||
// Return a copy of the object only containing the whitelisted properties.
|
// Return a copy of the object only containing the whitelisted properties.
|
||||||
_.pick = function(obj) {
|
_.pick = function(obj) {
|
||||||
var result = {};
|
var copy = {};
|
||||||
each(flatten(slice.call(arguments, 1), true, []), function(key) {
|
var keys = _.flatten(slice.call(arguments, 1));
|
||||||
if (key in obj) result[key] = obj[key];
|
each(keys, function(key) {
|
||||||
|
if (key in obj) copy[key] = obj[key];
|
||||||
});
|
});
|
||||||
return result;
|
return copy;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Return a copy of the object without the blacklisted properties.
|
||||||
|
_.omit = function(obj) {
|
||||||
|
var copy = {};
|
||||||
|
var keys = _.flatten(slice.call(arguments, 1));
|
||||||
|
for (var key in obj) {
|
||||||
|
if (!_.include(keys, key)) copy[key] = obj[key];
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fill in a given object with default properties.
|
// Fill in a given object with default properties.
|
||||||
@@ -709,7 +741,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Internal recursive comparison function for `isEqual`.
|
// Internal recursive comparison function for `isEqual`.
|
||||||
function eq(a, b, stack) {
|
var eq = function(a, b, stack) {
|
||||||
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
||||||
// See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
|
// See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
|
||||||
if (a === b) return a !== 0 || 1 / a == 1 / b;
|
if (a === b) return a !== 0 || 1 / a == 1 / b;
|
||||||
@@ -794,7 +826,7 @@
|
|||||||
// Remove the first object from the stack of traversed objects.
|
// Remove the first object from the stack of traversed objects.
|
||||||
stack.pop();
|
stack.pop();
|
||||||
return result;
|
return result;
|
||||||
}
|
};
|
||||||
|
|
||||||
// Perform a deep comparison to check if two objects are equal.
|
// Perform a deep comparison to check if two objects are equal.
|
||||||
_.isEqual = function(a, b) {
|
_.isEqual = function(a, b) {
|
||||||
@@ -832,7 +864,7 @@
|
|||||||
return toString.call(obj) == '[object ' + name + ']';
|
return toString.call(obj) == '[object ' + name + ']';
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// Define a fallback version of the method in browsers (ahem, IE), where
|
// Define a fallback version of the method in browsers (ahem, IE), where
|
||||||
// there isn't any inspectable "Arguments" type.
|
// there isn't any inspectable "Arguments" type.
|
||||||
if (!_.isArguments(arguments)) {
|
if (!_.isArguments(arguments)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user