mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Compare commits
1079 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07f7a3f3c5 | ||
|
|
22984f4eb2 | ||
|
|
2286283f98 | ||
|
|
5ca26e6ae0 | ||
|
|
e7c3afc1e5 | ||
|
|
82e9b4197b | ||
|
|
820939f014 | ||
|
|
e4c9916e17 | ||
|
|
ce88b120eb | ||
|
|
23c5101227 | ||
|
|
de3eeb2d47 | ||
|
|
03f7205e6d | ||
|
|
7bf7ab954b | ||
|
|
97612f3b31 | ||
|
|
71702d058c | ||
|
|
6a4164d9f3 | ||
|
|
d3b0eae84c | ||
|
|
0105b93f38 | ||
|
|
cae0d2c707 | ||
|
|
dcb1572240 | ||
|
|
e20f43018b | ||
|
|
01e176694f | ||
|
|
a239ccaa9a | ||
|
|
b97a05b7f2 | ||
|
|
c86754afde | ||
|
|
95da9c0dd4 | ||
|
|
567171993b | ||
|
|
60a0d554a0 | ||
|
|
f87af6c642 | ||
|
|
df849e8698 | ||
|
|
7a8ef7aeb7 | ||
|
|
25c7c8b153 | ||
|
|
8048f015e5 | ||
|
|
8a7fce41bb | ||
|
|
094a272443 | ||
|
|
552be2f5fb | ||
|
|
d99954133c | ||
|
|
c49ace5587 | ||
|
|
258ad020ed | ||
|
|
59de939c1d | ||
|
|
9d2d4f39bc | ||
|
|
f555cd2303 | ||
|
|
fcb80e926d | ||
|
|
3f1fd98bef | ||
|
|
e2280db917 | ||
|
|
627e92e7e0 | ||
|
|
5a9ca34a92 | ||
|
|
880ffcb1f6 | ||
|
|
4e35d970af | ||
|
|
42a4e09f91 | ||
|
|
b13b17e801 | ||
|
|
68d0238044 | ||
|
|
82b4f4147e | ||
|
|
6cbd2c4188 | ||
|
|
78982f3074 | ||
|
|
345746f7ab | ||
|
|
741a7b9caa | ||
|
|
7544c8fac8 | ||
|
|
a46169329d | ||
|
|
9aa56630ab | ||
|
|
01819e7a5a | ||
|
|
bae497ec5a | ||
|
|
68e0c78602 | ||
|
|
6296afd279 | ||
|
|
6d58fe912d | ||
|
|
0c45957096 | ||
|
|
aa311bd792 | ||
|
|
8858cdbe8c | ||
|
|
9d033247e9 | ||
|
|
cacae31af3 | ||
|
|
759a44e2b8 | ||
|
|
2fb778413b | ||
|
|
473d059efd | ||
|
|
67cd43d97a | ||
|
|
b77248c975 | ||
|
|
6bc58a16f6 | ||
|
|
0edbd96bb5 | ||
|
|
6ecc675670 | ||
|
|
c0a6f051fc | ||
|
|
6bc0aba800 | ||
|
|
6949f71516 | ||
|
|
f6c6de40f1 | ||
|
|
fdea9a447f | ||
|
|
2e02636fc1 | ||
|
|
17b9646c0b | ||
|
|
0a3d7e7cbc | ||
|
|
a62d70e80c | ||
|
|
96bbf74207 | ||
|
|
6cfe7fa5ea | ||
|
|
efc61ea70d | ||
|
|
e752b26f9e | ||
|
|
6b19ca1c11 | ||
|
|
42e01fd37b | ||
|
|
1df18a3e10 | ||
|
|
f31fb8bd34 | ||
|
|
1d54d868e3 | ||
|
|
4b801f423b | ||
|
|
96ef2110ce | ||
|
|
84763cab26 | ||
|
|
fc2ce9a021 | ||
|
|
a5c1421c6b | ||
|
|
1a54e43a24 | ||
|
|
1ab5a20784 | ||
|
|
1634388534 | ||
|
|
455afb0019 | ||
|
|
349dfbf182 | ||
|
|
b081b3ae2d | ||
|
|
110f86f803 | ||
|
|
ace771d4e9 | ||
|
|
7544166d11 | ||
|
|
ff5f06b9f0 | ||
|
|
06395f8436 | ||
|
|
fe3d86bf13 | ||
|
|
f92dc95c58 | ||
|
|
9058c00cfe | ||
|
|
8b6bd8442e | ||
|
|
1ef22e976d | ||
|
|
d0d86aecf8 | ||
|
|
1ef4807a8e | ||
|
|
846e813c99 | ||
|
|
73405cf042 | ||
|
|
79c873f3f8 | ||
|
|
0fc6929dd4 | ||
|
|
753a32bed7 | ||
|
|
027c572758 | ||
|
|
afb7d3e351 | ||
|
|
a5c3ae0a7e | ||
|
|
9477e46fb3 | ||
|
|
bf06df4475 | ||
|
|
e775a58496 | ||
|
|
ad15e47d4d | ||
|
|
45f7a91780 | ||
|
|
b1401d03a1 | ||
|
|
8b264e5c11 | ||
|
|
2fb4ec0d5f | ||
|
|
ddd5318bb0 | ||
|
|
3d44135df5 | ||
|
|
a98fc802fc | ||
|
|
ed364ecfee | ||
|
|
434d217bfa | ||
|
|
2386557b5e | ||
|
|
f619a6666a | ||
|
|
359ef9715e | ||
|
|
9211bc6329 | ||
|
|
a26ef1a997 | ||
|
|
c9f53b9a1c | ||
|
|
f9a3e66716 | ||
|
|
e5464fa199 | ||
|
|
9dc2f1ee29 | ||
|
|
b27143aa15 | ||
|
|
07c38311ca | ||
|
|
4a0415a6bd | ||
|
|
5d97cdbcfe | ||
|
|
7cce658fc4 | ||
|
|
84879453b1 | ||
|
|
9cc79db819 | ||
|
|
17a1663513 | ||
|
|
11538ccf90 | ||
|
|
5c51b1c4d1 | ||
|
|
5a13fe28c9 | ||
|
|
946560c998 | ||
|
|
7c5e032853 | ||
|
|
54ae91b2d9 | ||
|
|
8bd8aa3037 | ||
|
|
6fa9490a13 | ||
|
|
5dc48d1a83 | ||
|
|
9e56a92c8a | ||
|
|
ac98d81b85 | ||
|
|
05e80e32f7 | ||
|
|
7435058859 | ||
|
|
81b1d6e451 | ||
|
|
52754415e0 | ||
|
|
d51d67a5c2 | ||
|
|
c62fbd811b | ||
|
|
1df780abba | ||
|
|
150511b263 | ||
|
|
7fefa954c8 | ||
|
|
030472cee4 | ||
|
|
00c0dc233e | ||
|
|
1013bccb9c | ||
|
|
0911e77c32 | ||
|
|
4cdd33b2aa | ||
|
|
638f081390 | ||
|
|
21f28bfd0d | ||
|
|
941745cd06 | ||
|
|
8bf6bcb8a7 | ||
|
|
e7b8fd8281 | ||
|
|
b1ba01e85a | ||
|
|
a74c71e423 | ||
|
|
dba1bcf973 | ||
|
|
ed3f8cc39d | ||
|
|
f39fdc42f6 | ||
|
|
9ef191db33 | ||
|
|
9582f25835 | ||
|
|
4463975ace | ||
|
|
33cf509822 | ||
|
|
34f44e8f25 | ||
|
|
7fb738ab91 | ||
|
|
973e0812ad | ||
|
|
cd8218541a | ||
|
|
2316dff1e0 | ||
|
|
15ce24db25 | ||
|
|
b0e0a20e96 | ||
|
|
849f8e77ec | ||
|
|
f7c7dee8b0 | ||
|
|
167fad9649 | ||
|
|
9d3a298895 | ||
|
|
19b5ef7c6f | ||
|
|
9b09caa463 | ||
|
|
f08b6e2690 | ||
|
|
fa13cb5544 | ||
|
|
1427c99169 | ||
|
|
3e155bdbb9 | ||
|
|
f830612f17 | ||
|
|
3b86574b4d | ||
|
|
30d9cb9a4a | ||
|
|
cfe05b7d34 | ||
|
|
60a016ae39 | ||
|
|
6229e02806 | ||
|
|
5202294ae2 | ||
|
|
5bc50c2ef0 | ||
|
|
22b0b942ae | ||
|
|
41f86399f0 | ||
|
|
bc7f2af2ce | ||
|
|
db04398e49 | ||
|
|
56929e9725 | ||
|
|
6798259b84 | ||
|
|
20906c7bf7 | ||
|
|
560ddac75a | ||
|
|
daecf5cf01 | ||
|
|
505f8d5cda | ||
|
|
1d7fd0638d | ||
|
|
67ca691334 | ||
|
|
85da55d917 | ||
|
|
ee8567ab38 | ||
|
|
4ca2740628 | ||
|
|
23e6302329 | ||
|
|
95c6dd8992 | ||
|
|
a5b733998d | ||
|
|
68b7749a0f | ||
|
|
fb37e0767a | ||
|
|
43469b9877 | ||
|
|
5a53215506 | ||
|
|
51ce9edcf3 | ||
|
|
18481a40b2 | ||
|
|
24c0221ec5 | ||
|
|
0f928233ce | ||
|
|
e5730af949 | ||
|
|
ed23b6b89d | ||
|
|
28420ac1fc | ||
|
|
6da255f786 | ||
|
|
2396932846 | ||
|
|
89b9f46ad8 | ||
|
|
7dd0bb5005 | ||
|
|
44ecbc944b | ||
|
|
223460bbd2 | ||
|
|
1a0a9709f2 | ||
|
|
a16c282f99 | ||
|
|
aeac5b0203 | ||
|
|
afdc4b746a | ||
|
|
6c84ccd5c5 | ||
|
|
916bfed84b | ||
|
|
35bb3ac128 | ||
|
|
4f1c3887f7 | ||
|
|
ce19067cfd | ||
|
|
00f4ebe6aa | ||
|
|
5add1cfd25 | ||
|
|
c67092d72b | ||
|
|
4bb5402cca | ||
|
|
837acf1394 | ||
|
|
0d8779734d | ||
|
|
d8213454c2 | ||
|
|
e05c8677bf | ||
|
|
a5b9063088 | ||
|
|
83ea7ac136 | ||
|
|
f3075d685e | ||
|
|
a811476c1b | ||
|
|
64fe626fa6 | ||
|
|
f8236c711f | ||
|
|
b1f6bc72f4 | ||
|
|
300dee34bd | ||
|
|
1eaa112f7d | ||
|
|
8228376160 | ||
|
|
a58cd65db8 | ||
|
|
2df689524e | ||
|
|
a20ad60f13 | ||
|
|
1c781389d2 | ||
|
|
5e639d1704 | ||
|
|
8e64432e2c | ||
|
|
a8de2ca410 | ||
|
|
6343518bca | ||
|
|
351e259174 | ||
|
|
1d77e29c3c | ||
|
|
eba9b3d22a | ||
|
|
844fe1d979 | ||
|
|
0971a7820f | ||
|
|
06c6f180dc | ||
|
|
33da30266c | ||
|
|
ad8628f8e7 | ||
|
|
f42446d22f | ||
|
|
4b77b7a8b3 | ||
|
|
9e99a57615 | ||
|
|
7e648741ad | ||
|
|
b1d396bbbb | ||
|
|
380435d020 | ||
|
|
71fb66dc37 | ||
|
|
a53280f047 | ||
|
|
ccfb968b8a | ||
|
|
db731e0c91 | ||
|
|
a4b86f8368 | ||
|
|
44c697908b | ||
|
|
e3c79bd24a | ||
|
|
fb1ed531e4 | ||
|
|
a6cb6d26a4 | ||
|
|
003a5981d6 | ||
|
|
0bf38b826e | ||
|
|
4038d12f1b | ||
|
|
9d60e28aad | ||
|
|
ae92aa200f | ||
|
|
4584b857ca | ||
|
|
46bdf5d79d | ||
|
|
83720f457e | ||
|
|
0706af1543 | ||
|
|
41985d8c1a | ||
|
|
440eb0876c | ||
|
|
ac0a0ea07e | ||
|
|
4a534da00a | ||
|
|
ff4143b482 | ||
|
|
f132c0024f | ||
|
|
82a1010f64 | ||
|
|
d885a9afd0 | ||
|
|
08568fcc8f | ||
|
|
2192b7748e | ||
|
|
c96a579291 | ||
|
|
095cf94c45 | ||
|
|
f7a49778ea | ||
|
|
58b235b435 | ||
|
|
a7f1c3c883 | ||
|
|
268d411bb4 | ||
|
|
7cdf708e3c | ||
|
|
42c077de02 | ||
|
|
769f78a2b7 | ||
|
|
b69ba06db9 | ||
|
|
42d5cc584e | ||
|
|
f3d54d0975 | ||
|
|
39192ad388 | ||
|
|
19500d36c7 | ||
|
|
229f0b48cd | ||
|
|
58736f743e | ||
|
|
dc136cbf31 | ||
|
|
81e39f7c4b | ||
|
|
1cbb6f1405 | ||
|
|
1ae6e67cdc | ||
|
|
3d43cc1029 | ||
|
|
230e8d0787 | ||
|
|
8154e5e521 | ||
|
|
f4467f6033 | ||
|
|
562b04a763 | ||
|
|
9bcbcc5293 | ||
|
|
fdc15df3b3 | ||
|
|
e778458f78 | ||
|
|
0a55eff5d5 | ||
|
|
3874b5bf84 | ||
|
|
d07343a1aa | ||
|
|
a37c6db377 | ||
|
|
1f991a7cdc | ||
|
|
e99a31c2fa | ||
|
|
876fe52efc | ||
|
|
8f190b1fb1 | ||
|
|
411f3ecb3e | ||
|
|
3d31423eef | ||
|
|
68c0eb5216 | ||
|
|
39dae19974 | ||
|
|
2dd6f0124e | ||
|
|
826af968c8 | ||
|
|
70c3d325a0 | ||
|
|
6289211910 | ||
|
|
86346291a7 | ||
|
|
05d57b90a9 | ||
|
|
dd64f5eac4 | ||
|
|
e6de183651 | ||
|
|
7bd986337a | ||
|
|
6dc92df880 | ||
|
|
44abe46da4 | ||
|
|
9e334b5ece | ||
|
|
ee8a248086 | ||
|
|
8f1f98b003 | ||
|
|
a6bc1fa316 | ||
|
|
ce6c0f3082 | ||
|
|
393849384b | ||
|
|
618280340f | ||
|
|
6b77af4e5a | ||
|
|
aa8524b8ad | ||
|
|
87a813566a | ||
|
|
73a97d5762 | ||
|
|
ce4c6ec755 | ||
|
|
21b5139d98 | ||
|
|
7745c91c69 | ||
|
|
bce8f498b4 | ||
|
|
7eaacc3997 | ||
|
|
c699ff7574 | ||
|
|
11d8867d7a | ||
|
|
d4eeb8d186 | ||
|
|
a562a20b4e | ||
|
|
3ecf626ad0 | ||
|
|
766c4315e6 | ||
|
|
b9f2855034 | ||
|
|
44397f79a6 | ||
|
|
dcca9b82b1 | ||
|
|
ecef32a101 | ||
|
|
41d425319c | ||
|
|
6a49f227b4 | ||
|
|
a3ced39b12 | ||
|
|
b89045b20f | ||
|
|
4e3f3899c4 | ||
|
|
a8d865a246 | ||
|
|
cad0fbfc4d | ||
|
|
45f07d5014 | ||
|
|
64a7503196 | ||
|
|
783c23cbfb | ||
|
|
1c04dfe083 | ||
|
|
59ec97f59f | ||
|
|
c71d26c7e8 | ||
|
|
88e58aa8f9 | ||
|
|
40850f9cda | ||
|
|
be3afcf668 | ||
|
|
c1b7679cac | ||
|
|
a370c48d9c | ||
|
|
6c0e456a5e | ||
|
|
ebb993b862 | ||
|
|
3408db91b6 | ||
|
|
f0e8371997 | ||
|
|
55383b9de4 | ||
|
|
5551a8365a | ||
|
|
87fc16af19 | ||
|
|
80d91b693a | ||
|
|
977438309b | ||
|
|
28b426f19d | ||
|
|
d40c5d3de8 | ||
|
|
53702774d0 | ||
|
|
b36e659c56 | ||
|
|
0dcf028592 | ||
|
|
549918d7f9 | ||
|
|
dcb23f46a4 | ||
|
|
c152ae71e2 | ||
|
|
32cd726bd0 | ||
|
|
4f104d74ca | ||
|
|
9c44430975 | ||
|
|
1309f37a7e | ||
|
|
3ed0cc14ea | ||
|
|
73a698151f | ||
|
|
8a3842b788 | ||
|
|
73d68c9609 | ||
|
|
f6d81e1bd8 | ||
|
|
98e607e610 | ||
|
|
a7ec0c2e93 | ||
|
|
0b3e19f56e | ||
|
|
60ac7cfe74 | ||
|
|
491102f221 | ||
|
|
9db252e55d | ||
|
|
b9b94609f5 | ||
|
|
fe910d01f6 | ||
|
|
ea71539b7a | ||
|
|
3d9fd1d374 | ||
|
|
3eda8e64f3 | ||
|
|
ec8ccbcc55 | ||
|
|
1d58823405 | ||
|
|
19e0650c4f | ||
|
|
f45fc10cb1 | ||
|
|
42dff0e5fb | ||
|
|
ee9339e73b | ||
|
|
611aaa5385 | ||
|
|
e25369a306 | ||
|
|
67701944f1 | ||
|
|
ecaee16d23 | ||
|
|
b84c336855 | ||
|
|
447bafaa5b | ||
|
|
2f93e0a499 | ||
|
|
6c2ada9ffc | ||
|
|
982b9d2b0a | ||
|
|
1fe87d0348 | ||
|
|
8d8d4fa3b1 | ||
|
|
94fb8c6f92 | ||
|
|
04c7b33f90 | ||
|
|
ae76c3ee71 | ||
|
|
7d1e24d07f | ||
|
|
37955345ef | ||
|
|
4bc35e9ed4 | ||
|
|
c142cfc81d | ||
|
|
39a22bf15b | ||
|
|
eb636f9538 | ||
|
|
8a838633d1 | ||
|
|
963e297c74 | ||
|
|
d95dbf6ba8 | ||
|
|
ae032c8523 | ||
|
|
2b4a10c159 | ||
|
|
c7ef030ef5 | ||
|
|
7e726735ba | ||
|
|
3d25b2fd9b | ||
|
|
96a22aaec0 | ||
|
|
ccef887f88 | ||
|
|
7d9c6527a4 | ||
|
|
ef7191dbc1 | ||
|
|
bc2adb208c | ||
|
|
cd371ac66f | ||
|
|
9c342eb432 | ||
|
|
95f5b39aed | ||
|
|
9ce38cb43c | ||
|
|
8b57b3086e | ||
|
|
3fdec6d25e | ||
|
|
557af10067 | ||
|
|
6b2645b310 | ||
|
|
c360ee0fa4 | ||
|
|
3ac5870530 | ||
|
|
5218fd2c24 | ||
|
|
accb8e9b07 | ||
|
|
e331ea5d82 | ||
|
|
ae804b8cc7 | ||
|
|
66d72345f2 | ||
|
|
436d64f881 | ||
|
|
c3ec32cc16 | ||
|
|
4b86df4966 | ||
|
|
9fbf1955f2 | ||
|
|
2008a82017 | ||
|
|
8c04a00177 | ||
|
|
8370277352 | ||
|
|
89279009d8 | ||
|
|
182b29662d | ||
|
|
8119bcdc61 | ||
|
|
b6d40f75c9 | ||
|
|
d9570e8223 | ||
|
|
3a0fc24a6a | ||
|
|
04879d0fe5 | ||
|
|
0d9b03ced2 | ||
|
|
7be7acfe30 | ||
|
|
655f7918ea | ||
|
|
67e799ccb2 | ||
|
|
4c12319d19 | ||
|
|
3769719816 | ||
|
|
cc8e4956f5 | ||
|
|
3ad67c754f | ||
|
|
cabd4198b0 | ||
|
|
2bf80673ae | ||
|
|
2182e0696d | ||
|
|
9c44b5c384 | ||
|
|
d5f51f2881 | ||
|
|
176e17c45d | ||
|
|
7912b08c41 | ||
|
|
643ffce289 | ||
|
|
0d4d740961 | ||
|
|
68473f08d6 | ||
|
|
6c09a69991 | ||
|
|
ac16bc0e15 | ||
|
|
99287a89eb | ||
|
|
e0aaf876c2 | ||
|
|
022f79beed | ||
|
|
a6aac88561 | ||
|
|
87057095bc | ||
|
|
5afa75ce51 | ||
|
|
c525598fd9 | ||
|
|
f54cfb0ea2 | ||
|
|
91fcf837f7 | ||
|
|
64e98d897f | ||
|
|
99a5fcc665 | ||
|
|
f0c38a6419 | ||
|
|
14c2747e80 | ||
|
|
3ee2a15cde | ||
|
|
8982578edd | ||
|
|
5ec6f1085a | ||
|
|
1513e46605 | ||
|
|
b95ed73e1d | ||
|
|
ff22efb3e2 | ||
|
|
35c6db1289 | ||
|
|
602e5d2766 | ||
|
|
247c4f1068 | ||
|
|
bdb5e4642f | ||
|
|
661e9b08b6 | ||
|
|
fdf6478bc9 | ||
|
|
10229cd332 | ||
|
|
33e2499006 | ||
|
|
6ae58e74c7 | ||
|
|
689b292c24 | ||
|
|
f6a4ab62b8 | ||
|
|
e197884e07 | ||
|
|
ba095d11cc | ||
|
|
e22cb5f3b3 | ||
|
|
da993ee48d | ||
|
|
9458759810 | ||
|
|
dd27a0adc7 | ||
|
|
3fd276f8a6 | ||
|
|
33f454bb75 | ||
|
|
1fd5d501b0 | ||
|
|
e4220282c8 | ||
|
|
6dec9cb831 | ||
|
|
1ad55ec263 | ||
|
|
96f5dbfccf | ||
|
|
fd2aa1f51c | ||
|
|
74137d4eab | ||
|
|
02398e319d | ||
|
|
32d6a04107 | ||
|
|
6bff374e91 | ||
|
|
18b5cb24c2 | ||
|
|
04e8ca771b | ||
|
|
174f771612 | ||
|
|
4f0a5e937b | ||
|
|
505f02fd72 | ||
|
|
a6c7ffd664 | ||
|
|
a08d52eb48 | ||
|
|
414ad602f2 | ||
|
|
e961505e0a | ||
|
|
59278a7a85 | ||
|
|
adaf6d7955 | ||
|
|
f6624bf270 | ||
|
|
cdf03228c2 | ||
|
|
1fd710e88d | ||
|
|
dc2e760b5a | ||
|
|
150bd32f97 | ||
|
|
d9fc0f1e37 | ||
|
|
e2c7e3a107 | ||
|
|
4995aa0298 | ||
|
|
54b774e481 | ||
|
|
c85095d53f | ||
|
|
8132ed52fd | ||
|
|
eb723422c1 | ||
|
|
051e5a6308 | ||
|
|
2d3e64b51a | ||
|
|
a21b25f751 | ||
|
|
1d425b1731 | ||
|
|
141630f557 | ||
|
|
9fd48bab69 | ||
|
|
f880e39838 | ||
|
|
afb66f4b8a | ||
|
|
7e09802565 | ||
|
|
a8b3833580 | ||
|
|
bf1bcaf394 | ||
|
|
7b61569d32 | ||
|
|
9c27ed8bda | ||
|
|
c9cb64ac10 | ||
|
|
4bd5122462 | ||
|
|
4dac4328e6 | ||
|
|
f7a857744f | ||
|
|
6725e7dc49 | ||
|
|
7da4ea5ecb | ||
|
|
6d5c6b2de7 | ||
|
|
ed462747bf | ||
|
|
53b37ca98f | ||
|
|
423320f235 | ||
|
|
020a8c864f | ||
|
|
69e6389369 | ||
|
|
0eaa10f578 | ||
|
|
2740dc5efa | ||
|
|
592824781c | ||
|
|
4bef0e21e7 | ||
|
|
7d7ce728ff | ||
|
|
27159cfa00 | ||
|
|
d236e37652 | ||
|
|
940559fc76 | ||
|
|
5746169aec | ||
|
|
4aa6fdeb2a | ||
|
|
77ab121c30 | ||
|
|
9558048906 | ||
|
|
b3f6426d36 | ||
|
|
d407d8aa08 | ||
|
|
8842fa209d | ||
|
|
bc252228e1 | ||
|
|
1b3cb0f184 | ||
|
|
f607c671f8 | ||
|
|
8f431cff52 | ||
|
|
6a81a7ba8e | ||
|
|
1f713ed9d1 | ||
|
|
2cb4829536 | ||
|
|
48d5110b5d | ||
|
|
68a5e2017e | ||
|
|
63c46a9aca | ||
|
|
528bec0bb1 | ||
|
|
9c79cb7766 | ||
|
|
38ac518095 | ||
|
|
7488068d50 | ||
|
|
8e207196d3 | ||
|
|
9c35db38a0 | ||
|
|
2087736649 | ||
|
|
dd75deb27f | ||
|
|
5f42a3d4db | ||
|
|
a569b723c5 | ||
|
|
ee2078f3ea | ||
|
|
12af298e33 | ||
|
|
0429f27c54 | ||
|
|
5026f51dfd | ||
|
|
80abaafcae | ||
|
|
bc651e886d | ||
|
|
ba9cfc3b26 | ||
|
|
b5bbc18c89 | ||
|
|
e35088f9e3 | ||
|
|
1c3b325633 | ||
|
|
0415701e50 | ||
|
|
cfe813fa08 | ||
|
|
f4ff336636 | ||
|
|
a4b333ceb8 | ||
|
|
f029d7c943 | ||
|
|
53bf94ce78 | ||
|
|
406e36977e | ||
|
|
98ee746ada | ||
|
|
9e0a22f771 | ||
|
|
14e62ae8d2 | ||
|
|
1162d2edd5 | ||
|
|
a84e44b2a3 | ||
|
|
cd4f278a16 | ||
|
|
c7f34e74ac | ||
|
|
00d26a6419 | ||
|
|
eb57e522aa | ||
|
|
e9230463e8 | ||
|
|
d652f144b2 | ||
|
|
e04a512c4c | ||
|
|
c276278767 | ||
|
|
2e248d1ca8 | ||
|
|
a5df55a6e7 | ||
|
|
f7e05e438e | ||
|
|
49266dce89 | ||
|
|
3a81738455 | ||
|
|
a4ff501bb1 | ||
|
|
351c131764 | ||
|
|
799fcb354b | ||
|
|
16a29659b3 | ||
|
|
55ef0f12cc | ||
|
|
925c489cf9 | ||
|
|
3f57236c19 | ||
|
|
b4dd21fc64 | ||
|
|
8278b1e79f | ||
|
|
c313f0c135 | ||
|
|
e9bfaa7d51 | ||
|
|
0ae254d6b4 | ||
|
|
bbc7b0b59b | ||
|
|
7f284d6ed5 | ||
|
|
4744f93a47 | ||
|
|
a2fe87a63a | ||
|
|
fa61e30dd5 | ||
|
|
0fb94ad3c6 | ||
|
|
33a73fb0c4 | ||
|
|
a61eeeaa03 | ||
|
|
80f6990a43 | ||
|
|
0d5f8437f5 | ||
|
|
5e968deb4e | ||
|
|
ac1ffa2efe | ||
|
|
ed2e6d16c8 | ||
|
|
dafe807888 | ||
|
|
1320706172 | ||
|
|
fb4cf9e78f | ||
|
|
8cbb8befd4 | ||
|
|
aa303df387 | ||
|
|
e42d29611c | ||
|
|
a5213f1291 | ||
|
|
875dfec570 | ||
|
|
6edde288ee | ||
|
|
a6ead18121 | ||
|
|
7245570405 | ||
|
|
38a37f1b18 | ||
|
|
5c98ab4b8f | ||
|
|
5ddb1ef76d | ||
|
|
8b320f913d | ||
|
|
8e0011d07a | ||
|
|
e50734a6fb | ||
|
|
307dae4fac | ||
|
|
d8c5f85cd2 | ||
|
|
94c95469e1 | ||
|
|
e8244f7f07 | ||
|
|
a48f48ca95 | ||
|
|
4a4e54479a | ||
|
|
86d06e0a4c | ||
|
|
9b41ae847b | ||
|
|
012cc521f5 | ||
|
|
20695548f1 | ||
|
|
d77c5123c1 | ||
|
|
c32a6837e6 | ||
|
|
c604be31e0 | ||
|
|
0a08edb6d7 | ||
|
|
4d7aeb8b96 | ||
|
|
6b09f1f233 | ||
|
|
7364c84b6b | ||
|
|
02a28d565b | ||
|
|
2ac6e31cc3 | ||
|
|
8bad4ae636 | ||
|
|
f0010ea3a8 | ||
|
|
f86bff3bf7 | ||
|
|
99b0094dcd | ||
|
|
db86a6ff1c | ||
|
|
cbc188916d | ||
|
|
2f411230c5 | ||
|
|
b9c8c877b7 | ||
|
|
13e4ba622e | ||
|
|
7863256de5 | ||
|
|
d81e029ec0 | ||
|
|
f6500eafb6 | ||
|
|
9da03f529f | ||
|
|
1e1e4fd557 | ||
|
|
08f8e659fd | ||
|
|
fc69fe1f21 | ||
|
|
38a16805ed | ||
|
|
dfd4ae9ea4 | ||
|
|
5c9585b2b0 | ||
|
|
dc2e769d9a | ||
|
|
15a4fb7adf | ||
|
|
7bb10d56f8 | ||
|
|
650282b186 | ||
|
|
ded3cfc251 | ||
|
|
a4fee3a3ad | ||
|
|
58d7404ee4 | ||
|
|
556eee8563 | ||
|
|
1422f50ee9 | ||
|
|
1be4adf365 | ||
|
|
4510ada21e | ||
|
|
e516d99b2d | ||
|
|
b534b83756 | ||
|
|
41b537249b | ||
|
|
4a87acf1ac | ||
|
|
41d3b66867 | ||
|
|
3ef7ae24e5 | ||
|
|
824d3b75f9 | ||
|
|
38a802fed3 | ||
|
|
ee776fd0de | ||
|
|
a1f29d8f4a | ||
|
|
3e42a817a1 | ||
|
|
617dd703e1 | ||
|
|
e63d7ff9d5 | ||
|
|
7e73b27edf | ||
|
|
6898b896d1 | ||
|
|
085e2c24d3 | ||
|
|
cc77eb7855 | ||
|
|
8e9f9f6f2f | ||
|
|
51006e8304 | ||
|
|
fce2bd89c7 | ||
|
|
830be3d918 | ||
|
|
0926e5a986 | ||
|
|
b61411956c | ||
|
|
5648fe940c | ||
|
|
57ad32448f | ||
|
|
b4db3c050d | ||
|
|
3f954ca790 | ||
|
|
6e0174e879 | ||
|
|
e4873f1982 | ||
|
|
3d35817a2f | ||
|
|
8c6aef3edb | ||
|
|
5fd8939b7d | ||
|
|
4c1b578b80 | ||
|
|
f6bf81d16f | ||
|
|
2d8cc57642 | ||
|
|
3b131f0231 | ||
|
|
202ce472bb | ||
|
|
7206edec2e | ||
|
|
9e86efadbc | ||
|
|
433331adac | ||
|
|
a0cd024b39 | ||
|
|
4fbb31b4dc | ||
|
|
09bcc5aaec | ||
|
|
c921c9bd12 | ||
|
|
8f621b38bf | ||
|
|
257d957dfb | ||
|
|
a0a6f0ae87 | ||
|
|
c396b60612 | ||
|
|
98a97b1eaf | ||
|
|
7d6fcc75da | ||
|
|
ecd8b7f614 | ||
|
|
cc1bcc25b9 | ||
|
|
b792276a00 | ||
|
|
b1d52ccd82 | ||
|
|
cc0e91ac2f | ||
|
|
dfac7b4261 | ||
|
|
1258eef213 | ||
|
|
f79148fa62 | ||
|
|
4d2aa29926 | ||
|
|
f016840c53 | ||
|
|
cffeec4713 | ||
|
|
fcbe4620cd | ||
|
|
5a5e0363c2 | ||
|
|
64512ee2ae | ||
|
|
ce4f2f1326 | ||
|
|
dfebb83c35 | ||
|
|
0ba226e3c2 | ||
|
|
e0f59eccf0 | ||
|
|
820e720b0a | ||
|
|
936c5f5d3d | ||
|
|
d0b3b8de44 | ||
|
|
89d53306f3 | ||
|
|
e30a20120c | ||
|
|
790d6331f8 | ||
|
|
9121ab95ea | ||
|
|
b09e5cf5a7 | ||
|
|
b53a8e873d | ||
|
|
4c38963c6f | ||
|
|
b0d6c34565 | ||
|
|
0a9c9411f0 | ||
|
|
e253f58aac | ||
|
|
0aa8ad202a | ||
|
|
7bc5a501c4 | ||
|
|
4691a38d21 | ||
|
|
00bae752d0 | ||
|
|
e253fe0547 | ||
|
|
e35d73be8f | ||
|
|
f9f7af2430 | ||
|
|
7aef780b14 | ||
|
|
5644a20eec | ||
|
|
b135431542 | ||
|
|
efdb254b12 | ||
|
|
8fd2f0ae11 | ||
|
|
3f7ee9bd2e | ||
|
|
a049c1189e | ||
|
|
9859b1555f | ||
|
|
356e47a6a3 | ||
|
|
2c1c8fc8df | ||
|
|
e7bdd4a624 | ||
|
|
1a9069e80a | ||
|
|
484861e3ee | ||
|
|
99ba0a4927 | ||
|
|
ba3ede584e | ||
|
|
dd472f489b | ||
|
|
9f0dd40b3b | ||
|
|
edc03287aa | ||
|
|
d6dc7627b9 | ||
|
|
59773ca284 | ||
|
|
6aa01ffe05 | ||
|
|
5b3de94fee | ||
|
|
b4edf122f6 | ||
|
|
1647c4deab | ||
|
|
3efb91e86d | ||
|
|
d6f73054a5 | ||
|
|
bd9b38665d | ||
|
|
de5c2b906e | ||
|
|
4a4badcdc1 | ||
|
|
fa7ebb36dc | ||
|
|
447440776b | ||
|
|
f5714f2eb0 | ||
|
|
a3b76f9259 | ||
|
|
ba71421a23 | ||
|
|
61251b305d | ||
|
|
73464d6bb6 | ||
|
|
7f7ebed4ea | ||
|
|
5c53809269 | ||
|
|
3935d5f2f7 | ||
|
|
693704a832 | ||
|
|
b17f6eee6a | ||
|
|
ccb90f46e6 | ||
|
|
dfa4cd921e | ||
|
|
32e0afd19c | ||
|
|
5fb732c0e6 | ||
|
|
48a6c4f2bf | ||
|
|
f1597386ef | ||
|
|
731d5b6872 | ||
|
|
ce569e4bc4 | ||
|
|
f48b8d6d91 | ||
|
|
4fc94a4383 | ||
|
|
c5057905b6 | ||
|
|
3c388c76c6 | ||
|
|
a730fe13c7 | ||
|
|
4520e0710d | ||
|
|
7e42892e6a | ||
|
|
a0c580298e | ||
|
|
e7ad50d243 | ||
|
|
1394d42f58 | ||
|
|
a8e95e25ad | ||
|
|
87cb4db263 | ||
|
|
2ccda44c44 | ||
|
|
0253c7bcf1 | ||
|
|
9c7b39b7a7 | ||
|
|
5f4611fce2 | ||
|
|
c4fa2e70bf | ||
|
|
15b1a22501 | ||
|
|
51425788d8 | ||
|
|
a17d5eea47 | ||
|
|
ef909e8a54 | ||
|
|
0a24e9854b | ||
|
|
4eb2eea809 | ||
|
|
8a6705617f | ||
|
|
bbe122aba5 | ||
|
|
40409df885 | ||
|
|
7fdbdae6b9 | ||
|
|
b87a18bd80 | ||
|
|
6d650a48db | ||
|
|
54ea0eac8e | ||
|
|
4054898170 | ||
|
|
8a205e1e32 | ||
|
|
39068730e2 | ||
|
|
1e344455b8 | ||
|
|
9a01f3a337 | ||
|
|
f6ea758b85 | ||
|
|
51fb82902b | ||
|
|
3c342adb67 | ||
|
|
24d592f94f | ||
|
|
181ebf024c | ||
|
|
ecf693ac75 | ||
|
|
8266266639 | ||
|
|
0f2419357c | ||
|
|
2e57123aa2 | ||
|
|
881733e099 | ||
|
|
18f778ce11 | ||
|
|
b8060a5bcc | ||
|
|
7a34b2982f | ||
|
|
f695af587a | ||
|
|
7759615775 | ||
|
|
bbad03547d | ||
|
|
b638f86b75 | ||
|
|
ab6210dc30 | ||
|
|
9ca16e3933 | ||
|
|
76ab41a742 | ||
|
|
c6f6eb294b | ||
|
|
19836a55a3 | ||
|
|
862c7fde6d | ||
|
|
5d842273d9 | ||
|
|
33a9ebaba1 | ||
|
|
192e35882a | ||
|
|
e6b9aaf499 | ||
|
|
b821660e79 | ||
|
|
0beaf47a64 | ||
|
|
8a9e9e9a11 | ||
|
|
df17244353 | ||
|
|
ffd3e17364 | ||
|
|
211a6cc4f1 | ||
|
|
4c09879aab | ||
|
|
fd526e8754 | ||
|
|
974306d4f0 | ||
|
|
56452d9fd8 | ||
|
|
6d231fecd1 | ||
|
|
2e91cf727a | ||
|
|
64b9402e12 | ||
|
|
4bae0c0139 | ||
|
|
06bc4aa50b | ||
|
|
31a7ac1e81 | ||
|
|
c75ac3ac64 | ||
|
|
3e14d8f4dd | ||
|
|
6cde31f843 | ||
|
|
a7b70008ba | ||
|
|
8cc19d908e | ||
|
|
d58cda122d | ||
|
|
ab26945eca | ||
|
|
2da1b2af1a | ||
|
|
2586129dcd | ||
|
|
13e5d77041 | ||
|
|
d036ff6c4f | ||
|
|
1f1bc393d3 | ||
|
|
9aa34e2487 | ||
|
|
0b7bffe3b5 | ||
|
|
41f248f54d | ||
|
|
bc7cabde4e | ||
|
|
65d5bba7df | ||
|
|
340a6d195f | ||
|
|
83ac168664 | ||
|
|
8ac1a67b7d | ||
|
|
abd67d0786 | ||
|
|
9a9e4cddd7 | ||
|
|
10c44b08c9 | ||
|
|
86b19f742c | ||
|
|
cb94b03e3e | ||
|
|
a898c3d7bc | ||
|
|
86be6d7897 | ||
|
|
d3d4de12be | ||
|
|
04bac321d1 | ||
|
|
1011353729 | ||
|
|
5651993d93 | ||
|
|
c51466935c | ||
|
|
454aca7003 | ||
|
|
5ff9f01aba | ||
|
|
b5dd2e605d | ||
|
|
1bfe25f1a5 | ||
|
|
bd98779b3c | ||
|
|
7862ae6d36 | ||
|
|
dfbd78f71d | ||
|
|
e132e878d6 | ||
|
|
bb78c0ea6d | ||
|
|
1a772023d5 | ||
|
|
230f90173c | ||
|
|
fbc7c28188 | ||
|
|
5d88cb7099 | ||
|
|
caae7a5879 | ||
|
|
816f37bdc5 | ||
|
|
a2dd7171a5 | ||
|
|
a80d0bc2ca | ||
|
|
2e50d11be5 | ||
|
|
a5e2caf40b | ||
|
|
82f693a2bc | ||
|
|
349baa3550 | ||
|
|
712761ab0a |
@@ -4,15 +4,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[**.{js,json,md}]
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
|
||||
[**.html]
|
||||
indent_style = tab
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,4 +3,5 @@
|
||||
*.log
|
||||
*.map
|
||||
lodash.compat.min.js
|
||||
coverage
|
||||
node_modules
|
||||
|
||||
96
.jscsrc
Normal file
96
.jscsrc
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"maxErrors": "2000",
|
||||
"maximumLineLength": {
|
||||
"value": 180,
|
||||
"allExcept": ["comments", "functionSignature", "regex"]
|
||||
},
|
||||
"requireCurlyBraces": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"try",
|
||||
"catch"
|
||||
],
|
||||
"requireOperatorBeforeLineBreak": [
|
||||
"=",
|
||||
"+",
|
||||
"-",
|
||||
"/",
|
||||
"*",
|
||||
"==",
|
||||
"===",
|
||||
"!=",
|
||||
"!==",
|
||||
">",
|
||||
">=",
|
||||
"<",
|
||||
"<="
|
||||
],
|
||||
"requireSpaceAfterKeywords": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"switch",
|
||||
"return",
|
||||
"try",
|
||||
"catch"
|
||||
],
|
||||
"requireSpaceBeforeBinaryOperators": [
|
||||
"=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
|
||||
"&=", "|=", "^=", "+=",
|
||||
|
||||
"+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
|
||||
"|", "^", "&&", "||", "===", "==", ">=",
|
||||
"<=", "<", ">", "!=", "!=="
|
||||
],
|
||||
"requireSpacesInFunctionExpression": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
||||
"requireDotNotation": { "allExcept": ["keywords"] },
|
||||
"requireEarlyReturn": true,
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"requireSemicolons": true,
|
||||
"requireSpaceAfterBinaryOperators": true,
|
||||
"requireSpacesInConditionalExpression": true,
|
||||
"requireSpaceBeforeObjectValues": true,
|
||||
"requireSpaceBeforeBlockStatements": true,
|
||||
"requireSpacesInForStatement": true,
|
||||
|
||||
"validateIndentation": 2,
|
||||
"validateParameterSeparator": ", ",
|
||||
"validateQuoteMarks": { "mark": "'", "escape": true },
|
||||
|
||||
"disallowSpacesInAnonymousFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInFunctionDeclaration": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowKeywords": ["with"],
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowMultipleLineBreaks": true,
|
||||
"disallowNewlineBeforeBlockStatements": true,
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
||||
"disallowSpacesInCallExpression": true,
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
|
||||
"jsDoc": {
|
||||
"checkRedundantAccess": true,
|
||||
"checkTypes": true,
|
||||
"requireNewlineAfterDescription": true,
|
||||
"requireParamDescription": true,
|
||||
"requireParamTypes": true,
|
||||
"requireReturnTypes": true
|
||||
}
|
||||
}
|
||||
97
.travis.yml
97
.travis.yml
@@ -1,39 +1,25 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "0.12"
|
||||
- "5"
|
||||
env:
|
||||
global:
|
||||
- PATTERN1="s|\s*else\s*\{\s*iteratee\(index\);\s*\}||"
|
||||
- BIN="node" BUILD="compat" ISTANBUL=false OPTION=""
|
||||
- NPM_VERSION="^2.0.0" SAUCE_LABS=false SAUCE_USERNAME="lodash"
|
||||
- BIN="node" ISTANBUL=false OPTION=""
|
||||
- SAUCE_LABS=false SAUCE_USERNAME="lodash"
|
||||
- secure: "tg1JFsIFnxzLaTboFPOnm+aJCuMm5+JdhLlESlqg9x3fwro++7KCnwHKLNovhchaPe4otC43ZMB/nfWhDnDm11dKbm/V6HlTkED+dadTsaLxVDg6J+7yK41QhokBPJOxLV78iDaNaAQVYEirAgZ0yn8kFubxmNKV+bpCGQNc9yU="
|
||||
matrix:
|
||||
- BUILD="compat"
|
||||
- BUILD="modern"
|
||||
- BUILD="modern"
|
||||
- BUILD="modern" ISTANBUL=true
|
||||
-
|
||||
- BIN="phantomjs"
|
||||
- BIN="rhino" OPTION="-opt -1"
|
||||
- BIN="rhino" OPTION="-opt -1 -require"
|
||||
- BIN="ringo" OPTION="-o -1"
|
||||
- ISTANBUL=true
|
||||
- SAUCE_LABS=true
|
||||
matrix:
|
||||
include:
|
||||
- node_js: "iojs"
|
||||
env:
|
||||
- node_js: "iojs"
|
||||
env: BUILD="modern"
|
||||
- node_js: "0.8"
|
||||
env: NPM_VERSION="~1.4.0"
|
||||
- node_js: "0.8"
|
||||
env: BUILD="modern" NPM_VERSION="~1.4.0"
|
||||
- node_js: "0.10"
|
||||
env:
|
||||
- node_js: "0.10"
|
||||
env: BUILD="modern"
|
||||
- node_js: "0.12"
|
||||
env: SAUCE_LABS=true
|
||||
- node_js: "0.12"
|
||||
env: SAUCE_LABS=true BUILD="modern"
|
||||
env:
|
||||
- node_js: "4"
|
||||
env:
|
||||
git:
|
||||
depth: 10
|
||||
branches:
|
||||
@@ -47,30 +33,45 @@ notifications:
|
||||
on_failure: always
|
||||
before_install:
|
||||
- "nvm use $TRAVIS_NODE_VERSION"
|
||||
- "npm config set loglevel error"
|
||||
- "npm i -g npm@\"$NPM_VERSION\""
|
||||
- "[ $SAUCE_LABS == false ] || npm i chalk@\"^1.0.0\" ecstatic@\"0.8.0\" request@\"^2.0.0\" sauce-tunnel@\"2.2.3\""
|
||||
- "[ $ISTANBUL == false ] || (npm i -g coveralls@\"^2.0.0\" && npm i istanbul@\"0.3.17\")"
|
||||
- "[ $BIN != 'rhino' ] || (sudo mkdir /opt/rhino-1.7.6 && sudo wget --no-check-certificate -O $_/js.jar https://lodash.com/_travis/rhino-1.7.6.jar)"
|
||||
- "[ $BIN != 'rhino' ] || (echo -e '#!/bin/sh\\njava -jar /opt/rhino-1.7.6/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino)"
|
||||
- "[ $BIN != 'ringo' ] || (wget --no-check-certificate https://lodash.com/_travis/ringojs-0.11.zip && sudo unzip ringojs-0.11 -d /opt && rm ringojs-0.11.zip)"
|
||||
- "[ $BIN != 'ringo' ] || (sudo ln -s /opt/ringojs-0.11/bin/ringo /usr/local/bin/ringo && sudo chmod +x $_)"
|
||||
- "perl -pi -e 's|\"lodash\"|\"lodash-compat\"|' ./package.json"
|
||||
- "git clone --depth=10 --branch=master git://github.com/lodash/lodash-cli ./node_modules/lodash-cli && mkdir $_/node_modules && cd $_ && ln -s ../../../ ./lodash-compat && cd ../ && npm i && cd ../../"
|
||||
- "node ./node_modules/lodash-cli/bin/lodash $BUILD -o ./lodash.$BUILD.js"
|
||||
- "npm set loglevel error"
|
||||
- "npm set progress false"
|
||||
- "npm i -g npm@\"^2.0.0\""
|
||||
- |
|
||||
PATTERN[0]="|\s*if\s*\(isHostObject\b[\s\S]+?\}(?=\n)|"
|
||||
PATTERN[1]="|\s*if\s*\(enumerate\b[\s\S]+?\};\s*\}|"
|
||||
PATTERN[2]="|\s*while\s*\([^)]+\)\s*\{\s*iteratee\(index\);\s*\}|"
|
||||
PATTERN[3]="|\s*else\s*\{\s*assocSet\(data\b[\s\S]+?\}|"
|
||||
PATTERN[4]="|\s*if\s*\(ctorString\b[\s\S]+?\}\s*\}|"
|
||||
PATTERN[5]="|\bindex,\s*iterable\)\s*===\s*false\)[^}]+?(break;)|"
|
||||
PATTERN[6]="|\s*if\s*\(!lodashFunc\)\s*\{\s*return;\s*\}|"
|
||||
PATTERN[7]="|\s*define\([\s\S]+?\);|"
|
||||
PATTERN[8]="|\s*root\._\s*=\s*_;|"
|
||||
|
||||
if [ $ISTANBUL == true ]; then
|
||||
set -e
|
||||
for PTRN in ${PATTERN[@]}; do
|
||||
node ./test/remove.js "$PTRN" ./lodash.js
|
||||
done
|
||||
fi
|
||||
- "git clone --depth=10 --branch=master git://github.com/lodash/lodash-cli ./node_modules/lodash-cli && mkdir $_/node_modules && cd $_ && ln -s ../../../ ./lodash && cd ../ && npm i && cd ../../"
|
||||
- "node ./node_modules/lodash-cli/bin/lodash -o ./dist/lodash.js"
|
||||
script:
|
||||
- "[ $ISTANBUL == false ] || cp ./lodash.$BUILD.js ./lodash.js"
|
||||
- "[ $ISTANBUL == false ] || perl -0pi -e \"$PATTERN\" ./lodash.js"
|
||||
- "[ $ISTANBUL == false ] || node ./node_modules/istanbul/lib/cli.js cover -x \"**/vendor/**\" --report lcovonly ./test/test.js -- ./lodash.js"
|
||||
- "[ $ISTANBUL == false ] || istanbul cover -x \"**/vendor/**\" --report lcovonly ./test/test.js -- ./lodash.js"
|
||||
- "[ $ISTANBUL == false ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || (cat ./coverage/lcov.info | coveralls) || true"
|
||||
- "[ $ISTANBUL == false ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || (cat ./coverage/coverage.json | codecov) || true"
|
||||
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || cd ./test"
|
||||
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || $BIN $OPTION ./test.js ../lodash.$BUILD.js"
|
||||
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || $BIN $OPTION ./test.js ../lodash.$BUILD.min.js"
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.js&noglobals=true\" tags=\"$BUILD,development\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.min.js&noglobals=true\" tags=\"$BUILD,production\""
|
||||
- "[ $SAUCE_LABS == false ] || [ $BUILD != 'compat' ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.js\" tags=\"$BUILD,development,ie-compat\" compatMode=7"
|
||||
- "[ $SAUCE_LABS == false ] || [ $BUILD != 'compat' ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.min.js\" tags=\"$BUILD,production,ie-compat\" compatMode=7"
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../lodash.$BUILD.min.js\" tags=\"$BUILD,production,backbone\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../lodash.$BUILD.js\" tags=\"$BUILD,development,backbone\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../lodash.$BUILD.min.js\" tags=\"$BUILD,production,underscore\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../lodash.$BUILD.js\" tags=\"$BUILD,development,underscore\""
|
||||
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || $BIN $OPTION ./test.js ../lodash.js"
|
||||
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || $BIN $OPTION ./test.js ../dist/lodash.min.js"
|
||||
- "[ $SAUCE_LABS == false ] || rm -rf ./node_modules/lodash"
|
||||
- "[ $SAUCE_LABS == false ] || ($BIN ./node_modules/lodash-cli/bin/lodash modularize exports=node -o ./node_modules/lodash && node ./node_modules/lodash-cli/bin/lodash -d -o ./node_modules/lodash/index.js)"
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./node_modules/lodash-cli/bin/lodash core -o ./dist/lodash.core.js"
|
||||
- "[ $SAUCE_LABS == false ] || npm run build"
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../dist/lodash.js&noglobals=true\" tags=\"development\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../dist/lodash.min.js&noglobals=true\" tags=\"production\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash-fp tests\" runner=\"test/fp.html?noglobals=true\" tags=\"development\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../dist/lodash.js\" tags=\"development,underscore\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../dist/lodash.min.js\" tags=\"production,underscore\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../dist/lodash.js\" tags=\"development,backbone\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../dist/lodash.min.js\" tags=\"production,backbone\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../dist/lodash.core.js\" tags=\"development,backbone\""
|
||||
- "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../dist/lodash.core.min.js\" tags=\"production,backbone\""
|
||||
|
||||
49
CODE_OF_CONDUCT.md
Normal file
49
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
As contributors and maintainers of this project, and in the interest of
|
||||
fostering an open and welcoming community, we pledge to respect all people who
|
||||
contribute through reporting issues, posting feature requests, updating
|
||||
documentation, submitting pull requests or patches, and other activities.
|
||||
|
||||
We are committed to making participation in this project a harassment-free
|
||||
experience for everyone, regardless of level of experience, gender, gender
|
||||
identity and expression, sexual orientation, disability, personal appearance,
|
||||
body size, race, ethnicity, age, religion, or nationality.
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery
|
||||
* Personal attacks
|
||||
* Trolling or insulting/derogatory comments
|
||||
* Public or private harassment
|
||||
* Publishing other's private information, such as physical or electronic
|
||||
addresses, without explicit permission
|
||||
* Other unethical or unprofessional conduct
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
By adopting this Code of Conduct, project maintainers commit themselves to
|
||||
fairly and consistently applying these principles to every aspect of managing
|
||||
this project. Project maintainers who do not follow or enforce the Code of
|
||||
Conduct may be permanently removed from the project team.
|
||||
|
||||
This code of conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting a project maintainer at
|
||||
[coc@lodash.com](mailto:coc@lodash.com). All complaints will be reviewed and
|
||||
investigated and will result in a response that is deemed necessary and
|
||||
appropriate to the circumstances. Maintainers are obligated to maintain
|
||||
confidentiality with regard to the reporter of an incident.
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 1.3.0, available at
|
||||
[http://contributor-covenant.org/version/1/3/0/][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/3/0/
|
||||
@@ -1,17 +1,15 @@
|
||||
# Contributing to lodash
|
||||
|
||||
If you’d like to contribute a feature or bug fix, you can [fork](https://help.github.com/articles/fork-a-repo/) lodash, commit your changes, & [send a pull request](https://help.github.com/articles/using-pull-requests/).
|
||||
Please make sure to [search the issue tracker](https://github.com/lodash/lodash/issues) first; your issue may have already been discussed or fixed in `master`.
|
||||
Contributions are always welcome. Before contributing, please read the [code of conduct](https://github.com/lodash/lodash/blob/master/CODE_OF_CONDUCT.md) & [search the issue tracker](https://github.com/lodash/lodash/issues);
|
||||
your issue may have already been discussed or fixed in `master`. To contribute, [fork](https://help.github.com/articles/fork-a-repo/) lodash, commit your changes, & [send a pull request](https://help.github.com/articles/using-pull-requests/).
|
||||
|
||||
## Tests
|
||||
|
||||
Include updated unit tests in the `test` directory as part of your pull request.
|
||||
Don’t worry about regenerating the documentation, lodash.js, or lodash.min.js.
|
||||
Don’t worry about regenerating the `dist/` or `doc/` files.
|
||||
|
||||
Before running the unit tests you’ll need to install, `npm i`, [development dependencies](https://docs.npmjs.com/files/package.json#devdependencies).
|
||||
Run unit tests from the command-line via `node test/test`, or open `test/index.html` in a web browser.
|
||||
|
||||
The `test/run-test.sh` script attempts to run the tests in [Rhino](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino), [RingoJS](http://ringojs.org/), [PhantomJS](http://phantomjs.org/), & [Node](http://nodejs.org/), before running them in your default browser.
|
||||
Run unit tests from the command-line via `npm test`, or open `test/index.html` & `test/fp.html` in a web browser.
|
||||
The [Backbone](http://backbonejs.org/) & [Underscore](http://underscorejs.org/) test suites are included as well.
|
||||
|
||||
## Contributor License Agreement
|
||||
@@ -36,4 +34,10 @@ In addition to the following guidelines, please follow the conventions already e
|
||||
Single-quoted strings are preferred to double-quoted strings; however, please use a double-quoted string if the value contains a single-quote character to avoid unnecessary escaping.
|
||||
|
||||
- **Comments**:<br>
|
||||
Please use single-line comments to annotate significant additions, & [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for new methods.
|
||||
Please use single-line comments to annotate significant additions, & [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for functions.
|
||||
|
||||
Guidelines are enforced using [JSCS](https://www.npmjs.com/package/jscs):
|
||||
|
||||
```bash
|
||||
$ npm run style
|
||||
```
|
||||
|
||||
4
LICENSE
4
LICENSE
@@ -1,5 +1,5 @@
|
||||
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas,
|
||||
Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||
Based on Underscore.js, copyright 2009-2016 Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
||||
17
README.md
17
README.md
@@ -1,10 +1,12 @@
|
||||
# lodash v3.10.0
|
||||
# lodash v4.1.0
|
||||
|
||||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) with packages for [Bower](http://bower.io/), [Component](http://component.github.io/), & [Volo](http://volojs.org/).
|
||||
The [lodash](https://lodash.com/) library exported as a [UMD](https://github.com/umdjs/umd) module.
|
||||
|
||||
Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
|
||||
```bash
|
||||
$ lodash modern -o ./lodash.js
|
||||
$ npm run build
|
||||
$ lodash -o ./dist/lodash.js
|
||||
$ lodash core -o ./dist/lodash.core.js
|
||||
```
|
||||
|
||||
## Community
|
||||
@@ -13,17 +15,16 @@ $ lodash modern -o ./lodash.js
|
||||
|
||||
## Module formats
|
||||
|
||||
lodash is also available in a variety of other builds & module formats.
|
||||
Lodash is also available in a variety of other builds & module formats.
|
||||
|
||||
* npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds
|
||||
* AMD modules for [modern](https://github.com/lodash/lodash/tree/3.10.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.10.0-amd) builds
|
||||
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.10.0-es) build
|
||||
* [lodash](https://www.npmjs.com/package/lodash) & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) packages
|
||||
* [lodash-amd](https://www.npmjs.com/package/lodash-amd)
|
||||
* [lodash-es](https://www.npmjs.com/package/lodash-es) & [babel-plugin-lodash](https://www.npmjs.com/package/babel-plugin-lodash)
|
||||
|
||||
## Further Reading
|
||||
|
||||
* [API Documentation](https://lodash.com/docs)
|
||||
* [Build Differences](https://github.com/lodash/lodash/wiki/Build-Differences)
|
||||
* [Changelog](https://github.com/lodash/lodash/wiki/Changelog)
|
||||
* [Release Notes](https://github.com/lodash/lodash/releases)
|
||||
* [Roadmap](https://github.com/lodash/lodash/wiki/Roadmap)
|
||||
* [More Resources](https://github.com/lodash/lodash/wiki/Resources)
|
||||
|
||||
19
bower.json
19
bower.json
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "lodash",
|
||||
"main": "lodash.js",
|
||||
"ignore": [
|
||||
".*",
|
||||
"*.custom.*",
|
||||
"*.log",
|
||||
"*.map",
|
||||
"*.md",
|
||||
"lodash.src.js",
|
||||
"component.json",
|
||||
"package.json",
|
||||
"doc",
|
||||
"node_modules",
|
||||
"perf",
|
||||
"test",
|
||||
"vendor"
|
||||
]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "lodash",
|
||||
"repo": "lodash/lodash",
|
||||
"version": "3.10.0",
|
||||
"description": "The modern build of lodash.",
|
||||
"license": "MIT",
|
||||
"main": "lodash.js",
|
||||
"keywords": ["stdlib", "util"],
|
||||
"scripts": ["lodash.js"]
|
||||
}
|
||||
3813
dist/lodash.core.js
vendored
Normal file
3813
dist/lodash.core.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
30
dist/lodash.core.min.js
vendored
Normal file
30
dist/lodash.core.min.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @license
|
||||
* lodash 4.1.0 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
|
||||
* Build: `lodash core -o ./dist/lodash.core.js`
|
||||
*/
|
||||
;(function(){function n(n,t){for(var r=-1,e=t.length,u=n.length;++r<e;)n[u+r]=t[r];return n}function t(n,t,r){for(var e=-1,u=n.length;++e<u;){var o=n[e],i=t(o);if(null!=i&&(c===an?i===i:r(i,c)))var c=i,f=o}return f}function r(n,t,r){var e;return r(n,function(n,r,u){return t(n,r,u)?(e=n,false):void 0}),e}function e(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function u(n,t){return w(t,function(t){return n[t]})}function o(n){return n&&n.Object===Object?n:null}function i(n){return hn[n];
|
||||
}function c(n){var t=false;if(null!=n&&typeof n.toString!="function")try{t=!!(n+"")}catch(r){}return t}function f(n,t){return n=typeof n=="number"||sn.test(n)?+n:-1,n>-1&&0==n%1&&(null==t?9007199254740991:t)>n}function a(n){if(Y(n)&&!Mn(n)){if(n instanceof l)return n;if(xn.call(n,"__wrapped__")){var t=new l(n.__wrapped__,n.__chain__);return t.__actions__=k(n.__actions__),t}}return new l(n)}function l(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t}function p(n,t,r,e){return n===an||V(n,On[r])&&!xn.call(e,r)?t:n;
|
||||
}function s(n,t,r){if(typeof n!="function")throw new TypeError("Expected a function");return setTimeout(function(){n.apply(an,r)},t)}function h(n,t){var r=true;return In(n,function(n,e,u){return r=!!t(n,e,u)}),r}function v(n,t){var r=[];return In(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function y(t,r,e,u){u||(u=[]);for(var o=-1,i=t.length;++o<i;){var c=t[o];Y(c)&&L(c)&&(e||Mn(c)||K(c))?r?y(c,r,e,u):n(u,c):e||(u[u.length]=c)}return u}function _(n,t){return n&&$n(n,t,en)}function g(n,t){return v(t,function(t){
|
||||
return Q(n[t])})}function b(n,t,r,e,u){return n===t?true:null==n||null==t||!X(n)&&!Y(t)?n!==n&&t!==t:j(n,t,b,r,e,u)}function j(n,t,r,e,u,o){var i=Mn(n),f=Mn(t),a="[object Array]",l="[object Array]";i||(a=An.call(n),"[object Arguments]"==a&&(a="[object Object]")),f||(l=An.call(t),"[object Arguments]"==l&&(l="[object Object]"));var p="[object Object]"==a&&!c(n),f="[object Object]"==l&&!c(t);return!(l=a==l)||i||p?2&u||(a=p&&xn.call(n,"__wrapped__"),f=f&&xn.call(t,"__wrapped__"),!a&&!f)?l?(o||(o=[]),(a=G(o,function(t){
|
||||
return t[0]===n}))&&a[1]?a[1]==t:(o.push([n,t]),t=(i?D:$)(n,t,r,e,u,o),o.pop(),t)):false:r(a?n.value():n,f?t.value():t,e,u,o):I(n,t,a)}function m(n){var t=typeof n;return"function"==t?n:null==n?cn:("object"==t?O:E)(n)}function d(n){n=null==n?n:Object(n);var t,r=[];for(t in n)r.push(t);return r}function w(n,t){var r=-1,e=L(n)?Array(n.length):[];return In(n,function(n,u,o){e[++r]=t(n,u,o)}),e}function O(n){var t=en(n);return function(r){var e=t.length;if(null==r)return!e;for(r=Object(r);e--;){var u=t[e];
|
||||
if(!(u in r&&b(n[u],r[u],an,3)))return false}return true}}function x(n,t){return n=Object(n),M(t,function(t,r){return r in n&&(t[r]=n[r]),t},{})}function E(n){return function(t){return null==t?an:t[n]}}function A(n,t,r){var e=-1,u=n.length;for(0>t&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++e<u;)r[e]=n[e+t];return r}function k(n){return A(n,0,n.length)}function N(n,t){var r;return In(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function S(t,r){return M(r,function(t,r){return r.func.apply(r.thisArg,n([t],r.args));
|
||||
},t)}function T(n,t,r,e){r||(r={});for(var u=-1,o=t.length;++u<o;){var i=t[u],c=e?e(r[i],n[i],i,r,n):n[i],f=r,a=f[i];(!V(a,c)||V(a,On[i])&&!xn.call(f,i)||c===an&&!(i in f))&&(f[i]=c)}return r}function F(n){return U(function(t,r){var e=-1,u=r.length,o=u>1?r[u-1]:an,o=typeof o=="function"?(u--,o):an;for(t=Object(t);++e<u;){var i=r[e];i&&n(t,i,e,o)}return t})}function B(n){return function(){var t=arguments,r=Dn(n.prototype),t=n.apply(r,t);return X(t)?t:r}}function R(n,t,r){function e(){for(var o=-1,i=arguments.length,c=-1,f=r.length,a=Array(f+i),l=this&&this!==dn&&this instanceof e?u:n;++c<f;)a[c]=r[c];
|
||||
for(;i--;)a[c++]=arguments[++o];return l.apply(t,a)}if(typeof n!="function")throw new TypeError("Expected a function");var u=B(n);return e}function D(n,t,r,e,u,o){var i=-1,c=1&u,f=n.length,a=t.length;if(f!=a&&!(2&u&&a>f))return false;for(a=true;++i<f;){var l=n[i],p=t[i];if(void 0!==an){a=false;break}if(c){if(!N(t,function(n){return l===n||r(l,n,e,u,o)})){a=false;break}}else if(l!==p&&!r(l,p,e,u,o)){a=false;break}}return a}function I(n,t,r){switch(r){case"[object Boolean]":case"[object Date]":return+n==+t;case"[object Error]":
|
||||
return n.name==t.name&&n.message==t.message;case"[object Number]":return n!=+n?t!=+t:n==+t;case"[object RegExp]":case"[object String]":return n==t+""}return false}function $(n,t,r,e,u,o){var i=2&u,c=en(n),f=c.length,a=en(t).length;if(f!=a&&!i)return false;for(var l=f;l--;){var p=c[l];if(!(i?p in t:xn.call(t,p)))return false}for(a=true;++l<f;){var p=c[l],s=n[p],h=t[p];if(void 0!==an||s!==h&&!r(s,h,e,u,o)){a=false;break}i||(i="constructor"==p)}return a&&!i&&(r=n.constructor,e=t.constructor,r!=e&&"constructor"in n&&"constructor"in t&&!(typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)&&(a=false)),
|
||||
a}function q(n){var t=n?n.length:an;if(W(t)&&(Mn(n)||nn(n)||K(n))){n=String;for(var r=-1,e=Array(t);++r<t;)e[r]=n(r);t=e}else t=null;return t}function z(n){var t=n&&n.constructor;return n===(typeof t=="function"&&t.prototype||On)}function C(n){return n?n[0]:an}function G(n,t){return r(n,m(t),In)}function J(n,t){return In(n,typeof t=="function"?t:cn)}function M(n,t,r){return e(n,m(t),r,3>arguments.length,In)}function P(n,t){var r;if(typeof t!="function")throw new TypeError("Expected a function");return n=Pn(n),
|
||||
function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=an),r}}function U(n){var t;if(typeof n!="function")throw new TypeError("Expected a function");return t=Rn(t===an?n.length-1:Pn(t),0),function(){for(var r=arguments,e=-1,u=Rn(r.length-t,0),o=Array(u);++e<u;)o[e]=r[t+e];for(u=Array(t+1),e=-1;++e<t;)u[e]=r[e];return u[t]=o,n.apply(this,u)}}function V(n,t){return n===t||n!==n&&t!==t}function H(n,t){return n>t}function K(n){return Y(n)&&L(n)&&xn.call(n,"callee")&&(!Tn.call(n,"callee")||"[object Arguments]"==An.call(n));
|
||||
}function L(n){return null!=n&&!(typeof n=="function"&&Q(n))&&W(qn(n))}function Q(n){return n=X(n)?An.call(n):"","[object Function]"==n||"[object GeneratorFunction]"==n}function W(n){return typeof n=="number"&&n>-1&&0==n%1&&9007199254740991>=n}function X(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function Y(n){return!!n&&typeof n=="object"}function Z(n){return typeof n=="number"||Y(n)&&"[object Number]"==An.call(n)}function nn(n){return typeof n=="string"||!Mn(n)&&Y(n)&&"[object String]"==An.call(n);
|
||||
}function tn(n,t){return t>n}function rn(n){return typeof n=="string"?n:null==n?"":n+""}function en(n){var t=z(n);if(!t&&!L(n))return Bn(Object(n));var r,e=q(n),u=!!e,e=e||[],o=e.length;for(r in n)!xn.call(n,r)||u&&("length"==r||f(r,o))||t&&"constructor"==r||e.push(r);return e}function un(n){for(var t=-1,r=z(n),e=d(n),u=e.length,o=q(n),i=!!o,o=o||[],c=o.length;++t<u;){var a=e[t];i&&("length"==a||f(a,c))||"constructor"==a&&(r||!xn.call(n,a))||o.push(a)}return o}function on(n){return n?u(n,en(n)):[];
|
||||
}function cn(n){return n}function fn(t,r,e){var u=en(r),o=g(r,u);null!=e||X(r)&&(o.length||!u.length)||(e=r,r=t,t=this,o=g(r,en(r)));var i=X(e)&&"chain"in e?e.chain:true,c=Q(t);return In(o,function(e){var u=r[e];t[e]=u,c&&(t.prototype[e]=function(){var r=this.__chain__;if(i||r){var e=t(this.__wrapped__);return(e.__actions__=k(this.__actions__)).push({func:u,args:arguments,thisArg:t}),e.__chain__=r,e}return u.apply(t,n([this.value()],arguments))})}),t}var an,ln=/[&<>"'`]/g,pn=RegExp(ln.source),sn=/^(?:0|[1-9]\d*)$/,hn={
|
||||
"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},vn={"function":true,object:true},yn=vn[typeof exports]&&exports&&!exports.nodeType?exports:null,_n=vn[typeof module]&&module&&!module.nodeType?module:null,gn=o(vn[typeof self]&&self),bn=o(vn[typeof window]&&window),jn=_n&&_n.exports===yn?yn:null,mn=o(vn[typeof this]&&this),dn=o(yn&&_n&&typeof global=="object"&&global)||bn!==(mn&&mn.window)&&bn||gn||mn||Function("return this")(),wn=Array.prototype,On=Object.prototype,xn=On.hasOwnProperty,En=0,An=On.toString,kn=dn._,Nn=dn.f,Sn=Nn?Nn.g:an,Tn=On.propertyIsEnumerable,Fn=dn.isFinite,Bn=Object.keys,Rn=Math.max,Dn=function(){
|
||||
function n(){}return function(t){if(X(t)){n.prototype=t;var r=new n;n.prototype=an}return r||{}}}(),In=function(n,t){return function(r,e){if(null==r)return r;if(!L(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++o<u)&&false!==e(i[o],o,i););return r}}(_),$n=function(n){return function(t,r,e){var u=-1,o=Object(t);e=e(t);for(var i=e.length;i--;){var c=e[n?i:++u];if(false===r(o[c],c,o))break}return t}}();Sn&&!Tn.call({valueOf:1},"valueOf")&&(d=function(n){n=Sn(n);for(var t,r=[];!(t=n.next()).done;)r.push(t.value);
|
||||
return r});var qn=E("length"),zn=U(function(t,r){return Mn(t)||(t=null==t?[]:[Object(t)]),y(r),n(k(t),on)}),Cn=U(function(n,t,r){return R(n,t,r)}),Gn=U(function(n,t){return s(n,1,t)}),Jn=U(function(n,t,r){return s(n,Un(t)||0,r)}),Mn=Array.isArray,Pn=Number,Un=Number,Vn=F(function(n,t){T(t,en(t),n)}),Hn=F(function(n,t){T(t,un(t),n)}),Kn=F(function(n,t,r,e){T(t,un(t),n,e)}),Ln=U(function(n){return n.push(an,p),Kn.apply(an,n)}),Qn=U(function(n,t){return null==n?{}:x(n,y(t))}),Wn=m;l.prototype=Dn(a.prototype),
|
||||
l.prototype.constructor=l,a.assignIn=Hn,a.before=P,a.bind=Cn,a.chain=function(n){return n=a(n),n.__chain__=true,n},a.compact=function(n){return v(n,Boolean)},a.concat=zn,a.create=function(n,t){var r=Dn(n);return t?Vn(r,t):r},a.defaults=Ln,a.defer=Gn,a.delay=Jn,a.filter=function(n,t){return v(n,m(t))},a.flatten=function(n){return n&&n.length?y(n):[]},a.flattenDeep=function(n){return n&&n.length?y(n,true):[]},a.iteratee=Wn,a.keys=en,a.map=function(n,t){return w(n,m(t))},a.matches=function(n){return O(Vn({},n));
|
||||
},a.mixin=fn,a.negate=function(n){if(typeof n!="function")throw new TypeError("Expected a function");return function(){return!n.apply(this,arguments)}},a.once=function(n){return P(2,n)},a.pick=Qn,a.slice=function(n,t,r){var e=n?n.length:0;return r=r===an?e:+r,e?A(n,null==t?0:+t,r):[]},a.sortBy=function(n,t){var r=0;return t=m(t),w(w(n,function(n,e,u){return{c:n,b:r++,a:t(n,e,u)}}).sort(function(n,t){var r;n:{r=n.a;var e=t.a;if(r!==e){var u=null===r,o=r===an,i=r===r,c=null===e,f=e===an,a=e===e;if(r>e&&!c||!i||u&&!f&&a||o&&a){
|
||||
r=1;break n}if(e>r&&!u||!a||c&&!o&&i||f&&i){r=-1;break n}}r=0}return r||n.b-t.b}),E("c"))},a.tap=function(n,t){return t(n),n},a.thru=function(n,t){return t(n)},a.toArray=function(n){return L(n)?n.length?k(n):[]:on(n)},a.values=on,a.extend=Hn,fn(a,a),a.clone=function(n){return X(n)?Mn(n)?k(n):T(n,en(n)):n},a.escape=function(n){return(n=rn(n))&&pn.test(n)?n.replace(ln,i):n},a.every=function(n,t,r){return t=r?an:t,h(n,m(t))},a.find=G,a.forEach=J,a.has=function(n,t){return null!=n&&xn.call(n,t)},a.head=C,
|
||||
a.identity=cn,a.indexOf=function(n,t,r){var e=n?n.length:0;r=typeof r=="number"?0>r?Rn(e+r,0):r:0,r=(r||0)-1;for(var u=t===t;++r<e;){var o=n[r];if(u?o===t:o!==o)return r}return-1},a.isArguments=K,a.isArray=Mn,a.isBoolean=function(n){return true===n||false===n||Y(n)&&"[object Boolean]"==An.call(n)},a.isDate=function(n){return Y(n)&&"[object Date]"==An.call(n)},a.isEmpty=function(n){if(L(n)&&(Mn(n)||nn(n)||Q(n.splice)||K(n)))return!n.length;for(var t in n)if(xn.call(n,t))return false;return true},a.isEqual=function(n,t){
|
||||
return b(n,t)},a.isFinite=function(n){return typeof n=="number"&&Fn(n)},a.isFunction=Q,a.isNaN=function(n){return Z(n)&&n!=+n},a.isNull=function(n){return null===n},a.isNumber=Z,a.isObject=X,a.isRegExp=function(n){return X(n)&&"[object RegExp]"==An.call(n)},a.isString=nn,a.isUndefined=function(n){return n===an},a.last=function(n){var t=n?n.length:0;return t?n[t-1]:an},a.max=function(n){return n&&n.length?t(n,cn,H):an},a.min=function(n){return n&&n.length?t(n,cn,tn):an},a.noConflict=function(){return dn._===this&&(dn._=kn),
|
||||
this},a.noop=function(){},a.reduce=M,a.result=function(n,t,r){return t=null==n?an:n[t],t===an&&(t=r),Q(t)?t.call(n):t},a.size=function(n){return null==n?0:(n=L(n)?n:en(n),n.length)},a.some=function(n,t,r){return t=r?an:t,N(n,m(t))},a.uniqueId=function(n){var t=++En;return rn(n)+t},a.each=J,a.first=C,fn(a,function(){var n={};return _(a,function(t,r){xn.call(a.prototype,r)||(n[r]=t)}),n}(),{chain:false}),a.VERSION="4.1.0",In("pop join replace reverse split push shift sort splice unshift".split(" "),function(n){
|
||||
var t=(/^(?:replace|split)$/.test(n)?String.prototype:wn)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|join|replace|shift)$/.test(n);a.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),a.prototype.toJSON=a.prototype.valueOf=a.prototype.value=function(){return S(this.__wrapped__,this.__actions__)},(bn||gn||{})._=a,typeof define=="function"&&typeof define.amd=="object"&&define.amd? define(function(){
|
||||
return a}):yn&&_n?(jn&&((_n.exports=a)._=a),yn._=a):dn._=a}).call(this);
|
||||
534
dist/lodash.fp.js
vendored
Normal file
534
dist/lodash.fp.js
vendored
Normal file
@@ -0,0 +1,534 @@
|
||||
(function webpackUniversalModuleDefinition(root, factory) {
|
||||
if(typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = factory();
|
||||
else if(typeof define === 'function' && define.amd)
|
||||
define([], factory);
|
||||
else if(typeof exports === 'object')
|
||||
exports["fp"] = factory();
|
||||
else
|
||||
root["fp"] = factory();
|
||||
})(this, function() {
|
||||
return /******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId])
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ exports: {},
|
||||
/******/ id: moduleId,
|
||||
/******/ loaded: false
|
||||
/******/ };
|
||||
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.loaded = true;
|
||||
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
|
||||
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(0);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var baseConvert = __webpack_require__(1);
|
||||
|
||||
/**
|
||||
* Converts `lodash` to an immutable auto-curried iteratee-first data-last version.
|
||||
*
|
||||
* @param {Function} lodash The lodash function.
|
||||
* @returns {Function} Returns the converted `lodash`.
|
||||
*/
|
||||
function browserConvert(lodash) {
|
||||
return baseConvert(lodash, lodash);
|
||||
}
|
||||
|
||||
module.exports = browserConvert;
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 1 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var mapping = __webpack_require__(2),
|
||||
mutateMap = mapping.mutate,
|
||||
placeholder = {};
|
||||
|
||||
/**
|
||||
* The base implementation of `convert` which accepts a `util` object of methods
|
||||
* required to perform conversions.
|
||||
*
|
||||
* @param {Object} util The util object.
|
||||
* @param {string} name The name of the function to wrap.
|
||||
* @param {Function} func The function to wrap.
|
||||
* @returns {Function|Object} Returns the converted function or object.
|
||||
*/
|
||||
function baseConvert(util, name, func) {
|
||||
if (typeof func != 'function') {
|
||||
func = name;
|
||||
name = undefined;
|
||||
}
|
||||
if (func == null) {
|
||||
throw new TypeError;
|
||||
}
|
||||
var isLib = name === undefined && typeof func.VERSION == 'string';
|
||||
|
||||
var _ = isLib ? func : {
|
||||
'ary': util.ary,
|
||||
'cloneDeep': util.cloneDeep,
|
||||
'curry': util.curry,
|
||||
'forEach': util.forEach,
|
||||
'isFunction': util.isFunction,
|
||||
'iteratee': util.iteratee,
|
||||
'keys': util.keys,
|
||||
'rearg': util.rearg
|
||||
};
|
||||
|
||||
var ary = _.ary,
|
||||
cloneDeep = _.cloneDeep,
|
||||
curry = _.curry,
|
||||
each = _.forEach,
|
||||
isFunction = _.isFunction,
|
||||
keys = _.keys,
|
||||
rearg = _.rearg;
|
||||
|
||||
var baseArity = function(func, n) {
|
||||
return n == 2
|
||||
? function(a, b) { return func.apply(undefined, arguments); }
|
||||
: function(a) { return func.apply(undefined, arguments); };
|
||||
};
|
||||
|
||||
var baseAry = function(func, n) {
|
||||
return n == 2
|
||||
? function(a, b) { return func(a, b); }
|
||||
: function(a) { return func(a); };
|
||||
};
|
||||
|
||||
var cloneArray = function(array) {
|
||||
var length = array ? array.length : 0,
|
||||
result = Array(length);
|
||||
|
||||
while (length--) {
|
||||
result[length] = array[length];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var createCloner = function(func) {
|
||||
return function(object) {
|
||||
return func({}, object);
|
||||
};
|
||||
};
|
||||
|
||||
var immutWrap = function(func, cloner) {
|
||||
return overArg(func, cloner, true);
|
||||
};
|
||||
|
||||
var iterateeAry = function(func, n) {
|
||||
return overArg(func, function(func) {
|
||||
return baseAry(func, n);
|
||||
});
|
||||
};
|
||||
|
||||
var iterateeRearg = function(func, indexes) {
|
||||
return overArg(func, function(func) {
|
||||
var n = indexes.length;
|
||||
return baseArity(rearg(baseAry(func, n), indexes), n);
|
||||
});
|
||||
};
|
||||
|
||||
var overArg = function(func, iteratee, retArg) {
|
||||
return function() {
|
||||
var length = arguments.length,
|
||||
args = Array(length);
|
||||
|
||||
while (length--) {
|
||||
args[length] = arguments[length];
|
||||
}
|
||||
args[0] = iteratee(args[0]);
|
||||
var result = func.apply(undefined, args);
|
||||
return retArg ? args[0] : result;
|
||||
};
|
||||
};
|
||||
|
||||
var wrappers = {
|
||||
'iteratee': function(iteratee) {
|
||||
return function() {
|
||||
var func = arguments[0],
|
||||
arity = arguments[1];
|
||||
|
||||
arity = arity > 2 ? (arity - 2) : 1;
|
||||
func = iteratee(func);
|
||||
var length = func.length;
|
||||
return (length && length <= arity) ? func : baseAry(func, arity);
|
||||
};
|
||||
},
|
||||
'mixin': function(mixin) {
|
||||
return function(source) {
|
||||
var func = this;
|
||||
if (!isFunction(func)) {
|
||||
return mixin(func, Object(source));
|
||||
}
|
||||
var methods = [],
|
||||
methodNames = [];
|
||||
|
||||
each(keys(source), function(key) {
|
||||
var value = source[key];
|
||||
if (isFunction(value)) {
|
||||
methodNames.push(key);
|
||||
methods.push(func.prototype[key]);
|
||||
}
|
||||
});
|
||||
|
||||
mixin(func, Object(source));
|
||||
|
||||
each(methodNames, function(methodName, index) {
|
||||
var method = methods[index];
|
||||
if (isFunction(method)) {
|
||||
func.prototype[methodName] = method;
|
||||
} else {
|
||||
delete func.prototype[methodName];
|
||||
}
|
||||
});
|
||||
return func;
|
||||
};
|
||||
},
|
||||
'runInContext': function(runInContext) {
|
||||
return function(context) {
|
||||
return baseConvert(util, runInContext(context));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var wrap = function(name, func) {
|
||||
name = mapping.aliasToReal[name] || name;
|
||||
var wrapper = wrappers[name];
|
||||
if (wrapper) {
|
||||
return wrapper(func);
|
||||
}
|
||||
if (mutateMap.array[name]) {
|
||||
func = immutWrap(func, cloneArray);
|
||||
}
|
||||
else if (mutateMap.object[name]) {
|
||||
func = immutWrap(func, createCloner(func));
|
||||
}
|
||||
else if (mutateMap.set[name]) {
|
||||
func = immutWrap(func, cloneDeep);
|
||||
}
|
||||
var result;
|
||||
each(mapping.caps, function(cap) {
|
||||
each(mapping.aryMethod[cap], function(otherName) {
|
||||
if (name == otherName) {
|
||||
var indexes = mapping.iterateeRearg[name],
|
||||
n = !isLib && mapping.aryIteratee[name];
|
||||
|
||||
result = ary(func, cap);
|
||||
if (cap > 1 && !mapping.skipRearg[name]) {
|
||||
result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[cap]);
|
||||
}
|
||||
if (indexes) {
|
||||
result = iterateeRearg(result, indexes);
|
||||
} else if (n) {
|
||||
result = iterateeAry(result, n);
|
||||
}
|
||||
if (cap > 1) {
|
||||
result = curry(result, cap);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return !result;
|
||||
});
|
||||
|
||||
result || (result = func);
|
||||
if (mapping.placeholder[name]) {
|
||||
result.placeholder = placeholder;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
if (!isLib) {
|
||||
return wrap(name, func);
|
||||
}
|
||||
// Iterate over methods for the current ary cap.
|
||||
var pairs = [];
|
||||
each(mapping.caps, function(cap) {
|
||||
each(mapping.aryMethod[cap], function(key) {
|
||||
var func = _[mapping.key[key] || key];
|
||||
if (func) {
|
||||
pairs.push([key, wrap(key, func)]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Assign to `_` leaving `_.prototype` unchanged to allow chaining.
|
||||
each(pairs, function(pair) {
|
||||
_[pair[0]] = pair[1];
|
||||
});
|
||||
|
||||
// Wrap the lodash method and its aliases.
|
||||
each(keys(_), function(key) {
|
||||
each(mapping.realToAlias[key] || [], function(alias) {
|
||||
_[alias] = _[key];
|
||||
});
|
||||
});
|
||||
|
||||
return _;
|
||||
}
|
||||
|
||||
module.exports = baseConvert;
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 2 */
|
||||
/***/ function(module, exports) {
|
||||
|
||||
/** Used to map aliases to their real names. */
|
||||
exports.aliasToReal = {
|
||||
'all': 'some',
|
||||
'allPass': 'overEvery',
|
||||
'apply': 'spread',
|
||||
'compose': 'flowRight',
|
||||
'contains': 'includes',
|
||||
'dissoc': 'omit',
|
||||
'each': 'forEach',
|
||||
'eachRight': 'forEachRight',
|
||||
'equals': 'isEqual',
|
||||
'extend': 'assignIn',
|
||||
'extendWith': 'assignInWith',
|
||||
'first': 'head',
|
||||
'init': 'initial',
|
||||
'mapObj': 'mapValues',
|
||||
'omitAll': 'omit',
|
||||
'nAry': 'ary',
|
||||
'path': 'get',
|
||||
'pathEq': 'matchesProperty',
|
||||
'pathOr': 'getOr',
|
||||
'pickAll': 'pick',
|
||||
'pipe': 'flow',
|
||||
'prop': 'get',
|
||||
'propOf': 'propertyOf',
|
||||
'propOr': 'getOr',
|
||||
'somePass': 'overSome',
|
||||
'unapply': 'rest',
|
||||
'unnest': 'flatten',
|
||||
'useWith': 'overArgs',
|
||||
'whereEq': 'filter',
|
||||
'zipObj': 'zipObject'
|
||||
};
|
||||
|
||||
/** Used to map method names to their iteratee ary. */
|
||||
exports.aryIteratee = {
|
||||
'assignWith': 2,
|
||||
'assignInWith': 2,
|
||||
'cloneDeepWith': 1,
|
||||
'cloneWith': 1,
|
||||
'dropRightWhile': 1,
|
||||
'dropWhile': 1,
|
||||
'every': 1,
|
||||
'filter': 1,
|
||||
'find': 1,
|
||||
'findIndex': 1,
|
||||
'findKey': 1,
|
||||
'findLast': 1,
|
||||
'findLastIndex': 1,
|
||||
'findLastKey': 1,
|
||||
'flatMap': 1,
|
||||
'forEach': 1,
|
||||
'forEachRight': 1,
|
||||
'forIn': 1,
|
||||
'forInRight': 1,
|
||||
'forOwn': 1,
|
||||
'forOwnRight': 1,
|
||||
'isEqualWith': 2,
|
||||
'isMatchWith': 2,
|
||||
'map': 1,
|
||||
'mapKeys': 1,
|
||||
'mapValues': 1,
|
||||
'partition': 1,
|
||||
'reduce': 2,
|
||||
'reduceRight': 2,
|
||||
'reject': 1,
|
||||
'remove': 1,
|
||||
'some': 1,
|
||||
'takeRightWhile': 1,
|
||||
'takeWhile': 1,
|
||||
'times': 1,
|
||||
'transform': 2
|
||||
};
|
||||
|
||||
/** Used to map ary to method names. */
|
||||
exports.aryMethod = {
|
||||
1: [
|
||||
'attempt', 'ceil', 'create', 'curry', 'curryRight', 'floor', 'fromPairs',
|
||||
'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin', 'over',
|
||||
'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext',
|
||||
'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words'
|
||||
],
|
||||
2: [
|
||||
'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindKey',
|
||||
'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN',
|
||||
'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference',
|
||||
'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every',
|
||||
'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
|
||||
'findLastKey', 'flatMap', 'forEach', 'forEachRight', 'forIn', 'forInRight',
|
||||
'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has', 'hasIn',
|
||||
'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap',
|
||||
'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map',
|
||||
'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy', 'omit',
|
||||
'omitBy', 'orderBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt',
|
||||
'partition', 'pick', 'pickBy', 'pull', 'pullAll', 'pullAt', 'random', 'range',
|
||||
'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'result', 'sampleSize',
|
||||
'some', 'sortBy', 'sortedIndex', 'sortedIndexOf', 'sortedLastIndex',
|
||||
'sortedLastIndexOf', 'sortedUniqBy', 'split', 'startsWith', 'subtract',
|
||||
'sumBy', 'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', 'throttle',
|
||||
'thru', 'times', 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset', 'unzipWith',
|
||||
'without', 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep'
|
||||
],
|
||||
3: [
|
||||
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
|
||||
'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith',
|
||||
'isMatchWith', 'mergeWith', 'pullAllBy', 'reduce', 'reduceRight', 'replace',
|
||||
'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy',
|
||||
'unionWith', 'xorBy', 'xorWith', 'zipWith'
|
||||
],
|
||||
4: [
|
||||
'fill', 'setWith'
|
||||
]
|
||||
};
|
||||
|
||||
/** Used to map ary to rearg configs. */
|
||||
exports.aryRearg = {
|
||||
2: [1, 0],
|
||||
3: [2, 1, 0],
|
||||
4: [3, 2, 0, 1]
|
||||
};
|
||||
|
||||
/** Used to map method names to iteratee rearg configs. */
|
||||
exports.iterateeRearg = {
|
||||
'findKey': [1],
|
||||
'findLastKey': [1],
|
||||
'mapKeys': [1]
|
||||
};
|
||||
|
||||
/** Used to map method names to rearg configs. */
|
||||
exports.methodRearg = {
|
||||
'assignInWith': [1, 2, 0],
|
||||
'assignWith': [1, 2, 0],
|
||||
'clamp': [2, 0, 1],
|
||||
'mergeWith': [1, 2, 0],
|
||||
'reduce': [2, 0, 1],
|
||||
'reduceRight': [2, 0, 1],
|
||||
'set': [2, 0, 1],
|
||||
'setWith': [3, 1, 2, 0],
|
||||
'slice': [2, 0, 1],
|
||||
'transform': [2, 0, 1]
|
||||
};
|
||||
|
||||
/** Used to iterate `mapping.aryMethod` keys. */
|
||||
exports.caps = [1, 2, 3, 4];
|
||||
|
||||
/** Used to map keys to other keys. */
|
||||
exports.key = {
|
||||
'curryN': 'curry',
|
||||
'curryRightN': 'curryRight',
|
||||
'getOr': 'get'
|
||||
};
|
||||
|
||||
/** Used to identify methods which mutate arrays or objects. */
|
||||
exports.mutate = {
|
||||
'array': {
|
||||
'fill': true,
|
||||
'pull': true,
|
||||
'pullAll': true,
|
||||
'pullAllBy': true,
|
||||
'pullAt': true,
|
||||
'remove': true,
|
||||
'reverse': true
|
||||
},
|
||||
'object': {
|
||||
'assign': true,
|
||||
'assignIn': true,
|
||||
'assignInWith': true,
|
||||
'assignWith': true,
|
||||
'defaults': true,
|
||||
'defaultsDeep': true,
|
||||
'merge': true,
|
||||
'mergeWith': true
|
||||
},
|
||||
'set': {
|
||||
'set': true,
|
||||
'setWith': true
|
||||
}
|
||||
};
|
||||
|
||||
/** Used to track methods with placeholder support */
|
||||
exports.placeholder = {
|
||||
'bind': true,
|
||||
'bindKey': true,
|
||||
'curry': true,
|
||||
'curryRight': true,
|
||||
'partial': true,
|
||||
'partialRight': true
|
||||
};
|
||||
|
||||
/** Used to map real names to their aliases. */
|
||||
exports.realToAlias = (function() {
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
object = exports.aliasToReal,
|
||||
result = {};
|
||||
|
||||
for (var key in object) {
|
||||
var value = object[key];
|
||||
if (hasOwnProperty.call(result, value)) {
|
||||
result[value].push(key);
|
||||
} else {
|
||||
result[value] = [key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}());
|
||||
|
||||
/** Used to track methods that skip `_.rearg`. */
|
||||
exports.skipRearg = {
|
||||
'assign': true,
|
||||
'assignIn': true,
|
||||
'concat': true,
|
||||
'difference': true,
|
||||
'matchesProperty': true,
|
||||
'merge': true,
|
||||
'random': true,
|
||||
'range': true,
|
||||
'rangeRight': true,
|
||||
'zip': true,
|
||||
'zipObject': true
|
||||
};
|
||||
|
||||
|
||||
/***/ }
|
||||
/******/ ])
|
||||
});
|
||||
;
|
||||
11
dist/lodash.fp.min.js
vendored
Normal file
11
dist/lodash.fp.min.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.fp=t():e.fp=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){function n(e){return i(e,e)}var i=r(1);e.exports=n},function(e,t,r){function n(e,t,r){
|
||||
if("function"!=typeof r&&(r=t,t=void 0),null==r)throw new TypeError;var s=void 0===t&&"string"==typeof r.VERSION,u=s?r:{ary:e.ary,cloneDeep:e.cloneDeep,curry:e.curry,forEach:e.forEach,isFunction:e.isFunction,iteratee:e.iteratee,keys:e.keys,rearg:e.rearg},c=u.ary,p=u.cloneDeep,f=u.curry,l=u.forEach,h=u.isFunction,d=u.keys,y=u.rearg,g=function(e,t){return 2==t?function(t,r){return e.apply(void 0,arguments)}:function(t){return e.apply(void 0,arguments)}},m=function(e,t){return 2==t?function(t,r){return e(t,r);
|
||||
}:function(t){return e(t)}},v=function(e){for(var t=e?e.length:0,r=Array(t);t--;)r[t]=e[t];return r},W=function(e){return function(t){return e({},t)}},R=function(e,t){return O(e,t,!0)},x=function(e,t){return O(e,function(e){return m(e,t)})},I=function(e,t){return O(e,function(e){var r=t.length;return g(y(m(e,r),t),r)})},O=function(e,t,r){return function(){for(var n=arguments.length,i=Array(n);n--;)i[n]=arguments[n];i[0]=t(i[0]);var a=e.apply(void 0,i);return r?i[0]:a}},b={iteratee:function(e){return function(){
|
||||
var t=arguments[0],r=arguments[1];r=r>2?r-2:1,t=e(t);var n=t.length;return n&&r>=n?t:m(t,r)}},mixin:function(e){return function(t){var r=this;if(!h(r))return e(r,Object(t));var n=[],i=[];return l(d(t),function(e){var a=t[e];h(a)&&(i.push(e),n.push(r.prototype[e]))}),e(r,Object(t)),l(i,function(e,t){var i=n[t];h(i)?r.prototype[e]=i:delete r.prototype[e]}),r}},runInContext:function(t){return function(r){return n(e,t(r))}}},k=function(e,t){e=i.aliasToReal[e]||e;var r=b[e];if(r)return r(t);a.array[e]?t=R(t,v):a.object[e]?t=R(t,W(t)):a.set[e]&&(t=R(t,p));
|
||||
var n;return l(i.caps,function(r){return l(i.aryMethod[r],function(a){if(e==a){var o=i.iterateeRearg[e],u=!s&&i.aryIteratee[e];return n=c(t,r),r>1&&!i.skipRearg[e]&&(n=y(n,i.methodRearg[e]||i.aryRearg[r])),o?n=I(n,o):u&&(n=x(n,u)),r>1&&(n=f(n,r)),!1}}),!n}),n||(n=t),i.placeholder[e]&&(n.placeholder=o),n};if(!s)return k(t,r);var B=[];return l(i.caps,function(e){l(i.aryMethod[e],function(e){var t=u[i.key[e]||e];t&&B.push([e,k(e,t)])})}),l(B,function(e){u[e[0]]=e[1]}),l(d(u),function(e){l(i.realToAlias[e]||[],function(t){
|
||||
u[t]=u[e]})}),u}var i=r(2),a=i.mutate,o={};e.exports=n},function(e,t){t.aliasToReal={all:"some",allPass:"overEvery",apply:"spread",compose:"flowRight",contains:"includes",dissoc:"omit",each:"forEach",eachRight:"forEachRight",equals:"isEqual",extend:"assignIn",extendWith:"assignInWith",first:"head",init:"initial",mapObj:"mapValues",omitAll:"omit",nAry:"ary",path:"get",pathEq:"matchesProperty",pathOr:"getOr",pickAll:"pick",pipe:"flow",prop:"get",propOf:"propertyOf",propOr:"getOr",somePass:"overSome",
|
||||
unapply:"rest",unnest:"flatten",useWith:"overArgs",whereEq:"filter",zipObj:"zipObject"},t.aryIteratee={assignWith:2,assignInWith:2,cloneDeepWith:1,cloneWith:1,dropRightWhile:1,dropWhile:1,every:1,filter:1,find:1,findIndex:1,findKey:1,findLast:1,findLastIndex:1,findLastKey:1,flatMap:1,forEach:1,forEachRight:1,forIn:1,forInRight:1,forOwn:1,forOwnRight:1,isEqualWith:2,isMatchWith:2,map:1,mapKeys:1,mapValues:1,partition:1,reduce:2,reduceRight:2,reject:1,remove:1,some:1,takeRightWhile:1,takeWhile:1,times:1,
|
||||
transform:2},t.aryMethod={1:["attempt","ceil","create","curry","curryRight","floor","fromPairs","invert","iteratee","memoize","method","methodOf","mixin","over","overEvery","overSome","rest","reverse","round","runInContext","template","trim","trimEnd","trimStart","uniqueId","words"],2:["add","after","ary","assign","assignIn","at","before","bind","bindKey","chunk","cloneDeepWith","cloneWith","concat","countBy","curryN","curryRightN","debounce","defaults","defaultsDeep","delay","difference","drop","dropRight","dropRightWhile","dropWhile","endsWith","eq","every","filter","find","find","findIndex","findKey","findLast","findLastIndex","findLastKey","flatMap","forEach","forEachRight","forIn","forInRight","forOwn","forOwnRight","get","groupBy","gt","gte","has","hasIn","includes","indexOf","intersection","invertBy","invoke","invokeMap","isEqual","isMatch","join","keyBy","lastIndexOf","lt","lte","map","mapKeys","mapValues","matchesProperty","maxBy","merge","minBy","omit","omitBy","orderBy","overArgs","pad","padEnd","padStart","parseInt","partition","pick","pickBy","pull","pullAll","pullAt","random","range","rangeRight","rearg","reject","remove","repeat","result","sampleSize","some","sortBy","sortedIndex","sortedIndexOf","sortedLastIndex","sortedLastIndexOf","sortedUniqBy","split","startsWith","subtract","sumBy","take","takeRight","takeRightWhile","takeWhile","tap","throttle","thru","times","truncate","union","uniqBy","uniqWith","unset","unzipWith","without","wrap","xor","zip","zipObject","zipObjectDeep"],
|
||||
3:["assignInWith","assignWith","clamp","differenceBy","differenceWith","getOr","inRange","intersectionBy","intersectionWith","isEqualWith","isMatchWith","mergeWith","pullAllBy","reduce","reduceRight","replace","set","slice","sortedIndexBy","sortedLastIndexBy","transform","unionBy","unionWith","xorBy","xorWith","zipWith"],4:["fill","setWith"]},t.aryRearg={2:[1,0],3:[2,1,0],4:[3,2,0,1]},t.iterateeRearg={findKey:[1],findLastKey:[1],mapKeys:[1]},t.methodRearg={assignInWith:[1,2,0],assignWith:[1,2,0],
|
||||
clamp:[2,0,1],mergeWith:[1,2,0],reduce:[2,0,1],reduceRight:[2,0,1],set:[2,0,1],setWith:[3,1,2,0],slice:[2,0,1],transform:[2,0,1]},t.caps=[1,2,3,4],t.key={curryN:"curry",curryRightN:"curryRight",getOr:"get"},t.mutate={array:{fill:!0,pull:!0,pullAll:!0,pullAllBy:!0,pullAt:!0,remove:!0,reverse:!0},object:{assign:!0,assignIn:!0,assignInWith:!0,assignWith:!0,defaults:!0,defaultsDeep:!0,merge:!0,mergeWith:!0},set:{set:!0,setWith:!0}},t.placeholder={bind:!0,bindKey:!0,curry:!0,curryRight:!0,partial:!0,partialRight:!0
|
||||
},t.realToAlias=function(){var e=Object.prototype.hasOwnProperty,r=t.aliasToReal,n={};for(var i in r){var a=r[i];e.call(n,a)?n[a].push(i):n[a]=[i]}return n}(),t.skipRearg={assign:!0,assignIn:!0,concat:!0,difference:!0,matchesProperty:!0,merge:!0,random:!0,range:!0,rangeRight:!0,zip:!0,zipObject:!0}}])});
|
||||
11736
lodash.src.js → dist/lodash.js
vendored
11736
lodash.src.js → dist/lodash.js
vendored
File diff suppressed because it is too large
Load Diff
118
dist/lodash.min.js
vendored
Normal file
118
dist/lodash.min.js
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* @license
|
||||
* lodash 4.1.0 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
|
||||
* Build: `lodash -o ./dist/lodash.js`
|
||||
*/
|
||||
;(function(){function n(n,t){return n.set(t[0],t[1]),n}function t(n,t){return n.add(t),n}function r(n,t,r){switch(r?r.length:0){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2])}return n.apply(t,r)}function e(n,t,r,e){for(var u=-1,o=n.length;++u<o;){var i=n[u];t(e,i,r(i),n)}return e}function u(n,t){for(var r=-1,e=n.length;++r<e&&false!==t(n[r],r,n););return n}function o(n,t){for(var r=-1,e=n.length;++r<e;)if(!t(n[r],r,n))return false;
|
||||
return true}function i(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;){var i=n[r];t(i,r,n)&&(o[++u]=i)}return o}function f(n,t){return!!n.length&&-1<d(n,t,0)}function c(n,t,r){for(var e=-1,u=n.length;++e<u;)if(r(t,n[e]))return true;return false}function a(n,t){for(var r=-1,e=n.length,u=Array(e);++r<e;)u[r]=t(n[r],r,n);return u}function l(n,t){for(var r=-1,e=t.length,u=n.length;++r<e;)n[u+r]=t[r];return n}function s(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++u<o;)r=t(r,n[u],u,n);return r}function h(n,t,r,e){
|
||||
var u=n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);return r}function p(n,t){for(var r=-1,e=n.length;++r<e;)if(t(n[r],r,n))return true;return false}function _(n,t,r){for(var e=-1,u=n.length;++e<u;){var o=n[e],i=t(o);if(null!=i&&(f===Z?i===i:r(i,f)))var f=i,c=o}return c}function g(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function v(n,t,r){for(var e=n.length,u=r?e:-1;r?u--:++u<e;)if(t(n[u],u,n))return u;return-1}function d(n,t,r){if(t!==t)return C(n,r);--r;for(var e=n.length;++r<e;)if(n[r]===t)return r;
|
||||
return-1}function y(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function b(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;return n}function x(n,t){for(var r,e=-1,u=n.length;++e<u;){var o=t(n[e]);o!==Z&&(r=r===Z?o:r+o)}return u?r:0}function m(n,t){for(var r=-1,e=Array(n);++r<n;)e[r]=t(r);return e}function j(n,t){return a(t,function(t){return[t,n[t]]})}function w(n){return function(t){return n(t)}}function A(n,t){return a(t,function(t){return n[t]})}function O(n,t){for(var r=-1,e=n.length;++r<e&&-1<d(t,n[r],0););
|
||||
return r}function E(n,t){for(var r=n.length;r--&&-1<d(t,n[r],0););return r}function k(n){return n&&n.Object===Object?n:null}function I(n,t){if(n!==t){var r=null===n,e=n===Z,u=n===n,o=null===t,i=t===Z,f=t===t;if(n>t&&!o||!u||r&&!i&&f||e&&f)return 1;if(t>n&&!r||!f||o&&!e&&u||i&&u)return-1}return 0}function R(n){return Bn[n]}function S(n){return zn[n]}function W(n){return"\\"+Fn[n]}function C(n,t,r){var e=n.length;for(t+=r?0:-1;r?t--:++t<e;){var u=n[t];if(u!==u)return t}return-1}function U(n){var t=false;
|
||||
if(null!=n&&typeof n.toString!="function")try{t=!!(n+"")}catch(r){}return t}function B(n,t){return n=typeof n=="number"||yn.test(n)?+n:-1,n>-1&&0==n%1&&(null==t?9007199254740991:t)>n}function z(n){for(var t,r=[];!(t=n.next()).done;)r.push(t.value);return r}function L(n){var t=-1,r=Array(n.size);return n.forEach(function(n,e){r[++t]=[e,n]}),r}function $(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;)n[r]===t&&(n[r]="__lodash_placeholder__",o[++u]=r);return o}function F(n){var t=-1,r=Array(n.size);return n.forEach(function(n){
|
||||
r[++t]=n}),r}function M(n){if(!n||!kn.test(n))return n.length;for(var t=En.lastIndex=0;En.test(n);)t++;return t}function N(n){return Ln[n]}function D(k){function yn(n){if(ye(n)&&!Lo(n)&&!(n instanceof An)){if(n instanceof wn)return n;if(iu.call(n,"__wrapped__"))return Nr(n)}return new wn(n)}function jn(){}function wn(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=Z}function An(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=false,
|
||||
this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Bn(){}function zn(n){var t=-1,r=n?n.length:0;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1])}}function Ln(n){var t=-1,r=n?n.length:0;for(this.__data__=new zn;++t<r;)this.push(n[t])}function $n(n,t){var r=n.__data__;return Cr(t)?(r=r.__data__,"__lodash_hash_undefined__"===(typeof t=="string"?r.string:r.hash)[t]):r.has(t)}function Fn(n){var t=-1,r=n?n.length:0;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1]);
|
||||
}}function Dn(n,t){var r=qn(n,t);return 0>r?false:(r==n.length-1?n.pop():ju.call(n,r,1),true)}function Zn(n,t){var r=qn(n,t);return 0>r?Z:n[r][1]}function qn(n,t){for(var r=n.length;r--;)if(ce(n[r][0],t))return r;return-1}function Pn(n,t,r){var e=qn(n,t);0>e?n.push([t,r]):n[e][1]=r}function Tn(n,t,r,e){return n===Z||ce(n,uu[r])&&!iu.call(e,r)?t:n}function Kn(n,t,r){(r!==Z&&!ce(n[t],r)||typeof t=="number"&&r===Z&&!(t in n))&&(n[t]=r)}function Jn(n,t,r){var e=n[t];(!ce(e,r)||ce(e,uu[t])&&!iu.call(n,t)||r===Z&&!(t in n))&&(n[t]=r);
|
||||
}function Yn(n,t,r,e){return Tu(n,function(n,u,o){t(e,n,r(n),o)}),e}function Hn(n,t){return n&&Jt(t,Le(t),n)}function Qn(n,t){for(var r=-1,e=null==n,u=t.length,o=Array(u);++r<u;)o[r]=e?Z:Ue(n,t[r]);return o}function Xn(n,t,r){return n===n&&(r!==Z&&(n=n>r?r:n),t!==Z&&(n=t>n?t:n)),n}function nt(n,t,r,e,o,i){var f;if(r&&(f=o?r(n,e,o,i):r(n)),f!==Z)return f;if(!de(n))return n;if(e=Lo(n)){if(f=Er(n),!t)return Vt(n,f)}else{var c=Ar(n),a="[object Function]"==c||"[object GeneratorFunction]"==c;if("[object Object]"!=c&&"[object Arguments]"!=c&&(!a||o))return Un[c]?Ir(n,c,t):o?n:{};
|
||||
if(U(n))return o?n:{};if(f=kr(a?{}:n),!t)return Ht(n,Hn(f,n))}return i||(i=new Fn),(o=i.get(n))?o:(i.set(n,f),(e?u:ct)(n,function(e,u){Jn(f,u,nt(e,t,r,u,n,i))}),e?f:Ht(n,f))}function tt(n){var t=Le(n),r=t.length;return function(e){if(null==e)return!r;for(var u=r;u--;){var o=t[u],i=n[o],f=e[o];if(f===Z&&!(o in Object(e))||!i(f))return false}return true}}function rt(n,t,r){if(typeof n!="function")throw new ru("Expected a function");return mu(function(){n.apply(Z,r)},t)}function et(n,t,r,e){var u=-1,o=f,i=true,l=n.length,s=[],h=t.length;
|
||||
if(!l)return s;r&&(t=a(t,w(r))),e?(o=c,i=false):t.length>=200&&(o=$n,i=false,t=new Ln(t));n:for(;++u<l;){var p=n[u],_=r?r(p):p;if(i&&_===_){for(var g=h;g--;)if(t[g]===_)continue n;s.push(p)}else o(t,_,e)||s.push(p)}return s}function ut(n,t){var r=true;return Tu(n,function(n,e,u){return r=!!t(n,e,u)}),r}function ot(n,t){var r=[];return Tu(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function it(n,t,r,e){e||(e=[]);for(var u=-1,o=n.length;++u<o;){var i=n[u];he(i)&&(r||Lo(i)||le(i))?t?it(i,t,r,e):l(e,i):r||(e[e.length]=i);
|
||||
}return e}function ft(n,t){null==n||Gu(n,t,$e)}function ct(n,t){return n&&Gu(n,t,Le)}function at(n,t){return n&&Vu(n,t,Le)}function lt(n,t){return i(t,function(t){return _e(n[t])})}function st(n,t){t=Wr(t,n)?[t+""]:Mt(t);for(var r=0,e=t.length;null!=n&&e>r;)n=n[t[r++]];return r&&r==e?n:Z}function ht(n,t){return iu.call(n,t)||typeof n=="object"&&t in n&&null===du(n)}function pt(n,t){return t in Object(n)}function _t(n,t,r){for(var e=r?c:f,u=n.length,o=u,i=Array(u),l=[];o--;){var s=n[o];o&&t&&(s=a(s,w(t))),
|
||||
i[o]=r||!t&&120>s.length?Z:new Ln(o&&s)}var s=n[0],h=-1,p=s.length,_=i[0];n:for(;++h<p;){var g=s[h],v=t?t(g):g;if(_?!$n(_,v):!e(l,v,r)){for(o=u;--o;){var d=i[o];if(d?!$n(d,v):!e(n[o],v,r))continue n}_&&_.push(v),l.push(g)}}return l}function gt(n,t,r){var e={};return ct(n,function(n,u,o){t(e,r(n),u,o)}),e}function vt(n,t,e){return Wr(t,n)||(t=Mt(t),n=Lr(n,t),t=Pr(t)),t=null==n?n:n[t],null==t?Z:r(t,n,e)}function dt(n,t,r,e,u){if(n===t)n=true;else if(null==n||null==t||!de(n)&&!ye(t))n=n!==n&&t!==t;else n:{
|
||||
var o=Lo(n),i=Lo(t),f="[object Array]",c="[object Array]";o||(f=Ar(n),"[object Arguments]"==f?f="[object Object]":"[object Object]"!=f&&(o=Oe(n))),i||(c=Ar(t),"[object Arguments]"==c?c="[object Object]":"[object Object]"!=c&&Oe(t));var a="[object Object]"==f&&!U(n),i="[object Object]"==c&&!U(t),c=f==c;if(!c||o||a){if(!(2&e)&&(f=a&&iu.call(n,"__wrapped__"),i=i&&iu.call(t,"__wrapped__"),f||i)){n=dt(f?n.value():n,i?t.value():t,r,e,u);break n}c?(u||(u=new Fn),n=(o?dr:br)(n,t,dt,r,e,u)):n=false}else n=yr(n,t,f,dt,r,e);
|
||||
}return n}function yt(n,t,r,e){var u=r.length,o=u,i=!e;if(null==n)return!o;for(n=Object(n);u--;){var f=r[u];if(i&&f[2]?f[1]!==n[f[0]]:!(f[0]in n))return false}for(;++u<o;){var f=r[u],c=f[0],a=n[c],l=f[1];if(i&&f[2]){if(a===Z&&!(c in n))return false}else if(f=new Fn,c=e?e(a,l,c,n,t,f):Z,c===Z?!dt(l,a,e,3,f):!c)return false}return true}function bt(n){var t=typeof n;return"function"==t?n:null==n?Te:"object"==t?Lo(n)?wt(n[0],n[1]):jt(n):Ye(n)}function xt(n){n=null==n?n:Object(n);var t,r=[];for(t in n)r.push(t);return r;
|
||||
}function mt(n,t){var r=-1,e=se(n)?Array(n.length):[];return Tu(n,function(n,u,o){e[++r]=t(n,u,o)}),e}function jt(n){var t=jr(n);if(1==t.length&&t[0][2]){var r=t[0][0],e=t[0][1];return function(n){return null==n?false:n[r]===e&&(e!==Z||r in Object(n))}}return function(r){return r===n||yt(r,n,t)}}function wt(n,t){return function(r){var e=Ue(r,n);return e===Z&&e===t?ze(r,n):dt(t,e,Z,3)}}function At(n,t,r,e,o){if(n!==t){var i=Lo(t)||Oe(t)?Z:$e(t);u(i||t,function(u,f){if(i&&(f=u,u=t[f]),de(u)){o||(o=new Fn);
|
||||
var c=f,a=o,l=n[c],s=t[c],h=a.get(s);if(h)Kn(n,c,h);else{var h=e?e(l,s,c+"",n,t,a):Z,p=h===Z;p&&(h=s,Lo(s)||Oe(s)?Lo(l)?h=r?Vt(l):l:he(l)?h=Vt(l):(p=false,h=nt(s)):me(s)||le(s)?le(l)?h=We(l):!de(l)||r&&_e(l)?(p=false,h=nt(s)):h=r?nt(l):l:p=false),a.set(s,h),p&&At(h,s,r,e,a),Kn(n,c,h)}}else c=e?e(n[f],u,f+"",n,t,o):Z,c===Z&&(c=u),Kn(n,f,c)})}}function Ot(n,t,r){var e=-1,u=mr();return t=a(t.length?t:Array(1),function(n){return u(n)}),n=mt(n,function(n){return{a:a(t,function(t){return t(n)}),b:++e,c:n}}),b(n,function(n,t){
|
||||
var e;n:{e=-1;for(var u=n.a,o=t.a,i=u.length,f=r.length;++e<i;){var c=I(u[e],o[e]);if(c){e=f>e?c*("desc"==r[e]?-1:1):c;break n}}e=n.b-t.b}return e})}function Et(n,t){return n=Object(n),s(t,function(t,r){return r in n&&(t[r]=n[r]),t},{})}function kt(n,t){var r={};return ft(n,function(n,e){t(n,e)&&(r[e]=n)}),r}function It(n){return function(t){return null==t?Z:t[n]}}function Rt(n){return function(t){return st(t,n)}}function St(n,t,r){var e=-1,u=t.length,o=n;for(r&&(o=a(n,function(n){return r(n)}));++e<u;)for(var i=0,f=t[e],f=r?r(f):f;-1<(i=d(o,f,i));)o!==n&&ju.call(o,i,1),
|
||||
ju.call(n,i,1);return n}function Wt(n,t){for(var r=n?t.length:0,e=r-1;r--;){var u=t[r];if(e==r||u!=o){var o=u;if(B(u))ju.call(n,u,1);else if(Wr(u,n))delete n[u];else{var u=Mt(u),i=Lr(n,u);null!=i&&delete i[Pr(u)]}}}}function Ct(n,t){return n+Au(Wu()*(t-n+1))}function Ut(n,t,r,e){t=Wr(t,n)?[t+""]:Mt(t);for(var u=-1,o=t.length,i=o-1,f=n;null!=f&&++u<o;){var c=t[u];if(de(f)){var a=r;if(u!=i){var l=f[c],a=e?e(l,c,f):Z;a===Z&&(a=null==l?B(t[u+1])?[]:{}:l)}Jn(f,c,a)}f=f[c]}return n}function Bt(n,t,r){var e=-1,u=n.length;
|
||||
for(0>t&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Array(u);++e<u;)r[e]=n[e+t];return r}function zt(n,t){var r;return Tu(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function Lt(n,t,r){var e=0,u=n?n.length:e;if(typeof t=="number"&&t===t&&2147483647>=u){for(;u>e;){var o=e+u>>>1,i=n[o];(r?t>=i:t>i)&&null!==i?e=o+1:u=o}return u}return $t(n,t,Te,r)}function $t(n,t,r,e){t=r(t);for(var u=0,o=n?n.length:0,i=t!==t,f=null===t,c=t===Z;o>u;){var a=Au((u+o)/2),l=r(n[a]),s=l!==Z,h=l===l;(i?h||e:f?h&&s&&(e||null!=l):c?h&&(e||s):null==l?0:e?t>=l:t>l)?u=a+1:o=a;
|
||||
}return Ru(o,4294967294)}function Ft(n,t){for(var r=0,e=n.length,u=n[0],o=t?t(u):u,i=o,f=0,c=[u];++r<e;)u=n[r],o=t?t(u):u,ce(o,i)||(i=o,c[++f]=u);return c}function Mt(n){return Lo(n)?n:$r(n)}function Nt(n,t,r){var e=-1,u=f,o=n.length,i=true,a=[],l=a;if(r)i=false,u=c;else if(o<200)l=t?[]:a;else{if(u=t?null:Yu(n))return F(u);i=false,u=$n,l=new Ln}n:for(;++e<o;){var s=n[e],h=t?t(s):s;if(i&&h===h){for(var p=l.length;p--;)if(l[p]===h)continue n;t&&l.push(h),a.push(s)}else u(l,h,r)||(l!==a&&l.push(h),a.push(s));
|
||||
}return a}function Dt(n,t,r,e){for(var u=n.length,o=e?u:-1;(e?o--:++o<u)&&t(n[o],o,n););return r?Bt(n,e?0:o,e?o+1:u):Bt(n,e?o+1:0,e?u:o)}function Zt(n,t){var r=n;return r instanceof An&&(r=r.value()),s(t,function(n,t){return t.func.apply(t.thisArg,l([n],t.args))},r)}function qt(n,t,r){for(var e=-1,u=n.length;++e<u;)var o=o?l(et(o,n[e],t,r),et(n[e],o,t,r)):n[e];return o&&o.length?Nt(o,t,r):[]}function Pt(n,t,r){for(var e=-1,u=n.length,o=t.length,i={};++e<u;)r(i,n[e],o>e?t[e]:Z);return i}function Tt(n){
|
||||
var t=new n.constructor(n.byteLength);return new _u(t).set(new _u(n)),t}function Kt(n,t,r){for(var e=r.length,u=-1,o=Iu(n.length-e,0),i=-1,f=t.length,c=Array(f+o);++i<f;)c[i]=t[i];for(;++u<e;)c[r[u]]=n[u];for(;o--;)c[i++]=n[u++];return c}function Gt(n,t,r){for(var e=-1,u=r.length,o=-1,i=Iu(n.length-u,0),f=-1,c=t.length,a=Array(i+c);++o<i;)a[o]=n[o];for(i=o;++f<c;)a[i+f]=t[f];for(;++e<u;)a[i+r[e]]=n[o++];return a}function Vt(n,t){var r=-1,e=n.length;for(t||(t=Array(e));++r<e;)t[r]=n[r];return t}function Jt(n,t,r){
|
||||
return Yt(n,t,r)}function Yt(n,t,r,e){r||(r={});for(var u=-1,o=t.length;++u<o;){var i=t[u],f=e?e(r[i],n[i],i,r,n):n[i];Jn(r,i,f)}return r}function Ht(n,t){return Jt(n,Xu(n),t)}function Qt(n,t){return function(r,u){var o=Lo(r)?e:Yn,i=t?t():{};return o(r,n,mr(u),i)}}function Xt(n){return fe(function(t,r){var e=-1,u=r.length,o=u>1?r[u-1]:Z,i=u>2?r[2]:Z,o=typeof o=="function"?(u--,o):Z;for(i&&Sr(r[0],r[1],i)&&(o=3>u?Z:o,u=1),t=Object(t);++e<u;)(i=r[e])&&n(t,i,e,o);return t})}function nr(n,t){return function(r,e){
|
||||
if(null==r)return r;if(!se(r))return n(r,e);for(var u=r.length,o=t?u:-1,i=Object(r);(t?o--:++o<u)&&false!==e(i[o],o,i););return r}}function tr(n){return function(t,r,e){var u=-1,o=Object(t);e=e(t);for(var i=e.length;i--;){var f=e[n?i:++u];if(false===r(o[f],f,o))break}return t}}function rr(n,t,r){function e(){return(this&&this!==Gn&&this instanceof e?o:n).apply(u?r:this,arguments)}var u=1&t,o=or(n);return e}function er(n){return function(t){t=Ce(t);var r=kn.test(t)?t.match(En):Z,e=r?r[0]:t.charAt(0);return t=r?r.slice(1).join(""):t.slice(1),
|
||||
e[n]()+t}}function ur(n){return function(t){return s(qe(De(t)),n,"")}}function or(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=Pu(n.prototype),t=n.apply(r,t);return de(t)?t:r}}function ir(n,t,e){
|
||||
function u(){for(var i=arguments.length,f=i,c=Array(i),a=this&&this!==Gn&&this instanceof u?o:n,l=u.placeholder;f--;)c[f]=arguments[f];return f=3>i&&c[0]!==l&&c[i-1]!==l?[]:$(c,l),i-=f.length,e>i?_r(n,t,cr,l,Z,c,f,Z,Z,e-i):r(a,this,c)}var o=or(n);return u}function fr(n){return fe(function(t){t=it(t);var r=t.length,e=r,u=wn.prototype.thru;for(n&&t.reverse();e--;){var o=t[e];if(typeof o!="function")throw new ru("Expected a function");if(u&&!i&&"wrapper"==xr(o))var i=new wn([],true)}for(e=i?e:r;++e<r;)var o=t[e],u=xr(o),f="wrapper"==u?Hu(o):Z,i=f&&Ur(f[0])&&424==f[1]&&!f[4].length&&1==f[9]?i[xr(f[0])].apply(i,f[3]):1==o.length&&Ur(o)?i[u]():i.thru(o);
|
||||
return function(){var n=arguments,e=n[0];if(i&&1==n.length&&Lo(e)&&e.length>=200)return i.plant(e).value();for(var u=0,n=r?t[u].apply(this,n):e;++u<r;)n=t[u].call(this,n);return n}})}function cr(n,t,r,e,u,o,i,f,c,a){function l(){for(var y=arguments.length,b=y,x=Array(y);b--;)x[b]=arguments[b];if(e&&(x=Kt(x,e,u)),o&&(x=Gt(x,o,i)),_||g){var b=l.placeholder,m=$(x,b),y=y-m.length;if(a>y)return _r(n,t,cr,b,r,x,m,f,c,a-y)}if(y=h?r:this,b=p?y[n]:n,f)for(var m=x.length,j=Ru(f.length,m),w=Vt(x);j--;){var A=f[j];
|
||||
x[j]=B(A,m)?w[A]:Z}else v&&x.length>1&&x.reverse();return s&&x.length>c&&(x.length=c),this&&this!==Gn&&this instanceof l&&(b=d||or(b)),b.apply(y,x)}var s=128&t,h=1&t,p=2&t,_=8&t,g=16&t,v=512&t,d=p?Z:or(n);return l}function ar(n,t){return function(r,e){return gt(r,n,t(e))}}function lr(n){return fe(function(t){return t=a(it(t),mr()),fe(function(e){var u=this;return n(t,function(n){return r(n,u,e)})})})}function sr(n,t,r){return t=Ie(t),n=M(n),t&&t>n?(t-=n,r=r===Z?" ":r+"",n=Ze(r,wu(t/M(r))),kn.test(r)?n.match(En).slice(0,t).join(""):n.slice(0,t)):"";
|
||||
}function hr(n,t,e,u){function o(){for(var t=-1,c=arguments.length,a=-1,l=u.length,s=Array(l+c),h=this&&this!==Gn&&this instanceof o?f:n;++a<l;)s[a]=u[a];for(;c--;)s[a++]=arguments[++t];return r(h,i?e:this,s)}var i=1&t,f=or(n);return o}function pr(n){return function(t,r,e){e&&typeof e!="number"&&Sr(t,r,e)&&(r=e=Z),t=Se(t),t=t===t?t:0,r===Z?(r=t,t=0):r=Se(r)||0,e=e===Z?r>t?1:-1:Se(e)||0;var u=-1;r=Iu(wu((r-t)/(e||1)),0);for(var o=Array(r);r--;)o[n?r:++u]=t,t+=e;return o}}function _r(n,t,r,e,u,o,i,f,c,a){
|
||||
var l=8&t;f=f?Vt(f):Z;var s=l?i:Z;i=l?Z:i;var h=l?o:Z;return o=l?Z:o,t=(t|(l?32:64))&~(l?64:32),4&t||(t&=-4),t=[n,t,u,h,s,o,i,f,c,a],r=r.apply(Z,t),Ur(n)&&no(r,t),r.placeholder=e,r}function gr(n){var t=nu[n];return function(n,r){if(n=Se(n),r=Ie(r)){var e=(Ce(n)+"e").split("e"),e=t(e[0]+"e"+(+e[1]+r)),e=(Ce(e)+"e").split("e");return+(e[0]+"e"+(+e[1]-r))}return t(n)}}function vr(n,t,r,e,u,o,i,f){var c=2&t;if(!c&&typeof n!="function")throw new ru("Expected a function");var a=e?e.length:0;if(a||(t&=-97,
|
||||
e=u=Z),i=i===Z?i:Iu(Ie(i),0),f=f===Z?f:Ie(f),a-=u?u.length:0,64&t){var l=e,s=u;e=u=Z}var h=c?Z:Hu(n);return o=[n,t,r,e,u,l,s,o,i,f],h&&(r=o[1],n=h[1],t=r|n,e=128==n&&8==r||128==n&&256==r&&h[8]>=o[7].length||384==n&&h[8]>=h[7].length&&8==r,131>t||e)&&(1&n&&(o[2]=h[2],t|=1&r?0:4),(r=h[3])&&(e=o[3],o[3]=e?Kt(e,r,h[4]):Vt(r),o[4]=e?$(o[3],"__lodash_placeholder__"):Vt(h[4])),(r=h[5])&&(e=o[5],o[5]=e?Gt(e,r,h[6]):Vt(r),o[6]=e?$(o[5],"__lodash_placeholder__"):Vt(h[6])),(r=h[7])&&(o[7]=Vt(r)),128&n&&(o[8]=null==o[8]?h[8]:Ru(o[8],h[8])),
|
||||
null==o[9]&&(o[9]=h[9]),o[0]=h[0],o[1]=t),n=o[0],t=o[1],r=o[2],e=o[3],u=o[4],f=o[9]=null==o[9]?c?0:n.length:Iu(o[9]-a,0),!f&&24&t&&(t&=-25),(h?Ju:no)(t&&1!=t?8==t||16==t?ir(n,t,f):32!=t&&33!=t||u.length?cr.apply(Z,o):hr(n,t,r,e):rr(n,t,r),o)}function dr(n,t,r,e,u,o){var i=-1,f=2&u,c=1&u,a=n.length,l=t.length;if(!(a==l||f&&l>a))return false;if(l=o.get(n))return l==t;for(l=true,o.set(n,t);++i<a;){var s=n[i],h=t[i];if(e)var _=f?e(h,s,i,t,n,o):e(s,h,i,n,t,o);if(_!==Z){if(_)continue;l=false;break}if(c){if(!p(t,function(n){
|
||||
return s===n||r(s,n,e,u,o)})){l=false;break}}else if(s!==h&&!r(s,h,e,u,o)){l=false;break}}return o["delete"](n),l}function yr(n,t,r,e,u,o){switch(r){case"[object ArrayBuffer]":if(n.byteLength!=t.byteLength||!e(new _u(n),new _u(t)))break;return true;case"[object Boolean]":case"[object Date]":return+n==+t;case"[object Error]":return n.name==t.name&&n.message==t.message;case"[object Number]":return n!=+n?t!=+t:n==+t;case"[object RegExp]":case"[object String]":return n==t+"";case"[object Map]":var i=L;case"[object Set]":
|
||||
return i||(i=F),(2&o||n.size==t.size)&&e(i(n),i(t),u,1|o);case"[object Symbol]":return!!pu&&Du.call(n)==Du.call(t)}return false}function br(n,t,r,e,u,o){var i=2&u,f=Le(n),c=f.length,a=Le(t).length;if(c!=a&&!i)return false;for(var l=c;l--;){var s=f[l];if(!(i?s in t:ht(t,s)))return false}if(a=o.get(n))return a==t;a=true,o.set(n,t);for(var h=i;++l<c;){var s=f[l],p=n[s],_=t[s];if(e)var g=i?e(_,p,s,t,n,o):e(p,_,s,n,t,o);if(g===Z?p!==_&&!r(p,_,e,u,o):!g){a=false;break}h||(h="constructor"==s)}return a&&!h&&(r=n.constructor,
|
||||
e=t.constructor,r!=e&&"constructor"in n&&"constructor"in t&&!(typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)&&(a=false)),o["delete"](n),a}function xr(n){for(var t=n.name+"",r=qu[t],e=iu.call(qu,t)?r.length:0;e--;){var u=r[e],o=u.func;if(null==o||o==n)return u.name}return t}function mr(){var n=yn.iteratee||Ke,n=n===Ke?bt:n;return arguments.length?n(arguments[0],arguments[1]):n}function jr(n){n=Fe(n);for(var t=n.length;t--;){var r=n[t][1];n[t][2]=r===r&&!de(r)}return n}function wr(n,t){
|
||||
var r=null==n?Z:n[t];return be(r)?r:Z}function Ar(n){return au.call(n)}function Or(n,t,r){if(null==n)return false;var e=r(n,t);return e||Wr(t)||(t=Mt(t),n=Lr(n,t),null!=n&&(t=Pr(t),e=r(n,t))),r=n?n.length:Z,e||!!r&&ve(r)&&B(t,r)&&(Lo(n)||we(n)||le(n))}function Er(n){var t=n.length,r=n.constructor(t);return t&&"string"==typeof n[0]&&iu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function kr(n){return Br(n)?{}:(n=n.constructor,Pu(_e(n)?n.prototype:Z))}function Ir(r,e,u){var o=r.constructor;switch(e){
|
||||
case"[object ArrayBuffer]":return Tt(r);case"[object Boolean]":case"[object Date]":return new o(+r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return e=r.buffer,new r.constructor(u?Tt(e):e,r.byteOffset,r.length);case"[object Map]":return u=r.constructor,s(L(r),n,new u);case"[object Number]":case"[object String]":
|
||||
return new o(r);case"[object RegExp]":return u=new r.constructor(r.source,hn.exec(r)),u.lastIndex=r.lastIndex,u;case"[object Set]":return u=r.constructor,s(F(r),t,new u);case"[object Symbol]":return pu?Object(Du.call(r)):{}}}function Rr(n){var t=n?n.length:Z;return ve(t)&&(Lo(n)||we(n)||le(n))?m(t,String):null}function Sr(n,t,r){if(!de(r))return false;var e=typeof t;return("number"==e?se(r)&&B(t,r.length):"string"==e&&t in r)?ce(r[t],n):false}function Wr(n,t){return typeof n=="number"?true:!Lo(n)&&(rn.test(n)||!tn.test(n)||null!=t&&n in Object(t));
|
||||
}function Cr(n){var t=typeof n;return"number"==t||"boolean"==t||"string"==t&&"__proto__"!==n||null==n}function Ur(n){var t=xr(n),r=yn[t];return typeof r=="function"&&t in An.prototype?n===r?true:(t=Hu(r),!!t&&n===t[0]):false}function Br(n){var t=n&&n.constructor;return n===(typeof t=="function"&&t.prototype||uu)}function zr(n,t,r,e,u,o){return de(n)&&de(t)&&(o.set(t,n),At(n,t,Z,zr,o)),n}function Lr(n,t){return 1==t.length?n:Ue(n,Bt(t,0,-1))}function $r(n){var t=[];return Ce(n).replace(en,function(n,r,e,u){
|
||||
t.push(e?u.replace(ln,"$1"):r||n)}),t}function Fr(n){return he(n)?n:[]}function Mr(n){return typeof n=="function"?n:Te}function Nr(n){if(n instanceof An)return n.clone();var t=new wn(n.__wrapped__,n.__chain__);return t.__actions__=Vt(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function Dr(n,t,r){var e=n?n.length:0;return e?(t=r||t===Z?1:Ie(t),Bt(n,0>t?0:t,e)):[]}function Zr(n,t,r){var e=n?n.length:0;return e?(t=r||t===Z?1:Ie(t),t=e-t,Bt(n,0,0>t?0:t)):[]}function qr(n){return n?n[0]:Z;
|
||||
}function Pr(n){var t=n?n.length:0;return t?n[t-1]:Z}function Tr(n,t){return n&&n.length&&t&&t.length?St(n,t):n}function Kr(n){return n?Cu.call(n):n}function Gr(n){if(!n||!n.length)return[];var t=0;return n=i(n,function(n){return he(n)?(t=Iu(n.length,t),true):void 0}),m(t,function(t){return a(n,It(t))})}function Vr(n,t){if(!n||!n.length)return[];var e=Gr(n);return null==t?e:a(e,function(n){return r(t,Z,n)})}function Jr(n){return n=yn(n),n.__chain__=true,n}function Yr(n,t){return t(n)}function Hr(){return this;
|
||||
}function Qr(n,t){return typeof t=="function"&&Lo(n)?u(n,t):Tu(n,Mr(t))}function Xr(n,t){var r;if(typeof t=="function"&&Lo(n)){for(r=n.length;r--&&false!==t(n[r],r,n););r=n}else r=Ku(n,Mr(t));return r}function ne(n,t){var r=-1,e=ke(n),u=e.length,o=u-1;for(t=Xn(Ie(t),0,u);++r<t;){var u=Ct(r,o),i=e[u];e[u]=e[r],e[r]=i}return e.length=t,e}function te(n,t,r){return t=r?Z:t,t=n&&null==t?n.length:t,vr(n,128,Z,Z,Z,Z,t)}function re(n,t){var r;if(typeof t!="function")throw new ru("Expected a function");return n=Ie(n),
|
||||
function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=Z),r}}function ee(n,t,r){return t=r?Z:t,n=vr(n,8,Z,Z,Z,Z,Z,t),n.placeholder=ee.placeholder,n}function ue(n,t,r){return t=r?Z:t,n=vr(n,16,Z,Z,Z,Z,Z,t),n.placeholder=ue.placeholder,n}function oe(n,t,r){function e(){p&&gu(p),a&&gu(a),g=0,c=a=h=p=_=Z}function u(t,r){r&&gu(r),a=p=_=Z,t&&(g=ko(),l=n.apply(h,c),p||a||(c=h=Z))}function o(){var n=t-(ko()-s);0>=n||n>t?u(_,a):p=mu(o,n)}function i(){u(y,p)}function f(){if(c=arguments,s=ko(),h=this,
|
||||
_=y&&(p||!v),false===d)var r=v&&!p;else{a||v||(g=s);var e=d-(s-g),u=0>=e||e>d;u?(a&&(a=gu(a)),g=s,l=n.apply(h,c)):a||(a=mu(i,e))}return u&&p?p=gu(p):p||t===d||(p=mu(o,t)),r&&(u=true,l=n.apply(h,c)),!u||p||a||(c=h=Z),l}var c,a,l,s,h,p,_,g=0,v=false,d=false,y=true;if(typeof n!="function")throw new ru("Expected a function");return t=Se(t)||0,de(r)&&(v=!!r.leading,d="maxWait"in r&&Iu(Se(r.maxWait)||0,t),y="trailing"in r?!!r.trailing:y),f.cancel=e,f.flush=function(){return(p&&_||a&&y)&&(l=n.apply(h,c)),e(),l},f}function ie(n,t){
|
||||
function r(){var e=arguments,u=t?t.apply(this,e):e[0],o=r.cache;return o.has(u)?o.get(u):(e=n.apply(this,e),r.cache=o.set(u,e),e)}if(typeof n!="function"||t&&typeof t!="function")throw new ru("Expected a function");return r.cache=new ie.Cache,r}function fe(n,t){if(typeof n!="function")throw new ru("Expected a function");return t=Iu(t===Z?n.length-1:Ie(t),0),function(){for(var e=arguments,u=-1,o=Iu(e.length-t,0),i=Array(o);++u<o;)i[u]=e[t+u];switch(t){case 0:return n.call(this,i);case 1:return n.call(this,e[0],i);
|
||||
case 2:return n.call(this,e[0],e[1],i)}for(o=Array(t+1),u=-1;++u<t;)o[u]=e[u];return o[t]=i,r(n,this,o)}}function ce(n,t){return n===t||n!==n&&t!==t}function ae(n,t){return n>t}function le(n){return he(n)&&iu.call(n,"callee")&&(!xu.call(n,"callee")||"[object Arguments]"==au.call(n))}function se(n){return null!=n&&!(typeof n=="function"&&_e(n))&&ve(Qu(n))}function he(n){return ye(n)&&se(n)}function pe(n){return ye(n)&&typeof n.message=="string"&&"[object Error]"==au.call(n)}function _e(n){return n=de(n)?au.call(n):"",
|
||||
"[object Function]"==n||"[object GeneratorFunction]"==n}function ge(n){return typeof n=="number"&&n==Ie(n)}function ve(n){return typeof n=="number"&&n>-1&&0==n%1&&9007199254740991>=n}function de(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function ye(n){return!!n&&typeof n=="object"}function be(n){return null==n?false:_e(n)?su.test(ou.call(n)):ye(n)&&(U(n)?su:vn).test(n)}function xe(n){return typeof n=="number"||ye(n)&&"[object Number]"==au.call(n)}function me(n){if(!ye(n)||"[object Object]"!=au.call(n)||U(n))return false;
|
||||
var t=uu;return typeof n.constructor=="function"&&(t=du(n)),null===t?true:(n=t.constructor,typeof n=="function"&&n instanceof n&&ou.call(n)==cu)}function je(n){return de(n)&&"[object RegExp]"==au.call(n)}function we(n){return typeof n=="string"||!Lo(n)&&ye(n)&&"[object String]"==au.call(n)}function Ae(n){return typeof n=="symbol"||ye(n)&&"[object Symbol]"==au.call(n)}function Oe(n){return ye(n)&&ve(n.length)&&!!Cn[au.call(n)]}function Ee(n,t){return t>n}function ke(n){if(!n)return[];if(se(n))return we(n)?n.match(En):Vt(n);
|
||||
if(bu&&n[bu])return z(n[bu]());var t=Ar(n);return("[object Map]"==t?L:"[object Set]"==t?F:Me)(n)}function Ie(n){if(!n)return 0===n?n:0;if(n=Se(n),n===q||n===-q)return 1.7976931348623157e308*(0>n?-1:1);var t=n%1;return n===n?t?n-t:n:0}function Re(n){return n?Xn(Ie(n),0,4294967295):0}function Se(n){if(de(n)&&(n=_e(n.valueOf)?n.valueOf():n,n=de(n)?n+"":n),typeof n!="string")return 0===n?n:+n;n=n.replace(fn,"");var t=gn.test(n);return t||dn.test(n)?Nn(n.slice(2),t?2:8):_n.test(n)?P:+n}function We(n){
|
||||
return Jt(n,$e(n))}function Ce(n){if(typeof n=="string")return n;if(null==n)return"";if(Ae(n))return pu?Zu.call(n):"";var t=n+"";return"0"==t&&1/n==-q?"-0":t}function Ue(n,t,r){return n=null==n?Z:st(n,t),n===Z?r:n}function Be(n,t){return Or(n,t,ht)}function ze(n,t){return Or(n,t,pt)}function Le(n){var t=Br(n);if(!t&&!se(n))return ku(Object(n));var r,e=Rr(n),u=!!e,e=e||[],o=e.length;for(r in n)!ht(n,r)||u&&("length"==r||B(r,o))||t&&"constructor"==r||e.push(r);return e}function $e(n){for(var t=-1,r=Br(n),e=xt(n),u=e.length,o=Rr(n),i=!!o,o=o||[],f=o.length;++t<u;){
|
||||
var c=e[t];i&&("length"==c||B(c,f))||"constructor"==c&&(r||!iu.call(n,c))||o.push(c)}return o}function Fe(n){return j(n,Le(n))}function Me(n){return n?A(n,Le(n)):[]}function Ne(n){return ti(Ce(n).toLowerCase())}function De(n){return(n=Ce(n))&&n.replace(bn,R).replace(On,"")}function Ze(n,t){n=Ce(n),t=Ie(t);var r="";if(!n||1>t||t>9007199254740991)return r;do t%2&&(r+=n),t=Au(t/2),n+=n;while(t);return r}function qe(n,t,r){return n=Ce(n),t=r?Z:t,t===Z&&(t=Sn.test(n)?Rn:In),n.match(t)||[]}function Pe(n){
|
||||
return function(){return n}}function Te(n){return n}function Ke(n){return ye(n)&&!Lo(n)?Ge(n):bt(n)}function Ge(n){return jt(nt(n,true))}function Ve(n,t,r){var e=Le(t),o=lt(t,e);null!=r||de(t)&&(o.length||!e.length)||(r=t,t=n,n=this,o=lt(t,Le(t)));var i=de(r)&&"chain"in r?r.chain:true,f=_e(n);return u(o,function(r){var e=t[r];n[r]=e,f&&(n.prototype[r]=function(){var t=this.__chain__;if(i||t){var r=n(this.__wrapped__);return(r.__actions__=Vt(this.__actions__)).push({func:e,args:arguments,thisArg:n}),r.__chain__=t,
|
||||
r}return e.apply(n,l([this.value()],arguments))})}),n}function Je(){}function Ye(n){return Wr(n)?It(n):Rt(n)}function He(n){return n&&n.length?x(n,Te):0}k=k?Vn.defaults({},k,Vn.pick(Gn,Wn)):Gn;var Qe=k.Date,Xe=k.Error,nu=k.Math,tu=k.RegExp,ru=k.TypeError,eu=k.Array.prototype,uu=k.Object.prototype,ou=k.Function.prototype.toString,iu=uu.hasOwnProperty,fu=0,cu=ou.call(Object),au=uu.toString,lu=Gn._,su=tu("^"+ou.call(iu).replace(un,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),hu=k.f,pu=k.Symbol,_u=k.Uint8Array,gu=k.clearTimeout,vu=hu?hu.g:Z,du=Object.getPrototypeOf,yu=Object.getOwnPropertySymbols,bu=typeof(bu=pu&&pu.iterator)=="symbol"?bu:Z,xu=uu.propertyIsEnumerable,mu=k.setTimeout,ju=eu.splice,wu=nu.ceil,Au=nu.floor,Ou=k.isFinite,Eu=eu.join,ku=Object.keys,Iu=nu.max,Ru=nu.min,Su=k.parseInt,Wu=nu.random,Cu=eu.reverse,Uu=wr(k,"Map"),Bu=wr(k,"Set"),zu=wr(k,"WeakMap"),Lu=wr(Object,"create"),$u=zu&&new zu,Fu=Uu?ou.call(Uu):"",Mu=Bu?ou.call(Bu):"",Nu=pu?pu.prototype:Z,Du=pu?Nu.valueOf:Z,Zu=pu?Nu.toString:Z,qu={};
|
||||
yn.templateSettings={escape:Q,evaluate:X,interpolate:nn,variable:"",imports:{_:yn}};var Pu=function(){function n(){}return function(t){if(de(t)){n.prototype=t;var r=new n;n.prototype=Z}return r||{}}}(),Tu=nr(ct),Ku=nr(at,true),Gu=tr(),Vu=tr(true);vu&&!xu.call({valueOf:1},"valueOf")&&(xt=function(n){return z(vu(n))});var Ju=$u?function(n,t){return $u.set(n,t),n}:Te,Yu=Bu&&2===new Bu([1,2]).size?function(n){return new Bu(n)}:Je,Hu=$u?function(n){return $u.get(n)}:Je,Qu=It("length"),Xu=yu||function(){return[];
|
||||
};(Uu&&"[object Map]"!=Ar(new Uu)||Bu&&"[object Set]"!=Ar(new Bu))&&(Ar=function(n){var t=au.call(n);if(n="[object Object]"==t?n.constructor:null,n=typeof n=="function"?ou.call(n):""){if(n==Fu)return"[object Map]";if(n==Mu)return"[object Set]"}return t});var no=function(){var n=0,t=0;return function(r,e){var u=ko(),o=16-(u-t);if(t=u,o>0){if(150<=++n)return r}else n=0;return Ju(r,e)}}(),to=fe(function(n,t){Lo(n)||(n=null==n?[]:[Object(n)]),t=it(t);for(var r=n,e=t,u=-1,o=r.length,i=-1,f=e.length,c=Array(o+f);++u<o;)c[u]=r[u];
|
||||
for(;++i<f;)c[u++]=e[i];return c}),ro=fe(function(n,t){return he(n)?et(n,it(t,false,true)):[]}),eo=fe(function(n,t){var r=Pr(t);return he(r)&&(r=Z),he(n)?et(n,it(t,false,true),mr(r)):[]}),uo=fe(function(n,t){var r=Pr(t);return he(r)&&(r=Z),he(n)?et(n,it(t,false,true),Z,r):[]}),oo=fe(function(n){var t=a(n,Fr);return t.length&&t[0]===n[0]?_t(t):[]}),io=fe(function(n){var t=Pr(n),r=a(n,Fr);return t===Pr(r)?t=Z:r.pop(),r.length&&r[0]===n[0]?_t(r,mr(t)):[]}),fo=fe(function(n){var t=Pr(n),r=a(n,Fr);return t===Pr(r)?t=Z:r.pop(),
|
||||
r.length&&r[0]===n[0]?_t(r,Z,t):[]}),co=fe(Tr),ao=fe(function(n,t){t=a(it(t),String);var r=Qn(n,t);return Wt(n,t.sort(I)),r}),lo=fe(function(n){return Nt(it(n,false,true))}),so=fe(function(n){var t=Pr(n);return he(t)&&(t=Z),Nt(it(n,false,true),mr(t))}),ho=fe(function(n){var t=Pr(n);return he(t)&&(t=Z),Nt(it(n,false,true),Z,t)}),po=fe(function(n,t){return he(n)?et(n,t):[]}),_o=fe(function(n){return qt(i(n,he))}),go=fe(function(n){var t=Pr(n);return he(t)&&(t=Z),qt(i(n,he),mr(t))}),vo=fe(function(n){var t=Pr(n);return he(t)&&(t=Z),
|
||||
qt(i(n,he),Z,t)}),yo=fe(Gr),bo=fe(function(n){var t=n.length,t=t>1?n[t-1]:Z,t=typeof t=="function"?(n.pop(),t):Z;return Vr(n,t)}),xo=fe(function(n){function t(t){return Qn(t,n)}n=it(n);var r=n.length,e=r?n[0]:0,u=this.__wrapped__;return 1>=r&&!this.__actions__.length&&u instanceof An&&B(e)?(u=u.slice(e,+e+(r?1:0)),u.__actions__.push({func:Yr,args:[t],thisArg:Z}),new wn(u,this.__chain__).thru(function(n){return r&&!n.length&&n.push(Z),n})):this.thru(t)}),mo=Qt(function(n,t,r){iu.call(n,r)?++n[r]:n[r]=1;
|
||||
}),jo=Qt(function(n,t,r){iu.call(n,r)?n[r].push(t):n[r]=[t]}),wo=fe(function(n,t,e){var u=-1,o=typeof t=="function",i=Wr(t),f=se(n)?Array(n.length):[];return Tu(n,function(n){var c=o?t:i&&null!=n?n[t]:Z;f[++u]=c?r(c,n,e):vt(n,t,e)}),f}),Ao=Qt(function(n,t,r){n[r]=t}),Oo=Qt(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Eo=fe(function(n,t){if(null==n)return[];var r=t.length;return r>1&&Sr(n,t[0],t[1])?t=[]:r>2&&Sr(t[0],t[1],t[2])&&(t.length=1),Ot(n,it(t),[])}),ko=Qe.now,Io=fe(function(n,t,r){
|
||||
var e=1;if(r.length)var u=$(r,Io.placeholder),e=32|e;return vr(n,e,t,r,u)}),Ro=fe(function(n,t,r){var e=3;if(r.length)var u=$(r,Ro.placeholder),e=32|e;return vr(t,e,n,r,u)}),So=fe(function(n,t){return rt(n,1,t)}),Wo=fe(function(n,t,r){return rt(n,Se(t)||0,r)}),Co=fe(function(n,t){t=a(it(t),mr());var e=t.length;return fe(function(u){for(var o=-1,i=Ru(u.length,e);++o<i;)u[o]=t[o].call(this,u[o]);return r(n,this,u)})}),Uo=fe(function(n,t){var r=$(t,Uo.placeholder);return vr(n,32,Z,t,r)}),Bo=fe(function(n,t){
|
||||
var r=$(t,Bo.placeholder);return vr(n,64,Z,t,r)}),zo=fe(function(n,t){return vr(n,256,Z,Z,Z,it(t))}),Lo=Array.isArray,$o=Xt(function(n,t){Jt(t,Le(t),n)}),Fo=Xt(function(n,t){Jt(t,$e(t),n)}),Mo=Xt(function(n,t,r,e){Yt(t,$e(t),n,e)}),No=Xt(function(n,t,r,e){Yt(t,Le(t),n,e)}),Do=fe(function(n,t){return Qn(n,it(t))}),Zo=fe(function(n){return n.push(Z,Tn),r(Mo,Z,n)}),qo=fe(function(n){return n.push(Z,zr),r(Vo,Z,n)}),Po=ar(function(n,t,r){n[t]=r},Pe(Te)),To=ar(function(n,t,r){iu.call(n,t)?n[t].push(r):n[t]=[r];
|
||||
},mr),Ko=fe(vt),Go=Xt(function(n,t,r){At(n,t,r)}),Vo=Xt(function(n,t,r,e){At(n,t,r,e)}),Jo=fe(function(n,t){return null==n?{}:(t=a(it(t),String),Et(n,et($e(n),t)))}),Yo=fe(function(n,t){return null==n?{}:Et(n,it(t))}),Ho=ur(function(n,t,r){return t=t.toLowerCase(),n+(r?Ne(t):t)}),Qo=ur(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()}),Xo=ur(function(n,t,r){return n+(r?" ":"")+t.toLowerCase()}),ni=er("toLowerCase"),ti=er("toUpperCase"),ri=ur(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),ei=ur(function(n,t,r){
|
||||
return n+(r?" ":"")+Ne(t)}),ui=ur(function(n,t,r){return n+(r?" ":"")+t.toUpperCase()}),oi=fe(function(n,t){try{return r(n,Z,t)}catch(e){return pe(e)?e:new Xe(e)}}),ii=fe(function(n,t){return u(it(t),function(t){n[t]=Io(n[t],n)}),n}),fi=fr(),ci=fr(true),ai=fe(function(n,t){return function(r){return vt(r,n,t)}}),li=fe(function(n,t){return function(r){return vt(n,r,t)}}),si=lr(a),hi=lr(o),pi=lr(p),_i=pr(),gi=pr(true),vi=gr("ceil"),di=gr("floor"),yi=gr("round");return yn.prototype=jn.prototype,wn.prototype=Pu(jn.prototype),
|
||||
wn.prototype.constructor=wn,An.prototype=Pu(jn.prototype),An.prototype.constructor=An,Bn.prototype=Lu?Lu(null):uu,zn.prototype.clear=function(){this.__data__={hash:new Bn,map:Uu?new Uu:[],string:new Bn}},zn.prototype["delete"]=function(n){var t=this.__data__;return Cr(n)?(t=typeof n=="string"?t.string:t.hash,n=(Lu?t[n]!==Z:iu.call(t,n))&&delete t[n]):n=Uu?t.map["delete"](n):Dn(t.map,n),n},zn.prototype.get=function(n){var t=this.__data__;return Cr(n)?(t=typeof n=="string"?t.string:t.hash,Lu?(n=t[n],
|
||||
n="__lodash_hash_undefined__"===n?Z:n):n=iu.call(t,n)?t[n]:Z):n=Uu?t.map.get(n):Zn(t.map,n),n},zn.prototype.has=function(n){var t=this.__data__;return Cr(n)?(t=typeof n=="string"?t.string:t.hash,n=Lu?t[n]!==Z:iu.call(t,n)):n=Uu?t.map.has(n):-1<qn(t.map,n),n},zn.prototype.set=function(n,t){var r=this.__data__;return Cr(n)?(typeof n=="string"?r.string:r.hash)[n]=Lu&&t===Z?"__lodash_hash_undefined__":t:Uu?r.map.set(n,t):Pn(r.map,n,t),this},Ln.prototype.push=function(n){var t=this.__data__;Cr(n)?(t=t.__data__,
|
||||
(typeof n=="string"?t.string:t.hash)[n]="__lodash_hash_undefined__"):t.set(n,"__lodash_hash_undefined__")},Fn.prototype.clear=function(){this.__data__={array:[],map:null}},Fn.prototype["delete"]=function(n){var t=this.__data__,r=t.array;return r?Dn(r,n):t.map["delete"](n)},Fn.prototype.get=function(n){var t=this.__data__,r=t.array;return r?Zn(r,n):t.map.get(n)},Fn.prototype.has=function(n){var t=this.__data__,r=t.array;return r?-1<qn(r,n):t.map.has(n)},Fn.prototype.set=function(n,t){var r=this.__data__,e=r.array;
|
||||
return e&&(199>e.length?Pn(e,n,t):(r.array=null,r.map=new zn(e))),(r=r.map)&&r.set(n,t),this},ie.Cache=zn,yn.after=function(n,t){if(typeof t!="function")throw new ru("Expected a function");return n=Ie(n),function(){return 1>--n?t.apply(this,arguments):void 0}},yn.ary=te,yn.assign=$o,yn.assignIn=Fo,yn.assignInWith=Mo,yn.assignWith=No,yn.at=Do,yn.before=re,yn.bind=Io,yn.bindAll=ii,yn.bindKey=Ro,yn.chain=Jr,yn.chunk=function(n,t){t=Iu(Ie(t),0);var r=n?n.length:0;if(!r||1>t)return[];for(var e=0,u=-1,o=Array(wu(r/t));r>e;)o[++u]=Bt(n,e,e+=t);
|
||||
return o},yn.compact=function(n){for(var t=-1,r=n?n.length:0,e=-1,u=[];++t<r;){var o=n[t];o&&(u[++e]=o)}return u},yn.concat=to,yn.cond=function(n){var t=n?n.length:0,e=mr();return n=t?a(n,function(n){if("function"!=typeof n[1])throw new ru("Expected a function");return[e(n[0]),n[1]]}):[],fe(function(e){for(var u=-1;++u<t;){var o=n[u];if(r(o[0],this,e))return r(o[1],this,e)}})},yn.conforms=function(n){return tt(nt(n,true))},yn.constant=Pe,yn.countBy=mo,yn.create=function(n,t){var r=Pu(n);return t?Hn(r,t):r;
|
||||
},yn.curry=ee,yn.curryRight=ue,yn.debounce=oe,yn.defaults=Zo,yn.defaultsDeep=qo,yn.defer=So,yn.delay=Wo,yn.difference=ro,yn.differenceBy=eo,yn.differenceWith=uo,yn.drop=Dr,yn.dropRight=Zr,yn.dropRightWhile=function(n,t){return n&&n.length?Dt(n,mr(t,3),true,true):[]},yn.dropWhile=function(n,t){return n&&n.length?Dt(n,mr(t,3),true):[]},yn.fill=function(n,t,r,e){var u=n?n.length:0;if(!u)return[];for(r&&typeof r!="number"&&Sr(n,t,r)&&(r=0,e=u),u=n.length,r=Ie(r),0>r&&(r=-r>u?0:u+r),e=e===Z||e>u?u:Ie(e),0>e&&(e+=u),
|
||||
e=r>e?0:Re(e);e>r;)n[r++]=t;return n},yn.filter=function(n,t){return(Lo(n)?i:ot)(n,mr(t,3))},yn.flatMap=function(n,t){return n&&n.length?it(a(n,mr(t,3))):[]},yn.flatten=function(n){return n&&n.length?it(n):[]},yn.flattenDeep=function(n){return n&&n.length?it(n,true):[]},yn.flip=function(n){return vr(n,512)},yn.flow=fi,yn.flowRight=ci,yn.fromPairs=function(n){for(var t=-1,r=n?n.length:0,e={};++t<r;){var u=n[t];e[u[0]]=u[1]}return e},yn.functions=function(n){return null==n?[]:lt(n,Le(n))},yn.functionsIn=function(n){
|
||||
return null==n?[]:lt(n,$e(n))},yn.groupBy=jo,yn.initial=function(n){return Zr(n,1)},yn.intersection=oo,yn.intersectionBy=io,yn.intersectionWith=fo,yn.invert=Po,yn.invertBy=To,yn.invokeMap=wo,yn.iteratee=Ke,yn.keyBy=Ao,yn.keys=Le,yn.keysIn=$e,yn.map=function(n,t){return(Lo(n)?a:mt)(n,mr(t,3))},yn.mapKeys=function(n,t){var r={};return t=mr(t,3),ct(n,function(n,e,u){r[t(n,e,u)]=n}),r},yn.mapValues=function(n,t){var r={};return t=mr(t,3),ct(n,function(n,e,u){r[e]=t(n,e,u)}),r},yn.matches=Ge,yn.matchesProperty=function(n,t){
|
||||
return wt(n,nt(t,true))},yn.memoize=ie,yn.merge=Go,yn.mergeWith=Vo,yn.method=ai,yn.methodOf=li,yn.mixin=Ve,yn.negate=function(n){if(typeof n!="function")throw new ru("Expected a function");return function(){return!n.apply(this,arguments)}},yn.nthArg=function(n){return n=Ie(n),function(){return arguments[n]}},yn.omit=Jo,yn.omitBy=function(n,t){return t=mr(t,2),kt(n,function(n,r){return!t(n,r)})},yn.once=function(n){return re(2,n)},yn.orderBy=function(n,t,r,e){return null==n?[]:(Lo(t)||(t=null==t?[]:[t]),
|
||||
r=e?Z:r,Lo(r)||(r=null==r?[]:[r]),Ot(n,t,r))},yn.over=si,yn.overArgs=Co,yn.overEvery=hi,yn.overSome=pi,yn.partial=Uo,yn.partialRight=Bo,yn.partition=Oo,yn.pick=Yo,yn.pickBy=function(n,t){return null==n?{}:kt(n,mr(t,2))},yn.property=Ye,yn.propertyOf=function(n){return function(t){return null==n?Z:st(n,t)}},yn.pull=co,yn.pullAll=Tr,yn.pullAllBy=function(n,t,r){return n&&n.length&&t&&t.length?St(n,t,mr(r)):n},yn.pullAt=ao,yn.range=_i,yn.rangeRight=gi,yn.rearg=zo,yn.reject=function(n,t){var r=Lo(n)?i:ot;
|
||||
return t=mr(t,3),r(n,function(n,r,e){return!t(n,r,e)})},yn.remove=function(n,t){var r=[];if(!n||!n.length)return r;var e=-1,u=[],o=n.length;for(t=mr(t,3);++e<o;){var i=n[e];t(i,e,n)&&(r.push(i),u.push(e))}return Wt(n,u),r},yn.rest=fe,yn.reverse=Kr,yn.sampleSize=ne,yn.set=function(n,t,r){return null==n?n:Ut(n,t,r)},yn.setWith=function(n,t,r,e){return e=typeof e=="function"?e:Z,null==n?n:Ut(n,t,r,e)},yn.shuffle=function(n){return ne(n,4294967295)},yn.slice=function(n,t,r){var e=n?n.length:0;return e?(r&&typeof r!="number"&&Sr(n,t,r)?(t=0,
|
||||
r=e):(t=null==t?0:Ie(t),r=r===Z?e:Ie(r)),Bt(n,t,r)):[]},yn.sortBy=Eo,yn.sortedUniq=function(n){return n&&n.length?Ft(n):[]},yn.sortedUniqBy=function(n,t){return n&&n.length?Ft(n,mr(t)):[]},yn.split=function(n,t,r){return Ce(n).split(t,r)},yn.spread=function(n){if(typeof n!="function")throw new ru("Expected a function");return function(t){return r(n,this,t)}},yn.tail=function(n){return Dr(n,1)},yn.take=function(n,t,r){return n&&n.length?(t=r||t===Z?1:Ie(t),Bt(n,0,0>t?0:t)):[]},yn.takeRight=function(n,t,r){
|
||||
var e=n?n.length:0;return e?(t=r||t===Z?1:Ie(t),t=e-t,Bt(n,0>t?0:t,e)):[]},yn.takeRightWhile=function(n,t){return n&&n.length?Dt(n,mr(t,3),false,true):[]},yn.takeWhile=function(n,t){return n&&n.length?Dt(n,mr(t,3)):[]},yn.tap=function(n,t){return t(n),n},yn.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new ru("Expected a function");return de(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),oe(n,t,{leading:e,maxWait:t,trailing:u})},yn.thru=Yr,yn.toArray=ke,yn.toPairs=Fe,
|
||||
yn.toPairsIn=function(n){return j(n,$e(n))},yn.toPath=function(n){return Lo(n)?a(n,String):$r(n)},yn.toPlainObject=We,yn.transform=function(n,t,r){var e=Lo(n)||Oe(n);if(t=mr(t,4),null==r)if(e||de(n)){var o=n.constructor;r=e?Lo(n)?new o:[]:Pu(_e(o)?o.prototype:Z)}else r={};return(e?u:ct)(n,function(n,e,u){return t(r,n,e,u)}),r},yn.unary=function(n){return te(n,1)},yn.union=lo,yn.unionBy=so,yn.unionWith=ho,yn.uniq=function(n){return n&&n.length?Nt(n):[]},yn.uniqBy=function(n,t){return n&&n.length?Nt(n,mr(t)):[];
|
||||
},yn.uniqWith=function(n,t){return n&&n.length?Nt(n,Z,t):[]},yn.unset=function(n,t){var r;if(null==n)r=true;else{r=n;var e=t,e=Wr(e,r)?[e+""]:Mt(e);r=Lr(r,e),e=Pr(e),r=null!=r&&Be(r,e)?delete r[e]:true}return r},yn.unzip=Gr,yn.unzipWith=Vr,yn.values=Me,yn.valuesIn=function(n){return null==n?A(n,$e(n)):[]},yn.without=po,yn.words=qe,yn.wrap=function(n,t){return t=null==t?Te:t,Uo(t,n)},yn.xor=_o,yn.xorBy=go,yn.xorWith=vo,yn.zip=yo,yn.zipObject=function(n,t){return Pt(n||[],t||[],Jn)},yn.zipObjectDeep=function(n,t){
|
||||
return Pt(n||[],t||[],Ut)},yn.zipWith=bo,yn.extend=Fo,yn.extendWith=Mo,Ve(yn,yn),yn.add=function(n,t){var r;return n!==Z&&(r=n),t!==Z&&(r=r===Z?t:r+t),r},yn.attempt=oi,yn.camelCase=Ho,yn.capitalize=Ne,yn.ceil=vi,yn.clamp=function(n,t,r){return r===Z&&(r=t,t=Z),r!==Z&&(r=Se(r),r=r===r?r:0),t!==Z&&(t=Se(t),t=t===t?t:0),Xn(Se(n),t,r)},yn.clone=function(n){return nt(n)},yn.cloneDeep=function(n){return nt(n,true)},yn.cloneDeepWith=function(n,t){return nt(n,true,t)},yn.cloneWith=function(n,t){return nt(n,false,t);
|
||||
},yn.deburr=De,yn.endsWith=function(n,t,r){n=Ce(n),t=typeof t=="string"?t:t+"";var e=n.length;return r=r===Z?e:Xn(Ie(r),0,e),r-=t.length,r>=0&&n.indexOf(t,r)==r},yn.eq=ce,yn.escape=function(n){return(n=Ce(n))&&H.test(n)?n.replace(J,S):n},yn.escapeRegExp=function(n){return(n=Ce(n))&&on.test(n)?n.replace(un,"\\$&"):n},yn.every=function(n,t,r){var e=Lo(n)?o:ut;return r&&Sr(n,t,r)&&(t=Z),e(n,mr(t,3))},yn.find=function(n,t){if(t=mr(t,3),Lo(n)){var r=v(n,t);return r>-1?n[r]:Z}return g(n,t,Tu)},yn.findIndex=function(n,t){
|
||||
return n&&n.length?v(n,mr(t,3)):-1},yn.findKey=function(n,t){return g(n,mr(t,3),ct,true)},yn.findLast=function(n,t){if(t=mr(t,3),Lo(n)){var r=v(n,t,true);return r>-1?n[r]:Z}return g(n,t,Ku)},yn.findLastIndex=function(n,t){return n&&n.length?v(n,mr(t,3),true):-1},yn.findLastKey=function(n,t){return g(n,mr(t,3),at,true)},yn.floor=di,yn.forEach=Qr,yn.forEachRight=Xr,yn.forIn=function(n,t){return null==n?n:Gu(n,Mr(t),$e)},yn.forInRight=function(n,t){return null==n?n:Vu(n,Mr(t),$e)},yn.forOwn=function(n,t){return n&&ct(n,Mr(t));
|
||||
},yn.forOwnRight=function(n,t){return n&&at(n,Mr(t))},yn.get=Ue,yn.gt=ae,yn.gte=function(n,t){return n>=t},yn.has=Be,yn.hasIn=ze,yn.head=qr,yn.identity=Te,yn.includes=function(n,t,r,e){return n=se(n)?n:Me(n),r=r&&!e?Ie(r):0,e=n.length,0>r&&(r=Iu(e+r,0)),we(n)?e>=r&&-1<n.indexOf(t,r):!!e&&-1<d(n,t,r)},yn.indexOf=function(n,t,r){var e=n?n.length:0;return e?(r=Ie(r),0>r&&(r=Iu(e+r,0)),d(n,t,r)):-1},yn.inRange=function(n,t,r){return t=Se(t)||0,r===Z?(r=t,t=0):r=Se(r)||0,n=Se(n),n>=Ru(t,r)&&n<Iu(t,r)},
|
||||
yn.invoke=Ko,yn.isArguments=le,yn.isArray=Lo,yn.isArrayLike=se,yn.isArrayLikeObject=he,yn.isBoolean=function(n){return true===n||false===n||ye(n)&&"[object Boolean]"==au.call(n)},yn.isDate=function(n){return ye(n)&&"[object Date]"==au.call(n)},yn.isElement=function(n){return!!n&&1===n.nodeType&&ye(n)&&!me(n)},yn.isEmpty=function(n){if(se(n)&&(Lo(n)||we(n)||_e(n.splice)||le(n)))return!n.length;for(var t in n)if(iu.call(n,t))return false;return true},yn.isEqual=function(n,t){return dt(n,t)},yn.isEqualWith=function(n,t,r){
|
||||
var e=(r=typeof r=="function"?r:Z)?r(n,t):Z;return e===Z?dt(n,t,r):!!e},yn.isError=pe,yn.isFinite=function(n){return typeof n=="number"&&Ou(n)},yn.isFunction=_e,yn.isInteger=ge,yn.isLength=ve,yn.isMatch=function(n,t){return n===t||yt(n,t,jr(t))},yn.isMatchWith=function(n,t,r){return r=typeof r=="function"?r:Z,yt(n,t,jr(t),r)},yn.isNaN=function(n){return xe(n)&&n!=+n},yn.isNative=be,yn.isNil=function(n){return null==n},yn.isNull=function(n){return null===n},yn.isNumber=xe,yn.isObject=de,yn.isObjectLike=ye,
|
||||
yn.isPlainObject=me,yn.isRegExp=je,yn.isSafeInteger=function(n){return ge(n)&&n>=-9007199254740991&&9007199254740991>=n},yn.isString=we,yn.isSymbol=Ae,yn.isTypedArray=Oe,yn.isUndefined=function(n){return n===Z},yn.join=function(n,t){return n?Eu.call(n,t):""},yn.kebabCase=Qo,yn.last=Pr,yn.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(r!==Z&&(u=Ie(r),u=(0>u?Iu(e+u,0):Ru(u,e-1))+1),t!==t)return C(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},yn.lowerCase=Xo,yn.lowerFirst=ni,
|
||||
yn.lt=Ee,yn.lte=function(n,t){return t>=n},yn.max=function(n){return n&&n.length?_(n,Te,ae):Z},yn.maxBy=function(n,t){return n&&n.length?_(n,mr(t),ae):Z},yn.mean=function(n){return He(n)/(n?n.length:0)},yn.min=function(n){return n&&n.length?_(n,Te,Ee):Z},yn.minBy=function(n,t){return n&&n.length?_(n,mr(t),Ee):Z},yn.noConflict=function(){return Gn._===this&&(Gn._=lu),this},yn.noop=Je,yn.now=ko,yn.pad=function(n,t,r){n=Ce(n),t=Ie(t);var e=M(n);return t&&t>e?(e=(t-e)/2,t=Au(e),e=wu(e),sr("",t,r)+n+sr("",e,r)):n;
|
||||
},yn.padEnd=function(n,t,r){return n=Ce(n),n+sr(n,t,r)},yn.padStart=function(n,t,r){return n=Ce(n),sr(n,t,r)+n},yn.parseInt=function(n,t,r){return r||null==t?t=0:t&&(t=+t),n=Ce(n).replace(fn,""),Su(n,t||(pn.test(n)?16:10))},yn.random=function(n,t,r){if(r&&typeof r!="boolean"&&Sr(n,t,r)&&(t=r=Z),r===Z&&(typeof t=="boolean"?(r=t,t=Z):typeof n=="boolean"&&(r=n,n=Z)),n===Z&&t===Z?(n=0,t=1):(n=Se(n)||0,t===Z?(t=n,n=0):t=Se(t)||0),n>t){var e=n;n=t,t=e}return r||n%1||t%1?(r=Wu(),Ru(n+r*(t-n+Mn("1e-"+((r+"").length-1))),t)):Ct(n,t);
|
||||
},yn.reduce=function(n,t,r){var e=Lo(n)?s:y,u=3>arguments.length;return e(n,mr(t,4),r,u,Tu)},yn.reduceRight=function(n,t,r){var e=Lo(n)?h:y,u=3>arguments.length;return e(n,mr(t,4),r,u,Ku)},yn.repeat=Ze,yn.replace=function(){var n=arguments,t=Ce(n[0]);return 3>n.length?t:t.replace(n[1],n[2])},yn.result=function(n,t,r){if(Wr(t,n))e=null==n?Z:n[t];else{t=Mt(t);var e=Ue(n,t);n=Lr(n,t)}return e===Z&&(e=r),_e(e)?e.call(n):e},yn.round=yi,yn.runInContext=D,yn.sample=function(n){n=se(n)?n:Me(n);var t=n.length;
|
||||
return t>0?n[Ct(0,t-1)]:Z},yn.size=function(n){if(null==n)return 0;if(se(n)){var t=n.length;return t&&we(n)?M(n):t}return Le(n).length},yn.snakeCase=ri,yn.some=function(n,t,r){var e=Lo(n)?p:zt;return r&&Sr(n,t,r)&&(t=Z),e(n,mr(t,3))},yn.sortedIndex=function(n,t){return Lt(n,t)},yn.sortedIndexBy=function(n,t,r){return $t(n,t,mr(r))},yn.sortedIndexOf=function(n,t){var r=n?n.length:0;if(r){var e=Lt(n,t);if(r>e&&ce(n[e],t))return e}return-1},yn.sortedLastIndex=function(n,t){return Lt(n,t,true)},yn.sortedLastIndexBy=function(n,t,r){
|
||||
return $t(n,t,mr(r),true)},yn.sortedLastIndexOf=function(n,t){if(n&&n.length){var r=Lt(n,t,true)-1;if(ce(n[r],t))return r}return-1},yn.startCase=ei,yn.startsWith=function(n,t,r){return n=Ce(n),r=Xn(Ie(r),0,n.length),n.lastIndexOf(t,r)==r},yn.subtract=function(n,t){var r;return n!==Z&&(r=n),t!==Z&&(r=r===Z?t:r-t),r},yn.sum=He,yn.sumBy=function(n,t){return n&&n.length?x(n,mr(t)):0},yn.template=function(n,t,r){var e=yn.templateSettings;r&&Sr(n,t,r)&&(t=Z),n=Ce(n),t=Mo({},t,e,Tn),r=Mo({},t.imports,e.imports,Tn);
|
||||
var u,o,i=Le(r),f=A(r,i),c=0;r=t.interpolate||xn;var a="__p+='";r=tu((t.escape||xn).source+"|"+r.source+"|"+(r===nn?sn:xn).source+"|"+(t.evaluate||xn).source+"|$","g");var l="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,i,f,l){return e||(e=i),a+=n.slice(c,l).replace(mn,W),r&&(u=true,a+="'+__e("+r+")+'"),f&&(o=true,a+="';"+f+";\n__p+='"),e&&(a+="'+((__t=("+e+"))==null?'':__t)+'"),c=l+t.length,t}),a+="';",(t=t.variable)||(a="with(obj){"+a+"}"),a=(o?a.replace(T,""):a).replace(K,"$1").replace(G,"$1;"),
|
||||
a="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+a+"return __p}",t=oi(function(){return Function(i,l+"return "+a).apply(Z,f)}),t.source=a,pe(t))throw t;return t},yn.times=function(n,t){if(n=Ie(n),1>n||n>9007199254740991)return[];var r=4294967295,e=Ru(n,4294967295);for(t=Mr(t),n-=4294967295,e=m(e,t);++r<n;)t(r);return e},yn.toInteger=Ie,yn.toLength=Re,yn.toLower=function(n){
|
||||
return Ce(n).toLowerCase()},yn.toNumber=Se,yn.toSafeInteger=function(n){return Xn(Ie(n),-9007199254740991,9007199254740991)},yn.toString=Ce,yn.toUpper=function(n){return Ce(n).toUpperCase()},yn.trim=function(n,t,r){return(n=Ce(n))?r||t===Z?n.replace(fn,""):(t+="")?(n=n.match(En),t=t.match(En),n.slice(O(n,t),E(n,t)+1).join("")):n:n},yn.trimEnd=function(n,t,r){return(n=Ce(n))?r||t===Z?n.replace(an,""):(t+="")?(n=n.match(En),n.slice(0,E(n,t.match(En))+1).join("")):n:n},yn.trimStart=function(n,t,r){return(n=Ce(n))?r||t===Z?n.replace(cn,""):(t+="")?(n=n.match(En),
|
||||
n.slice(O(n,t.match(En))).join("")):n:n},yn.truncate=function(n,t){var r=30,e="...";if(de(t))var u="separator"in t?t.separator:u,r="length"in t?Ie(t.length):r,e="omission"in t?Ce(t.omission):e;n=Ce(n);var o=n.length;if(kn.test(n))var i=n.match(En),o=i.length;if(r>=o)return n;if(o=r-M(e),1>o)return e;if(r=i?i.slice(0,o).join(""):n.slice(0,o),u===Z)return r+e;if(i&&(o+=r.length-o),je(u)){if(n.slice(o).search(u)){var f=r;for(u.global||(u=tu(u.source,Ce(hn.exec(u))+"g")),u.lastIndex=0;i=u.exec(f);)var c=i.index;
|
||||
r=r.slice(0,c===Z?o:c)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),u>-1&&(r=r.slice(0,u)));return r+e},yn.unescape=function(n){return(n=Ce(n))&&Y.test(n)?n.replace(V,N):n},yn.uniqueId=function(n){var t=++fu;return Ce(n)+t},yn.upperCase=ui,yn.upperFirst=ti,yn.each=Qr,yn.eachRight=Xr,yn.first=qr,Ve(yn,function(){var n={};return ct(yn,function(t,r){iu.call(yn.prototype,r)||(n[r]=t)}),n}(),{chain:false}),yn.VERSION="4.1.0",u("bind bindKey curry curryRight partial partialRight".split(" "),function(n){yn[n].placeholder=yn;
|
||||
}),u(["drop","take"],function(n,t){An.prototype[n]=function(r){var e=this.__filtered__;if(e&&!t)return new An(this);r=r===Z?1:Iu(Ie(r),0);var u=this.clone();return e?u.__takeCount__=Ru(r,u.__takeCount__):u.__views__.push({size:Ru(r,4294967295),type:n+(0>u.__dir__?"Right":"")}),u},An.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),u(["filter","map","takeWhile"],function(n,t){var r=t+1,e=1==r||3==r;An.prototype[n]=function(n){var t=this.clone();return t.__iteratees__.push({
|
||||
iteratee:mr(n,3),type:r}),t.__filtered__=t.__filtered__||e,t}}),u(["head","last"],function(n,t){var r="take"+(t?"Right":"");An.prototype[n]=function(){return this[r](1).value()[0]}}),u(["initial","tail"],function(n,t){var r="drop"+(t?"":"Right");An.prototype[n]=function(){return this.__filtered__?new An(this):this[r](1)}}),An.prototype.compact=function(){return this.filter(Te)},An.prototype.find=function(n){return this.filter(n).head()},An.prototype.findLast=function(n){return this.reverse().find(n);
|
||||
},An.prototype.invokeMap=fe(function(n,t){return typeof n=="function"?new An(this):this.map(function(r){return vt(r,n,t)})}),An.prototype.reject=function(n){return n=mr(n,3),this.filter(function(t){return!n(t)})},An.prototype.slice=function(n,t){n=Ie(n);var r=this;return r.__filtered__&&(n>0||0>t)?new An(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==Z&&(t=Ie(t),r=0>t?r.dropRight(-t):r.take(t-n)),r)},An.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},An.prototype.toArray=function(){
|
||||
return this.take(4294967295)},ct(An.prototype,function(n,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),e=/^(?:head|last)$/.test(t),u=yn[e?"take"+("last"==t?"Right":""):t],o=e||/^find/.test(t);u&&(yn.prototype[t]=function(){function t(n){return n=u.apply(yn,l([n],f)),e&&h?n[0]:n}var i=this.__wrapped__,f=e?[1]:arguments,c=i instanceof An,a=f[0],s=c||Lo(i);s&&r&&typeof a=="function"&&1!=a.length&&(c=s=false);var h=this.__chain__,p=!!this.__actions__.length,a=o&&!h,c=c&&!p;return!o&&s?(i=c?i:new An(this),
|
||||
i=n.apply(i,f),i.__actions__.push({func:Yr,args:[t],thisArg:Z}),new wn(i,h)):a&&c?n.apply(this,f):(i=this.thru(t),a?e?i.value()[0]:i.value():i)})}),u("pop push shift sort splice unshift".split(" "),function(n){var t=eu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|shift)$/.test(n);yn.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),ct(An.prototype,function(n,t){var r=yn[t];if(r){var e=r.name+"";(qu[e]||(qu[e]=[])).push({
|
||||
name:t,func:r})}}),qu[cr(Z,2).name]=[{name:"wrapper",func:Z}],An.prototype.clone=function(){var n=new An(this.__wrapped__);return n.__actions__=Vt(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=Vt(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=Vt(this.__views__),n},An.prototype.reverse=function(){if(this.__filtered__){var n=new An(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},An.prototype.value=function(){
|
||||
var n,t=this.__wrapped__.value(),r=this.__dir__,e=Lo(t),u=0>r,o=e?t.length:0;n=o;for(var i=this.__views__,f=0,c=-1,a=i.length;++c<a;){var l=i[c],s=l.size;switch(l.type){case"drop":f+=s;break;case"dropRight":n-=s;break;case"take":n=Ru(n,f+s);break;case"takeRight":f=Iu(f,n-s)}}if(n={start:f,end:n},i=n.start,f=n.end,n=f-i,u=u?f:i-1,i=this.__iteratees__,f=i.length,c=0,a=Ru(n,this.__takeCount__),!e||200>o||o==n&&a==n)return Zt(t,this.__actions__);e=[];n:for(;n--&&a>c;){for(u+=r,o=-1,l=t[u];++o<f;){var h=i[o],s=h.type,h=(0,
|
||||
h.iteratee)(l);if(2==s)l=h;else if(!h){if(1==s)continue n;break n}}e[c++]=l}return e},yn.prototype.at=xo,yn.prototype.chain=function(){return Jr(this)},yn.prototype.commit=function(){return new wn(this.value(),this.__chain__)},yn.prototype.flatMap=function(n){return this.map(n).flatten()},yn.prototype.next=function(){this.__values__===Z&&(this.__values__=ke(this.value()));var n=this.__index__>=this.__values__.length,t=n?Z:this.__values__[this.__index__++];return{done:n,value:t}},yn.prototype.plant=function(n){
|
||||
for(var t,r=this;r instanceof jn;){var e=Nr(r);e.__index__=0,e.__values__=Z,t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},yn.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof An?(this.__actions__.length&&(n=new An(this)),n=n.reverse(),n.__actions__.push({func:Yr,args:[Kr],thisArg:Z}),new wn(n,this.__chain__)):this.thru(Kr)},yn.prototype.toJSON=yn.prototype.valueOf=yn.prototype.value=function(){return Zt(this.__wrapped__,this.__actions__)},bu&&(yn.prototype[bu]=Hr),
|
||||
yn}var Z,q=1/0,P=NaN,T=/\b__p\+='';/g,K=/\b(__p\+=)''\+/g,G=/(__e\(.*?\)|\b__t\))\+'';/g,V=/&(?:amp|lt|gt|quot|#39|#96);/g,J=/[&<>"'`]/g,Y=RegExp(V.source),H=RegExp(J.source),Q=/<%-([\s\S]+?)%>/g,X=/<%([\s\S]+?)%>/g,nn=/<%=([\s\S]+?)%>/g,tn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,rn=/^\w*$/,en=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]/g,un=/[\\^$.*+?()[\]{}|]/g,on=RegExp(un.source),fn=/^\s+|\s+$/g,cn=/^\s+/,an=/\s+$/,ln=/\\(\\)?/g,sn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,hn=/\w*$/,pn=/^0x/i,_n=/^[-+]0x[0-9a-f]+$/i,gn=/^0b[01]+$/i,vn=/^\[object .+?Constructor\]$/,dn=/^0o[0-7]+$/i,yn=/^(?:0|[1-9]\d*)$/,bn=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,xn=/($^)/,mn=/['\n\r\u2028\u2029\\]/g,jn="[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|\\ud83c[\\udffb-\\udfff])?(?:\\u200d(?:[^\\ud800-\\udfff]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|\\ud83c[\\udffb-\\udfff])?)*",wn="(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])"+jn,An="(?:[^\\ud800-\\udfff][\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]?|[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\ud800-\\udfff])",On=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]","g"),En=RegExp("\\ud83c[\\udffb-\\udfff](?=\\ud83c[\\udffb-\\udfff])|"+An+jn,"g"),kn=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0\\ufe0e\\ufe0f]"),In=/[a-zA-Z0-9]+/g,Rn=RegExp(["[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000]|[A-Z\\xc0-\\xd6\\xd8-\\xde]|$)|(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000]|[A-Z\\xc0-\\xd6\\xd8-\\xde](?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])|$)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?(?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2018\\u2019\\u201c\\u201d \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|\\d+",wn].join("|"),"g"),Sn=/[a-z][A-Z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Wn="Array Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Map Math Object Reflect RegExp Set String Symbol TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap _ clearTimeout isFinite parseInt setTimeout".split(" "),Cn={};
|
||||
Cn["[object Float32Array]"]=Cn["[object Float64Array]"]=Cn["[object Int8Array]"]=Cn["[object Int16Array]"]=Cn["[object Int32Array]"]=Cn["[object Uint8Array]"]=Cn["[object Uint8ClampedArray]"]=Cn["[object Uint16Array]"]=Cn["[object Uint32Array]"]=true,Cn["[object Arguments]"]=Cn["[object Array]"]=Cn["[object ArrayBuffer]"]=Cn["[object Boolean]"]=Cn["[object Date]"]=Cn["[object Error]"]=Cn["[object Function]"]=Cn["[object Map]"]=Cn["[object Number]"]=Cn["[object Object]"]=Cn["[object RegExp]"]=Cn["[object Set]"]=Cn["[object String]"]=Cn["[object WeakMap]"]=false;
|
||||
var Un={};Un["[object Arguments]"]=Un["[object Array]"]=Un["[object ArrayBuffer]"]=Un["[object Boolean]"]=Un["[object Date]"]=Un["[object Float32Array]"]=Un["[object Float64Array]"]=Un["[object Int8Array]"]=Un["[object Int16Array]"]=Un["[object Int32Array]"]=Un["[object Map]"]=Un["[object Number]"]=Un["[object Object]"]=Un["[object RegExp]"]=Un["[object Set]"]=Un["[object String]"]=Un["[object Symbol]"]=Un["[object Uint8Array]"]=Un["[object Uint8ClampedArray]"]=Un["[object Uint16Array]"]=Un["[object Uint32Array]"]=true,
|
||||
Un["[object Error]"]=Un["[object Function]"]=Un["[object WeakMap]"]=false;var Bn={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O",
|
||||
"\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},zn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ln={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},$n={"function":true,object:true},Fn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"
|
||||
},Mn=parseFloat,Nn=parseInt,Dn=$n[typeof exports]&&exports&&!exports.nodeType?exports:null,Zn=$n[typeof module]&&module&&!module.nodeType?module:null,qn=k($n[typeof self]&&self),Pn=k($n[typeof window]&&window),Tn=Zn&&Zn.exports===Dn?Dn:null,Kn=k($n[typeof this]&&this),Gn=k(Dn&&Zn&&typeof global=="object"&&global)||Pn!==(Kn&&Kn.window)&&Pn||qn||Kn||Function("return this")(),Vn=D();(Pn||qn||{})._=Vn,typeof define=="function"&&typeof define.amd=="object"&&define.amd? define(function(){return Vn}):Dn&&Zn?(Tn&&((Zn.exports=Vn)._=Vn),
|
||||
Dn._=Vn):Gn._=Vn}).call(this);
|
||||
282
dist/mapping.fp.js
vendored
Normal file
282
dist/mapping.fp.js
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
(function webpackUniversalModuleDefinition(root, factory) {
|
||||
if(typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = factory();
|
||||
else if(typeof define === 'function' && define.amd)
|
||||
define([], factory);
|
||||
else if(typeof exports === 'object')
|
||||
exports["mapping"] = factory();
|
||||
else
|
||||
root["mapping"] = factory();
|
||||
})(this, function() {
|
||||
return /******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId])
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ exports: {},
|
||||
/******/ id: moduleId,
|
||||
/******/ loaded: false
|
||||
/******/ };
|
||||
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.loaded = true;
|
||||
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
|
||||
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(0);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ function(module, exports) {
|
||||
|
||||
/** Used to map aliases to their real names. */
|
||||
exports.aliasToReal = {
|
||||
'all': 'some',
|
||||
'allPass': 'overEvery',
|
||||
'apply': 'spread',
|
||||
'compose': 'flowRight',
|
||||
'contains': 'includes',
|
||||
'dissoc': 'omit',
|
||||
'each': 'forEach',
|
||||
'eachRight': 'forEachRight',
|
||||
'equals': 'isEqual',
|
||||
'extend': 'assignIn',
|
||||
'extendWith': 'assignInWith',
|
||||
'first': 'head',
|
||||
'init': 'initial',
|
||||
'mapObj': 'mapValues',
|
||||
'omitAll': 'omit',
|
||||
'nAry': 'ary',
|
||||
'path': 'get',
|
||||
'pathEq': 'matchesProperty',
|
||||
'pathOr': 'getOr',
|
||||
'pickAll': 'pick',
|
||||
'pipe': 'flow',
|
||||
'prop': 'get',
|
||||
'propOf': 'propertyOf',
|
||||
'propOr': 'getOr',
|
||||
'somePass': 'overSome',
|
||||
'unapply': 'rest',
|
||||
'unnest': 'flatten',
|
||||
'useWith': 'overArgs',
|
||||
'whereEq': 'filter',
|
||||
'zipObj': 'zipObject'
|
||||
};
|
||||
|
||||
/** Used to map method names to their iteratee ary. */
|
||||
exports.aryIteratee = {
|
||||
'assignWith': 2,
|
||||
'assignInWith': 2,
|
||||
'cloneDeepWith': 1,
|
||||
'cloneWith': 1,
|
||||
'dropRightWhile': 1,
|
||||
'dropWhile': 1,
|
||||
'every': 1,
|
||||
'filter': 1,
|
||||
'find': 1,
|
||||
'findIndex': 1,
|
||||
'findKey': 1,
|
||||
'findLast': 1,
|
||||
'findLastIndex': 1,
|
||||
'findLastKey': 1,
|
||||
'flatMap': 1,
|
||||
'forEach': 1,
|
||||
'forEachRight': 1,
|
||||
'forIn': 1,
|
||||
'forInRight': 1,
|
||||
'forOwn': 1,
|
||||
'forOwnRight': 1,
|
||||
'isEqualWith': 2,
|
||||
'isMatchWith': 2,
|
||||
'map': 1,
|
||||
'mapKeys': 1,
|
||||
'mapValues': 1,
|
||||
'partition': 1,
|
||||
'reduce': 2,
|
||||
'reduceRight': 2,
|
||||
'reject': 1,
|
||||
'remove': 1,
|
||||
'some': 1,
|
||||
'takeRightWhile': 1,
|
||||
'takeWhile': 1,
|
||||
'times': 1,
|
||||
'transform': 2
|
||||
};
|
||||
|
||||
/** Used to map ary to method names. */
|
||||
exports.aryMethod = {
|
||||
1: [
|
||||
'attempt', 'ceil', 'create', 'curry', 'curryRight', 'floor', 'fromPairs',
|
||||
'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin', 'over',
|
||||
'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext',
|
||||
'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words'
|
||||
],
|
||||
2: [
|
||||
'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindKey',
|
||||
'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN',
|
||||
'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference',
|
||||
'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every',
|
||||
'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
|
||||
'findLastKey', 'flatMap', 'forEach', 'forEachRight', 'forIn', 'forInRight',
|
||||
'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has', 'hasIn',
|
||||
'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap',
|
||||
'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map',
|
||||
'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy', 'omit',
|
||||
'omitBy', 'orderBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt',
|
||||
'partition', 'pick', 'pickBy', 'pull', 'pullAll', 'pullAt', 'random', 'range',
|
||||
'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'result', 'sampleSize',
|
||||
'some', 'sortBy', 'sortedIndex', 'sortedIndexOf', 'sortedLastIndex',
|
||||
'sortedLastIndexOf', 'sortedUniqBy', 'split', 'startsWith', 'subtract',
|
||||
'sumBy', 'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', 'throttle',
|
||||
'thru', 'times', 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset', 'unzipWith',
|
||||
'without', 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep'
|
||||
],
|
||||
3: [
|
||||
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
|
||||
'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith',
|
||||
'isMatchWith', 'mergeWith', 'pullAllBy', 'reduce', 'reduceRight', 'replace',
|
||||
'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy',
|
||||
'unionWith', 'xorBy', 'xorWith', 'zipWith'
|
||||
],
|
||||
4: [
|
||||
'fill', 'setWith'
|
||||
]
|
||||
};
|
||||
|
||||
/** Used to map ary to rearg configs. */
|
||||
exports.aryRearg = {
|
||||
2: [1, 0],
|
||||
3: [2, 1, 0],
|
||||
4: [3, 2, 0, 1]
|
||||
};
|
||||
|
||||
/** Used to map method names to iteratee rearg configs. */
|
||||
exports.iterateeRearg = {
|
||||
'findKey': [1],
|
||||
'findLastKey': [1],
|
||||
'mapKeys': [1]
|
||||
};
|
||||
|
||||
/** Used to map method names to rearg configs. */
|
||||
exports.methodRearg = {
|
||||
'assignInWith': [1, 2, 0],
|
||||
'assignWith': [1, 2, 0],
|
||||
'clamp': [2, 0, 1],
|
||||
'mergeWith': [1, 2, 0],
|
||||
'reduce': [2, 0, 1],
|
||||
'reduceRight': [2, 0, 1],
|
||||
'set': [2, 0, 1],
|
||||
'setWith': [3, 1, 2, 0],
|
||||
'slice': [2, 0, 1],
|
||||
'transform': [2, 0, 1]
|
||||
};
|
||||
|
||||
/** Used to iterate `mapping.aryMethod` keys. */
|
||||
exports.caps = [1, 2, 3, 4];
|
||||
|
||||
/** Used to map keys to other keys. */
|
||||
exports.key = {
|
||||
'curryN': 'curry',
|
||||
'curryRightN': 'curryRight',
|
||||
'getOr': 'get'
|
||||
};
|
||||
|
||||
/** Used to identify methods which mutate arrays or objects. */
|
||||
exports.mutate = {
|
||||
'array': {
|
||||
'fill': true,
|
||||
'pull': true,
|
||||
'pullAll': true,
|
||||
'pullAllBy': true,
|
||||
'pullAt': true,
|
||||
'remove': true,
|
||||
'reverse': true
|
||||
},
|
||||
'object': {
|
||||
'assign': true,
|
||||
'assignIn': true,
|
||||
'assignInWith': true,
|
||||
'assignWith': true,
|
||||
'defaults': true,
|
||||
'defaultsDeep': true,
|
||||
'merge': true,
|
||||
'mergeWith': true
|
||||
},
|
||||
'set': {
|
||||
'set': true,
|
||||
'setWith': true
|
||||
}
|
||||
};
|
||||
|
||||
/** Used to track methods with placeholder support */
|
||||
exports.placeholder = {
|
||||
'bind': true,
|
||||
'bindKey': true,
|
||||
'curry': true,
|
||||
'curryRight': true,
|
||||
'partial': true,
|
||||
'partialRight': true
|
||||
};
|
||||
|
||||
/** Used to map real names to their aliases. */
|
||||
exports.realToAlias = (function() {
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
object = exports.aliasToReal,
|
||||
result = {};
|
||||
|
||||
for (var key in object) {
|
||||
var value = object[key];
|
||||
if (hasOwnProperty.call(result, value)) {
|
||||
result[value].push(key);
|
||||
} else {
|
||||
result[value] = [key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}());
|
||||
|
||||
/** Used to track methods that skip `_.rearg`. */
|
||||
exports.skipRearg = {
|
||||
'assign': true,
|
||||
'assignIn': true,
|
||||
'concat': true,
|
||||
'difference': true,
|
||||
'matchesProperty': true,
|
||||
'merge': true,
|
||||
'random': true,
|
||||
'range': true,
|
||||
'rangeRight': true,
|
||||
'zip': true,
|
||||
'zipObject': true
|
||||
};
|
||||
|
||||
|
||||
/***/ }
|
||||
/******/ ])
|
||||
});
|
||||
;
|
||||
6957
doc/README.md
6957
doc/README.md
File diff suppressed because it is too large
Load Diff
227
fp/_baseConvert.js
Normal file
227
fp/_baseConvert.js
Normal file
@@ -0,0 +1,227 @@
|
||||
var mapping = require('./_mapping'),
|
||||
mutateMap = mapping.mutate,
|
||||
placeholder = {};
|
||||
|
||||
/**
|
||||
* The base implementation of `convert` which accepts a `util` object of methods
|
||||
* required to perform conversions.
|
||||
*
|
||||
* @param {Object} util The util object.
|
||||
* @param {string} name The name of the function to wrap.
|
||||
* @param {Function} func The function to wrap.
|
||||
* @returns {Function|Object} Returns the converted function or object.
|
||||
*/
|
||||
function baseConvert(util, name, func) {
|
||||
if (typeof func != 'function') {
|
||||
func = name;
|
||||
name = undefined;
|
||||
}
|
||||
if (func == null) {
|
||||
throw new TypeError;
|
||||
}
|
||||
var isLib = name === undefined && typeof func.VERSION == 'string';
|
||||
|
||||
var _ = isLib ? func : {
|
||||
'ary': util.ary,
|
||||
'cloneDeep': util.cloneDeep,
|
||||
'curry': util.curry,
|
||||
'forEach': util.forEach,
|
||||
'isFunction': util.isFunction,
|
||||
'iteratee': util.iteratee,
|
||||
'keys': util.keys,
|
||||
'rearg': util.rearg
|
||||
};
|
||||
|
||||
var ary = _.ary,
|
||||
cloneDeep = _.cloneDeep,
|
||||
curry = _.curry,
|
||||
each = _.forEach,
|
||||
isFunction = _.isFunction,
|
||||
keys = _.keys,
|
||||
rearg = _.rearg;
|
||||
|
||||
var baseArity = function(func, n) {
|
||||
return n == 2
|
||||
? function(a, b) { return func.apply(undefined, arguments); }
|
||||
: function(a) { return func.apply(undefined, arguments); };
|
||||
};
|
||||
|
||||
var baseAry = function(func, n) {
|
||||
return n == 2
|
||||
? function(a, b) { return func(a, b); }
|
||||
: function(a) { return func(a); };
|
||||
};
|
||||
|
||||
var cloneArray = function(array) {
|
||||
var length = array ? array.length : 0,
|
||||
result = Array(length);
|
||||
|
||||
while (length--) {
|
||||
result[length] = array[length];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var createCloner = function(func) {
|
||||
return function(object) {
|
||||
return func({}, object);
|
||||
};
|
||||
};
|
||||
|
||||
var immutWrap = function(func, cloner) {
|
||||
return overArg(func, cloner, true);
|
||||
};
|
||||
|
||||
var iterateeAry = function(func, n) {
|
||||
return overArg(func, function(func) {
|
||||
return baseAry(func, n);
|
||||
});
|
||||
};
|
||||
|
||||
var iterateeRearg = function(func, indexes) {
|
||||
return overArg(func, function(func) {
|
||||
var n = indexes.length;
|
||||
return baseArity(rearg(baseAry(func, n), indexes), n);
|
||||
});
|
||||
};
|
||||
|
||||
var overArg = function(func, iteratee, retArg) {
|
||||
return function() {
|
||||
var length = arguments.length,
|
||||
args = Array(length);
|
||||
|
||||
while (length--) {
|
||||
args[length] = arguments[length];
|
||||
}
|
||||
args[0] = iteratee(args[0]);
|
||||
var result = func.apply(undefined, args);
|
||||
return retArg ? args[0] : result;
|
||||
};
|
||||
};
|
||||
|
||||
var wrappers = {
|
||||
'iteratee': function(iteratee) {
|
||||
return function() {
|
||||
var func = arguments[0],
|
||||
arity = arguments[1];
|
||||
|
||||
arity = arity > 2 ? (arity - 2) : 1;
|
||||
func = iteratee(func);
|
||||
var length = func.length;
|
||||
return (length && length <= arity) ? func : baseAry(func, arity);
|
||||
};
|
||||
},
|
||||
'mixin': function(mixin) {
|
||||
return function(source) {
|
||||
var func = this;
|
||||
if (!isFunction(func)) {
|
||||
return mixin(func, Object(source));
|
||||
}
|
||||
var methods = [],
|
||||
methodNames = [];
|
||||
|
||||
each(keys(source), function(key) {
|
||||
var value = source[key];
|
||||
if (isFunction(value)) {
|
||||
methodNames.push(key);
|
||||
methods.push(func.prototype[key]);
|
||||
}
|
||||
});
|
||||
|
||||
mixin(func, Object(source));
|
||||
|
||||
each(methodNames, function(methodName, index) {
|
||||
var method = methods[index];
|
||||
if (isFunction(method)) {
|
||||
func.prototype[methodName] = method;
|
||||
} else {
|
||||
delete func.prototype[methodName];
|
||||
}
|
||||
});
|
||||
return func;
|
||||
};
|
||||
},
|
||||
'runInContext': function(runInContext) {
|
||||
return function(context) {
|
||||
return baseConvert(util, runInContext(context));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var wrap = function(name, func) {
|
||||
name = mapping.aliasToReal[name] || name;
|
||||
var wrapper = wrappers[name];
|
||||
if (wrapper) {
|
||||
return wrapper(func);
|
||||
}
|
||||
if (mutateMap.array[name]) {
|
||||
func = immutWrap(func, cloneArray);
|
||||
}
|
||||
else if (mutateMap.object[name]) {
|
||||
func = immutWrap(func, createCloner(func));
|
||||
}
|
||||
else if (mutateMap.set[name]) {
|
||||
func = immutWrap(func, cloneDeep);
|
||||
}
|
||||
var result;
|
||||
each(mapping.caps, function(cap) {
|
||||
each(mapping.aryMethod[cap], function(otherName) {
|
||||
if (name == otherName) {
|
||||
var indexes = mapping.iterateeRearg[name],
|
||||
n = !isLib && mapping.aryIteratee[name];
|
||||
|
||||
result = ary(func, cap);
|
||||
if (cap > 1 && !mapping.skipRearg[name]) {
|
||||
result = rearg(result, mapping.methodRearg[name] || mapping.aryRearg[cap]);
|
||||
}
|
||||
if (indexes) {
|
||||
result = iterateeRearg(result, indexes);
|
||||
} else if (n) {
|
||||
result = iterateeAry(result, n);
|
||||
}
|
||||
if (cap > 1) {
|
||||
result = curry(result, cap);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return !result;
|
||||
});
|
||||
|
||||
result || (result = func);
|
||||
if (mapping.placeholder[name]) {
|
||||
result.placeholder = placeholder;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
if (!isLib) {
|
||||
return wrap(name, func);
|
||||
}
|
||||
// Iterate over methods for the current ary cap.
|
||||
var pairs = [];
|
||||
each(mapping.caps, function(cap) {
|
||||
each(mapping.aryMethod[cap], function(key) {
|
||||
var func = _[mapping.key[key] || key];
|
||||
if (func) {
|
||||
pairs.push([key, wrap(key, func)]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Assign to `_` leaving `_.prototype` unchanged to allow chaining.
|
||||
each(pairs, function(pair) {
|
||||
_[pair[0]] = pair[1];
|
||||
});
|
||||
|
||||
// Wrap the lodash method and its aliases.
|
||||
each(keys(_), function(key) {
|
||||
each(mapping.realToAlias[key] || [], function(alias) {
|
||||
_[alias] = _[key];
|
||||
});
|
||||
});
|
||||
|
||||
return _;
|
||||
}
|
||||
|
||||
module.exports = baseConvert;
|
||||
13
fp/_convertBrowser.js
Normal file
13
fp/_convertBrowser.js
Normal file
@@ -0,0 +1,13 @@
|
||||
var baseConvert = require('./_baseConvert');
|
||||
|
||||
/**
|
||||
* Converts `lodash` to an immutable auto-curried iteratee-first data-last version.
|
||||
*
|
||||
* @param {Function} lodash The lodash function.
|
||||
* @returns {Function} Returns the converted `lodash`.
|
||||
*/
|
||||
function browserConvert(lodash) {
|
||||
return baseConvert(lodash, lodash);
|
||||
}
|
||||
|
||||
module.exports = browserConvert;
|
||||
220
fp/_mapping.js
Normal file
220
fp/_mapping.js
Normal file
@@ -0,0 +1,220 @@
|
||||
/** Used to map aliases to their real names. */
|
||||
exports.aliasToReal = {
|
||||
'all': 'some',
|
||||
'allPass': 'overEvery',
|
||||
'apply': 'spread',
|
||||
'compose': 'flowRight',
|
||||
'contains': 'includes',
|
||||
'dissoc': 'omit',
|
||||
'each': 'forEach',
|
||||
'eachRight': 'forEachRight',
|
||||
'equals': 'isEqual',
|
||||
'extend': 'assignIn',
|
||||
'extendWith': 'assignInWith',
|
||||
'first': 'head',
|
||||
'init': 'initial',
|
||||
'mapObj': 'mapValues',
|
||||
'omitAll': 'omit',
|
||||
'nAry': 'ary',
|
||||
'path': 'get',
|
||||
'pathEq': 'matchesProperty',
|
||||
'pathOr': 'getOr',
|
||||
'pickAll': 'pick',
|
||||
'pipe': 'flow',
|
||||
'prop': 'get',
|
||||
'propOf': 'propertyOf',
|
||||
'propOr': 'getOr',
|
||||
'somePass': 'overSome',
|
||||
'unapply': 'rest',
|
||||
'unnest': 'flatten',
|
||||
'useWith': 'overArgs',
|
||||
'whereEq': 'filter',
|
||||
'zipObj': 'zipObject'
|
||||
};
|
||||
|
||||
/** Used to map method names to their iteratee ary. */
|
||||
exports.aryIteratee = {
|
||||
'assignWith': 2,
|
||||
'assignInWith': 2,
|
||||
'cloneDeepWith': 1,
|
||||
'cloneWith': 1,
|
||||
'dropRightWhile': 1,
|
||||
'dropWhile': 1,
|
||||
'every': 1,
|
||||
'filter': 1,
|
||||
'find': 1,
|
||||
'findIndex': 1,
|
||||
'findKey': 1,
|
||||
'findLast': 1,
|
||||
'findLastIndex': 1,
|
||||
'findLastKey': 1,
|
||||
'flatMap': 1,
|
||||
'forEach': 1,
|
||||
'forEachRight': 1,
|
||||
'forIn': 1,
|
||||
'forInRight': 1,
|
||||
'forOwn': 1,
|
||||
'forOwnRight': 1,
|
||||
'isEqualWith': 2,
|
||||
'isMatchWith': 2,
|
||||
'map': 1,
|
||||
'mapKeys': 1,
|
||||
'mapValues': 1,
|
||||
'partition': 1,
|
||||
'reduce': 2,
|
||||
'reduceRight': 2,
|
||||
'reject': 1,
|
||||
'remove': 1,
|
||||
'some': 1,
|
||||
'takeRightWhile': 1,
|
||||
'takeWhile': 1,
|
||||
'times': 1,
|
||||
'transform': 2
|
||||
};
|
||||
|
||||
/** Used to map ary to method names. */
|
||||
exports.aryMethod = {
|
||||
1: [
|
||||
'attempt', 'ceil', 'create', 'curry', 'curryRight', 'floor', 'fromPairs',
|
||||
'invert', 'iteratee', 'memoize', 'method', 'methodOf', 'mixin', 'over',
|
||||
'overEvery', 'overSome', 'rest', 'reverse', 'round', 'runInContext',
|
||||
'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words'
|
||||
],
|
||||
2: [
|
||||
'add', 'after', 'ary', 'assign', 'assignIn', 'at', 'before', 'bind', 'bindKey',
|
||||
'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'countBy', 'curryN',
|
||||
'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'delay', 'difference',
|
||||
'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every',
|
||||
'filter', 'find', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex',
|
||||
'findLastKey', 'flatMap', 'forEach', 'forEachRight', 'forIn', 'forInRight',
|
||||
'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has', 'hasIn',
|
||||
'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap',
|
||||
'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map',
|
||||
'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'merge', 'minBy', 'omit',
|
||||
'omitBy', 'orderBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt',
|
||||
'partition', 'pick', 'pickBy', 'pull', 'pullAll', 'pullAt', 'random', 'range',
|
||||
'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'result', 'sampleSize',
|
||||
'some', 'sortBy', 'sortedIndex', 'sortedIndexOf', 'sortedLastIndex',
|
||||
'sortedLastIndexOf', 'sortedUniqBy', 'split', 'startsWith', 'subtract',
|
||||
'sumBy', 'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', 'throttle',
|
||||
'thru', 'times', 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset', 'unzipWith',
|
||||
'without', 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep'
|
||||
],
|
||||
3: [
|
||||
'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith',
|
||||
'getOr', 'inRange', 'intersectionBy', 'intersectionWith', 'isEqualWith',
|
||||
'isMatchWith', 'mergeWith', 'pullAllBy', 'reduce', 'reduceRight', 'replace',
|
||||
'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy',
|
||||
'unionWith', 'xorBy', 'xorWith', 'zipWith'
|
||||
],
|
||||
4: [
|
||||
'fill', 'setWith'
|
||||
]
|
||||
};
|
||||
|
||||
/** Used to map ary to rearg configs. */
|
||||
exports.aryRearg = {
|
||||
2: [1, 0],
|
||||
3: [2, 1, 0],
|
||||
4: [3, 2, 0, 1]
|
||||
};
|
||||
|
||||
/** Used to map method names to iteratee rearg configs. */
|
||||
exports.iterateeRearg = {
|
||||
'findKey': [1],
|
||||
'findLastKey': [1],
|
||||
'mapKeys': [1]
|
||||
};
|
||||
|
||||
/** Used to map method names to rearg configs. */
|
||||
exports.methodRearg = {
|
||||
'assignInWith': [1, 2, 0],
|
||||
'assignWith': [1, 2, 0],
|
||||
'clamp': [2, 0, 1],
|
||||
'mergeWith': [1, 2, 0],
|
||||
'reduce': [2, 0, 1],
|
||||
'reduceRight': [2, 0, 1],
|
||||
'set': [2, 0, 1],
|
||||
'setWith': [3, 1, 2, 0],
|
||||
'slice': [2, 0, 1],
|
||||
'transform': [2, 0, 1]
|
||||
};
|
||||
|
||||
/** Used to iterate `mapping.aryMethod` keys. */
|
||||
exports.caps = [1, 2, 3, 4];
|
||||
|
||||
/** Used to map keys to other keys. */
|
||||
exports.key = {
|
||||
'curryN': 'curry',
|
||||
'curryRightN': 'curryRight',
|
||||
'getOr': 'get'
|
||||
};
|
||||
|
||||
/** Used to identify methods which mutate arrays or objects. */
|
||||
exports.mutate = {
|
||||
'array': {
|
||||
'fill': true,
|
||||
'pull': true,
|
||||
'pullAll': true,
|
||||
'pullAllBy': true,
|
||||
'pullAt': true,
|
||||
'remove': true,
|
||||
'reverse': true
|
||||
},
|
||||
'object': {
|
||||
'assign': true,
|
||||
'assignIn': true,
|
||||
'assignInWith': true,
|
||||
'assignWith': true,
|
||||
'defaults': true,
|
||||
'defaultsDeep': true,
|
||||
'merge': true,
|
||||
'mergeWith': true
|
||||
},
|
||||
'set': {
|
||||
'set': true,
|
||||
'setWith': true
|
||||
}
|
||||
};
|
||||
|
||||
/** Used to track methods with placeholder support */
|
||||
exports.placeholder = {
|
||||
'bind': true,
|
||||
'bindKey': true,
|
||||
'curry': true,
|
||||
'curryRight': true,
|
||||
'partial': true,
|
||||
'partialRight': true
|
||||
};
|
||||
|
||||
/** Used to map real names to their aliases. */
|
||||
exports.realToAlias = (function() {
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
object = exports.aliasToReal,
|
||||
result = {};
|
||||
|
||||
for (var key in object) {
|
||||
var value = object[key];
|
||||
if (hasOwnProperty.call(result, value)) {
|
||||
result[value].push(key);
|
||||
} else {
|
||||
result[value] = [key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}());
|
||||
|
||||
/** Used to track methods that skip `_.rearg`. */
|
||||
exports.skipRearg = {
|
||||
'assign': true,
|
||||
'assignIn': true,
|
||||
'concat': true,
|
||||
'difference': true,
|
||||
'matchesProperty': true,
|
||||
'merge': true,
|
||||
'random': true,
|
||||
'range': true,
|
||||
'rangeRight': true,
|
||||
'zip': true,
|
||||
'zipObject': true
|
||||
};
|
||||
26
lib/common/minify.js
Normal file
26
lib/common/minify.js
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash'),
|
||||
fs = require('fs-extra'),
|
||||
uglify = require('uglify-js');
|
||||
|
||||
var uglifyOptions = require('./uglify.options.js');
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
function minify(inpath, outpath, callback, options) {
|
||||
if (_.isFunction(outpath)) {
|
||||
if (_.isObject(callback)) {
|
||||
options = callback;
|
||||
}
|
||||
callback = outpath;
|
||||
outpath = undefined;
|
||||
}
|
||||
if (!outpath) {
|
||||
outpath = inpath.replace(/(?=\.js$)/, '.min');
|
||||
}
|
||||
var output = uglify.minify(inpath, _.defaults(options || {}, uglifyOptions));
|
||||
fs.writeFile(outpath, output.code, 'utf-8', callback);
|
||||
}
|
||||
|
||||
module.exports = minify;
|
||||
16
lib/common/uglify.options.js
Normal file
16
lib/common/uglify.options.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = {
|
||||
'compress': {
|
||||
'pure_getters': true,
|
||||
'unsafe': true,
|
||||
'unsafe_comps': true,
|
||||
'warnings': false
|
||||
},
|
||||
'mangle': {
|
||||
'except': ['define']
|
||||
},
|
||||
'output': {
|
||||
'ascii_only': true,
|
||||
'comments': /^!|@cc_on|@license|@preserve/i,
|
||||
'max_line_len': 500
|
||||
}
|
||||
};
|
||||
55
lib/doc/build.js
Normal file
55
lib/doc/build.js
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash'),
|
||||
docdown = require('docdown'),
|
||||
fs = require('fs-extra'),
|
||||
path = require('path');
|
||||
|
||||
var basePath = path.join(__dirname, '..', '..'),
|
||||
docPath = path.join(basePath, 'doc'),
|
||||
readmePath = path.join(docPath, 'README.md');
|
||||
|
||||
var pkg = require('../../package.json'),
|
||||
version = pkg.version;
|
||||
|
||||
var config = {
|
||||
'base': {
|
||||
'entryLinks': [
|
||||
'<% if (name == "templateSettings" || !/^(?:methods|properties|seq)$/i.test(category)) {' +
|
||||
'print("[Ⓝ](https://www.npmjs.com/package/lodash." + name.toLowerCase() + " \\"See the npm package\\")")' +
|
||||
'} %>'
|
||||
],
|
||||
'path': path.join(basePath, 'lodash.js'),
|
||||
'title': '<a href="https://lodash.com/">lodash</a> <span>v' + version + '</span>',
|
||||
'toc': 'categories',
|
||||
'url': 'https://github.com/lodash/lodash/blob/' + version + '/lodash.js'
|
||||
},
|
||||
'github': {
|
||||
'hash': 'github'
|
||||
},
|
||||
'site': {
|
||||
'tocLink': '#docs'
|
||||
}
|
||||
};
|
||||
|
||||
function postprocess(string) {
|
||||
// Fix docdown bug by wrapping symbol property identifiers in brackets.
|
||||
return string.replace(/\.(Symbol\.(?:[a-z]+[A-Z]?)+)/g, '[$1]');
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
function onComplete(error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function build(type) {
|
||||
var options = _.defaults({}, config.base, config[type]),
|
||||
markdown = docdown(options);
|
||||
|
||||
fs.writeFile(readmePath, postprocess(markdown), onComplete);
|
||||
}
|
||||
|
||||
build(_.last(process.argv));
|
||||
55
lib/fp/build-dist.js
Normal file
55
lib/fp/build-dist.js
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash'),
|
||||
async = require('async'),
|
||||
path = require('path'),
|
||||
webpack = require('webpack');
|
||||
|
||||
var minify = require('../common/minify.js');
|
||||
|
||||
var basePath = path.join(__dirname, '..', '..'),
|
||||
distPath = path.join(basePath, 'dist'),
|
||||
fpPath = path.join(basePath, 'fp'),
|
||||
filename = 'lodash.fp.js';
|
||||
|
||||
var fpConfig = {
|
||||
'entry': path.join(fpPath, '_convertBrowser.js'),
|
||||
'output': {
|
||||
'path': distPath,
|
||||
'filename': filename,
|
||||
'library': 'fp',
|
||||
'libraryTarget': 'umd'
|
||||
},
|
||||
'plugins': [
|
||||
new webpack.optimize.OccurenceOrderPlugin,
|
||||
new webpack.optimize.DedupePlugin
|
||||
]
|
||||
};
|
||||
|
||||
var mappingConfig = {
|
||||
'entry': path.join(fpPath, '_mapping.js'),
|
||||
'output': {
|
||||
'path': distPath,
|
||||
'filename': 'mapping.fp.js',
|
||||
'library': 'mapping',
|
||||
'libraryTarget': 'umd'
|
||||
}
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
function onComplete(error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function build() {
|
||||
async.series([
|
||||
_.partial(webpack, mappingConfig),
|
||||
_.partial(webpack, fpConfig),
|
||||
_.partial(minify, path.join(distPath, filename))
|
||||
], onComplete);
|
||||
}
|
||||
|
||||
build();
|
||||
115
lib/fp/build-modules.js
Normal file
115
lib/fp/build-modules.js
Normal file
@@ -0,0 +1,115 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash'),
|
||||
async = require('async'),
|
||||
fs = require('fs-extra'),
|
||||
glob = require('glob'),
|
||||
path = require('path');
|
||||
|
||||
var mapping = require('../../fp/_mapping');
|
||||
|
||||
var templatePath = path.join(__dirname, 'template');
|
||||
|
||||
var template = _.transform(glob.sync(path.join(templatePath, '*.jst')), function(result, filePath) {
|
||||
result[path.basename(filePath, '.jst')] = _.template(fs.readFileSync(filePath));
|
||||
}, {});
|
||||
|
||||
var aryMethods = _.union(
|
||||
mapping.aryMethod[1],
|
||||
mapping.aryMethod[2],
|
||||
mapping.aryMethod[3],
|
||||
mapping.aryMethod[4]
|
||||
);
|
||||
|
||||
var categories = [
|
||||
'array',
|
||||
'collection',
|
||||
'date',
|
||||
'function',
|
||||
'lang',
|
||||
'math',
|
||||
'number',
|
||||
'object',
|
||||
'seq',
|
||||
'string',
|
||||
'util'
|
||||
];
|
||||
|
||||
function isAlias(funcName) {
|
||||
return _.has(mapping.aliasToReal, funcName);
|
||||
}
|
||||
|
||||
function isCategory(funcName) {
|
||||
return _.includes(categories, funcName);
|
||||
}
|
||||
|
||||
function isThru(funcName) {
|
||||
return !_.includes(aryMethods, funcName);
|
||||
}
|
||||
|
||||
function getTemplate(moduleName) {
|
||||
var data = {
|
||||
'key': mapping.key,
|
||||
'name': _.result(mapping.aliasToReal, moduleName, moduleName)
|
||||
};
|
||||
|
||||
if (isAlias(moduleName)) {
|
||||
return template.alias(data);
|
||||
}
|
||||
if (isCategory(moduleName)) {
|
||||
return template.category(data);
|
||||
}
|
||||
if (isThru(moduleName)) {
|
||||
return template.thru(data);
|
||||
}
|
||||
return template.module(data);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
function onComplete(error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function build(target) {
|
||||
var fpPath = path.join(target, 'fp');
|
||||
|
||||
// Glob existing lodash module paths.
|
||||
var modulePaths = glob.sync(path.join(target, '*.js'), {
|
||||
'nodir': true,
|
||||
'ignore': [
|
||||
'_*.js',
|
||||
'core.js',
|
||||
'fp.js',
|
||||
'index.js',
|
||||
'lodash.js'
|
||||
].map(function(filename) {
|
||||
return path.join(target, filename);
|
||||
})
|
||||
});
|
||||
|
||||
// Add FP alias and remapped module paths.
|
||||
_.each([mapping.aliasToReal, mapping.key], function(data) {
|
||||
_.forOwn(data, function(realName, alias) {
|
||||
modulePaths.push(path.join(target, alias + '.js'));
|
||||
});
|
||||
});
|
||||
|
||||
modulePaths = _.uniq(modulePaths);
|
||||
|
||||
var actions = modulePaths.map(function(modulePath) {
|
||||
var moduleName = path.basename(modulePath, '.js');
|
||||
return _.partial(fs.writeFile, path.join(fpPath, moduleName + '.js'), getTemplate(moduleName));
|
||||
});
|
||||
|
||||
actions.unshift(_.partial(fs.copy, path.join(__dirname, '../../fp'), fpPath));
|
||||
actions.push(_.partial(fs.writeFile, path.join(target, 'fp.js'), template.fp()));
|
||||
actions.push(_.partial(fs.writeFile, path.join(fpPath, 'convert.js'), template.convert()));
|
||||
actions.push(_.partial(fs.writeFile, path.join(fpPath, '_util.js'), template._util()));
|
||||
|
||||
async.series(actions, onComplete);
|
||||
}
|
||||
|
||||
build(_.last(process.argv));
|
||||
10
lib/fp/template/_util.jst
Normal file
10
lib/fp/template/_util.jst
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
'ary': require('../ary'),
|
||||
'cloneDeep': require('../cloneDeep'),
|
||||
'curry': require('../curry'),
|
||||
'forEach': require('../_arrayEach'),
|
||||
'isFunction': require('../isFunction'),
|
||||
'iteratee': require('../iteratee'),
|
||||
'keys': require('../_baseKeys'),
|
||||
'rearg': require('../rearg')
|
||||
};
|
||||
1
lib/fp/template/alias.jst
Normal file
1
lib/fp/template/alias.jst
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./<%= name %>');
|
||||
2
lib/fp/template/category.jst
Normal file
2
lib/fp/template/category.jst
Normal file
@@ -0,0 +1,2 @@
|
||||
var convert = require('./convert');
|
||||
module.exports = convert(require('../<%= name %>'));
|
||||
16
lib/fp/template/convert.jst
Normal file
16
lib/fp/template/convert.jst
Normal file
@@ -0,0 +1,16 @@
|
||||
var baseConvert = require('./_baseConvert'),
|
||||
util = require('./_util');
|
||||
|
||||
/**
|
||||
* Converts `func` of `name` to an immutable auto-curried iteratee-first data-last
|
||||
* version. If `name` is an object its methods will be converted.
|
||||
*
|
||||
* @param {string} name The name of the function to wrap.
|
||||
* @param {Function} [func] The function to wrap.
|
||||
* @returns {Function|Object} Returns the converted function or object.
|
||||
*/
|
||||
function convert(name, func) {
|
||||
return baseConvert(util, name, func);
|
||||
}
|
||||
|
||||
module.exports = convert;
|
||||
2
lib/fp/template/fp.jst
Normal file
2
lib/fp/template/fp.jst
Normal file
@@ -0,0 +1,2 @@
|
||||
var _ = require('./lodash').noConflict().runInContext();
|
||||
module.exports = require('./fp/convert')(_);
|
||||
2
lib/fp/template/module.jst
Normal file
2
lib/fp/template/module.jst
Normal file
@@ -0,0 +1,2 @@
|
||||
var convert = require('./convert');
|
||||
module.exports = convert('<%= name %>', require('../<%= _.result(key, name, name) %>'));
|
||||
1
lib/fp/template/thru.jst
Normal file
1
lib/fp/template/thru.jst
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('../<%= name %>');
|
||||
32
lib/main/build-dist.js
Normal file
32
lib/main/build-dist.js
Normal file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash'),
|
||||
async = require('async'),
|
||||
fs = require('fs-extra'),
|
||||
path = require('path');
|
||||
|
||||
var minify = require('../common/minify.js');
|
||||
|
||||
var basePath = path.join(__dirname, '..', '..'),
|
||||
distPath = path.join(basePath, 'dist'),
|
||||
filename = 'lodash.js';
|
||||
|
||||
var baseLodash = path.join(basePath, filename),
|
||||
distLodash = path.join(distPath, filename);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
function onComplete(error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function build() {
|
||||
async.series([
|
||||
_.partial(fs.copy, baseLodash, distLodash),
|
||||
_.partial(minify, distLodash)
|
||||
], onComplete);
|
||||
}
|
||||
|
||||
build();
|
||||
23
lib/main/build-modules.js
Normal file
23
lib/main/build-modules.js
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash'),
|
||||
fs = require('fs-extra'),
|
||||
path = require('path');
|
||||
|
||||
var basePath = path.join(__dirname, '..', '..'),
|
||||
distPath = path.join(basePath, 'dist'),
|
||||
corePath = path.join(distPath, 'lodash.core.js');
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
function onComplete(error) {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function build(target) {
|
||||
fs.copy(corePath, path.join(target, 'core.js'), onComplete);
|
||||
}
|
||||
|
||||
build(_.last(process.argv));
|
||||
99
lodash.min.js
vendored
99
lodash.min.js
vendored
@@ -1,99 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* lodash 3.10.0 (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
|
||||
* Build: `lodash modern -o ./lodash.js`
|
||||
*/
|
||||
;(function(){function n(n,t){if(n!==t){var r=null===n,e=n===w,u=n===n,o=null===t,i=t===w,f=t===t;if(n>t&&!o||!u||r&&!i&&f||e&&f)return 1;if(n<t&&!r||!f||o&&!e&&u||i&&u)return-1}return 0}function t(n,t,r){for(var e=n.length,u=r?e:-1;r?u--:++u<e;)if(t(n[u],u,n))return u;return-1}function r(n,t,r){if(t!==t)return p(n,r);r-=1;for(var e=n.length;++r<e;)if(n[r]===t)return r;return-1}function e(n){return typeof n=="function"||false}function u(n){return null==n?"":n+""}function o(n,t){for(var r=-1,e=n.length;++r<e&&-1<t.indexOf(n.charAt(r)););
|
||||
return r}function i(n,t){for(var r=n.length;r--&&-1<t.indexOf(n.charAt(r)););return r}function f(t,r){return n(t.a,r.a)||t.b-r.b}function a(n){return Nn[n]}function c(n){return Tn[n]}function l(n,t,r){return t?n=Bn[n]:r&&(n=Dn[n]),"\\"+n}function s(n){return"\\"+Dn[n]}function p(n,t,r){var e=n.length;for(t+=r?0:-1;r?t--:++t<e;){var u=n[t];if(u!==u)return t}return-1}function h(n){return!!n&&typeof n=="object"}function _(n){return 160>=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n);
|
||||
}function v(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;)n[r]===t&&(n[r]=z,o[++u]=r);return o}function g(n){for(var t=-1,r=n.length;++t<r&&_(n.charCodeAt(t)););return t}function y(n){for(var t=n.length;t--&&_(n.charCodeAt(t)););return t}function d(n){return Ln[n]}function m(_){function Nn(n){if(h(n)&&!(Oo(n)||n instanceof zn)){if(n instanceof Ln)return n;if(nu.call(n,"__chain__")&&nu.call(n,"__wrapped__"))return Mr(n)}return new Ln(n)}function Tn(){}function Ln(n,t,r){this.__wrapped__=n,this.__actions__=r||[],
|
||||
this.__chain__=!!t}function zn(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=false,this.__iteratees__=[],this.__takeCount__=Ru,this.__views__=[]}function Bn(){this.__data__={}}function Dn(n){var t=n?n.length:0;for(this.data={hash:gu(null),set:new lu};t--;)this.push(n[t])}function Mn(n,t){var r=n.data;return(typeof t=="string"||ge(t)?r.set.has(t):r.hash[t])?0:-1}function qn(n,t){var r=-1,e=n.length;for(t||(t=Be(e));++r<e;)t[r]=n[r];return t}function Pn(n,t){for(var r=-1,e=n.length;++r<e&&false!==t(n[r],r,n););
|
||||
return n}function Kn(n,t){for(var r=-1,e=n.length;++r<e;)if(!t(n[r],r,n))return false;return true}function Vn(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;){var i=n[r];t(i,r,n)&&(o[++u]=i)}return o}function Gn(n,t){for(var r=-1,e=n.length,u=Be(e);++r<e;)u[r]=t(n[r],r,n);return u}function Jn(n,t){for(var r=-1,e=t.length,u=n.length;++r<e;)n[u+r]=t[r];return n}function Xn(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++u<o;)r=t(r,n[u],u,n);return r}function Hn(n,t){for(var r=-1,e=n.length;++r<e;)if(t(n[r],r,n))return true;
|
||||
return false}function Qn(n,t,r,e){return n!==w&&nu.call(e,r)?n:t}function nt(n,t,r){for(var e=-1,u=zo(t),o=u.length;++e<o;){var i=u[e],f=n[i],a=r(f,t[i],i,n,t);(a===a?a===f:f!==f)&&(f!==w||i in n)||(n[i]=a)}return n}function tt(n,t){return null==t?n:et(t,zo(t),n)}function rt(n,t){for(var r=-1,e=null==n,u=!e&&Er(n),o=u?n.length:0,i=t.length,f=Be(i);++r<i;){var a=t[r];f[r]=u?Cr(a,o)?n[a]:w:e?w:n[a]}return f}function et(n,t,r){r||(r={});for(var e=-1,u=t.length;++e<u;){var o=t[e];r[o]=n[o]}return r}function ut(n,t,r){
|
||||
var e=typeof n;return"function"==e?t===w?n:Bt(n,t,r):null==n?Fe:"object"==e?bt(n):t===w?ze(n):xt(n,t)}function ot(n,t,r,e,u,o,i){var f;if(r&&(f=u?r(n,e,u):r(n)),f!==w)return f;if(!ge(n))return n;if(e=Oo(n)){if(f=kr(n),!t)return qn(n,f)}else{var a=ru.call(n),c=a==K;if(a!=Z&&a!=B&&(!c||u))return Fn[a]?Rr(n,a,t):u?n:{};if(f=Ir(c?{}:n),!t)return tt(f,n)}for(o||(o=[]),i||(i=[]),u=o.length;u--;)if(o[u]==n)return i[u];return o.push(n),i.push(f),(e?Pn:_t)(n,function(e,u){f[u]=ot(e,t,r,u,n,o,i)}),f}function it(n,t,r){
|
||||
if(typeof n!="function")throw new Ge(L);return su(function(){n.apply(w,r)},t)}function ft(n,t){var e=n?n.length:0,u=[];if(!e)return u;var o=-1,i=xr(),f=i==r,a=f&&t.length>=F&&gu&&lu?new Dn(t):null,c=t.length;a&&(i=Mn,f=false,t=a);n:for(;++o<e;)if(a=n[o],f&&a===a){for(var l=c;l--;)if(t[l]===a)continue n;u.push(a)}else 0>i(t,a,0)&&u.push(a);return u}function at(n,t){var r=true;return Su(n,function(n,e,u){return r=!!t(n,e,u)}),r}function ct(n,t,r,e){var u=e,o=u;return Su(n,function(n,i,f){i=+t(n,i,f),(r(i,u)||i===e&&i===o)&&(u=i,
|
||||
o=n)}),o}function lt(n,t){var r=[];return Su(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function st(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function pt(n,t,r,e){e||(e=[]);for(var u=-1,o=n.length;++u<o;){var i=n[u];h(i)&&Er(i)&&(r||Oo(i)||pe(i))?t?pt(i,t,r,e):Jn(e,i):r||(e[e.length]=i)}return e}function ht(n,t){Nu(n,t,Re)}function _t(n,t){return Nu(n,t,zo)}function vt(n,t){return Tu(n,t,zo)}function gt(n,t){for(var r=-1,e=t.length,u=-1,o=[];++r<e;){var i=t[r];
|
||||
ve(n[i])&&(o[++u]=i)}return o}function yt(n,t,r){if(null!=n){r!==w&&r in Br(n)&&(t=[r]),r=0;for(var e=t.length;null!=n&&r<e;)n=n[t[r++]];return r&&r==e?n:w}}function dt(n,t,r,e,u,o){if(n===t)n=true;else if(null==n||null==t||!ge(n)&&!h(t))n=n!==n&&t!==t;else n:{var i=dt,f=Oo(n),a=Oo(t),c=D,l=D;f||(c=ru.call(n),c==B?c=Z:c!=Z&&(f=xe(n))),a||(l=ru.call(t),l==B?l=Z:l!=Z&&xe(t));var s=c==Z,a=l==Z,l=c==l;if(!l||f||s){if(!e&&(c=s&&nu.call(n,"__wrapped__"),a=a&&nu.call(t,"__wrapped__"),c||a)){n=i(c?n.value():n,a?t.value():t,r,e,u,o);
|
||||
break n}if(l){for(u||(u=[]),o||(o=[]),c=u.length;c--;)if(u[c]==n){n=o[c]==t;break n}u.push(n),o.push(t),n=(f?yr:mr)(n,t,i,r,e,u,o),u.pop(),o.pop()}else n=false}else n=dr(n,t,c)}return n}function mt(n,t,r){var e=t.length,u=e,o=!r;if(null==n)return!u;for(n=Br(n);e--;){var i=t[e];if(o&&i[2]?i[1]!==n[i[0]]:!(i[0]in n))return false}for(;++e<u;){var i=t[e],f=i[0],a=n[f],c=i[1];if(o&&i[2]){if(a===w&&!(f in n))return false}else if(i=r?r(a,c,f):w,i===w?!dt(c,a,r,true):!i)return false}return true}function wt(n,t){var r=-1,e=Er(n)?Be(n.length):[];
|
||||
return Su(n,function(n,u,o){e[++r]=t(n,u,o)}),e}function bt(n){var t=Ar(n);if(1==t.length&&t[0][2]){var r=t[0][0],e=t[0][1];return function(n){return null==n?false:n[r]===e&&(e!==w||r in Br(n))}}return function(n){return mt(n,t)}}function xt(n,t){var r=Oo(n),e=Wr(n)&&t===t&&!ge(t),u=n+"";return n=Dr(n),function(o){if(null==o)return false;var i=u;if(o=Br(o),!(!r&&e||i in o)){if(o=1==n.length?o:yt(o,Et(n,0,-1)),null==o)return false;i=Zr(n),o=Br(o)}return o[i]===t?t!==w||i in o:dt(t,o[i],w,true)}}function At(n,t,r,e,u){
|
||||
if(!ge(n))return n;var o=Er(t)&&(Oo(t)||xe(t)),i=o?w:zo(t);return Pn(i||t,function(f,a){if(i&&(a=f,f=t[a]),h(f)){e||(e=[]),u||(u=[]);n:{for(var c=a,l=e,s=u,p=l.length,_=t[c];p--;)if(l[p]==_){n[c]=s[p];break n}var p=n[c],v=r?r(p,_,c,n,t):w,g=v===w;g&&(v=_,Er(_)&&(Oo(_)||xe(_))?v=Oo(p)?p:Er(p)?qn(p):[]:me(_)||pe(_)?v=pe(p)?ke(p):me(p)?p:{}:g=false),l.push(_),s.push(v),g?n[c]=At(v,_,r,l,s):(v===v?v!==p:p===p)&&(n[c]=v)}}else c=n[a],l=r?r(c,f,a,n,t):w,(s=l===w)&&(l=f),l===w&&(!o||a in n)||!s&&(l===l?l===c:c!==c)||(n[a]=l);
|
||||
}),n}function jt(n){return function(t){return null==t?w:t[n]}}function kt(n){var t=n+"";return n=Dr(n),function(r){return yt(r,n,t)}}function It(n,t){for(var r=n?t.length:0;r--;){var e=t[r];if(e!=u&&Cr(e)){var u=e;pu.call(n,e,1)}}}function Rt(n,t){return n+yu(ku()*(t-n+1))}function Ot(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function Et(n,t,r){var e=-1,u=n.length;for(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=r===w||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Be(u);++e<u;)r[e]=n[e+t];
|
||||
return r}function Ct(n,t){var r;return Su(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function Ut(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;return n}function Wt(t,r,e){var u=wr(),o=-1;return r=Gn(r,function(n){return u(n)}),t=wt(t,function(n){return{a:Gn(r,function(t){return t(n)}),b:++o,c:n}}),Ut(t,function(t,r){var u;n:{for(var o=-1,i=t.a,f=r.a,a=i.length,c=e.length;++o<a;)if(u=n(i[o],f[o])){if(o>=c)break n;o=e[o],u*="asc"===o||true===o?1:-1;break n}u=t.b-r.b}return u})}function $t(n,t){
|
||||
var r=0;return Su(n,function(n,e,u){r+=+t(n,e,u)||0}),r}function St(n,t){var e=-1,u=xr(),o=n.length,i=u==r,f=i&&o>=F,a=f&&gu&&lu?new Dn(void 0):null,c=[];a?(u=Mn,i=false):(f=false,a=t?[]:c);n:for(;++e<o;){var l=n[e],s=t?t(l,e,n):l;if(i&&l===l){for(var p=a.length;p--;)if(a[p]===s)continue n;t&&a.push(s),c.push(l)}else 0>u(a,s,0)&&((t||f)&&a.push(s),c.push(l))}return c}function Ft(n,t){for(var r=-1,e=t.length,u=Be(e);++r<e;)u[r]=n[t[r]];return u}function Nt(n,t,r,e){for(var u=n.length,o=e?u:-1;(e?o--:++o<u)&&t(n[o],o,n););
|
||||
return r?Et(n,e?0:o,e?o+1:u):Et(n,e?o+1:0,e?u:o)}function Tt(n,t){var r=n;r instanceof zn&&(r=r.value());for(var e=-1,u=t.length;++e<u;)var o=t[e],r=o.func.apply(o.thisArg,Jn([r],o.args));return r}function Lt(n,t,r){var e=0,u=n?n.length:e;if(typeof t=="number"&&t===t&&u<=Eu){for(;e<u;){var o=e+u>>>1,i=n[o];(r?i<=t:i<t)&&null!==i?e=o+1:u=o}return u}return zt(n,t,Fe,r)}function zt(n,t,r,e){t=r(t);for(var u=0,o=n?n.length:0,i=t!==t,f=null===t,a=t===w;u<o;){var c=yu((u+o)/2),l=r(n[c]),s=l!==w,p=l===l;
|
||||
(i?p||e:f?p&&s&&(e||null!=l):a?p&&(e||s):null==l?0:e?l<=t:l<t)?u=c+1:o=c}return xu(o,Ou)}function Bt(n,t,r){if(typeof n!="function")return Fe;if(t===w)return n;switch(r){case 1:return function(r){return n.call(t,r)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,o){return n.call(t,r,e,u,o)};case 5:return function(r,e,u,o,i){return n.call(t,r,e,u,o,i)}}return function(){return n.apply(t,arguments)}}function Dt(n){var t=new ou(n.byteLength);return new hu(t).set(new hu(n)),
|
||||
t}function Mt(n,t,r){for(var e=r.length,u=-1,o=bu(n.length-e,0),i=-1,f=t.length,a=Be(f+o);++i<f;)a[i]=t[i];for(;++u<e;)a[r[u]]=n[u];for(;o--;)a[i++]=n[u++];return a}function qt(n,t,r){for(var e=-1,u=r.length,o=-1,i=bu(n.length-u,0),f=-1,a=t.length,c=Be(i+a);++o<i;)c[o]=n[o];for(i=o;++f<a;)c[i+f]=t[f];for(;++e<u;)c[i+r[e]]=n[o++];return c}function Pt(n,t){return function(r,e,u){var o=t?t():{};if(e=wr(e,u,3),Oo(r)){u=-1;for(var i=r.length;++u<i;){var f=r[u];n(o,f,e(f,u,r),r)}}else Su(r,function(t,r,u){
|
||||
n(o,t,e(t,r,u),u)});return o}}function Kt(n){return le(function(t,r){var e=-1,u=null==t?0:r.length,o=2<u?r[u-2]:w,i=2<u?r[2]:w,f=1<u?r[u-1]:w;for(typeof o=="function"?(o=Bt(o,f,5),u-=2):(o=typeof f=="function"?f:w,u-=o?1:0),i&&Ur(r[0],r[1],i)&&(o=3>u?w:o,u=1);++e<u;)(i=r[e])&&n(t,i,o);return t})}function Vt(n,t){return function(r,e){var u=r?Bu(r):0;if(!Sr(u))return n(r,e);for(var o=t?u:-1,i=Br(r);(t?o--:++o<u)&&false!==e(i[o],o,i););return r}}function Zt(n){return function(t,r,e){var u=Br(t);e=e(t);for(var o=e.length,i=n?o:-1;n?i--:++i<o;){
|
||||
var f=e[i];if(false===r(u[f],f,u))break}return t}}function Yt(n,t){function r(){return(this&&this!==Zn&&this instanceof r?e:n).apply(t,arguments)}var e=Jt(n);return r}function Gt(n){return function(t){var r=-1;t=$e(Ce(t));for(var e=t.length,u="";++r<e;)u=n(u,t[r],r);return u}}function Jt(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:
|
||||
return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=$u(n.prototype),t=n.apply(r,t);return ge(t)?t:r}}function Xt(n){function t(r,e,u){return u&&Ur(r,e,u)&&(e=w),r=gr(r,n,w,w,w,w,w,e),r.placeholder=t.placeholder,r}return t}function Ht(n,t){return le(function(r){var e=r[0];return null==e?e:(r.push(t),n.apply(w,r))})}function Qt(n,t){return function(r,e,u){if(u&&Ur(r,e,u)&&(e=w),e=wr(e,u,3),1==e.length){
|
||||
u=r=Oo(r)?r:zr(r);for(var o=e,i=-1,f=u.length,a=t,c=a;++i<f;){var l=u[i],s=+o(l);n(s,a)&&(a=s,c=l)}if(u=c,!r.length||u!==t)return u}return ct(r,e,n,t)}}function nr(n,r){return function(e,u,o){return u=wr(u,o,3),Oo(e)?(u=t(e,u,r),-1<u?e[u]:w):st(e,u,n)}}function tr(n){return function(r,e,u){return r&&r.length?(e=wr(e,u,3),t(r,e,n)):-1}}function rr(n){return function(t,r,e){return r=wr(r,e,3),st(t,r,n,true)}}function er(n){return function(){for(var t,r=arguments.length,e=n?r:-1,u=0,o=Be(r);n?e--:++e<r;){
|
||||
var i=o[u++]=arguments[e];if(typeof i!="function")throw new Ge(L);!t&&Ln.prototype.thru&&"wrapper"==br(i)&&(t=new Ln([],true))}for(e=t?-1:r;++e<r;){var i=o[e],u=br(i),f="wrapper"==u?zu(i):w;t=f&&$r(f[0])&&f[1]==(E|k|R|C)&&!f[4].length&&1==f[9]?t[br(f[0])].apply(t,f[3]):1==i.length&&$r(i)?t[u]():t.thru(i)}return function(){var n=arguments,e=n[0];if(t&&1==n.length&&Oo(e)&&e.length>=F)return t.plant(e).value();for(var u=0,n=r?o[u].apply(this,n):e;++u<r;)n=o[u].call(this,n);return n}}}function ur(n,t){
|
||||
return function(r,e,u){return typeof e=="function"&&u===w&&Oo(r)?n(r,e):t(r,Bt(e,u,3))}}function or(n){return function(t,r,e){return(typeof r!="function"||e!==w)&&(r=Bt(r,e,3)),n(t,r,Re)}}function ir(n){return function(t,r,e){return(typeof r!="function"||e!==w)&&(r=Bt(r,e,3)),n(t,r)}}function fr(n){return function(t,r,e){var u={};return r=wr(r,e,3),_t(t,function(t,e,o){o=r(t,e,o),e=n?o:e,t=n?t:o,u[e]=t}),u}}function ar(n){return function(t,r,e){return t=u(t),(n?t:"")+pr(t,r,e)+(n?"":t)}}function cr(n){
|
||||
var t=le(function(r,e){var u=v(e,t.placeholder);return gr(r,n,w,e,u)});return t}function lr(n,t){return function(r,e,u,o){var i=3>arguments.length;return typeof e=="function"&&o===w&&Oo(r)?n(r,e,u,i):Ot(r,wr(e,o,4),u,i,t)}}function sr(n,t,r,e,u,o,i,f,a,c){function l(){for(var m=arguments.length,b=m,j=Be(m);b--;)j[b]=arguments[b];if(e&&(j=Mt(j,e,u)),o&&(j=qt(j,o,i)),_||y){var b=l.placeholder,k=v(j,b),m=m-k.length;if(m<c){var I=f?qn(f):w,m=bu(c-m,0),E=_?k:w,k=_?w:k,C=_?j:w,j=_?w:j;return t|=_?R:O,t&=~(_?O:R),
|
||||
g||(t&=~(x|A)),j=[n,t,r,C,E,j,k,I,a,m],I=sr.apply(w,j),$r(n)&&Du(I,j),I.placeholder=b,I}}if(b=p?r:this,I=h?b[n]:n,f)for(m=j.length,E=xu(f.length,m),k=qn(j);E--;)C=f[E],j[E]=Cr(C,m)?k[C]:w;return s&&a<j.length&&(j.length=a),this&&this!==Zn&&this instanceof l&&(I=d||Jt(n)),I.apply(b,j)}var s=t&E,p=t&x,h=t&A,_=t&k,g=t&j,y=t&I,d=h?w:Jt(n);return l}function pr(n,t,r){return n=n.length,t=+t,n<t&&mu(t)?(t-=n,r=null==r?" ":r+"",Ue(r,vu(t/r.length)).slice(0,t)):""}function hr(n,t,r,e){function u(){for(var t=-1,f=arguments.length,a=-1,c=e.length,l=Be(c+f);++a<c;)l[a]=e[a];
|
||||
for(;f--;)l[a++]=arguments[++t];return(this&&this!==Zn&&this instanceof u?i:n).apply(o?r:this,l)}var o=t&x,i=Jt(n);return u}function _r(n){var t=Pe[n];return function(n,r){return(r=r===w?0:+r||0)?(r=au(10,r),t(n*r)/r):t(n)}}function vr(n){return function(t,r,e,u){var o=wr(e);return null==e&&o===ut?Lt(t,r,n):zt(t,r,o(e,u,1),n)}}function gr(n,t,r,e,u,o,i,f){var a=t&A;if(!a&&typeof n!="function")throw new Ge(L);var c=e?e.length:0;if(c||(t&=~(R|O),e=u=w),c-=u?u.length:0,t&O){var l=e,s=u;e=u=w}var p=a?w:zu(n);
|
||||
return r=[n,t,r,e,u,l,s,o,i,f],p&&(e=r[1],t=p[1],f=e|t,u=t==E&&e==k||t==E&&e==C&&r[7].length<=p[8]||t==(E|C)&&e==k,(f<E||u)&&(t&x&&(r[2]=p[2],f|=e&x?0:j),(e=p[3])&&(u=r[3],r[3]=u?Mt(u,e,p[4]):qn(e),r[4]=u?v(r[3],z):qn(p[4])),(e=p[5])&&(u=r[5],r[5]=u?qt(u,e,p[6]):qn(e),r[6]=u?v(r[5],z):qn(p[6])),(e=p[7])&&(r[7]=qn(e)),t&E&&(r[8]=null==r[8]?p[8]:xu(r[8],p[8])),null==r[9]&&(r[9]=p[9]),r[0]=p[0],r[1]=f),t=r[1],f=r[9]),r[9]=null==f?a?0:n.length:bu(f-c,0)||0,(p?Lu:Du)(t==x?Yt(r[0],r[2]):t!=R&&t!=(x|R)||r[4].length?sr.apply(w,r):hr.apply(w,r),r);
|
||||
}function yr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length;if(a!=c&&(!u||c<=a))return false;for(;++f<a;){var l=n[f],c=t[f],s=e?e(u?c:l,u?l:c,f):w;if(s!==w){if(s)continue;return false}if(u){if(!Hn(t,function(n){return l===n||r(l,n,e,u,o,i)}))return false}else if(l!==c&&!r(l,c,e,u,o,i))return false}return true}function dr(n,t,r){switch(r){case M:case q:return+n==+t;case P:return n.name==t.name&&n.message==t.message;case V:return n!=+n?t!=+t:n==+t;case Y:case G:return n==t+""}return false}function mr(n,t,r,e,u,o,i){var f=zo(n),a=f.length,c=zo(t).length;
|
||||
if(a!=c&&!u)return false;for(c=a;c--;){var l=f[c];if(!(u?l in t:nu.call(t,l)))return false}for(var s=u;++c<a;){var l=f[c],p=n[l],h=t[l],_=e?e(u?h:p,u?p:h,l):w;if(_===w?!r(p,h,e,u,o,i):!_)return false;s||(s="constructor"==l)}return s||(r=n.constructor,e=t.constructor,!(r!=e&&"constructor"in n&&"constructor"in t)||typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)?true:false}function wr(n,t,r){var e=Nn.callback||Se,e=e===Se?ut:e;return r?e(n,t,r):e}function br(n){for(var t=n.name,r=Wu[t],e=r?r.length:0;e--;){
|
||||
var u=r[e],o=u.func;if(null==o||o==n)return u.name}return t}function xr(n,t,e){var u=Nn.indexOf||Vr,u=u===Vr?r:u;return n?u(n,t,e):u}function Ar(n){n=Oe(n);for(var t=n.length;t--;){var r=n[t][1];n[t][2]=r===r&&!ge(r)}return n}function jr(n,t){var r=null==n?w:n[t];return ye(r)?r:w}function kr(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&nu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function Ir(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Ve),
|
||||
new n}function Rr(n,t,r){var e=n.constructor;switch(t){case J:return Dt(n);case M:case q:return new e(+n);case X:case H:case Q:case nn:case tn:case rn:case en:case un:case on:return t=n.buffer,new e(r?Dt(t):t,n.byteOffset,n.length);case V:case G:return new e(n);case Y:var u=new e(n.source,kn.exec(n));u.lastIndex=n.lastIndex}return u}function Or(n,t,r){return null==n||Wr(t,n)||(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),t=Zr(t)),t=null==n?n:n[t],null==t?w:t.apply(n,r)}function Er(n){return null!=n&&Sr(Bu(n));
|
||||
}function Cr(n,t){return n=typeof n=="number"||On.test(n)?+n:-1,t=null==t?Cu:t,-1<n&&0==n%1&&n<t}function Ur(n,t,r){if(!ge(r))return false;var e=typeof t;return("number"==e?Er(r)&&Cr(t,r.length):"string"==e&&t in r)?(t=r[t],n===n?n===t:t!==t):false}function Wr(n,t){var r=typeof n;return"string"==r&&dn.test(n)||"number"==r?true:Oo(n)?false:!yn.test(n)||null!=t&&n in Br(t)}function $r(n){var t=br(n);return t in zn.prototype?(t=Nn[t],n===t?true:(t=zu(t),!!t&&n===t[0])):false}function Sr(n){return typeof n=="number"&&-1<n&&0==n%1&&n<=Cu;
|
||||
}function Fr(n,t){return n===w?t:Eo(n,t,Fr)}function Nr(n,t){n=Br(n);for(var r=-1,e=t.length,u={};++r<e;){var o=t[r];o in n&&(u[o]=n[o])}return u}function Tr(n,t){var r={};return ht(n,function(n,e,u){t(n,e,u)&&(r[e]=n)}),r}function Lr(n){for(var t=Re(n),r=t.length,e=r&&n.length,u=!!e&&Sr(e)&&(Oo(n)||pe(n)),o=-1,i=[];++o<r;){var f=t[o];(u&&Cr(f,e)||nu.call(n,f))&&i.push(f)}return i}function zr(n){return null==n?[]:Er(n)?ge(n)?n:Ve(n):Ee(n)}function Br(n){return ge(n)?n:Ve(n)}function Dr(n){if(Oo(n))return n;
|
||||
var t=[];return u(n).replace(mn,function(n,r,e,u){t.push(e?u.replace(An,"$1"):r||n)}),t}function Mr(n){return n instanceof zn?n.clone():new Ln(n.__wrapped__,n.__chain__,qn(n.__actions__))}function qr(n,t,r){return n&&n.length?((r?Ur(n,t,r):null==t)&&(t=1),Et(n,0>t?0:t)):[]}function Pr(n,t,r){var e=n?n.length:0;return e?((r?Ur(n,t,r):null==t)&&(t=1),t=e-(+t||0),Et(n,0,0>t?0:t)):[]}function Kr(n){return n?n[0]:w}function Vr(n,t,e){var u=n?n.length:0;if(!u)return-1;if(typeof e=="number")e=0>e?bu(u+e,0):e;else if(e)return e=Lt(n,t),
|
||||
e<u&&(t===t?t===n[e]:n[e]!==n[e])?e:-1;return r(n,t,e||0)}function Zr(n){var t=n?n.length:0;return t?n[t-1]:w}function Yr(n){return qr(n,1)}function Gr(n,t,e,u){if(!n||!n.length)return[];null!=t&&typeof t!="boolean"&&(u=e,e=Ur(n,t,u)?w:t,t=false);var o=wr();if((null!=e||o!==ut)&&(e=o(e,u,3)),t&&xr()==r){t=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e<u;){var a=n[e],c=t?t(a,e,n):a;e&&i===c||(i=c,f[++o]=a)}n=f}else n=St(n,e);return n}function Jr(n){if(!n||!n.length)return[];var t=-1,r=0;n=Vn(n,function(n){
|
||||
return Er(n)?(r=bu(n.length,r),true):void 0});for(var e=Be(r);++t<r;)e[t]=Gn(n,jt(t));return e}function Xr(n,t,r){return n&&n.length?(n=Jr(n),null==t?n:(t=Bt(t,r,4),Gn(n,function(n){return Xn(n,t,w,true)}))):[]}function Hr(n,t){var r=-1,e=n?n.length:0,u={};for(!e||t||Oo(n[0])||(t=[]);++r<e;){var o=n[r];t?u[o]=t[r]:o&&(u[o[0]]=o[1])}return u}function Qr(n){return n=Nn(n),n.__chain__=true,n}function ne(n,t,r){return t.call(r,n)}function te(n,t,r){var e=Oo(n)?Kn:at;return r&&Ur(n,t,r)&&(t=w),(typeof t!="function"||r!==w)&&(t=wr(t,r,3)),
|
||||
e(n,t)}function re(n,t,r){var e=Oo(n)?Vn:lt;return t=wr(t,r,3),e(n,t)}function ee(n,t,r,e){var u=n?Bu(n):0;return Sr(u)||(n=Ee(n),u=n.length),r=typeof r!="number"||e&&Ur(t,r,e)?0:0>r?bu(u+r,0):r||0,typeof n=="string"||!Oo(n)&&be(n)?r<=u&&-1<n.indexOf(t,r):!!u&&-1<xr(n,t,r)}function ue(n,t,r){var e=Oo(n)?Gn:wt;return t=wr(t,r,3),e(n,t)}function oe(n,t,r){if(r?Ur(n,t,r):null==t){n=zr(n);var e=n.length;return 0<e?n[Rt(0,e-1)]:w}r=-1,n=je(n);var e=n.length,u=e-1;for(t=xu(0>t?0:+t||0,e);++r<t;){var e=Rt(r,u),o=n[e];
|
||||
n[e]=n[r],n[r]=o}return n.length=t,n}function ie(n,t,r){var e=Oo(n)?Hn:Ct;return r&&Ur(n,t,r)&&(t=w),(typeof t!="function"||r!==w)&&(t=wr(t,r,3)),e(n,t)}function fe(n,t){var r;if(typeof t!="function"){if(typeof n!="function")throw new Ge(L);var e=n;n=t,t=e}return function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=w),r}}function ae(n,t,r){function e(t,r){r&&iu(r),a=p=h=w,t&&(_=ho(),c=n.apply(s,f),p||a||(f=s=w))}function u(){var n=t-(ho()-l);0>=n||n>t?e(h,a):p=su(u,n)}function o(){e(g,p);
|
||||
}function i(){if(f=arguments,l=ho(),s=this,h=g&&(p||!y),false===v)var r=y&&!p;else{a||y||(_=l);var e=v-(l-_),i=0>=e||e>v;i?(a&&(a=iu(a)),_=l,c=n.apply(s,f)):a||(a=su(o,e))}return i&&p?p=iu(p):p||t===v||(p=su(u,t)),r&&(i=true,c=n.apply(s,f)),!i||p||a||(f=s=w),c}var f,a,c,l,s,p,h,_=0,v=false,g=true;if(typeof n!="function")throw new Ge(L);if(t=0>t?0:+t||0,true===r)var y=true,g=false;else ge(r)&&(y=!!r.leading,v="maxWait"in r&&bu(+r.maxWait||0,t),g="trailing"in r?!!r.trailing:g);return i.cancel=function(){p&&iu(p),a&&iu(a),
|
||||
_=0,a=p=h=w},i}function ce(n,t){function r(){var e=arguments,u=t?t.apply(this,e):e[0],o=r.cache;return o.has(u)?o.get(u):(e=n.apply(this,e),r.cache=o.set(u,e),e)}if(typeof n!="function"||t&&typeof t!="function")throw new Ge(L);return r.cache=new ce.Cache,r}function le(n,t){if(typeof n!="function")throw new Ge(L);return t=bu(t===w?n.length-1:+t||0,0),function(){for(var r=arguments,e=-1,u=bu(r.length-t,0),o=Be(u);++e<u;)o[e]=r[t+e];switch(t){case 0:return n.call(this,o);case 1:return n.call(this,r[0],o);
|
||||
case 2:return n.call(this,r[0],r[1],o)}for(u=Be(t+1),e=-1;++e<t;)u[e]=r[e];return u[t]=o,n.apply(this,u)}}function se(n,t){return n>t}function pe(n){return h(n)&&Er(n)&&nu.call(n,"callee")&&!cu.call(n,"callee")}function he(n,t,r,e){return e=(r=typeof r=="function"?Bt(r,e,3):w)?r(n,t):w,e===w?dt(n,t,r):!!e}function _e(n){return h(n)&&typeof n.message=="string"&&ru.call(n)==P}function ve(n){return ge(n)&&ru.call(n)==K}function ge(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function ye(n){
|
||||
return null==n?false:ve(n)?uu.test(Qe.call(n)):h(n)&&Rn.test(n)}function de(n){return typeof n=="number"||h(n)&&ru.call(n)==V}function me(n){var t;if(!h(n)||ru.call(n)!=Z||pe(n)||!(nu.call(n,"constructor")||(t=n.constructor,typeof t!="function"||t instanceof t)))return false;var r;return ht(n,function(n,t){r=t}),r===w||nu.call(n,r)}function we(n){return ge(n)&&ru.call(n)==Y}function be(n){return typeof n=="string"||h(n)&&ru.call(n)==G}function xe(n){return h(n)&&Sr(n.length)&&!!Sn[ru.call(n)]}function Ae(n,t){
|
||||
return n<t}function je(n){var t=n?Bu(n):0;return Sr(t)?t?qn(n):[]:Ee(n)}function ke(n){return et(n,Re(n))}function Ie(n){return gt(n,Re(n))}function Re(n){if(null==n)return[];ge(n)||(n=Ve(n));for(var t=n.length,t=t&&Sr(t)&&(Oo(n)||pe(n))&&t||0,r=n.constructor,e=-1,r=typeof r=="function"&&r.prototype===n,u=Be(t),o=0<t;++e<t;)u[e]=e+"";for(var i in n)o&&Cr(i,t)||"constructor"==i&&(r||!nu.call(n,i))||u.push(i);return u}function Oe(n){n=Br(n);for(var t=-1,r=zo(n),e=r.length,u=Be(e);++t<e;){var o=r[t];
|
||||
u[t]=[o,n[o]]}return u}function Ee(n){return Ft(n,zo(n))}function Ce(n){return(n=u(n))&&n.replace(En,a).replace(xn,"")}function Ue(n,t){var r="";if(n=u(n),t=+t,1>t||!n||!mu(t))return r;do t%2&&(r+=n),t=yu(t/2),n+=n;while(t);return r}function We(n,t,r){var e=n;return(n=u(n))?(r?Ur(e,t,r):null==t)?n.slice(g(n),y(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function $e(n,t,r){return r&&Ur(n,t,r)&&(t=w),n=u(n),n.match(t||Wn)||[]}function Se(n,t,r){return r&&Ur(n,t,r)&&(t=w),h(n)?Ne(n):ut(n,t)}function Fe(n){
|
||||
return n}function Ne(n){return bt(ot(n,true))}function Te(n,t,r){if(null==r){var e=ge(t),u=e?zo(t):w;((u=u&&u.length?gt(t,u):w)?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=gt(t,zo(t)));var o=true,e=-1,i=ve(n),f=u.length;false===r?o=false:ge(r)&&"chain"in r&&(o=r.chain);for(;++e<f;){r=u[e];var a=t[r];n[r]=a,i&&(n.prototype[r]=function(t){return function(){var r=this.__chain__;if(o||r){var e=n(this.__wrapped__);return(e.__actions__=qn(this.__actions__)).push({func:t,args:arguments,thisArg:n}),e.__chain__=r,e}return t.apply(n,Jn([this.value()],arguments));
|
||||
}}(a))}return n}function Le(){}function ze(n){return Wr(n)?jt(n):kt(n)}_=_?Yn.defaults(Zn.Object(),_,Yn.pick(Zn,$n)):Zn;var Be=_.Array,De=_.Date,Me=_.Error,qe=_.Function,Pe=_.Math,Ke=_.Number,Ve=_.Object,Ze=_.RegExp,Ye=_.String,Ge=_.TypeError,Je=Be.prototype,Xe=Ve.prototype,He=Ye.prototype,Qe=qe.prototype.toString,nu=Xe.hasOwnProperty,tu=0,ru=Xe.toString,eu=Zn._,uu=Ze("^"+Qe.call(nu).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ou=_.ArrayBuffer,iu=_.clearTimeout,fu=_.parseFloat,au=Pe.pow,cu=Xe.propertyIsEnumerable,lu=jr(_,"Set"),su=_.setTimeout,pu=Je.splice,hu=_.Uint8Array,_u=jr(_,"WeakMap"),vu=Pe.ceil,gu=jr(Ve,"create"),yu=Pe.floor,du=jr(Be,"isArray"),mu=_.isFinite,wu=jr(Ve,"keys"),bu=Pe.max,xu=Pe.min,Au=jr(De,"now"),ju=_.parseInt,ku=Pe.random,Iu=Ke.NEGATIVE_INFINITY,Ru=Ke.POSITIVE_INFINITY,Ou=4294967294,Eu=2147483647,Cu=9007199254740991,Uu=_u&&new _u,Wu={};
|
||||
Nn.support={},Nn.templateSettings={escape:_n,evaluate:vn,interpolate:gn,variable:"",imports:{_:Nn}};var $u=function(){function n(){}return function(t){if(ge(t)){n.prototype=t;var r=new n;n.prototype=w}return r||{}}}(),Su=Vt(_t),Fu=Vt(vt,true),Nu=Zt(),Tu=Zt(true),Lu=Uu?function(n,t){return Uu.set(n,t),n}:Fe,zu=Uu?function(n){return Uu.get(n)}:Le,Bu=jt("length"),Du=function(){var n=0,t=0;return function(r,e){var u=ho(),o=S-(u-t);if(t=u,0<o){if(++n>=$)return r}else n=0;return Lu(r,e)}}(),Mu=le(function(n,t){
|
||||
return h(n)&&Er(n)?ft(n,pt(t,false,true)):[]}),qu=tr(),Pu=tr(true),Ku=le(function(n){for(var t=n.length,e=t,u=Be(l),o=xr(),i=o==r,f=[];e--;){var a=n[e]=Er(a=n[e])?a:[];u[e]=i&&120<=a.length&&gu&&lu?new Dn(e&&a):null}var i=n[0],c=-1,l=i?i.length:0,s=u[0];n:for(;++c<l;)if(a=i[c],0>(s?Mn(s,a):o(f,a,0))){for(e=t;--e;){var p=u[e];if(0>(p?Mn(p,a):o(n[e],a,0)))continue n}s&&s.push(a),f.push(a)}return f}),Vu=le(function(t,r){r=pt(r);var e=rt(t,r);return It(t,r.sort(n)),e}),Zu=vr(),Yu=vr(true),Gu=le(function(n){return St(pt(n,false,true));
|
||||
}),Ju=le(function(n,t){return Er(n)?ft(n,t):[]}),Xu=le(Jr),Hu=le(function(n){var t=n.length,r=2<t?n[t-2]:w,e=1<t?n[t-1]:w;return 2<t&&typeof r=="function"?t-=2:(r=1<t&&typeof e=="function"?(--t,e):w,e=w),n.length=t,Xr(n,r,e)}),Qu=le(function(n){return n=pt(n),this.thru(function(t){t=Oo(t)?t:[Br(t)];for(var r=n,e=-1,u=t.length,o=-1,i=r.length,f=Be(u+i);++e<u;)f[e]=t[e];for(;++o<i;)f[e++]=r[o];return f})}),no=le(function(n,t){return rt(n,pt(t))}),to=Pt(function(n,t,r){nu.call(n,r)?++n[r]:n[r]=1}),ro=nr(Su),eo=nr(Fu,true),uo=ur(Pn,Su),oo=ur(function(n,t){
|
||||
for(var r=n.length;r--&&false!==t(n[r],r,n););return n},Fu),io=Pt(function(n,t,r){nu.call(n,r)?n[r].push(t):n[r]=[t]}),fo=Pt(function(n,t,r){n[r]=t}),ao=le(function(n,t,r){var e=-1,u=typeof t=="function",o=Wr(t),i=Er(n)?Be(n.length):[];return Su(n,function(n){var f=u?t:o&&null!=n?n[t]:w;i[++e]=f?f.apply(n,r):Or(n,t,r)}),i}),co=Pt(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),lo=lr(Xn,Su),so=lr(function(n,t,r,e){var u=n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);return r},Fu),po=le(function(n,t){
|
||||
if(null==n)return[];var r=t[2];return r&&Ur(t[0],t[1],r)&&(t.length=1),Wt(n,pt(t),[])}),ho=Au||function(){return(new De).getTime()},_o=le(function(n,t,r){var e=x;if(r.length)var u=v(r,_o.placeholder),e=e|R;return gr(n,e,t,r,u)}),vo=le(function(n,t){t=t.length?pt(t):Ie(n);for(var r=-1,e=t.length;++r<e;){var u=t[r];n[u]=gr(n[u],x,n)}return n}),go=le(function(n,t,r){var e=x|A;if(r.length)var u=v(r,go.placeholder),e=e|R;return gr(t,e,n,r,u)}),yo=Xt(k),mo=Xt(I),wo=le(function(n,t){return it(n,1,t)}),bo=le(function(n,t,r){
|
||||
return it(n,t,r)}),xo=er(),Ao=er(true),jo=le(function(n,t){if(t=pt(t),typeof n!="function"||!Kn(t,e))throw new Ge(L);var r=t.length;return le(function(e){for(var u=xu(e.length,r);u--;)e[u]=t[u](e[u]);return n.apply(this,e)})}),ko=cr(R),Io=cr(O),Ro=le(function(n,t){return gr(n,C,w,w,w,pt(t))}),Oo=du||function(n){return h(n)&&Sr(n.length)&&ru.call(n)==D},Eo=Kt(At),Co=Kt(function(n,t,r){return r?nt(n,t,r):tt(n,t)}),Uo=Ht(Co,function(n,t){return n===w?t:n}),Wo=Ht(Eo,Fr),$o=rr(_t),So=rr(vt),Fo=or(Nu),No=or(Tu),To=ir(_t),Lo=ir(vt),zo=wu?function(n){
|
||||
var t=null==n?w:n.constructor;return typeof t=="function"&&t.prototype===n||typeof n!="function"&&Er(n)?Lr(n):ge(n)?wu(n):[]}:Lr,Bo=fr(true),Do=fr(),Mo=le(function(n,t){if(null==n)return{};if("function"!=typeof t[0])return t=Gn(pt(t),Ye),Nr(n,ft(Re(n),t));var r=Bt(t[0],t[1],3);return Tr(n,function(n,t,e){return!r(n,t,e)})}),qo=le(function(n,t){return null==n?{}:"function"==typeof t[0]?Tr(n,Bt(t[0],t[1],3)):Nr(n,pt(t))}),Po=Gt(function(n,t,r){return t=t.toLowerCase(),n+(r?t.charAt(0).toUpperCase()+t.slice(1):t);
|
||||
}),Ko=Gt(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()}),Vo=ar(),Zo=ar(true),Yo=Gt(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),Go=Gt(function(n,t,r){return n+(r?" ":"")+(t.charAt(0).toUpperCase()+t.slice(1))}),Jo=le(function(n,t){try{return n.apply(w,t)}catch(r){return _e(r)?r:new Me(r)}}),Xo=le(function(n,t){return function(r){return Or(r,n,t)}}),Ho=le(function(n,t){return function(r){return Or(n,r,t)}}),Qo=_r("ceil"),ni=_r("floor"),ti=Qt(se,Iu),ri=Qt(Ae,Ru),ei=_r("round");return Nn.prototype=Tn.prototype,
|
||||
Ln.prototype=$u(Tn.prototype),Ln.prototype.constructor=Ln,zn.prototype=$u(Tn.prototype),zn.prototype.constructor=zn,Bn.prototype["delete"]=function(n){return this.has(n)&&delete this.__data__[n]},Bn.prototype.get=function(n){return"__proto__"==n?w:this.__data__[n]},Bn.prototype.has=function(n){return"__proto__"!=n&&nu.call(this.__data__,n)},Bn.prototype.set=function(n,t){return"__proto__"!=n&&(this.__data__[n]=t),this},Dn.prototype.push=function(n){var t=this.data;typeof n=="string"||ge(n)?t.set.add(n):t.hash[n]=true;
|
||||
},ce.Cache=Bn,Nn.after=function(n,t){if(typeof t!="function"){if(typeof n!="function")throw new Ge(L);var r=n;n=t,t=r}return n=mu(n=+n)?n:0,function(){return 1>--n?t.apply(this,arguments):void 0}},Nn.ary=function(n,t,r){return r&&Ur(n,t,r)&&(t=w),t=n&&null==t?n.length:bu(+t||0,0),gr(n,E,w,w,w,w,t)},Nn.assign=Co,Nn.at=no,Nn.before=fe,Nn.bind=_o,Nn.bindAll=vo,Nn.bindKey=go,Nn.callback=Se,Nn.chain=Qr,Nn.chunk=function(n,t,r){t=(r?Ur(n,t,r):null==t)?1:bu(yu(t)||1,1),r=0;for(var e=n?n.length:0,u=-1,o=Be(vu(e/t));r<e;)o[++u]=Et(n,r,r+=t);
|
||||
return o},Nn.compact=function(n){for(var t=-1,r=n?n.length:0,e=-1,u=[];++t<r;){var o=n[t];o&&(u[++e]=o)}return u},Nn.constant=function(n){return function(){return n}},Nn.countBy=to,Nn.create=function(n,t,r){var e=$u(n);return r&&Ur(n,t,r)&&(t=w),t?tt(e,t):e},Nn.curry=yo,Nn.curryRight=mo,Nn.debounce=ae,Nn.defaults=Uo,Nn.defaultsDeep=Wo,Nn.defer=wo,Nn.delay=bo,Nn.difference=Mu,Nn.drop=qr,Nn.dropRight=Pr,Nn.dropRightWhile=function(n,t,r){return n&&n.length?Nt(n,wr(t,r,3),true,true):[]},Nn.dropWhile=function(n,t,r){
|
||||
return n&&n.length?Nt(n,wr(t,r,3),true):[]},Nn.fill=function(n,t,r,e){var u=n?n.length:0;if(!u)return[];for(r&&typeof r!="number"&&Ur(n,t,r)&&(r=0,e=u),u=n.length,r=null==r?0:+r||0,0>r&&(r=-r>u?0:u+r),e=e===w||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r<u;)n[r++]=t;return n},Nn.filter=re,Nn.flatten=function(n,t,r){var e=n?n.length:0;return r&&Ur(n,t,r)&&(t=false),e?pt(n,t):[]},Nn.flattenDeep=function(n){return n&&n.length?pt(n,true):[]},Nn.flow=xo,Nn.flowRight=Ao,Nn.forEach=uo,Nn.forEachRight=oo,Nn.forIn=Fo,
|
||||
Nn.forInRight=No,Nn.forOwn=To,Nn.forOwnRight=Lo,Nn.functions=Ie,Nn.groupBy=io,Nn.indexBy=fo,Nn.initial=function(n){return Pr(n,1)},Nn.intersection=Ku,Nn.invert=function(n,t,r){r&&Ur(n,t,r)&&(t=w),r=-1;for(var e=zo(n),u=e.length,o={};++r<u;){var i=e[r],f=n[i];t?nu.call(o,f)?o[f].push(i):o[f]=[i]:o[f]=i}return o},Nn.invoke=ao,Nn.keys=zo,Nn.keysIn=Re,Nn.map=ue,Nn.mapKeys=Bo,Nn.mapValues=Do,Nn.matches=Ne,Nn.matchesProperty=function(n,t){return xt(n,ot(t,true))},Nn.memoize=ce,Nn.merge=Eo,Nn.method=Xo,Nn.methodOf=Ho,
|
||||
Nn.mixin=Te,Nn.modArgs=jo,Nn.negate=function(n){if(typeof n!="function")throw new Ge(L);return function(){return!n.apply(this,arguments)}},Nn.omit=Mo,Nn.once=function(n){return fe(2,n)},Nn.pairs=Oe,Nn.partial=ko,Nn.partialRight=Io,Nn.partition=co,Nn.pick=qo,Nn.pluck=function(n,t){return ue(n,ze(t))},Nn.property=ze,Nn.propertyOf=function(n){return function(t){return yt(n,Dr(t),t+"")}},Nn.pull=function(){var n=arguments,t=n[0];if(!t||!t.length)return t;for(var r=0,e=xr(),u=n.length;++r<u;)for(var o=0,i=n[r];-1<(o=e(t,i,o));)pu.call(t,o,1);
|
||||
return t},Nn.pullAt=Vu,Nn.range=function(n,t,r){r&&Ur(n,t,r)&&(t=r=w),n=+n||0,r=null==r?1:+r||0,null==t?(t=n,n=0):t=+t||0;var e=-1;t=bu(vu((t-n)/(r||1)),0);for(var u=Be(t);++e<t;)u[e]=n,n+=r;return u},Nn.rearg=Ro,Nn.reject=function(n,t,r){var e=Oo(n)?Vn:lt;return t=wr(t,r,3),e(n,function(n,r,e){return!t(n,r,e)})},Nn.remove=function(n,t,r){var e=[];if(!n||!n.length)return e;var u=-1,o=[],i=n.length;for(t=wr(t,r,3);++u<i;)r=n[u],t(r,u,n)&&(e.push(r),o.push(u));return It(n,o),e},Nn.rest=Yr,Nn.restParam=le,
|
||||
Nn.set=function(n,t,r){if(null==n)return n;var e=t+"";t=null!=n[e]||Wr(t,n)?[e]:Dr(t);for(var e=-1,u=t.length,o=u-1,i=n;null!=i&&++e<u;){var f=t[e];ge(i)&&(e==o?i[f]=r:null==i[f]&&(i[f]=Cr(t[e+1])?[]:{})),i=i[f]}return n},Nn.shuffle=function(n){return oe(n,Ru)},Nn.slice=function(n,t,r){var e=n?n.length:0;return e?(r&&typeof r!="number"&&Ur(n,t,r)&&(t=0,r=e),Et(n,t,r)):[]},Nn.sortBy=function(n,t,r){if(null==n)return[];r&&Ur(n,t,r)&&(t=w);var e=-1;return t=wr(t,r,3),n=wt(n,function(n,r,u){return{a:t(n,r,u),
|
||||
b:++e,c:n}}),Ut(n,f)},Nn.sortByAll=po,Nn.sortByOrder=function(n,t,r,e){return null==n?[]:(e&&Ur(t,r,e)&&(r=w),Oo(t)||(t=null==t?[]:[t]),Oo(r)||(r=null==r?[]:[r]),Wt(n,t,r))},Nn.spread=function(n){if(typeof n!="function")throw new Ge(L);return function(t){return n.apply(this,t)}},Nn.take=function(n,t,r){return n&&n.length?((r?Ur(n,t,r):null==t)&&(t=1),Et(n,0,0>t?0:t)):[]},Nn.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?Ur(n,t,r):null==t)&&(t=1),t=e-(+t||0),Et(n,0>t?0:t)):[]},Nn.takeRightWhile=function(n,t,r){
|
||||
return n&&n.length?Nt(n,wr(t,r,3),false,true):[]},Nn.takeWhile=function(n,t,r){return n&&n.length?Nt(n,wr(t,r,3)):[]},Nn.tap=function(n,t,r){return t.call(r,n),n},Nn.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new Ge(L);return false===r?e=false:ge(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),ae(n,t,{leading:e,maxWait:+t,trailing:u})},Nn.thru=ne,Nn.times=function(n,t,r){if(n=yu(n),1>n||!mu(n))return[];var e=-1,u=Be(xu(n,4294967295));for(t=Bt(t,r,1);++e<n;)4294967295>e?u[e]=t(e):t(e);
|
||||
return u},Nn.toArray=je,Nn.toPlainObject=ke,Nn.transform=function(n,t,r,e){var u=Oo(n)||xe(n);return t=wr(t,e,4),null==r&&(u||ge(n)?(e=n.constructor,r=u?Oo(n)?new e:[]:$u(ve(e)?e.prototype:w)):r={}),(u?Pn:_t)(n,function(n,e,u){return t(r,n,e,u)}),r},Nn.union=Gu,Nn.uniq=Gr,Nn.unzip=Jr,Nn.unzipWith=Xr,Nn.values=Ee,Nn.valuesIn=function(n){return Ft(n,Re(n))},Nn.where=function(n,t){return re(n,bt(t))},Nn.without=Ju,Nn.wrap=function(n,t){return t=null==t?Fe:t,gr(t,R,w,[n],[])},Nn.xor=function(){for(var n=-1,t=arguments.length;++n<t;){
|
||||
var r=arguments[n];if(Er(r))var e=e?Jn(ft(e,r),ft(r,e)):r}return e?St(e):[]},Nn.zip=Xu,Nn.zipObject=Hr,Nn.zipWith=Hu,Nn.backflow=Ao,Nn.collect=ue,Nn.compose=Ao,Nn.each=uo,Nn.eachRight=oo,Nn.extend=Co,Nn.iteratee=Se,Nn.methods=Ie,Nn.object=Hr,Nn.select=re,Nn.tail=Yr,Nn.unique=Gr,Te(Nn,Nn),Nn.add=function(n,t){return(+n||0)+(+t||0)},Nn.attempt=Jo,Nn.camelCase=Po,Nn.capitalize=function(n){return(n=u(n))&&n.charAt(0).toUpperCase()+n.slice(1)},Nn.ceil=Qo,Nn.clone=function(n,t,r,e){return t&&typeof t!="boolean"&&Ur(n,t,r)?t=false:typeof t=="function"&&(e=r,
|
||||
r=t,t=false),typeof r=="function"?ot(n,t,Bt(r,e,1)):ot(n,t)},Nn.cloneDeep=function(n,t,r){return typeof t=="function"?ot(n,true,Bt(t,r,1)):ot(n,true)},Nn.deburr=Ce,Nn.endsWith=function(n,t,r){n=u(n),t+="";var e=n.length;return r=r===w?e:xu(0>r?0:+r||0,e),r-=t.length,0<=r&&n.indexOf(t,r)==r},Nn.escape=function(n){return(n=u(n))&&hn.test(n)?n.replace(sn,c):n},Nn.escapeRegExp=function(n){return(n=u(n))&&bn.test(n)?n.replace(wn,l):n||"(?:)"},Nn.every=te,Nn.find=ro,Nn.findIndex=qu,Nn.findKey=$o,Nn.findLast=eo,
|
||||
Nn.findLastIndex=Pu,Nn.findLastKey=So,Nn.findWhere=function(n,t){return ro(n,bt(t))},Nn.first=Kr,Nn.floor=ni,Nn.get=function(n,t,r){return n=null==n?w:yt(n,Dr(t),t+""),n===w?r:n},Nn.gt=se,Nn.gte=function(n,t){return n>=t},Nn.has=function(n,t){if(null==n)return false;var r=nu.call(n,t);if(!r&&!Wr(t)){if(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),null==n)return false;t=Zr(t),r=nu.call(n,t)}return r||Sr(n.length)&&Cr(t,n.length)&&(Oo(n)||pe(n))},Nn.identity=Fe,Nn.includes=ee,Nn.indexOf=Vr,Nn.inRange=function(n,t,r){
|
||||
return t=+t||0,r===w?(r=t,t=0):r=+r||0,n>=xu(t,r)&&n<bu(t,r)},Nn.isArguments=pe,Nn.isArray=Oo,Nn.isBoolean=function(n){return true===n||false===n||h(n)&&ru.call(n)==M},Nn.isDate=function(n){return h(n)&&ru.call(n)==q},Nn.isElement=function(n){return!!n&&1===n.nodeType&&h(n)&&!me(n)},Nn.isEmpty=function(n){return null==n?true:Er(n)&&(Oo(n)||be(n)||pe(n)||h(n)&&ve(n.splice))?!n.length:!zo(n).length},Nn.isEqual=he,Nn.isError=_e,Nn.isFinite=function(n){return typeof n=="number"&&mu(n)},Nn.isFunction=ve,Nn.isMatch=function(n,t,r,e){
|
||||
return r=typeof r=="function"?Bt(r,e,3):w,mt(n,Ar(t),r)},Nn.isNaN=function(n){return de(n)&&n!=+n},Nn.isNative=ye,Nn.isNull=function(n){return null===n},Nn.isNumber=de,Nn.isObject=ge,Nn.isPlainObject=me,Nn.isRegExp=we,Nn.isString=be,Nn.isTypedArray=xe,Nn.isUndefined=function(n){return n===w},Nn.kebabCase=Ko,Nn.last=Zr,Nn.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?bu(e+r,0):xu(r||0,e-1))+1;else if(r)return u=Lt(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;
|
||||
if(t!==t)return p(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Nn.lt=Ae,Nn.lte=function(n,t){return n<=t},Nn.max=ti,Nn.min=ri,Nn.noConflict=function(){return Zn._=eu,this},Nn.noop=Le,Nn.now=ho,Nn.pad=function(n,t,r){n=u(n),t=+t;var e=n.length;return e<t&&mu(t)?(e=(t-e)/2,t=yu(e),e=vu(e),r=pr("",e,r),r.slice(0,t)+n+r):n},Nn.padLeft=Vo,Nn.padRight=Zo,Nn.parseInt=function(n,t,r){return(r?Ur(n,t,r):null==t)?t=0:t&&(t=+t),n=We(n),ju(n,t||(In.test(n)?16:10))},Nn.random=function(n,t,r){r&&Ur(n,t,r)&&(t=r=w);
|
||||
var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=ku(),xu(n+r*(t-n+fu("1e-"+((r+"").length-1))),t)):Rt(n,t)},Nn.reduce=lo,Nn.reduceRight=so,Nn.repeat=Ue,Nn.result=function(n,t,r){var e=null==n?w:n[t];return e===w&&(null==n||Wr(t,n)||(t=Dr(t),n=1==t.length?n:yt(n,Et(t,0,-1)),e=null==n?w:n[Zr(t)]),e=e===w?r:e),ve(e)?e.call(n):e},Nn.round=ei,Nn.runInContext=m,Nn.size=function(n){var t=n?Bu(n):0;
|
||||
return Sr(t)?t:zo(n).length},Nn.snakeCase=Yo,Nn.some=ie,Nn.sortedIndex=Zu,Nn.sortedLastIndex=Yu,Nn.startCase=Go,Nn.startsWith=function(n,t,r){return n=u(n),r=null==r?0:xu(0>r?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Nn.sum=function(n,t,r){if(r&&Ur(n,t,r)&&(t=w),t=wr(t,r,3),1==t.length){n=Oo(n)?n:zr(n),r=n.length;for(var e=0;r--;)e+=+t(n[r])||0;n=e}else n=$t(n,t);return n},Nn.template=function(n,t,r){var e=Nn.templateSettings;r&&Ur(n,t,r)&&(t=r=w),n=u(n),t=nt(tt({},r||t),e,Qn),r=nt(tt({},t.imports),e.imports,Qn);
|
||||
var o,i,f=zo(r),a=Ft(r,f),c=0;r=t.interpolate||Cn;var l="__p+='";r=Ze((t.escape||Cn).source+"|"+r.source+"|"+(r===gn?jn:Cn).source+"|"+(t.evaluate||Cn).source+"|$","g");var p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Un,s),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(fn,""):l).replace(an,"$1").replace(cn,"$1;"),
|
||||
l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=Jo(function(){return qe(f,p+"return "+l).apply(w,a)}),t.source=l,_e(t))throw t;return t},Nn.trim=We,Nn.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?Ur(e,t,r):null==t)?g(n):o(n,t+"")):n},Nn.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?Ur(e,t,r):null==t)?n.slice(0,y(n)+1):n.slice(0,i(n,t+"")+1):n;
|
||||
},Nn.trunc=function(n,t,r){r&&Ur(n,t,r)&&(t=w);var e=U;if(r=W,null!=t)if(ge(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==o)return t+r;if(we(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Ze(o.source,(kn.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o),
|
||||
-1<o&&(t=t.slice(0,o)));return t+r},Nn.unescape=function(n){return(n=u(n))&&pn.test(n)?n.replace(ln,d):n},Nn.uniqueId=function(n){var t=++tu;return u(n)+t},Nn.words=$e,Nn.all=te,Nn.any=ie,Nn.contains=ee,Nn.eq=he,Nn.detect=ro,Nn.foldl=lo,Nn.foldr=so,Nn.head=Kr,Nn.include=ee,Nn.inject=lo,Te(Nn,function(){var n={};return _t(Nn,function(t,r){Nn.prototype[r]||(n[r]=t)}),n}(),false),Nn.sample=oe,Nn.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return oe(t,n)}):oe(this.value());
|
||||
},Nn.VERSION=b,Pn("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Nn[n].placeholder=Nn}),Pn(["drop","take"],function(n,t){zn.prototype[n]=function(r){var e=this.__filtered__;if(e&&!t)return new zn(this);r=null==r?1:bu(yu(r)||0,0);var u=this.clone();return e?u.__takeCount__=xu(u.__takeCount__,r):u.__views__.push({size:r,type:n+(0>u.__dir__?"Right":"")}),u},zn.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),Pn(["filter","map","takeWhile"],function(n,t){
|
||||
var r=t+1,e=r!=T;zn.prototype[n]=function(n,t){var u=this.clone();return u.__iteratees__.push({iteratee:wr(n,t,1),type:r}),u.__filtered__=u.__filtered__||e,u}}),Pn(["first","last"],function(n,t){var r="take"+(t?"Right":"");zn.prototype[n]=function(){return this[r](1).value()[0]}}),Pn(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");zn.prototype[n]=function(){return this.__filtered__?new zn(this):this[r](1)}}),Pn(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?bt:ze;zn.prototype[n]=function(n){
|
||||
return this[r](e(n))}}),zn.prototype.compact=function(){return this.filter(Fe)},zn.prototype.reject=function(n,t){return n=wr(n,t,1),this.filter(function(t){return!n(t)})},zn.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=this;return r.__filtered__&&(0<n||0>t)?new zn(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==w&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r)},zn.prototype.takeRightWhile=function(n,t){return this.reverse().takeWhile(n,t).reverse()},zn.prototype.toArray=function(){return this.take(Ru);
|
||||
},_t(zn.prototype,function(n,t){var r=/^(?:filter|map|reject)|While$/.test(t),e=/^(?:first|last)$/.test(t),u=Nn[e?"take"+("last"==t?"Right":""):t];u&&(Nn.prototype[t]=function(){function t(n){return e&&i?u(n,1)[0]:u.apply(w,Jn([n],o))}var o=e?[1]:arguments,i=this.__chain__,f=this.__wrapped__,a=!!this.__actions__.length,c=f instanceof zn,l=o[0],s=c||Oo(f);return s&&r&&typeof l=="function"&&1!=l.length&&(c=s=false),l={func:ne,args:[t],thisArg:w},a=c&&!a,e&&!i?a?(f=f.clone(),f.__actions__.push(l),n.call(f)):u.call(w,this.value())[0]:!e&&s?(f=a?f:new zn(this),
|
||||
f=n.apply(f,o),f.__actions__.push(l),new Ln(f,i)):this.thru(t)})}),Pn("join pop push replace shift sort splice split unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?He:Je)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|replace|shift)$/.test(n);Nn.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),_t(zn.prototype,function(n,t){var r=Nn[t];if(r){var e=r.name;(Wu[e]||(Wu[e]=[])).push({
|
||||
name:t,func:r})}}),Wu[sr(w,A).name]=[{name:"wrapper",func:w}],zn.prototype.clone=function(){var n=new zn(this.__wrapped__);return n.__actions__=qn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=qn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=qn(this.__views__),n},zn.prototype.reverse=function(){if(this.__filtered__){var n=new zn(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},zn.prototype.value=function(){
|
||||
var n,t=this.__wrapped__.value(),r=this.__dir__,e=Oo(t),u=0>r,o=e?t.length:0;n=o;for(var i=this.__views__,f=0,a=-1,c=i.length;++a<c;){var l=i[a],s=l.size;switch(l.type){case"drop":f+=s;break;case"dropRight":n-=s;break;case"take":n=xu(n,f+s);break;case"takeRight":f=bu(f,n-s)}}if(n={start:f,end:n},i=n.start,f=n.end,n=f-i,i=u?f:i-1,f=this.__iteratees__,a=f.length,c=0,l=xu(n,this.__takeCount__),!e||o<F||o==n&&l==n)return Tt(u&&e?t.reverse():t,this.__actions__);e=[];n:for(;n--&&c<l;){for(i+=r,u=-1,o=t[i];++u<a;){
|
||||
var p=f[u],s=p.type,p=p.iteratee(o);if(s==T)o=p;else if(!p){if(s==N)continue n;break n}}e[c++]=o}return e},Nn.prototype.chain=function(){return Qr(this)},Nn.prototype.commit=function(){return new Ln(this.value(),this.__chain__)},Nn.prototype.concat=Qu,Nn.prototype.plant=function(n){for(var t,r=this;r instanceof Tn;){var e=Mr(r);t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},Nn.prototype.reverse=function(){function n(n){return r&&0>r.__dir__?n:n.reverse()}var t=this.__wrapped__;
|
||||
if(t instanceof zn){var r=t;return this.__actions__.length&&(r=new zn(this)),r=r.reverse(),r.__actions__.push({func:ne,args:[n],thisArg:w}),new Ln(r,this.__chain__)}return this.thru(n)},Nn.prototype.toString=function(){return this.value()+""},Nn.prototype.run=Nn.prototype.toJSON=Nn.prototype.valueOf=Nn.prototype.value=function(){return Tt(this.__wrapped__,this.__actions__)},Nn.prototype.collect=Nn.prototype.map,Nn.prototype.head=Nn.prototype.first,Nn.prototype.select=Nn.prototype.filter,Nn.prototype.tail=Nn.prototype.rest,
|
||||
Nn}var w,b="3.10.0",x=1,A=2,j=4,k=8,I=16,R=32,O=64,E=128,C=256,U=30,W="...",$=150,S=16,F=200,N=1,T=2,L="Expected a function",z="__lodash_placeholder__",B="[object Arguments]",D="[object Array]",M="[object Boolean]",q="[object Date]",P="[object Error]",K="[object Function]",V="[object Number]",Z="[object Object]",Y="[object RegExp]",G="[object String]",J="[object ArrayBuffer]",X="[object Float32Array]",H="[object Float64Array]",Q="[object Int8Array]",nn="[object Int16Array]",tn="[object Int32Array]",rn="[object Uint8Array]",en="[object Uint8ClampedArray]",un="[object Uint16Array]",on="[object Uint32Array]",fn=/\b__p\+='';/g,an=/\b(__p\+=)''\+/g,cn=/(__e\(.*?\)|\b__t\))\+'';/g,ln=/&(?:amp|lt|gt|quot|#39|#96);/g,sn=/[&<>"'`]/g,pn=RegExp(ln.source),hn=RegExp(sn.source),_n=/<%-([\s\S]+?)%>/g,vn=/<%([\s\S]+?)%>/g,gn=/<%=([\s\S]+?)%>/g,yn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,dn=/^\w*$/,mn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,wn=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,bn=RegExp(wn.source),xn=/[\u0300-\u036f\ufe20-\ufe23]/g,An=/\\(\\)?/g,jn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,kn=/\w*$/,In=/^0[xX]/,Rn=/^\[object .+?Constructor\]$/,On=/^\d+$/,En=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Cn=/($^)/,Un=/['\n\r\u2028\u2029\\]/g,Wn=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),$n="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout isFinite parseFloat parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap".split(" "),Sn={};
|
||||
Sn[X]=Sn[H]=Sn[Q]=Sn[nn]=Sn[tn]=Sn[rn]=Sn[en]=Sn[un]=Sn[on]=true,Sn[B]=Sn[D]=Sn[J]=Sn[M]=Sn[q]=Sn[P]=Sn[K]=Sn["[object Map]"]=Sn[V]=Sn[Z]=Sn[Y]=Sn["[object Set]"]=Sn[G]=Sn["[object WeakMap]"]=false;var Fn={};Fn[B]=Fn[D]=Fn[J]=Fn[M]=Fn[q]=Fn[X]=Fn[H]=Fn[Q]=Fn[nn]=Fn[tn]=Fn[V]=Fn[Z]=Fn[Y]=Fn[G]=Fn[rn]=Fn[en]=Fn[un]=Fn[on]=true,Fn[P]=Fn[K]=Fn["[object Map]"]=Fn["[object Set]"]=Fn["[object WeakMap]"]=false;var Nn={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a",
|
||||
"\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y",
|
||||
"\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Tn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ln={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},zn={"function":true,object:true},Bn={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Dn={"\\":"\\",
|
||||
"'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mn=zn[typeof exports]&&exports&&!exports.nodeType&&exports,qn=zn[typeof module]&&module&&!module.nodeType&&module,Pn=zn[typeof self]&&self&&self.Object&&self,Kn=zn[typeof window]&&window&&window.Object&&window,Vn=qn&&qn.exports===Mn&&Mn,Zn=Mn&&qn&&typeof global=="object"&&global&&global.Object&&global||Kn!==(this&&this.window)&&Kn||Pn||this,Yn=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Zn._=Yn, define(function(){
|
||||
return Yn})):Mn&&qn?Vn?(qn.exports=Yn)._=Yn:Mn._=Yn:Zn._=Yn}).call(this);
|
||||
67
package.json
67
package.json
@@ -1,33 +1,48 @@
|
||||
{
|
||||
"name": "lodash",
|
||||
"version": "3.10.0",
|
||||
"main": "lodash.src.js",
|
||||
"version": "4.1.0",
|
||||
"main": "lodash.js",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"curl-amd": "0.8.12",
|
||||
"dojo": "~1.10.0",
|
||||
"jquery": "~1.11.0",
|
||||
"platform": "~1.3.0",
|
||||
"qunit-extras": "~1.4.0",
|
||||
"qunitjs": "~1.18.0",
|
||||
"requirejs": "~2.1.0"
|
||||
"async": "^1.5.2",
|
||||
"chalk": "^1.1.1",
|
||||
"codecov.io": "~0.1.6",
|
||||
"coveralls": "^2.11.6",
|
||||
"curl-amd": "~0.8.12",
|
||||
"docdown": "~0.4.0",
|
||||
"dojo": "^1.10.4",
|
||||
"ecstatic": "^1.4.0",
|
||||
"fs-extra": "~0.26.5",
|
||||
"glob": "^6.0.4",
|
||||
"istanbul": "0.4.2",
|
||||
"jquery": "^2.2.0",
|
||||
"jscs": "^2.9.0",
|
||||
"lodash": "^3.10.1",
|
||||
"platform": "^1.3.1",
|
||||
"qunit-extras": "^1.4.5",
|
||||
"qunitjs": "~1.20.0",
|
||||
"request": "^2.69.0",
|
||||
"requirejs": "^2.1.22",
|
||||
"sauce-tunnel": "2.3.0",
|
||||
"uglify-js": "2.6.1",
|
||||
"webpack": "^1.12.12"
|
||||
},
|
||||
"volo": {
|
||||
"type": "directory",
|
||||
"ignore": [
|
||||
".*",
|
||||
"*.custom.*",
|
||||
"*.log",
|
||||
"*.map",
|
||||
"*.md",
|
||||
"lodash.src.js",
|
||||
"bower.json",
|
||||
"component.json",
|
||||
"doc",
|
||||
"node_modules",
|
||||
"perf",
|
||||
"test",
|
||||
"vendor"
|
||||
]
|
||||
"scripts": {
|
||||
"build": "npm run build:main & npm run build:fp",
|
||||
"build:fp": "node lib/fp/build-dist.js",
|
||||
"build:fp-modules": "node lib/fp/build-modules.js",
|
||||
"build:main": "node lib/main/build-dist.js",
|
||||
"build:main-modules": "node lib/main/build-modules.js",
|
||||
"doc": "node lib/doc/build github",
|
||||
"doc:site": "node lib/doc/build site",
|
||||
"pretest": "npm run build",
|
||||
"style": "npm run style:main & npm run style:fp & npm run style:perf & npm run style:test",
|
||||
"style:fp": "jscs fp/*.js lib/**/*.js",
|
||||
"style:main": "jscs lodash.js",
|
||||
"style:perf": "jscs perf/*.js perf/**/*.js",
|
||||
"style:test": "jscs test/*.js test/**/*.js",
|
||||
"test": "npm run test:main && npm run test:fp",
|
||||
"test:fp": "node test/test-fp",
|
||||
"test:main": "node test/test"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,7 @@
|
||||
span1.innerHTML =
|
||||
'<label for="perf-build">Build: </label>' +
|
||||
'<select id="perf-build">' +
|
||||
'<option value="lodash-compat">lodash (compat)</option>' +
|
||||
'<option value="lodash-modern">lodash (modern)</option>' +
|
||||
'<option value="lodash-custom-dev">lodash (custom development)</option>' +
|
||||
'<option value="lodash-custom">lodash (custom production)</option>' +
|
||||
'<option value="lodash">lodash</option>' +
|
||||
'</select>';
|
||||
|
||||
var span2 = document.createElement('span');
|
||||
@@ -71,10 +68,7 @@
|
||||
'<select id="perf-other">' +
|
||||
'<option value="underscore-dev">Underscore (development)</option>' +
|
||||
'<option value="underscore">Underscore (production)</option>' +
|
||||
'<option value="lodash-compat">lodash (compat)</option>' +
|
||||
'<option value="lodash-modern">lodash (modern)</option>' +
|
||||
'<option value="lodash-custom-dev">lodash (custom development)</option>' +
|
||||
'<option value="lodash-custom">lodash (custom production)</option>' +
|
||||
'<option value="lodash">lodash</option>' +
|
||||
'</select>';
|
||||
|
||||
var buildList = span1.lastChild,
|
||||
@@ -86,11 +80,8 @@
|
||||
|
||||
buildList.selectedIndex = (function() {
|
||||
switch (build) {
|
||||
case 'lodash-compat': return 0;
|
||||
case 'lodash-custom-dev': return 2;
|
||||
case 'lodash-custom': return 3;
|
||||
case 'lodash-modern':
|
||||
case null: return 1;
|
||||
case 'lodash':
|
||||
case null: return 0;
|
||||
}
|
||||
return -1;
|
||||
}());
|
||||
@@ -98,10 +89,7 @@
|
||||
otherList.selectedIndex = (function() {
|
||||
switch (other) {
|
||||
case 'underscore-dev': return 0;
|
||||
case 'lodash-compat': return 2;
|
||||
case 'lodash-modern': return 3;
|
||||
case 'lodash-custom-dev': return 4;
|
||||
case 'lodash-custom': return 5;
|
||||
case 'lodash': return 2;
|
||||
case 'underscore':
|
||||
case null: return 1;
|
||||
}
|
||||
@@ -116,11 +104,8 @@
|
||||
ui.buildPath = (function() {
|
||||
var result;
|
||||
switch (build) {
|
||||
case 'lodash-compat': result = 'lodash.compat.min.js'; break;
|
||||
case 'lodash-custom-dev': result = 'lodash.custom.js'; break;
|
||||
case 'lodash-custom': result = 'lodash.custom.min.js'; break;
|
||||
case null: build = 'lodash-modern';
|
||||
case 'lodash-modern': result = 'lodash.min.js'; break;
|
||||
case null: build = 'lodash';
|
||||
case 'lodash': result = 'dist/lodash.min.js'; break;
|
||||
default: return build;
|
||||
}
|
||||
return basePath + result;
|
||||
@@ -130,10 +115,7 @@
|
||||
ui.otherPath = (function() {
|
||||
var result;
|
||||
switch (other) {
|
||||
case 'lodash-compat': result = 'lodash.compat.min.js'; break;
|
||||
case 'lodash-modern': result = 'lodash.min.js'; break;
|
||||
case 'lodash-custom-dev': result = 'lodash.custom.js'; break;
|
||||
case 'lodash-custom': result = 'lodash.custom.min.js'; break;
|
||||
case 'lodash': result = 'dist/lodash.min.js'; break;
|
||||
case 'underscore-dev': result = 'vendor/underscore/underscore.js'; break;
|
||||
case null: other = 'underscore';
|
||||
case 'underscore': result = 'vendor/underscore/underscore-min.js'; break;
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
applet {
|
||||
position: absolute;
|
||||
left: -9999em;
|
||||
}
|
||||
#FirebugUI {
|
||||
top: 2em;
|
||||
}
|
||||
@@ -29,7 +25,7 @@
|
||||
<body>
|
||||
<div id="perf-toolbar"></div>
|
||||
<script src="../node_modules/platform/platform.js"></script>
|
||||
<script src="../lodash.src.js"></script>
|
||||
<script src="../lodash.js"></script>
|
||||
<script src="../vendor/benchmark.js/benchmark.js"></script>
|
||||
<script src="../vendor/firebug-lite/src/firebug-lite-debug.js"></script>
|
||||
<script src="./asset/perf-ui.js"></script>
|
||||
@@ -66,15 +62,6 @@
|
||||
setTimeout(run, 15);
|
||||
}
|
||||
|
||||
// is the applet permitted?
|
||||
if (!/[?&]nojava=true(?:&|$)/.test(location.search)) {
|
||||
// is the applet really needed?
|
||||
while (!(measured = new Date - begin)) {}
|
||||
if (measured > 1 && !((perfNow = window.performance) && typeof (perfNow.now || perfNow.webkitNow) == 'function')) {
|
||||
// load applet
|
||||
document.write('<applet code="nano" archive="../vendor/benchmark.js/nano.jar"></applet>');
|
||||
}
|
||||
}
|
||||
window.onload = init;
|
||||
}());
|
||||
</script>
|
||||
|
||||
504
perf/perf.js
504
perf/perf.js
@@ -38,16 +38,16 @@
|
||||
result = params;
|
||||
}
|
||||
var last = result[result.length - 1];
|
||||
result = (result.length > min && !/perf(?:\.js)?$/.test(last)) ? last : '../lodash.src.js';
|
||||
result = (result.length > min && !/perf(?:\.js)?$/.test(last)) ? last : '../lodash.js';
|
||||
|
||||
if (!amd) {
|
||||
try {
|
||||
result = require('fs').realpathSync(result);
|
||||
} catch(e) {}
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
result = require.resolve(result);
|
||||
} catch(e) {}
|
||||
} catch (e) {}
|
||||
}
|
||||
return result;
|
||||
}());
|
||||
@@ -88,13 +88,10 @@
|
||||
/** Detect if in a browser environment. */
|
||||
var isBrowser = isHostType(root, 'document') && isHostType(root, 'navigator');
|
||||
|
||||
/** Detect if in a Java environment. */
|
||||
var isJava = !isBrowser && /Java/.test(toString.call(root.java));
|
||||
|
||||
/** Use a single "load" function. */
|
||||
var load = (typeof require == 'function' && !amd)
|
||||
? require
|
||||
: (isJava && root.load) || noop;
|
||||
: noop;
|
||||
|
||||
/** Load lodash. */
|
||||
var lodash = root.lodash || (root.lodash = (
|
||||
@@ -104,6 +101,12 @@
|
||||
lodash.noConflict()
|
||||
));
|
||||
|
||||
/** Load Underscore. */
|
||||
var _ = root.underscore || (root.underscore = (
|
||||
_ = load('../vendor/underscore/underscore.js') || root._,
|
||||
_._ || _
|
||||
));
|
||||
|
||||
/** Load Benchmark.js. */
|
||||
var Benchmark = root.Benchmark || (root.Benchmark = (
|
||||
Benchmark = load('../vendor/benchmark.js/benchmark.js') || root.Benchmark,
|
||||
@@ -111,12 +114,6 @@
|
||||
Benchmark.runInContext(lodash.extend({}, root, { '_': lodash }))
|
||||
));
|
||||
|
||||
/** Load Underscore. */
|
||||
var _ = root._ || (root._ = (
|
||||
_ = load('../vendor/underscore/underscore.js') || root._,
|
||||
_._ || _
|
||||
));
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@@ -205,7 +202,7 @@
|
||||
fbPanel.getElementById('fbPanel1');
|
||||
|
||||
log('\nSit back and relax, this may take a while.');
|
||||
suites[0].run({ 'async': !isJava });
|
||||
suites[0].run({ 'async': true });
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -258,7 +255,7 @@
|
||||
|
||||
if (suites.length) {
|
||||
// Run next suite.
|
||||
suites[0].run({ 'async': !isJava });
|
||||
suites[0].run({ 'async': true });
|
||||
}
|
||||
else {
|
||||
var aMeanHz = getGeometricMean(score.a),
|
||||
@@ -284,7 +281,7 @@
|
||||
lodash.extend(Benchmark.options, {
|
||||
'async': true,
|
||||
'setup': '\
|
||||
var _ = global._,\
|
||||
var _ = global.underscore,\
|
||||
lodash = global.lodash,\
|
||||
belt = this.name == buildName ? lodash : _;\
|
||||
\
|
||||
@@ -351,8 +348,8 @@
|
||||
square = function(v) { return v * v; };\
|
||||
\
|
||||
var largeArray = belt.range(10000),\
|
||||
_chaining = _.chain ? _(largeArray).chain() : _(largeArray),\
|
||||
lodashChaining = lodash(largeArray);\
|
||||
_chaining = _(largeArray).chain(),\
|
||||
lodashChaining = lodash(largeArray).chain();\
|
||||
}\
|
||||
if (typeof compact != "undefined") {\
|
||||
var uncompacted = numbers.slice();\
|
||||
@@ -360,13 +357,13 @@
|
||||
uncompacted[6] = null;\
|
||||
uncompacted[18] = "";\
|
||||
}\
|
||||
if (typeof compose != "undefined") {\
|
||||
if (typeof flowRight != "undefined") {\
|
||||
var compAddOne = function(n) { return n + 1; },\
|
||||
compAddTwo = function(n) { return n + 2; },\
|
||||
compAddThree = function(n) { return n + 3; };\
|
||||
\
|
||||
var _composed = _.compose(compAddThree, compAddTwo, compAddOne),\
|
||||
lodashComposed = lodash.compose(compAddThree, compAddTwo, compAddOne);\
|
||||
var _composed = _.flowRight && _.flowRight(compAddThree, compAddTwo, compAddOne),\
|
||||
lodashComposed = lodash.flowRight && lodash.flowRight(compAddThree, compAddTwo, compAddOne);\
|
||||
}\
|
||||
if (typeof countBy != "undefined" || typeof omit != "undefined") {\
|
||||
var wordToNumber = {\
|
||||
@@ -461,11 +458,8 @@
|
||||
if (typeof matches != "undefined") {\
|
||||
var source = { "num": 9 };\
|
||||
\
|
||||
var _findWhere = _.findWhere || _.find,\
|
||||
_matcher = (_.matches || _.createCallback || _.noop)(source);\
|
||||
\
|
||||
var lodashFindWhere = lodash.findWhere || lodash.find,\
|
||||
lodashMatcher = (lodash.matches || lodash.createCallback || lodash.noop)(source);\
|
||||
var _matcher = (_.matches || _.noop)(source),\
|
||||
lodashMatcher = (lodash.matches || lodash.noop)(source);\
|
||||
}\
|
||||
if (typeof multiArrays != "undefined") {\
|
||||
var twentyValues = belt.shuffle(belt.range(20)),\
|
||||
@@ -645,25 +639,13 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.bindAll` iterating arguments')
|
||||
Benchmark.Suite('`_.bindAll`')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.bindAll.apply(lodash, [bindAllObjects[++bindAllCount]].concat(funcNames))',
|
||||
'fn': 'lodash.bindAll(bindAllObjects[++bindAllCount], funcNames)',
|
||||
'teardown': 'function bindAll(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.bindAll.apply(_, [bindAllObjects[++bindAllCount]].concat(funcNames))',
|
||||
'teardown': 'function bindAll(){}'
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.bindAll` iterating the `object`')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.bindAll(bindAllObjects[++bindAllCount])',
|
||||
'teardown': 'function bindAll(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.bindAll(bindAllObjects[++bindAllCount])',
|
||||
'fn': '_.bindAll(bindAllObjects[++bindAllCount], funcNames)',
|
||||
'teardown': 'function bindAll(){}'
|
||||
})
|
||||
);
|
||||
@@ -706,32 +688,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.compose`')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.compose(compAddThree, compAddTwo, compAddOne)',
|
||||
'teardown': 'function compose(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.compose(compAddThree, compAddTwo, compAddOne)',
|
||||
'teardown': 'function compose(){}'
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('composed call')
|
||||
.add(buildName, {
|
||||
'fn': 'lodashComposed(0)',
|
||||
'teardown': 'function compose(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_composed(0)',
|
||||
'teardown': 'function compose(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.countBy` with `callback` iterating an array')
|
||||
.add(buildName, '\
|
||||
@@ -832,22 +788,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.each` iterating an array with `thisArg` (slow path)')
|
||||
.add(buildName, '\
|
||||
var result = [];\
|
||||
lodash.each(numbers, function(num, index) {\
|
||||
result.push(num + this["key" + index]);\
|
||||
}, object)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
var result = [];\
|
||||
_.each(numbers, function(num, index) {\
|
||||
result.push(num + this["key" + index]);\
|
||||
}, object)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.each` iterating an object')
|
||||
.add(buildName, '\
|
||||
@@ -910,20 +850,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.filter` iterating an array with `thisArg` (slow path)')
|
||||
.add(buildName, '\
|
||||
lodash.filter(numbers, function(num, index) {\
|
||||
return this["key" + index] % 2;\
|
||||
}, object)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.filter(numbers, function(num, index) {\
|
||||
return this["key" + index] % 2;\
|
||||
}, object)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.filter` iterating an object')
|
||||
.add(buildName, '\
|
||||
@@ -938,6 +864,18 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.filter` with `_.matches` shorthand')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.filter(objects, source)',
|
||||
'teardown': 'function matches(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.filter(objects, source)',
|
||||
'teardown': 'function matches(){}'
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.filter` with `_.matches` predicate')
|
||||
.add(buildName, {
|
||||
@@ -981,19 +919,17 @@
|
||||
);
|
||||
|
||||
// Avoid Underscore induced `OutOfMemoryError` in Rhino and Ringo.
|
||||
if (!isJava) {
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.find` with `_.matches` shorthand')
|
||||
.add(buildName, {
|
||||
'fn': 'lodashFindWhere(objects, source)',
|
||||
'teardown': 'function matches(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_findWhere(objects, source)',
|
||||
'teardown': 'function matches(){}'
|
||||
})
|
||||
);
|
||||
}
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.find` with `_.matches` shorthand')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.find(objects, source)',
|
||||
'teardown': 'function matches(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.find(objects, source)',
|
||||
'teardown': 'function matches(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@@ -1009,32 +945,60 @@
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.flatten` nested arrays of numbers with `isDeep`')
|
||||
Benchmark.Suite('`_.flattenDeep` nested arrays of numbers')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.flatten(nestedNumbers, lodashFlattenDeep)',
|
||||
'fn': 'lodash.flattenDeep(nestedNumbers)',
|
||||
'teardown': 'function flatten(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.flatten(nestedNumbers, _flattenDeep)',
|
||||
'fn': '_.flattenDeep(nestedNumbers)',
|
||||
'teardown': 'function flatten(){}'
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.flatten` nest arrays of objects with `isDeep`')
|
||||
Benchmark.Suite('`_.flattenDeep` nest arrays of objects')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.flatten(nestedObjects, lodashFlattenDeep)',
|
||||
'fn': 'lodash.flattenDeep(nestedObjects)',
|
||||
'teardown': 'function flatten(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.flatten(nestedObjects, _flattenDeep)',
|
||||
'fn': '_.flattenDeep(nestedObjects)',
|
||||
'teardown': 'function flatten(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.flowRight`')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.flowRight(compAddThree, compAddTwo, compAddOne)',
|
||||
'teardown': 'function flowRight(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.flowRight(compAddThree, compAddTwo, compAddOne)',
|
||||
'teardown': 'function flowRight(){}'
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('composed call')
|
||||
.add(buildName, {
|
||||
'fn': 'lodashComposed(0)',
|
||||
'teardown': 'function flowRight(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_composed(0)',
|
||||
'teardown': 'function flowRight(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.functions`')
|
||||
.add(buildName, '\
|
||||
@@ -1086,73 +1050,37 @@
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.includes` searching an array')
|
||||
.add(buildName, '\
|
||||
lodash.include(numbers, limit - 1)'
|
||||
lodash.includes(numbers, limit - 1)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.include(numbers, limit - 1)'
|
||||
_.includes(numbers, limit - 1)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.includes` searching an object')
|
||||
.add(buildName, '\
|
||||
lodash.include(object, limit - 1)'
|
||||
lodash.includes(object, limit - 1)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.include(object, limit - 1)'
|
||||
_.includes(object, limit - 1)'
|
||||
)
|
||||
);
|
||||
|
||||
if (lodash.include('ab', 'ab') && _.include('ab', 'ab')) {
|
||||
if (lodash.includes('ab', 'ab') && _.includes('ab', 'ab')) {
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.includes` searching a string')
|
||||
.add(buildName, '\
|
||||
lodash.include(strNumbers, "," + (limit - 1))'
|
||||
lodash.includes(strNumbers, "," + (limit - 1))'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.include(strNumbers, "," + (limit - 1))'
|
||||
_.includes(strNumbers, "," + (limit - 1))'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.indexBy` with `callback` iterating an array')
|
||||
.add(buildName, '\
|
||||
lodash.indexBy(numbers, function(num) { return num >> 1; })'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.indexBy(numbers, function(num) { return num >> 1; })'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.indexBy` with `property` name iterating an array')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.indexBy(words, "length")',
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.indexBy(words, "length")',
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.indexBy` with `callback` iterating an object')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.indexBy(wordToNumber, function(num) { return num >> 1; })',
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.indexBy(wordToNumber, function(num) { return num >> 1; })',
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.indexOf`')
|
||||
.add(buildName, {
|
||||
@@ -1165,18 +1093,6 @@
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.indexOf` performing a binary search')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.indexOf(hundredSortedValues, 99, true)',
|
||||
'teardown': 'function multiArrays(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.indexOf(hundredSortedValues, 99, true)',
|
||||
'teardown': 'function multiArrays(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
@@ -1216,42 +1132,42 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.invoke` iterating an array')
|
||||
Benchmark.Suite('`_.invokeMap` iterating an array')
|
||||
.add(buildName, '\
|
||||
lodash.invoke(numbers, "toFixed")'
|
||||
lodash.invokeMap(numbers, "toFixed")'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.invoke(numbers, "toFixed")'
|
||||
_.invokeMap(numbers, "toFixed")'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.invoke` with arguments iterating an array')
|
||||
Benchmark.Suite('`_.invokeMap` with arguments iterating an array')
|
||||
.add(buildName, '\
|
||||
lodash.invoke(numbers, "toFixed", 1)'
|
||||
lodash.invokeMap(numbers, "toFixed", 1)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.invoke(numbers, "toFixed", 1)'
|
||||
_.invokeMap(numbers, "toFixed", 1)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.invoke` with a function for `path` iterating an array')
|
||||
Benchmark.Suite('`_.invokeMap` with a function for `path` iterating an array')
|
||||
.add(buildName, '\
|
||||
lodash.invoke(numbers, Number.prototype.toFixed, 1)'
|
||||
lodash.invokeMap(numbers, Number.prototype.toFixed, 1)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.invoke(numbers, Number.prototype.toFixed, 1)'
|
||||
_.invokeMap(numbers, Number.prototype.toFixed, 1)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.invoke` iterating an object')
|
||||
Benchmark.Suite('`_.invokeMap` iterating an object')
|
||||
.add(buildName, '\
|
||||
lodash.invoke(object, "toFixed", 1)'
|
||||
lodash.invokeMap(object, "toFixed", 1)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.invoke(object, "toFixed", 1)'
|
||||
_.invokeMap(object, "toFixed", 1)'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1413,18 +1329,6 @@
|
||||
})
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.lastIndexOf` performing a binary search')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.lastIndexOf(hundredSortedValues, 0, true)',
|
||||
'teardown': 'function multiArrays(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.lastIndexOf(hundredSortedValues, 0, true)',
|
||||
'teardown': 'function multiArrays(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
@@ -1441,20 +1345,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.map` with `thisArg` iterating an array (slow path)')
|
||||
.add(buildName, '\
|
||||
lodash.map(objects, function(value, index) {\
|
||||
return this["key" + index] + value.num;\
|
||||
}, object)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.map(objects, function(value, index) {\
|
||||
return this["key" + index] + value.num;\
|
||||
}, object)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.map` iterating an object')
|
||||
.add(buildName, '\
|
||||
@@ -1469,6 +1359,16 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.map` with `_.property` shorthand')
|
||||
.add(buildName, '\
|
||||
lodash.map(objects, "num")'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.map(objects, "num")'
|
||||
)
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
@@ -1519,18 +1419,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.pairs`')
|
||||
.add(buildName, '\
|
||||
lodash.pairs(object)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.pairs(object)'
|
||||
)
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.partial` (slow path)')
|
||||
.add(buildName, {
|
||||
@@ -1571,20 +1459,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.partition` iterating an array with `thisArg` (slow path)')
|
||||
.add(buildName, '\
|
||||
lodash.partition(numbers, function(num, index) {\
|
||||
return this["key" + index] % 2;\
|
||||
}, object)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.partition(numbers, function(num, index) {\
|
||||
return this["key" + index] % 2;\
|
||||
}, object)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.partition` iterating an object')
|
||||
.add(buildName, '\
|
||||
@@ -1613,18 +1487,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.pluck`')
|
||||
.add(buildName, '\
|
||||
lodash.pluck(objects, "num")'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.pluck(objects, "num")'
|
||||
)
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.reduce` iterating an array')
|
||||
.add(buildName, '\
|
||||
@@ -1707,20 +1569,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.reject` iterating an array with `thisArg` (slow path)')
|
||||
.add(buildName, '\
|
||||
lodash.reject(numbers, function(num, index) {\
|
||||
return this["key" + index] % 2;\
|
||||
}, object)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.reject(numbers, function(num, index) {\
|
||||
return this["key" + index] % 2;\
|
||||
}, object)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.reject` iterating an object')
|
||||
.add(buildName, '\
|
||||
@@ -1738,12 +1586,12 @@
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.sample` with an `n`')
|
||||
Benchmark.Suite('`_.sampleSize`')
|
||||
.add(buildName, '\
|
||||
lodash.sample(numbers, limit / 2)'
|
||||
lodash.sampleSize(numbers, limit / 2)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.sample(numbers, limit / 2)'
|
||||
_.sampleSize(numbers, limit / 2)'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1787,20 +1635,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.some` with `thisArg` iterating an array (slow path)')
|
||||
.add(buildName, '\
|
||||
lodash.some(objects, function(value, index) {\
|
||||
return this["key" + index] == (limit - 1);\
|
||||
}, object)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.some(objects, function(value, index) {\
|
||||
return this["key" + index] == (limit - 1);\
|
||||
}, object)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.some` iterating an object')
|
||||
.add(buildName, '\
|
||||
@@ -1827,16 +1661,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.sortBy` with `callback` and `thisArg` (slow path)')
|
||||
.add(buildName, '\
|
||||
lodash.sortBy(numbers, function(num) { return this.sin(num); }, Math)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.sortBy(numbers, function(num) { return this.sin(num); }, Math)'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.sortBy` with `property` name')
|
||||
.add(buildName, {
|
||||
@@ -1861,18 +1685,20 @@
|
||||
)
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.sortedIndex` with `callback`')
|
||||
Benchmark.Suite('`_.sortedIndexBy`')
|
||||
.add(buildName, {
|
||||
'fn': '\
|
||||
lodash.sortedIndex(words, "twenty-five", function(value) {\
|
||||
lodash.sortedIndexBy(words, "twenty-five", function(value) {\
|
||||
return wordToNumber[value];\
|
||||
})',
|
||||
'teardown': 'function countBy(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '\
|
||||
_.sortedIndex(words, "twenty-five", function(value) {\
|
||||
_.sortedIndexBy(words, "twenty-five", function(value) {\
|
||||
return wordToNumber[value];\
|
||||
})',
|
||||
'teardown': 'function countBy(){}'
|
||||
@@ -1881,6 +1707,34 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.sortedIndexOf`')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.sortedIndexOf(hundredSortedValues, 99)',
|
||||
'teardown': 'function multiArrays(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.sortedIndexOf(hundredSortedValues, 99)',
|
||||
'teardown': 'function multiArrays(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.sortedLastIndexOf`')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.sortedLastIndexOf(hundredSortedValues, 0)',
|
||||
'teardown': 'function multiArrays(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.sortedLastIndexOf(hundredSortedValues, 0)',
|
||||
'teardown': 'function multiArrays(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.sum`')
|
||||
.add(buildName, '\
|
||||
@@ -1943,18 +1797,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.times` with `thisArg` (slow path)')
|
||||
.add(buildName, '\
|
||||
var result = [];\
|
||||
lodash.times(limit, function(n) { result.push(this.sin(n)); }, Math)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
var result = [];\
|
||||
_.times(limit, function(n) { result.push(this.sin(n)); }, Math)'
|
||||
)
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
@@ -1979,6 +1821,18 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.toPairs`')
|
||||
.add(buildName, '\
|
||||
lodash.toPairs(object)'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.toPairs(object)'
|
||||
)
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.unescape` string without html entities')
|
||||
.add(buildName, '\
|
||||
@@ -2035,20 +1889,6 @@
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.uniq` with `callback`')
|
||||
.add(buildName, '\
|
||||
lodash.uniq(numbers.concat(twoNumbers, fourNumbers), function(num) {\
|
||||
return num % 2;\
|
||||
})'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.uniq(numbers.concat(twoNumbers, fourNumbers), function(num) {\
|
||||
return num % 2;\
|
||||
})'
|
||||
)
|
||||
);
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.uniq` iterating an array of 200 elements')
|
||||
.add(buildName, {
|
||||
@@ -2063,6 +1903,22 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.uniqBy`')
|
||||
.add(buildName, '\
|
||||
lodash.uniqBy(numbers.concat(twoNumbers, fourNumbers), function(num) {\
|
||||
return num % 2;\
|
||||
})'
|
||||
)
|
||||
.add(otherName, '\
|
||||
_.uniqBy(numbers.concat(twoNumbers, fourNumbers), function(num) {\
|
||||
return num % 2;\
|
||||
})'
|
||||
)
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.values`')
|
||||
.add(buildName, '\
|
||||
@@ -2075,20 +1931,6 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.where`')
|
||||
.add(buildName, {
|
||||
'fn': 'lodash.where(objects, source)',
|
||||
'teardown': 'function matches(){}'
|
||||
})
|
||||
.add(otherName, {
|
||||
'fn': '_.where(objects, source)',
|
||||
'teardown': 'function matches(){}'
|
||||
})
|
||||
);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
suites.push(
|
||||
Benchmark.Suite('`_.without`')
|
||||
.add(buildName, '\
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
echo "Running performance suite in node..."
|
||||
node perf.js ../lodash.js && node perf.js ../lodash.min.js
|
||||
|
||||
for cmd in rhino "rhino -require" narwhal ringo phantomjs; do
|
||||
echo ""
|
||||
echo "Running performance suite in $cmd..."
|
||||
$cmd perf.js ../lodash.src.js
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Running performance suite in a browser..."
|
||||
open index.html
|
||||
@@ -1,157 +0,0 @@
|
||||
;(function() {
|
||||
|
||||
/** Used to determine if values are of the language type Object. */
|
||||
var objectTypes = {
|
||||
'function': true,
|
||||
'object': true
|
||||
};
|
||||
|
||||
/** Used as the `Set#toString` return value. */
|
||||
var nativeString = String(Object.prototype.toString).replace(/toString/g, 'Set');
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
|
||||
|
||||
/** Detect free variable `self`. */
|
||||
var freeSelf = objectTypes[typeof self] && self && self.Object && self;
|
||||
|
||||
/** Detect free variable `window`. */
|
||||
var freeWindow = objectTypes[typeof window] && window && window.Object && window;
|
||||
|
||||
/**
|
||||
* Used as a reference to the global object.
|
||||
*
|
||||
* The `this` value is used if it is the global object to avoid Greasemonkey's
|
||||
* restricted `window` object, otherwise the `window` object is used.
|
||||
*/
|
||||
var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Installs `Set` on the given `context` object.
|
||||
*
|
||||
* @memberOf exports
|
||||
* @param {Object} context The context object.
|
||||
*/
|
||||
function runInContext(context) {
|
||||
|
||||
/**
|
||||
* Creates a `Set` object.
|
||||
*/
|
||||
function Set() {
|
||||
this.__cache__ = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index at which the first occurrence of `value` is found using
|
||||
* strict equality for comparisons, i.e. `===`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @param {*} value The value to search for.
|
||||
* @returns {number} Returns the index of the matched value or `-1`.
|
||||
*/
|
||||
function indexOf(array, value) {
|
||||
var index = -1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is in the set.
|
||||
*
|
||||
* @memberOf Set
|
||||
* @param {*} value The value to search for.
|
||||
* @returns {boolean} Returns `true` if `value` is found, else `false`.
|
||||
*/
|
||||
function has(value) {
|
||||
var type = typeof value,
|
||||
cache = this.__cache__;
|
||||
|
||||
if (type == 'boolean' || value == null) {
|
||||
return cache[value] || false;
|
||||
}
|
||||
if (type != 'number' && type != 'string') {
|
||||
type = 'object';
|
||||
}
|
||||
var key = type == 'number' ? value : '_' + value;
|
||||
cache = (cache = cache[type]) && cache[key];
|
||||
|
||||
return type == 'object'
|
||||
? (cache && indexOf(cache, value) > -1 ? true : false)
|
||||
: (cache || false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds `value` to the set.
|
||||
*
|
||||
* @memberOf Set
|
||||
* @param {*} value The value to add.
|
||||
*/
|
||||
function add(value) {
|
||||
var cache = this.__cache__,
|
||||
type = typeof value;
|
||||
|
||||
if (type == 'boolean' || value == null) {
|
||||
cache[value] = true;
|
||||
} else {
|
||||
if (type != 'number' && type != 'string') {
|
||||
type = 'object';
|
||||
}
|
||||
var key = type == 'number' ? value : '_' + value,
|
||||
typeCache = cache[type] || (cache[type] = {});
|
||||
|
||||
if (type == 'object') {
|
||||
var array = typeCache[key];
|
||||
if (array) {
|
||||
array.push(value);
|
||||
} else {
|
||||
typeCache[key] = [value];
|
||||
}
|
||||
} else {
|
||||
typeCache[key] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces the `toString` result of `Set`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf Set
|
||||
* @returns {string} Returns the string result.
|
||||
*/
|
||||
function toString() {
|
||||
return nativeString;
|
||||
}
|
||||
|
||||
Set.toString = toString;
|
||||
Set.prototype.add = add;
|
||||
Set.prototype.has = has;
|
||||
|
||||
if (!root.Set) {
|
||||
context.Set = Set;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
if (freeExports) {
|
||||
freeExports.runInContext = runInContext;
|
||||
} else {
|
||||
runInContext(root);
|
||||
}
|
||||
}.call(this));
|
||||
@@ -64,12 +64,10 @@
|
||||
|
||||
buildList.selectedIndex = (function() {
|
||||
switch (build) {
|
||||
case 'lodash-compat': return 1;
|
||||
case 'lodash-modern-dev': return 2;
|
||||
case 'lodash-modern': return 3;
|
||||
case 'lodash-custom-dev': return 4;
|
||||
case 'lodash-custom': return 5;
|
||||
case 'lodash-compat-dev':
|
||||
case 'lodash': return 1;
|
||||
case 'lodash-core-dev': return 2;
|
||||
case 'lodash-core': return 3;
|
||||
case 'lodash-dev':
|
||||
case null: return 0;
|
||||
}
|
||||
return -1;
|
||||
@@ -95,12 +93,10 @@
|
||||
span1.innerHTML =
|
||||
'<label for="qunit-build">Build: </label>' +
|
||||
'<select id="qunit-build">' +
|
||||
'<option value="lodash-compat-dev">lodash (compat development)</option>' +
|
||||
'<option value="lodash-compat">lodash (compat production)</option>' +
|
||||
'<option value="lodash-modern-dev">lodash (modern development)</option>' +
|
||||
'<option value="lodash-modern">lodash (modern production)</option>' +
|
||||
'<option value="lodash-custom-dev">lodash (custom development)</option>' +
|
||||
'<option value="lodash-custom">lodash (custom production)</option>' +
|
||||
'<option value="lodash-dev">lodash (development)</option>' +
|
||||
'<option value="lodash">lodash (production)</option>' +
|
||||
'<option value="lodash-core-dev">lodash-core (development)</option>' +
|
||||
'<option value="lodash-core">lodash-core (production)</option>' +
|
||||
'</select>';
|
||||
|
||||
var span2 = document.createElement('span');
|
||||
@@ -124,29 +120,15 @@
|
||||
init();
|
||||
});
|
||||
|
||||
// Used to indicate testing a foreign file.
|
||||
ui.isForeign = RegExp('^(\\w+:)?//').test(build);
|
||||
|
||||
// Used to indicate testing a modularized build.
|
||||
ui.isModularize = /\b(?:amd|commonjs|es6?|node|npm|(index|main)\.js)\b/.test([location.pathname, location.search]);
|
||||
|
||||
// Used to indicate testing in Sauce Labs' automated test cloud.
|
||||
ui.isSauceLabs = location.port == '9001';
|
||||
|
||||
// Used to indicate that lodash is in strict mode.
|
||||
ui.isStrict = /\bes6?\b/.test([location.pathname, location.search]);
|
||||
|
||||
// The lodash build file path.
|
||||
ui.buildPath = (function() {
|
||||
var result;
|
||||
switch (build) {
|
||||
case 'lodash-compat': result = 'lodash.compat.min.js'; break;
|
||||
case 'lodash-modern-dev': result = 'lodash.js'; break;
|
||||
case 'lodash-modern': result = 'lodash.min.js'; break;
|
||||
case 'lodash-custom-dev': result = 'lodash.custom.js'; break;
|
||||
case 'lodash-custom': result = 'lodash.custom.min.js'; break;
|
||||
case null: build = 'lodash-compat-dev';
|
||||
case 'lodash-compat-dev': result = 'lodash.src.js'; break;
|
||||
case 'lodash': result = 'dist/lodash.min.js'; break;
|
||||
case 'lodash-core-dev': result = 'dist/lodash.core.js'; break;
|
||||
case 'lodash-core': result = 'dist/lodash.core.min.js'; break;
|
||||
case null: build = 'lodash-dev';
|
||||
case 'lodash-dev': result = 'lodash.js'; break;
|
||||
default: return build;
|
||||
}
|
||||
return basePath + result;
|
||||
@@ -165,6 +147,21 @@
|
||||
return basePath + result;
|
||||
}());
|
||||
|
||||
// Used to indicate testing a core build.
|
||||
ui.isCore = /\bcore(\.min)?\.js\b/.test(ui.buildPath);
|
||||
|
||||
// Used to indicate testing a foreign file.
|
||||
ui.isForeign = RegExp('^(\\w+:)?//').test(build);
|
||||
|
||||
// Used to indicate testing a modularized build.
|
||||
ui.isModularize = /\b(?:amd|commonjs|es6?|node|npm|(index|main)\.js)\b/.test([location.pathname, location.search]);
|
||||
|
||||
// Used to indicate testing in Sauce Labs' automated test cloud.
|
||||
ui.isSauceLabs = location.port == '9001';
|
||||
|
||||
// Used to indicate that lodash is in strict mode.
|
||||
ui.isStrict = /\bes6?\b/.test([location.pathname, location.search]);
|
||||
|
||||
ui.urlParams = { 'build': build, 'loader': loader };
|
||||
ui.timing = { 'loadEventEnd': 0 };
|
||||
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
;(function() {
|
||||
|
||||
/** Used to determine if values are of the language type Object. */
|
||||
var objectTypes = {
|
||||
'function': true,
|
||||
'object': true
|
||||
};
|
||||
|
||||
/** Used as the `WeakMap#toString` return value. */
|
||||
var nativeString = String(Object.prototype.toString).replace(/toString/g, 'WeakMap');
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
|
||||
|
||||
/** Detect free variable `self`. */
|
||||
var freeSelf = objectTypes[typeof self] && self && self.Object && self;
|
||||
|
||||
/** Detect free variable `window`. */
|
||||
var freeWindow = objectTypes[typeof window] && window && window.Object && window;
|
||||
|
||||
/**
|
||||
* Used as a reference to the global object.
|
||||
*
|
||||
* The `this` value is used if it is the global object to avoid Greasemonkey's
|
||||
* restricted `window` object, otherwise the `window` object is used.
|
||||
*/
|
||||
var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Installs `WeakMap` on the given `context` object.
|
||||
*
|
||||
* @memberOf exports
|
||||
* @param {Object} context The context object.
|
||||
*/
|
||||
function runInContext(context) {
|
||||
|
||||
/**
|
||||
* Creates a `WeakMap` object.
|
||||
*/
|
||||
function WeakMap() {
|
||||
// No operation performed.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value associated with the given key.
|
||||
*
|
||||
* @memberOf WeakMap
|
||||
* @param {Object} key The key object.
|
||||
* @returns {*} Returns the associated value, else `undefined`.
|
||||
*/
|
||||
function get(key) {
|
||||
return key.__weakmap__;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value for the given key.
|
||||
*
|
||||
* @memberOf WeakMap
|
||||
* @param {Object} key The key object.
|
||||
* @param {*} value The value to set.
|
||||
*/
|
||||
function set(key, value) {
|
||||
key.__weakmap__ = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces the `toString` result of `WeakMap`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf WeakMap
|
||||
* @returns {string} Returns the string result.
|
||||
*/
|
||||
function toString() {
|
||||
return nativeString;
|
||||
}
|
||||
|
||||
WeakMap.toString = toString;
|
||||
WeakMap.prototype.get = get;
|
||||
WeakMap.prototype.set = set;
|
||||
|
||||
if (!root.WeakMap) {
|
||||
context.WeakMap = WeakMap;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
if (freeExports) {
|
||||
freeExports.runInContext = runInContext;
|
||||
} else {
|
||||
runInContext(root);
|
||||
}
|
||||
}.call(this));
|
||||
@@ -4,7 +4,7 @@ addEventListener('message', function(e) {
|
||||
if (e.data) {
|
||||
try {
|
||||
importScripts('../' + e.data);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
self._ = { 'VERSION': e.message };
|
||||
}
|
||||
postMessage(_.VERSION);
|
||||
|
||||
@@ -22,27 +22,67 @@
|
||||
<script src="../vendor/json-js/json2.js"></script>
|
||||
<script src="../node_modules/platform/platform.js"></script>
|
||||
<script src="./asset/test-ui.js"></script>
|
||||
<script src="../lodash.src.js"></script>
|
||||
<script src="../lodash.js"></script>
|
||||
<script>
|
||||
QUnit.config.asyncRetries = 10;
|
||||
QUnit.config.hidepassed = true;
|
||||
|
||||
var mixinPrereqs = (function() {
|
||||
var aliasToReal = {
|
||||
'indexBy': 'keyBy',
|
||||
'invoke': 'invokeMap'
|
||||
};
|
||||
|
||||
var keyMap = {
|
||||
'rest': 'tail'
|
||||
};
|
||||
|
||||
var lodash = _.noConflict();
|
||||
|
||||
return function(_) {
|
||||
_.mixin({
|
||||
'debounce': _.debounce || lodash.debounce,
|
||||
'defer': _.defer || lodash.defer,
|
||||
'pluck': _.pluck || lodash.pluck
|
||||
lodash.defaultsDeep(_, { 'templateSettings': lodash.templateSettings });
|
||||
lodash.mixin(_, lodash.pick(lodash, lodash.difference([
|
||||
'countBy',
|
||||
'debounce',
|
||||
'difference',
|
||||
'find',
|
||||
'findIndex',
|
||||
'findLastIndex',
|
||||
'groupBy',
|
||||
'includes',
|
||||
'invert',
|
||||
'invokeMap',
|
||||
'keyBy',
|
||||
'omit',
|
||||
'partition',
|
||||
'reduceRight',
|
||||
'reject',
|
||||
'sample',
|
||||
'without'
|
||||
], lodash.functions(_))));
|
||||
|
||||
lodash.forOwn(keyMap, function(realName, otherName) {
|
||||
_[otherName] = lodash[realName];
|
||||
_.prototype[otherName] = lodash.prototype[realName];
|
||||
});
|
||||
|
||||
lodash.forOwn(aliasToReal, function(realName, alias) {
|
||||
_[alias] = _[realName];
|
||||
_.prototype[alias] = _.prototype[realName];
|
||||
});
|
||||
};
|
||||
}());
|
||||
|
||||
QUnit.config.asyncRetries = 10;
|
||||
QUnit.config.hidepassed = true;
|
||||
|
||||
// Load test scripts.
|
||||
document.write(ui.urlParams.loader != 'none'
|
||||
? '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
|
||||
: ([
|
||||
'<script src="' + ui.buildPath + '"><\/script>',
|
||||
// Load prerequisite scripts.
|
||||
document.write(ui.urlParams.loader == 'none'
|
||||
? '<script src="' + ui.buildPath + '"><\/script>'
|
||||
: '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
|
||||
);
|
||||
</script>
|
||||
<script>
|
||||
if (ui.urlParams.loader == 'none') {
|
||||
mixinPrereqs(_);
|
||||
document.write([
|
||||
'<script src="../node_modules/jquery/dist/jquery.js"><\/script>',
|
||||
'<script src="../vendor/backbone/backbone.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/setup/dom-setup.js"><\/script>',
|
||||
@@ -54,8 +94,8 @@
|
||||
'<script src="../vendor/backbone/test/router.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/view.js"><\/script>',
|
||||
'<script src="../vendor/backbone/test/sync.js"><\/script>'
|
||||
].join('\n'))
|
||||
);
|
||||
].join('\n'));
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
(function() {
|
||||
@@ -63,7 +103,6 @@
|
||||
curl.config({ 'apiName': 'require' });
|
||||
}
|
||||
if (!window.require) {
|
||||
mixinPrereqs(_);
|
||||
return;
|
||||
}
|
||||
var reBasename = /[\w.-]+$/,
|
||||
@@ -107,24 +146,22 @@
|
||||
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
require(getConfig(), ['underscore', 'backbone'], function(lodash) {
|
||||
require(getConfig(), ['underscore'], function(lodash) {
|
||||
mixinPrereqs(lodash);
|
||||
|
||||
if (ui.isModularize) {
|
||||
window._ = lodash;
|
||||
}
|
||||
require(getConfig(), [
|
||||
'test/setup/dom-setup',
|
||||
'test/setup/environment',
|
||||
'test/noconflict',
|
||||
'test/events',
|
||||
'test/model',
|
||||
'test/collection',
|
||||
'test/router',
|
||||
'test/view',
|
||||
'test/sync'
|
||||
], function() {
|
||||
QUnit.start();
|
||||
require(getConfig(), ['backbone'], function() {
|
||||
require(getConfig(), [
|
||||
'test/setup/dom-setup',
|
||||
'test/setup/environment',
|
||||
'test/noconflict',
|
||||
'test/events',
|
||||
'test/model',
|
||||
'test/collection',
|
||||
'test/router',
|
||||
'test/view',
|
||||
'test/sync'
|
||||
], function() {
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
||||
41
test/fp.html
Normal file
41
test/fp.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>lodash-fp Test Suite</title>
|
||||
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
// Avoid reporting tests to Sauce Labs when script errors occur.
|
||||
if (location.port == '9001') {
|
||||
window.onerror = function(message) {
|
||||
if (window.QUnit) {
|
||||
QUnit.config.done.length = 0;
|
||||
}
|
||||
global_test_results = { 'message': message };
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<script src="../lodash.js"></script>
|
||||
<script src="../dist/lodash.fp.js"></script>
|
||||
<script src="../dist/mapping.fp.js"></script>
|
||||
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
|
||||
<script src="../node_modules/qunit-extras/qunit-extras.js"></script>
|
||||
<script src="../node_modules/platform/platform.js"></script>
|
||||
<script src="./test-fp.js"></script>
|
||||
<div id="qunit"></div>
|
||||
<script>
|
||||
// Set a more readable browser name.
|
||||
window.onload = function() {
|
||||
var timeoutId = setInterval(function() {
|
||||
var ua = document.getElementById('qunit-userAgent');
|
||||
if (ua) {
|
||||
ua.innerHTML = platform;
|
||||
clearInterval(timeoutId);
|
||||
}
|
||||
}, 16);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
143
test/index.html
143
test/index.html
@@ -5,7 +5,7 @@
|
||||
<title>lodash Test Suite</title>
|
||||
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
|
||||
<style>
|
||||
#exports {
|
||||
#exports, #module {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@@ -22,35 +22,33 @@
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<script src="../node_modules/lodash/index.js"></script>
|
||||
<script>var lodashStable = _.noConflict();</script>
|
||||
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
|
||||
<script src="../node_modules/qunit-extras/qunit-extras.js"></script>
|
||||
<script src="../node_modules/platform/platform.js"></script>
|
||||
<script src="./asset/set.js"></script>
|
||||
<script src="./asset/weakmap.js"></script>
|
||||
<script src="./asset/test-ui.js"></script>
|
||||
<div id="qunit"></div>
|
||||
<div id="exports"></div>
|
||||
<div id="module"></div>
|
||||
<script>
|
||||
var setProperty = (function() {
|
||||
var _defineProperty = Object.defineProperty;
|
||||
return function(object, key, value) {
|
||||
try {
|
||||
_defineProperty(object, key, {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'writable': true,
|
||||
'value': value
|
||||
});
|
||||
} catch(e) {
|
||||
object[key] = value;
|
||||
}
|
||||
};
|
||||
}());
|
||||
function setProperty(object, key, value) {
|
||||
try {
|
||||
Object.defineProperty(object, key, {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'writable': true,
|
||||
'value': value
|
||||
});
|
||||
} catch (e) {
|
||||
object[key] = value;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
function addBizarroMethods() {
|
||||
var funcProto = Function.prototype,
|
||||
objectProto = Object.prototype,
|
||||
stringProto = String.prototype;
|
||||
objectProto = Object.prototype;
|
||||
|
||||
var hasOwnProperty = objectProto.hasOwnProperty,
|
||||
fnToString = funcProto.toString,
|
||||
@@ -64,9 +62,11 @@
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
function createToString(funcName) {
|
||||
return constant(nativeString.replace(reToString, funcName));
|
||||
}
|
||||
|
||||
// Allow bypassing native checks.
|
||||
setProperty(funcProto, 'toString', (function() {
|
||||
function wrapper() {
|
||||
@@ -82,29 +82,39 @@
|
||||
funcProto._method = noop;
|
||||
|
||||
// Set bad shims.
|
||||
setProperty(Array, '_isArray', Array.isArray);
|
||||
setProperty(Array, 'isArray', noop);
|
||||
|
||||
setProperty(Date, '_now', Date.now);
|
||||
setProperty(Date, 'now', noop);
|
||||
|
||||
setProperty(Object, '_keys', Object.keys);
|
||||
setProperty(Object, 'keys', noop);
|
||||
|
||||
setProperty(objectProto, '_propertyIsEnumerable', propertyIsEnumerable);
|
||||
setProperty(objectProto, 'propertyIsEnumerable', function(key) {
|
||||
if (key == '1' && this && typeof this == 'object' &&
|
||||
hasOwnProperty.call(this, 'callee') &&
|
||||
!propertyIsEnumerable.call(this, 'callee') &&
|
||||
this.length === 2 && this[0] === 1 && this[1] === 0) {
|
||||
throw new Error;
|
||||
}
|
||||
return propertyIsEnumerable.call(this, key);
|
||||
return !(key == 'valueOf' && this && this.valueOf === 1) && _propertyIsEnumerable.call(this, key);
|
||||
});
|
||||
|
||||
setProperty(window, '_Map', window.Map);
|
||||
if (_Map) {
|
||||
setProperty(window, 'Map', (function(Map) {
|
||||
var count = 0;
|
||||
return function() {
|
||||
if (count++) {
|
||||
return new Map;
|
||||
}
|
||||
var result = {};
|
||||
setProperty(window, 'Map', Map);
|
||||
return result;
|
||||
};
|
||||
}(_Map)));
|
||||
|
||||
setProperty(Map, 'toString', createToString('Map'));
|
||||
}
|
||||
setProperty(Object, '_create', Object.create);
|
||||
setProperty(Object, 'create', noop);
|
||||
|
||||
setProperty(Object, '_getOwnPropertySymbols', Object.getOwnPropertySymbols);
|
||||
setProperty(Object, 'getOwnPropertySymbols', undefined);
|
||||
|
||||
setProperty(window, '_Set', window.Set);
|
||||
setProperty(window, 'Set', noop);
|
||||
|
||||
setProperty(window, '_Symbol', window.Symbol);
|
||||
setProperty(window, 'Symbol', undefined);
|
||||
|
||||
setProperty(window, '_WeakMap', window.WeakMap);
|
||||
setProperty(window, 'WeakMap', noop);
|
||||
|
||||
@@ -119,47 +129,53 @@
|
||||
|
||||
function removeBizarroMethods() {
|
||||
var funcProto = Function.prototype,
|
||||
objectProto = Object.prototype,
|
||||
stringProto = String.prototype;
|
||||
objectProto = Object.prototype;
|
||||
|
||||
if (Array._isArray) {
|
||||
setProperty(Array, 'isArray', Array._isArray);
|
||||
if (Object._create) {
|
||||
Object.create = Object._create;
|
||||
} else {
|
||||
delete Array.isArray;
|
||||
delete Object.create;
|
||||
}
|
||||
if (Date._now) {
|
||||
setProperty(Date, 'now', Date._now);
|
||||
if (Object._getOwnPropertySymbols) {
|
||||
Object.getOwnPropertySymbols = Object._getOwnPropertySymbols;
|
||||
} else {
|
||||
delete Date.now;
|
||||
delete Object.getOwnPropertySymbols;
|
||||
}
|
||||
if (Object._keys) {
|
||||
setProperty(Object, 'keys', Object._keys);
|
||||
if (_Map) {
|
||||
Map = _Map;
|
||||
} else {
|
||||
delete Object.keys;
|
||||
setProperty(window, 'Map', undefined);
|
||||
}
|
||||
if (window._Set) {
|
||||
if (_Set) {
|
||||
Set = _Set;
|
||||
} else {
|
||||
setProperty(window, 'Set', undefined);
|
||||
}
|
||||
setProperty(window, '_Set', undefined);
|
||||
|
||||
if (window._WeakMap) {
|
||||
if (_Symbol) {
|
||||
Symbol = _Symbol;
|
||||
}
|
||||
if (_WeakMap) {
|
||||
WeakMap = _WeakMap;
|
||||
} else {
|
||||
setProperty(window, 'WeakMap', undefined);
|
||||
}
|
||||
setProperty(objectProto, 'propertyIsEnumerable', objectProto._propertyIsEnumerable);
|
||||
|
||||
setProperty(window, '_Map', undefined);
|
||||
setProperty(window, '_Set', undefined);
|
||||
setProperty(window, '_Symbol', undefined);
|
||||
setProperty(window, '_WeakMap', undefined);
|
||||
|
||||
setProperty(window, 'WinRTError', undefined);
|
||||
|
||||
setProperty(window, 'exports', undefined);
|
||||
setProperty(window, 'exports', document.getElementById('exports'));
|
||||
setProperty(window, 'global', undefined);
|
||||
setProperty(window, 'module', undefined);
|
||||
setProperty(window, 'module', document.getElementById('module'));
|
||||
|
||||
setProperty(objectProto, 'propertyIsEnumerable', objectProto._propertyIsEnumerable);
|
||||
|
||||
delete Array._isArray;
|
||||
delete Date._now;
|
||||
delete Object._keys;
|
||||
delete funcProto._method;
|
||||
delete objectProto._propertyIsEnumerable;
|
||||
delete Object._create;
|
||||
delete Object._getOwnPropertySymbols;
|
||||
}
|
||||
|
||||
// Load lodash to expose it to the bad extensions/shims.
|
||||
@@ -266,20 +282,17 @@
|
||||
underscoreModule = underscore.result(underscore, 'noConflict') || underscore;
|
||||
underscoreModule.moduleName = 'underscore';
|
||||
}
|
||||
if (ui.isModularize) {
|
||||
window._ = lodash;
|
||||
}
|
||||
window._ = lodash;
|
||||
|
||||
if (ui.isModularize) {
|
||||
require(getConfig(), [
|
||||
'lodash/internal/baseEach',
|
||||
'lodash/internal/isIndex',
|
||||
'lodash/internal/isIterateeCall',
|
||||
'lodash/internal/isLength'
|
||||
], function(baseEach, isIndex, isIterateeCall, isLength) {
|
||||
'lodash/internal/isIterateeCall'
|
||||
], function(baseEach, isIndex, isIterateeCall) {
|
||||
lodash._baseEach = baseEach;
|
||||
lodash._isIndex = isIndex;
|
||||
lodash._isIterateeCall = isIterateeCall;
|
||||
lodash._isLength = isLength;
|
||||
loadTests();
|
||||
});
|
||||
} else {
|
||||
|
||||
27
test/remove.js
Normal file
27
test/remove.js
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path');
|
||||
|
||||
var args = (args = process.argv)
|
||||
.slice((args[0] === process.execPath || args[0] === 'node') ? 2 : 0);
|
||||
|
||||
var filePath = path.resolve(args[1]),
|
||||
reLine = /.*/gm,
|
||||
slice = Array.prototype.slice;
|
||||
|
||||
var pattern = (function() {
|
||||
var result = args[0],
|
||||
delimiter = result.charAt(0),
|
||||
lastIndex = result.lastIndexOf(delimiter);
|
||||
|
||||
return RegExp(result.slice(1, lastIndex), result.slice(lastIndex + 1));
|
||||
}());
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
fs.writeFileSync(filePath, fs.readFileSync(filePath, 'utf8').replace(pattern, function(match) {
|
||||
var snippet = slice.call(arguments, -3, -1)[0];
|
||||
return match.replace(snippet, snippet.replace(reLine, ''));
|
||||
}));
|
||||
@@ -1,14 +0,0 @@
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
echo "Testing in node..."
|
||||
node test.js ../lodash.src.js
|
||||
|
||||
for cmd in rhino "rhino -require" ringo phantomjs; do
|
||||
echo ""
|
||||
echo "Testing in $cmd..."
|
||||
$cmd test.js ../lodash.src.js
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Testing in a browser..."
|
||||
open index.html
|
||||
@@ -17,7 +17,7 @@ var EventEmitter = require('events').EventEmitter,
|
||||
util = require('util');
|
||||
|
||||
/** Load other modules. */
|
||||
var _ = require('../lodash.src.js'),
|
||||
var _ = require('../lodash.js'),
|
||||
chalk = require('chalk'),
|
||||
ecstatic = require('ecstatic'),
|
||||
request = require('request'),
|
||||
@@ -102,26 +102,18 @@ var browserNameMap = {
|
||||
|
||||
/** List of platforms to load the runner on. */
|
||||
var platforms = [
|
||||
['Linux', 'android', '5.0'],
|
||||
['Linux', 'android', '4.4'],
|
||||
['Linux', 'android', '4.0'],
|
||||
['Windows 8.1', 'firefox', '38'],
|
||||
['Windows 8.1', 'firefox', '37'],
|
||||
['Windows 8.1', 'firefox', '20'],
|
||||
['Windows 8.1', 'chrome', '43'],
|
||||
['Windows 8.1', 'chrome', '42'],
|
||||
['Windows 8.1', 'internet explorer', '11'],
|
||||
['Linux', 'android', '5.1'],
|
||||
['Windows 10', 'chrome', '47'],
|
||||
['Windows 10', 'chrome', '46'],
|
||||
['Windows 10', 'firefox', '43'],
|
||||
['Windows 10', 'firefox', '42'],
|
||||
['Windows 10', 'microsoftedge', '20.10240'],
|
||||
['Windows 10', 'internet explorer', '11'],
|
||||
['Windows 8', 'internet explorer', '10'],
|
||||
['Windows 7', 'internet explorer', '9'],
|
||||
['Windows 7', 'internet explorer', '8'],
|
||||
['Windows XP', 'internet explorer', '7'],
|
||||
['Windows XP', 'internet explorer', '6'],
|
||||
['OS X 10.9', 'ipad', '8.1'],
|
||||
['OS X 10.6', 'ipad', '4'],
|
||||
['OS X 10.10', 'safari', '8'],
|
||||
['OS X 10.9', 'safari', '7'],
|
||||
['OS X 10.8', 'safari', '6'],
|
||||
['OS X 10.6', 'safari', '5']
|
||||
// ['OS X 10.10', 'ipad', '9.1'],
|
||||
['OS X 10.11', 'safari', '9'],
|
||||
['OS X 10.10', 'safari', '8']
|
||||
];
|
||||
|
||||
/** Used to tailor the `platforms` array. */
|
||||
@@ -132,7 +124,7 @@ var isAMD = _.includes(tags, 'amd'),
|
||||
// The platforms to test IE compatibility modes.
|
||||
if (compatMode) {
|
||||
platforms = [
|
||||
['Windows 8.1', 'internet explorer', '11'],
|
||||
['Windows 10', 'internet explorer', '11'],
|
||||
['Windows 8', 'internet explorer', '10'],
|
||||
['Windows 7', 'internet explorer', '9'],
|
||||
['Windows 7', 'internet explorer', '8']
|
||||
@@ -276,7 +268,7 @@ function isJobId(value) {
|
||||
*/
|
||||
function logInline(text) {
|
||||
var blankLine = _.repeat(' ', _.size(prevLine));
|
||||
prevLine = text = _.trunc(text, 40);
|
||||
prevLine = text = _.truncate(text, { 'length': 40 });
|
||||
process.stdout.write(text + blankLine.slice(text.length) + '\r');
|
||||
}
|
||||
|
||||
@@ -298,7 +290,7 @@ function logThrobber() {
|
||||
* @returns {Array} Returns the new converted array.
|
||||
*/
|
||||
function optionToArray(name, string) {
|
||||
return _.compact(_.invoke((optionToValue(name, string) || '').split(/, */), 'trim'));
|
||||
return _.compact(_.invokeMap((optionToValue(name, string) || '').split(/, */), 'trim'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -560,7 +552,7 @@ util.inherits(Job, EventEmitter);
|
||||
* @param {Object} Returns the job instance.
|
||||
*/
|
||||
Job.prototype.remove = function(callback) {
|
||||
this.once('remove', _.callback(callback));
|
||||
this.once('remove', _.iteratee(callback));
|
||||
if (this.removing) {
|
||||
return this;
|
||||
}
|
||||
@@ -585,7 +577,7 @@ Job.prototype.remove = function(callback) {
|
||||
* @param {Object} Returns the job instance.
|
||||
*/
|
||||
Job.prototype.reset = function(callback) {
|
||||
this.once('reset', _.callback(callback));
|
||||
this.once('reset', _.iteratee(callback));
|
||||
if (this.resetting) {
|
||||
return this;
|
||||
}
|
||||
@@ -601,7 +593,7 @@ Job.prototype.reset = function(callback) {
|
||||
* @param {Object} Returns the job instance.
|
||||
*/
|
||||
Job.prototype.restart = function(callback) {
|
||||
this.once('restart', _.callback(callback));
|
||||
this.once('restart', _.iteratee(callback));
|
||||
if (this.restarting) {
|
||||
return this;
|
||||
}
|
||||
@@ -626,7 +618,7 @@ Job.prototype.restart = function(callback) {
|
||||
* @param {Object} Returns the job instance.
|
||||
*/
|
||||
Job.prototype.start = function(callback) {
|
||||
this.once('start', _.callback(callback));
|
||||
this.once('start', _.iteratee(callback));
|
||||
if (this.starting || this.running) {
|
||||
return this;
|
||||
}
|
||||
@@ -647,7 +639,7 @@ Job.prototype.start = function(callback) {
|
||||
* @param {Object} Returns the job instance.
|
||||
*/
|
||||
Job.prototype.status = function(callback) {
|
||||
this.once('status', _.callback(callback));
|
||||
this.once('status', _.iteratee(callback));
|
||||
if (this.checking || this.removing || this.resetting || this.restarting || this.starting || this.stopping) {
|
||||
return this;
|
||||
}
|
||||
@@ -669,7 +661,7 @@ Job.prototype.status = function(callback) {
|
||||
* @param {Object} Returns the job instance.
|
||||
*/
|
||||
Job.prototype.stop = function(callback) {
|
||||
this.once('stop', _.callback(callback));
|
||||
this.once('stop', _.iteratee(callback));
|
||||
if (this.stopping) {
|
||||
return this;
|
||||
}
|
||||
@@ -707,14 +699,14 @@ function Tunnel(properties) {
|
||||
var active = [],
|
||||
queue = [];
|
||||
|
||||
var all = _.map(this.platforms, function(platform) {
|
||||
var all = _.map(this.platforms, _.bind(function(platform) {
|
||||
return new Job(_.merge({
|
||||
'user': this.user,
|
||||
'pass': this.pass,
|
||||
'tunnel': this,
|
||||
'options': { 'platforms': [platform] }
|
||||
}, this.job));
|
||||
}, this);
|
||||
}, this));
|
||||
|
||||
var completed = 0,
|
||||
restarted = [],
|
||||
@@ -722,7 +714,7 @@ function Tunnel(properties) {
|
||||
total = all.length,
|
||||
tunnel = this;
|
||||
|
||||
_.invoke(all, 'on', 'complete', function() {
|
||||
_.invokeMap(all, 'on', 'complete', function() {
|
||||
_.pull(active, this);
|
||||
if (success) {
|
||||
success = !this.failed;
|
||||
@@ -734,7 +726,7 @@ function Tunnel(properties) {
|
||||
tunnel.dequeue();
|
||||
});
|
||||
|
||||
_.invoke(all, 'on', 'restart', function() {
|
||||
_.invokeMap(all, 'on', 'restart', function() {
|
||||
if (!_.includes(restarted, this)) {
|
||||
restarted.push(this);
|
||||
}
|
||||
@@ -768,7 +760,7 @@ util.inherits(Tunnel, EventEmitter);
|
||||
* @param {Function} callback The function called once the tunnel is restarted.
|
||||
*/
|
||||
Tunnel.prototype.restart = function(callback) {
|
||||
this.once('restart', _.callback(callback));
|
||||
this.once('restart', _.iteratee(callback));
|
||||
if (this.restarting) {
|
||||
return this;
|
||||
}
|
||||
@@ -782,7 +774,7 @@ Tunnel.prototype.restart = function(callback) {
|
||||
all = jobs.all;
|
||||
|
||||
var reset = _.after(all.length, _.bind(this.stop, this, onGenericRestart)),
|
||||
stop = _.after(active.length, _.partial(_.invoke, all, 'reset', reset));
|
||||
stop = _.after(active.length, _.partial(_.invokeMap, all, 'reset', reset));
|
||||
|
||||
if (_.isEmpty(active)) {
|
||||
_.defer(stop);
|
||||
@@ -790,7 +782,7 @@ Tunnel.prototype.restart = function(callback) {
|
||||
if (_.isEmpty(all)) {
|
||||
_.defer(reset);
|
||||
}
|
||||
_.invoke(active, 'stop', function() {
|
||||
_.invokeMap(active, 'stop', function() {
|
||||
_.pull(active, this);
|
||||
stop();
|
||||
});
|
||||
@@ -810,7 +802,7 @@ Tunnel.prototype.restart = function(callback) {
|
||||
* @param {Object} Returns the tunnel instance.
|
||||
*/
|
||||
Tunnel.prototype.start = function(callback) {
|
||||
this.once('start', _.callback(callback));
|
||||
this.once('start', _.iteratee(callback));
|
||||
if (this.starting || this.running) {
|
||||
return this;
|
||||
}
|
||||
@@ -853,7 +845,7 @@ Tunnel.prototype.dequeue = function() {
|
||||
* @param {Object} Returns the tunnel instance.
|
||||
*/
|
||||
Tunnel.prototype.stop = function(callback) {
|
||||
this.once('stop', _.callback(callback));
|
||||
this.once('stop', _.iteratee(callback));
|
||||
if (this.stopping) {
|
||||
return this;
|
||||
}
|
||||
@@ -878,7 +870,7 @@ Tunnel.prototype.stop = function(callback) {
|
||||
if (_.isEmpty(active)) {
|
||||
_.defer(stop);
|
||||
}
|
||||
_.invoke(active, 'stop', function() {
|
||||
_.invokeMap(active, 'stop', function() {
|
||||
_.pull(active, this);
|
||||
stop();
|
||||
});
|
||||
|
||||
1021
test/test-fp.js
Normal file
1021
test/test-fp.js
Normal file
File diff suppressed because it is too large
Load Diff
23784
test/test.js
23784
test/test.js
File diff suppressed because it is too large
Load Diff
@@ -23,50 +23,87 @@
|
||||
<script src="../node_modules/jquery/dist/jquery.js"></script>
|
||||
<script src="../node_modules/platform/platform.js"></script>
|
||||
<script src="./asset/test-ui.js"></script>
|
||||
<script src="../lodash.js"></script>
|
||||
<script>
|
||||
QUnit.config.asyncRetries = 10;
|
||||
QUnit.config.hidepassed = true;
|
||||
|
||||
// Excuse tests we intentionally fail or those with problems.
|
||||
QUnit.config.excused = {
|
||||
'Arrays': {
|
||||
'drop': [
|
||||
'alias for rest'
|
||||
'is an alias for rest'
|
||||
],
|
||||
'first': [
|
||||
'can pass an index to first',
|
||||
'[1,2]',
|
||||
'0'
|
||||
'returns an empty array when n <= 0 (0 case)',
|
||||
'returns an empty array when n <= 0 (negative case)',
|
||||
'can fetch the first n elements',
|
||||
'returns the whole array if n > length'
|
||||
],
|
||||
'findIndex': [
|
||||
'called with context'
|
||||
],
|
||||
'findLastIndex': [
|
||||
'called with context'
|
||||
],
|
||||
'flatten': [
|
||||
'Flattens empty arrays',
|
||||
'supports empty arrays',
|
||||
'can flatten nested arrays',
|
||||
'can shallowly flatten nested arrays',
|
||||
'works on an arguments object',
|
||||
'can shallowly flatten arrays containing only other arrays'
|
||||
'can handle very deep arrays'
|
||||
],
|
||||
'head': [
|
||||
'is an alias for first'
|
||||
],
|
||||
'indexOf': [
|
||||
"sorted indexOf doesn't uses binary search",
|
||||
'0'
|
||||
],
|
||||
'initial': [
|
||||
'initial can take an index',
|
||||
'initial can take a large index',
|
||||
'initial works on arguments object'
|
||||
'returns all but the last n elements',
|
||||
'returns an empty array when n > length',
|
||||
'works on an arguments object'
|
||||
],
|
||||
'intersection': [
|
||||
'can perform an OO-style intersection'
|
||||
],
|
||||
'last': [
|
||||
'can pass an index to last',
|
||||
'0'
|
||||
'returns an empty array when n <= 0 (0 case)',
|
||||
'returns an empty array when n <= 0 (negative case)',
|
||||
'can fetch the last n elements',
|
||||
'returns the whole array if n > length'
|
||||
],
|
||||
'lastIndexOf': [
|
||||
'should treat falsey `fromIndex` values, except `0` and `NaN`, as `array.length`',
|
||||
'should treat non-number `fromIndex` values as `array.length`',
|
||||
'[0,-1,-1]'
|
||||
],
|
||||
'object': [
|
||||
'an array of pairs zipped together into an object',
|
||||
'an object converted to pairs and back to an object'
|
||||
],
|
||||
'range': [
|
||||
'range with two arguments a & b, b<a generates an empty array'
|
||||
],
|
||||
'rest': [
|
||||
'working rest(0)',
|
||||
'rest can take an index',
|
||||
'works on arguments object'
|
||||
'returns the whole array when index is 0',
|
||||
'returns elements starting at the given index',
|
||||
'works on an arguments object'
|
||||
],
|
||||
'sortedIndex': [
|
||||
'2',
|
||||
'3'
|
||||
],
|
||||
'tail': [
|
||||
'is an alias for rest'
|
||||
],
|
||||
'take': [
|
||||
'alias for first'
|
||||
'is an alias for first'
|
||||
],
|
||||
'uniq': [
|
||||
'can find the unique values of an array using a custom iterator',
|
||||
'can find the unique values of an array using a custom iterator without specifying whether array is sorted',
|
||||
'string iterator works with sorted array',
|
||||
'can use pluck like iterator',
|
||||
'can use falsey pluck like iterator'
|
||||
]
|
||||
},
|
||||
'Chaining': {
|
||||
@@ -78,20 +115,120 @@
|
||||
]
|
||||
},
|
||||
'Collections': {
|
||||
'lookupIterator with contexts': true,
|
||||
'Iterating objects with sketchy length properties': true,
|
||||
'Resistant to collection length and properties changing while iterating': true,
|
||||
'countBy': [
|
||||
'true'
|
||||
],
|
||||
'each': [
|
||||
'context object property accessed'
|
||||
],
|
||||
'every': [
|
||||
'Can be called with object',
|
||||
'Died on test #15',
|
||||
'context works'
|
||||
],
|
||||
'filter': [
|
||||
'given context',
|
||||
'[{"a":1,"b":2},{"a":1,"b":3},{"a":1,"b":4}]',
|
||||
'[{"a":1,"b":2},{"a":2,"b":2}]',
|
||||
'Empty object accepts all items',
|
||||
'OO-filter'
|
||||
],
|
||||
'find': [
|
||||
'{"a":1,"b":4}',
|
||||
'undefined when not found',
|
||||
'undefined when searching empty list',
|
||||
'works on objects',
|
||||
'undefined',
|
||||
'called with context'
|
||||
],
|
||||
'findWhere': [
|
||||
'checks properties given function'
|
||||
],
|
||||
'groupBy': [
|
||||
'true'
|
||||
],
|
||||
'includes': [
|
||||
"doesn't delegate to binary search"
|
||||
],
|
||||
'invoke': [
|
||||
'handles null & undefined'
|
||||
],
|
||||
'map': [
|
||||
'tripled numbers with context',
|
||||
'OO-style doubled numbers'
|
||||
],
|
||||
'Resistant to collection length and properties changing while iterating': [
|
||||
'Died on test #50'
|
||||
'max': [
|
||||
'can handle null/undefined',
|
||||
'can perform a computation-based max',
|
||||
'Maximum value of an empty object',
|
||||
'Maximum value of an empty array',
|
||||
'Maximum value of a non-numeric collection',
|
||||
'Finds correct max in array starting with num and containing a NaN',
|
||||
'Finds correct max in array starting with NaN',
|
||||
'Respects iterator return value of -Infinity',
|
||||
'String keys use property iterator',
|
||||
'Iterator context',
|
||||
'Lookup falsy iterator'
|
||||
],
|
||||
'min': [
|
||||
'can handle null/undefined',
|
||||
'can perform a computation-based min',
|
||||
'Minimum value of an empty object',
|
||||
'Minimum value of an empty array',
|
||||
'Minimum value of a non-numeric collection',
|
||||
'Finds correct min in array starting with NaN',
|
||||
'Respects iterator return value of Infinity',
|
||||
'String keys use property iterator',
|
||||
'Iterator context',
|
||||
'Lookup falsy iterator'
|
||||
],
|
||||
'partition': [
|
||||
'can reference the array index',
|
||||
'Died on test #8',
|
||||
'partition takes a context argument',
|
||||
'function(a){[code]}'
|
||||
],
|
||||
'pluck': [
|
||||
'[1]'
|
||||
],
|
||||
'reduce': [
|
||||
'can reduce with a context object'
|
||||
],
|
||||
'reject': [
|
||||
'Returns empty list given empty array'
|
||||
],
|
||||
'sample': [
|
||||
'behaves correctly on negative n',
|
||||
'Died on test #3'
|
||||
],
|
||||
'some': [
|
||||
'Can be called with object',
|
||||
'Died on test #17',
|
||||
'context works'
|
||||
],
|
||||
'where': [
|
||||
'checks properties given function'
|
||||
],
|
||||
'Can use various collection methods on NodeLists': [
|
||||
'<span id="id2"></span>',
|
||||
'<span id="id1"></span>'
|
||||
]
|
||||
},
|
||||
'Functions': {
|
||||
'debounce asap': true,
|
||||
'debounce asap cancel': true,
|
||||
'debounce after system time is set backwards': true,
|
||||
'debounce asap recursively': true,
|
||||
'throttle repeatedly with results': true,
|
||||
'more throttle does not trigger leading call when leading is set to false': true,
|
||||
'throttle does not trigger trailing call when trailing is set to false': true,
|
||||
'before': [
|
||||
'stores a memo to the last value',
|
||||
'provides context'
|
||||
],
|
||||
'bind': [
|
||||
'Died on test #2'
|
||||
],
|
||||
@@ -102,45 +239,78 @@
|
||||
'{"bar":"BAR","foo":"FOO"}',
|
||||
'Died on test #8'
|
||||
],
|
||||
'throttle repeatedly with results': true,
|
||||
'more throttle does not trigger leading call when leading is set to false': true,
|
||||
'throttle does not trigger trailing call when trailing is set to false': true,
|
||||
'debounce asap': true
|
||||
'partial':[
|
||||
'can partially apply with placeholders',
|
||||
'accepts more arguments than the number of placeholders',
|
||||
'accepts fewer arguments than the number of placeholders',
|
||||
'unfilled placeholders are undefined',
|
||||
'keeps prototype',
|
||||
'allows the placeholder to be swapped out'
|
||||
]
|
||||
},
|
||||
'Objects': {
|
||||
'#1929 Typed Array constructors are functions': true,
|
||||
'allKeys': true,
|
||||
'extendOwn': true,
|
||||
'mapObject': true,
|
||||
'matcher': true,
|
||||
'matcher ': true,
|
||||
'allKeys': [
|
||||
'is not fooled by sparse arrays; see issue #95',
|
||||
'is not fooled by sparse arrays with additional properties',
|
||||
'[]'
|
||||
],
|
||||
'defaults': [
|
||||
'defaults skips nulls',
|
||||
'defaults skips undefined'
|
||||
],
|
||||
'extend': [
|
||||
'extend copies all properties from source'
|
||||
'extending null results in null',
|
||||
'extending undefined results in undefined'
|
||||
],
|
||||
'extendOwn': [
|
||||
'extending non-objects results in returning the non-object value',
|
||||
'extending undefined results in undefined'
|
||||
],
|
||||
'functions': [
|
||||
'also looks up functions on the prototype'
|
||||
],
|
||||
'isEqual': [
|
||||
'`0` is not equal to `-0`',
|
||||
'Commutative equality is implemented for `0` and `-0`',
|
||||
'`new Number(0)` and `-0` are not equal',
|
||||
'Commutative equality is implemented for `new Number(0)` and `-0`'
|
||||
'Commutative equality is implemented for `new Number(0)` and `-0`',
|
||||
'false'
|
||||
],
|
||||
'isFinite': [
|
||||
'Numeric strings are numbers',
|
||||
'Number instances can be finite'
|
||||
],
|
||||
'isMatch': [
|
||||
'inherited and own properties are checked on the test object',
|
||||
'doesnt falsey match constructor on undefined/null'
|
||||
],
|
||||
'findKey': [
|
||||
'called with context'
|
||||
],
|
||||
'keys': [
|
||||
'is not fooled by sparse arrays; see issue #95',
|
||||
'[]'
|
||||
],
|
||||
'matches': [
|
||||
'inherited and own properties are checked on the test object',
|
||||
'doesnt fasley match constructor on undefined/null'
|
||||
'mapObject': [
|
||||
'keep context',
|
||||
'called with context',
|
||||
'mapValue identity'
|
||||
],
|
||||
'matcher': [
|
||||
'null matches null',
|
||||
'treats primitives as empty'
|
||||
],
|
||||
'omit': [
|
||||
'can accept a predicate',
|
||||
'function is given context'
|
||||
],
|
||||
'pick': [
|
||||
'can accept a predicate and context',
|
||||
'function is given context'
|
||||
]
|
||||
},
|
||||
'Utility': {
|
||||
'noConflict (node vm)': true,
|
||||
'now': [
|
||||
'Produces the correct time in milliseconds'
|
||||
],
|
||||
@@ -150,19 +320,75 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Only excuse in Sauce Labs (buggy Safari and timers).
|
||||
var mixinPrereqs = (function() {
|
||||
var aliasToReal = {
|
||||
'all': 'every',
|
||||
'allKeys': 'keysIn',
|
||||
'any': 'some',
|
||||
'collect': 'map',
|
||||
'compose': 'flowRight',
|
||||
'contains': 'includes',
|
||||
'detect': 'find',
|
||||
'extendOwn': 'assign',
|
||||
'findWhere': 'find',
|
||||
'foldl': 'reduce',
|
||||
'foldr': 'reduceRight',
|
||||
'include': 'includes',
|
||||
'indexBy': 'keyBy',
|
||||
'inject': 'reduce',
|
||||
'invoke': 'invokeMap',
|
||||
'mapObject': 'mapValues',
|
||||
'matcher': 'matches',
|
||||
'methods': 'functions',
|
||||
'object': 'zipObject',
|
||||
'pairs': 'toPairs',
|
||||
'pluck': 'map',
|
||||
'restParam': 'restArgs',
|
||||
'select': 'filter',
|
||||
'unique': 'uniq',
|
||||
'where': 'filter'
|
||||
};
|
||||
|
||||
var keyMap = {
|
||||
'rest': 'tail',
|
||||
'restArgs': 'rest'
|
||||
};
|
||||
|
||||
var lodash = _.noConflict();
|
||||
|
||||
return function(_) {
|
||||
lodash.defaultsDeep(_, { 'templateSettings': lodash.templateSettings });
|
||||
lodash.mixin(_, lodash.pick(lodash, lodash.difference(lodash.functions(lodash), lodash.functions(_))));
|
||||
|
||||
lodash.forOwn(keyMap, function(realName, otherName) {
|
||||
_[otherName] = lodash[realName];
|
||||
_.prototype[otherName] = lodash.prototype[realName];
|
||||
});
|
||||
|
||||
lodash.forOwn(aliasToReal, function(realName, alias) {
|
||||
_[alias] = _[realName];
|
||||
_.prototype[alias] = _.prototype[realName];
|
||||
});
|
||||
};
|
||||
}());
|
||||
|
||||
// Only excuse in Sauce Labs.
|
||||
if (!ui.isSauceLabs) {
|
||||
delete QUnit.config.excused.Functions['throttle repeatedly with results'];
|
||||
delete QUnit.config.excused.Functions['more throttle does not trigger leading call when leading is set to false'];
|
||||
delete QUnit.config.excused.Functions['throttle does not trigger trailing call when trailing is set to false'];
|
||||
delete QUnit.config.excused.Functions['debounce asap'];
|
||||
delete QUnit.config.excused.Utility.now;
|
||||
}
|
||||
// Load test scripts.
|
||||
document.write(ui.urlParams.loader != 'none'
|
||||
? '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
|
||||
: ([
|
||||
'<script src="' + ui.buildPath + '"><\/script>',
|
||||
// Load prerequisite scripts.
|
||||
document.write(ui.urlParams.loader == 'none'
|
||||
? '<script src="' + ui.buildPath + '"><\/script>'
|
||||
: '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
|
||||
);
|
||||
</script>
|
||||
<script>
|
||||
if (ui.urlParams.loader == 'none') {
|
||||
mixinPrereqs(_);
|
||||
document.write([
|
||||
'<script src="../vendor/underscore/test/collections.js"><\/script>',
|
||||
'<script src="../vendor/underscore/test/arrays.js"><\/script>',
|
||||
'<script src="../vendor/underscore/test/functions.js"><\/script>',
|
||||
@@ -170,8 +396,8 @@
|
||||
'<script src="../vendor/underscore/test/cross-document.js"><\/script>',
|
||||
'<script src="../vendor/underscore/test/utility.js"><\/script>',
|
||||
'<script src="../vendor/underscore/test/chaining.js"><\/script>'
|
||||
].join('\n'))
|
||||
);
|
||||
].join('\n'));
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
(function() {
|
||||
@@ -181,6 +407,13 @@
|
||||
if (!window.require) {
|
||||
return;
|
||||
}
|
||||
// Wrap to work around tests assuming Node `require` use.
|
||||
require = (function(func) {
|
||||
return function() {
|
||||
return arguments[0] === '..' ? window._ : func.apply(null, arguments);
|
||||
};
|
||||
}(require));
|
||||
|
||||
var reBasename = /[\w.-]+$/,
|
||||
basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
|
||||
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
||||
@@ -221,9 +454,7 @@
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
require(getConfig(), [moduleId], function(lodash) {
|
||||
if (ui.isModularize) {
|
||||
window._ = lodash;
|
||||
}
|
||||
mixinPrereqs(lodash);
|
||||
require(getConfig(), [
|
||||
'test/collections',
|
||||
'test/arrays',
|
||||
|
||||
357
vendor/backbone/backbone.js
vendored
357
vendor/backbone/backbone.js
vendored
@@ -1,4 +1,4 @@
|
||||
// Backbone.js 1.2.1
|
||||
// Backbone.js 1.2.3
|
||||
|
||||
// (c) 2010-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
// Backbone may be freely distributed under the MIT license.
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
// Establish the root object, `window` (`self`) in the browser, or `global` on the server.
|
||||
// We use `self` instead of `window` for `WebWorker` support.
|
||||
var root = (typeof self == 'object' && self.self == self && self) ||
|
||||
(typeof global == 'object' && global.global == global && global);
|
||||
var root = (typeof self == 'object' && self.self === self && self) ||
|
||||
(typeof global == 'object' && global.global === global && global);
|
||||
|
||||
// Set up Backbone appropriately for the environment. Start with AMD.
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@@ -23,7 +23,7 @@
|
||||
// Next for Node.js or CommonJS. jQuery may not be needed as a module.
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
var _ = require('underscore'), $;
|
||||
try { $ = require('jquery'); } catch(e) {}
|
||||
try { $ = require('jquery'); } catch (e) {}
|
||||
factory(root, exports, _, $);
|
||||
|
||||
// Finally, as a browser global.
|
||||
@@ -31,7 +31,7 @@
|
||||
root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$));
|
||||
}
|
||||
|
||||
}(function(root, Backbone, _, $) {
|
||||
})(function(root, Backbone, _, $) {
|
||||
|
||||
// Initial Setup
|
||||
// -------------
|
||||
@@ -41,10 +41,10 @@
|
||||
var previousBackbone = root.Backbone;
|
||||
|
||||
// Create a local reference to a common array method we'll want to use later.
|
||||
var slice = [].slice;
|
||||
var slice = Array.prototype.slice;
|
||||
|
||||
// Current version of the library. Keep in sync with `package.json`.
|
||||
Backbone.VERSION = '1.2.1';
|
||||
Backbone.VERSION = '1.2.3';
|
||||
|
||||
// For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
|
||||
// the `$` variable.
|
||||
@@ -68,8 +68,13 @@
|
||||
// form param named `model`.
|
||||
Backbone.emulateJSON = false;
|
||||
|
||||
// Proxy Underscore methods to a Backbone class' prototype using a
|
||||
// particular attribute as the data argument
|
||||
// Proxy Backbone class methods to Underscore functions, wrapping the model's
|
||||
// `attributes` object or collection's `models` array behind the scenes.
|
||||
//
|
||||
// collection.filter(function(model) { return model.get('age') > 10 });
|
||||
// collection.each(this.addView);
|
||||
//
|
||||
// `Function#apply` can be slow so we use the method's arg count, if we know it.
|
||||
var addMethod = function(length, method, attribute) {
|
||||
switch (length) {
|
||||
case 1: return function() {
|
||||
@@ -79,10 +84,10 @@
|
||||
return _[method](this[attribute], value);
|
||||
};
|
||||
case 3: return function(iteratee, context) {
|
||||
return _[method](this[attribute], iteratee, context);
|
||||
return _[method](this[attribute], cb(iteratee, this), context);
|
||||
};
|
||||
case 4: return function(iteratee, defaultVal, context) {
|
||||
return _[method](this[attribute], iteratee, defaultVal, context);
|
||||
return _[method](this[attribute], cb(iteratee, this), defaultVal, context);
|
||||
};
|
||||
default: return function() {
|
||||
var args = slice.call(arguments);
|
||||
@@ -97,12 +102,26 @@
|
||||
});
|
||||
};
|
||||
|
||||
// Support `collection.sortBy('attr')` and `collection.findWhere({id: 1})`.
|
||||
var cb = function(iteratee, instance) {
|
||||
if (_.isFunction(iteratee)) return iteratee;
|
||||
if (_.isObject(iteratee) && !instance._isModel(iteratee)) return modelMatcher(iteratee);
|
||||
if (_.isString(iteratee)) return function(model) { return model.get(iteratee); };
|
||||
return iteratee;
|
||||
};
|
||||
var modelMatcher = function(attrs) {
|
||||
var matcher = _.matches(attrs);
|
||||
return function(model) {
|
||||
return matcher(model.attributes);
|
||||
};
|
||||
};
|
||||
|
||||
// Backbone.Events
|
||||
// ---------------
|
||||
|
||||
// A module that can be mixed in to *any object* in order to provide it with
|
||||
// custom events. You may bind with `on` or remove with `off` callback
|
||||
// functions to an event; `trigger`-ing an event fires all callbacks in
|
||||
// a custom event channel. You may bind a callback to an event with `on` or
|
||||
// remove with `off`; `trigger`-ing an event fires all callbacks in
|
||||
// succession.
|
||||
//
|
||||
// var object = {};
|
||||
@@ -117,26 +136,25 @@
|
||||
|
||||
// Iterates over the standard `event, callback` (as well as the fancy multiple
|
||||
// space-separated events `"change blur", callback` and jQuery-style event
|
||||
// maps `{event: callback}`), reducing them by manipulating `memo`.
|
||||
// Passes a normalized single event name and callback, as well as any
|
||||
// optional `opts`.
|
||||
var eventsApi = function(iteratee, memo, name, callback, opts) {
|
||||
// maps `{event: callback}`).
|
||||
var eventsApi = function(iteratee, events, name, callback, opts) {
|
||||
var i = 0, names;
|
||||
if (name && typeof name === 'object') {
|
||||
// Handle event maps.
|
||||
if (callback !== void 0 && 'context' in opts && opts.context === void 0) opts.context = callback;
|
||||
for (names = _.keys(name); i < names.length ; i++) {
|
||||
memo = iteratee(memo, names[i], name[names[i]], opts);
|
||||
events = eventsApi(iteratee, events, names[i], name[names[i]], opts);
|
||||
}
|
||||
} else if (name && eventSplitter.test(name)) {
|
||||
// Handle space separated event names.
|
||||
// Handle space separated event names by delegating them individually.
|
||||
for (names = name.split(eventSplitter); i < names.length; i++) {
|
||||
memo = iteratee(memo, names[i], callback, opts);
|
||||
events = iteratee(events, names[i], callback, opts);
|
||||
}
|
||||
} else {
|
||||
memo = iteratee(memo, name, callback, opts);
|
||||
// Finally, standard events.
|
||||
events = iteratee(events, name, callback, opts);
|
||||
}
|
||||
return memo;
|
||||
return events;
|
||||
};
|
||||
|
||||
// Bind an event to a `callback` function. Passing `"all"` will bind
|
||||
@@ -145,13 +163,12 @@
|
||||
return internalOn(this, name, callback, context);
|
||||
};
|
||||
|
||||
// An internal use `on` function, used to guard the `listening` argument from
|
||||
// the public API.
|
||||
// Guard the `listening` argument from the public API.
|
||||
var internalOn = function(obj, name, callback, context, listening) {
|
||||
obj._events = eventsApi(onApi, obj._events || {}, name, callback, {
|
||||
context: context,
|
||||
ctx: obj,
|
||||
listening: listening
|
||||
context: context,
|
||||
ctx: obj,
|
||||
listening: listening
|
||||
});
|
||||
|
||||
if (listening) {
|
||||
@@ -163,8 +180,9 @@
|
||||
};
|
||||
|
||||
// Inversion-of-control versions of `on`. Tell *this* object to listen to
|
||||
// an event in another object... keeping track of what it's listening to.
|
||||
Events.listenTo = function(obj, name, callback) {
|
||||
// an event in another object... keeping track of what it's listening to
|
||||
// for easier unbinding later.
|
||||
Events.listenTo = function(obj, name, callback) {
|
||||
if (!obj) return this;
|
||||
var id = obj._listenId || (obj._listenId = _.uniqueId('l'));
|
||||
var listeningTo = this._listeningTo || (this._listeningTo = {});
|
||||
@@ -189,7 +207,7 @@
|
||||
var context = options.context, ctx = options.ctx, listening = options.listening;
|
||||
if (listening) listening.count++;
|
||||
|
||||
handlers.push({ callback: callback, context: context, ctx: context || ctx, listening: listening });
|
||||
handlers.push({callback: callback, context: context, ctx: context || ctx, listening: listening});
|
||||
}
|
||||
return events;
|
||||
};
|
||||
@@ -198,18 +216,18 @@
|
||||
// callbacks with that function. If `callback` is null, removes all
|
||||
// callbacks for the event. If `name` is null, removes all bound
|
||||
// callbacks for all events.
|
||||
Events.off = function(name, callback, context) {
|
||||
Events.off = function(name, callback, context) {
|
||||
if (!this._events) return this;
|
||||
this._events = eventsApi(offApi, this._events, name, callback, {
|
||||
context: context,
|
||||
listeners: this._listeners
|
||||
context: context,
|
||||
listeners: this._listeners
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
// Tell this object to stop listening to either specific events ... or
|
||||
// to every object it's currently listening to.
|
||||
Events.stopListening = function(obj, name, callback) {
|
||||
Events.stopListening = function(obj, name, callback) {
|
||||
var listeningTo = this._listeningTo;
|
||||
if (!listeningTo) return this;
|
||||
|
||||
@@ -231,7 +249,6 @@
|
||||
|
||||
// The reducing API that removes a callback from the `events` object.
|
||||
var offApi = function(events, name, callback, options) {
|
||||
// No events to consider.
|
||||
if (!events) return;
|
||||
|
||||
var i = 0, listening;
|
||||
@@ -286,17 +303,17 @@
|
||||
};
|
||||
|
||||
// Bind an event to only be triggered a single time. After the first time
|
||||
// the callback is invoked, it will be removed. When multiple events are
|
||||
// passed in using the space-separated syntax, the event will fire once for every
|
||||
// event you passed in, not once for a combination of all events
|
||||
Events.once = function(name, callback, context) {
|
||||
// the callback is invoked, its listener will be removed. If multiple events
|
||||
// are passed in using the space-separated syntax, the handler will fire
|
||||
// once for each event, not once for a combination of all events.
|
||||
Events.once = function(name, callback, context) {
|
||||
// Map the event into a `{event: once}` object.
|
||||
var events = eventsApi(onceMap, {}, name, callback, _.bind(this.off, this));
|
||||
return this.on(events, void 0, context);
|
||||
};
|
||||
|
||||
// Inversion-of-control versions of `once`.
|
||||
Events.listenToOnce = function(obj, name, callback) {
|
||||
Events.listenToOnce = function(obj, name, callback) {
|
||||
// Map the event into a `{event: once}` object.
|
||||
var events = eventsApi(onceMap, {}, name, callback, _.bind(this.stopListening, this, obj));
|
||||
return this.listenTo(obj, events);
|
||||
@@ -319,7 +336,7 @@
|
||||
// passed the same arguments as `trigger` is, apart from the event name
|
||||
// (unless you're listening on `"all"`, which will cause your callback to
|
||||
// receive the true name of the event as the first argument).
|
||||
Events.trigger = function(name) {
|
||||
Events.trigger = function(name) {
|
||||
if (!this._events) return this;
|
||||
|
||||
var length = Math.max(0, arguments.length - 1);
|
||||
@@ -476,9 +493,6 @@
|
||||
var changed = this.changed;
|
||||
var prev = this._previousAttributes;
|
||||
|
||||
// Check for changes of `id`.
|
||||
if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
|
||||
|
||||
// For each `set` attribute, update or delete the current value.
|
||||
for (var attr in attrs) {
|
||||
val = attrs[attr];
|
||||
@@ -491,6 +505,9 @@
|
||||
unset ? delete current[attr] : current[attr] = val;
|
||||
}
|
||||
|
||||
// Update the `id`.
|
||||
if (this.idAttribute in attrs) this.id = this.get(this.idAttribute);
|
||||
|
||||
// Trigger all relevant attribute changes.
|
||||
if (!silent) {
|
||||
if (changes.length) this._pending = options;
|
||||
@@ -602,8 +619,8 @@
|
||||
// the model will be valid when the attributes, if any, are set.
|
||||
if (attrs && !wait) {
|
||||
if (!this.set(attrs, options)) return false;
|
||||
} else {
|
||||
if (!this._validate(attrs, options)) return false;
|
||||
} else if (!this._validate(attrs, options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// After a successful server-side save, the client is (optionally)
|
||||
@@ -713,9 +730,10 @@
|
||||
|
||||
});
|
||||
|
||||
// Underscore methods that we want to implement on the Model.
|
||||
var modelMethods = { keys: 1, values: 1, pairs: 1, invert: 1, pick: 0,
|
||||
omit: 0, chain: 1, isEmpty: 1 };
|
||||
// Underscore methods that we want to implement on the Model, mapped to the
|
||||
// number of arguments they take.
|
||||
var modelMethods = {keys: 1, values: 1, pairs: 1, invert: 1, pick: 0,
|
||||
omit: 0, chain: 1, isEmpty: 1};
|
||||
|
||||
// Mix in each Underscore method as a proxy to `Model#attributes`.
|
||||
addUnderscoreMethods(Model, modelMethods, 'attributes');
|
||||
@@ -746,6 +764,17 @@
|
||||
var setOptions = {add: true, remove: true, merge: true};
|
||||
var addOptions = {add: true, remove: false};
|
||||
|
||||
// Splices `insert` into `array` at index `at`.
|
||||
var splice = function(array, insert, at) {
|
||||
at = Math.min(Math.max(at, 0), array.length);
|
||||
var tail = Array(array.length - at);
|
||||
var length = insert.length;
|
||||
var i;
|
||||
for (i = 0; i < tail.length; i++) tail[i] = array[i + at];
|
||||
for (i = 0; i < length; i++) array[i + at] = insert[i];
|
||||
for (i = 0; i < tail.length; i++) array[i + length + at] = tail[i];
|
||||
};
|
||||
|
||||
// Define the Collection's inheritable methods.
|
||||
_.extend(Collection.prototype, Events, {
|
||||
|
||||
@@ -768,7 +797,9 @@
|
||||
return Backbone.sync.apply(this, arguments);
|
||||
},
|
||||
|
||||
// Add a model, or list of models to the set.
|
||||
// Add a model, or list of models to the set. `models` may be Backbone
|
||||
// Models or raw JavaScript objects to be converted to Models, or any
|
||||
// combination of the two.
|
||||
add: function(models, options) {
|
||||
return this.set(models, _.extend({merge: false}, options, addOptions));
|
||||
},
|
||||
@@ -777,9 +808,9 @@
|
||||
remove: function(models, options) {
|
||||
options = _.extend({}, options);
|
||||
var singular = !_.isArray(models);
|
||||
models = singular ? [models] : _.clone(models);
|
||||
models = singular ? [models] : models.slice();
|
||||
var removed = this._removeModels(models, options);
|
||||
if (!options.silent && removed) this.trigger('update', this, options);
|
||||
if (!options.silent && removed.length) this.trigger('update', this, options);
|
||||
return singular ? removed[0] : removed;
|
||||
},
|
||||
|
||||
@@ -788,83 +819,90 @@
|
||||
// already exist in the collection, as necessary. Similar to **Model#set**,
|
||||
// the core operation for updating the data contained by the collection.
|
||||
set: function(models, options) {
|
||||
if (models == null) return;
|
||||
|
||||
options = _.defaults({}, options, setOptions);
|
||||
if (options.parse && !this._isModel(models)) models = this.parse(models, options);
|
||||
if (options.parse && !this._isModel(models)) {
|
||||
models = this.parse(models, options) || [];
|
||||
}
|
||||
|
||||
var singular = !_.isArray(models);
|
||||
models = singular ? (models ? [models] : []) : models.slice();
|
||||
var id, model, attrs, existing, sort;
|
||||
models = singular ? [models] : models.slice();
|
||||
|
||||
var at = options.at;
|
||||
if (at != null) at = +at;
|
||||
if (at < 0) at += this.length + 1;
|
||||
var sortable = this.comparator && (at == null) && options.sort !== false;
|
||||
|
||||
var set = [];
|
||||
var toAdd = [];
|
||||
var toRemove = [];
|
||||
var modelMap = {};
|
||||
|
||||
var add = options.add;
|
||||
var merge = options.merge;
|
||||
var remove = options.remove;
|
||||
|
||||
var sort = false;
|
||||
var sortable = this.comparator && at == null && options.sort !== false;
|
||||
var sortAttr = _.isString(this.comparator) ? this.comparator : null;
|
||||
var toAdd = [], toRemove = [], modelMap = {};
|
||||
var add = options.add, merge = options.merge, remove = options.remove;
|
||||
var order = !sortable && add && remove ? [] : false;
|
||||
var orderChanged = false;
|
||||
|
||||
// Turn bare objects into model references, and prevent invalid models
|
||||
// from being added.
|
||||
for (var i = 0; i < models.length; i++) {
|
||||
attrs = models[i];
|
||||
var model, i;
|
||||
for (i = 0; i < models.length; i++) {
|
||||
model = models[i];
|
||||
|
||||
// If a duplicate is found, prevent it from being added and
|
||||
// optionally merge it into the existing model.
|
||||
if (existing = this.get(attrs)) {
|
||||
if (remove) modelMap[existing.cid] = true;
|
||||
if (merge && attrs !== existing) {
|
||||
attrs = this._isModel(attrs) ? attrs.attributes : attrs;
|
||||
var existing = this.get(model);
|
||||
if (existing) {
|
||||
if (merge && model !== existing) {
|
||||
var attrs = this._isModel(model) ? model.attributes : model;
|
||||
if (options.parse) attrs = existing.parse(attrs, options);
|
||||
existing.set(attrs, options);
|
||||
if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true;
|
||||
if (sortable && !sort) sort = existing.hasChanged(sortAttr);
|
||||
}
|
||||
if (!modelMap[existing.cid]) {
|
||||
modelMap[existing.cid] = true;
|
||||
set.push(existing);
|
||||
}
|
||||
models[i] = existing;
|
||||
|
||||
// If this is a new, valid model, push it to the `toAdd` list.
|
||||
} else if (add) {
|
||||
model = models[i] = this._prepareModel(attrs, options);
|
||||
if (!model) continue;
|
||||
toAdd.push(model);
|
||||
this._addReference(model, options);
|
||||
model = models[i] = this._prepareModel(model, options);
|
||||
if (model) {
|
||||
toAdd.push(model);
|
||||
this._addReference(model, options);
|
||||
modelMap[model.cid] = true;
|
||||
set.push(model);
|
||||
}
|
||||
}
|
||||
|
||||
// Do not add multiple models with the same `id`.
|
||||
model = existing || model;
|
||||
if (!model) continue;
|
||||
id = this.modelId(model.attributes);
|
||||
if (order && (model.isNew() || !modelMap[id])) {
|
||||
order.push(model);
|
||||
|
||||
// Check to see if this is actually a new model at this index.
|
||||
orderChanged = orderChanged || !this.models[i] || model.cid !== this.models[i].cid;
|
||||
}
|
||||
|
||||
modelMap[id] = true;
|
||||
}
|
||||
|
||||
// Remove nonexistent models if appropriate.
|
||||
// Remove stale models.
|
||||
if (remove) {
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model);
|
||||
for (i = 0; i < this.length; i++) {
|
||||
model = this.models[i];
|
||||
if (!modelMap[model.cid]) toRemove.push(model);
|
||||
}
|
||||
if (toRemove.length) this._removeModels(toRemove, options);
|
||||
}
|
||||
|
||||
// See if sorting is needed, update `length` and splice in new models.
|
||||
if (toAdd.length || orderChanged) {
|
||||
var orderChanged = false;
|
||||
var replace = !sortable && add && remove;
|
||||
if (set.length && replace) {
|
||||
orderChanged = this.length !== set.length || _.some(this.models, function(model, index) {
|
||||
return model !== set[index];
|
||||
});
|
||||
this.models.length = 0;
|
||||
splice(this.models, set, 0);
|
||||
this.length = this.models.length;
|
||||
} else if (toAdd.length) {
|
||||
if (sortable) sort = true;
|
||||
this.length += toAdd.length;
|
||||
if (at != null) {
|
||||
for (var i = 0; i < toAdd.length; i++) {
|
||||
this.models.splice(at + i, 0, toAdd[i]);
|
||||
}
|
||||
} else {
|
||||
if (order) this.models.length = 0;
|
||||
var orderedModels = order || toAdd;
|
||||
for (var i = 0; i < orderedModels.length; i++) {
|
||||
this.models.push(orderedModels[i]);
|
||||
}
|
||||
}
|
||||
splice(this.models, toAdd, at == null ? this.length : at);
|
||||
this.length = this.models.length;
|
||||
}
|
||||
|
||||
// Silently sort the collection if appropriate.
|
||||
@@ -872,10 +910,10 @@
|
||||
|
||||
// Unless silenced, it's time to fire all appropriate add/sort events.
|
||||
if (!options.silent) {
|
||||
var addOpts = at != null ? _.clone(options) : options;
|
||||
for (var i = 0; i < toAdd.length; i++) {
|
||||
if (at != null) addOpts.index = at + i;
|
||||
(model = toAdd[i]).trigger('add', model, this, addOpts);
|
||||
for (i = 0; i < toAdd.length; i++) {
|
||||
if (at != null) options.index = at + i;
|
||||
model = toAdd[i];
|
||||
model.trigger('add', model, this, options);
|
||||
}
|
||||
if (sort || orderChanged) this.trigger('sort', this, options);
|
||||
if (toAdd.length || toRemove.length) this.trigger('update', this, options);
|
||||
@@ -944,10 +982,7 @@
|
||||
// Return models with matching attributes. Useful for simple cases of
|
||||
// `filter`.
|
||||
where: function(attrs, first) {
|
||||
var matches = _.matches(attrs);
|
||||
return this[first ? 'find' : 'filter'](function(model) {
|
||||
return matches(model.attributes);
|
||||
});
|
||||
return this[first ? 'find' : 'filter'](attrs);
|
||||
},
|
||||
|
||||
// Return the first model with matching attributes. Useful for simple cases
|
||||
@@ -960,23 +995,26 @@
|
||||
// normal circumstances, as the set will maintain sort order as each item
|
||||
// is added.
|
||||
sort: function(options) {
|
||||
if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
|
||||
var comparator = this.comparator;
|
||||
if (!comparator) throw new Error('Cannot sort a set without a comparator');
|
||||
options || (options = {});
|
||||
|
||||
// Run sort based on type of `comparator`.
|
||||
if (_.isString(this.comparator) || this.comparator.length === 1) {
|
||||
this.models = this.sortBy(this.comparator, this);
|
||||
} else {
|
||||
this.models.sort(_.bind(this.comparator, this));
|
||||
}
|
||||
var length = comparator.length;
|
||||
if (_.isFunction(comparator)) comparator = _.bind(comparator, this);
|
||||
|
||||
// Run sort based on type of `comparator`.
|
||||
if (length === 1 || _.isString(comparator)) {
|
||||
this.models = this.sortBy(comparator);
|
||||
} else {
|
||||
this.models.sort(comparator);
|
||||
}
|
||||
if (!options.silent) this.trigger('sort', this, options);
|
||||
return this;
|
||||
},
|
||||
|
||||
// Pluck an attribute from each model in the collection.
|
||||
pluck: function(attr) {
|
||||
return _.invoke(this.models, 'get', attr);
|
||||
return this.map(attr + '');
|
||||
},
|
||||
|
||||
// Fetch the default set of models for this collection, resetting the
|
||||
@@ -1030,7 +1068,7 @@
|
||||
},
|
||||
|
||||
// Define how to uniquely identify models in the collection.
|
||||
modelId: function (attrs) {
|
||||
modelId: function(attrs) {
|
||||
return attrs[this.model.prototype.idAttribute || 'id'];
|
||||
},
|
||||
|
||||
@@ -1058,7 +1096,6 @@
|
||||
},
|
||||
|
||||
// Internal method called by both remove and set.
|
||||
// Returns removed models, or false if nothing is removed.
|
||||
_removeModels: function(models, options) {
|
||||
var removed = [];
|
||||
for (var i = 0; i < models.length; i++) {
|
||||
@@ -1069,6 +1106,12 @@
|
||||
this.models.splice(index, 1);
|
||||
this.length--;
|
||||
|
||||
// Remove references before triggering 'remove' event to prevent an
|
||||
// infinite loop. #3693
|
||||
delete this._byId[model.cid];
|
||||
var id = this.modelId(model.attributes);
|
||||
if (id != null) delete this._byId[id];
|
||||
|
||||
if (!options.silent) {
|
||||
options.index = index;
|
||||
model.trigger('remove', model, this, options);
|
||||
@@ -1077,12 +1120,12 @@
|
||||
removed.push(model);
|
||||
this._removeReference(model, options);
|
||||
}
|
||||
return removed.length ? removed : false;
|
||||
return removed;
|
||||
},
|
||||
|
||||
// Method for checking whether an object should be considered a model for
|
||||
// the purposes of adding to the collection.
|
||||
_isModel: function (model) {
|
||||
_isModel: function(model) {
|
||||
return model instanceof Model;
|
||||
},
|
||||
|
||||
@@ -1108,14 +1151,16 @@
|
||||
// events simply proxy through. "add" and "remove" events that originate
|
||||
// in other collections are ignored.
|
||||
_onModelEvent: function(event, model, collection, options) {
|
||||
if ((event === 'add' || event === 'remove') && collection !== this) return;
|
||||
if (event === 'destroy') this.remove(model, options);
|
||||
if (event === 'change') {
|
||||
var prevId = this.modelId(model.previousAttributes());
|
||||
var id = this.modelId(model.attributes);
|
||||
if (prevId !== id) {
|
||||
if (prevId != null) delete this._byId[prevId];
|
||||
if (id != null) this._byId[id] = model;
|
||||
if (model) {
|
||||
if ((event === 'add' || event === 'remove') && collection !== this) return;
|
||||
if (event === 'destroy') this.remove(model, options);
|
||||
if (event === 'change') {
|
||||
var prevId = this.modelId(model.previousAttributes());
|
||||
var id = this.modelId(model.attributes);
|
||||
if (prevId !== id) {
|
||||
if (prevId != null) delete this._byId[prevId];
|
||||
if (id != null) this._byId[id] = model;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.trigger.apply(this, arguments);
|
||||
@@ -1126,31 +1171,18 @@
|
||||
// Underscore methods that we want to implement on the Collection.
|
||||
// 90% of the core usefulness of Backbone Collections is actually implemented
|
||||
// right here:
|
||||
var collectionMethods = { forEach: 3, each: 3, map: 3, collect: 3, reduce: 4,
|
||||
foldl: 4, inject: 4, reduceRight: 4, foldr: 4, find: 3, detect: 3, filter: 3,
|
||||
select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 2,
|
||||
contains: 2, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3,
|
||||
var collectionMethods = {forEach: 3, each: 3, map: 3, collect: 3, reduce: 0,
|
||||
foldl: 0, inject: 0, reduceRight: 0, foldr: 0, find: 3, detect: 3, filter: 3,
|
||||
select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 3, includes: 3,
|
||||
contains: 3, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3,
|
||||
head: 3, take: 3, initial: 3, rest: 3, tail: 3, drop: 3, last: 3,
|
||||
without: 0, difference: 0, indexOf: 3, shuffle: 1, lastIndexOf: 3,
|
||||
isEmpty: 1, chain: 1, sample: 3, partition: 3 };
|
||||
isEmpty: 1, chain: 1, sample: 3, partition: 3, groupBy: 3, countBy: 3,
|
||||
sortBy: 3, indexBy: 3, findIndex: 3, findLastIndex: 3};
|
||||
|
||||
// Mix in each Underscore method as a proxy to `Collection#models`.
|
||||
addUnderscoreMethods(Collection, collectionMethods, 'models');
|
||||
|
||||
// Underscore methods that take a property name as an argument.
|
||||
var attributeMethods = ['groupBy', 'countBy', 'sortBy', 'indexBy'];
|
||||
|
||||
// Use attributes instead of properties.
|
||||
_.each(attributeMethods, function(method) {
|
||||
if (!_[method]) return;
|
||||
Collection.prototype[method] = function(value, context) {
|
||||
var iterator = _.isFunction(value) ? value : function(model) {
|
||||
return model.get(value);
|
||||
};
|
||||
return _[method](this.models, iterator, context);
|
||||
};
|
||||
});
|
||||
|
||||
// Backbone.View
|
||||
// -------------
|
||||
|
||||
@@ -1174,7 +1206,7 @@
|
||||
// Cached regex to split keys for `delegate`.
|
||||
var delegateEventSplitter = /^(\S+)\s*(.*)$/;
|
||||
|
||||
// List of view options to be merged as properties.
|
||||
// List of view options to be set as properties.
|
||||
var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
|
||||
|
||||
// Set up all inheritable **Backbone.View** properties and methods.
|
||||
@@ -1396,9 +1428,9 @@
|
||||
var methodMap = {
|
||||
'create': 'POST',
|
||||
'update': 'PUT',
|
||||
'patch': 'PATCH',
|
||||
'patch': 'PATCH',
|
||||
'delete': 'DELETE',
|
||||
'read': 'GET'
|
||||
'read': 'GET'
|
||||
};
|
||||
|
||||
// Set the default implementation of `Backbone.ajax` to proxy through to `$`.
|
||||
@@ -1518,7 +1550,7 @@
|
||||
// falls back to polling.
|
||||
var History = Backbone.History = function() {
|
||||
this.handlers = [];
|
||||
_.bindAll(this, 'checkUrl');
|
||||
this.checkUrl = _.bind(this.checkUrl, this);
|
||||
|
||||
// Ensure that `History` can be used outside of the browser.
|
||||
if (typeof window !== 'undefined') {
|
||||
@@ -1611,7 +1643,7 @@
|
||||
this.options = _.extend({root: '/'}, this.options, options);
|
||||
this.root = this.options.root;
|
||||
this._wantsHashChange = this.options.hashChange !== false;
|
||||
this._hasHashChange = 'onhashchange' in window;
|
||||
this._hasHashChange = 'onhashchange' in window && (document.documentMode === void 0 || document.documentMode > 7);
|
||||
this._useHashChange = this._wantsHashChange && this._hasHashChange;
|
||||
this._wantsPushState = !!this.options.pushState;
|
||||
this._hasPushState = !!(this.history && this.history.pushState);
|
||||
@@ -1658,7 +1690,7 @@
|
||||
}
|
||||
|
||||
// Add a cross-platform `addEventListener` shim for older browsers.
|
||||
var addEventListener = window.addEventListener || function (eventName, listener) {
|
||||
var addEventListener = window.addEventListener || function(eventName, listener) {
|
||||
return attachEvent('on' + eventName, listener);
|
||||
};
|
||||
|
||||
@@ -1679,7 +1711,7 @@
|
||||
// but possibly useful for unit testing Routers.
|
||||
stop: function() {
|
||||
// Add a cross-platform `removeEventListener` shim for older browsers.
|
||||
var removeEventListener = window.removeEventListener || function (eventName, listener) {
|
||||
var removeEventListener = window.removeEventListener || function(eventName, listener) {
|
||||
return detachEvent('on' + eventName, listener);
|
||||
};
|
||||
|
||||
@@ -1730,7 +1762,7 @@
|
||||
// If the root doesn't match, no routes can match either.
|
||||
if (!this.matchRoot()) return false;
|
||||
fragment = this.fragment = this.getFragment(fragment);
|
||||
return _.any(this.handlers, function(handler) {
|
||||
return _.some(this.handlers, function(handler) {
|
||||
if (handler.route.test(fragment)) {
|
||||
handler.callback(fragment);
|
||||
return true;
|
||||
@@ -1773,7 +1805,7 @@
|
||||
// fragment to store history.
|
||||
} else if (this._wantsHashChange) {
|
||||
this._updateHash(this.location, fragment, options.replace);
|
||||
if (this.iframe && (fragment !== this.getHash(this.iframe.contentWindow))) {
|
||||
if (this.iframe && fragment !== this.getHash(this.iframe.contentWindow)) {
|
||||
var iWindow = this.iframe.contentWindow;
|
||||
|
||||
// Opening and closing the iframe tricks IE7 and earlier to push a
|
||||
@@ -1835,14 +1867,9 @@
|
||||
_.extend(child, parent, staticProps);
|
||||
|
||||
// Set the prototype chain to inherit from `parent`, without calling
|
||||
// `parent` constructor function.
|
||||
var Surrogate = function(){ this.constructor = child; };
|
||||
Surrogate.prototype = parent.prototype;
|
||||
child.prototype = new Surrogate;
|
||||
|
||||
// Add prototype properties (instance properties) to the subclass,
|
||||
// if supplied.
|
||||
if (protoProps) _.extend(child.prototype, protoProps);
|
||||
// `parent`'s constructor function and add the prototype properties.
|
||||
child.prototype = _.create(parent.prototype, protoProps);
|
||||
child.prototype.constructor = child;
|
||||
|
||||
// Set a convenience property in case the parent's prototype is needed
|
||||
// later.
|
||||
@@ -1870,4 +1897,4 @@
|
||||
|
||||
return Backbone;
|
||||
|
||||
}));
|
||||
});
|
||||
|
||||
1291
vendor/backbone/test/collection.js
vendored
1291
vendor/backbone/test/collection.js
vendored
File diff suppressed because it is too large
Load Diff
473
vendor/backbone/test/events.js
vendored
473
vendor/backbone/test/events.js
vendored
@@ -1,42 +1,44 @@
|
||||
(function() {
|
||||
|
||||
module("Backbone.Events");
|
||||
QUnit.module('Backbone.Events');
|
||||
|
||||
test("on and trigger", 2, function() {
|
||||
var obj = { counter: 0 };
|
||||
_.extend(obj,Backbone.Events);
|
||||
QUnit.test('on and trigger', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
obj.on('event', function() { obj.counter += 1; });
|
||||
obj.trigger('event');
|
||||
equal(obj.counter,1,'counter should be incremented.');
|
||||
assert.equal(obj.counter, 1, 'counter should be incremented.');
|
||||
obj.trigger('event');
|
||||
obj.trigger('event');
|
||||
obj.trigger('event');
|
||||
obj.trigger('event');
|
||||
equal(obj.counter, 5, 'counter should be incremented five times.');
|
||||
assert.equal(obj.counter, 5, 'counter should be incremented five times.');
|
||||
});
|
||||
|
||||
test("binding and triggering multiple events", 4, function() {
|
||||
var obj = { counter: 0 };
|
||||
QUnit.test('binding and triggering multiple events', function(assert) {
|
||||
assert.expect(4);
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
obj.on('a b c', function() { obj.counter += 1; });
|
||||
|
||||
obj.trigger('a');
|
||||
equal(obj.counter, 1);
|
||||
assert.equal(obj.counter, 1);
|
||||
|
||||
obj.trigger('a b');
|
||||
equal(obj.counter, 3);
|
||||
assert.equal(obj.counter, 3);
|
||||
|
||||
obj.trigger('c');
|
||||
equal(obj.counter, 4);
|
||||
assert.equal(obj.counter, 4);
|
||||
|
||||
obj.off('a c');
|
||||
obj.trigger('a b c');
|
||||
equal(obj.counter, 5);
|
||||
assert.equal(obj.counter, 5);
|
||||
});
|
||||
|
||||
test("binding and triggering with event maps", function() {
|
||||
var obj = { counter: 0 };
|
||||
QUnit.test('binding and triggering with event maps', function(assert) {
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
var increment = function() {
|
||||
@@ -50,54 +52,85 @@
|
||||
}, obj);
|
||||
|
||||
obj.trigger('a');
|
||||
equal(obj.counter, 1);
|
||||
assert.equal(obj.counter, 1);
|
||||
|
||||
obj.trigger('a b');
|
||||
equal(obj.counter, 3);
|
||||
assert.equal(obj.counter, 3);
|
||||
|
||||
obj.trigger('c');
|
||||
equal(obj.counter, 4);
|
||||
assert.equal(obj.counter, 4);
|
||||
|
||||
obj.off({
|
||||
a: increment,
|
||||
c: increment
|
||||
}, obj);
|
||||
obj.trigger('a b c');
|
||||
equal(obj.counter, 5);
|
||||
assert.equal(obj.counter, 5);
|
||||
});
|
||||
|
||||
test("binding and trigger with event maps context", 2, function() {
|
||||
var obj = { counter: 0 };
|
||||
QUnit.test('binding and triggering multiple event names with event maps', function(assert) {
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
var increment = function() {
|
||||
this.counter += 1;
|
||||
};
|
||||
|
||||
obj.on({
|
||||
'a b c': increment
|
||||
});
|
||||
|
||||
obj.trigger('a');
|
||||
assert.equal(obj.counter, 1);
|
||||
|
||||
obj.trigger('a b');
|
||||
assert.equal(obj.counter, 3);
|
||||
|
||||
obj.trigger('c');
|
||||
assert.equal(obj.counter, 4);
|
||||
|
||||
obj.off({
|
||||
'a c': increment
|
||||
});
|
||||
obj.trigger('a b c');
|
||||
assert.equal(obj.counter, 5);
|
||||
});
|
||||
|
||||
QUnit.test('binding and trigger with event maps context', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = {counter: 0};
|
||||
var context = {};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
obj.on({
|
||||
a: function() {
|
||||
strictEqual(this, context, 'defaults `context` to `callback` param');
|
||||
}
|
||||
a: function() {
|
||||
assert.strictEqual(this, context, 'defaults `context` to `callback` param');
|
||||
}
|
||||
}, context).trigger('a');
|
||||
|
||||
obj.off().on({
|
||||
a: function() {
|
||||
strictEqual(this, context, 'will not override explicit `context` param');
|
||||
}
|
||||
a: function() {
|
||||
assert.strictEqual(this, context, 'will not override explicit `context` param');
|
||||
}
|
||||
}, this, context).trigger('a');
|
||||
});
|
||||
|
||||
test("listenTo and stopListening", 1, function() {
|
||||
QUnit.test('listenTo and stopListening', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
a.listenTo(b, 'all', function(){ ok(true); });
|
||||
a.listenTo(b, 'all', function(){ assert.ok(true); });
|
||||
b.trigger('anything');
|
||||
a.listenTo(b, 'all', function(){ ok(false); });
|
||||
a.listenTo(b, 'all', function(){ assert.ok(false); });
|
||||
a.stopListening();
|
||||
b.trigger('anything');
|
||||
});
|
||||
|
||||
test("listenTo and stopListening with event maps", 4, function() {
|
||||
QUnit.test('listenTo and stopListening with event maps', function(assert) {
|
||||
assert.expect(4);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
var cb = function(){ ok(true); };
|
||||
var cb = function(){ assert.ok(true); };
|
||||
a.listenTo(b, {event: cb});
|
||||
b.trigger('event');
|
||||
a.listenTo(b, {event2: cb});
|
||||
@@ -108,10 +141,11 @@
|
||||
b.trigger('event event2');
|
||||
});
|
||||
|
||||
test("stopListening with omitted args", 2, function () {
|
||||
QUnit.test('stopListening with omitted args', function(assert) {
|
||||
assert.expect(2);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
var cb = function () { ok(true); };
|
||||
var cb = function() { assert.ok(true); };
|
||||
a.listenTo(b, 'event', cb);
|
||||
b.on('event', cb);
|
||||
a.listenTo(b, 'event2', cb);
|
||||
@@ -124,219 +158,237 @@
|
||||
b.trigger('event2');
|
||||
});
|
||||
|
||||
test("listenToOnce", 2, function() {
|
||||
QUnit.test('listenToOnce', function(assert) {
|
||||
assert.expect(2);
|
||||
// Same as the previous test, but we use once rather than having to explicitly unbind
|
||||
var obj = { counterA: 0, counterB: 0 };
|
||||
var obj = {counterA: 0, counterB: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var incrA = function(){ obj.counterA += 1; obj.trigger('event'); };
|
||||
var incrB = function(){ obj.counterB += 1; };
|
||||
obj.listenToOnce(obj, 'event', incrA);
|
||||
obj.listenToOnce(obj, 'event', incrB);
|
||||
obj.trigger('event');
|
||||
equal(obj.counterA, 1, 'counterA should have only been incremented once.');
|
||||
equal(obj.counterB, 1, 'counterB should have only been incremented once.');
|
||||
assert.equal(obj.counterA, 1, 'counterA should have only been incremented once.');
|
||||
assert.equal(obj.counterB, 1, 'counterB should have only been incremented once.');
|
||||
});
|
||||
|
||||
test("listenToOnce and stopListening", 1, function() {
|
||||
QUnit.test('listenToOnce and stopListening', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
a.listenToOnce(b, 'all', function() { ok(true); });
|
||||
a.listenToOnce(b, 'all', function() { assert.ok(true); });
|
||||
b.trigger('anything');
|
||||
b.trigger('anything');
|
||||
a.listenToOnce(b, 'all', function() { ok(false); });
|
||||
a.listenToOnce(b, 'all', function() { assert.ok(false); });
|
||||
a.stopListening();
|
||||
b.trigger('anything');
|
||||
});
|
||||
|
||||
test("listenTo, listenToOnce and stopListening", 1, function() {
|
||||
QUnit.test('listenTo, listenToOnce and stopListening', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
a.listenToOnce(b, 'all', function() { ok(true); });
|
||||
a.listenToOnce(b, 'all', function() { assert.ok(true); });
|
||||
b.trigger('anything');
|
||||
b.trigger('anything');
|
||||
a.listenTo(b, 'all', function() { ok(false); });
|
||||
a.listenTo(b, 'all', function() { assert.ok(false); });
|
||||
a.stopListening();
|
||||
b.trigger('anything');
|
||||
});
|
||||
|
||||
test("listenTo and stopListening with event maps", 1, function() {
|
||||
QUnit.test('listenTo and stopListening with event maps', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
a.listenTo(b, {change: function(){ ok(true); }});
|
||||
a.listenTo(b, {change: function(){ assert.ok(true); }});
|
||||
b.trigger('change');
|
||||
a.listenTo(b, {change: function(){ ok(false); }});
|
||||
a.listenTo(b, {change: function(){ assert.ok(false); }});
|
||||
a.stopListening();
|
||||
b.trigger('change');
|
||||
});
|
||||
|
||||
test("listenTo yourself", 1, function(){
|
||||
QUnit.test('listenTo yourself', function(assert) {
|
||||
assert.expect(1);
|
||||
var e = _.extend({}, Backbone.Events);
|
||||
e.listenTo(e, "foo", function(){ ok(true); });
|
||||
e.trigger("foo");
|
||||
e.listenTo(e, 'foo', function(){ assert.ok(true); });
|
||||
e.trigger('foo');
|
||||
});
|
||||
|
||||
test("listenTo yourself cleans yourself up with stopListening", 1, function(){
|
||||
QUnit.test('listenTo yourself cleans yourself up with stopListening', function(assert) {
|
||||
assert.expect(1);
|
||||
var e = _.extend({}, Backbone.Events);
|
||||
e.listenTo(e, "foo", function(){ ok(true); });
|
||||
e.trigger("foo");
|
||||
e.listenTo(e, 'foo', function(){ assert.ok(true); });
|
||||
e.trigger('foo');
|
||||
e.stopListening();
|
||||
e.trigger("foo");
|
||||
e.trigger('foo');
|
||||
});
|
||||
|
||||
test("stopListening cleans up references", 12, function() {
|
||||
QUnit.test('stopListening cleans up references', function(assert) {
|
||||
assert.expect(12);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
var fn = function() {};
|
||||
b.on('event', fn);
|
||||
a.listenTo(b, 'event', fn).stopListening();
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._events.event), 1);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._events.event), 1);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
a.listenTo(b, 'event', fn).stopListening(b);
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._events.event), 1);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._events.event), 1);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
a.listenTo(b, 'event', fn).stopListening(b, 'event');
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._events.event), 1);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._events.event), 1);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
a.listenTo(b, 'event', fn).stopListening(b, 'event', fn);
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._events.event), 1);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._events.event), 1);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
});
|
||||
|
||||
test("stopListening cleans up references from listenToOnce", 12, function() {
|
||||
QUnit.test('stopListening cleans up references from listenToOnce', function(assert) {
|
||||
assert.expect(12);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
var fn = function() {};
|
||||
b.on('event', fn);
|
||||
a.listenToOnce(b, 'event', fn).stopListening();
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._events.event), 1);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._events.event), 1);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
a.listenToOnce(b, 'event', fn).stopListening(b);
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._events.event), 1);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._events.event), 1);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
a.listenToOnce(b, 'event', fn).stopListening(b, 'event');
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._events.event), 1);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._events.event), 1);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
a.listenToOnce(b, 'event', fn).stopListening(b, 'event', fn);
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._events.event), 1);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._events.event), 1);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
});
|
||||
|
||||
test("listenTo and off cleaning up references", 8, function() {
|
||||
QUnit.test('listenTo and off cleaning up references', function(assert) {
|
||||
assert.expect(8);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
var fn = function() {};
|
||||
a.listenTo(b, 'event', fn);
|
||||
b.off();
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
a.listenTo(b, 'event', fn);
|
||||
b.off('event');
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
a.listenTo(b, 'event', fn);
|
||||
b.off(null, fn);
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
a.listenTo(b, 'event', fn);
|
||||
b.off(null, null, a);
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
equal(_.size(b._listeners), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(b._listeners), 0);
|
||||
});
|
||||
|
||||
test("listenTo and stopListening cleaning up references", 2, function() {
|
||||
QUnit.test('listenTo and stopListening cleaning up references', function(assert) {
|
||||
assert.expect(2);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
a.listenTo(b, 'all', function(){ ok(true); });
|
||||
a.listenTo(b, 'all', function(){ assert.ok(true); });
|
||||
b.trigger('anything');
|
||||
a.listenTo(b, 'other', function(){ ok(false); });
|
||||
a.listenTo(b, 'other', function(){ assert.ok(false); });
|
||||
a.stopListening(b, 'other');
|
||||
a.stopListening(b, 'all');
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
});
|
||||
|
||||
test("listenToOnce without context cleans up references after the event has fired", 2, function() {
|
||||
QUnit.test('listenToOnce without context cleans up references after the event has fired', function(assert) {
|
||||
assert.expect(2);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
a.listenToOnce(b, 'all', function(){ ok(true); });
|
||||
a.listenToOnce(b, 'all', function(){ assert.ok(true); });
|
||||
b.trigger('anything');
|
||||
equal(_.size(a._listeningTo), 0);
|
||||
assert.equal(_.size(a._listeningTo), 0);
|
||||
});
|
||||
|
||||
test("listenToOnce with event maps cleans up references", 2, function() {
|
||||
QUnit.test('listenToOnce with event maps cleans up references', function(assert) {
|
||||
assert.expect(2);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
a.listenToOnce(b, {
|
||||
one: function() { ok(true); },
|
||||
two: function() { ok(false); }
|
||||
one: function() { assert.ok(true); },
|
||||
two: function() { assert.ok(false); }
|
||||
});
|
||||
b.trigger('one');
|
||||
equal(_.size(a._listeningTo), 1);
|
||||
assert.equal(_.size(a._listeningTo), 1);
|
||||
});
|
||||
|
||||
test("listenToOnce with event maps binds the correct `this`", 1, function() {
|
||||
QUnit.test('listenToOnce with event maps binds the correct `this`', function(assert) {
|
||||
assert.expect(1);
|
||||
var a = _.extend({}, Backbone.Events);
|
||||
var b = _.extend({}, Backbone.Events);
|
||||
a.listenToOnce(b, {
|
||||
one: function() { ok(this === a); },
|
||||
two: function() { ok(false); }
|
||||
one: function() { assert.ok(this === a); },
|
||||
two: function() { assert.ok(false); }
|
||||
});
|
||||
b.trigger('one');
|
||||
});
|
||||
|
||||
test("listenTo with empty callback doesn't throw an error", 1, function(){
|
||||
QUnit.test("listenTo with empty callback doesn't throw an error", function(assert) {
|
||||
assert.expect(1);
|
||||
var e = _.extend({}, Backbone.Events);
|
||||
e.listenTo(e, "foo", null);
|
||||
e.trigger("foo");
|
||||
ok(true);
|
||||
e.listenTo(e, 'foo', null);
|
||||
e.trigger('foo');
|
||||
assert.ok(true);
|
||||
});
|
||||
|
||||
test("trigger all for each event", 3, function() {
|
||||
var a, b, obj = { counter: 0 };
|
||||
QUnit.test('trigger all for each event', function(assert) {
|
||||
assert.expect(3);
|
||||
var a, b, obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
obj.on('all', function(event) {
|
||||
obj.counter++;
|
||||
if (event == 'a') a = true;
|
||||
if (event == 'b') b = true;
|
||||
if (event === 'a') a = true;
|
||||
if (event === 'b') b = true;
|
||||
})
|
||||
.trigger('a b');
|
||||
ok(a);
|
||||
ok(b);
|
||||
equal(obj.counter, 2);
|
||||
assert.ok(a);
|
||||
assert.ok(b);
|
||||
assert.equal(obj.counter, 2);
|
||||
});
|
||||
|
||||
test("on, then unbind all functions", 1, function() {
|
||||
var obj = { counter: 0 };
|
||||
_.extend(obj,Backbone.Events);
|
||||
QUnit.test('on, then unbind all functions', function(assert) {
|
||||
assert.expect(1);
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var callback = function() { obj.counter += 1; };
|
||||
obj.on('event', callback);
|
||||
obj.trigger('event');
|
||||
obj.off('event');
|
||||
obj.trigger('event');
|
||||
equal(obj.counter, 1, 'counter should have only been incremented once.');
|
||||
assert.equal(obj.counter, 1, 'counter should have only been incremented once.');
|
||||
});
|
||||
|
||||
test("bind two callbacks, unbind only one", 2, function() {
|
||||
var obj = { counterA: 0, counterB: 0 };
|
||||
_.extend(obj,Backbone.Events);
|
||||
QUnit.test('bind two callbacks, unbind only one', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = {counterA: 0, counterB: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var callback = function() { obj.counterA += 1; };
|
||||
obj.on('event', callback);
|
||||
obj.on('event', function() { obj.counterB += 1; });
|
||||
obj.trigger('event');
|
||||
obj.off('event', callback);
|
||||
obj.trigger('event');
|
||||
equal(obj.counterA, 1, 'counterA should have only been incremented once.');
|
||||
equal(obj.counterB, 2, 'counterB should have been incremented twice.');
|
||||
assert.equal(obj.counterA, 1, 'counterA should have only been incremented once.');
|
||||
assert.equal(obj.counterB, 2, 'counterB should have been incremented twice.');
|
||||
});
|
||||
|
||||
test("unbind a callback in the midst of it firing", 1, function() {
|
||||
QUnit.test('unbind a callback in the midst of it firing', function(assert) {
|
||||
assert.expect(1);
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var callback = function() {
|
||||
@@ -347,12 +399,13 @@
|
||||
obj.trigger('event');
|
||||
obj.trigger('event');
|
||||
obj.trigger('event');
|
||||
equal(obj.counter, 1, 'the callback should have been unbound.');
|
||||
assert.equal(obj.counter, 1, 'the callback should have been unbound.');
|
||||
});
|
||||
|
||||
test("two binds that unbind themeselves", 2, function() {
|
||||
var obj = { counterA: 0, counterB: 0 };
|
||||
_.extend(obj,Backbone.Events);
|
||||
QUnit.test('two binds that unbind themeselves', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = {counterA: 0, counterB: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var incrA = function(){ obj.counterA += 1; obj.off('event', incrA); };
|
||||
var incrB = function(){ obj.counterB += 1; obj.off('event', incrB); };
|
||||
obj.on('event', incrA);
|
||||
@@ -360,48 +413,52 @@
|
||||
obj.trigger('event');
|
||||
obj.trigger('event');
|
||||
obj.trigger('event');
|
||||
equal(obj.counterA, 1, 'counterA should have only been incremented once.');
|
||||
equal(obj.counterB, 1, 'counterB should have only been incremented once.');
|
||||
assert.equal(obj.counterA, 1, 'counterA should have only been incremented once.');
|
||||
assert.equal(obj.counterB, 1, 'counterB should have only been incremented once.');
|
||||
});
|
||||
|
||||
test("bind a callback with a supplied context", 1, function () {
|
||||
var TestClass = function () {
|
||||
QUnit.test('bind a callback with a supplied context', function(assert) {
|
||||
assert.expect(1);
|
||||
var TestClass = function() {
|
||||
return this;
|
||||
};
|
||||
TestClass.prototype.assertTrue = function () {
|
||||
ok(true, '`this` was bound to the callback');
|
||||
TestClass.prototype.assertTrue = function() {
|
||||
assert.ok(true, '`this` was bound to the callback');
|
||||
};
|
||||
|
||||
var obj = _.extend({},Backbone.Events);
|
||||
obj.on('event', function () { this.assertTrue(); }, (new TestClass));
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.on('event', function() { this.assertTrue(); }, new TestClass);
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
test("nested trigger with unbind", 1, function () {
|
||||
var obj = { counter: 0 };
|
||||
QUnit.test('nested trigger with unbind', function(assert) {
|
||||
assert.expect(1);
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var incr1 = function(){ obj.counter += 1; obj.off('event', incr1); obj.trigger('event'); };
|
||||
var incr2 = function(){ obj.counter += 1; };
|
||||
obj.on('event', incr1);
|
||||
obj.on('event', incr2);
|
||||
obj.trigger('event');
|
||||
equal(obj.counter, 3, 'counter should have been incremented three times');
|
||||
assert.equal(obj.counter, 3, 'counter should have been incremented three times');
|
||||
});
|
||||
|
||||
test("callback list is not altered during trigger", 2, function () {
|
||||
QUnit.test('callback list is not altered during trigger', function(assert) {
|
||||
assert.expect(2);
|
||||
var counter = 0, obj = _.extend({}, Backbone.Events);
|
||||
var incr = function(){ counter++; };
|
||||
var incrOn = function(){ obj.on('event all', incr); };
|
||||
var incrOff = function(){ obj.off('event all', incr); };
|
||||
|
||||
obj.on('event all', incrOn).trigger('event');
|
||||
equal(counter, 0, 'on does not alter callback list');
|
||||
assert.equal(counter, 0, 'on does not alter callback list');
|
||||
|
||||
obj.off().on('event', incrOff).on('event all', incr).trigger('event');
|
||||
equal(counter, 2, 'off does not alter callback list');
|
||||
assert.equal(counter, 2, 'off does not alter callback list');
|
||||
});
|
||||
|
||||
test("#1282 - 'all' callback list is retrieved after each event.", 1, function() {
|
||||
QUnit.test("#1282 - 'all' callback list is retrieved after each event.", function(assert) {
|
||||
assert.expect(1);
|
||||
var counter = 0;
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
var incr = function(){ counter++; };
|
||||
@@ -409,61 +466,68 @@
|
||||
obj.on('y', incr).on('all', incr);
|
||||
})
|
||||
.trigger('x y');
|
||||
strictEqual(counter, 2);
|
||||
assert.strictEqual(counter, 2);
|
||||
});
|
||||
|
||||
test("if no callback is provided, `on` is a noop", 0, function() {
|
||||
QUnit.test('if no callback is provided, `on` is a noop', function(assert) {
|
||||
assert.expect(0);
|
||||
_.extend({}, Backbone.Events).on('test').trigger('test');
|
||||
});
|
||||
|
||||
test("if callback is truthy but not a function, `on` should throw an error just like jQuery", 1, function() {
|
||||
QUnit.test('if callback is truthy but not a function, `on` should throw an error just like jQuery', function(assert) {
|
||||
assert.expect(1);
|
||||
var view = _.extend({}, Backbone.Events).on('test', 'noop');
|
||||
throws(function() {
|
||||
assert.raises(function() {
|
||||
view.trigger('test');
|
||||
});
|
||||
});
|
||||
|
||||
test("remove all events for a specific context", 4, function() {
|
||||
QUnit.test('remove all events for a specific context', function(assert) {
|
||||
assert.expect(4);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.on('x y all', function() { ok(true); });
|
||||
obj.on('x y all', function() { ok(false); }, obj);
|
||||
obj.on('x y all', function() { assert.ok(true); });
|
||||
obj.on('x y all', function() { assert.ok(false); }, obj);
|
||||
obj.off(null, null, obj);
|
||||
obj.trigger('x y');
|
||||
});
|
||||
|
||||
test("remove all events for a specific callback", 4, function() {
|
||||
QUnit.test('remove all events for a specific callback', function(assert) {
|
||||
assert.expect(4);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
var success = function() { ok(true); };
|
||||
var fail = function() { ok(false); };
|
||||
var success = function() { assert.ok(true); };
|
||||
var fail = function() { assert.ok(false); };
|
||||
obj.on('x y all', success);
|
||||
obj.on('x y all', fail);
|
||||
obj.off(null, fail);
|
||||
obj.trigger('x y');
|
||||
});
|
||||
|
||||
test("#1310 - off does not skip consecutive events", 0, function() {
|
||||
QUnit.test('#1310 - off does not skip consecutive events', function(assert) {
|
||||
assert.expect(0);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.on('event', function() { ok(false); }, obj);
|
||||
obj.on('event', function() { ok(false); }, obj);
|
||||
obj.on('event', function() { assert.ok(false); }, obj);
|
||||
obj.on('event', function() { assert.ok(false); }, obj);
|
||||
obj.off(null, null, obj);
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
test("once", 2, function() {
|
||||
QUnit.test('once', function(assert) {
|
||||
assert.expect(2);
|
||||
// Same as the previous test, but we use once rather than having to explicitly unbind
|
||||
var obj = { counterA: 0, counterB: 0 };
|
||||
var obj = {counterA: 0, counterB: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
var incrA = function(){ obj.counterA += 1; obj.trigger('event'); };
|
||||
var incrB = function(){ obj.counterB += 1; };
|
||||
obj.once('event', incrA);
|
||||
obj.once('event', incrB);
|
||||
obj.trigger('event');
|
||||
equal(obj.counterA, 1, 'counterA should have only been incremented once.');
|
||||
equal(obj.counterB, 1, 'counterB should have only been incremented once.');
|
||||
assert.equal(obj.counterA, 1, 'counterA should have only been incremented once.');
|
||||
assert.equal(obj.counterB, 1, 'counterB should have only been incremented once.');
|
||||
});
|
||||
|
||||
test("once variant one", 3, function() {
|
||||
var f = function(){ ok(true); };
|
||||
QUnit.test('once variant one', function(assert) {
|
||||
assert.expect(3);
|
||||
var f = function(){ assert.ok(true); };
|
||||
|
||||
var a = _.extend({}, Backbone.Events).once('event', f);
|
||||
var b = _.extend({}, Backbone.Events).on('event', f);
|
||||
@@ -474,8 +538,9 @@
|
||||
b.trigger('event');
|
||||
});
|
||||
|
||||
test("once variant two", 3, function() {
|
||||
var f = function(){ ok(true); };
|
||||
QUnit.test('once variant two', function(assert) {
|
||||
assert.expect(3);
|
||||
var f = function(){ assert.ok(true); };
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
|
||||
obj
|
||||
@@ -485,8 +550,9 @@
|
||||
.trigger('event');
|
||||
});
|
||||
|
||||
test("once with off", 0, function() {
|
||||
var f = function(){ ok(true); };
|
||||
QUnit.test('once with off', function(assert) {
|
||||
assert.expect(0);
|
||||
var f = function(){ assert.ok(true); };
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
|
||||
obj.once('event', f);
|
||||
@@ -494,8 +560,8 @@
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
test("once with event maps", function() {
|
||||
var obj = { counter: 0 };
|
||||
QUnit.test('once with event maps', function(assert) {
|
||||
var obj = {counter: 0};
|
||||
_.extend(obj, Backbone.Events);
|
||||
|
||||
var increment = function() {
|
||||
@@ -509,94 +575,103 @@
|
||||
}, obj);
|
||||
|
||||
obj.trigger('a');
|
||||
equal(obj.counter, 1);
|
||||
assert.equal(obj.counter, 1);
|
||||
|
||||
obj.trigger('a b');
|
||||
equal(obj.counter, 2);
|
||||
assert.equal(obj.counter, 2);
|
||||
|
||||
obj.trigger('c');
|
||||
equal(obj.counter, 3);
|
||||
assert.equal(obj.counter, 3);
|
||||
|
||||
obj.trigger('a b c');
|
||||
equal(obj.counter, 3);
|
||||
assert.equal(obj.counter, 3);
|
||||
});
|
||||
|
||||
test("once with off only by context", 0, function() {
|
||||
QUnit.test('once with off only by context', function(assert) {
|
||||
assert.expect(0);
|
||||
var context = {};
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.once('event', function(){ ok(false); }, context);
|
||||
obj.once('event', function(){ assert.ok(false); }, context);
|
||||
obj.off(null, null, context);
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
test("Backbone object inherits Events", function() {
|
||||
ok(Backbone.on === Backbone.Events.on);
|
||||
QUnit.test('Backbone object inherits Events', function(assert) {
|
||||
assert.ok(Backbone.on === Backbone.Events.on);
|
||||
});
|
||||
|
||||
asyncTest("once with asynchronous events", 1, function() {
|
||||
var func = _.debounce(function() { ok(true); start(); }, 50);
|
||||
QUnit.test('once with asynchronous events', function(assert) {
|
||||
var done = assert.async();
|
||||
assert.expect(1);
|
||||
var func = _.debounce(function() { assert.ok(true); done(); }, 50);
|
||||
var obj = _.extend({}, Backbone.Events).once('async', func);
|
||||
|
||||
obj.trigger('async');
|
||||
obj.trigger('async');
|
||||
});
|
||||
|
||||
test("once with multiple events.", 2, function() {
|
||||
QUnit.test('once with multiple events.', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.once('x y', function() { ok(true); });
|
||||
obj.once('x y', function() { assert.ok(true); });
|
||||
obj.trigger('x y');
|
||||
});
|
||||
|
||||
test("Off during iteration with once.", 2, function() {
|
||||
QUnit.test('Off during iteration with once.', function(assert) {
|
||||
assert.expect(2);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
var f = function(){ this.off('event', f); };
|
||||
obj.on('event', f);
|
||||
obj.once('event', function(){});
|
||||
obj.on('event', function(){ ok(true); });
|
||||
obj.on('event', function(){ assert.ok(true); });
|
||||
|
||||
obj.trigger('event');
|
||||
obj.trigger('event');
|
||||
});
|
||||
|
||||
test("`once` on `all` should work as expected", 1, function() {
|
||||
QUnit.test('`once` on `all` should work as expected', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.once('all', function() {
|
||||
ok(true);
|
||||
assert.ok(true);
|
||||
Backbone.trigger('all');
|
||||
});
|
||||
Backbone.trigger('all');
|
||||
});
|
||||
|
||||
test("once without a callback is a noop", 0, function() {
|
||||
QUnit.test('once without a callback is a noop', function(assert) {
|
||||
assert.expect(0);
|
||||
_.extend({}, Backbone.Events).once('event').trigger('event');
|
||||
});
|
||||
|
||||
test("listenToOnce without a callback is a noop", 0, function() {
|
||||
QUnit.test('listenToOnce without a callback is a noop', function(assert) {
|
||||
assert.expect(0);
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
obj.listenToOnce(obj, 'event').trigger('event');
|
||||
});
|
||||
|
||||
test("event functions are chainable", function() {
|
||||
QUnit.test('event functions are chainable', function(assert) {
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
var obj2 = _.extend({}, Backbone.Events);
|
||||
var fn = function() {};
|
||||
equal(obj, obj.trigger('noeventssetyet'));
|
||||
equal(obj, obj.off('noeventssetyet'));
|
||||
equal(obj, obj.stopListening('noeventssetyet'));
|
||||
equal(obj, obj.on('a', fn));
|
||||
equal(obj, obj.once('c', fn));
|
||||
equal(obj, obj.trigger('a'));
|
||||
equal(obj, obj.listenTo(obj2, 'a', fn));
|
||||
equal(obj, obj.listenToOnce(obj2, 'b', fn));
|
||||
equal(obj, obj.off('a c'));
|
||||
equal(obj, obj.stopListening(obj2, 'a'));
|
||||
equal(obj, obj.stopListening());
|
||||
assert.equal(obj, obj.trigger('noeventssetyet'));
|
||||
assert.equal(obj, obj.off('noeventssetyet'));
|
||||
assert.equal(obj, obj.stopListening('noeventssetyet'));
|
||||
assert.equal(obj, obj.on('a', fn));
|
||||
assert.equal(obj, obj.once('c', fn));
|
||||
assert.equal(obj, obj.trigger('a'));
|
||||
assert.equal(obj, obj.listenTo(obj2, 'a', fn));
|
||||
assert.equal(obj, obj.listenToOnce(obj2, 'b', fn));
|
||||
assert.equal(obj, obj.off('a c'));
|
||||
assert.equal(obj, obj.stopListening(obj2, 'a'));
|
||||
assert.equal(obj, obj.stopListening());
|
||||
});
|
||||
|
||||
test("#3448 - listenToOnce with space-separated events", 2, function() {
|
||||
QUnit.test('#3448 - listenToOnce with space-separated events', function(assert) {
|
||||
assert.expect(2);
|
||||
var one = _.extend({}, Backbone.Events);
|
||||
var two = _.extend({}, Backbone.Events);
|
||||
var count = 1;
|
||||
one.listenToOnce(two, 'x y', function(n) { ok(n === count++); });
|
||||
one.listenToOnce(two, 'x y', function(n) { assert.ok(n === count++); });
|
||||
two.trigger('x', 1);
|
||||
two.trigger('x', 1);
|
||||
two.trigger('y', 2);
|
||||
|
||||
1089
vendor/backbone/test/model.js
vendored
1089
vendor/backbone/test/model.js
vendored
File diff suppressed because it is too large
Load Diff
9
vendor/backbone/test/noconflict.js
vendored
9
vendor/backbone/test/noconflict.js
vendored
@@ -1,12 +1,13 @@
|
||||
(function() {
|
||||
|
||||
module("Backbone.noConflict");
|
||||
QUnit.module('Backbone.noConflict');
|
||||
|
||||
test('noConflict', 2, function() {
|
||||
QUnit.test('noConflict', function(assert) {
|
||||
assert.expect(2);
|
||||
var noconflictBackbone = Backbone.noConflict();
|
||||
equal(window.Backbone, undefined, 'Returned window.Backbone');
|
||||
assert.equal(window.Backbone, undefined, 'Returned window.Backbone');
|
||||
window.Backbone = noconflictBackbone;
|
||||
equal(window.Backbone, noconflictBackbone, 'Backbone is still pointing to the original Backbone');
|
||||
assert.equal(window.Backbone, noconflictBackbone, 'Backbone is still pointing to the original Backbone');
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
468
vendor/backbone/test/router.js
vendored
468
vendor/backbone/test/router.js
vendored
File diff suppressed because it is too large
Load Diff
6
vendor/backbone/test/setup/dom-setup.js
vendored
6
vendor/backbone/test/setup/dom-setup.js
vendored
@@ -1,6 +1,4 @@
|
||||
$('body').append(
|
||||
'<div id="qunit"></div>' +
|
||||
'<div id="qunit-fixture">' +
|
||||
'<div id="testElement"><h1>Test</h1></div>' +
|
||||
'</div>'
|
||||
);
|
||||
'<div id="qunit-fixture"></div>'
|
||||
);
|
||||
|
||||
2
vendor/backbone/test/setup/environment.js
vendored
2
vendor/backbone/test/setup/environment.js
vendored
@@ -8,6 +8,8 @@
|
||||
var pushState = history.pushState;
|
||||
var replaceState = history.replaceState;
|
||||
|
||||
QUnit.config.noglobals = true;
|
||||
|
||||
QUnit.testStart(function() {
|
||||
var env = QUnit.config.current.testEnvironment;
|
||||
|
||||
|
||||
192
vendor/backbone/test/sync.js
vendored
192
vendor/backbone/test/sync.js
vendored
@@ -1,218 +1,236 @@
|
||||
(function() {
|
||||
|
||||
var Library = Backbone.Collection.extend({
|
||||
url : function() { return '/library'; }
|
||||
url: function() { return '/library'; }
|
||||
});
|
||||
var library;
|
||||
|
||||
var attrs = {
|
||||
title : "The Tempest",
|
||||
author : "Bill Shakespeare",
|
||||
length : 123
|
||||
title: 'The Tempest',
|
||||
author: 'Bill Shakespeare',
|
||||
length: 123
|
||||
};
|
||||
|
||||
module("Backbone.sync", {
|
||||
QUnit.module('Backbone.sync', {
|
||||
|
||||
setup : function() {
|
||||
beforeEach: function(assert) {
|
||||
library = new Library;
|
||||
library.create(attrs, {wait: false});
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
afterEach: function(assert) {
|
||||
Backbone.emulateHTTP = false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
test("read", 4, function() {
|
||||
QUnit.test('read', function(assert) {
|
||||
assert.expect(4);
|
||||
library.fetch();
|
||||
equal(this.ajaxSettings.url, '/library');
|
||||
equal(this.ajaxSettings.type, 'GET');
|
||||
equal(this.ajaxSettings.dataType, 'json');
|
||||
ok(_.isEmpty(this.ajaxSettings.data));
|
||||
assert.equal(this.ajaxSettings.url, '/library');
|
||||
assert.equal(this.ajaxSettings.type, 'GET');
|
||||
assert.equal(this.ajaxSettings.dataType, 'json');
|
||||
assert.ok(_.isEmpty(this.ajaxSettings.data));
|
||||
});
|
||||
|
||||
test("passing data", 3, function() {
|
||||
QUnit.test('passing data', function(assert) {
|
||||
assert.expect(3);
|
||||
library.fetch({data: {a: 'a', one: 1}});
|
||||
equal(this.ajaxSettings.url, '/library');
|
||||
equal(this.ajaxSettings.data.a, 'a');
|
||||
equal(this.ajaxSettings.data.one, 1);
|
||||
assert.equal(this.ajaxSettings.url, '/library');
|
||||
assert.equal(this.ajaxSettings.data.a, 'a');
|
||||
assert.equal(this.ajaxSettings.data.one, 1);
|
||||
});
|
||||
|
||||
test("create", 6, function() {
|
||||
equal(this.ajaxSettings.url, '/library');
|
||||
equal(this.ajaxSettings.type, 'POST');
|
||||
equal(this.ajaxSettings.dataType, 'json');
|
||||
QUnit.test('create', function(assert) {
|
||||
assert.expect(6);
|
||||
assert.equal(this.ajaxSettings.url, '/library');
|
||||
assert.equal(this.ajaxSettings.type, 'POST');
|
||||
assert.equal(this.ajaxSettings.dataType, 'json');
|
||||
var data = JSON.parse(this.ajaxSettings.data);
|
||||
equal(data.title, 'The Tempest');
|
||||
equal(data.author, 'Bill Shakespeare');
|
||||
equal(data.length, 123);
|
||||
assert.equal(data.title, 'The Tempest');
|
||||
assert.equal(data.author, 'Bill Shakespeare');
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
test("update", 7, function() {
|
||||
QUnit.test('update', function(assert) {
|
||||
assert.expect(7);
|
||||
library.first().save({id: '1-the-tempest', author: 'William Shakespeare'});
|
||||
equal(this.ajaxSettings.url, '/library/1-the-tempest');
|
||||
equal(this.ajaxSettings.type, 'PUT');
|
||||
equal(this.ajaxSettings.dataType, 'json');
|
||||
assert.equal(this.ajaxSettings.url, '/library/1-the-tempest');
|
||||
assert.equal(this.ajaxSettings.type, 'PUT');
|
||||
assert.equal(this.ajaxSettings.dataType, 'json');
|
||||
var data = JSON.parse(this.ajaxSettings.data);
|
||||
equal(data.id, '1-the-tempest');
|
||||
equal(data.title, 'The Tempest');
|
||||
equal(data.author, 'William Shakespeare');
|
||||
equal(data.length, 123);
|
||||
assert.equal(data.id, '1-the-tempest');
|
||||
assert.equal(data.title, 'The Tempest');
|
||||
assert.equal(data.author, 'William Shakespeare');
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
test("update with emulateHTTP and emulateJSON", 7, function() {
|
||||
QUnit.test('update with emulateHTTP and emulateJSON', function(assert) {
|
||||
assert.expect(7);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'}, {
|
||||
emulateHTTP: true,
|
||||
emulateJSON: true
|
||||
});
|
||||
equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
equal(this.ajaxSettings.type, 'POST');
|
||||
equal(this.ajaxSettings.dataType, 'json');
|
||||
equal(this.ajaxSettings.data._method, 'PUT');
|
||||
assert.equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
assert.equal(this.ajaxSettings.type, 'POST');
|
||||
assert.equal(this.ajaxSettings.dataType, 'json');
|
||||
assert.equal(this.ajaxSettings.data._method, 'PUT');
|
||||
var data = JSON.parse(this.ajaxSettings.data.model);
|
||||
equal(data.id, '2-the-tempest');
|
||||
equal(data.author, 'Tim Shakespeare');
|
||||
equal(data.length, 123);
|
||||
assert.equal(data.id, '2-the-tempest');
|
||||
assert.equal(data.author, 'Tim Shakespeare');
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
test("update with just emulateHTTP", 6, function() {
|
||||
QUnit.test('update with just emulateHTTP', function(assert) {
|
||||
assert.expect(6);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'}, {
|
||||
emulateHTTP: true
|
||||
});
|
||||
equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
equal(this.ajaxSettings.type, 'POST');
|
||||
equal(this.ajaxSettings.contentType, 'application/json');
|
||||
assert.equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
assert.equal(this.ajaxSettings.type, 'POST');
|
||||
assert.equal(this.ajaxSettings.contentType, 'application/json');
|
||||
var data = JSON.parse(this.ajaxSettings.data);
|
||||
equal(data.id, '2-the-tempest');
|
||||
equal(data.author, 'Tim Shakespeare');
|
||||
equal(data.length, 123);
|
||||
assert.equal(data.id, '2-the-tempest');
|
||||
assert.equal(data.author, 'Tim Shakespeare');
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
test("update with just emulateJSON", 6, function() {
|
||||
QUnit.test('update with just emulateJSON', function(assert) {
|
||||
assert.expect(6);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'}, {
|
||||
emulateJSON: true
|
||||
});
|
||||
equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
equal(this.ajaxSettings.type, 'PUT');
|
||||
equal(this.ajaxSettings.contentType, 'application/x-www-form-urlencoded');
|
||||
assert.equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
assert.equal(this.ajaxSettings.type, 'PUT');
|
||||
assert.equal(this.ajaxSettings.contentType, 'application/x-www-form-urlencoded');
|
||||
var data = JSON.parse(this.ajaxSettings.data.model);
|
||||
equal(data.id, '2-the-tempest');
|
||||
equal(data.author, 'Tim Shakespeare');
|
||||
equal(data.length, 123);
|
||||
assert.equal(data.id, '2-the-tempest');
|
||||
assert.equal(data.author, 'Tim Shakespeare');
|
||||
assert.equal(data.length, 123);
|
||||
});
|
||||
|
||||
test("read model", 3, function() {
|
||||
QUnit.test('read model', function(assert) {
|
||||
assert.expect(3);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'});
|
||||
library.first().fetch();
|
||||
equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
equal(this.ajaxSettings.type, 'GET');
|
||||
ok(_.isEmpty(this.ajaxSettings.data));
|
||||
assert.equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
assert.equal(this.ajaxSettings.type, 'GET');
|
||||
assert.ok(_.isEmpty(this.ajaxSettings.data));
|
||||
});
|
||||
|
||||
test("destroy", 3, function() {
|
||||
QUnit.test('destroy', function(assert) {
|
||||
assert.expect(3);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'});
|
||||
library.first().destroy({wait: true});
|
||||
equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
equal(this.ajaxSettings.type, 'DELETE');
|
||||
equal(this.ajaxSettings.data, null);
|
||||
assert.equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
assert.equal(this.ajaxSettings.type, 'DELETE');
|
||||
assert.equal(this.ajaxSettings.data, null);
|
||||
});
|
||||
|
||||
test("destroy with emulateHTTP", 3, function() {
|
||||
QUnit.test('destroy with emulateHTTP', function(assert) {
|
||||
assert.expect(3);
|
||||
library.first().save({id: '2-the-tempest', author: 'Tim Shakespeare'});
|
||||
library.first().destroy({
|
||||
emulateHTTP: true,
|
||||
emulateJSON: true
|
||||
});
|
||||
equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
equal(this.ajaxSettings.type, 'POST');
|
||||
equal(JSON.stringify(this.ajaxSettings.data), '{"_method":"DELETE"}');
|
||||
assert.equal(this.ajaxSettings.url, '/library/2-the-tempest');
|
||||
assert.equal(this.ajaxSettings.type, 'POST');
|
||||
assert.equal(JSON.stringify(this.ajaxSettings.data), '{"_method":"DELETE"}');
|
||||
});
|
||||
|
||||
test("urlError", 2, function() {
|
||||
QUnit.test('urlError', function(assert) {
|
||||
assert.expect(2);
|
||||
var model = new Backbone.Model();
|
||||
throws(function() {
|
||||
assert.raises(function() {
|
||||
model.fetch();
|
||||
});
|
||||
model.fetch({url: '/one/two'});
|
||||
equal(this.ajaxSettings.url, '/one/two');
|
||||
assert.equal(this.ajaxSettings.url, '/one/two');
|
||||
});
|
||||
|
||||
test("#1052 - `options` is optional.", 0, function() {
|
||||
QUnit.test('#1052 - `options` is optional.', function(assert) {
|
||||
assert.expect(0);
|
||||
var model = new Backbone.Model();
|
||||
model.url = '/test';
|
||||
Backbone.sync('create', model);
|
||||
});
|
||||
|
||||
test("Backbone.ajax", 1, function() {
|
||||
QUnit.test('Backbone.ajax', function(assert) {
|
||||
assert.expect(1);
|
||||
Backbone.ajax = function(settings){
|
||||
strictEqual(settings.url, '/test');
|
||||
assert.strictEqual(settings.url, '/test');
|
||||
};
|
||||
var model = new Backbone.Model();
|
||||
model.url = '/test';
|
||||
Backbone.sync('create', model);
|
||||
});
|
||||
|
||||
test("Call provided error callback on error.", 1, function() {
|
||||
QUnit.test('Call provided error callback on error.', function(assert) {
|
||||
assert.expect(1);
|
||||
var model = new Backbone.Model;
|
||||
model.url = '/test';
|
||||
Backbone.sync('read', model, {
|
||||
error: function() { ok(true); }
|
||||
error: function() { assert.ok(true); }
|
||||
});
|
||||
this.ajaxSettings.error();
|
||||
});
|
||||
|
||||
test('Use Backbone.emulateHTTP as default.', 2, function() {
|
||||
QUnit.test('Use Backbone.emulateHTTP as default.', function(assert) {
|
||||
assert.expect(2);
|
||||
var model = new Backbone.Model;
|
||||
model.url = '/test';
|
||||
|
||||
Backbone.emulateHTTP = true;
|
||||
model.sync('create', model);
|
||||
strictEqual(this.ajaxSettings.emulateHTTP, true);
|
||||
assert.strictEqual(this.ajaxSettings.emulateHTTP, true);
|
||||
|
||||
Backbone.emulateHTTP = false;
|
||||
model.sync('create', model);
|
||||
strictEqual(this.ajaxSettings.emulateHTTP, false);
|
||||
assert.strictEqual(this.ajaxSettings.emulateHTTP, false);
|
||||
});
|
||||
|
||||
test('Use Backbone.emulateJSON as default.', 2, function() {
|
||||
QUnit.test('Use Backbone.emulateJSON as default.', function(assert) {
|
||||
assert.expect(2);
|
||||
var model = new Backbone.Model;
|
||||
model.url = '/test';
|
||||
|
||||
Backbone.emulateJSON = true;
|
||||
model.sync('create', model);
|
||||
strictEqual(this.ajaxSettings.emulateJSON, true);
|
||||
assert.strictEqual(this.ajaxSettings.emulateJSON, true);
|
||||
|
||||
Backbone.emulateJSON = false;
|
||||
model.sync('create', model);
|
||||
strictEqual(this.ajaxSettings.emulateJSON, false);
|
||||
assert.strictEqual(this.ajaxSettings.emulateJSON, false);
|
||||
});
|
||||
|
||||
test("#1756 - Call user provided beforeSend function.", 4, function() {
|
||||
QUnit.test('#1756 - Call user provided beforeSend function.', function(assert) {
|
||||
assert.expect(4);
|
||||
Backbone.emulateHTTP = true;
|
||||
var model = new Backbone.Model;
|
||||
model.url = '/test';
|
||||
var xhr = {
|
||||
setRequestHeader: function(header, value) {
|
||||
strictEqual(header, 'X-HTTP-Method-Override');
|
||||
strictEqual(value, 'DELETE');
|
||||
assert.strictEqual(header, 'X-HTTP-Method-Override');
|
||||
assert.strictEqual(value, 'DELETE');
|
||||
}
|
||||
};
|
||||
model.sync('delete', model, {
|
||||
beforeSend: function(_xhr) {
|
||||
ok(_xhr === xhr);
|
||||
assert.ok(_xhr === xhr);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
strictEqual(this.ajaxSettings.beforeSend(xhr), false);
|
||||
assert.strictEqual(this.ajaxSettings.beforeSend(xhr), false);
|
||||
});
|
||||
|
||||
test('#2928 - Pass along `textStatus` and `errorThrown`.', 2, function() {
|
||||
QUnit.test('#2928 - Pass along `textStatus` and `errorThrown`.', function(assert) {
|
||||
assert.expect(2);
|
||||
var model = new Backbone.Model;
|
||||
model.url = '/test';
|
||||
model.on('error', function(model, xhr, options) {
|
||||
strictEqual(options.textStatus, 'textStatus');
|
||||
strictEqual(options.errorThrown, 'errorThrown');
|
||||
assert.strictEqual(options.textStatus, 'textStatus');
|
||||
assert.strictEqual(options.errorThrown, 'errorThrown');
|
||||
});
|
||||
model.fetch();
|
||||
this.ajaxSettings.error({}, 'textStatus', 'errorThrown');
|
||||
|
||||
283
vendor/backbone/test/view.js
vendored
283
vendor/backbone/test/view.js
vendored
@@ -2,58 +2,68 @@
|
||||
|
||||
var view;
|
||||
|
||||
module("Backbone.View", {
|
||||
QUnit.module('Backbone.View', {
|
||||
|
||||
beforeEach: function(assert) {
|
||||
$('#qunit-fixture').append(
|
||||
'<div id="testElement"><h1>Test</h1></div>'
|
||||
);
|
||||
|
||||
setup: function() {
|
||||
view = new Backbone.View({
|
||||
id : 'test-view',
|
||||
className : 'test-view',
|
||||
other : 'non-special-option'
|
||||
id: 'test-view',
|
||||
className: 'test-view',
|
||||
other: 'non-special-option'
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
test("constructor", 3, function() {
|
||||
equal(view.el.id, 'test-view');
|
||||
equal(view.el.className, 'test-view');
|
||||
equal(view.el.other, void 0);
|
||||
QUnit.test('constructor', function(assert) {
|
||||
assert.expect(3);
|
||||
assert.equal(view.el.id, 'test-view');
|
||||
assert.equal(view.el.className, 'test-view');
|
||||
assert.equal(view.el.other, void 0);
|
||||
});
|
||||
|
||||
test("$", 2, function() {
|
||||
QUnit.test('$', function(assert) {
|
||||
assert.expect(2);
|
||||
var view = new Backbone.View;
|
||||
view.setElement('<p><a><b>test</b></a></p>');
|
||||
var result = view.$('a b');
|
||||
|
||||
strictEqual(result[0].innerHTML, 'test');
|
||||
ok(result.length === +result.length);
|
||||
assert.strictEqual(result[0].innerHTML, 'test');
|
||||
assert.ok(result.length === +result.length);
|
||||
});
|
||||
|
||||
test("$el", 3, function() {
|
||||
QUnit.test('$el', function(assert) {
|
||||
assert.expect(3);
|
||||
var view = new Backbone.View;
|
||||
view.setElement('<p><a><b>test</b></a></p>');
|
||||
strictEqual(view.el.nodeType, 1);
|
||||
assert.strictEqual(view.el.nodeType, 1);
|
||||
|
||||
ok(view.$el instanceof Backbone.$);
|
||||
strictEqual(view.$el[0], view.el);
|
||||
assert.ok(view.$el instanceof Backbone.$);
|
||||
assert.strictEqual(view.$el[0], view.el);
|
||||
});
|
||||
|
||||
test("initialize", 1, function() {
|
||||
QUnit.test('initialize', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
this.one = 1;
|
||||
}
|
||||
});
|
||||
|
||||
strictEqual(new View().one, 1);
|
||||
assert.strictEqual(new View().one, 1);
|
||||
});
|
||||
|
||||
test("render", 1, function() {
|
||||
QUnit.test('render', function(assert) {
|
||||
assert.expect(1);
|
||||
var view = new Backbone.View;
|
||||
equal(view.render(), view, '#render returns the view instance');
|
||||
assert.equal(view.render(), view, '#render returns the view instance');
|
||||
});
|
||||
|
||||
test("delegateEvents", 6, function() {
|
||||
QUnit.test('delegateEvents', function(assert) {
|
||||
assert.expect(6);
|
||||
var counter1 = 0, counter2 = 0;
|
||||
|
||||
var view = new Backbone.View({el: '#testElement'});
|
||||
@@ -64,33 +74,35 @@
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$('h1').trigger('click');
|
||||
equal(counter1, 1);
|
||||
equal(counter2, 1);
|
||||
assert.equal(counter1, 1);
|
||||
assert.equal(counter2, 1);
|
||||
|
||||
view.$('h1').trigger('click');
|
||||
equal(counter1, 2);
|
||||
equal(counter2, 2);
|
||||
assert.equal(counter1, 2);
|
||||
assert.equal(counter2, 2);
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$('h1').trigger('click');
|
||||
equal(counter1, 3);
|
||||
equal(counter2, 3);
|
||||
assert.equal(counter1, 3);
|
||||
assert.equal(counter2, 3);
|
||||
});
|
||||
|
||||
test("delegate", 3, function() {
|
||||
QUnit.test('delegate', function(assert) {
|
||||
assert.expect(3);
|
||||
var view = new Backbone.View({el: '#testElement'});
|
||||
view.delegate('click', 'h1', function() {
|
||||
ok(true);
|
||||
assert.ok(true);
|
||||
});
|
||||
view.delegate('click', function() {
|
||||
ok(true);
|
||||
assert.ok(true);
|
||||
});
|
||||
view.$('h1').trigger('click');
|
||||
|
||||
equal(view.delegate(), view, '#delegate returns the view instance');
|
||||
assert.equal(view.delegate(), view, '#delegate returns the view instance');
|
||||
});
|
||||
|
||||
test("delegateEvents allows functions for callbacks", 3, function() {
|
||||
QUnit.test('delegateEvents allows functions for callbacks', function(assert) {
|
||||
assert.expect(3);
|
||||
var view = new Backbone.View({el: '<p></p>'});
|
||||
view.counter = 0;
|
||||
|
||||
@@ -102,24 +114,26 @@
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$el.trigger('click');
|
||||
equal(view.counter, 1);
|
||||
assert.equal(view.counter, 1);
|
||||
|
||||
view.$el.trigger('click');
|
||||
equal(view.counter, 2);
|
||||
assert.equal(view.counter, 2);
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$el.trigger('click');
|
||||
equal(view.counter, 3);
|
||||
assert.equal(view.counter, 3);
|
||||
});
|
||||
|
||||
|
||||
test("delegateEvents ignore undefined methods", 0, function() {
|
||||
QUnit.test('delegateEvents ignore undefined methods', function(assert) {
|
||||
assert.expect(0);
|
||||
var view = new Backbone.View({el: '<p></p>'});
|
||||
view.delegateEvents({'click': 'undefinedMethod'});
|
||||
view.$el.trigger('click');
|
||||
});
|
||||
|
||||
test("undelegateEvents", 7, function() {
|
||||
QUnit.test('undelegateEvents', function(assert) {
|
||||
assert.expect(7);
|
||||
var counter1 = 0, counter2 = 0;
|
||||
|
||||
var view = new Backbone.View({el: '#testElement'});
|
||||
@@ -130,107 +144,116 @@
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$('h1').trigger('click');
|
||||
equal(counter1, 1);
|
||||
equal(counter2, 1);
|
||||
assert.equal(counter1, 1);
|
||||
assert.equal(counter2, 1);
|
||||
|
||||
view.undelegateEvents();
|
||||
view.$('h1').trigger('click');
|
||||
equal(counter1, 1);
|
||||
equal(counter2, 2);
|
||||
assert.equal(counter1, 1);
|
||||
assert.equal(counter2, 2);
|
||||
|
||||
view.delegateEvents(events);
|
||||
view.$('h1').trigger('click');
|
||||
equal(counter1, 2);
|
||||
equal(counter2, 3);
|
||||
assert.equal(counter1, 2);
|
||||
assert.equal(counter2, 3);
|
||||
|
||||
equal(view.undelegateEvents(), view, '#undelegateEvents returns the view instance');
|
||||
assert.equal(view.undelegateEvents(), view, '#undelegateEvents returns the view instance');
|
||||
});
|
||||
|
||||
test("undelegate", 1, function() {
|
||||
QUnit.test('undelegate', function(assert) {
|
||||
assert.expect(1);
|
||||
view = new Backbone.View({el: '#testElement'});
|
||||
view.delegate('click', function() { ok(false); });
|
||||
view.delegate('click', 'h1', function() { ok(false); });
|
||||
view.delegate('click', function() { assert.ok(false); });
|
||||
view.delegate('click', 'h1', function() { assert.ok(false); });
|
||||
|
||||
view.undelegate('click');
|
||||
|
||||
view.$('h1').trigger('click');
|
||||
view.$el.trigger('click');
|
||||
|
||||
equal(view.undelegate(), view, '#undelegate returns the view instance');
|
||||
assert.equal(view.undelegate(), view, '#undelegate returns the view instance');
|
||||
});
|
||||
|
||||
test("undelegate with passed handler", 1, function() {
|
||||
QUnit.test('undelegate with passed handler', function(assert) {
|
||||
assert.expect(1);
|
||||
view = new Backbone.View({el: '#testElement'});
|
||||
var listener = function() { ok(false); };
|
||||
var listener = function() { assert.ok(false); };
|
||||
view.delegate('click', listener);
|
||||
view.delegate('click', function() { ok(true); });
|
||||
view.delegate('click', function() { assert.ok(true); });
|
||||
view.undelegate('click', listener);
|
||||
view.$el.trigger('click');
|
||||
});
|
||||
|
||||
test("undelegate with selector", 2, function() {
|
||||
QUnit.test('undelegate with selector', function(assert) {
|
||||
assert.expect(2);
|
||||
view = new Backbone.View({el: '#testElement'});
|
||||
view.delegate('click', function() { ok(true); });
|
||||
view.delegate('click', 'h1', function() { ok(false); });
|
||||
view.delegate('click', function() { assert.ok(true); });
|
||||
view.delegate('click', 'h1', function() { assert.ok(false); });
|
||||
view.undelegate('click', 'h1');
|
||||
view.$('h1').trigger('click');
|
||||
view.$el.trigger('click');
|
||||
});
|
||||
|
||||
test("undelegate with handler and selector", 2, function() {
|
||||
QUnit.test('undelegate with handler and selector', function(assert) {
|
||||
assert.expect(2);
|
||||
view = new Backbone.View({el: '#testElement'});
|
||||
view.delegate('click', function() { ok(true); });
|
||||
var handler = function(){ ok(false); };
|
||||
view.delegate('click', function() { assert.ok(true); });
|
||||
var handler = function(){ assert.ok(false); };
|
||||
view.delegate('click', 'h1', handler);
|
||||
view.undelegate('click', 'h1', handler);
|
||||
view.$('h1').trigger('click');
|
||||
view.$el.trigger('click');
|
||||
});
|
||||
|
||||
test("tagName can be provided as a string", 1, function() {
|
||||
QUnit.test('tagName can be provided as a string', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
tagName: 'span'
|
||||
});
|
||||
|
||||
equal(new View().el.tagName, 'SPAN');
|
||||
assert.equal(new View().el.tagName, 'SPAN');
|
||||
});
|
||||
|
||||
test("tagName can be provided as a function", 1, function() {
|
||||
QUnit.test('tagName can be provided as a function', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
tagName: function() {
|
||||
return 'p';
|
||||
}
|
||||
});
|
||||
|
||||
ok(new View().$el.is('p'));
|
||||
assert.ok(new View().$el.is('p'));
|
||||
});
|
||||
|
||||
test("_ensureElement with DOM node el", 1, function() {
|
||||
QUnit.test('_ensureElement with DOM node el', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
el: document.body
|
||||
});
|
||||
|
||||
equal(new View().el, document.body);
|
||||
assert.equal(new View().el, document.body);
|
||||
});
|
||||
|
||||
test("_ensureElement with string el", 3, function() {
|
||||
QUnit.test('_ensureElement with string el', function(assert) {
|
||||
assert.expect(3);
|
||||
var View = Backbone.View.extend({
|
||||
el: "body"
|
||||
el: 'body'
|
||||
});
|
||||
strictEqual(new View().el, document.body);
|
||||
assert.strictEqual(new View().el, document.body);
|
||||
|
||||
View = Backbone.View.extend({
|
||||
el: "#testElement > h1"
|
||||
el: '#testElement > h1'
|
||||
});
|
||||
strictEqual(new View().el, $("#testElement > h1").get(0));
|
||||
assert.strictEqual(new View().el, $('#testElement > h1').get(0));
|
||||
|
||||
View = Backbone.View.extend({
|
||||
el: "#nonexistent"
|
||||
el: '#nonexistent'
|
||||
});
|
||||
ok(!new View().el);
|
||||
assert.ok(!new View().el);
|
||||
});
|
||||
|
||||
test("with className and id functions", 2, function() {
|
||||
QUnit.test('with className and id functions', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
className: function() {
|
||||
return 'className';
|
||||
@@ -240,33 +263,54 @@
|
||||
}
|
||||
});
|
||||
|
||||
strictEqual(new View().el.className, 'className');
|
||||
strictEqual(new View().el.id, 'id');
|
||||
assert.strictEqual(new View().el.className, 'className');
|
||||
assert.strictEqual(new View().el.id, 'id');
|
||||
});
|
||||
|
||||
test("with attributes", 2, function() {
|
||||
QUnit.test('with attributes', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
attributes: {
|
||||
id: 'id',
|
||||
'id': 'id',
|
||||
'class': 'class'
|
||||
}
|
||||
});
|
||||
|
||||
strictEqual(new View().el.className, 'class');
|
||||
strictEqual(new View().el.id, 'id');
|
||||
assert.strictEqual(new View().el.className, 'class');
|
||||
assert.strictEqual(new View().el.id, 'id');
|
||||
});
|
||||
|
||||
test("with attributes as a function", 1, function() {
|
||||
QUnit.test('with attributes as a function', function(assert) {
|
||||
assert.expect(1);
|
||||
var View = Backbone.View.extend({
|
||||
attributes: function() {
|
||||
return {'class': 'dynamic'};
|
||||
}
|
||||
});
|
||||
|
||||
strictEqual(new View().el.className, 'dynamic');
|
||||
assert.strictEqual(new View().el.className, 'dynamic');
|
||||
});
|
||||
|
||||
test("multiple views per element", 3, function() {
|
||||
QUnit.test('should default to className/id properties', function(assert) {
|
||||
assert.expect(4);
|
||||
var View = Backbone.View.extend({
|
||||
className: 'backboneClass',
|
||||
id: 'backboneId',
|
||||
attributes: {
|
||||
'class': 'attributeClass',
|
||||
'id': 'attributeId'
|
||||
}
|
||||
});
|
||||
|
||||
var view = new View;
|
||||
assert.strictEqual(view.el.className, 'backboneClass');
|
||||
assert.strictEqual(view.el.id, 'backboneId');
|
||||
assert.strictEqual(view.$el.attr('class'), 'backboneClass');
|
||||
assert.strictEqual(view.$el.attr('id'), 'backboneId');
|
||||
});
|
||||
|
||||
QUnit.test('multiple views per element', function(assert) {
|
||||
assert.expect(3);
|
||||
var count = 0;
|
||||
var $el = $('<p></p>');
|
||||
|
||||
@@ -280,23 +324,24 @@
|
||||
});
|
||||
|
||||
var view1 = new View;
|
||||
$el.trigger("click");
|
||||
equal(1, count);
|
||||
$el.trigger('click');
|
||||
assert.equal(1, count);
|
||||
|
||||
var view2 = new View;
|
||||
$el.trigger("click");
|
||||
equal(3, count);
|
||||
$el.trigger('click');
|
||||
assert.equal(3, count);
|
||||
|
||||
view1.delegateEvents();
|
||||
$el.trigger("click");
|
||||
equal(5, count);
|
||||
$el.trigger('click');
|
||||
assert.equal(5, count);
|
||||
});
|
||||
|
||||
test("custom events", 2, function() {
|
||||
QUnit.test('custom events', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
el: $('body'),
|
||||
events: {
|
||||
"fake$event": function() { ok(true); }
|
||||
fake$event: function() { assert.ok(true); }
|
||||
}
|
||||
});
|
||||
|
||||
@@ -307,24 +352,26 @@
|
||||
$('body').trigger('fake$event');
|
||||
});
|
||||
|
||||
test("#1048 - setElement uses provided object.", 2, function() {
|
||||
QUnit.test('#1048 - setElement uses provided object.', function(assert) {
|
||||
assert.expect(2);
|
||||
var $el = $('body');
|
||||
|
||||
var view = new Backbone.View({el: $el});
|
||||
ok(view.$el === $el);
|
||||
assert.ok(view.$el === $el);
|
||||
|
||||
view.setElement($el = $($el));
|
||||
ok(view.$el === $el);
|
||||
assert.ok(view.$el === $el);
|
||||
});
|
||||
|
||||
test("#986 - Undelegate before changing element.", 1, function() {
|
||||
QUnit.test('#986 - Undelegate before changing element.', function(assert) {
|
||||
assert.expect(1);
|
||||
var button1 = $('<button></button>');
|
||||
var button2 = $('<button></button>');
|
||||
|
||||
var View = Backbone.View.extend({
|
||||
events: {
|
||||
click: function(e) {
|
||||
ok(view.el === e.target);
|
||||
assert.ok(view.el === e.target);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -336,23 +383,25 @@
|
||||
button2.trigger('click');
|
||||
});
|
||||
|
||||
test("#1172 - Clone attributes object", 2, function() {
|
||||
QUnit.test('#1172 - Clone attributes object', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
attributes: {foo: 'bar'}
|
||||
});
|
||||
|
||||
var view1 = new View({id: 'foo'});
|
||||
strictEqual(view1.el.id, 'foo');
|
||||
assert.strictEqual(view1.el.id, 'foo');
|
||||
|
||||
var view2 = new View();
|
||||
ok(!view2.el.id);
|
||||
assert.ok(!view2.el.id);
|
||||
});
|
||||
|
||||
test("views stopListening", 0, function() {
|
||||
QUnit.test('views stopListening', function(assert) {
|
||||
assert.expect(0);
|
||||
var View = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
this.listenTo(this.model, 'all x', function(){ ok(false); });
|
||||
this.listenTo(this.collection, 'all x', function(){ ok(false); });
|
||||
this.listenTo(this.model, 'all x', function(){ assert.ok(false); });
|
||||
this.listenTo(this.collection, 'all x', function(){ assert.ok(false); });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -366,19 +415,21 @@
|
||||
view.collection.trigger('x');
|
||||
});
|
||||
|
||||
test("Provide function for el.", 2, function() {
|
||||
QUnit.test('Provide function for el.', function(assert) {
|
||||
assert.expect(2);
|
||||
var View = Backbone.View.extend({
|
||||
el: function() {
|
||||
return "<p><a></a></p>";
|
||||
return '<p><a></a></p>';
|
||||
}
|
||||
});
|
||||
|
||||
var view = new View;
|
||||
ok(view.$el.is('p'));
|
||||
ok(view.$el.has('a'));
|
||||
assert.ok(view.$el.is('p'));
|
||||
assert.ok(view.$el.has('a'));
|
||||
});
|
||||
|
||||
test("events passed in options", 1, function() {
|
||||
QUnit.test('events passed in options', function(assert) {
|
||||
assert.expect(1);
|
||||
var counter = 0;
|
||||
|
||||
var View = Backbone.View.extend({
|
||||
@@ -395,32 +446,34 @@
|
||||
});
|
||||
|
||||
view.$('h1').trigger('click').trigger('click');
|
||||
equal(counter, 2);
|
||||
assert.equal(counter, 2);
|
||||
});
|
||||
|
||||
test("remove", 2, function() {
|
||||
QUnit.test('remove', function(assert) {
|
||||
assert.expect(2);
|
||||
var view = new Backbone.View;
|
||||
document.body.appendChild(view.el);
|
||||
|
||||
view.delegate('click', function() { ok(false); });
|
||||
view.listenTo(view, 'all x', function() { ok(false); });
|
||||
view.delegate('click', function() { assert.ok(false); });
|
||||
view.listenTo(view, 'all x', function() { assert.ok(false); });
|
||||
|
||||
equal(view.remove(), view, '#remove returns the view instance');
|
||||
assert.equal(view.remove(), view, '#remove returns the view instance');
|
||||
view.$el.trigger('click');
|
||||
view.trigger('x');
|
||||
|
||||
// In IE8 and below, parentNode still exists but is not document.body.
|
||||
notEqual(view.el.parentNode, document.body);
|
||||
assert.notEqual(view.el.parentNode, document.body);
|
||||
});
|
||||
|
||||
test("setElement", 3, function() {
|
||||
QUnit.test('setElement', function(assert) {
|
||||
assert.expect(3);
|
||||
var view = new Backbone.View({
|
||||
events: {
|
||||
click: function() { ok(false); }
|
||||
click: function() { assert.ok(false); }
|
||||
}
|
||||
});
|
||||
view.events = {
|
||||
click: function() { ok(true); }
|
||||
click: function() { assert.ok(true); }
|
||||
};
|
||||
var oldEl = view.el;
|
||||
var $oldEl = view.$el;
|
||||
@@ -430,8 +483,8 @@
|
||||
$oldEl.click();
|
||||
view.$el.click();
|
||||
|
||||
notEqual(oldEl, view.el);
|
||||
notEqual($oldEl, view.$el);
|
||||
assert.notEqual(oldEl, view.el);
|
||||
assert.notEqual($oldEl, view.$el);
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
2
vendor/benchmark.js/LICENSE
vendored
2
vendor/benchmark.js/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright 2010-2015 Mathias Bynens <http://mathiasbynens.be/>
|
||||
Copyright 2010-2016 Mathias Bynens <https://mathiasbynens.be/>
|
||||
Based on JSLitmus.js, copyright Robert Kieffer <http://broofa.com/>
|
||||
Modified by John-David Dalton <http://allyoucanleet.com/>
|
||||
|
||||
|
||||
185
vendor/benchmark.js/benchmark.js
vendored
185
vendor/benchmark.js/benchmark.js
vendored
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* Benchmark.js v2.0.0-pre <http://benchmarkjs.com/>
|
||||
* Copyright 2010-2015 Mathias Bynens <http://mths.be/>
|
||||
* Benchmark.js v2.1.0 <https://benchmarkjs.com/>
|
||||
* Copyright 2010-2016 Mathias Bynens <https://mths.be/>
|
||||
* Based on JSLitmus.js, copyright Robert Kieffer <http://broofa.com/>
|
||||
* Modified by John-David Dalton <http://allyoucanleet.com/>
|
||||
* Available under MIT license <http://mths.be/mit>
|
||||
* Available under MIT license <https://mths.be/mit>
|
||||
*/
|
||||
;(function() {
|
||||
'use strict';
|
||||
@@ -38,7 +38,7 @@
|
||||
/** Detect free variable `require`. */
|
||||
var freeRequire = typeof require == 'function' && require;
|
||||
|
||||
/** Used to assign each benchmark an incrimented id. */
|
||||
/** Used to assign each benchmark an incremented id. */
|
||||
var counter = 0;
|
||||
|
||||
/** Detect the popular CommonJS extension `module.exports`. */
|
||||
@@ -53,8 +53,8 @@
|
||||
/** Used to assign default `context` object properties. */
|
||||
var contextProps = [
|
||||
'Array', 'Date', 'Function', 'Math', 'Object', 'RegExp', 'String', '_',
|
||||
'clearTimeout', 'chrome', 'chromium', 'document', 'java', 'navigator',
|
||||
'phantom', 'platform', 'process', 'runtime', 'setTimeout'
|
||||
'clearTimeout', 'chrome', 'chromium', 'document', 'navigator', 'phantom',
|
||||
'platform', 'process', 'runtime', 'setTimeout'
|
||||
];
|
||||
|
||||
/** Used to avoid hz of Infinity. */
|
||||
@@ -201,14 +201,6 @@
|
||||
*/
|
||||
support.browser = doc && isHostType(context, 'navigator') && !isHostType(context, 'phantom');
|
||||
|
||||
/**
|
||||
* Detect if Java is enabled/exposed.
|
||||
*
|
||||
* @memberOf Benchmark.support
|
||||
* @type boolean
|
||||
*/
|
||||
support.java = isClassOf(context.java, 'JavaPackage');
|
||||
|
||||
/**
|
||||
* Detect if the Timers API exists.
|
||||
*
|
||||
@@ -217,14 +209,6 @@
|
||||
*/
|
||||
support.timeout = isHostType(context, 'setTimeout') && isHostType(context, 'clearTimeout');
|
||||
|
||||
/**
|
||||
* Detect if `Array#unshift` returns the new length of the array (all but IE < 8).
|
||||
*
|
||||
* @memberOf Benchmark.support
|
||||
* @type boolean
|
||||
*/
|
||||
support.unshiftResult = !![].unshift(1);
|
||||
|
||||
/**
|
||||
* Detect if function decompilation is support.
|
||||
*
|
||||
@@ -293,8 +277,7 @@
|
||||
* methods are:
|
||||
* [`each/forEach`](https://lodash.com/docs#forEach), [`forOwn`](https://lodash.com/docs#forOwn),
|
||||
* [`has`](https://lodash.com/docs#has), [`indexOf`](https://lodash.com/docs#indexOf),
|
||||
* [`map`](https://lodash.com/docs#map), [`pluck`](https://lodash.com/docs#pluck),
|
||||
* and [`reduce`](https://lodash.com/docs#reduce)
|
||||
* [`map`](https://lodash.com/docs#map), and [`reduce`](https://lodash.com/docs#reduce)
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} name A name to identify the benchmark.
|
||||
@@ -371,7 +354,7 @@
|
||||
var bench = this;
|
||||
|
||||
// Allow instance creation without the `new` operator.
|
||||
if (bench == null || bench.constructor != Benchmark) {
|
||||
if (!(bench instanceof Benchmark)) {
|
||||
return new Benchmark(name, fn, options);
|
||||
}
|
||||
// Juggle arguments.
|
||||
@@ -412,7 +395,7 @@
|
||||
*/
|
||||
function Deferred(clone) {
|
||||
var deferred = this;
|
||||
if (deferred == null || deferred.constructor != Deferred) {
|
||||
if (!(deferred instanceof Deferred)) {
|
||||
return new Deferred(clone);
|
||||
}
|
||||
deferred.benchmark = clone;
|
||||
@@ -431,9 +414,9 @@
|
||||
if (type instanceof Event) {
|
||||
return type;
|
||||
}
|
||||
return (event == null || event.constructor != Event)
|
||||
? new Event(type)
|
||||
: _.assign(event, { 'timeStamp': _.now() }, typeof type == 'string' ? { 'type': type } : type);
|
||||
return (event instanceof Event)
|
||||
? _.assign(event, { 'timeStamp': _.now() }, typeof type == 'string' ? { 'type': type } : type)
|
||||
: new Event(type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,8 +425,7 @@
|
||||
* Note: Each Suite instance has a handful of wrapped lodash methods to
|
||||
* make working with Suites easier. The wrapped lodash methods are:
|
||||
* [`each/forEach`](https://lodash.com/docs#forEach), [`indexOf`](https://lodash.com/docs#indexOf),
|
||||
* [`map`](https://lodash.com/docs#map), [`pluck`](https://lodash.com/docs#pluck),
|
||||
* and [`reduce`](https://lodash.com/docs#reduce)
|
||||
* [`map`](https://lodash.com/docs#map), and [`reduce`](https://lodash.com/docs#reduce)
|
||||
*
|
||||
* @constructor
|
||||
* @memberOf Benchmark
|
||||
@@ -483,7 +465,7 @@
|
||||
var suite = this;
|
||||
|
||||
// Allow instance creation without the `new` operator.
|
||||
if (suite == null || suite.constructor != Suite) {
|
||||
if (!(suite instanceof Suite)) {
|
||||
return new Suite(name, options);
|
||||
}
|
||||
// Juggle arguments.
|
||||
@@ -507,7 +489,7 @@
|
||||
* @param {*} value The value to clone.
|
||||
* @returns {*} The cloned value.
|
||||
*/
|
||||
var cloneDeep = _.partial(_.cloneDeep, _, function(value) {
|
||||
var cloneDeep = _.partial(_.cloneDeepWith, _, function(value) {
|
||||
// Only clone primitives, arrays, and plain objects.
|
||||
return (_.isObject(value) && !_.isArray(value) && !_.isPlainObject(value))
|
||||
? value
|
||||
@@ -758,7 +740,6 @@
|
||||
* @memberOf Benchmark
|
||||
* @param {Array} array The array to iterate over.
|
||||
* @param {Function|string} callback The function/alias called per iteration.
|
||||
* @param {*} thisArg The `this` binding for the callback.
|
||||
* @returns {Array} A new array of values that passed callback filter.
|
||||
* @example
|
||||
*
|
||||
@@ -776,11 +757,11 @@
|
||||
* // get benchmarks that completed without erroring
|
||||
* Benchmark.filter(benches, 'successful');
|
||||
*/
|
||||
function filter(array, callback, thisArg) {
|
||||
function filter(array, callback) {
|
||||
if (callback === 'successful') {
|
||||
// Callback to exclude those that are errored, unrun, or have hz of Infinity.
|
||||
callback = function(bench) {
|
||||
return bench.cycles && _.isFinite(bench.hz);
|
||||
return bench.cycles && _.isFinite(bench.hz) && !bench.error;
|
||||
};
|
||||
}
|
||||
else if (callback === 'fastest' || callback === 'slowest') {
|
||||
@@ -794,7 +775,7 @@
|
||||
return result[0].compare(bench) == 0;
|
||||
});
|
||||
}
|
||||
return _.filter(array, callback, thisArg);
|
||||
return _.filter(array, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -931,7 +912,7 @@
|
||||
function isAsync(object) {
|
||||
// Avoid using `instanceof` here because of IE memory leak issues with host objects.
|
||||
var async = args[0] && args[0].async;
|
||||
return Object(object).constructor == Benchmark && name == 'run' &&
|
||||
return name == 'run' && (object instanceof Benchmark) &&
|
||||
((async == null ? object.options.async : async) && support.timeout || object.defer);
|
||||
}
|
||||
|
||||
@@ -950,7 +931,6 @@
|
||||
? index
|
||||
: (index = false);
|
||||
}
|
||||
|
||||
// Juggle arguments.
|
||||
if (_.isString(name)) {
|
||||
// 2 arguments (array, name).
|
||||
@@ -962,7 +942,6 @@
|
||||
args = _.isArray(args = 'args' in options ? options.args : []) ? args : [args];
|
||||
queued = options.queued;
|
||||
}
|
||||
|
||||
// Start iterating over the array.
|
||||
if (raiseIndex() !== false) {
|
||||
// Emit "start" event.
|
||||
@@ -972,7 +951,7 @@
|
||||
options.onStart.call(benches, Event(eventProps));
|
||||
|
||||
// End early if the suite was aborted in an "onStart" listener.
|
||||
if (benches.aborted && benches.constructor == Suite && name == 'run') {
|
||||
if (name == 'run' && (benches instanceof Suite) && benches.aborted) {
|
||||
// Emit "cycle" event.
|
||||
eventProps.type = 'cycle';
|
||||
options.onCycle.call(benches, Event(eventProps));
|
||||
@@ -1440,7 +1419,7 @@
|
||||
function getZ(u) {
|
||||
return (u - ((size1 * size2) / 2)) / sqrt((size1 * size2 * (size1 + size2 + 1)) / 12);
|
||||
}
|
||||
// Reject the null hyphothesis the two samples come from the
|
||||
// Reject the null hypothesis the two samples come from the
|
||||
// same population (i.e. have the same median) if...
|
||||
if (size1 + size2 > 30) {
|
||||
// ...the z-stat is greater than 1.96 or less than -1.96
|
||||
@@ -1544,7 +1523,7 @@
|
||||
id = bench.id,
|
||||
stats = bench.stats,
|
||||
size = stats.sample.length,
|
||||
pm = support.java ? '+/-' : '\xb1',
|
||||
pm = '\xb1',
|
||||
result = bench.name || (_.isNaN(id) ? id : '<Test #' + id + '>');
|
||||
|
||||
if (error) {
|
||||
@@ -1566,8 +1545,7 @@
|
||||
* @returns {number} The time taken.
|
||||
*/
|
||||
function clock() {
|
||||
var applet,
|
||||
options = Benchmark.options,
|
||||
var options = Benchmark.options,
|
||||
templateData = {},
|
||||
timers = [{ 'ns': timer.ns, 'res': max(0.0015, getRes('ms')), 'unit': 'ms' }];
|
||||
|
||||
@@ -1590,16 +1568,6 @@
|
||||
// Init `minTime` if needed.
|
||||
clone.minTime = bench.minTime || (bench.minTime = bench.options.minTime = options.minTime);
|
||||
|
||||
// Repair nanosecond timer.
|
||||
// Some Chrome builds erase the `ns` variable after millions of executions.
|
||||
if (applet) {
|
||||
try {
|
||||
timer.ns.nanoTime();
|
||||
} catch(e) {
|
||||
// Use non-element to avoid issues with libs that augment them.
|
||||
timer.ns = new applet.Packages.nano;
|
||||
}
|
||||
}
|
||||
// Compile in setup/teardown functions and the test loop.
|
||||
// Create a new compiled test, instead of using the cached `bench.compiled`,
|
||||
// to avoid potential engine optimizations enabled over the life of the test.
|
||||
@@ -1696,17 +1664,10 @@
|
||||
|
||||
// Use API of chosen timer.
|
||||
if (timer.unit == 'ns') {
|
||||
if (timer.ns.nanoTime) {
|
||||
_.assign(templateData, {
|
||||
'begin': interpolate('s#=n#.nanoTime()'),
|
||||
'end': interpolate('r#=(n#.nanoTime()-s#)/1e9')
|
||||
});
|
||||
} else {
|
||||
_.assign(templateData, {
|
||||
'begin': interpolate('s#=n#()'),
|
||||
'end': interpolate('r#=n#(s#);r#=r#[0]+(r#[1]/1e9)')
|
||||
});
|
||||
}
|
||||
_.assign(templateData, {
|
||||
'begin': interpolate('s#=n#()'),
|
||||
'end': interpolate('r#=n#(s#);r#=r#[0]+(r#[1]/1e9)')
|
||||
});
|
||||
}
|
||||
else if (timer.unit == 'us') {
|
||||
if (timer.ns.stop) {
|
||||
@@ -1777,14 +1738,9 @@
|
||||
}
|
||||
else if (unit == 'ns') {
|
||||
divisor = 1e9;
|
||||
if (ns.nanoTime) {
|
||||
begin = ns.nanoTime();
|
||||
while (!(measured = ns.nanoTime() - begin)) {}
|
||||
} else {
|
||||
begin = (begin = ns())[0] + (begin[1] / divisor);
|
||||
while (!(measured = ((measured = ns())[0] + (measured[1] / divisor)) - begin)) {}
|
||||
divisor = 1;
|
||||
}
|
||||
begin = (begin = ns())[0] + (begin[1] / divisor);
|
||||
while (!(measured = ((measured = ns())[0] + (measured[1] / divisor)) - begin)) {}
|
||||
divisor = 1;
|
||||
}
|
||||
else if (ns.now) {
|
||||
begin = ns.now();
|
||||
@@ -1794,8 +1750,7 @@
|
||||
begin = new ns().getTime();
|
||||
while (!(measured = new ns().getTime() - begin)) {}
|
||||
}
|
||||
// Check for broken timers (`nanoTime` may have issues).
|
||||
// For more information see http://alivebutsleepy.srnet.cz/unreliable-system-nanotime/.
|
||||
// Check for broken timers.
|
||||
if (measured > 0) {
|
||||
sample.push(measured);
|
||||
} else {
|
||||
@@ -1817,18 +1772,6 @@
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
// Detect nanosecond support from a Java applet.
|
||||
_.each(doc && doc.applets || [], function(element) {
|
||||
return !(timer.ns = applet = 'nanoTime' in element && element);
|
||||
});
|
||||
|
||||
// Check type in case Safari returns an object instead of a number.
|
||||
try {
|
||||
if (typeof timer.ns.nanoTime() == 'number') {
|
||||
timers.push({ 'ns': timer.ns, 'res': getRes('ns'), 'unit': 'ns' });
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
// Detect Chrome's microsecond timer:
|
||||
// enable benchmarking via the --enable-benchmarking command
|
||||
// line switch in at least Chrome 7 to use chrome.Interval
|
||||
@@ -1847,12 +1790,8 @@
|
||||
timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' });
|
||||
}
|
||||
// Pick timer with highest resolution.
|
||||
timer = _.min(timers, 'res');
|
||||
timer = _.minBy(timers, 'res');
|
||||
|
||||
// Remove unused applet.
|
||||
if (timer.unit != 'ns' && applet) {
|
||||
applet = destroyElement(applet);
|
||||
}
|
||||
// Error if there are no working timers.
|
||||
if (timer.res == Infinity) {
|
||||
throw new Error('Benchmark.js was unable to find a working timer.');
|
||||
@@ -2034,7 +1973,6 @@
|
||||
deferred = clone;
|
||||
clone = clone.benchmark;
|
||||
}
|
||||
|
||||
var clocked,
|
||||
cycles,
|
||||
divisor,
|
||||
@@ -2065,7 +2003,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Continue, if not errored.
|
||||
if (clone.running) {
|
||||
// Compute the time taken to complete last test cycle.
|
||||
@@ -2085,7 +2022,7 @@
|
||||
if (!clocked && (divisor = divisors[clone.cycles]) != null) {
|
||||
count = floor(4e6 / divisor);
|
||||
}
|
||||
// Calculate how many more iterations it will take to achive the `minTime`.
|
||||
// Calculate how many more iterations it will take to achieve the `minTime`.
|
||||
if (count <= clone.count) {
|
||||
count += Math.ceil((minTime - clocked) / period);
|
||||
}
|
||||
@@ -2314,7 +2251,7 @@
|
||||
|
||||
/**
|
||||
* Platform object with properties describing things like browser name,
|
||||
* version, and operating system. See [`platform.js`](http://mths.be/platform).
|
||||
* version, and operating system. See [`platform.js`](https://mths.be/platform).
|
||||
*
|
||||
* @static
|
||||
* @memberOf Benchmark
|
||||
@@ -2341,7 +2278,7 @@
|
||||
* @memberOf Benchmark
|
||||
* @type string
|
||||
*/
|
||||
'version': '2.0.0-pre'
|
||||
'version': '2.1.0'
|
||||
});
|
||||
|
||||
_.assign(Benchmark, {
|
||||
@@ -2354,7 +2291,7 @@
|
||||
});
|
||||
|
||||
// Add lodash methods to Benchmark.
|
||||
_.each(['each', 'forEach', 'forOwn', 'has', 'indexOf', 'map', 'pluck', 'reduce'], function(methodName) {
|
||||
_.each(['each', 'forEach', 'forOwn', 'has', 'indexOf', 'map', 'reduce'], function(methodName) {
|
||||
Benchmark[methodName] = _[methodName];
|
||||
});
|
||||
|
||||
@@ -2802,7 +2739,7 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// Add lodash methods as Suite methods.
|
||||
_.each(['each', 'forEach', 'indexOf', 'map', 'pluck', 'reduce'], function(methodName) {
|
||||
_.each(['each', 'forEach', 'indexOf', 'map', 'reduce'], function(methodName) {
|
||||
var func = _[methodName];
|
||||
Suite.prototype[methodName] = function() {
|
||||
var args = [this];
|
||||
@@ -2813,30 +2750,28 @@
|
||||
|
||||
// Avoid array-like object bugs with `Array#shift` and `Array#splice`
|
||||
// in Firefox < 10 and IE < 9.
|
||||
if (!_.support.spliceObjects) {
|
||||
_.each(['pop', 'shift', 'splice'], function(methodName) {
|
||||
var func = arrayRef[methodName];
|
||||
_.each(['pop', 'shift', 'splice'], function(methodName) {
|
||||
var func = arrayRef[methodName];
|
||||
|
||||
Suite.prototype[methodName] = function() {
|
||||
var value = this,
|
||||
result = func.apply(value, arguments);
|
||||
Suite.prototype[methodName] = function() {
|
||||
var value = this,
|
||||
result = func.apply(value, arguments);
|
||||
|
||||
if (value.length === 0) {
|
||||
delete value[0];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
});
|
||||
|
||||
if (value.length === 0) {
|
||||
delete value[0];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
});
|
||||
}
|
||||
// Avoid buggy `Array#unshift` in IE < 8 which doesn't return the new
|
||||
// length of the array.
|
||||
if (!support.unshiftResult) {
|
||||
Suite.prototype.unshift = function() {
|
||||
var value = this;
|
||||
unshift.apply(value, arguments);
|
||||
return value.length;
|
||||
};
|
||||
}
|
||||
Suite.prototype.unshift = function() {
|
||||
var value = this;
|
||||
unshift.apply(value, arguments);
|
||||
return value.length;
|
||||
};
|
||||
|
||||
return Benchmark;
|
||||
}
|
||||
|
||||
@@ -2858,17 +2793,15 @@
|
||||
|
||||
// Check for `exports` after `define` in case a build optimizer adds an `exports` object.
|
||||
if (freeExports && freeModule) {
|
||||
// Export for Node.js or RingoJS.
|
||||
// Export for Node.js.
|
||||
if (moduleExports) {
|
||||
(freeModule.exports = Benchmark).Benchmark = Benchmark;
|
||||
}
|
||||
// Export for Rhino with CommonJS support.
|
||||
else {
|
||||
freeExports.Benchmark = Benchmark;
|
||||
}
|
||||
// Export for CommonJS support.
|
||||
freeExports.Benchmark = Benchmark;
|
||||
}
|
||||
else {
|
||||
// Export for a browser or Rhino.
|
||||
// Export to the global object.
|
||||
root.Benchmark = Benchmark;
|
||||
}
|
||||
}
|
||||
|
||||
BIN
vendor/benchmark.js/nano.jar
vendored
BIN
vendor/benchmark.js/nano.jar
vendored
Binary file not shown.
514
vendor/underscore/test/arrays.js
vendored
514
vendor/underscore/test/arrays.js
vendored
@@ -3,156 +3,159 @@
|
||||
|
||||
QUnit.module('Arrays');
|
||||
|
||||
test('first', function() {
|
||||
equal(_.first([1, 2, 3]), 1, 'can pull out the first element of an array');
|
||||
equal(_([1, 2, 3]).first(), 1, 'can perform OO-style "first()"');
|
||||
deepEqual(_.first([1, 2, 3], 0), [], 'can pass an index to first');
|
||||
deepEqual(_.first([1, 2, 3], 2), [1, 2], 'can pass an index to first');
|
||||
deepEqual(_.first([1, 2, 3], 5), [1, 2, 3], 'can pass an index to first');
|
||||
QUnit.test('first', function(assert) {
|
||||
assert.equal(_.first([1, 2, 3]), 1, 'can pull out the first element of an array');
|
||||
assert.equal(_([1, 2, 3]).first(), 1, 'can perform OO-style "first()"');
|
||||
assert.deepEqual(_.first([1, 2, 3], 0), [], 'returns an empty array when n <= 0 (0 case)');
|
||||
assert.deepEqual(_.first([1, 2, 3], -1), [], 'returns an empty array when n <= 0 (negative case)');
|
||||
assert.deepEqual(_.first([1, 2, 3], 2), [1, 2], 'can fetch the first n elements');
|
||||
assert.deepEqual(_.first([1, 2, 3], 5), [1, 2, 3], 'returns the whole array if n > length');
|
||||
var result = (function(){ return _.first(arguments); }(4, 3, 2, 1));
|
||||
equal(result, 4, 'works on an arguments object.');
|
||||
assert.equal(result, 4, 'works on an arguments object');
|
||||
result = _.map([[1, 2, 3], [1, 2, 3]], _.first);
|
||||
deepEqual(result, [1, 1], 'works well with _.map');
|
||||
result = (function() { return _.first([1, 2, 3], 2); }());
|
||||
deepEqual(result, [1, 2]);
|
||||
|
||||
equal(_.first(null), undefined, 'handles nulls');
|
||||
strictEqual(_.first([1, 2, 3], -1).length, 0);
|
||||
assert.deepEqual(result, [1, 1], 'works well with _.map');
|
||||
assert.equal(_.first(null), void 0, 'returns undefined when called on null');
|
||||
});
|
||||
|
||||
test('head', function() {
|
||||
strictEqual(_.first, _.head, 'alias for first');
|
||||
QUnit.test('head', function(assert) {
|
||||
assert.strictEqual(_.head, _.first, 'is an alias for first');
|
||||
});
|
||||
|
||||
test('take', function() {
|
||||
strictEqual(_.first, _.take, 'alias for first');
|
||||
QUnit.test('take', function(assert) {
|
||||
assert.strictEqual(_.take, _.first, 'is an alias for first');
|
||||
});
|
||||
|
||||
test('rest', function() {
|
||||
QUnit.test('rest', function(assert) {
|
||||
var numbers = [1, 2, 3, 4];
|
||||
deepEqual(_.rest(numbers), [2, 3, 4], 'working rest()');
|
||||
deepEqual(_.rest(numbers, 0), [1, 2, 3, 4], 'working rest(0)');
|
||||
deepEqual(_.rest(numbers, 2), [3, 4], 'rest can take an index');
|
||||
assert.deepEqual(_.rest(numbers), [2, 3, 4], 'fetches all but the first element');
|
||||
assert.deepEqual(_.rest(numbers, 0), [1, 2, 3, 4], 'returns the whole array when index is 0');
|
||||
assert.deepEqual(_.rest(numbers, 2), [3, 4], 'returns elements starting at the given index');
|
||||
var result = (function(){ return _(arguments).rest(); }(1, 2, 3, 4));
|
||||
deepEqual(result, [2, 3, 4], 'works on arguments object');
|
||||
assert.deepEqual(result, [2, 3, 4], 'works on an arguments object');
|
||||
result = _.map([[1, 2, 3], [1, 2, 3]], _.rest);
|
||||
deepEqual(_.flatten(result), [2, 3, 2, 3], 'works well with _.map');
|
||||
result = (function(){ return _(arguments).rest(); }(1, 2, 3, 4));
|
||||
deepEqual(result, [2, 3, 4], 'works on arguments object');
|
||||
assert.deepEqual(_.flatten(result), [2, 3, 2, 3], 'works well with _.map');
|
||||
});
|
||||
|
||||
test('tail', function() {
|
||||
strictEqual(_.rest, _.tail, 'alias for rest');
|
||||
QUnit.test('tail', function(assert) {
|
||||
assert.strictEqual(_.tail, _.rest, 'is an alias for rest');
|
||||
});
|
||||
|
||||
test('drop', function() {
|
||||
strictEqual(_.rest, _.drop, 'alias for rest');
|
||||
QUnit.test('drop', function(assert) {
|
||||
assert.strictEqual(_.drop, _.rest, 'is an alias for rest');
|
||||
});
|
||||
|
||||
test('initial', function() {
|
||||
deepEqual(_.initial([1, 2, 3, 4, 5]), [1, 2, 3, 4], 'working initial()');
|
||||
deepEqual(_.initial([1, 2, 3, 4], 2), [1, 2], 'initial can take an index');
|
||||
deepEqual(_.initial([1, 2, 3, 4], 6), [], 'initial can take a large index');
|
||||
QUnit.test('initial', function(assert) {
|
||||
assert.deepEqual(_.initial([1, 2, 3, 4, 5]), [1, 2, 3, 4], 'returns all but the last element');
|
||||
assert.deepEqual(_.initial([1, 2, 3, 4], 2), [1, 2], 'returns all but the last n elements');
|
||||
assert.deepEqual(_.initial([1, 2, 3, 4], 6), [], 'returns an empty array when n > length');
|
||||
var result = (function(){ return _(arguments).initial(); }(1, 2, 3, 4));
|
||||
deepEqual(result, [1, 2, 3], 'initial works on arguments object');
|
||||
assert.deepEqual(result, [1, 2, 3], 'works on an arguments object');
|
||||
result = _.map([[1, 2, 3], [1, 2, 3]], _.initial);
|
||||
deepEqual(_.flatten(result), [1, 2, 1, 2], 'initial works with _.map');
|
||||
assert.deepEqual(_.flatten(result), [1, 2, 1, 2], 'works well with _.map');
|
||||
});
|
||||
|
||||
test('last', function() {
|
||||
equal(_.last([1, 2, 3]), 3, 'can pull out the last element of an array');
|
||||
deepEqual(_.last([1, 2, 3], 0), [], 'can pass an index to last');
|
||||
deepEqual(_.last([1, 2, 3], 2), [2, 3], 'can pass an index to last');
|
||||
deepEqual(_.last([1, 2, 3], 5), [1, 2, 3], 'can pass an index to last');
|
||||
QUnit.test('last', function(assert) {
|
||||
assert.equal(_.last([1, 2, 3]), 3, 'can pull out the last element of an array');
|
||||
assert.equal(_([1, 2, 3]).last(), 3, 'can perform OO-style "last()"');
|
||||
assert.deepEqual(_.last([1, 2, 3], 0), [], 'returns an empty array when n <= 0 (0 case)');
|
||||
assert.deepEqual(_.last([1, 2, 3], -1), [], 'returns an empty array when n <= 0 (negative case)');
|
||||
assert.deepEqual(_.last([1, 2, 3], 2), [2, 3], 'can fetch the last n elements');
|
||||
assert.deepEqual(_.last([1, 2, 3], 5), [1, 2, 3], 'returns the whole array if n > length');
|
||||
var result = (function(){ return _(arguments).last(); }(1, 2, 3, 4));
|
||||
equal(result, 4, 'works on an arguments object');
|
||||
assert.equal(result, 4, 'works on an arguments object');
|
||||
result = _.map([[1, 2, 3], [1, 2, 3]], _.last);
|
||||
deepEqual(result, [3, 3], 'works well with _.map');
|
||||
|
||||
equal(_.last(null), undefined, 'handles nulls');
|
||||
strictEqual(_.last([1, 2, 3], -1).length, 0);
|
||||
assert.deepEqual(result, [3, 3], 'works well with _.map');
|
||||
assert.equal(_.last(null), void 0, 'returns undefined when called on null');
|
||||
});
|
||||
|
||||
test('compact', function() {
|
||||
equal(_.compact([0, 1, false, 2, false, 3]).length, 3, 'can trim out all falsy values');
|
||||
var result = (function(){ return _.compact(arguments).length; }(0, 1, false, 2, false, 3));
|
||||
equal(result, 3, 'works on an arguments object');
|
||||
QUnit.test('compact', function(assert) {
|
||||
assert.deepEqual(_.compact([1, false, null, 0, '', void 0, NaN, 2]), [1, 2], 'removes all falsy values');
|
||||
var result = (function(){ return _.compact(arguments); }(0, 1, false, 2, false, 3));
|
||||
assert.deepEqual(result, [1, 2, 3], 'works on an arguments object');
|
||||
result = _.map([[1, false, false], [false, false, 3]], _.compact);
|
||||
assert.deepEqual(result, [[1], [3]], 'works well with _.map');
|
||||
});
|
||||
|
||||
test('flatten', function() {
|
||||
deepEqual(_.flatten(null), [], 'Flattens supports null');
|
||||
deepEqual(_.flatten(void 0), [], 'Flattens supports undefined');
|
||||
QUnit.test('flatten', function(assert) {
|
||||
assert.deepEqual(_.flatten(null), [], 'supports null');
|
||||
assert.deepEqual(_.flatten(void 0), [], 'supports undefined');
|
||||
|
||||
deepEqual(_.flatten([[], [[]], []]), [], 'Flattens empty arrays');
|
||||
deepEqual(_.flatten([[], [[]], []], true), [[]], 'Flattens empty arrays');
|
||||
assert.deepEqual(_.flatten([[], [[]], []]), [], 'supports empty arrays');
|
||||
assert.deepEqual(_.flatten([[], [[]], []], true), [[]], 'can shallowly flatten empty arrays');
|
||||
|
||||
var list = [1, [2], [3, [[[4]]]]];
|
||||
deepEqual(_.flatten(list), [1, 2, 3, 4], 'can flatten nested arrays');
|
||||
deepEqual(_.flatten(list, true), [1, 2, 3, [[[4]]]], 'can shallowly flatten nested arrays');
|
||||
assert.deepEqual(_.flatten(list), [1, 2, 3, 4], 'can flatten nested arrays');
|
||||
assert.deepEqual(_.flatten(list, true), [1, 2, 3, [[[4]]]], 'can shallowly flatten nested arrays');
|
||||
var result = (function(){ return _.flatten(arguments); }(1, [2], [3, [[[4]]]]));
|
||||
deepEqual(result, [1, 2, 3, 4], 'works on an arguments object');
|
||||
assert.deepEqual(result, [1, 2, 3, 4], 'works on an arguments object');
|
||||
list = [[1], [2], [3], [[4]]];
|
||||
deepEqual(_.flatten(list, true), [1, 2, 3, [4]], 'can shallowly flatten arrays containing only other arrays');
|
||||
assert.deepEqual(_.flatten(list, true), [1, 2, 3, [4]], 'can shallowly flatten arrays containing only other arrays');
|
||||
|
||||
equal(_.flatten([_.range(10), _.range(10), 5, 1, 3], true).length, 23);
|
||||
equal(_.flatten([_.range(10), _.range(10), 5, 1, 3]).length, 23);
|
||||
equal(_.flatten([new Array(1000000), _.range(56000), 5, 1, 3]).length, 1056003, 'Flatten can handle massive collections');
|
||||
equal(_.flatten([new Array(1000000), _.range(56000), 5, 1, 3], true).length, 1056003, 'Flatten can handle massive collections');
|
||||
assert.equal(_.flatten([_.range(10), _.range(10), 5, 1, 3], true).length, 23, 'can flatten medium length arrays');
|
||||
assert.equal(_.flatten([_.range(10), _.range(10), 5, 1, 3]).length, 23, 'can shallowly flatten medium length arrays');
|
||||
assert.equal(_.flatten([new Array(1000000), _.range(56000), 5, 1, 3]).length, 1056003, 'can handle massive arrays');
|
||||
assert.equal(_.flatten([new Array(1000000), _.range(56000), 5, 1, 3], true).length, 1056003, 'can handle massive arrays in shallow mode');
|
||||
|
||||
var x = _.range(100000);
|
||||
for (var i = 0; i < 1000; i++) x = [x];
|
||||
assert.deepEqual(_.flatten(x), _.range(100000), 'can handle very deep arrays');
|
||||
assert.deepEqual(_.flatten(x, true), x[0], 'can handle very deep arrays in shallow mode');
|
||||
});
|
||||
|
||||
test('without', function() {
|
||||
QUnit.test('without', function(assert) {
|
||||
var list = [1, 2, 1, 0, 3, 1, 4];
|
||||
deepEqual(_.without(list, 0, 1), [2, 3, 4], 'can remove all instances of an object');
|
||||
assert.deepEqual(_.without(list, 0, 1), [2, 3, 4], 'removes all instances of the given values');
|
||||
var result = (function(){ return _.without(arguments, 0, 1); }(1, 2, 1, 0, 3, 1, 4));
|
||||
deepEqual(result, [2, 3, 4], 'works on an arguments object');
|
||||
assert.deepEqual(result, [2, 3, 4], 'works on an arguments object');
|
||||
|
||||
list = [{one : 1}, {two : 2}];
|
||||
equal(_.without(list, {one : 1}).length, 2, 'uses real object identity for comparisons.');
|
||||
equal(_.without(list, list[0]).length, 1, 'ditto.');
|
||||
list = [{one: 1}, {two: 2}];
|
||||
assert.deepEqual(_.without(list, {one: 1}), list, 'compares objects by reference (value case)');
|
||||
assert.deepEqual(_.without(list, list[0]), [{two: 2}], 'compares objects by reference (reference case)');
|
||||
});
|
||||
|
||||
test('sortedIndex', function() {
|
||||
var numbers = [10, 20, 30, 40, 50], num = 35;
|
||||
var indexForNum = _.sortedIndex(numbers, num);
|
||||
equal(indexForNum, 3, '35 should be inserted at index 3');
|
||||
|
||||
QUnit.test('sortedIndex', function(assert) {
|
||||
var numbers = [10, 20, 30, 40, 50];
|
||||
var indexFor35 = _.sortedIndex(numbers, 35);
|
||||
assert.equal(indexFor35, 3, 'finds the index at which a value should be inserted to retain order');
|
||||
var indexFor30 = _.sortedIndex(numbers, 30);
|
||||
equal(indexFor30, 2, '30 should be inserted at index 2');
|
||||
assert.equal(indexFor30, 2, 'finds the smallest index at which a value could be inserted to retain order');
|
||||
|
||||
var objects = [{x: 10}, {x: 20}, {x: 30}, {x: 40}];
|
||||
var iterator = function(obj){ return obj.x; };
|
||||
strictEqual(_.sortedIndex(objects, {x: 25}, iterator), 2);
|
||||
strictEqual(_.sortedIndex(objects, {x: 35}, 'x'), 3);
|
||||
assert.strictEqual(_.sortedIndex(objects, {x: 25}, iterator), 2, 'uses the result of `iterator` for order comparisons');
|
||||
assert.strictEqual(_.sortedIndex(objects, {x: 35}, 'x'), 3, 'when `iterator` is a string, uses that key for order comparisons');
|
||||
|
||||
var context = {1: 2, 2: 3, 3: 4};
|
||||
iterator = function(obj){ return this[obj]; };
|
||||
strictEqual(_.sortedIndex([1, 3], 2, iterator, context), 1);
|
||||
assert.strictEqual(_.sortedIndex([1, 3], 2, iterator, context), 1, 'can execute its iterator in the given context');
|
||||
|
||||
var values = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647];
|
||||
var array = Array(Math.pow(2, 32) - 1);
|
||||
var values = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287,
|
||||
1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647];
|
||||
var largeArray = Array(Math.pow(2, 32) - 1);
|
||||
var length = values.length;
|
||||
// Sparsely populate `array`
|
||||
while (length--) {
|
||||
array[values[length]] = values[length];
|
||||
largeArray[values[length]] = values[length];
|
||||
}
|
||||
equal(_.sortedIndex(array, 2147483648), 2147483648, 'should work with large indexes');
|
||||
assert.equal(_.sortedIndex(largeArray, 2147483648), 2147483648, 'works with large indexes');
|
||||
});
|
||||
|
||||
test('uniq', function() {
|
||||
QUnit.test('uniq', function(assert) {
|
||||
var list = [1, 2, 1, 3, 1, 4];
|
||||
deepEqual(_.uniq(list), [1, 2, 3, 4], 'can find the unique values of an unsorted array');
|
||||
assert.deepEqual(_.uniq(list), [1, 2, 3, 4], 'can find the unique values of an unsorted array');
|
||||
|
||||
list = [1, 1, 1, 2, 2, 3];
|
||||
deepEqual(_.uniq(list, true), [1, 2, 3], 'can find the unique values of a sorted array faster');
|
||||
assert.deepEqual(_.uniq(list, true), [1, 2, 3], 'can find the unique values of a sorted array faster');
|
||||
|
||||
list = [{name: 'moe'}, {name: 'curly'}, {name: 'larry'}, {name: 'curly'}];
|
||||
var iterator = function(value) { return value.name; };
|
||||
deepEqual(_.map(_.uniq(list, false, iterator), iterator), ['moe', 'curly', 'larry'], 'can find the unique values of an array using a custom iterator');
|
||||
assert.deepEqual(_.map(_.uniq(list, false, iterator), iterator), ['moe', 'curly', 'larry'], 'can find the unique values of an array using a custom iterator');
|
||||
|
||||
deepEqual(_.map(_.uniq(list, iterator), iterator), ['moe', 'curly', 'larry'], 'can find the unique values of an array using a custom iterator without specifying whether array is sorted');
|
||||
assert.deepEqual(_.map(_.uniq(list, iterator), iterator), ['moe', 'curly', 'larry'], 'can find the unique values of an array using a custom iterator without specifying whether array is sorted');
|
||||
|
||||
iterator = function(value) { return value + 1; };
|
||||
list = [1, 2, 2, 3, 4, 4];
|
||||
deepEqual(_.uniq(list, true, iterator), [1, 2, 3, 4], 'iterator works with sorted array');
|
||||
assert.deepEqual(_.uniq(list, true, iterator), [1, 2, 3, 4], 'iterator works with sorted array');
|
||||
|
||||
var kittens = [
|
||||
{kitten: 'Celery', cuteness: 8},
|
||||
@@ -165,236 +168,236 @@
|
||||
{kitten: 'Juniper', cuteness: 10}
|
||||
];
|
||||
|
||||
deepEqual(_.uniq(kittens, true, 'cuteness'), expected, 'string iterator works with sorted array');
|
||||
assert.deepEqual(_.uniq(kittens, true, 'cuteness'), expected, 'string iterator works with sorted array');
|
||||
|
||||
|
||||
var result = (function(){ return _.uniq(arguments); }(1, 2, 1, 3, 1, 4));
|
||||
deepEqual(result, [1, 2, 3, 4], 'works on an arguments object');
|
||||
assert.deepEqual(result, [1, 2, 3, 4], 'works on an arguments object');
|
||||
|
||||
var a = {}, b = {}, c = {};
|
||||
deepEqual(_.uniq([a, b, a, b, c]), [a, b, c], 'works on values that can be tested for equivalency but not ordered');
|
||||
assert.deepEqual(_.uniq([a, b, a, b, c]), [a, b, c], 'works on values that can be tested for equivalency but not ordered');
|
||||
|
||||
deepEqual(_.uniq(null), []);
|
||||
assert.deepEqual(_.uniq(null), []);
|
||||
|
||||
var context = {};
|
||||
list = [3];
|
||||
_.uniq(list, function(value, index, array) {
|
||||
strictEqual(this, context);
|
||||
strictEqual(value, 3);
|
||||
strictEqual(index, 0);
|
||||
strictEqual(array, list);
|
||||
assert.strictEqual(this, context);
|
||||
assert.strictEqual(value, 3);
|
||||
assert.strictEqual(index, 0);
|
||||
assert.strictEqual(array, list);
|
||||
}, context);
|
||||
|
||||
deepEqual(_.uniq([{a: 1, b: 1}, {a: 1, b: 2}, {a: 1, b: 3}, {a: 2, b: 1}], 'a'), [{a: 1, b: 1}, {a: 2, b: 1}], 'can use pluck like iterator');
|
||||
deepEqual(_.uniq([{0: 1, b: 1}, {0: 1, b: 2}, {0: 1, b: 3}, {0: 2, b: 1}], 0), [{0: 1, b: 1}, {0: 2, b: 1}], 'can use falsey pluck like iterator');
|
||||
assert.deepEqual(_.uniq([{a: 1, b: 1}, {a: 1, b: 2}, {a: 1, b: 3}, {a: 2, b: 1}], 'a'), [{a: 1, b: 1}, {a: 2, b: 1}], 'can use pluck like iterator');
|
||||
assert.deepEqual(_.uniq([{0: 1, b: 1}, {0: 1, b: 2}, {0: 1, b: 3}, {0: 2, b: 1}], 0), [{0: 1, b: 1}, {0: 2, b: 1}], 'can use falsey pluck like iterator');
|
||||
});
|
||||
|
||||
test('unique', function() {
|
||||
strictEqual(_.uniq, _.unique, 'alias for uniq');
|
||||
QUnit.test('unique', function(assert) {
|
||||
assert.strictEqual(_.unique, _.uniq, 'is an alias for uniq');
|
||||
});
|
||||
|
||||
test('intersection', function() {
|
||||
QUnit.test('intersection', function(assert) {
|
||||
var stooges = ['moe', 'curly', 'larry'], leaders = ['moe', 'groucho'];
|
||||
deepEqual(_.intersection(stooges, leaders), ['moe'], 'can take the set intersection of two arrays');
|
||||
deepEqual(_(stooges).intersection(leaders), ['moe'], 'can perform an OO-style intersection');
|
||||
assert.deepEqual(_.intersection(stooges, leaders), ['moe'], 'can take the set intersection of two arrays');
|
||||
assert.deepEqual(_(stooges).intersection(leaders), ['moe'], 'can perform an OO-style intersection');
|
||||
var result = (function(){ return _.intersection(arguments, leaders); }('moe', 'curly', 'larry'));
|
||||
deepEqual(result, ['moe'], 'works on an arguments object');
|
||||
assert.deepEqual(result, ['moe'], 'works on an arguments object');
|
||||
var theSixStooges = ['moe', 'moe', 'curly', 'curly', 'larry', 'larry'];
|
||||
deepEqual(_.intersection(theSixStooges, leaders), ['moe'], 'returns a duplicate-free array');
|
||||
assert.deepEqual(_.intersection(theSixStooges, leaders), ['moe'], 'returns a duplicate-free array');
|
||||
result = _.intersection([2, 4, 3, 1], [1, 2, 3]);
|
||||
deepEqual(result, [2, 3, 1], 'preserves order of first array');
|
||||
assert.deepEqual(result, [2, 3, 1], 'preserves order of first array');
|
||||
result = _.intersection(null, [1, 2, 3]);
|
||||
equal(Object.prototype.toString.call(result), '[object Array]', 'returns an empty array when passed null as first argument');
|
||||
equal(result.length, 0, 'returns an empty array when passed null as first argument');
|
||||
assert.equal(Object.prototype.toString.call(result), '[object Array]', 'returns an empty array when passed null as first argument');
|
||||
assert.equal(result.length, 0, 'returns an empty array when passed null as first argument');
|
||||
result = _.intersection([1, 2, 3], null);
|
||||
equal(Object.prototype.toString.call(result), '[object Array]', 'returns an empty array when passed null as argument beyond the first');
|
||||
equal(result.length, 0, 'returns an empty array when passed null as argument beyond the first');
|
||||
assert.equal(Object.prototype.toString.call(result), '[object Array]', 'returns an empty array when passed null as argument beyond the first');
|
||||
assert.equal(result.length, 0, 'returns an empty array when passed null as argument beyond the first');
|
||||
});
|
||||
|
||||
test('union', function() {
|
||||
QUnit.test('union', function(assert) {
|
||||
var result = _.union([1, 2, 3], [2, 30, 1], [1, 40]);
|
||||
deepEqual(result, [1, 2, 3, 30, 40], 'takes the union of a list of arrays');
|
||||
assert.deepEqual(result, [1, 2, 3, 30, 40], 'takes the union of a list of arrays');
|
||||
|
||||
result = _.union([1, 2, 3], [2, 30, 1], [1, 40, [1]]);
|
||||
deepEqual(result, [1, 2, 3, 30, 40, [1]], 'takes the union of a list of nested arrays');
|
||||
assert.deepEqual(result, [1, 2, 3, 30, 40, [1]], 'takes the union of a list of nested arrays');
|
||||
|
||||
var args = null;
|
||||
(function(){ args = arguments; }(1, 2, 3));
|
||||
result = _.union(args, [2, 30, 1], [1, 40]);
|
||||
deepEqual(result, [1, 2, 3, 30, 40], 'takes the union of a list of arrays');
|
||||
assert.deepEqual(result, [1, 2, 3, 30, 40], 'takes the union of a list of arrays');
|
||||
|
||||
result = _.union([1, 2, 3], 4);
|
||||
deepEqual(result, [1, 2, 3], 'restrict the union to arrays only');
|
||||
assert.deepEqual(result, [1, 2, 3], 'restrict the union to arrays only');
|
||||
});
|
||||
|
||||
test('difference', function() {
|
||||
QUnit.test('difference', function(assert) {
|
||||
var result = _.difference([1, 2, 3], [2, 30, 40]);
|
||||
deepEqual(result, [1, 3], 'takes the difference of two arrays');
|
||||
assert.deepEqual(result, [1, 3], 'takes the difference of two arrays');
|
||||
|
||||
result = _.difference([1, 2, 3, 4], [2, 30, 40], [1, 11, 111]);
|
||||
deepEqual(result, [3, 4], 'takes the difference of three arrays');
|
||||
assert.deepEqual(result, [3, 4], 'takes the difference of three arrays');
|
||||
|
||||
result = _.difference([1, 2, 3], 1);
|
||||
deepEqual(result, [1, 2, 3], 'restrict the difference to arrays only');
|
||||
assert.deepEqual(result, [1, 2, 3], 'restrict the difference to arrays only');
|
||||
});
|
||||
|
||||
test('zip', function() {
|
||||
QUnit.test('zip', function(assert) {
|
||||
var names = ['moe', 'larry', 'curly'], ages = [30, 40, 50], leaders = [true];
|
||||
deepEqual(_.zip(names, ages, leaders), [
|
||||
assert.deepEqual(_.zip(names, ages, leaders), [
|
||||
['moe', 30, true],
|
||||
['larry', 40, undefined],
|
||||
['curly', 50, undefined]
|
||||
['larry', 40, void 0],
|
||||
['curly', 50, void 0]
|
||||
], 'zipped together arrays of different lengths');
|
||||
|
||||
var stooges = _.zip(['moe', 30, 'stooge 1'], ['larry', 40, 'stooge 2'], ['curly', 50, 'stooge 3']);
|
||||
deepEqual(stooges, [['moe', 'larry', 'curly'], [30, 40, 50], ['stooge 1', 'stooge 2', 'stooge 3']], 'zipped pairs');
|
||||
assert.deepEqual(stooges, [['moe', 'larry', 'curly'], [30, 40, 50], ['stooge 1', 'stooge 2', 'stooge 3']], 'zipped pairs');
|
||||
|
||||
// In the case of difference lengths of the tuples undefineds
|
||||
// In the case of different lengths of the tuples, undefined values
|
||||
// should be used as placeholder
|
||||
stooges = _.zip(['moe', 30], ['larry', 40], ['curly', 50, 'extra data']);
|
||||
deepEqual(stooges, [['moe', 'larry', 'curly'], [30, 40, 50], [undefined, undefined, 'extra data']], 'zipped pairs with empties');
|
||||
assert.deepEqual(stooges, [['moe', 'larry', 'curly'], [30, 40, 50], [void 0, void 0, 'extra data']], 'zipped pairs with empties');
|
||||
|
||||
var empty = _.zip([]);
|
||||
deepEqual(empty, [], 'unzipped empty');
|
||||
assert.deepEqual(empty, [], 'unzipped empty');
|
||||
|
||||
deepEqual(_.zip(null), [], 'handles null');
|
||||
deepEqual(_.zip(), [], '_.zip() returns []');
|
||||
assert.deepEqual(_.zip(null), [], 'handles null');
|
||||
assert.deepEqual(_.zip(), [], '_.zip() returns []');
|
||||
});
|
||||
|
||||
test('unzip', function() {
|
||||
deepEqual(_.unzip(null), [], 'handles null');
|
||||
QUnit.test('unzip', function(assert) {
|
||||
assert.deepEqual(_.unzip(null), [], 'handles null');
|
||||
|
||||
deepEqual(_.unzip([['a', 'b'], [1, 2]]), [['a', 1], ['b', 2]]);
|
||||
assert.deepEqual(_.unzip([['a', 'b'], [1, 2]]), [['a', 1], ['b', 2]]);
|
||||
|
||||
// complements zip
|
||||
var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);
|
||||
deepEqual(_.unzip(zipped), [['fred', 'barney'], [30, 40], [true, false]]);
|
||||
assert.deepEqual(_.unzip(zipped), [['fred', 'barney'], [30, 40], [true, false]]);
|
||||
|
||||
zipped = _.zip(['moe', 30], ['larry', 40], ['curly', 50, 'extra data']);
|
||||
deepEqual(_.unzip(zipped), [['moe', 30, void 0], ['larry', 40, void 0], ['curly', 50, 'extra data']], 'Uses length of largest array');
|
||||
assert.deepEqual(_.unzip(zipped), [['moe', 30, void 0], ['larry', 40, void 0], ['curly', 50, 'extra data']], 'Uses length of largest array');
|
||||
});
|
||||
|
||||
test('object', function() {
|
||||
QUnit.test('object', function(assert) {
|
||||
var result = _.object(['moe', 'larry', 'curly'], [30, 40, 50]);
|
||||
var shouldBe = {moe: 30, larry: 40, curly: 50};
|
||||
deepEqual(result, shouldBe, 'two arrays zipped together into an object');
|
||||
assert.deepEqual(result, shouldBe, 'two arrays zipped together into an object');
|
||||
|
||||
result = _.object([['one', 1], ['two', 2], ['three', 3]]);
|
||||
shouldBe = {one: 1, two: 2, three: 3};
|
||||
deepEqual(result, shouldBe, 'an array of pairs zipped together into an object');
|
||||
assert.deepEqual(result, shouldBe, 'an array of pairs zipped together into an object');
|
||||
|
||||
var stooges = {moe: 30, larry: 40, curly: 50};
|
||||
deepEqual(_.object(_.pairs(stooges)), stooges, 'an object converted to pairs and back to an object');
|
||||
assert.deepEqual(_.object(_.pairs(stooges)), stooges, 'an object converted to pairs and back to an object');
|
||||
|
||||
deepEqual(_.object(null), {}, 'handles nulls');
|
||||
assert.deepEqual(_.object(null), {}, 'handles nulls');
|
||||
});
|
||||
|
||||
test('indexOf', function() {
|
||||
QUnit.test('indexOf', function(assert) {
|
||||
var numbers = [1, 2, 3];
|
||||
equal(_.indexOf(numbers, 2), 1, 'can compute indexOf');
|
||||
assert.equal(_.indexOf(numbers, 2), 1, 'can compute indexOf');
|
||||
var result = (function(){ return _.indexOf(arguments, 2); }(1, 2, 3));
|
||||
equal(result, 1, 'works on an arguments object');
|
||||
assert.equal(result, 1, 'works on an arguments object');
|
||||
|
||||
_.each([null, void 0, [], false], function(val) {
|
||||
var msg = 'Handles: ' + (_.isArray(val) ? '[]' : val);
|
||||
equal(_.indexOf(val, 2), -1, msg);
|
||||
equal(_.indexOf(val, 2, -1), -1, msg);
|
||||
equal(_.indexOf(val, 2, -20), -1, msg);
|
||||
equal(_.indexOf(val, 2, 15), -1, msg);
|
||||
assert.equal(_.indexOf(val, 2), -1, msg);
|
||||
assert.equal(_.indexOf(val, 2, -1), -1, msg);
|
||||
assert.equal(_.indexOf(val, 2, -20), -1, msg);
|
||||
assert.equal(_.indexOf(val, 2, 15), -1, msg);
|
||||
});
|
||||
|
||||
var num = 35;
|
||||
numbers = [10, 20, 30, 40, 50];
|
||||
var index = _.indexOf(numbers, num, true);
|
||||
equal(index, -1, '35 is not in the list');
|
||||
assert.equal(index, -1, '35 is not in the list');
|
||||
|
||||
numbers = [10, 20, 30, 40, 50]; num = 40;
|
||||
index = _.indexOf(numbers, num, true);
|
||||
equal(index, 3, '40 is in the list');
|
||||
assert.equal(index, 3, '40 is in the list');
|
||||
|
||||
numbers = [1, 40, 40, 40, 40, 40, 40, 40, 50, 60, 70]; num = 40;
|
||||
equal(_.indexOf(numbers, num, true), 1, '40 is in the list');
|
||||
equal(_.indexOf(numbers, 6, true), -1, '6 isnt in the list');
|
||||
equal(_.indexOf([1, 2, 5, 4, 6, 7], 5, true), -1, 'sorted indexOf doesn\'t uses binary search');
|
||||
ok(_.every(['1', [], {}, null], function() {
|
||||
assert.equal(_.indexOf(numbers, num, true), 1, '40 is in the list');
|
||||
assert.equal(_.indexOf(numbers, 6, true), -1, '6 isnt in the list');
|
||||
assert.equal(_.indexOf([1, 2, 5, 4, 6, 7], 5, true), -1, 'sorted indexOf doesn\'t uses binary search');
|
||||
assert.ok(_.every(['1', [], {}, null], function() {
|
||||
return _.indexOf(numbers, num, {}) === 1;
|
||||
}), 'non-nums as fromIndex make indexOf assume sorted');
|
||||
|
||||
numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
|
||||
index = _.indexOf(numbers, 2, 5);
|
||||
equal(index, 7, 'supports the fromIndex argument');
|
||||
assert.equal(index, 7, 'supports the fromIndex argument');
|
||||
|
||||
index = _.indexOf([,,,], undefined);
|
||||
equal(index, 0, 'treats sparse arrays as if they were dense');
|
||||
index = _.indexOf([,,, 0], void 0);
|
||||
assert.equal(index, 0, 'treats sparse arrays as if they were dense');
|
||||
|
||||
var array = [1, 2, 3, 1, 2, 3];
|
||||
strictEqual(_.indexOf(array, 1, -3), 3, 'neg `fromIndex` starts at the right index');
|
||||
strictEqual(_.indexOf(array, 1, -2), -1, 'neg `fromIndex` starts at the right index');
|
||||
strictEqual(_.indexOf(array, 2, -3), 4);
|
||||
assert.strictEqual(_.indexOf(array, 1, -3), 3, 'neg `fromIndex` starts at the right index');
|
||||
assert.strictEqual(_.indexOf(array, 1, -2), -1, 'neg `fromIndex` starts at the right index');
|
||||
assert.strictEqual(_.indexOf(array, 2, -3), 4);
|
||||
_.each([-6, -8, -Infinity], function(fromIndex) {
|
||||
strictEqual(_.indexOf(array, 1, fromIndex), 0);
|
||||
assert.strictEqual(_.indexOf(array, 1, fromIndex), 0);
|
||||
});
|
||||
strictEqual(_.indexOf([1, 2, 3], 1, true), 0);
|
||||
assert.strictEqual(_.indexOf([1, 2, 3], 1, true), 0);
|
||||
|
||||
index = _.indexOf([], undefined, true);
|
||||
equal(index, -1, 'empty array with truthy `isSorted` returns -1');
|
||||
index = _.indexOf([], void 0, true);
|
||||
assert.equal(index, -1, 'empty array with truthy `isSorted` returns -1');
|
||||
});
|
||||
|
||||
test('indexOf with NaN', function() {
|
||||
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN), 2, 'Expected [1, 2, NaN] to contain NaN');
|
||||
strictEqual(_.indexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
|
||||
QUnit.test('indexOf with NaN', function(assert) {
|
||||
assert.strictEqual(_.indexOf([1, 2, NaN, NaN], NaN), 2, 'Expected [1, 2, NaN] to contain NaN');
|
||||
assert.strictEqual(_.indexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
|
||||
|
||||
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN, 1), 2, 'startIndex does not affect result');
|
||||
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN, -2), 2, 'startIndex does not affect result');
|
||||
assert.strictEqual(_.indexOf([1, 2, NaN, NaN], NaN, 1), 2, 'startIndex does not affect result');
|
||||
assert.strictEqual(_.indexOf([1, 2, NaN, NaN], NaN, -2), 2, 'startIndex does not affect result');
|
||||
|
||||
(function() {
|
||||
strictEqual(_.indexOf(arguments, NaN), 2, 'Expected arguments [1, 2, NaN] to contain NaN');
|
||||
assert.strictEqual(_.indexOf(arguments, NaN), 2, 'Expected arguments [1, 2, NaN] to contain NaN');
|
||||
}(1, 2, NaN, NaN));
|
||||
});
|
||||
|
||||
test('indexOf with +- 0', function() {
|
||||
QUnit.test('indexOf with +- 0', function(assert) {
|
||||
_.each([-0, +0], function(val) {
|
||||
strictEqual(_.indexOf([1, 2, val, val], val), 2);
|
||||
strictEqual(_.indexOf([1, 2, val, val], -val), 2);
|
||||
assert.strictEqual(_.indexOf([1, 2, val, val], val), 2);
|
||||
assert.strictEqual(_.indexOf([1, 2, val, val], -val), 2);
|
||||
});
|
||||
});
|
||||
|
||||
test('lastIndexOf', function() {
|
||||
QUnit.test('lastIndexOf', function(assert) {
|
||||
var numbers = [1, 0, 1];
|
||||
var falsey = [void 0, '', 0, false, NaN, null, undefined];
|
||||
equal(_.lastIndexOf(numbers, 1), 2);
|
||||
var falsey = [void 0, '', 0, false, NaN, null, void 0];
|
||||
assert.equal(_.lastIndexOf(numbers, 1), 2);
|
||||
|
||||
numbers = [1, 0, 1, 0, 0, 1, 0, 0, 0];
|
||||
numbers.lastIndexOf = null;
|
||||
equal(_.lastIndexOf(numbers, 1), 5, 'can compute lastIndexOf, even without the native function');
|
||||
equal(_.lastIndexOf(numbers, 0), 8, 'lastIndexOf the other element');
|
||||
assert.equal(_.lastIndexOf(numbers, 1), 5, 'can compute lastIndexOf, even without the native function');
|
||||
assert.equal(_.lastIndexOf(numbers, 0), 8, 'lastIndexOf the other element');
|
||||
var result = (function(){ return _.lastIndexOf(arguments, 1); }(1, 0, 1, 0, 0, 1, 0, 0, 0));
|
||||
equal(result, 5, 'works on an arguments object');
|
||||
assert.equal(result, 5, 'works on an arguments object');
|
||||
|
||||
_.each([null, void 0, [], false], function(val) {
|
||||
var msg = 'Handles: ' + (_.isArray(val) ? '[]' : val);
|
||||
equal(_.lastIndexOf(val, 2), -1, msg);
|
||||
equal(_.lastIndexOf(val, 2, -1), -1, msg);
|
||||
equal(_.lastIndexOf(val, 2, -20), -1, msg);
|
||||
equal(_.lastIndexOf(val, 2, 15), -1, msg);
|
||||
assert.equal(_.lastIndexOf(val, 2), -1, msg);
|
||||
assert.equal(_.lastIndexOf(val, 2, -1), -1, msg);
|
||||
assert.equal(_.lastIndexOf(val, 2, -20), -1, msg);
|
||||
assert.equal(_.lastIndexOf(val, 2, 15), -1, msg);
|
||||
});
|
||||
|
||||
numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
|
||||
var index = _.lastIndexOf(numbers, 2, 2);
|
||||
equal(index, 1, 'supports the fromIndex argument');
|
||||
assert.equal(index, 1, 'supports the fromIndex argument');
|
||||
|
||||
var array = [1, 2, 3, 1, 2, 3];
|
||||
|
||||
strictEqual(_.lastIndexOf(array, 1, 0), 0, 'starts at the correct from idx');
|
||||
strictEqual(_.lastIndexOf(array, 3), 5, 'should return the index of the last matched value');
|
||||
strictEqual(_.lastIndexOf(array, 4), -1, 'should return `-1` for an unmatched value');
|
||||
assert.strictEqual(_.lastIndexOf(array, 1, 0), 0, 'starts at the correct from idx');
|
||||
assert.strictEqual(_.lastIndexOf(array, 3), 5, 'should return the index of the last matched value');
|
||||
assert.strictEqual(_.lastIndexOf(array, 4), -1, 'should return `-1` for an unmatched value');
|
||||
|
||||
strictEqual(_.lastIndexOf(array, 1, 2), 0, 'should work with a positive `fromIndex`');
|
||||
assert.strictEqual(_.lastIndexOf(array, 1, 2), 0, 'should work with a positive `fromIndex`');
|
||||
|
||||
_.each([6, 8, Math.pow(2, 32), Infinity], function(fromIndex) {
|
||||
strictEqual(_.lastIndexOf(array, undefined, fromIndex), -1);
|
||||
strictEqual(_.lastIndexOf(array, 1, fromIndex), 3);
|
||||
strictEqual(_.lastIndexOf(array, '', fromIndex), -1);
|
||||
assert.strictEqual(_.lastIndexOf(array, void 0, fromIndex), -1);
|
||||
assert.strictEqual(_.lastIndexOf(array, 1, fromIndex), 3);
|
||||
assert.strictEqual(_.lastIndexOf(array, '', fromIndex), -1);
|
||||
});
|
||||
|
||||
var expected = _.map(falsey, function(value) {
|
||||
@@ -405,133 +408,150 @@
|
||||
return _.lastIndexOf(array, 3, fromIndex);
|
||||
});
|
||||
|
||||
deepEqual(actual, expected, 'should treat falsey `fromIndex` values, except `0` and `NaN`, as `array.length`');
|
||||
strictEqual(_.lastIndexOf(array, 3, '1'), 5, 'should treat non-number `fromIndex` values as `array.length`');
|
||||
strictEqual(_.lastIndexOf(array, 3, true), 5, 'should treat non-number `fromIndex` values as `array.length`');
|
||||
assert.deepEqual(actual, expected, 'should treat falsey `fromIndex` values, except `0` and `NaN`, as `array.length`');
|
||||
assert.strictEqual(_.lastIndexOf(array, 3, '1'), 5, 'should treat non-number `fromIndex` values as `array.length`');
|
||||
assert.strictEqual(_.lastIndexOf(array, 3, true), 5, 'should treat non-number `fromIndex` values as `array.length`');
|
||||
|
||||
strictEqual(_.lastIndexOf(array, 2, -3), 1, 'should work with a negative `fromIndex`');
|
||||
strictEqual(_.lastIndexOf(array, 1, -3), 3, 'neg `fromIndex` starts at the right index');
|
||||
assert.strictEqual(_.lastIndexOf(array, 2, -3), 1, 'should work with a negative `fromIndex`');
|
||||
assert.strictEqual(_.lastIndexOf(array, 1, -3), 3, 'neg `fromIndex` starts at the right index');
|
||||
|
||||
deepEqual(_.map([-6, -8, -Infinity], function(fromIndex) {
|
||||
assert.deepEqual(_.map([-6, -8, -Infinity], function(fromIndex) {
|
||||
return _.lastIndexOf(array, 1, fromIndex);
|
||||
}), [0, -1, -1]);
|
||||
});
|
||||
|
||||
test('lastIndexOf with NaN', function() {
|
||||
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN), 3, 'Expected [1, 2, NaN] to contain NaN');
|
||||
strictEqual(_.lastIndexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
|
||||
QUnit.test('lastIndexOf with NaN', function(assert) {
|
||||
assert.strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN), 3, 'Expected [1, 2, NaN] to contain NaN');
|
||||
assert.strictEqual(_.lastIndexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
|
||||
|
||||
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN, 2), 2, 'fromIndex does not affect result');
|
||||
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN, -2), 2, 'fromIndex does not affect result');
|
||||
assert.strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN, 2), 2, 'fromIndex does not affect result');
|
||||
assert.strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN, -2), 2, 'fromIndex does not affect result');
|
||||
|
||||
(function() {
|
||||
strictEqual(_.lastIndexOf(arguments, NaN), 3, 'Expected arguments [1, 2, NaN] to contain NaN');
|
||||
assert.strictEqual(_.lastIndexOf(arguments, NaN), 3, 'Expected arguments [1, 2, NaN] to contain NaN');
|
||||
}(1, 2, NaN, NaN));
|
||||
});
|
||||
|
||||
test('lastIndexOf with +- 0', function() {
|
||||
QUnit.test('lastIndexOf with +- 0', function(assert) {
|
||||
_.each([-0, +0], function(val) {
|
||||
strictEqual(_.lastIndexOf([1, 2, val, val], val), 3);
|
||||
strictEqual(_.lastIndexOf([1, 2, val, val], -val), 3);
|
||||
strictEqual(_.lastIndexOf([-1, 1, 2], -val), -1);
|
||||
assert.strictEqual(_.lastIndexOf([1, 2, val, val], val), 3);
|
||||
assert.strictEqual(_.lastIndexOf([1, 2, val, val], -val), 3);
|
||||
assert.strictEqual(_.lastIndexOf([-1, 1, 2], -val), -1);
|
||||
});
|
||||
});
|
||||
|
||||
test('findIndex', function() {
|
||||
QUnit.test('findIndex', function(assert) {
|
||||
var objects = [
|
||||
{'a': 0, 'b': 0},
|
||||
{'a': 1, 'b': 1},
|
||||
{'a': 2, 'b': 2},
|
||||
{'a': 0, 'b': 0}
|
||||
{a: 0, b: 0},
|
||||
{a: 1, b: 1},
|
||||
{a: 2, b: 2},
|
||||
{a: 0, b: 0}
|
||||
];
|
||||
|
||||
equal(_.findIndex(objects, function(obj) {
|
||||
assert.equal(_.findIndex(objects, function(obj) {
|
||||
return obj.a === 0;
|
||||
}), 0);
|
||||
|
||||
equal(_.findIndex(objects, function(obj) {
|
||||
assert.equal(_.findIndex(objects, function(obj) {
|
||||
return obj.b * obj.a === 4;
|
||||
}), 2);
|
||||
|
||||
equal(_.findIndex(objects, 'a'), 1, 'Uses lookupIterator');
|
||||
assert.equal(_.findIndex(objects, 'a'), 1, 'Uses lookupIterator');
|
||||
|
||||
equal(_.findIndex(objects, function(obj) {
|
||||
assert.equal(_.findIndex(objects, function(obj) {
|
||||
return obj.b * obj.a === 5;
|
||||
}), -1);
|
||||
|
||||
equal(_.findIndex(null, _.noop), -1);
|
||||
strictEqual(_.findIndex(objects, function(a) {
|
||||
assert.equal(_.findIndex(null, _.noop), -1);
|
||||
assert.strictEqual(_.findIndex(objects, function(a) {
|
||||
return a.foo === null;
|
||||
}), -1);
|
||||
_.findIndex([{a: 1}], function(a, key, obj) {
|
||||
equal(key, 0);
|
||||
deepEqual(obj, [{a: 1}]);
|
||||
strictEqual(this, objects, 'called with context');
|
||||
assert.equal(key, 0);
|
||||
assert.deepEqual(obj, [{a: 1}]);
|
||||
assert.strictEqual(this, objects, 'called with context');
|
||||
}, objects);
|
||||
|
||||
var sparse = [];
|
||||
sparse[20] = {'a': 2, 'b': 2};
|
||||
equal(_.findIndex(sparse, function(obj) {
|
||||
sparse[20] = {a: 2, b: 2};
|
||||
assert.equal(_.findIndex(sparse, function(obj) {
|
||||
return obj && obj.b * obj.a === 4;
|
||||
}), 20, 'Works with sparse arrays');
|
||||
|
||||
var array = [1, 2, 3, 4];
|
||||
array.match = 55;
|
||||
strictEqual(_.findIndex(array, function(x) { return x === 55; }), -1, 'doesn\'t match array-likes keys');
|
||||
assert.strictEqual(_.findIndex(array, function(x) { return x === 55; }), -1, 'doesn\'t match array-likes keys');
|
||||
});
|
||||
|
||||
test('findLastIndex', function() {
|
||||
QUnit.test('findLastIndex', function(assert) {
|
||||
var objects = [
|
||||
{'a': 0, 'b': 0},
|
||||
{'a': 1, 'b': 1},
|
||||
{'a': 2, 'b': 2},
|
||||
{'a': 0, 'b': 0}
|
||||
{a: 0, b: 0},
|
||||
{a: 1, b: 1},
|
||||
{a: 2, b: 2},
|
||||
{a: 0, b: 0}
|
||||
];
|
||||
|
||||
equal(_.findLastIndex(objects, function(obj) {
|
||||
assert.equal(_.findLastIndex(objects, function(obj) {
|
||||
return obj.a === 0;
|
||||
}), 3);
|
||||
|
||||
equal(_.findLastIndex(objects, function(obj) {
|
||||
assert.equal(_.findLastIndex(objects, function(obj) {
|
||||
return obj.b * obj.a === 4;
|
||||
}), 2);
|
||||
|
||||
equal(_.findLastIndex(objects, 'a'), 2, 'Uses lookupIterator');
|
||||
assert.equal(_.findLastIndex(objects, 'a'), 2, 'Uses lookupIterator');
|
||||
|
||||
equal(_.findLastIndex(objects, function(obj) {
|
||||
assert.equal(_.findLastIndex(objects, function(obj) {
|
||||
return obj.b * obj.a === 5;
|
||||
}), -1);
|
||||
|
||||
equal(_.findLastIndex(null, _.noop), -1);
|
||||
strictEqual(_.findLastIndex(objects, function(a) {
|
||||
assert.equal(_.findLastIndex(null, _.noop), -1);
|
||||
assert.strictEqual(_.findLastIndex(objects, function(a) {
|
||||
return a.foo === null;
|
||||
}), -1);
|
||||
_.findLastIndex([{a: 1}], function(a, key, obj) {
|
||||
equal(key, 0);
|
||||
deepEqual(obj, [{a: 1}]);
|
||||
strictEqual(this, objects, 'called with context');
|
||||
assert.equal(key, 0);
|
||||
assert.deepEqual(obj, [{a: 1}]);
|
||||
assert.strictEqual(this, objects, 'called with context');
|
||||
}, objects);
|
||||
|
||||
var sparse = [];
|
||||
sparse[20] = {'a': 2, 'b': 2};
|
||||
equal(_.findLastIndex(sparse, function(obj) {
|
||||
sparse[20] = {a: 2, b: 2};
|
||||
assert.equal(_.findLastIndex(sparse, function(obj) {
|
||||
return obj && obj.b * obj.a === 4;
|
||||
}), 20, 'Works with sparse arrays');
|
||||
|
||||
var array = [1, 2, 3, 4];
|
||||
array.match = 55;
|
||||
strictEqual(_.findLastIndex(array, function(x) { return x === 55; }), -1, 'doesn\'t match array-likes keys');
|
||||
assert.strictEqual(_.findLastIndex(array, function(x) { return x === 55; }), -1, 'doesn\'t match array-likes keys');
|
||||
});
|
||||
|
||||
test('range', function() {
|
||||
deepEqual(_.range(0), [], 'range with 0 as a first argument generates an empty array');
|
||||
deepEqual(_.range(4), [0, 1, 2, 3], 'range with a single positive argument generates an array of elements 0,1,2,...,n-1');
|
||||
deepEqual(_.range(5, 8), [5, 6, 7], 'range with two arguments a & b, a<b generates an array of elements a,a+1,a+2,...,b-2,b-1');
|
||||
deepEqual(_.range(8, 5), [], 'range with two arguments a & b, b<a generates an empty array');
|
||||
deepEqual(_.range(3, 10, 3), [3, 6, 9], 'range with three arguments a & b & c, c < b-a, a < b generates an array of elements a,a+c,a+2c,...,b - (multiplier of a) < c');
|
||||
deepEqual(_.range(3, 10, 15), [3], 'range with three arguments a & b & c, c > b-a, a < b generates an array with a single element, equal to a');
|
||||
deepEqual(_.range(12, 7, -2), [12, 10, 8], 'range with three arguments a & b & c, a > b, c < 0 generates an array of elements a,a-c,a-2c and ends with the number not less than b');
|
||||
deepEqual(_.range(0, -10, -1), [0, -1, -2, -3, -4, -5, -6, -7, -8, -9], 'final example in the Python docs');
|
||||
QUnit.test('range', function(assert) {
|
||||
assert.deepEqual(_.range(0), [], 'range with 0 as a first argument generates an empty array');
|
||||
assert.deepEqual(_.range(4), [0, 1, 2, 3], 'range with a single positive argument generates an array of elements 0,1,2,...,n-1');
|
||||
assert.deepEqual(_.range(5, 8), [5, 6, 7], 'range with two arguments a & b, a<b generates an array of elements a,a+1,a+2,...,b-2,b-1');
|
||||
assert.deepEqual(_.range(3, 10, 3), [3, 6, 9], 'range with three arguments a & b & c, c < b-a, a < b generates an array of elements a,a+c,a+2c,...,b - (multiplier of a) < c');
|
||||
assert.deepEqual(_.range(3, 10, 15), [3], 'range with three arguments a & b & c, c > b-a, a < b generates an array with a single element, equal to a');
|
||||
assert.deepEqual(_.range(12, 7, -2), [12, 10, 8], 'range with three arguments a & b & c, a > b, c < 0 generates an array of elements a,a-c,a-2c and ends with the number not less than b');
|
||||
assert.deepEqual(_.range(0, -10, -1), [0, -1, -2, -3, -4, -5, -6, -7, -8, -9], 'final example in the Python docs');
|
||||
assert.strictEqual(1 / _.range(-0, 1)[0], -Infinity, 'should preserve -0');
|
||||
assert.deepEqual(_.range(8, 5), [8, 7, 6], 'negative range generates descending array');
|
||||
assert.deepEqual(_.range(-3), [0, -1, -2], 'negative range generates descending array');
|
||||
});
|
||||
|
||||
QUnit.test('chunk', function(assert) {
|
||||
assert.deepEqual(_.chunk([], 2), [], 'chunk for empty array returns an empty array');
|
||||
|
||||
assert.deepEqual(_.chunk([1, 2, 3], 0), [], 'chunk into parts of 0 elements returns empty array');
|
||||
assert.deepEqual(_.chunk([1, 2, 3], -1), [], 'chunk into parts of negative amount of elements returns an empty array');
|
||||
assert.deepEqual(_.chunk([1, 2, 3]), [], 'defaults to empty array (chunk size 0)');
|
||||
|
||||
assert.deepEqual(_.chunk([1, 2, 3], 1), [[1], [2], [3]], 'chunk into parts of 1 elements returns original array');
|
||||
|
||||
assert.deepEqual(_.chunk([1, 2, 3], 3), [[1, 2, 3]], 'chunk into parts of current array length elements returns the original array');
|
||||
assert.deepEqual(_.chunk([1, 2, 3], 5), [[1, 2, 3]], 'chunk into parts of more then current array length elements returns the original array');
|
||||
|
||||
assert.deepEqual(_.chunk([10, 20, 30, 40, 50, 60, 70], 2), [[10, 20], [30, 40], [50, 60], [70]], 'chunk into parts of less then current array length elements');
|
||||
assert.deepEqual(_.chunk([10, 20, 30, 40, 50, 60, 70], 3), [[10, 20, 30], [40, 50, 60], [70]], 'chunk into parts of less then current array length elements');
|
||||
});
|
||||
}());
|
||||
|
||||
65
vendor/underscore/test/chaining.js
vendored
65
vendor/underscore/test/chaining.js
vendored
@@ -3,7 +3,7 @@
|
||||
|
||||
QUnit.module('Chaining');
|
||||
|
||||
test('map/flatten/reduce', function() {
|
||||
QUnit.test('map/flatten/reduce', function(assert) {
|
||||
var lyrics = [
|
||||
'I\'m a lumberjack and I\'m okay',
|
||||
'I sleep all night and I work all day',
|
||||
@@ -17,12 +17,13 @@
|
||||
hash[l] = hash[l] || 0;
|
||||
hash[l]++;
|
||||
return hash;
|
||||
}, {}).value();
|
||||
equal(counts.a, 16, 'counted all the letters in the song');
|
||||
equal(counts.e, 10, 'counted all the letters in the song');
|
||||
}, {})
|
||||
.value();
|
||||
assert.equal(counts.a, 16, 'counted all the letters in the song');
|
||||
assert.equal(counts.e, 10, 'counted all the letters in the song');
|
||||
});
|
||||
|
||||
test('select/reject/sortBy', function() {
|
||||
QUnit.test('select/reject/sortBy', function(assert) {
|
||||
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
numbers = _(numbers).chain().select(function(n) {
|
||||
return n % 2 === 0;
|
||||
@@ -31,10 +32,10 @@
|
||||
}).sortBy(function(n) {
|
||||
return -n;
|
||||
}).value();
|
||||
deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers');
|
||||
assert.deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers');
|
||||
});
|
||||
|
||||
test('select/reject/sortBy in functional style', function() {
|
||||
QUnit.test('select/reject/sortBy in functional style', function(assert) {
|
||||
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
numbers = _.chain(numbers).select(function(n) {
|
||||
return n % 2 === 0;
|
||||
@@ -43,10 +44,10 @@
|
||||
}).sortBy(function(n) {
|
||||
return -n;
|
||||
}).value();
|
||||
deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers');
|
||||
assert.deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers');
|
||||
});
|
||||
|
||||
test('reverse/concat/unshift/pop/map', function() {
|
||||
QUnit.test('reverse/concat/unshift/pop/map', function(assert) {
|
||||
var numbers = [1, 2, 3, 4, 5];
|
||||
numbers = _(numbers).chain()
|
||||
.reverse()
|
||||
@@ -55,44 +56,44 @@
|
||||
.pop()
|
||||
.map(function(n){ return n * 2; })
|
||||
.value();
|
||||
deepEqual(numbers, [34, 10, 8, 6, 4, 2, 10, 10], 'can chain together array functions.');
|
||||
assert.deepEqual(numbers, [34, 10, 8, 6, 4, 2, 10, 10], 'can chain together array functions.');
|
||||
});
|
||||
|
||||
test('splice', function() {
|
||||
QUnit.test('splice', function(assert) {
|
||||
var instance = _([1, 2, 3, 4, 5]).chain();
|
||||
deepEqual(instance.splice(1, 3).value(), [1, 5]);
|
||||
deepEqual(instance.splice(1, 0).value(), [1, 5]);
|
||||
deepEqual(instance.splice(1, 1).value(), [1]);
|
||||
deepEqual(instance.splice(0, 1).value(), [], '#397 Can create empty array');
|
||||
assert.deepEqual(instance.splice(1, 3).value(), [1, 5]);
|
||||
assert.deepEqual(instance.splice(1, 0).value(), [1, 5]);
|
||||
assert.deepEqual(instance.splice(1, 1).value(), [1]);
|
||||
assert.deepEqual(instance.splice(0, 1).value(), [], '#397 Can create empty array');
|
||||
});
|
||||
|
||||
test('shift', function() {
|
||||
QUnit.test('shift', function(assert) {
|
||||
var instance = _([1, 2, 3]).chain();
|
||||
deepEqual(instance.shift().value(), [2, 3]);
|
||||
deepEqual(instance.shift().value(), [3]);
|
||||
deepEqual(instance.shift().value(), [], '#397 Can create empty array');
|
||||
assert.deepEqual(instance.shift().value(), [2, 3]);
|
||||
assert.deepEqual(instance.shift().value(), [3]);
|
||||
assert.deepEqual(instance.shift().value(), [], '#397 Can create empty array');
|
||||
});
|
||||
|
||||
test('pop', function() {
|
||||
QUnit.test('pop', function(assert) {
|
||||
var instance = _([1, 2, 3]).chain();
|
||||
deepEqual(instance.pop().value(), [1, 2]);
|
||||
deepEqual(instance.pop().value(), [1]);
|
||||
deepEqual(instance.pop().value(), [], '#397 Can create empty array');
|
||||
assert.deepEqual(instance.pop().value(), [1, 2]);
|
||||
assert.deepEqual(instance.pop().value(), [1]);
|
||||
assert.deepEqual(instance.pop().value(), [], '#397 Can create empty array');
|
||||
});
|
||||
|
||||
test('chaining works in small stages', function() {
|
||||
QUnit.test('chaining works in small stages', function(assert) {
|
||||
var o = _([1, 2, 3, 4]).chain();
|
||||
deepEqual(o.filter(function(i) { return i < 3; }).value(), [1, 2]);
|
||||
deepEqual(o.filter(function(i) { return i > 2; }).value(), [3, 4]);
|
||||
assert.deepEqual(o.filter(function(i) { return i < 3; }).value(), [1, 2]);
|
||||
assert.deepEqual(o.filter(function(i) { return i > 2; }).value(), [3, 4]);
|
||||
});
|
||||
|
||||
test('#1562: Engine proxies for chained functions', function() {
|
||||
QUnit.test('#1562: Engine proxies for chained functions', function(assert) {
|
||||
var wrapped = _(512);
|
||||
strictEqual(wrapped.toJSON(), 512);
|
||||
strictEqual(wrapped.valueOf(), 512);
|
||||
strictEqual(+wrapped, 512);
|
||||
strictEqual(wrapped.toString(), '512');
|
||||
strictEqual('' + wrapped, '512');
|
||||
assert.strictEqual(wrapped.toJSON(), 512);
|
||||
assert.strictEqual(wrapped.valueOf(), 512);
|
||||
assert.strictEqual(+wrapped, 512);
|
||||
assert.strictEqual(wrapped.toString(), '512');
|
||||
assert.strictEqual('' + wrapped, '512');
|
||||
});
|
||||
|
||||
}());
|
||||
|
||||
803
vendor/underscore/test/collections.js
vendored
803
vendor/underscore/test/collections.js
vendored
File diff suppressed because it is too large
Load Diff
104
vendor/underscore/test/cross-document.js
vendored
104
vendor/underscore/test/cross-document.js
vendored
@@ -33,95 +33,95 @@
|
||||
);
|
||||
iDoc.close();
|
||||
|
||||
test('isEqual', function() {
|
||||
QUnit.test('isEqual', function(assert) {
|
||||
|
||||
ok(!_.isEqual(iNumber, 101));
|
||||
ok(_.isEqual(iNumber, 100));
|
||||
assert.ok(!_.isEqual(iNumber, 101));
|
||||
assert.ok(_.isEqual(iNumber, 100));
|
||||
|
||||
// Objects from another frame.
|
||||
ok(_.isEqual({}, iObject), 'Objects with equivalent members created in different documents are equal');
|
||||
assert.ok(_.isEqual({}, iObject), 'Objects with equivalent members created in different documents are equal');
|
||||
|
||||
// Array from another frame.
|
||||
ok(_.isEqual([1, 2, 3], iArray), 'Arrays with equivalent elements created in different documents are equal');
|
||||
assert.ok(_.isEqual([1, 2, 3], iArray), 'Arrays with equivalent elements created in different documents are equal');
|
||||
});
|
||||
|
||||
test('isEmpty', function() {
|
||||
ok(!_([iNumber]).isEmpty(), '[1] is not empty');
|
||||
ok(!_.isEmpty(iArray), '[] is empty');
|
||||
ok(_.isEmpty(iObject), '{} is empty');
|
||||
QUnit.test('isEmpty', function(assert) {
|
||||
assert.ok(!_([iNumber]).isEmpty(), '[1] is not empty');
|
||||
assert.ok(!_.isEmpty(iArray), '[] is empty');
|
||||
assert.ok(_.isEmpty(iObject), '{} is empty');
|
||||
});
|
||||
|
||||
test('isElement', function() {
|
||||
ok(!_.isElement('div'), 'strings are not dom elements');
|
||||
ok(_.isElement(document.body), 'the body tag is a DOM element');
|
||||
ok(_.isElement(iElement), 'even from another frame');
|
||||
QUnit.test('isElement', function(assert) {
|
||||
assert.ok(!_.isElement('div'), 'strings are not dom elements');
|
||||
assert.ok(_.isElement(document.body), 'the body tag is a DOM element');
|
||||
assert.ok(_.isElement(iElement), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isArguments', function() {
|
||||
ok(_.isArguments(iArguments), 'even from another frame');
|
||||
QUnit.test('isArguments', function(assert) {
|
||||
assert.ok(_.isArguments(iArguments), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isObject', function() {
|
||||
ok(_.isObject(iElement), 'even from another frame');
|
||||
ok(_.isObject(iFunction), 'even from another frame');
|
||||
QUnit.test('isObject', function(assert) {
|
||||
assert.ok(_.isObject(iElement), 'even from another frame');
|
||||
assert.ok(_.isObject(iFunction), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isArray', function() {
|
||||
ok(_.isArray(iArray), 'even from another frame');
|
||||
QUnit.test('isArray', function(assert) {
|
||||
assert.ok(_.isArray(iArray), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isString', function() {
|
||||
ok(_.isString(iString), 'even from another frame');
|
||||
QUnit.test('isString', function(assert) {
|
||||
assert.ok(_.isString(iString), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isNumber', function() {
|
||||
ok(_.isNumber(iNumber), 'even from another frame');
|
||||
QUnit.test('isNumber', function(assert) {
|
||||
assert.ok(_.isNumber(iNumber), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isBoolean', function() {
|
||||
ok(_.isBoolean(iBoolean), 'even from another frame');
|
||||
QUnit.test('isBoolean', function(assert) {
|
||||
assert.ok(_.isBoolean(iBoolean), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isFunction', function() {
|
||||
ok(_.isFunction(iFunction), 'even from another frame');
|
||||
QUnit.test('isFunction', function(assert) {
|
||||
assert.ok(_.isFunction(iFunction), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isDate', function() {
|
||||
ok(_.isDate(iDate), 'even from another frame');
|
||||
QUnit.test('isDate', function(assert) {
|
||||
assert.ok(_.isDate(iDate), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isRegExp', function() {
|
||||
ok(_.isRegExp(iRegExp), 'even from another frame');
|
||||
QUnit.test('isRegExp', function(assert) {
|
||||
assert.ok(_.isRegExp(iRegExp), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isNaN', function() {
|
||||
ok(_.isNaN(iNaN), 'even from another frame');
|
||||
QUnit.test('isNaN', function(assert) {
|
||||
assert.ok(_.isNaN(iNaN), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isNull', function() {
|
||||
ok(_.isNull(iNull), 'even from another frame');
|
||||
QUnit.test('isNull', function(assert) {
|
||||
assert.ok(_.isNull(iNull), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isUndefined', function() {
|
||||
ok(_.isUndefined(iUndefined), 'even from another frame');
|
||||
QUnit.test('isUndefined', function(assert) {
|
||||
assert.ok(_.isUndefined(iUndefined), 'even from another frame');
|
||||
});
|
||||
|
||||
test('isError', function() {
|
||||
ok(_.isError(iError), 'even from another frame');
|
||||
QUnit.test('isError', function(assert) {
|
||||
assert.ok(_.isError(iError), 'even from another frame');
|
||||
});
|
||||
|
||||
if (typeof ActiveXObject != 'undefined') {
|
||||
test('IE host objects', function() {
|
||||
QUnit.test('IE host objects', function(assert) {
|
||||
var xml = new ActiveXObject('Msxml2.DOMDocument.3.0');
|
||||
ok(!_.isNumber(xml));
|
||||
ok(!_.isBoolean(xml));
|
||||
ok(!_.isNaN(xml));
|
||||
ok(!_.isFunction(xml));
|
||||
ok(!_.isNull(xml));
|
||||
ok(!_.isUndefined(xml));
|
||||
assert.ok(!_.isNumber(xml));
|
||||
assert.ok(!_.isBoolean(xml));
|
||||
assert.ok(!_.isNaN(xml));
|
||||
assert.ok(!_.isFunction(xml));
|
||||
assert.ok(!_.isNull(xml));
|
||||
assert.ok(!_.isUndefined(xml));
|
||||
});
|
||||
|
||||
test('#1621 IE 11 compat mode DOM elements are not functions', function() {
|
||||
QUnit.test('#1621 IE 11 compat mode DOM elements are not functions', function(assert) {
|
||||
var fn = function() {};
|
||||
var xml = new ActiveXObject('Msxml2.DOMDocument.3.0');
|
||||
var div = document.createElement('div');
|
||||
@@ -132,10 +132,10 @@
|
||||
_.isFunction(fn);
|
||||
}
|
||||
|
||||
equal(_.isFunction(xml), false);
|
||||
equal(_.isFunction(div), false);
|
||||
equal(_.isFunction(fn), true);
|
||||
assert.equal(_.isFunction(xml), false);
|
||||
assert.equal(_.isFunction(div), false);
|
||||
assert.equal(_.isFunction(fn), true);
|
||||
});
|
||||
}
|
||||
|
||||
}());
|
||||
}());
|
||||
|
||||
493
vendor/underscore/test/functions.js
vendored
493
vendor/underscore/test/functions.js
vendored
@@ -4,65 +4,65 @@
|
||||
QUnit.module('Functions');
|
||||
QUnit.config.asyncRetries = 3;
|
||||
|
||||
test('bind', function() {
|
||||
var context = {name : 'moe'};
|
||||
QUnit.test('bind', function(assert) {
|
||||
var context = {name: 'moe'};
|
||||
var func = function(arg) { return 'name: ' + (this.name || arg); };
|
||||
var bound = _.bind(func, context);
|
||||
equal(bound(), 'name: moe', 'can bind a function to a context');
|
||||
assert.equal(bound(), 'name: moe', 'can bind a function to a context');
|
||||
|
||||
bound = _(func).bind(context);
|
||||
equal(bound(), 'name: moe', 'can do OO-style binding');
|
||||
assert.equal(bound(), 'name: moe', 'can do OO-style binding');
|
||||
|
||||
bound = _.bind(func, null, 'curly');
|
||||
var result = bound();
|
||||
// Work around a PhantomJS bug when applying a function with null|undefined.
|
||||
ok(result === 'name: curly' || result === 'name: ' + window.name, 'can bind without specifying a context');
|
||||
assert.ok(result === 'name: curly' || result === 'name: ' + window.name, 'can bind without specifying a context');
|
||||
|
||||
func = function(salutation, name) { return salutation + ': ' + name; };
|
||||
func = _.bind(func, this, 'hello');
|
||||
equal(func('moe'), 'hello: moe', 'the function was partially applied in advance');
|
||||
assert.equal(func('moe'), 'hello: moe', 'the function was partially applied in advance');
|
||||
|
||||
func = _.bind(func, this, 'curly');
|
||||
equal(func(), 'hello: curly', 'the function was completely applied in advance');
|
||||
assert.equal(func(), 'hello: curly', 'the function was completely applied in advance');
|
||||
|
||||
func = function(salutation, firstname, lastname) { return salutation + ': ' + firstname + ' ' + lastname; };
|
||||
func = _.bind(func, this, 'hello', 'moe', 'curly');
|
||||
equal(func(), 'hello: moe curly', 'the function was partially applied in advance and can accept multiple arguments');
|
||||
assert.equal(func(), 'hello: moe curly', 'the function was partially applied in advance and can accept multiple arguments');
|
||||
|
||||
func = function(context, message) { equal(this, context, message); };
|
||||
func = function(ctx, message) { assert.equal(this, ctx, message); };
|
||||
_.bind(func, 0, 0, 'can bind a function to `0`')();
|
||||
_.bind(func, '', '', 'can bind a function to an empty string')();
|
||||
_.bind(func, false, false, 'can bind a function to `false`')();
|
||||
|
||||
// These tests are only meaningful when using a browser without a native bind function
|
||||
// To test this with a modern browser, set underscore's nativeBind to undefined
|
||||
var F = function () { return this; };
|
||||
var F = function() { return this; };
|
||||
var boundf = _.bind(F, {hello: 'moe curly'});
|
||||
var Boundf = boundf; // make eslint happy.
|
||||
var newBoundf = new Boundf();
|
||||
equal(newBoundf.hello, undefined, 'function should not be bound to the context, to comply with ECMAScript 5');
|
||||
equal(boundf().hello, 'moe curly', "When called without the new operator, it's OK to be bound to the context");
|
||||
ok(newBoundf instanceof F, 'a bound instance is an instance of the original function');
|
||||
assert.equal(newBoundf.hello, void 0, 'function should not be bound to the context, to comply with ECMAScript 5');
|
||||
assert.equal(boundf().hello, 'moe curly', "When called without the new operator, it's OK to be bound to the context");
|
||||
assert.ok(newBoundf instanceof F, 'a bound instance is an instance of the original function');
|
||||
|
||||
throws(function() { _.bind('notafunction'); }, TypeError, 'throws an error when binding to a non-function');
|
||||
assert.raises(function() { _.bind('notafunction'); }, TypeError, 'throws an error when binding to a non-function');
|
||||
});
|
||||
|
||||
test('partial', function() {
|
||||
QUnit.test('partial', function(assert) {
|
||||
var obj = {name: 'moe'};
|
||||
var func = function() { return this.name + ' ' + _.toArray(arguments).join(' '); };
|
||||
|
||||
obj.func = _.partial(func, 'a', 'b');
|
||||
equal(obj.func('c', 'd'), 'moe a b c d', 'can partially apply');
|
||||
assert.equal(obj.func('c', 'd'), 'moe a b c d', 'can partially apply');
|
||||
|
||||
obj.func = _.partial(func, _, 'b', _, 'd');
|
||||
equal(obj.func('a', 'c'), 'moe a b c d', 'can partially apply with placeholders');
|
||||
assert.equal(obj.func('a', 'c'), 'moe a b c d', 'can partially apply with placeholders');
|
||||
|
||||
func = _.partial(function() { return arguments.length; }, _, 'b', _, 'd');
|
||||
equal(func('a', 'c', 'e'), 5, 'accepts more arguments than the number of placeholders');
|
||||
equal(func('a'), 4, 'accepts fewer arguments than the number of placeholders');
|
||||
assert.equal(func('a', 'c', 'e'), 5, 'accepts more arguments than the number of placeholders');
|
||||
assert.equal(func('a'), 4, 'accepts fewer arguments than the number of placeholders');
|
||||
|
||||
func = _.partial(function() { return typeof arguments[2]; }, _, 'b', _, 'd');
|
||||
equal(func('a'), 'undefined', 'unfilled placeholders are undefined');
|
||||
assert.equal(func('a'), 'undefined', 'unfilled placeholders are undefined');
|
||||
|
||||
// passes context
|
||||
function MyWidget(name, options) {
|
||||
@@ -74,78 +74,93 @@
|
||||
};
|
||||
var MyWidgetWithCoolOpts = _.partial(MyWidget, _, {a: 1});
|
||||
var widget = new MyWidgetWithCoolOpts('foo');
|
||||
ok(widget instanceof MyWidget, 'Can partially bind a constructor');
|
||||
equal(widget.get(), 'foo', 'keeps prototype');
|
||||
deepEqual(widget.options, {a: 1});
|
||||
assert.ok(widget instanceof MyWidget, 'Can partially bind a constructor');
|
||||
assert.equal(widget.get(), 'foo', 'keeps prototype');
|
||||
assert.deepEqual(widget.options, {a: 1});
|
||||
|
||||
_.partial.placeholder = obj;
|
||||
func = _.partial(function() { return arguments.length; }, obj, 'b', obj, 'd');
|
||||
assert.equal(func('a'), 4, 'allows the placeholder to be swapped out');
|
||||
|
||||
_.partial.placeholder = {};
|
||||
func = _.partial(function() { return arguments.length; }, obj, 'b', obj, 'd');
|
||||
assert.equal(func('a'), 5, 'swapping the placeholder preserves previously bound arguments');
|
||||
|
||||
_.partial.placeholder = _;
|
||||
});
|
||||
|
||||
test('bindAll', function() {
|
||||
var curly = {name : 'curly'}, moe = {
|
||||
name : 'moe',
|
||||
getName : function() { return 'name: ' + this.name; },
|
||||
sayHi : function() { return 'hi: ' + this.name; }
|
||||
QUnit.test('bindAll', function(assert) {
|
||||
var curly = {name: 'curly'};
|
||||
var moe = {
|
||||
name: 'moe',
|
||||
getName: function() { return 'name: ' + this.name; },
|
||||
sayHi: function() { return 'hi: ' + this.name; }
|
||||
};
|
||||
curly.getName = moe.getName;
|
||||
_.bindAll(moe, 'getName', 'sayHi');
|
||||
curly.sayHi = moe.sayHi;
|
||||
equal(curly.getName(), 'name: curly', 'unbound function is bound to current object');
|
||||
equal(curly.sayHi(), 'hi: moe', 'bound function is still bound to original object');
|
||||
assert.equal(curly.getName(), 'name: curly', 'unbound function is bound to current object');
|
||||
assert.equal(curly.sayHi(), 'hi: moe', 'bound function is still bound to original object');
|
||||
|
||||
curly = {name : 'curly'};
|
||||
curly = {name: 'curly'};
|
||||
moe = {
|
||||
name : 'moe',
|
||||
getName : function() { return 'name: ' + this.name; },
|
||||
sayHi : function() { return 'hi: ' + this.name; },
|
||||
sayLast : function() { return this.sayHi(_.last(arguments)); }
|
||||
name: 'moe',
|
||||
getName: function() { return 'name: ' + this.name; },
|
||||
sayHi: function() { return 'hi: ' + this.name; },
|
||||
sayLast: function() { return this.sayHi(_.last(arguments)); }
|
||||
};
|
||||
|
||||
throws(function() { _.bindAll(moe); }, Error, 'throws an error for bindAll with no functions named');
|
||||
throws(function() { _.bindAll(moe, 'sayBye'); }, TypeError, 'throws an error for bindAll if the given key is undefined');
|
||||
throws(function() { _.bindAll(moe, 'name'); }, TypeError, 'throws an error for bindAll if the given key is not a function');
|
||||
assert.raises(function() { _.bindAll(moe); }, Error, 'throws an error for bindAll with no functions named');
|
||||
assert.raises(function() { _.bindAll(moe, 'sayBye'); }, TypeError, 'throws an error for bindAll if the given key is undefined');
|
||||
assert.raises(function() { _.bindAll(moe, 'name'); }, TypeError, 'throws an error for bindAll if the given key is not a function');
|
||||
|
||||
_.bindAll(moe, 'sayHi', 'sayLast');
|
||||
curly.sayHi = moe.sayHi;
|
||||
equal(curly.sayHi(), 'hi: moe');
|
||||
assert.equal(curly.sayHi(), 'hi: moe');
|
||||
|
||||
var sayLast = moe.sayLast;
|
||||
equal(sayLast(1, 2, 3, 4, 5, 6, 7, 'Tom'), 'hi: moe', 'createCallback works with any number of arguments');
|
||||
assert.equal(sayLast(1, 2, 3, 4, 5, 6, 7, 'Tom'), 'hi: moe', 'createCallback works with any number of arguments');
|
||||
|
||||
_.bindAll(moe, ['getName']);
|
||||
var getName = moe.getName;
|
||||
assert.equal(getName(), 'name: moe', 'flattens arguments into a single list');
|
||||
});
|
||||
|
||||
test('memoize', function() {
|
||||
QUnit.test('memoize', function(assert) {
|
||||
var fib = function(n) {
|
||||
return n < 2 ? n : fib(n - 1) + fib(n - 2);
|
||||
};
|
||||
equal(fib(10), 55, 'a memoized version of fibonacci produces identical results');
|
||||
assert.equal(fib(10), 55, 'a memoized version of fibonacci produces identical results');
|
||||
fib = _.memoize(fib); // Redefine `fib` for memoization
|
||||
equal(fib(10), 55, 'a memoized version of fibonacci produces identical results');
|
||||
assert.equal(fib(10), 55, 'a memoized version of fibonacci produces identical results');
|
||||
|
||||
var o = function(str) {
|
||||
return str;
|
||||
};
|
||||
var fastO = _.memoize(o);
|
||||
equal(o('toString'), 'toString', 'checks hasOwnProperty');
|
||||
equal(fastO('toString'), 'toString', 'checks hasOwnProperty');
|
||||
assert.equal(o('toString'), 'toString', 'checks hasOwnProperty');
|
||||
assert.equal(fastO('toString'), 'toString', 'checks hasOwnProperty');
|
||||
|
||||
// Expose the cache.
|
||||
var upper = _.memoize(function(s) {
|
||||
return s.toUpperCase();
|
||||
});
|
||||
equal(upper('foo'), 'FOO');
|
||||
equal(upper('bar'), 'BAR');
|
||||
deepEqual(upper.cache, {foo: 'FOO', bar: 'BAR'});
|
||||
assert.equal(upper('foo'), 'FOO');
|
||||
assert.equal(upper('bar'), 'BAR');
|
||||
assert.deepEqual(upper.cache, {foo: 'FOO', bar: 'BAR'});
|
||||
upper.cache = {foo: 'BAR', bar: 'FOO'};
|
||||
equal(upper('foo'), 'BAR');
|
||||
equal(upper('bar'), 'FOO');
|
||||
assert.equal(upper('foo'), 'BAR');
|
||||
assert.equal(upper('bar'), 'FOO');
|
||||
|
||||
var hashed = _.memoize(function(key) {
|
||||
//https://github.com/jashkenas/underscore/pull/1679#discussion_r13736209
|
||||
ok(/[a-z]+/.test(key), 'hasher doesn\'t change keys');
|
||||
assert.ok(/[a-z]+/.test(key), 'hasher doesn\'t change keys');
|
||||
return key;
|
||||
}, function(key) {
|
||||
return key.toUpperCase();
|
||||
});
|
||||
hashed('yep');
|
||||
deepEqual(hashed.cache, {'YEP': 'yep'}, 'takes a hasher');
|
||||
assert.deepEqual(hashed.cache, {YEP: 'yep'}, 'takes a hasher');
|
||||
|
||||
// Test that the hash function can be used to swizzle the key.
|
||||
var objCacher = _.memoize(function(value, key) {
|
||||
@@ -155,78 +170,94 @@
|
||||
});
|
||||
var myObj = objCacher('a', 'alpha');
|
||||
var myObjAlias = objCacher('b', 'alpha');
|
||||
notStrictEqual(myObj, undefined, 'object is created if second argument used as key');
|
||||
strictEqual(myObj, myObjAlias, 'object is cached if second argument used as key');
|
||||
strictEqual(myObj.value, 'a', 'object is not modified if second argument used as key');
|
||||
assert.notStrictEqual(myObj, void 0, 'object is created if second argument used as key');
|
||||
assert.strictEqual(myObj, myObjAlias, 'object is cached if second argument used as key');
|
||||
assert.strictEqual(myObj.value, 'a', 'object is not modified if second argument used as key');
|
||||
});
|
||||
|
||||
asyncTest('delay', 2, function() {
|
||||
QUnit.test('delay', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var delayed = false;
|
||||
_.delay(function(){ delayed = true; }, 100);
|
||||
setTimeout(function(){ ok(!delayed, "didn't delay the function quite yet"); }, 50);
|
||||
setTimeout(function(){ ok(delayed, 'delayed the function'); start(); }, 150);
|
||||
setTimeout(function(){ assert.ok(!delayed, "didn't delay the function quite yet"); }, 50);
|
||||
setTimeout(function(){ assert.ok(delayed, 'delayed the function'); done(); }, 150);
|
||||
});
|
||||
|
||||
asyncTest('defer', 1, function() {
|
||||
QUnit.test('defer', function(assert) {
|
||||
assert.expect(1);
|
||||
var done = assert.async();
|
||||
var deferred = false;
|
||||
_.defer(function(bool){ deferred = bool; }, true);
|
||||
_.delay(function(){ ok(deferred, 'deferred the function'); start(); }, 50);
|
||||
_.delay(function(){ assert.ok(deferred, 'deferred the function'); done(); }, 50);
|
||||
});
|
||||
|
||||
asyncTest('throttle', 2, function() {
|
||||
QUnit.test('throttle', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 32);
|
||||
throttledIncr(); throttledIncr();
|
||||
|
||||
equal(counter, 1, 'incr was called immediately');
|
||||
_.delay(function(){ equal(counter, 2, 'incr was throttled'); start(); }, 64);
|
||||
assert.equal(counter, 1, 'incr was called immediately');
|
||||
_.delay(function(){ assert.equal(counter, 2, 'incr was throttled'); done(); }, 64);
|
||||
});
|
||||
|
||||
asyncTest('throttle arguments', 2, function() {
|
||||
QUnit.test('throttle arguments', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var value = 0;
|
||||
var update = function(val){ value = val; };
|
||||
var throttledUpdate = _.throttle(update, 32);
|
||||
throttledUpdate(1); throttledUpdate(2);
|
||||
_.delay(function(){ throttledUpdate(3); }, 64);
|
||||
equal(value, 1, 'updated to latest value');
|
||||
_.delay(function(){ equal(value, 3, 'updated to latest value'); start(); }, 96);
|
||||
assert.equal(value, 1, 'updated to latest value');
|
||||
_.delay(function(){ assert.equal(value, 3, 'updated to latest value'); done(); }, 96);
|
||||
});
|
||||
|
||||
asyncTest('throttle once', 2, function() {
|
||||
QUnit.test('throttle once', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ return ++counter; };
|
||||
var throttledIncr = _.throttle(incr, 32);
|
||||
var result = throttledIncr();
|
||||
_.delay(function(){
|
||||
equal(result, 1, 'throttled functions return their value');
|
||||
equal(counter, 1, 'incr was called once'); start();
|
||||
assert.equal(result, 1, 'throttled functions return their value');
|
||||
assert.equal(counter, 1, 'incr was called once'); done();
|
||||
}, 64);
|
||||
});
|
||||
|
||||
asyncTest('throttle twice', 1, function() {
|
||||
QUnit.test('throttle twice', function(assert) {
|
||||
assert.expect(1);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 32);
|
||||
throttledIncr(); throttledIncr();
|
||||
_.delay(function(){ equal(counter, 2, 'incr was called twice'); start(); }, 64);
|
||||
_.delay(function(){ assert.equal(counter, 2, 'incr was called twice'); done(); }, 64);
|
||||
});
|
||||
|
||||
asyncTest('more throttling', 3, function() {
|
||||
QUnit.test('more throttling', function(assert) {
|
||||
assert.expect(3);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 30);
|
||||
throttledIncr(); throttledIncr();
|
||||
equal(counter, 1);
|
||||
assert.equal(counter, 1);
|
||||
_.delay(function(){
|
||||
equal(counter, 2);
|
||||
assert.equal(counter, 2);
|
||||
throttledIncr();
|
||||
equal(counter, 3);
|
||||
start();
|
||||
assert.equal(counter, 3);
|
||||
done();
|
||||
}, 85);
|
||||
});
|
||||
|
||||
asyncTest('throttle repeatedly with results', 6, function() {
|
||||
QUnit.test('throttle repeatedly with results', function(assert) {
|
||||
assert.expect(6);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ return ++counter; };
|
||||
var throttledIncr = _.throttle(incr, 100);
|
||||
@@ -238,17 +269,19 @@
|
||||
_.delay(saveResult, 160);
|
||||
_.delay(saveResult, 230);
|
||||
_.delay(function() {
|
||||
equal(results[0], 1, 'incr was called once');
|
||||
equal(results[1], 1, 'incr was throttled');
|
||||
equal(results[2], 1, 'incr was throttled');
|
||||
equal(results[3], 2, 'incr was called twice');
|
||||
equal(results[4], 2, 'incr was throttled');
|
||||
equal(results[5], 3, 'incr was called trailing');
|
||||
start();
|
||||
assert.equal(results[0], 1, 'incr was called once');
|
||||
assert.equal(results[1], 1, 'incr was throttled');
|
||||
assert.equal(results[2], 1, 'incr was throttled');
|
||||
assert.equal(results[3], 2, 'incr was called twice');
|
||||
assert.equal(results[4], 2, 'incr was throttled');
|
||||
assert.equal(results[5], 3, 'incr was called trailing');
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
asyncTest('throttle triggers trailing call when invoked repeatedly', 2, function() {
|
||||
QUnit.test('throttle triggers trailing call when invoked repeatedly', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var limit = 48;
|
||||
var incr = function(){ counter++; };
|
||||
@@ -259,29 +292,33 @@
|
||||
throttledIncr();
|
||||
}
|
||||
var lastCount = counter;
|
||||
ok(counter > 1);
|
||||
assert.ok(counter > 1);
|
||||
|
||||
_.delay(function() {
|
||||
ok(counter > lastCount);
|
||||
start();
|
||||
assert.ok(counter > lastCount);
|
||||
done();
|
||||
}, 96);
|
||||
});
|
||||
|
||||
asyncTest('throttle does not trigger leading call when leading is set to false', 2, function() {
|
||||
QUnit.test('throttle does not trigger leading call when leading is set to false', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 60, {leading: false});
|
||||
|
||||
throttledIncr(); throttledIncr();
|
||||
equal(counter, 0);
|
||||
assert.equal(counter, 0);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 1);
|
||||
start();
|
||||
assert.equal(counter, 1);
|
||||
done();
|
||||
}, 96);
|
||||
});
|
||||
|
||||
asyncTest('more throttle does not trigger leading call when leading is set to false', 3, function() {
|
||||
QUnit.test('more throttle does not trigger leading call when leading is set to false', function(assert) {
|
||||
assert.expect(3);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 100, {leading: false});
|
||||
@@ -290,75 +327,83 @@
|
||||
_.delay(throttledIncr, 50);
|
||||
_.delay(throttledIncr, 60);
|
||||
_.delay(throttledIncr, 200);
|
||||
equal(counter, 0);
|
||||
assert.equal(counter, 0);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 1);
|
||||
assert.equal(counter, 1);
|
||||
}, 250);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 2);
|
||||
start();
|
||||
assert.equal(counter, 2);
|
||||
done();
|
||||
}, 350);
|
||||
});
|
||||
|
||||
asyncTest('one more throttle with leading: false test', 2, function() {
|
||||
QUnit.test('one more throttle with leading: false test', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 100, {leading: false});
|
||||
|
||||
var time = new Date;
|
||||
while (new Date - time < 350) throttledIncr();
|
||||
ok(counter <= 3);
|
||||
assert.ok(counter <= 3);
|
||||
|
||||
_.delay(function() {
|
||||
ok(counter <= 4);
|
||||
start();
|
||||
assert.ok(counter <= 4);
|
||||
done();
|
||||
}, 200);
|
||||
});
|
||||
|
||||
asyncTest('throttle does not trigger trailing call when trailing is set to false', 4, function() {
|
||||
QUnit.test('throttle does not trigger trailing call when trailing is set to false', function(assert) {
|
||||
assert.expect(4);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 60, {trailing: false});
|
||||
|
||||
throttledIncr(); throttledIncr(); throttledIncr();
|
||||
equal(counter, 1);
|
||||
assert.equal(counter, 1);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 1);
|
||||
assert.equal(counter, 1);
|
||||
|
||||
throttledIncr(); throttledIncr();
|
||||
equal(counter, 2);
|
||||
assert.equal(counter, 2);
|
||||
|
||||
_.delay(function() {
|
||||
equal(counter, 2);
|
||||
start();
|
||||
assert.equal(counter, 2);
|
||||
done();
|
||||
}, 96);
|
||||
}, 96);
|
||||
});
|
||||
|
||||
asyncTest('throttle continues to function after system time is set backwards', 2, function() {
|
||||
QUnit.test('throttle continues to function after system time is set backwards', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 100);
|
||||
var origNowFunc = _.now;
|
||||
|
||||
throttledIncr();
|
||||
equal(counter, 1);
|
||||
_.now = function () {
|
||||
assert.equal(counter, 1);
|
||||
_.now = function() {
|
||||
return new Date(2013, 0, 1, 1, 1, 1);
|
||||
};
|
||||
|
||||
_.delay(function() {
|
||||
throttledIncr();
|
||||
equal(counter, 2);
|
||||
start();
|
||||
assert.equal(counter, 2);
|
||||
done();
|
||||
_.now = origNowFunc;
|
||||
}, 200);
|
||||
});
|
||||
|
||||
asyncTest('throttle re-entrant', 2, function() {
|
||||
QUnit.test('throttle re-entrant', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var sequence = [
|
||||
['b1', 'b2'],
|
||||
['c1', 'c2']
|
||||
@@ -374,50 +419,114 @@
|
||||
};
|
||||
throttledAppend = _.throttle(append, 32);
|
||||
throttledAppend.call('a1', 'a2');
|
||||
equal(value, 'a1a2');
|
||||
assert.equal(value, 'a1a2');
|
||||
_.delay(function(){
|
||||
equal(value, 'a1a2c1c2b1b2', 'append was throttled successfully');
|
||||
start();
|
||||
assert.equal(value, 'a1a2c1c2b1b2', 'append was throttled successfully');
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
asyncTest('debounce', 1, function() {
|
||||
QUnit.test('throttle cancel', function(assert) {
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 32);
|
||||
throttledIncr();
|
||||
throttledIncr.cancel();
|
||||
throttledIncr();
|
||||
throttledIncr();
|
||||
|
||||
assert.equal(counter, 2, 'incr was called immediately');
|
||||
_.delay(function(){ assert.equal(counter, 3, 'incr was throttled'); done(); }, 64);
|
||||
});
|
||||
|
||||
QUnit.test('throttle cancel with leading: false', function(assert) {
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var throttledIncr = _.throttle(incr, 32, {leading: false});
|
||||
throttledIncr();
|
||||
throttledIncr.cancel();
|
||||
|
||||
assert.equal(counter, 0, 'incr was throttled');
|
||||
_.delay(function(){ assert.equal(counter, 0, 'incr was throttled'); done(); }, 64);
|
||||
});
|
||||
|
||||
QUnit.test('debounce', function(assert) {
|
||||
assert.expect(1);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var debouncedIncr = _.debounce(incr, 32);
|
||||
debouncedIncr(); debouncedIncr();
|
||||
_.delay(debouncedIncr, 16);
|
||||
_.delay(function(){ equal(counter, 1, 'incr was debounced'); start(); }, 96);
|
||||
_.delay(function(){ assert.equal(counter, 1, 'incr was debounced'); done(); }, 96);
|
||||
});
|
||||
|
||||
asyncTest('debounce asap', 4, function() {
|
||||
QUnit.test('debounce cancel', function(assert) {
|
||||
assert.expect(1);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var incr = function(){ counter++; };
|
||||
var debouncedIncr = _.debounce(incr, 32);
|
||||
debouncedIncr();
|
||||
debouncedIncr.cancel();
|
||||
_.delay(function(){ assert.equal(counter, 0, 'incr was not called'); done(); }, 96);
|
||||
});
|
||||
|
||||
QUnit.test('debounce asap', function(assert) {
|
||||
assert.expect(4);
|
||||
var done = assert.async();
|
||||
var a, b;
|
||||
var counter = 0;
|
||||
var incr = function(){ return ++counter; };
|
||||
var debouncedIncr = _.debounce(incr, 64, true);
|
||||
a = debouncedIncr();
|
||||
b = debouncedIncr();
|
||||
equal(a, 1);
|
||||
equal(b, 1);
|
||||
equal(counter, 1, 'incr was called immediately');
|
||||
assert.equal(a, 1);
|
||||
assert.equal(b, 1);
|
||||
assert.equal(counter, 1, 'incr was called immediately');
|
||||
_.delay(debouncedIncr, 16);
|
||||
_.delay(debouncedIncr, 32);
|
||||
_.delay(debouncedIncr, 48);
|
||||
_.delay(function(){ equal(counter, 1, 'incr was debounced'); start(); }, 128);
|
||||
_.delay(function(){ assert.equal(counter, 1, 'incr was debounced'); done(); }, 128);
|
||||
});
|
||||
|
||||
asyncTest('debounce asap recursively', 2, function() {
|
||||
QUnit.test('debounce asap cancel', function(assert) {
|
||||
assert.expect(4);
|
||||
var done = assert.async();
|
||||
var a, b;
|
||||
var counter = 0;
|
||||
var incr = function(){ return ++counter; };
|
||||
var debouncedIncr = _.debounce(incr, 64, true);
|
||||
a = debouncedIncr();
|
||||
debouncedIncr.cancel();
|
||||
b = debouncedIncr();
|
||||
assert.equal(a, 1);
|
||||
assert.equal(b, 2);
|
||||
assert.equal(counter, 2, 'incr was called immediately');
|
||||
_.delay(debouncedIncr, 16);
|
||||
_.delay(debouncedIncr, 32);
|
||||
_.delay(debouncedIncr, 48);
|
||||
_.delay(function(){ assert.equal(counter, 2, 'incr was debounced'); done(); }, 128);
|
||||
});
|
||||
|
||||
QUnit.test('debounce asap recursively', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var debouncedIncr = _.debounce(function(){
|
||||
counter++;
|
||||
if (counter < 10) debouncedIncr();
|
||||
}, 32, true);
|
||||
debouncedIncr();
|
||||
equal(counter, 1, 'incr was called immediately');
|
||||
_.delay(function(){ equal(counter, 1, 'incr was debounced'); start(); }, 96);
|
||||
assert.equal(counter, 1, 'incr was called immediately');
|
||||
_.delay(function(){ assert.equal(counter, 1, 'incr was debounced'); done(); }, 96);
|
||||
});
|
||||
|
||||
asyncTest('debounce after system time is set backwards', 2, function() {
|
||||
QUnit.test('debounce after system time is set backwards', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var counter = 0;
|
||||
var origNowFunc = _.now;
|
||||
var debouncedIncr = _.debounce(function(){
|
||||
@@ -425,21 +534,23 @@
|
||||
}, 100, true);
|
||||
|
||||
debouncedIncr();
|
||||
equal(counter, 1, 'incr was called immediately');
|
||||
assert.equal(counter, 1, 'incr was called immediately');
|
||||
|
||||
_.now = function () {
|
||||
_.now = function() {
|
||||
return new Date(2013, 0, 1, 1, 1, 1);
|
||||
};
|
||||
|
||||
_.delay(function() {
|
||||
debouncedIncr();
|
||||
equal(counter, 2, 'incr was debounced successfully');
|
||||
start();
|
||||
assert.equal(counter, 2, 'incr was debounced successfully');
|
||||
done();
|
||||
_.now = origNowFunc;
|
||||
}, 200);
|
||||
});
|
||||
|
||||
asyncTest('debounce re-entrant', 2, function() {
|
||||
QUnit.test('debounce re-entrant', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var sequence = [
|
||||
['b1', 'b2']
|
||||
];
|
||||
@@ -454,80 +565,81 @@
|
||||
};
|
||||
debouncedAppend = _.debounce(append, 32);
|
||||
debouncedAppend.call('a1', 'a2');
|
||||
equal(value, '');
|
||||
assert.equal(value, '');
|
||||
_.delay(function(){
|
||||
equal(value, 'a1a2b1b2', 'append was debounced successfully');
|
||||
start();
|
||||
assert.equal(value, 'a1a2b1b2', 'append was debounced successfully');
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
test('once', function() {
|
||||
QUnit.test('once', function(assert) {
|
||||
var num = 0;
|
||||
var increment = _.once(function(){ return ++num; });
|
||||
increment();
|
||||
increment();
|
||||
equal(num, 1);
|
||||
assert.equal(num, 1);
|
||||
|
||||
equal(increment(), 1, 'stores a memo to the last value');
|
||||
assert.equal(increment(), 1, 'stores a memo to the last value');
|
||||
});
|
||||
|
||||
test('Recursive onced function.', 1, function() {
|
||||
QUnit.test('Recursive onced function.', function(assert) {
|
||||
assert.expect(1);
|
||||
var f = _.once(function(){
|
||||
ok(true);
|
||||
assert.ok(true);
|
||||
f();
|
||||
});
|
||||
f();
|
||||
});
|
||||
|
||||
test('wrap', function() {
|
||||
QUnit.test('wrap', function(assert) {
|
||||
var greet = function(name){ return 'hi: ' + name; };
|
||||
var backwards = _.wrap(greet, function(func, name){ return func(name) + ' ' + name.split('').reverse().join(''); });
|
||||
equal(backwards('moe'), 'hi: moe eom', 'wrapped the salutation function');
|
||||
assert.equal(backwards('moe'), 'hi: moe eom', 'wrapped the salutation function');
|
||||
|
||||
var inner = function(){ return 'Hello '; };
|
||||
var obj = {name : 'Moe'};
|
||||
obj.hi = _.wrap(inner, function(fn){ return fn() + this.name; });
|
||||
equal(obj.hi(), 'Hello Moe');
|
||||
var obj = {name: 'Moe'};
|
||||
obj.hi = _.wrap(inner, function(fn){ return fn() + this.name; });
|
||||
assert.equal(obj.hi(), 'Hello Moe');
|
||||
|
||||
var noop = function(){};
|
||||
var noop = function(){};
|
||||
var wrapped = _.wrap(noop, function(){ return Array.prototype.slice.call(arguments, 0); });
|
||||
var ret = wrapped(['whats', 'your'], 'vector', 'victor');
|
||||
deepEqual(ret, [noop, ['whats', 'your'], 'vector', 'victor']);
|
||||
var ret = wrapped(['whats', 'your'], 'vector', 'victor');
|
||||
assert.deepEqual(ret, [noop, ['whats', 'your'], 'vector', 'victor']);
|
||||
});
|
||||
|
||||
test('negate', function() {
|
||||
QUnit.test('negate', function(assert) {
|
||||
var isOdd = function(n){ return n & 1; };
|
||||
equal(_.negate(isOdd)(2), true, 'should return the complement of the given function');
|
||||
equal(_.negate(isOdd)(3), false, 'should return the complement of the given function');
|
||||
assert.equal(_.negate(isOdd)(2), true, 'should return the complement of the given function');
|
||||
assert.equal(_.negate(isOdd)(3), false, 'should return the complement of the given function');
|
||||
});
|
||||
|
||||
test('compose', function() {
|
||||
QUnit.test('compose', function(assert) {
|
||||
var greet = function(name){ return 'hi: ' + name; };
|
||||
var exclaim = function(sentence){ return sentence + '!'; };
|
||||
var composed = _.compose(exclaim, greet);
|
||||
equal(composed('moe'), 'hi: moe!', 'can compose a function that takes another');
|
||||
assert.equal(composed('moe'), 'hi: moe!', 'can compose a function that takes another');
|
||||
|
||||
composed = _.compose(greet, exclaim);
|
||||
equal(composed('moe'), 'hi: moe!', 'in this case, the functions are also commutative');
|
||||
assert.equal(composed('moe'), 'hi: moe!', 'in this case, the functions are also commutative');
|
||||
|
||||
// f(g(h(x, y, z)))
|
||||
function h(x, y, z) {
|
||||
equal(arguments.length, 3, 'First function called with multiple args');
|
||||
assert.equal(arguments.length, 3, 'First function called with multiple args');
|
||||
return z * y;
|
||||
}
|
||||
function g(x) {
|
||||
equal(arguments.length, 1, 'Composed function is called with 1 argument');
|
||||
assert.equal(arguments.length, 1, 'Composed function is called with 1 argument');
|
||||
return x;
|
||||
}
|
||||
function f(x) {
|
||||
equal(arguments.length, 1, 'Composed function is called with 1 argument');
|
||||
assert.equal(arguments.length, 1, 'Composed function is called with 1 argument');
|
||||
return x * 2;
|
||||
}
|
||||
composed = _.compose(f, g, h);
|
||||
equal(composed(1, 2, 3), 12);
|
||||
assert.equal(composed(1, 2, 3), 12);
|
||||
});
|
||||
|
||||
test('after', function() {
|
||||
QUnit.test('after', function(assert) {
|
||||
var testAfter = function(afterAmount, timesCalled) {
|
||||
var afterCalled = 0;
|
||||
var after = _.after(afterAmount, function() {
|
||||
@@ -537,13 +649,13 @@
|
||||
return afterCalled;
|
||||
};
|
||||
|
||||
equal(testAfter(5, 5), 1, 'after(N) should fire after being called N times');
|
||||
equal(testAfter(5, 4), 0, 'after(N) should not fire unless called N times');
|
||||
equal(testAfter(0, 0), 0, 'after(0) should not fire immediately');
|
||||
equal(testAfter(0, 1), 1, 'after(0) should fire when first invoked');
|
||||
assert.equal(testAfter(5, 5), 1, 'after(N) should fire after being called N times');
|
||||
assert.equal(testAfter(5, 4), 0, 'after(N) should not fire unless called N times');
|
||||
assert.equal(testAfter(0, 0), 0, 'after(0) should not fire immediately');
|
||||
assert.equal(testAfter(0, 1), 1, 'after(0) should fire when first invoked');
|
||||
});
|
||||
|
||||
test('before', function() {
|
||||
QUnit.test('before', function(assert) {
|
||||
var testBefore = function(beforeAmount, timesCalled) {
|
||||
var beforeCalled = 0;
|
||||
var before = _.before(beforeAmount, function() { beforeCalled++; });
|
||||
@@ -551,31 +663,60 @@
|
||||
return beforeCalled;
|
||||
};
|
||||
|
||||
equal(testBefore(5, 5), 4, 'before(N) should not fire after being called N times');
|
||||
equal(testBefore(5, 4), 4, 'before(N) should fire before being called N times');
|
||||
equal(testBefore(0, 0), 0, 'before(0) should not fire immediately');
|
||||
equal(testBefore(0, 1), 0, 'before(0) should not fire when first invoked');
|
||||
assert.equal(testBefore(5, 5), 4, 'before(N) should not fire after being called N times');
|
||||
assert.equal(testBefore(5, 4), 4, 'before(N) should fire before being called N times');
|
||||
assert.equal(testBefore(0, 0), 0, 'before(0) should not fire immediately');
|
||||
assert.equal(testBefore(0, 1), 0, 'before(0) should not fire when first invoked');
|
||||
|
||||
var context = {num: 0};
|
||||
var increment = _.before(3, function(){ return ++this.num; });
|
||||
_.times(10, increment, context);
|
||||
equal(increment(), 2, 'stores a memo to the last value');
|
||||
equal(context.num, 2, 'provides context');
|
||||
assert.equal(increment(), 2, 'stores a memo to the last value');
|
||||
assert.equal(context.num, 2, 'provides context');
|
||||
});
|
||||
|
||||
test('iteratee', function() {
|
||||
QUnit.test('iteratee', function(assert) {
|
||||
var identity = _.iteratee();
|
||||
equal(identity, _.identity, '_.iteratee is exposed as an external function.');
|
||||
assert.equal(identity, _.identity, '_.iteratee is exposed as an external function.');
|
||||
|
||||
function fn() {
|
||||
return arguments;
|
||||
}
|
||||
_.each([_.iteratee(fn), _.iteratee(fn, {})], function(cb) {
|
||||
equal(cb().length, 0);
|
||||
deepEqual(_.toArray(cb(1, 2, 3)), _.range(1, 4));
|
||||
deepEqual(_.toArray(cb(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), _.range(1, 11));
|
||||
assert.equal(cb().length, 0);
|
||||
assert.deepEqual(_.toArray(cb(1, 2, 3)), _.range(1, 4));
|
||||
assert.deepEqual(_.toArray(cb(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), _.range(1, 11));
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
QUnit.test('restArgs', function(assert) {
|
||||
assert.expect(10);
|
||||
_.restArgs(function(a, args) {
|
||||
assert.strictEqual(a, 1);
|
||||
assert.deepEqual(args, [2, 3], 'collects rest arguments into an array');
|
||||
})(1, 2, 3);
|
||||
|
||||
_.restArgs(function(a, args) {
|
||||
assert.strictEqual(a, void 0);
|
||||
assert.deepEqual(args, [], 'passes empty array if there are not enough arguments');
|
||||
})();
|
||||
|
||||
_.restArgs(function(a, b, c, args) {
|
||||
assert.strictEqual(arguments.length, 4);
|
||||
assert.deepEqual(args, [4, 5], 'works on functions with many named parameters');
|
||||
})(1, 2, 3, 4, 5);
|
||||
|
||||
var obj = {};
|
||||
_.restArgs(function() {
|
||||
assert.strictEqual(this, obj, 'invokes function with this context');
|
||||
}).call(obj);
|
||||
|
||||
_.restArgs(function(array, iteratee, context) {
|
||||
assert.deepEqual(array, [1, 2, 3, 4], 'startIndex can be used manually specify index of rest parameter');
|
||||
assert.strictEqual(iteratee, void 0);
|
||||
assert.strictEqual(context, void 0);
|
||||
}, 0)(1, 2, 3, 4);
|
||||
});
|
||||
|
||||
}());
|
||||
|
||||
991
vendor/underscore/test/objects.js
vendored
991
vendor/underscore/test/objects.js
vendored
File diff suppressed because it is too large
Load Diff
338
vendor/underscore/test/utility.js
vendored
338
vendor/underscore/test/utility.js
vendored
@@ -4,181 +4,217 @@
|
||||
|
||||
QUnit.module('Utility', {
|
||||
|
||||
setup: function() {
|
||||
beforeEach: function() {
|
||||
templateSettings = _.clone(_.templateSettings);
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
afterEach: function() {
|
||||
_.templateSettings = templateSettings;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
test('#750 - Return _ instance.', 2, function() {
|
||||
if (typeof this == 'object') {
|
||||
QUnit.test('noConflict', function(assert) {
|
||||
var underscore = _.noConflict();
|
||||
assert.equal(underscore.identity(1), 1);
|
||||
if (typeof require != 'function') {
|
||||
assert.equal(this._, void 0, 'global underscore is removed');
|
||||
this._ = underscore;
|
||||
} else if (typeof global !== 'undefined') {
|
||||
delete global._;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof require == 'function') {
|
||||
QUnit.test('noConflict (node vm)', function(assert) {
|
||||
assert.expect(2);
|
||||
var done = assert.async();
|
||||
var fs = require('fs');
|
||||
var vm = require('vm');
|
||||
var filename = __dirname + '/../underscore.js';
|
||||
fs.readFile(filename, function(err, content){
|
||||
var sandbox = vm.createScript(
|
||||
content + 'this.underscore = this._.noConflict();',
|
||||
filename
|
||||
);
|
||||
var context = {_: 'oldvalue'};
|
||||
sandbox.runInNewContext(context);
|
||||
assert.equal(context._, 'oldvalue');
|
||||
assert.equal(context.underscore.VERSION, _.VERSION);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
QUnit.test('#750 - Return _ instance.', function(assert) {
|
||||
assert.expect(2);
|
||||
var instance = _([]);
|
||||
ok(_(instance) === instance);
|
||||
ok(new _(instance) === instance);
|
||||
assert.ok(_(instance) === instance);
|
||||
assert.ok(new _(instance) === instance);
|
||||
});
|
||||
|
||||
test('identity', function() {
|
||||
var stooge = {name : 'moe'};
|
||||
equal(_.identity(stooge), stooge, 'stooge is the same as his identity');
|
||||
QUnit.test('identity', function(assert) {
|
||||
var stooge = {name: 'moe'};
|
||||
assert.equal(_.identity(stooge), stooge, 'stooge is the same as his identity');
|
||||
});
|
||||
|
||||
test('constant', function() {
|
||||
var stooge = {name : 'moe'};
|
||||
equal(_.constant(stooge)(), stooge, 'should create a function that returns stooge');
|
||||
QUnit.test('constant', function(assert) {
|
||||
var stooge = {name: 'moe'};
|
||||
assert.equal(_.constant(stooge)(), stooge, 'should create a function that returns stooge');
|
||||
});
|
||||
|
||||
test('noop', function() {
|
||||
strictEqual(_.noop('curly', 'larry', 'moe'), undefined, 'should always return undefined');
|
||||
QUnit.test('noop', function(assert) {
|
||||
assert.strictEqual(_.noop('curly', 'larry', 'moe'), void 0, 'should always return undefined');
|
||||
});
|
||||
|
||||
test('property', function() {
|
||||
var stooge = {name : 'moe'};
|
||||
equal(_.property('name')(stooge), 'moe', 'should return the property with the given name');
|
||||
equal(_.property('name')(null), undefined, 'should return undefined for null values');
|
||||
equal(_.property('name')(undefined), undefined, 'should return undefined for undefined values');
|
||||
QUnit.test('property', function(assert) {
|
||||
var stooge = {name: 'moe'};
|
||||
assert.equal(_.property('name')(stooge), 'moe', 'should return the property with the given name');
|
||||
assert.equal(_.property('name')(null), void 0, 'should return undefined for null values');
|
||||
assert.equal(_.property('name')(void 0), void 0, 'should return undefined for undefined values');
|
||||
});
|
||||
|
||||
test('propertyOf', function() {
|
||||
|
||||
QUnit.test('propertyOf', function(assert) {
|
||||
var stoogeRanks = _.propertyOf({curly: 2, moe: 1, larry: 3});
|
||||
equal(stoogeRanks('curly'), 2, 'should return the property with the given name');
|
||||
equal(stoogeRanks(null), undefined, 'should return undefined for null values');
|
||||
equal(stoogeRanks(undefined), undefined, 'should return undefined for undefined values');
|
||||
|
||||
assert.equal(stoogeRanks('curly'), 2, 'should return the property with the given name');
|
||||
assert.equal(stoogeRanks(null), void 0, 'should return undefined for null values');
|
||||
assert.equal(stoogeRanks(void 0), void 0, 'should return undefined for undefined values');
|
||||
|
||||
function MoreStooges() { this.shemp = 87; }
|
||||
MoreStooges.prototype = {curly: 2, moe: 1, larry: 3};
|
||||
var moreStoogeRanks = _.propertyOf(new MoreStooges());
|
||||
equal(moreStoogeRanks('curly'), 2, 'should return properties from further up the prototype chain');
|
||||
|
||||
assert.equal(moreStoogeRanks('curly'), 2, 'should return properties from further up the prototype chain');
|
||||
|
||||
var nullPropertyOf = _.propertyOf(null);
|
||||
equal(nullPropertyOf('curly'), undefined, 'should return undefined when obj is null');
|
||||
|
||||
var undefPropertyOf = _.propertyOf(undefined);
|
||||
equal(undefPropertyOf('curly'), undefined, 'should return undefined when obj is undefined');
|
||||
assert.equal(nullPropertyOf('curly'), void 0, 'should return undefined when obj is null');
|
||||
|
||||
var undefPropertyOf = _.propertyOf(void 0);
|
||||
assert.equal(undefPropertyOf('curly'), void 0, 'should return undefined when obj is undefined');
|
||||
});
|
||||
|
||||
test('random', function() {
|
||||
QUnit.test('random', function(assert) {
|
||||
var array = _.range(1000);
|
||||
var min = Math.pow(2, 31);
|
||||
var max = Math.pow(2, 62);
|
||||
|
||||
ok(_.every(array, function() {
|
||||
assert.ok(_.every(array, function() {
|
||||
return _.random(min, max) >= min;
|
||||
}), 'should produce a random number greater than or equal to the minimum number');
|
||||
|
||||
ok(_.some(array, function() {
|
||||
assert.ok(_.some(array, function() {
|
||||
return _.random(Number.MAX_VALUE) > 0;
|
||||
}), 'should produce a random number when passed `Number.MAX_VALUE`');
|
||||
});
|
||||
|
||||
test('now', function() {
|
||||
QUnit.test('now', function(assert) {
|
||||
var diff = _.now() - new Date().getTime();
|
||||
ok(diff <= 0 && diff > -5, 'Produces the correct time in milliseconds');//within 5ms
|
||||
assert.ok(diff <= 0 && diff > -5, 'Produces the correct time in milliseconds');//within 5ms
|
||||
});
|
||||
|
||||
test('uniqueId', function() {
|
||||
QUnit.test('uniqueId', function(assert) {
|
||||
var ids = [], i = 0;
|
||||
while (i++ < 100) ids.push(_.uniqueId());
|
||||
equal(_.uniq(ids).length, ids.length, 'can generate a globally-unique stream of ids');
|
||||
assert.equal(_.uniq(ids).length, ids.length, 'can generate a globally-unique stream of ids');
|
||||
});
|
||||
|
||||
test('times', function() {
|
||||
QUnit.test('times', function(assert) {
|
||||
var vals = [];
|
||||
_.times(3, function (i) { vals.push(i); });
|
||||
deepEqual(vals, [0, 1, 2], 'is 0 indexed');
|
||||
_.times(3, function(i) { vals.push(i); });
|
||||
assert.deepEqual(vals, [0, 1, 2], 'is 0 indexed');
|
||||
//
|
||||
vals = [];
|
||||
_(3).times(function(i) { vals.push(i); });
|
||||
deepEqual(vals, [0, 1, 2], 'works as a wrapper');
|
||||
assert.deepEqual(vals, [0, 1, 2], 'works as a wrapper');
|
||||
// collects return values
|
||||
deepEqual([0, 1, 2], _.times(3, function(i) { return i; }), 'collects return values');
|
||||
assert.deepEqual([0, 1, 2], _.times(3, function(i) { return i; }), 'collects return values');
|
||||
|
||||
deepEqual(_.times(0, _.identity), []);
|
||||
deepEqual(_.times(-1, _.identity), []);
|
||||
deepEqual(_.times(parseFloat('-Infinity'), _.identity), []);
|
||||
assert.deepEqual(_.times(0, _.identity), []);
|
||||
assert.deepEqual(_.times(-1, _.identity), []);
|
||||
assert.deepEqual(_.times(parseFloat('-Infinity'), _.identity), []);
|
||||
});
|
||||
|
||||
test('mixin', function() {
|
||||
QUnit.test('mixin', function(assert) {
|
||||
_.mixin({
|
||||
myReverse: function(string) {
|
||||
return string.split('').reverse().join('');
|
||||
}
|
||||
});
|
||||
equal(_.myReverse('panacea'), 'aecanap', 'mixed in a function to _');
|
||||
equal(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OOP wrapper');
|
||||
assert.equal(_.myReverse('panacea'), 'aecanap', 'mixed in a function to _');
|
||||
assert.equal(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OOP wrapper');
|
||||
});
|
||||
|
||||
test('_.escape', function() {
|
||||
equal(_.escape(null), '');
|
||||
QUnit.test('_.escape', function(assert) {
|
||||
assert.equal(_.escape(null), '');
|
||||
});
|
||||
|
||||
test('_.unescape', function() {
|
||||
QUnit.test('_.unescape', function(assert) {
|
||||
var string = 'Curly & Moe';
|
||||
equal(_.unescape(null), '');
|
||||
equal(_.unescape(_.escape(string)), string);
|
||||
equal(_.unescape(string), string, 'don\'t unescape unnecessarily');
|
||||
assert.equal(_.unescape(null), '');
|
||||
assert.equal(_.unescape(_.escape(string)), string);
|
||||
assert.equal(_.unescape(string), string, 'don\'t unescape unnecessarily');
|
||||
});
|
||||
|
||||
// Don't care what they escape them to just that they're escaped and can be unescaped
|
||||
test('_.escape & unescape', function() {
|
||||
QUnit.test('_.escape & unescape', function(assert) {
|
||||
// test & (&) seperately obviously
|
||||
var escapeCharacters = ['<', '>', '"', '\'', '`'];
|
||||
|
||||
_.each(escapeCharacters, function(escapeChar) {
|
||||
var str = 'a ' + escapeChar + ' string escaped';
|
||||
var escaped = _.escape(str);
|
||||
notEqual(str, escaped, escapeChar + ' is escaped');
|
||||
equal(str, _.unescape(escaped), escapeChar + ' can be unescaped');
|
||||
var s = 'a ' + escapeChar + ' string escaped';
|
||||
var e = _.escape(s);
|
||||
assert.notEqual(s, e, escapeChar + ' is escaped');
|
||||
assert.equal(s, _.unescape(e), escapeChar + ' can be unescaped');
|
||||
|
||||
str = 'a ' + escapeChar + escapeChar + escapeChar + 'some more string' + escapeChar;
|
||||
escaped = _.escape(str);
|
||||
s = 'a ' + escapeChar + escapeChar + escapeChar + 'some more string' + escapeChar;
|
||||
e = _.escape(s);
|
||||
|
||||
equal(escaped.indexOf(escapeChar), -1, 'can escape multiple occurances of ' + escapeChar);
|
||||
equal(_.unescape(escaped), str, 'multiple occurrences of ' + escapeChar + ' can be unescaped');
|
||||
assert.equal(e.indexOf(escapeChar), -1, 'can escape multiple occurances of ' + escapeChar);
|
||||
assert.equal(_.unescape(e), s, 'multiple occurrences of ' + escapeChar + ' can be unescaped');
|
||||
});
|
||||
|
||||
// handles multiple escape characters at once
|
||||
var joiner = ' other stuff ';
|
||||
var allEscaped = escapeCharacters.join(joiner);
|
||||
allEscaped += allEscaped;
|
||||
ok(_.every(escapeCharacters, function(escapeChar) {
|
||||
assert.ok(_.every(escapeCharacters, function(escapeChar) {
|
||||
return allEscaped.indexOf(escapeChar) !== -1;
|
||||
}), 'handles multiple characters');
|
||||
ok(allEscaped.indexOf(joiner) >= 0, 'can escape multiple escape characters at the same time');
|
||||
assert.ok(allEscaped.indexOf(joiner) >= 0, 'can escape multiple escape characters at the same time');
|
||||
|
||||
// test & -> &
|
||||
var str = 'some string & another string & yet another';
|
||||
var escaped = _.escape(str);
|
||||
|
||||
ok(escaped.indexOf('&') !== -1, 'handles & aka &');
|
||||
equal(_.unescape(str), str, 'can unescape &');
|
||||
assert.ok(escaped.indexOf('&') !== -1, 'handles & aka &');
|
||||
assert.equal(_.unescape(str), str, 'can unescape &');
|
||||
});
|
||||
|
||||
test('template', function() {
|
||||
QUnit.test('template', function(assert) {
|
||||
var basicTemplate = _.template("<%= thing %> is gettin' on my noives!");
|
||||
var result = basicTemplate({thing : 'This'});
|
||||
equal(result, "This is gettin' on my noives!", 'can do basic attribute interpolation');
|
||||
var result = basicTemplate({thing: 'This'});
|
||||
assert.equal(result, "This is gettin' on my noives!", 'can do basic attribute interpolation');
|
||||
|
||||
var sansSemicolonTemplate = _.template('A <% this %> B');
|
||||
equal(sansSemicolonTemplate(), 'A B');
|
||||
assert.equal(sansSemicolonTemplate(), 'A B');
|
||||
|
||||
var backslashTemplate = _.template('<%= thing %> is \\ridanculous');
|
||||
equal(backslashTemplate({thing: 'This'}), 'This is \\ridanculous');
|
||||
assert.equal(backslashTemplate({thing: 'This'}), 'This is \\ridanculous');
|
||||
|
||||
var escapeTemplate = _.template('<%= a ? "checked=\\"checked\\"" : "" %>');
|
||||
equal(escapeTemplate({a: true}), 'checked="checked"', 'can handle slash escapes in interpolations.');
|
||||
assert.equal(escapeTemplate({a: true}), 'checked="checked"', 'can handle slash escapes in interpolations.');
|
||||
|
||||
var fancyTemplate = _.template('<ul><% ' +
|
||||
' for (var key in people) { ' +
|
||||
'%><li><%= people[key] %></li><% } %></ul>');
|
||||
result = fancyTemplate({people : {moe : 'Moe', larry : 'Larry', curly : 'Curly'}});
|
||||
equal(result, '<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', 'can run arbitrary javascript in templates');
|
||||
result = fancyTemplate({people: {moe: 'Moe', larry: 'Larry', curly: 'Curly'}});
|
||||
assert.equal(result, '<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', 'can run arbitrary javascript in templates');
|
||||
|
||||
var escapedCharsInJavascriptTemplate = _.template('<ul><% _.each(numbers.split("\\n"), function(item) { %><li><%= item %></li><% }) %></ul>');
|
||||
result = escapedCharsInJavascriptTemplate({numbers: 'one\ntwo\nthree\nfour'});
|
||||
equal(result, '<ul><li>one</li><li>two</li><li>three</li><li>four</li></ul>', 'Can use escaped characters (e.g. \\n) in JavaScript');
|
||||
assert.equal(result, '<ul><li>one</li><li>two</li><li>three</li><li>four</li></ul>', 'Can use escaped characters (e.g. \\n) in JavaScript');
|
||||
|
||||
var namespaceCollisionTemplate = _.template('<%= pageCount %> <%= thumbnails[pageCount] %> <% _.each(thumbnails, function(p) { %><div class="thumbnail" rel="<%= p %>"></div><% }); %>');
|
||||
result = namespaceCollisionTemplate({
|
||||
@@ -189,32 +225,32 @@
|
||||
3: 'p3-thumbnail.gif'
|
||||
}
|
||||
});
|
||||
equal(result, '3 p3-thumbnail.gif <div class="thumbnail" rel="p1-thumbnail.gif"></div><div class="thumbnail" rel="p2-thumbnail.gif"></div><div class="thumbnail" rel="p3-thumbnail.gif"></div>');
|
||||
assert.equal(result, '3 p3-thumbnail.gif <div class="thumbnail" rel="p1-thumbnail.gif"></div><div class="thumbnail" rel="p2-thumbnail.gif"></div><div class="thumbnail" rel="p3-thumbnail.gif"></div>');
|
||||
|
||||
var noInterpolateTemplate = _.template('<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>');
|
||||
result = noInterpolateTemplate();
|
||||
equal(result, '<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>');
|
||||
assert.equal(result, '<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>');
|
||||
|
||||
var quoteTemplate = _.template("It's its, not it's");
|
||||
equal(quoteTemplate({}), "It's its, not it's");
|
||||
assert.equal(quoteTemplate({}), "It's its, not it's");
|
||||
|
||||
var quoteInStatementAndBody = _.template('<% ' +
|
||||
" if(foo == 'bar'){ " +
|
||||
"%>Statement quotes and 'quotes'.<% } %>");
|
||||
equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'.");
|
||||
assert.equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'.");
|
||||
|
||||
var withNewlinesAndTabs = _.template('This\n\t\tis: <%= x %>.\n\tok.\nend.');
|
||||
equal(withNewlinesAndTabs({x: 'that'}), 'This\n\t\tis: that.\n\tok.\nend.');
|
||||
assert.equal(withNewlinesAndTabs({x: 'that'}), 'This\n\t\tis: that.\n\tok.\nend.');
|
||||
|
||||
var template = _.template('<i><%- value %></i>');
|
||||
result = template({value: '<script>'});
|
||||
equal(result, '<i><script></i>');
|
||||
assert.equal(result, '<i><script></i>');
|
||||
|
||||
var stooge = {
|
||||
name: 'Moe',
|
||||
template: _.template("I'm <%= this.name %>")
|
||||
};
|
||||
equal(stooge.template(), "I'm Moe");
|
||||
assert.equal(stooge.template(), "I'm Moe");
|
||||
|
||||
template = _.template('\n ' +
|
||||
' <%\n ' +
|
||||
@@ -222,159 +258,163 @@
|
||||
' if (data) { data += 12345; }; %>\n ' +
|
||||
' <li><%= data %></li>\n '
|
||||
);
|
||||
equal(template({data : 12345}).replace(/\s/g, ''), '<li>24690</li>');
|
||||
assert.equal(template({data: 12345}).replace(/\s/g, ''), '<li>24690</li>');
|
||||
|
||||
_.templateSettings = {
|
||||
evaluate : /\{\{([\s\S]+?)\}\}/g,
|
||||
interpolate : /\{\{=([\s\S]+?)\}\}/g
|
||||
evaluate: /\{\{([\s\S]+?)\}\}/g,
|
||||
interpolate: /\{\{=([\s\S]+?)\}\}/g
|
||||
};
|
||||
|
||||
var custom = _.template('<ul>{{ for (var key in people) { }}<li>{{= people[key] }}</li>{{ } }}</ul>');
|
||||
result = custom({people : {moe : 'Moe', larry : 'Larry', curly : 'Curly'}});
|
||||
equal(result, '<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', 'can run arbitrary javascript in templates');
|
||||
result = custom({people: {moe: 'Moe', larry: 'Larry', curly: 'Curly'}});
|
||||
assert.equal(result, '<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', 'can run arbitrary javascript in templates');
|
||||
|
||||
var customQuote = _.template("It's its, not it's");
|
||||
equal(customQuote({}), "It's its, not it's");
|
||||
assert.equal(customQuote({}), "It's its, not it's");
|
||||
|
||||
quoteInStatementAndBody = _.template("{{ if(foo == 'bar'){ }}Statement quotes and 'quotes'.{{ } }}");
|
||||
equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'.");
|
||||
assert.equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'.");
|
||||
|
||||
_.templateSettings = {
|
||||
evaluate : /<\?([\s\S]+?)\?>/g,
|
||||
interpolate : /<\?=([\s\S]+?)\?>/g
|
||||
evaluate: /<\?([\s\S]+?)\?>/g,
|
||||
interpolate: /<\?=([\s\S]+?)\?>/g
|
||||
};
|
||||
|
||||
var customWithSpecialChars = _.template('<ul><? for (var key in people) { ?><li><?= people[key] ?></li><? } ?></ul>');
|
||||
result = customWithSpecialChars({people : {moe : 'Moe', larry : 'Larry', curly : 'Curly'}});
|
||||
equal(result, '<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', 'can run arbitrary javascript in templates');
|
||||
result = customWithSpecialChars({people: {moe: 'Moe', larry: 'Larry', curly: 'Curly'}});
|
||||
assert.equal(result, '<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', 'can run arbitrary javascript in templates');
|
||||
|
||||
var customWithSpecialCharsQuote = _.template("It's its, not it's");
|
||||
equal(customWithSpecialCharsQuote({}), "It's its, not it's");
|
||||
assert.equal(customWithSpecialCharsQuote({}), "It's its, not it's");
|
||||
|
||||
quoteInStatementAndBody = _.template("<? if(foo == 'bar'){ ?>Statement quotes and 'quotes'.<? } ?>");
|
||||
equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'.");
|
||||
assert.equal(quoteInStatementAndBody({foo: 'bar'}), "Statement quotes and 'quotes'.");
|
||||
|
||||
_.templateSettings = {
|
||||
interpolate : /\{\{(.+?)\}\}/g
|
||||
interpolate: /\{\{(.+?)\}\}/g
|
||||
};
|
||||
|
||||
var mustache = _.template('Hello {{planet}}!');
|
||||
equal(mustache({planet : 'World'}), 'Hello World!', 'can mimic mustache.js');
|
||||
assert.equal(mustache({planet: 'World'}), 'Hello World!', 'can mimic mustache.js');
|
||||
|
||||
var templateWithNull = _.template('a null undefined {{planet}}');
|
||||
equal(templateWithNull({planet : 'world'}), 'a null undefined world', 'can handle missing escape and evaluate settings');
|
||||
assert.equal(templateWithNull({planet: 'world'}), 'a null undefined world', 'can handle missing escape and evaluate settings');
|
||||
});
|
||||
|
||||
test('_.template provides the generated function source, when a SyntaxError occurs', function() {
|
||||
QUnit.test('_.template provides the generated function source, when a SyntaxError occurs', function(assert) {
|
||||
var source;
|
||||
try {
|
||||
_.template('<b><%= if x %></b>');
|
||||
} catch (ex) {
|
||||
var source = ex.source;
|
||||
source = ex.source;
|
||||
}
|
||||
ok(/__p/.test(source));
|
||||
assert.ok(/__p/.test(source));
|
||||
});
|
||||
|
||||
test('_.template handles \\u2028 & \\u2029', function() {
|
||||
QUnit.test('_.template handles \\u2028 & \\u2029', function(assert) {
|
||||
var tmpl = _.template('<p>\u2028<%= "\\u2028\\u2029" %>\u2029</p>');
|
||||
strictEqual(tmpl(), '<p>\u2028\u2028\u2029\u2029</p>');
|
||||
assert.strictEqual(tmpl(), '<p>\u2028\u2028\u2029\u2029</p>');
|
||||
});
|
||||
|
||||
test('result calls functions and returns primitives', function() {
|
||||
QUnit.test('result calls functions and returns primitives', function(assert) {
|
||||
var obj = {w: '', x: 'x', y: function(){ return this.x; }};
|
||||
strictEqual(_.result(obj, 'w'), '');
|
||||
strictEqual(_.result(obj, 'x'), 'x');
|
||||
strictEqual(_.result(obj, 'y'), 'x');
|
||||
strictEqual(_.result(obj, 'z'), undefined);
|
||||
strictEqual(_.result(null, 'x'), undefined);
|
||||
assert.strictEqual(_.result(obj, 'w'), '');
|
||||
assert.strictEqual(_.result(obj, 'x'), 'x');
|
||||
assert.strictEqual(_.result(obj, 'y'), 'x');
|
||||
assert.strictEqual(_.result(obj, 'z'), void 0);
|
||||
assert.strictEqual(_.result(null, 'x'), void 0);
|
||||
});
|
||||
|
||||
test('result returns a default value if object is null or undefined', function() {
|
||||
strictEqual(_.result(null, 'b', 'default'), 'default');
|
||||
strictEqual(_.result(undefined, 'c', 'default'), 'default');
|
||||
strictEqual(_.result(''.match('missing'), 1, 'default'), 'default');
|
||||
QUnit.test('result returns a default value if object is null or undefined', function(assert) {
|
||||
assert.strictEqual(_.result(null, 'b', 'default'), 'default');
|
||||
assert.strictEqual(_.result(void 0, 'c', 'default'), 'default');
|
||||
assert.strictEqual(_.result(''.match('missing'), 1, 'default'), 'default');
|
||||
});
|
||||
|
||||
test('result returns a default value if property of object is missing', function() {
|
||||
strictEqual(_.result({d: null}, 'd', 'default'), null);
|
||||
strictEqual(_.result({e: false}, 'e', 'default'), false);
|
||||
QUnit.test('result returns a default value if property of object is missing', function(assert) {
|
||||
assert.strictEqual(_.result({d: null}, 'd', 'default'), null);
|
||||
assert.strictEqual(_.result({e: false}, 'e', 'default'), false);
|
||||
});
|
||||
|
||||
test('result only returns the default value if the object does not have the property or is undefined', function() {
|
||||
strictEqual(_.result({}, 'b', 'default'), 'default');
|
||||
strictEqual(_.result({d: undefined}, 'd', 'default'), 'default');
|
||||
QUnit.test('result only returns the default value if the object does not have the property or is undefined', function(assert) {
|
||||
assert.strictEqual(_.result({}, 'b', 'default'), 'default');
|
||||
assert.strictEqual(_.result({d: void 0}, 'd', 'default'), 'default');
|
||||
});
|
||||
|
||||
test('result does not return the default if the property of an object is found in the prototype', function() {
|
||||
QUnit.test('result does not return the default if the property of an object is found in the prototype', function(assert) {
|
||||
var Foo = function(){};
|
||||
Foo.prototype.bar = 1;
|
||||
strictEqual(_.result(new Foo, 'bar', 2), 1);
|
||||
assert.strictEqual(_.result(new Foo, 'bar', 2), 1);
|
||||
});
|
||||
|
||||
test('result does use the fallback when the result of invoking the property is undefined', function() {
|
||||
QUnit.test('result does use the fallback when the result of invoking the property is undefined', function(assert) {
|
||||
var obj = {a: function() {}};
|
||||
strictEqual(_.result(obj, 'a', 'failed'), undefined);
|
||||
assert.strictEqual(_.result(obj, 'a', 'failed'), void 0);
|
||||
});
|
||||
|
||||
test('result fallback can use a function', function() {
|
||||
QUnit.test('result fallback can use a function', function(assert) {
|
||||
var obj = {a: [1, 2, 3]};
|
||||
strictEqual(_.result(obj, 'b', _.constant(5)), 5);
|
||||
strictEqual(_.result(obj, 'b', function() {
|
||||
assert.strictEqual(_.result(obj, 'b', _.constant(5)), 5);
|
||||
assert.strictEqual(_.result(obj, 'b', function() {
|
||||
return this.a;
|
||||
}), obj.a, 'called with context');
|
||||
});
|
||||
|
||||
test('_.templateSettings.variable', function() {
|
||||
QUnit.test('_.templateSettings.variable', function(assert) {
|
||||
var s = '<%=data.x%>';
|
||||
var data = {x: 'x'};
|
||||
var tmp = _.template(s, {variable: 'data'});
|
||||
strictEqual(tmp(data), 'x');
|
||||
assert.strictEqual(tmp(data), 'x');
|
||||
_.templateSettings.variable = 'data';
|
||||
strictEqual(_.template(s)(data), 'x');
|
||||
assert.strictEqual(_.template(s)(data), 'x');
|
||||
});
|
||||
|
||||
test('#547 - _.templateSettings is unchanged by custom settings.', function() {
|
||||
ok(!_.templateSettings.variable);
|
||||
QUnit.test('#547 - _.templateSettings is unchanged by custom settings.', function(assert) {
|
||||
assert.ok(!_.templateSettings.variable);
|
||||
_.template('', {}, {variable: 'x'});
|
||||
ok(!_.templateSettings.variable);
|
||||
assert.ok(!_.templateSettings.variable);
|
||||
});
|
||||
|
||||
test('#556 - undefined template variables.', function() {
|
||||
QUnit.test('#556 - undefined template variables.', function(assert) {
|
||||
var template = _.template('<%=x%>');
|
||||
strictEqual(template({x: null}), '');
|
||||
strictEqual(template({x: undefined}), '');
|
||||
assert.strictEqual(template({x: null}), '');
|
||||
assert.strictEqual(template({x: void 0}), '');
|
||||
|
||||
var templateEscaped = _.template('<%-x%>');
|
||||
strictEqual(templateEscaped({x: null}), '');
|
||||
strictEqual(templateEscaped({x: undefined}), '');
|
||||
assert.strictEqual(templateEscaped({x: null}), '');
|
||||
assert.strictEqual(templateEscaped({x: void 0}), '');
|
||||
|
||||
var templateWithProperty = _.template('<%=x.foo%>');
|
||||
strictEqual(templateWithProperty({x: {}}), '');
|
||||
strictEqual(templateWithProperty({x: {}}), '');
|
||||
assert.strictEqual(templateWithProperty({x: {}}), '');
|
||||
assert.strictEqual(templateWithProperty({x: {}}), '');
|
||||
|
||||
var templateWithPropertyEscaped = _.template('<%-x.foo%>');
|
||||
strictEqual(templateWithPropertyEscaped({x: {}}), '');
|
||||
strictEqual(templateWithPropertyEscaped({x: {}}), '');
|
||||
assert.strictEqual(templateWithPropertyEscaped({x: {}}), '');
|
||||
assert.strictEqual(templateWithPropertyEscaped({x: {}}), '');
|
||||
});
|
||||
|
||||
test('interpolate evaluates code only once.', 2, function() {
|
||||
QUnit.test('interpolate evaluates code only once.', function(assert) {
|
||||
assert.expect(2);
|
||||
var count = 0;
|
||||
var template = _.template('<%= f() %>');
|
||||
template({f: function(){ ok(!count++); }});
|
||||
template({f: function(){ assert.ok(!count++); }});
|
||||
|
||||
var countEscaped = 0;
|
||||
var templateEscaped = _.template('<%- f() %>');
|
||||
templateEscaped({f: function(){ ok(!countEscaped++); }});
|
||||
templateEscaped({f: function(){ assert.ok(!countEscaped++); }});
|
||||
});
|
||||
|
||||
test('#746 - _.template settings are not modified.', 1, function() {
|
||||
QUnit.test('#746 - _.template settings are not modified.', function(assert) {
|
||||
assert.expect(1);
|
||||
var settings = {};
|
||||
_.template('', null, settings);
|
||||
deepEqual(settings, {});
|
||||
assert.deepEqual(settings, {});
|
||||
});
|
||||
|
||||
test('#779 - delimeters are applied to unescaped text.', 1, function() {
|
||||
QUnit.test('#779 - delimeters are applied to unescaped text.', function(assert) {
|
||||
assert.expect(1);
|
||||
var template = _.template('<<\nx\n>>', null, {evaluate: /<<(.*?)>>/g});
|
||||
strictEqual(template(), '<<\nx\n>>');
|
||||
assert.strictEqual(template(), '<<\nx\n>>');
|
||||
});
|
||||
|
||||
}());
|
||||
|
||||
507
vendor/underscore/underscore.js
vendored
507
vendor/underscore/underscore.js
vendored
@@ -8,29 +8,30 @@
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `exports` on the server.
|
||||
var root = this;
|
||||
// Establish the root object, `window` (`self`) in the browser, `global`
|
||||
// on the server, or `this` in some virtual machines. We use `self`
|
||||
// instead of `window` for `WebWorker` support.
|
||||
var root = typeof self == 'object' && self.self === self && self ||
|
||||
typeof global == 'object' && global.global === global && global ||
|
||||
this;
|
||||
|
||||
// Save the previous value of the `_` variable.
|
||||
var previousUnderscore = root._;
|
||||
|
||||
// Save bytes in the minified (but not gzipped) version:
|
||||
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
|
||||
var ArrayProto = Array.prototype, ObjProto = Object.prototype;
|
||||
|
||||
// Create quick reference variables for speed access to core prototypes.
|
||||
var
|
||||
push = ArrayProto.push,
|
||||
slice = ArrayProto.slice,
|
||||
toString = ObjProto.toString,
|
||||
hasOwnProperty = ObjProto.hasOwnProperty;
|
||||
var push = ArrayProto.push,
|
||||
slice = ArrayProto.slice,
|
||||
toString = ObjProto.toString,
|
||||
hasOwnProperty = ObjProto.hasOwnProperty;
|
||||
|
||||
// All **ECMAScript 5** native function implementations that we hope to use
|
||||
// are declared here.
|
||||
var
|
||||
nativeIsArray = Array.isArray,
|
||||
nativeKeys = Object.keys,
|
||||
nativeBind = FuncProto.bind,
|
||||
nativeCreate = Object.create;
|
||||
var nativeIsArray = Array.isArray,
|
||||
nativeKeys = Object.keys,
|
||||
nativeCreate = Object.create;
|
||||
|
||||
// Naked function reference for surrogate-prototype-swapping.
|
||||
var Ctor = function(){};
|
||||
@@ -43,10 +44,12 @@
|
||||
};
|
||||
|
||||
// Export the Underscore object for **Node.js**, with
|
||||
// backwards-compatibility for the old `require()` API. If we're in
|
||||
// backwards-compatibility for their old module API. If we're in
|
||||
// the browser, add `_` as a global object.
|
||||
if (typeof exports !== 'undefined') {
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
// (`nodeType` is checked to ensure that `module`
|
||||
// and `exports` are not HTML elements.)
|
||||
if (typeof exports != 'undefined' && !exports.nodeType) {
|
||||
if (typeof module != 'undefined' && !module.nodeType && module.exports) {
|
||||
exports = module.exports = _;
|
||||
}
|
||||
exports._ = _;
|
||||
@@ -66,9 +69,8 @@
|
||||
case 1: return function(value) {
|
||||
return func.call(context, value);
|
||||
};
|
||||
case 2: return function(value, other) {
|
||||
return func.call(context, value, other);
|
||||
};
|
||||
// The 2-parameter case has been omitted only because no current consumers
|
||||
// made use of it.
|
||||
case 3: return function(value, index, collection) {
|
||||
return func.call(context, value, index, collection);
|
||||
};
|
||||
@@ -81,34 +83,42 @@
|
||||
};
|
||||
};
|
||||
|
||||
// A mostly-internal function to generate callbacks that can be applied
|
||||
// to each element in a collection, returning the desired result — either
|
||||
// identity, an arbitrary callback, a property matcher, or a property accessor.
|
||||
// An internal function to generate callbacks that can be applied to each
|
||||
// element in a collection, returning the desired result — either `identity`,
|
||||
// an arbitrary callback, a property matcher, or a property accessor.
|
||||
var cb = function(value, context, argCount) {
|
||||
if (value == null) return _.identity;
|
||||
if (_.isFunction(value)) return optimizeCb(value, context, argCount);
|
||||
if (_.isObject(value)) return _.matcher(value);
|
||||
return _.property(value);
|
||||
};
|
||||
|
||||
// An external wrapper for the internal callback generator
|
||||
_.iteratee = function(value, context) {
|
||||
return cb(value, context, Infinity);
|
||||
};
|
||||
|
||||
// An internal function for creating assigner functions.
|
||||
var createAssigner = function(keysFunc, undefinedOnly) {
|
||||
return function(obj) {
|
||||
var length = arguments.length;
|
||||
if (length < 2 || obj == null) return obj;
|
||||
for (var index = 1; index < length; index++) {
|
||||
var source = arguments[index],
|
||||
keys = keysFunc(source),
|
||||
l = keys.length;
|
||||
for (var i = 0; i < l; i++) {
|
||||
var key = keys[i];
|
||||
if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key];
|
||||
}
|
||||
// Similar to ES6's rest param (http://ariya.ofilabs.com/2013/03/es6-and-rest-parameter.html)
|
||||
// This accumulates the arguments passed into an array, after a given index.
|
||||
var restArgs = function(func, startIndex) {
|
||||
startIndex = startIndex == null ? func.length - 1 : +startIndex;
|
||||
return function() {
|
||||
var length = Math.max(arguments.length - startIndex, 0);
|
||||
var rest = Array(length);
|
||||
for (var index = 0; index < length; index++) {
|
||||
rest[index] = arguments[index + startIndex];
|
||||
}
|
||||
return obj;
|
||||
switch (startIndex) {
|
||||
case 0: return func.call(this, rest);
|
||||
case 1: return func.call(this, arguments[0], rest);
|
||||
case 2: return func.call(this, arguments[0], arguments[1], rest);
|
||||
}
|
||||
var args = Array(startIndex + 1);
|
||||
for (index = 0; index < startIndex; index++) {
|
||||
args[index] = arguments[index];
|
||||
}
|
||||
args[startIndex] = rest;
|
||||
return func.apply(this, args);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -129,7 +139,7 @@
|
||||
};
|
||||
|
||||
// Helper for collection methods to determine whether a collection
|
||||
// should be iterated as an array or as an object
|
||||
// should be iterated as an array or as an object.
|
||||
// Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
|
||||
// Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
|
||||
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
|
||||
@@ -175,30 +185,29 @@
|
||||
};
|
||||
|
||||
// Create a reducing function iterating left or right.
|
||||
function createReduce(dir) {
|
||||
// Optimized iterator function as using arguments.length
|
||||
// in the main function will deoptimize the, see #1991.
|
||||
function iterator(obj, iteratee, memo, keys, index, length) {
|
||||
var createReduce = function(dir) {
|
||||
// Wrap code that reassigns argument variables in a separate function than
|
||||
// the one that accesses `arguments.length` to avoid a perf hit. (#1991)
|
||||
var reducer = function(obj, iteratee, memo, initial) {
|
||||
var keys = !isArrayLike(obj) && _.keys(obj),
|
||||
length = (keys || obj).length,
|
||||
index = dir > 0 ? 0 : length - 1;
|
||||
if (!initial) {
|
||||
memo = obj[keys ? keys[index] : index];
|
||||
index += dir;
|
||||
}
|
||||
for (; index >= 0 && index < length; index += dir) {
|
||||
var currentKey = keys ? keys[index] : index;
|
||||
memo = iteratee(memo, obj[currentKey], currentKey, obj);
|
||||
}
|
||||
return memo;
|
||||
}
|
||||
};
|
||||
|
||||
return function(obj, iteratee, memo, context) {
|
||||
iteratee = optimizeCb(iteratee, context, 4);
|
||||
var keys = !isArrayLike(obj) && _.keys(obj),
|
||||
length = (keys || obj).length,
|
||||
index = dir > 0 ? 0 : length - 1;
|
||||
// Determine the initial value if none is provided.
|
||||
if (arguments.length < 3) {
|
||||
memo = obj[keys ? keys[index] : index];
|
||||
index += dir;
|
||||
}
|
||||
return iterator(obj, iteratee, memo, keys, index, length);
|
||||
var initial = arguments.length >= 3;
|
||||
return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// **Reduce** builds up a single result from a list of values, aka `inject`,
|
||||
// or `foldl`.
|
||||
@@ -269,14 +278,13 @@
|
||||
};
|
||||
|
||||
// Invoke a method (with arguments) on every item in a collection.
|
||||
_.invoke = function(obj, method) {
|
||||
var args = slice.call(arguments, 2);
|
||||
_.invoke = restArgs(function(obj, method, args) {
|
||||
var isFunc = _.isFunction(method);
|
||||
return _.map(obj, function(value) {
|
||||
var func = isFunc ? method : value[method];
|
||||
return func == null ? func : func.apply(value, args);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
// Convenience version of a common use case of `map`: fetching a property.
|
||||
_.pluck = function(obj, key) {
|
||||
@@ -299,20 +307,20 @@
|
||||
_.max = function(obj, iteratee, context) {
|
||||
var result = -Infinity, lastComputed = -Infinity,
|
||||
value, computed;
|
||||
if (iteratee == null && obj != null) {
|
||||
if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object') && obj != null) {
|
||||
obj = isArrayLike(obj) ? obj : _.values(obj);
|
||||
for (var i = 0, length = obj.length; i < length; i++) {
|
||||
value = obj[i];
|
||||
if (value > result) {
|
||||
if (value != null && value > result) {
|
||||
result = value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iteratee = cb(iteratee, context);
|
||||
_.each(obj, function(value, index, list) {
|
||||
computed = iteratee(value, index, list);
|
||||
_.each(obj, function(v, index, list) {
|
||||
computed = iteratee(v, index, list);
|
||||
if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
|
||||
result = value;
|
||||
result = v;
|
||||
lastComputed = computed;
|
||||
}
|
||||
});
|
||||
@@ -324,20 +332,20 @@
|
||||
_.min = function(obj, iteratee, context) {
|
||||
var result = Infinity, lastComputed = Infinity,
|
||||
value, computed;
|
||||
if (iteratee == null && obj != null) {
|
||||
if (iteratee == null || (typeof iteratee == 'number' && typeof obj[0] != 'object') && obj != null) {
|
||||
obj = isArrayLike(obj) ? obj : _.values(obj);
|
||||
for (var i = 0, length = obj.length; i < length; i++) {
|
||||
value = obj[i];
|
||||
if (value < result) {
|
||||
if (value != null && value < result) {
|
||||
result = value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iteratee = cb(iteratee, context);
|
||||
_.each(obj, function(value, index, list) {
|
||||
computed = iteratee(value, index, list);
|
||||
_.each(obj, function(v, index, list) {
|
||||
computed = iteratee(v, index, list);
|
||||
if (computed < lastComputed || computed === Infinity && result === Infinity) {
|
||||
result = value;
|
||||
result = v;
|
||||
lastComputed = computed;
|
||||
}
|
||||
});
|
||||
@@ -345,21 +353,13 @@
|
||||
return result;
|
||||
};
|
||||
|
||||
// Shuffle a collection, using the modern version of the
|
||||
// [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
|
||||
// Shuffle a collection.
|
||||
_.shuffle = function(obj) {
|
||||
var set = isArrayLike(obj) ? obj : _.values(obj);
|
||||
var length = set.length;
|
||||
var shuffled = Array(length);
|
||||
for (var index = 0, rand; index < length; index++) {
|
||||
rand = _.random(0, index);
|
||||
if (rand !== index) shuffled[index] = shuffled[rand];
|
||||
shuffled[rand] = set[index];
|
||||
}
|
||||
return shuffled;
|
||||
return _.sample(obj, Infinity);
|
||||
};
|
||||
|
||||
// Sample **n** random values from a collection.
|
||||
// Sample **n** random values from a collection using the modern version of the
|
||||
// [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
|
||||
// If **n** is not specified, returns a single random element.
|
||||
// The internal `guard` argument allows it to work with `map`.
|
||||
_.sample = function(obj, n, guard) {
|
||||
@@ -367,17 +367,28 @@
|
||||
if (!isArrayLike(obj)) obj = _.values(obj);
|
||||
return obj[_.random(obj.length - 1)];
|
||||
}
|
||||
return _.shuffle(obj).slice(0, Math.max(0, n));
|
||||
var sample = isArrayLike(obj) ? _.clone(obj) : _.values(obj);
|
||||
var length = getLength(sample);
|
||||
n = Math.max(Math.min(n, length), 0);
|
||||
var last = length - 1;
|
||||
for (var index = 0; index < n; index++) {
|
||||
var rand = _.random(index, last);
|
||||
var temp = sample[index];
|
||||
sample[index] = sample[rand];
|
||||
sample[rand] = temp;
|
||||
}
|
||||
return sample.slice(0, n);
|
||||
};
|
||||
|
||||
// Sort the object's values by a criterion produced by an iteratee.
|
||||
_.sortBy = function(obj, iteratee, context) {
|
||||
var index = 0;
|
||||
iteratee = cb(iteratee, context);
|
||||
return _.pluck(_.map(obj, function(value, index, list) {
|
||||
return _.pluck(_.map(obj, function(value, key, list) {
|
||||
return {
|
||||
value: value,
|
||||
index: index,
|
||||
criteria: iteratee(value, index, list)
|
||||
index: index++,
|
||||
criteria: iteratee(value, key, list)
|
||||
};
|
||||
}).sort(function(left, right) {
|
||||
var a = left.criteria;
|
||||
@@ -391,9 +402,9 @@
|
||||
};
|
||||
|
||||
// An internal function used for aggregate "group by" operations.
|
||||
var group = function(behavior) {
|
||||
var group = function(behavior, partition) {
|
||||
return function(obj, iteratee, context) {
|
||||
var result = {};
|
||||
var result = partition ? [[], []] : {};
|
||||
iteratee = cb(iteratee, context);
|
||||
_.each(obj, function(value, index) {
|
||||
var key = iteratee(value, index, obj);
|
||||
@@ -422,10 +433,15 @@
|
||||
if (_.has(result, key)) result[key]++; else result[key] = 1;
|
||||
});
|
||||
|
||||
var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
|
||||
// Safely create a real, live array from anything iterable.
|
||||
_.toArray = function(obj) {
|
||||
if (!obj) return [];
|
||||
if (_.isArray(obj)) return slice.call(obj);
|
||||
if (_.isString(obj)) {
|
||||
// Keep surrogate pair characters together
|
||||
return obj.match(reStrSymbol);
|
||||
}
|
||||
if (isArrayLike(obj)) return _.map(obj, _.identity);
|
||||
return _.values(obj);
|
||||
};
|
||||
@@ -438,14 +454,9 @@
|
||||
|
||||
// Split a collection into two arrays: one whose elements all satisfy the given
|
||||
// predicate, and one whose elements all do not satisfy the predicate.
|
||||
_.partition = function(obj, predicate, context) {
|
||||
predicate = cb(predicate, context);
|
||||
var pass = [], fail = [];
|
||||
_.each(obj, function(value, key, obj) {
|
||||
(predicate(value, key, obj) ? pass : fail).push(value);
|
||||
});
|
||||
return [pass, fail];
|
||||
};
|
||||
_.partition = group(function(result, value, pass) {
|
||||
result[pass ? 0 : 1].push(value);
|
||||
}, true);
|
||||
|
||||
// Array Functions
|
||||
// ---------------
|
||||
@@ -487,17 +498,19 @@
|
||||
};
|
||||
|
||||
// Internal implementation of a recursive `flatten` function.
|
||||
var flatten = function(input, shallow, strict, startIndex) {
|
||||
var output = [], idx = 0;
|
||||
for (var i = startIndex || 0, length = getLength(input); i < length; i++) {
|
||||
var flatten = function(input, shallow, strict, output) {
|
||||
output = output || [];
|
||||
var idx = output.length;
|
||||
for (var i = 0, length = getLength(input); i < length; i++) {
|
||||
var value = input[i];
|
||||
if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
|
||||
//flatten current level of array or arguments object
|
||||
if (!shallow) value = flatten(value, shallow, strict);
|
||||
var j = 0, len = value.length;
|
||||
output.length += len;
|
||||
while (j < len) {
|
||||
output[idx++] = value[j++];
|
||||
// Flatten current level of array or arguments object
|
||||
if (shallow) {
|
||||
var j = 0, len = value.length;
|
||||
while (j < len) output[idx++] = value[j++];
|
||||
} else {
|
||||
flatten(value, shallow, strict, output);
|
||||
idx = output.length;
|
||||
}
|
||||
} else if (!strict) {
|
||||
output[idx++] = value;
|
||||
@@ -512,9 +525,9 @@
|
||||
};
|
||||
|
||||
// Return a version of the array that does not contain the specified value(s).
|
||||
_.without = function(array) {
|
||||
return _.difference(array, slice.call(arguments, 1));
|
||||
};
|
||||
_.without = restArgs(function(array, otherArrays) {
|
||||
return _.difference(array, otherArrays);
|
||||
});
|
||||
|
||||
// Produce a duplicate-free version of the array. If the array has already
|
||||
// been sorted, you have the option of using a faster algorithm.
|
||||
@@ -548,9 +561,9 @@
|
||||
|
||||
// Produce an array that contains the union: each distinct element from all of
|
||||
// the passed-in arrays.
|
||||
_.union = function() {
|
||||
return _.uniq(flatten(arguments, true, true));
|
||||
};
|
||||
_.union = restArgs(function(arrays) {
|
||||
return _.uniq(flatten(arrays, true, true));
|
||||
});
|
||||
|
||||
// Produce an array that contains every item shared between all the
|
||||
// passed-in arrays.
|
||||
@@ -560,7 +573,8 @@
|
||||
for (var i = 0, length = getLength(array); i < length; i++) {
|
||||
var item = array[i];
|
||||
if (_.contains(result, item)) continue;
|
||||
for (var j = 1; j < argsLength; j++) {
|
||||
var j;
|
||||
for (j = 1; j < argsLength; j++) {
|
||||
if (!_.contains(arguments[j], item)) break;
|
||||
}
|
||||
if (j === argsLength) result.push(item);
|
||||
@@ -570,18 +584,12 @@
|
||||
|
||||
// Take the difference between one array and a number of other arrays.
|
||||
// Only the elements present in just the first array will remain.
|
||||
_.difference = function(array) {
|
||||
var rest = flatten(arguments, true, true, 1);
|
||||
_.difference = restArgs(function(array, rest) {
|
||||
rest = flatten(rest, true, true);
|
||||
return _.filter(array, function(value){
|
||||
return !_.contains(rest, value);
|
||||
});
|
||||
};
|
||||
|
||||
// Zip together multiple lists into a single array -- elements that share
|
||||
// an index go together.
|
||||
_.zip = function() {
|
||||
return _.unzip(arguments);
|
||||
};
|
||||
});
|
||||
|
||||
// Complement of _.zip. Unzip accepts an array of arrays and groups
|
||||
// each array's elements on shared indices
|
||||
@@ -595,6 +603,10 @@
|
||||
return result;
|
||||
};
|
||||
|
||||
// Zip together multiple lists into a single array -- elements that share
|
||||
// an index go together.
|
||||
_.zip = restArgs(_.unzip);
|
||||
|
||||
// Converts lists into objects. Pass either a single array of `[key, value]`
|
||||
// pairs, or two parallel arrays of the same length -- one of keys, and one of
|
||||
// the corresponding values.
|
||||
@@ -611,7 +623,7 @@
|
||||
};
|
||||
|
||||
// Generator function to create the findIndex and findLastIndex functions
|
||||
function createPredicateIndexFinder(dir) {
|
||||
var createPredicateIndexFinder = function(dir) {
|
||||
return function(array, predicate, context) {
|
||||
predicate = cb(predicate, context);
|
||||
var length = getLength(array);
|
||||
@@ -621,7 +633,7 @@
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// Returns the first index on an array-like that passes a predicate test
|
||||
_.findIndex = createPredicateIndexFinder(1);
|
||||
@@ -641,14 +653,14 @@
|
||||
};
|
||||
|
||||
// Generator function to create the indexOf and lastIndexOf functions
|
||||
function createIndexFinder(dir, predicateFind, sortedIndex) {
|
||||
var createIndexFinder = function(dir, predicateFind, sortedIndex) {
|
||||
return function(array, item, idx) {
|
||||
var i = 0, length = getLength(array);
|
||||
if (typeof idx == 'number') {
|
||||
if (dir > 0) {
|
||||
i = idx >= 0 ? idx : Math.max(idx + length, i);
|
||||
i = idx >= 0 ? idx : Math.max(idx + length, i);
|
||||
} else {
|
||||
length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
|
||||
length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
|
||||
}
|
||||
} else if (sortedIndex && idx && length) {
|
||||
idx = sortedIndex(array, item);
|
||||
@@ -663,7 +675,7 @@
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// Return the position of the first occurrence of an item in an array,
|
||||
// or -1 if the item is not included in the array.
|
||||
@@ -680,7 +692,9 @@
|
||||
stop = start || 0;
|
||||
start = 0;
|
||||
}
|
||||
step = step || 1;
|
||||
if (!step) {
|
||||
step = stop < start ? -1 : 1;
|
||||
}
|
||||
|
||||
var length = Math.max(Math.ceil((stop - start) / step), 0);
|
||||
var range = Array(length);
|
||||
@@ -692,6 +706,19 @@
|
||||
return range;
|
||||
};
|
||||
|
||||
// Split an **array** into several arrays containing **count** or less elements
|
||||
// of initial array
|
||||
_.chunk = function(array, count) {
|
||||
if (count == null || count < 1) return [];
|
||||
|
||||
var result = [];
|
||||
var i = 0, length = array.length;
|
||||
while (i < length) {
|
||||
result.push(slice.call(array, i, i += count));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// Function (ahem) Functions
|
||||
// ------------------
|
||||
|
||||
@@ -708,45 +735,46 @@
|
||||
// Create a function bound to a given object (assigning `this`, and arguments,
|
||||
// optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
|
||||
// available.
|
||||
_.bind = function(func, context) {
|
||||
if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
|
||||
_.bind = restArgs(function(func, context, args) {
|
||||
if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
|
||||
var args = slice.call(arguments, 2);
|
||||
var bound = function() {
|
||||
return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
|
||||
};
|
||||
var bound = restArgs(function(callArgs) {
|
||||
return executeBound(func, bound, context, this, args.concat(callArgs));
|
||||
});
|
||||
return bound;
|
||||
};
|
||||
});
|
||||
|
||||
// Partially apply a function by creating a version that has had some of its
|
||||
// arguments pre-filled, without changing its dynamic `this` context. _ acts
|
||||
// as a placeholder, allowing any combination of arguments to be pre-filled.
|
||||
_.partial = function(func) {
|
||||
var boundArgs = slice.call(arguments, 1);
|
||||
// as a placeholder by default, allowing any combination of arguments to be
|
||||
// pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.
|
||||
_.partial = restArgs(function(func, boundArgs) {
|
||||
var placeholder = _.partial.placeholder;
|
||||
var bound = function() {
|
||||
var position = 0, length = boundArgs.length;
|
||||
var args = Array(length);
|
||||
for (var i = 0; i < length; i++) {
|
||||
args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i];
|
||||
args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];
|
||||
}
|
||||
while (position < arguments.length) args.push(arguments[position++]);
|
||||
return executeBound(func, bound, this, this, args);
|
||||
};
|
||||
return bound;
|
||||
};
|
||||
});
|
||||
|
||||
_.partial.placeholder = _;
|
||||
|
||||
// Bind a number of an object's methods to that object. Remaining arguments
|
||||
// are the method names to be bound. Useful for ensuring that all callbacks
|
||||
// defined on an object belong to it.
|
||||
_.bindAll = function(obj) {
|
||||
var i, length = arguments.length, key;
|
||||
if (length <= 1) throw new Error('bindAll must be passed function names');
|
||||
for (i = 1; i < length; i++) {
|
||||
key = arguments[i];
|
||||
_.bindAll = restArgs(function(obj, keys) {
|
||||
keys = flatten(keys, false, false);
|
||||
var index = keys.length;
|
||||
if (index < 1) throw new Error('bindAll must be passed function names');
|
||||
while (index--) {
|
||||
var key = keys[index];
|
||||
obj[key] = _.bind(obj[key], obj);
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
});
|
||||
|
||||
// Memoize an expensive function by storing its results.
|
||||
_.memoize = function(func, hasher) {
|
||||
@@ -762,12 +790,11 @@
|
||||
|
||||
// Delays a function for the given number of milliseconds, and then calls
|
||||
// it with the arguments supplied.
|
||||
_.delay = function(func, wait) {
|
||||
var args = slice.call(arguments, 2);
|
||||
return setTimeout(function(){
|
||||
_.delay = restArgs(function(func, wait, args) {
|
||||
return setTimeout(function() {
|
||||
return func.apply(null, args);
|
||||
}, wait);
|
||||
};
|
||||
});
|
||||
|
||||
// Defers a function, scheduling it to run after the current call stack has
|
||||
// cleared.
|
||||
@@ -779,17 +806,18 @@
|
||||
// but if you'd like to disable the execution on the leading edge, pass
|
||||
// `{leading: false}`. To disable execution on the trailing edge, ditto.
|
||||
_.throttle = function(func, wait, options) {
|
||||
var context, args, result;
|
||||
var timeout = null;
|
||||
var timeout, context, args, result;
|
||||
var previous = 0;
|
||||
if (!options) options = {};
|
||||
|
||||
var later = function() {
|
||||
previous = options.leading === false ? 0 : _.now();
|
||||
timeout = null;
|
||||
result = func.apply(context, args);
|
||||
if (!timeout) context = args = null;
|
||||
};
|
||||
return function() {
|
||||
|
||||
var throttled = function() {
|
||||
var now = _.now();
|
||||
if (!previous && options.leading === false) previous = now;
|
||||
var remaining = wait - (now - previous);
|
||||
@@ -808,6 +836,14 @@
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
throttled.cancel = function() {
|
||||
clearTimeout(timeout);
|
||||
previous = 0;
|
||||
timeout = context = args = null;
|
||||
};
|
||||
|
||||
return throttled;
|
||||
};
|
||||
|
||||
// Returns a function, that, as long as it continues to be invoked, will not
|
||||
@@ -815,35 +851,32 @@
|
||||
// N milliseconds. If `immediate` is passed, trigger the function on the
|
||||
// leading edge, instead of the trailing.
|
||||
_.debounce = function(func, wait, immediate) {
|
||||
var timeout, args, context, timestamp, result;
|
||||
var timeout, result;
|
||||
|
||||
var later = function() {
|
||||
var last = _.now() - timestamp;
|
||||
|
||||
if (last < wait && last >= 0) {
|
||||
timeout = setTimeout(later, wait - last);
|
||||
} else {
|
||||
timeout = null;
|
||||
if (!immediate) {
|
||||
result = func.apply(context, args);
|
||||
if (!timeout) context = args = null;
|
||||
}
|
||||
}
|
||||
var later = function(context, args) {
|
||||
timeout = null;
|
||||
if (args) result = func.apply(context, args);
|
||||
};
|
||||
|
||||
return function() {
|
||||
context = this;
|
||||
args = arguments;
|
||||
timestamp = _.now();
|
||||
var debounced = restArgs(function(args) {
|
||||
var callNow = immediate && !timeout;
|
||||
if (!timeout) timeout = setTimeout(later, wait);
|
||||
if (timeout) clearTimeout(timeout);
|
||||
if (callNow) {
|
||||
result = func.apply(context, args);
|
||||
context = args = null;
|
||||
timeout = setTimeout(later, wait);
|
||||
result = func.apply(this, args);
|
||||
} else if (!immediate) {
|
||||
timeout = _.delay(later, wait, this, args);
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
debounced.cancel = function() {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
};
|
||||
|
||||
return debounced;
|
||||
};
|
||||
|
||||
// Returns the first function passed as an argument to the second,
|
||||
@@ -898,6 +931,8 @@
|
||||
// often you call it. Useful for lazy initialization.
|
||||
_.once = _.partial(_.before, 2);
|
||||
|
||||
_.restArgs = restArgs;
|
||||
|
||||
// Object Functions
|
||||
// ----------------
|
||||
|
||||
@@ -906,10 +941,10 @@
|
||||
var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
|
||||
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
|
||||
|
||||
function collectNonEnumProps(obj, keys) {
|
||||
var collectNonEnumProps = function(obj, keys) {
|
||||
var nonEnumIdx = nonEnumerableProps.length;
|
||||
var constructor = obj.constructor;
|
||||
var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
|
||||
var proto = _.isFunction(constructor) && constructor.prototype || ObjProto;
|
||||
|
||||
// Constructor is a special case.
|
||||
var prop = 'constructor';
|
||||
@@ -921,7 +956,7 @@
|
||||
keys.push(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Retrieve the names of an object's own properties.
|
||||
// Delegates to **ECMAScript 5**'s native `Object.keys`
|
||||
@@ -960,15 +995,14 @@
|
||||
// In contrast to _.map it returns an object
|
||||
_.mapObject = function(obj, iteratee, context) {
|
||||
iteratee = cb(iteratee, context);
|
||||
var keys = _.keys(obj),
|
||||
length = keys.length,
|
||||
results = {},
|
||||
currentKey;
|
||||
for (var index = 0; index < length; index++) {
|
||||
currentKey = keys[index];
|
||||
results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
|
||||
}
|
||||
return results;
|
||||
var keys = _.keys(obj),
|
||||
length = keys.length,
|
||||
results = {};
|
||||
for (var index = 0; index < length; index++) {
|
||||
var currentKey = keys[index];
|
||||
results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
// Convert an object into a list of `[key, value]` pairs.
|
||||
@@ -1002,6 +1036,25 @@
|
||||
return names.sort();
|
||||
};
|
||||
|
||||
// An internal function for creating assigner functions.
|
||||
var createAssigner = function(keysFunc, defaults) {
|
||||
return function(obj) {
|
||||
var length = arguments.length;
|
||||
if (defaults) obj = Object(obj);
|
||||
if (length < 2 || obj == null) return obj;
|
||||
for (var index = 1; index < length; index++) {
|
||||
var source = arguments[index],
|
||||
keys = keysFunc(source),
|
||||
l = keys.length;
|
||||
for (var i = 0; i < l; i++) {
|
||||
var key = keys[i];
|
||||
if (!defaults || obj[key] === void 0) obj[key] = source[key];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
};
|
||||
|
||||
// Extend a given object with all the properties in passed-in object(s).
|
||||
_.extend = createAssigner(_.allKeys);
|
||||
|
||||
@@ -1019,16 +1072,21 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Internal pick helper function to determine if `obj` has key `key`.
|
||||
var keyInObj = function(value, key, obj) {
|
||||
return key in obj;
|
||||
};
|
||||
|
||||
// Return a copy of the object only containing the whitelisted properties.
|
||||
_.pick = function(object, oiteratee, context) {
|
||||
var result = {}, obj = object, iteratee, keys;
|
||||
_.pick = restArgs(function(obj, keys) {
|
||||
var result = {}, iteratee = keys[0];
|
||||
if (obj == null) return result;
|
||||
if (_.isFunction(oiteratee)) {
|
||||
if (_.isFunction(iteratee)) {
|
||||
if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);
|
||||
keys = _.allKeys(obj);
|
||||
iteratee = optimizeCb(oiteratee, context);
|
||||
} else {
|
||||
keys = flatten(arguments, false, false, 1);
|
||||
iteratee = function(value, key, obj) { return key in obj; };
|
||||
iteratee = keyInObj;
|
||||
keys = flatten(keys, false, false);
|
||||
obj = Object(obj);
|
||||
}
|
||||
for (var i = 0, length = keys.length; i < length; i++) {
|
||||
@@ -1037,20 +1095,22 @@
|
||||
if (iteratee(value, key, obj)) result[key] = value;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
});
|
||||
|
||||
// Return a copy of the object without the blacklisted properties.
|
||||
_.omit = function(obj, iteratee, context) {
|
||||
_.omit = restArgs(function(obj, keys) {
|
||||
var iteratee = keys[0], context;
|
||||
if (_.isFunction(iteratee)) {
|
||||
iteratee = _.negate(iteratee);
|
||||
if (keys.length > 1) context = keys[1];
|
||||
} else {
|
||||
var keys = _.map(flatten(arguments, false, false, 1), String);
|
||||
keys = _.map(flatten(keys, false, false), String);
|
||||
iteratee = function(value, key) {
|
||||
return !_.contains(keys, key);
|
||||
};
|
||||
}
|
||||
return _.pick(obj, iteratee, context);
|
||||
};
|
||||
});
|
||||
|
||||
// Fill in a given object with default properties.
|
||||
_.defaults = createAssigner(_.allKeys, true);
|
||||
@@ -1092,12 +1152,23 @@
|
||||
|
||||
|
||||
// Internal recursive comparison function for `isEqual`.
|
||||
var eq = function(a, b, aStack, bStack) {
|
||||
var eq, deepEq;
|
||||
eq = function(a, b, aStack, bStack) {
|
||||
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
||||
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
|
||||
if (a === b) return a !== 0 || 1 / a === 1 / b;
|
||||
// A strict comparison is necessary because `null == undefined`.
|
||||
if (a == null || b == null) return a === b;
|
||||
// `NaN`s are equivalent, but non-reflexive.
|
||||
if (a !== a) return b !== b;
|
||||
// Exhaust primitive checks
|
||||
var type = typeof a;
|
||||
if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;
|
||||
return deepEq(a, b, aStack, bStack);
|
||||
};
|
||||
|
||||
// Internal recursive comparison function for `isEqual`.
|
||||
deepEq = function(a, b, aStack, bStack) {
|
||||
// Unwrap any wrapped objects.
|
||||
if (a instanceof _) a = a._wrapped;
|
||||
if (b instanceof _) b = b._wrapped;
|
||||
@@ -1215,7 +1286,7 @@
|
||||
};
|
||||
|
||||
// Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
|
||||
_.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
|
||||
_.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol'], function(name) {
|
||||
_['is' + name] = function(obj) {
|
||||
return toString.call(obj) === '[object ' + name + ']';
|
||||
};
|
||||
@@ -1230,8 +1301,9 @@
|
||||
}
|
||||
|
||||
// Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8,
|
||||
// IE 11 (#1621), and in Safari 8 (#1929).
|
||||
if (typeof /./ != 'function' && typeof Int8Array != 'object') {
|
||||
// IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236).
|
||||
var nodelist = root.document && root.document.childNodes;
|
||||
if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') {
|
||||
_.isFunction = function(obj) {
|
||||
return typeof obj == 'function' || false;
|
||||
};
|
||||
@@ -1242,9 +1314,9 @@
|
||||
return isFinite(obj) && !isNaN(parseFloat(obj));
|
||||
};
|
||||
|
||||
// Is the given value `NaN`? (NaN is the only number which does not equal itself).
|
||||
// Is the given value `NaN`?
|
||||
_.isNaN = function(obj) {
|
||||
return _.isNumber(obj) && obj !== +obj;
|
||||
return _.isNumber(obj) && isNaN(obj);
|
||||
};
|
||||
|
||||
// Is a given value a boolean?
|
||||
@@ -1362,8 +1434,8 @@
|
||||
|
||||
// If the value of the named `property` is a function then invoke it with the
|
||||
// `object` as context; otherwise, return it.
|
||||
_.result = function(object, property, fallback) {
|
||||
var value = object == null ? void 0 : object[property];
|
||||
_.result = function(object, prop, fallback) {
|
||||
var value = object == null ? void 0 : object[prop];
|
||||
if (value === void 0) {
|
||||
value = fallback;
|
||||
}
|
||||
@@ -1381,9 +1453,9 @@
|
||||
// By default, Underscore uses ERB-style template delimiters, change the
|
||||
// following template settings to use alternative delimiters.
|
||||
_.templateSettings = {
|
||||
evaluate : /<%([\s\S]+?)%>/g,
|
||||
interpolate : /<%=([\s\S]+?)%>/g,
|
||||
escape : /<%-([\s\S]+?)%>/g
|
||||
evaluate: /<%([\s\S]+?)%>/g,
|
||||
interpolate: /<%=([\s\S]+?)%>/g,
|
||||
escape: /<%-([\s\S]+?)%>/g
|
||||
};
|
||||
|
||||
// When customizing `templateSettings`, if you don't want to define an
|
||||
@@ -1394,15 +1466,15 @@
|
||||
// Certain characters need to be escaped so that they can be put into a
|
||||
// string literal.
|
||||
var escapes = {
|
||||
"'": "'",
|
||||
'\\': '\\',
|
||||
'\r': 'r',
|
||||
'\n': 'n',
|
||||
"'": "'",
|
||||
'\\': '\\',
|
||||
'\r': 'r',
|
||||
'\n': 'n',
|
||||
'\u2028': 'u2028',
|
||||
'\u2029': 'u2029'
|
||||
};
|
||||
|
||||
var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
|
||||
var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g;
|
||||
|
||||
var escapeChar = function(match) {
|
||||
return '\\' + escapes[match];
|
||||
@@ -1427,7 +1499,7 @@
|
||||
var index = 0;
|
||||
var source = "__p+='";
|
||||
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
|
||||
source += text.slice(index, offset).replace(escaper, escapeChar);
|
||||
source += text.slice(index, offset).replace(escapeRegExp, escapeChar);
|
||||
index = offset + match.length;
|
||||
|
||||
if (escape) {
|
||||
@@ -1438,7 +1510,7 @@
|
||||
source += "';\n" + evaluate + "\n__p+='";
|
||||
}
|
||||
|
||||
// Adobe VMs need the match returned to produce the correct offest.
|
||||
// Adobe VMs need the match returned to produce the correct offset.
|
||||
return match;
|
||||
});
|
||||
source += "';\n";
|
||||
@@ -1450,8 +1522,9 @@
|
||||
"print=function(){__p+=__j.call(arguments,'');};\n" +
|
||||
source + 'return __p;\n';
|
||||
|
||||
var render;
|
||||
try {
|
||||
var render = new Function(settings.variable || 'obj', '_', source);
|
||||
render = new Function(settings.variable || 'obj', '_', source);
|
||||
} catch (e) {
|
||||
e.source = source;
|
||||
throw e;
|
||||
@@ -1482,7 +1555,7 @@
|
||||
// underscore functions. Wrapped objects may be chained.
|
||||
|
||||
// Helper function to continue chaining intermediate results.
|
||||
var result = function(instance, obj) {
|
||||
var chainResult = function(instance, obj) {
|
||||
return instance._chain ? _(obj).chain() : obj;
|
||||
};
|
||||
|
||||
@@ -1493,7 +1566,7 @@
|
||||
_.prototype[name] = function() {
|
||||
var args = [this._wrapped];
|
||||
push.apply(args, arguments);
|
||||
return result(this, func.apply(_, args));
|
||||
return chainResult(this, func.apply(_, args));
|
||||
};
|
||||
});
|
||||
};
|
||||
@@ -1508,7 +1581,7 @@
|
||||
var obj = this._wrapped;
|
||||
method.apply(obj, arguments);
|
||||
if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
|
||||
return result(this, obj);
|
||||
return chainResult(this, obj);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1516,7 +1589,7 @@
|
||||
_.each(['concat', 'join', 'slice'], function(name) {
|
||||
var method = ArrayProto[name];
|
||||
_.prototype[name] = function() {
|
||||
return result(this, method.apply(this._wrapped, arguments));
|
||||
return chainResult(this, method.apply(this._wrapped, arguments));
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1540,9 +1613,9 @@
|
||||
// popular enough to be bundled in a third party lib, but not be part of
|
||||
// an AMD load request. Those cases could generate an error when an
|
||||
// anonymous define() is called outside of a loader request.
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
if (typeof define == 'function' && define.amd) {
|
||||
define('underscore', [], function() {
|
||||
return _;
|
||||
});
|
||||
}
|
||||
}.call(this));
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user