opal-wedge 0.9.0.dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (830) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.gitmodules +7 -0
  4. data/.inch.yml +19 -0
  5. data/.jshintrc +48 -0
  6. data/.rspec +3 -0
  7. data/.spectator +2 -0
  8. data/.spectator-mspec +3 -0
  9. data/.travis.yml +60 -0
  10. data/.yardopts +6 -0
  11. data/CHANGELOG.md +571 -0
  12. data/CODE_OF_CONDUCT.md +15 -0
  13. data/CONTRIBUTING.md +192 -0
  14. data/Gemfile +26 -0
  15. data/Guardfile +77 -0
  16. data/LICENSE +19 -0
  17. data/README.md +167 -0
  18. data/Rakefile +15 -0
  19. data/benchmark/benchmarks +103 -0
  20. data/benchmark/bm_array_intersection_numbers.rb +7 -0
  21. data/benchmark/bm_array_intersection_objects.rb +7 -0
  22. data/benchmark/bm_array_intersection_strings.rb +7 -0
  23. data/benchmark/bm_array_minus_numbers.rb +7 -0
  24. data/benchmark/bm_array_minus_objects.rb +7 -0
  25. data/benchmark/bm_array_minus_strings.rb +7 -0
  26. data/benchmark/bm_array_union_numbers.rb +7 -0
  27. data/benchmark/bm_array_union_objects.rb +7 -0
  28. data/benchmark/bm_array_union_strings.rb +7 -0
  29. data/benchmark/bm_array_uniq_bang_numbers.rb +5 -0
  30. data/benchmark/bm_array_uniq_bang_objects.rb +5 -0
  31. data/benchmark/bm_array_uniq_bang_strings.rb +5 -0
  32. data/benchmark/bm_array_uniq_numbers.rb +5 -0
  33. data/benchmark/bm_array_uniq_objects.rb +5 -0
  34. data/benchmark/bm_array_uniq_strings.rb +5 -0
  35. data/benchmark/bm_dispatch_bind_table.rb +57 -0
  36. data/benchmark/bm_dispatch_code_gen.rb +65 -0
  37. data/benchmark/bm_dispatch_code_gen_if.rb +64 -0
  38. data/benchmark/bm_dispatch_hardcoded.rb +44 -0
  39. data/benchmark/bm_dispatch_send.rb +38 -0
  40. data/benchmark/bm_dispatch_send_table.rb +57 -0
  41. data/benchmark/bm_hash_assoc_object.rb +11 -0
  42. data/benchmark/bm_hash_assoc_string.rb +9 -0
  43. data/benchmark/bm_hash_clone_object.rb +9 -0
  44. data/benchmark/bm_hash_clone_string.rb +9 -0
  45. data/benchmark/bm_hash_delete_object.rb +11 -0
  46. data/benchmark/bm_hash_delete_string.rb +9 -0
  47. data/benchmark/bm_hash_each_key_object.rb +9 -0
  48. data/benchmark/bm_hash_each_key_string.rb +9 -0
  49. data/benchmark/bm_hash_each_object.rb +9 -0
  50. data/benchmark/bm_hash_each_string.rb +9 -0
  51. data/benchmark/bm_hash_each_value_object.rb +9 -0
  52. data/benchmark/bm_hash_each_value_string.rb +9 -0
  53. data/benchmark/bm_hash_element_reference_object.rb +11 -0
  54. data/benchmark/bm_hash_element_reference_string.rb +9 -0
  55. data/benchmark/bm_hash_element_set_object.rb +5 -0
  56. data/benchmark/bm_hash_element_set_string.rb +5 -0
  57. data/benchmark/bm_hash_equal_value_object.rb +14 -0
  58. data/benchmark/bm_hash_equal_value_string.rb +11 -0
  59. data/benchmark/bm_hash_fetch_object.rb +11 -0
  60. data/benchmark/bm_hash_fetch_string.rb +9 -0
  61. data/benchmark/bm_hash_flatten_object.rb +9 -0
  62. data/benchmark/bm_hash_flatten_string.rb +9 -0
  63. data/benchmark/bm_hash_has_key_object.rb +11 -0
  64. data/benchmark/bm_hash_has_key_string.rb +9 -0
  65. data/benchmark/bm_hash_has_value_object.rb +9 -0
  66. data/benchmark/bm_hash_has_value_string.rb +9 -0
  67. data/benchmark/bm_hash_hash_object.rb +9 -0
  68. data/benchmark/bm_hash_hash_string.rb +9 -0
  69. data/benchmark/bm_hash_inspect_object.rb +9 -0
  70. data/benchmark/bm_hash_inspect_string.rb +9 -0
  71. data/benchmark/bm_hash_invert_object.rb +9 -0
  72. data/benchmark/bm_hash_invert_string.rb +9 -0
  73. data/benchmark/bm_hash_keep_if_object.rb +9 -0
  74. data/benchmark/bm_hash_keep_if_string.rb +9 -0
  75. data/benchmark/bm_hash_key_object.rb +9 -0
  76. data/benchmark/bm_hash_key_string.rb +9 -0
  77. data/benchmark/bm_hash_keys_object.rb +9 -0
  78. data/benchmark/bm_hash_keys_string.rb +9 -0
  79. data/benchmark/bm_hash_literal_mixed_large.rb +3 -0
  80. data/benchmark/bm_hash_literal_mixed_small.rb +3 -0
  81. data/benchmark/bm_hash_literal_object_large.rb +4 -0
  82. data/benchmark/bm_hash_literal_object_small.rb +3 -0
  83. data/benchmark/bm_hash_literal_string_large.rb +4 -0
  84. data/benchmark/bm_hash_literal_string_small.rb +3 -0
  85. data/benchmark/bm_hash_merge_object.rb +22 -0
  86. data/benchmark/bm_hash_merge_string.rb +18 -0
  87. data/benchmark/bm_hash_rassoc_object.rb +9 -0
  88. data/benchmark/bm_hash_rassoc_string.rb +9 -0
  89. data/benchmark/bm_hash_rehash_object.rb +9 -0
  90. data/benchmark/bm_hash_rehash_string.rb +9 -0
  91. data/benchmark/bm_hash_reject_bang_object.rb +9 -0
  92. data/benchmark/bm_hash_reject_bang_string.rb +9 -0
  93. data/benchmark/bm_hash_reject_object.rb +9 -0
  94. data/benchmark/bm_hash_reject_string.rb +9 -0
  95. data/benchmark/bm_hash_replace_object.rb +18 -0
  96. data/benchmark/bm_hash_replace_string.rb +14 -0
  97. data/benchmark/bm_hash_select_bang_object.rb +9 -0
  98. data/benchmark/bm_hash_select_bang_string.rb +9 -0
  99. data/benchmark/bm_hash_select_object.rb +9 -0
  100. data/benchmark/bm_hash_select_string.rb +9 -0
  101. data/benchmark/bm_hash_shift_object.rb +10 -0
  102. data/benchmark/bm_hash_shift_string.rb +10 -0
  103. data/benchmark/bm_hash_to_a_object.rb +9 -0
  104. data/benchmark/bm_hash_to_a_string.rb +9 -0
  105. data/benchmark/bm_hash_to_h_object.rb +10 -0
  106. data/benchmark/bm_hash_to_h_string.rb +10 -0
  107. data/benchmark/bm_hash_values_object.rb +9 -0
  108. data/benchmark/bm_hash_values_string.rb +9 -0
  109. data/benchmark/run.rb +37 -0
  110. data/bin/opal +27 -0
  111. data/bin/opal-build +77 -0
  112. data/bin/opal-mspec +10 -0
  113. data/bin/opal-repl +72 -0
  114. data/config.ru +14 -0
  115. data/docs/compiler_directives.md +127 -0
  116. data/examples/rack/.gitignore +1 -0
  117. data/examples/rack/Gemfile +3 -0
  118. data/examples/rack/app/application.rb +13 -0
  119. data/examples/rack/app/user.rb +22 -0
  120. data/examples/rack/config.ru +20 -0
  121. data/examples/rack/index.html.erb +10 -0
  122. data/examples/sinatra/Gemfile +5 -0
  123. data/examples/sinatra/app/application.rb +7 -0
  124. data/examples/sinatra/config.ru +38 -0
  125. data/lib/mspec/opal/main.rb.erb +9 -0
  126. data/lib/mspec/opal/new.html.erb +1 -0
  127. data/lib/mspec/opal/rake_task.rb +248 -0
  128. data/lib/mspec/opal/runner.rb +281 -0
  129. data/lib/mspec/opal/special_calls.rb +44 -0
  130. data/lib/mspec/opal/sprockets.js +57 -0
  131. data/lib/opal-wedge.rb +4 -0
  132. data/lib/opal.rb +11 -0
  133. data/lib/opal/builder.rb +161 -0
  134. data/lib/opal/builder_processors.rb +149 -0
  135. data/lib/opal/cli.rb +162 -0
  136. data/lib/opal/cli_options.rb +158 -0
  137. data/lib/opal/cli_runners.rb +11 -0
  138. data/lib/opal/cli_runners/apple_script.rb +65 -0
  139. data/lib/opal/cli_runners/nodejs.rb +63 -0
  140. data/lib/opal/cli_runners/phantom.js +44 -0
  141. data/lib/opal/cli_runners/phantomjs.rb +28 -0
  142. data/lib/opal/cli_runners/server.rb +56 -0
  143. data/lib/opal/compiler.rb +381 -0
  144. data/lib/opal/config.rb +48 -0
  145. data/lib/opal/erb.rb +84 -0
  146. data/lib/opal/fragment.rb +53 -0
  147. data/lib/opal/hike_path_finder.rb +18 -0
  148. data/lib/opal/nodes.rb +26 -0
  149. data/lib/opal/nodes/arglist.rb +56 -0
  150. data/lib/opal/nodes/array.rb +54 -0
  151. data/lib/opal/nodes/base.rb +151 -0
  152. data/lib/opal/nodes/call.rb +290 -0
  153. data/lib/opal/nodes/call_special.rb +252 -0
  154. data/lib/opal/nodes/case.rb +96 -0
  155. data/lib/opal/nodes/class.rb +42 -0
  156. data/lib/opal/nodes/constants.rb +78 -0
  157. data/lib/opal/nodes/def.rb +281 -0
  158. data/lib/opal/nodes/defined.rb +113 -0
  159. data/lib/opal/nodes/definitions.rb +168 -0
  160. data/lib/opal/nodes/for.rb +48 -0
  161. data/lib/opal/nodes/hash.rb +67 -0
  162. data/lib/opal/nodes/helpers.rb +116 -0
  163. data/lib/opal/nodes/if.rb +81 -0
  164. data/lib/opal/nodes/iter.rb +136 -0
  165. data/lib/opal/nodes/literal.rb +247 -0
  166. data/lib/opal/nodes/logic.rb +217 -0
  167. data/lib/opal/nodes/masgn.rb +62 -0
  168. data/lib/opal/nodes/module.rb +45 -0
  169. data/lib/opal/nodes/rescue.rb +143 -0
  170. data/lib/opal/nodes/runtime_helpers.rb +45 -0
  171. data/lib/opal/nodes/scope.rb +281 -0
  172. data/lib/opal/nodes/singleton_class.rb +26 -0
  173. data/lib/opal/nodes/super.rb +97 -0
  174. data/lib/opal/nodes/top.rb +103 -0
  175. data/lib/opal/nodes/variables.rb +191 -0
  176. data/lib/opal/nodes/while.rb +65 -0
  177. data/lib/opal/nodes/yield.rb +95 -0
  178. data/lib/opal/parser.rb +742 -0
  179. data/lib/opal/parser/grammar.rb +5723 -0
  180. data/lib/opal/parser/grammar.y +1787 -0
  181. data/lib/opal/parser/keywords.rb +66 -0
  182. data/lib/opal/parser/lexer.rb +1260 -0
  183. data/lib/opal/parser/parser_scope.rb +28 -0
  184. data/lib/opal/parser/sexp.rb +81 -0
  185. data/lib/opal/path_reader.rb +35 -0
  186. data/lib/opal/paths.rb +55 -0
  187. data/lib/opal/regexp_anchors.rb +5 -0
  188. data/lib/opal/source_map.rb +70 -0
  189. data/lib/opal/sprockets.rb +3 -0
  190. data/lib/opal/sprockets/cache_key_fix.rb +17 -0
  191. data/lib/opal/sprockets/environment.rb +31 -0
  192. data/lib/opal/sprockets/erb.rb +23 -0
  193. data/lib/opal/sprockets/path_reader.rb +36 -0
  194. data/lib/opal/sprockets/processor.rb +167 -0
  195. data/lib/opal/sprockets/server.rb +160 -0
  196. data/lib/opal/sprockets/source_map_header_patch.rb +41 -0
  197. data/lib/opal/sprockets/source_map_server.rb +115 -0
  198. data/lib/opal/util.rb +69 -0
  199. data/lib/opal/version.rb +5 -0
  200. data/lib/tilt/opal.rb +54 -0
  201. data/opal.gemspec +37 -0
  202. data/opal/README.md +6 -0
  203. data/opal/corelib/array.rb +2073 -0
  204. data/opal/corelib/array/inheritance.rb +127 -0
  205. data/opal/corelib/basic_object.rb +82 -0
  206. data/opal/corelib/boolean.rb +47 -0
  207. data/opal/corelib/class.rb +55 -0
  208. data/opal/corelib/comparable.rb +57 -0
  209. data/opal/corelib/complex.rb +3 -0
  210. data/opal/corelib/dir.rb +20 -0
  211. data/opal/corelib/enumerable.rb +1138 -0
  212. data/opal/corelib/enumerator.rb +426 -0
  213. data/opal/corelib/error.rb +77 -0
  214. data/opal/corelib/file.rb +59 -0
  215. data/opal/corelib/hash.rb +951 -0
  216. data/opal/corelib/helpers.rb +102 -0
  217. data/opal/corelib/io.rb +73 -0
  218. data/opal/corelib/kernel.rb +1124 -0
  219. data/opal/corelib/main.rb +7 -0
  220. data/opal/corelib/match_data.rb +128 -0
  221. data/opal/corelib/method.rb +62 -0
  222. data/opal/corelib/module.rb +553 -0
  223. data/opal/corelib/nil_class.rb +57 -0
  224. data/opal/corelib/numeric.rb +564 -0
  225. data/opal/corelib/proc.rb +105 -0
  226. data/opal/corelib/process.rb +27 -0
  227. data/opal/corelib/range.rb +116 -0
  228. data/opal/corelib/rational.rb +3 -0
  229. data/opal/corelib/regexp.rb +203 -0
  230. data/opal/corelib/runtime.js +1637 -0
  231. data/opal/corelib/string.rb +1762 -0
  232. data/opal/corelib/string/inheritance.rb +117 -0
  233. data/opal/corelib/struct.rb +159 -0
  234. data/opal/corelib/time.rb +746 -0
  235. data/opal/corelib/variables.rb +28 -0
  236. data/opal/opal.rb +33 -0
  237. data/spec/README.md +8 -0
  238. data/spec/filters/bugs/array.rb +77 -0
  239. data/spec/filters/bugs/basicobject.rb +33 -0
  240. data/spec/filters/bugs/class.rb +15 -0
  241. data/spec/filters/bugs/comparable.rb +4 -0
  242. data/spec/filters/bugs/date.rb +173 -0
  243. data/spec/filters/bugs/enumerable.rb +62 -0
  244. data/spec/filters/bugs/enumerator.rb +45 -0
  245. data/spec/filters/bugs/exception.rb +84 -0
  246. data/spec/filters/bugs/fixnum.rb +35 -0
  247. data/spec/filters/bugs/float.rb +100 -0
  248. data/spec/filters/bugs/hash.rb +17 -0
  249. data/spec/filters/bugs/integer.rb +63 -0
  250. data/spec/filters/bugs/kernel.rb +395 -0
  251. data/spec/filters/bugs/language.rb +246 -0
  252. data/spec/filters/bugs/math.rb +89 -0
  253. data/spec/filters/bugs/method.rb +5 -0
  254. data/spec/filters/bugs/module.rb +372 -0
  255. data/spec/filters/bugs/nil.rb +7 -0
  256. data/spec/filters/bugs/numeric.rb +123 -0
  257. data/spec/filters/bugs/proc.rb +65 -0
  258. data/spec/filters/bugs/range.rb +148 -0
  259. data/spec/filters/bugs/regexp.rb +252 -0
  260. data/spec/filters/bugs/set.rb +51 -0
  261. data/spec/filters/bugs/singleton.rb +6 -0
  262. data/spec/filters/bugs/string.rb +99 -0
  263. data/spec/filters/bugs/strscan.rb +106 -0
  264. data/spec/filters/bugs/struct.rb +22 -0
  265. data/spec/filters/bugs/time.rb +28 -0
  266. data/spec/filters/bugs/unboundmethod.rb +22 -0
  267. data/spec/filters/unsupported/array.rb +176 -0
  268. data/spec/filters/unsupported/basicobject.rb +12 -0
  269. data/spec/filters/unsupported/class.rb +4 -0
  270. data/spec/filters/unsupported/delegator.rb +5 -0
  271. data/spec/filters/unsupported/enumerable.rb +8 -0
  272. data/spec/filters/unsupported/enumerator.rb +13 -0
  273. data/spec/filters/unsupported/fixnum.rb +15 -0
  274. data/spec/filters/unsupported/float.rb +6 -0
  275. data/spec/filters/unsupported/hash.rb +55 -0
  276. data/spec/filters/unsupported/integer.rb +3 -0
  277. data/spec/filters/unsupported/kernel.rb +22 -0
  278. data/spec/filters/unsupported/language.rb +31 -0
  279. data/spec/filters/unsupported/matchdata.rb +33 -0
  280. data/spec/filters/unsupported/math.rb +3 -0
  281. data/spec/filters/unsupported/module.rb +36 -0
  282. data/spec/filters/unsupported/pathname.rb +3 -0
  283. data/spec/filters/unsupported/regexp.rb +94 -0
  284. data/spec/filters/unsupported/set.rb +4 -0
  285. data/spec/filters/unsupported/singleton.rb +6 -0
  286. data/spec/filters/unsupported/string.rb +538 -0
  287. data/spec/filters/unsupported/struct.rb +3 -0
  288. data/spec/filters/unsupported/time.rb +208 -0
  289. data/spec/lib/builder_processors_spec.rb +27 -0
  290. data/spec/lib/builder_spec.rb +72 -0
  291. data/spec/lib/cli_spec.rb +150 -0
  292. data/spec/lib/compiler/pre_processed_conditionals_spec.rb +87 -0
  293. data/spec/lib/compiler_spec.rb +131 -0
  294. data/spec/lib/dependency_resolver_spec.rb +40 -0
  295. data/spec/lib/fixtures/complex_sprockets.js.rb.erb +4 -0
  296. data/spec/lib/fixtures/file_with_directives.js +2 -0
  297. data/spec/lib/fixtures/jst_file.js.jst +1 -0
  298. data/spec/lib/fixtures/no_requires.rb +1 -0
  299. data/spec/lib/fixtures/opal_file.rb +2 -0
  300. data/spec/lib/fixtures/require_tree_test.rb +3 -0
  301. data/spec/lib/fixtures/required_file.js +1 -0
  302. data/spec/lib/fixtures/required_tree_test/required_file1.rb +1 -0
  303. data/spec/lib/fixtures/required_tree_test/required_file2.rb +1 -0
  304. data/spec/lib/fixtures/requires.rb +7 -0
  305. data/spec/lib/fixtures/source_map.rb +1 -0
  306. data/spec/lib/fixtures/source_map/subfolder/other_file.rb +1 -0
  307. data/spec/lib/fixtures/sprockets_file.js.rb +3 -0
  308. data/spec/lib/fixtures/sprockets_require_tree_test.rb +3 -0
  309. data/spec/lib/hike_path_finder_spec.rb +23 -0
  310. data/spec/lib/lexer_spec.rb +110 -0
  311. data/spec/lib/parser/alias_spec.rb +26 -0
  312. data/spec/lib/parser/and_spec.rb +13 -0
  313. data/spec/lib/parser/attrasgn_spec.rb +28 -0
  314. data/spec/lib/parser/begin_spec.rb +42 -0
  315. data/spec/lib/parser/block_spec.rb +12 -0
  316. data/spec/lib/parser/break_spec.rb +17 -0
  317. data/spec/lib/parser/call_spec.rb +165 -0
  318. data/spec/lib/parser/class_spec.rb +35 -0
  319. data/spec/lib/parser/comments_spec.rb +11 -0
  320. data/spec/lib/parser/def_spec.rb +80 -0
  321. data/spec/lib/parser/if_spec.rb +26 -0
  322. data/spec/lib/parser/iter_spec.rb +59 -0
  323. data/spec/lib/parser/lambda_spec.rb +64 -0
  324. data/spec/lib/parser/literal_spec.rb +118 -0
  325. data/spec/lib/parser/masgn_spec.rb +37 -0
  326. data/spec/lib/parser/module_spec.rb +27 -0
  327. data/spec/lib/parser/not_spec.rb +21 -0
  328. data/spec/lib/parser/op_asgn1_spec.rb +23 -0
  329. data/spec/lib/parser/op_asgn2_spec.rb +23 -0
  330. data/spec/lib/parser/or_spec.rb +13 -0
  331. data/spec/lib/parser/return_spec.rb +17 -0
  332. data/spec/lib/parser/sclass_spec.rb +21 -0
  333. data/spec/lib/parser/string_spec.rb +276 -0
  334. data/spec/lib/parser/super_spec.rb +20 -0
  335. data/spec/lib/parser/unary_spec.rb +48 -0
  336. data/spec/lib/parser/undef_spec.rb +15 -0
  337. data/spec/lib/parser/unless_spec.rb +13 -0
  338. data/spec/lib/parser/variables_spec.rb +92 -0
  339. data/spec/lib/parser/while_spec.rb +15 -0
  340. data/spec/lib/parser/yield_spec.rb +20 -0
  341. data/spec/lib/path_reader_spec.rb +36 -0
  342. data/spec/lib/shared/path_finder_shared.rb +19 -0
  343. data/spec/lib/shared/path_reader_shared.rb +31 -0
  344. data/spec/lib/spec_helper.rb +9 -0
  345. data/spec/lib/sprockets/erb_spec.rb +38 -0
  346. data/spec/lib/sprockets/path_reader_spec.rb +41 -0
  347. data/spec/lib/sprockets/processor_spec.rb +67 -0
  348. data/spec/lib/sprockets/server_spec.rb +102 -0
  349. data/spec/lib/tilt/opal_spec.rb +37 -0
  350. data/spec/opal/compiler/irb_spec.rb +44 -0
  351. data/spec/opal/core/array/intersection_spec.rb +38 -0
  352. data/spec/opal/core/array/minus_spec.rb +38 -0
  353. data/spec/opal/core/array/select_spec.rb +14 -0
  354. data/spec/opal/core/array/set_range_to_array_spec.rb +7 -0
  355. data/spec/opal/core/array/union_spec.rb +38 -0
  356. data/spec/opal/core/array/uniq_spec.rb +49 -0
  357. data/spec/opal/core/date_spec.rb +177 -0
  358. data/spec/opal/core/enumerable/all_break_spec.rb +5 -0
  359. data/spec/opal/core/enumerable/any_break_spec.rb +5 -0
  360. data/spec/opal/core/enumerable/collect_break_spec.rb +13 -0
  361. data/spec/opal/core/enumerable/count_break_spec.rb +5 -0
  362. data/spec/opal/core/enumerable/detect_break_spec.rb +5 -0
  363. data/spec/opal/core/enumerable/drop_while_break_spec.rb +5 -0
  364. data/spec/opal/core/enumerable/each_slice_break.rb +6 -0
  365. data/spec/opal/core/enumerable/each_with_index_break_spec.rb +5 -0
  366. data/spec/opal/core/enumerable/each_with_object_break_spec.rb +5 -0
  367. data/spec/opal/core/enumerable/find_all_break_spec.rb +5 -0
  368. data/spec/opal/core/enumerable/find_index_break_spec.rb +5 -0
  369. data/spec/opal/core/enumerable/grep_break_spec.rb +5 -0
  370. data/spec/opal/core/enumerable/max_break_spec.rb +5 -0
  371. data/spec/opal/core/enumerable/max_by_break_spec.rb +5 -0
  372. data/spec/opal/core/enumerable/min_break_spec.rb +5 -0
  373. data/spec/opal/core/enumerable/min_by_break_spec.rb +5 -0
  374. data/spec/opal/core/enumerable/none_break_spec.rb +5 -0
  375. data/spec/opal/core/enumerable/one_break_spec.rb +5 -0
  376. data/spec/opal/core/enumerable/reduce_break_spec.rb +5 -0
  377. data/spec/opal/core/enumerable/take_while_break_spec.rb +5 -0
  378. data/spec/opal/core/exception_spec.rb +13 -0
  379. data/spec/opal/core/fixtures/class.rb +124 -0
  380. data/spec/opal/core/fixtures/class_variables.rb +0 -0
  381. data/spec/opal/core/fixtures/constants.rb +33 -0
  382. data/spec/opal/core/fixtures/require_tree_files/file 1.rb +1 -0
  383. data/spec/opal/core/fixtures/require_tree_files/file 2.rb +1 -0
  384. data/spec/opal/core/fixtures/require_tree_files/file 3.rb +1 -0
  385. data/spec/opal/core/fixtures/require_tree_files/file 4.rb +1 -0
  386. data/spec/opal/core/fixtures/require_tree_files/file 5.rb +1 -0
  387. data/spec/opal/core/fixtures/require_tree_files/nested/nested 1.rb +1 -0
  388. data/spec/opal/core/fixtures/require_tree_files/nested/nested 2.rb +1 -0
  389. data/spec/opal/core/fixtures/require_tree_files/other/other 1.rb +1 -0
  390. data/spec/opal/core/fixtures/require_tree_with_dot/file 1.rb +1 -0
  391. data/spec/opal/core/fixtures/require_tree_with_dot/file 2.rb +1 -0
  392. data/spec/opal/core/fixtures/require_tree_with_dot/file 3.rb +1 -0
  393. data/spec/opal/core/fixtures/require_tree_with_dot/index.rb +3 -0
  394. data/spec/opal/core/hash/has_value_spec.rb +13 -0
  395. data/spec/opal/core/hash/internals_spec.rb +332 -0
  396. data/spec/opal/core/kernel/Array_spec.rb +10 -0
  397. data/spec/opal/core/kernel/block_given_spec.rb +30 -0
  398. data/spec/opal/core/kernel/class_spec.rb +6 -0
  399. data/spec/opal/core/kernel/define_singleton_method_spec.rb +21 -0
  400. data/spec/opal/core/kernel/equal_value_spec.rb +12 -0
  401. data/spec/opal/core/kernel/extend_spec.rb +21 -0
  402. data/spec/opal/core/kernel/format_spec.rb +122 -0
  403. data/spec/opal/core/kernel/freeze_spec.rb +15 -0
  404. data/spec/opal/core/kernel/instance_eval_spec.rb +28 -0
  405. data/spec/opal/core/kernel/instance_variable_defined_spec.rb +15 -0
  406. data/spec/opal/core/kernel/instance_variable_get_spec.rb +14 -0
  407. data/spec/opal/core/kernel/instance_variable_set_spec.rb +10 -0
  408. data/spec/opal/core/kernel/loop_spec.rb +23 -0
  409. data/spec/opal/core/kernel/match_spec.rb +5 -0
  410. data/spec/opal/core/kernel/method_spec.rb +31 -0
  411. data/spec/opal/core/kernel/methods_spec.rb +25 -0
  412. data/spec/opal/core/kernel/nil_spec.rb +7 -0
  413. data/spec/opal/core/kernel/p_spec.rb +15 -0
  414. data/spec/opal/core/kernel/printf_spec.rb +11 -0
  415. data/spec/opal/core/kernel/proc_spec.rb +13 -0
  416. data/spec/opal/core/kernel/rand_spec.rb +23 -0
  417. data/spec/opal/core/kernel/require_tree_spec.rb +18 -0
  418. data/spec/opal/core/kernel/respond_to_spec.rb +41 -0
  419. data/spec/opal/core/kernel/send_spec.rb +56 -0
  420. data/spec/opal/core/kernel/sprintf_spec.rb +5 -0
  421. data/spec/opal/core/language/block_spec.rb +538 -0
  422. data/spec/opal/core/language/fixtures/array.rb +11 -0
  423. data/spec/opal/core/language/fixtures/block.rb +57 -0
  424. data/spec/opal/core/language/fixtures/break.rb +240 -0
  425. data/spec/opal/core/language/fixtures/ensure.rb +72 -0
  426. data/spec/opal/core/language/fixtures/literal_lambda.rb +7 -0
  427. data/spec/opal/core/language/fixtures/metaclass.rb +33 -0
  428. data/spec/opal/core/language/fixtures/module.rb +24 -0
  429. data/spec/opal/core/language/fixtures/next.rb +128 -0
  430. data/spec/opal/core/language/fixtures/return.rb +118 -0
  431. data/spec/opal/core/language/fixtures/send.rb +110 -0
  432. data/spec/opal/core/language/fixtures/send_1.9.rb +22 -0
  433. data/spec/opal/core/language/fixtures/super.rb +308 -0
  434. data/spec/opal/core/language/fixtures/variables.rb +58 -0
  435. data/spec/opal/core/language/fixtures/yield.rb +28 -0
  436. data/spec/opal/core/language/predefined_spec.rb +138 -0
  437. data/spec/opal/core/language/proc_spec.rb +263 -0
  438. data/spec/opal/core/language/regexp_spec.rb +20 -0
  439. data/spec/opal/core/language/send_spec.rb +225 -0
  440. data/spec/opal/core/language/string_spec.rb +44 -0
  441. data/spec/opal/core/language/variables_spec.rb +1366 -0
  442. data/spec/opal/core/language/versions/array_1.9.rb +39 -0
  443. data/spec/opal/core/language/versions/block_1.9.rb +0 -0
  444. data/spec/opal/core/language/versions/break_1.9.rb +0 -0
  445. data/spec/opal/core/language/versions/case_1.9.rb +20 -0
  446. data/spec/opal/core/language/versions/def_2_0_spec.rb +62 -0
  447. data/spec/opal/core/language/versions/hash_1.9.rb +18 -0
  448. data/spec/opal/core/language/versions/literal_lambda_1.9.rb +143 -0
  449. data/spec/opal/core/language/versions/not_1.9.rb +22 -0
  450. data/spec/opal/core/language/versions/send_1.9.rb +241 -0
  451. data/spec/opal/core/language/versions/symbol_1.9.rb +15 -0
  452. data/spec/opal/core/language/versions/variables_1.9.rb +8 -0
  453. data/spec/opal/core/language_spec.rb +23 -0
  454. data/spec/opal/core/method/to_proc_spec.rb +28 -0
  455. data/spec/opal/core/module/alias_method_spec.rb +28 -0
  456. data/spec/opal/core/module/ancestors_spec.rb +11 -0
  457. data/spec/opal/core/module/append_features_spec.rb +14 -0
  458. data/spec/opal/core/module/attr_accessor_spec.rb +26 -0
  459. data/spec/opal/core/module/const_defined_spec.rb +85 -0
  460. data/spec/opal/core/module/const_get_spec.rb +85 -0
  461. data/spec/opal/core/module/const_missing_spec.rb +17 -0
  462. data/spec/opal/core/module/const_set_spec.rb +64 -0
  463. data/spec/opal/core/module/constants_spec.rb +49 -0
  464. data/spec/opal/core/module/fixtures/classes.rb +434 -0
  465. data/spec/opal/core/module/method_defined_spec.rb +48 -0
  466. data/spec/opal/core/module/module_function_spec.rb +25 -0
  467. data/spec/opal/core/module/name_spec.rb +52 -0
  468. data/spec/opal/core/module/public_method_defined_spec.rb +18 -0
  469. data/spec/opal/core/module/remove_const_spec.rb +22 -0
  470. data/spec/opal/core/module/undef_method_spec.rb +66 -0
  471. data/spec/opal/core/numeric/bit_and_spec.rb +7 -0
  472. data/spec/opal/core/numeric/bit_or_spec.rb +8 -0
  473. data/spec/opal/core/numeric/bit_xor_spec.rb +6 -0
  474. data/spec/opal/core/numeric/ceil_spec.rb +8 -0
  475. data/spec/opal/core/numeric/chr_spec.rb +8 -0
  476. data/spec/opal/core/numeric/comparison_spec.rb +24 -0
  477. data/spec/opal/core/numeric/complement_spec.rb +8 -0
  478. data/spec/opal/core/numeric/divide_spec.rb +10 -0
  479. data/spec/opal/core/numeric/eql_spec.rb +9 -0
  480. data/spec/opal/core/numeric/exponent_spec.rb +33 -0
  481. data/spec/opal/core/numeric/floor_spec.rb +8 -0
  482. data/spec/opal/core/numeric/gt_spec.rb +11 -0
  483. data/spec/opal/core/numeric/gte_spec.rb +12 -0
  484. data/spec/opal/core/numeric/integer_spec.rb +9 -0
  485. data/spec/opal/core/numeric/left_shift_spec.rb +21 -0
  486. data/spec/opal/core/numeric/lt_spec.rb +11 -0
  487. data/spec/opal/core/numeric/lte_spec.rb +12 -0
  488. data/spec/opal/core/numeric/minus_spec.rb +8 -0
  489. data/spec/opal/core/numeric/modulo_spec.rb +19 -0
  490. data/spec/opal/core/numeric/multiply_spec.rb +9 -0
  491. data/spec/opal/core/numeric/next_spec.rb +9 -0
  492. data/spec/opal/core/numeric/ord_spec.rb +9 -0
  493. data/spec/opal/core/numeric/plus_spec.rb +8 -0
  494. data/spec/opal/core/numeric/pred_spec.rb +7 -0
  495. data/spec/opal/core/numeric/right_shift_spec.rb +25 -0
  496. data/spec/opal/core/numeric/step_spec.rb +11 -0
  497. data/spec/opal/core/numeric/succ_spec.rb +9 -0
  498. data/spec/opal/core/numeric/times_spec.rb +36 -0
  499. data/spec/opal/core/numeric/to_f_spec.rb +7 -0
  500. data/spec/opal/core/numeric/to_i_spec.rb +7 -0
  501. data/spec/opal/core/numeric/to_json_spec.rb +8 -0
  502. data/spec/opal/core/numeric/to_s_spec.rb +26 -0
  503. data/spec/opal/core/numeric/uminus_spec.rb +9 -0
  504. data/spec/opal/core/numeric/upto_spec.rb +19 -0
  505. data/spec/opal/core/numeric/zero_spec.rb +7 -0
  506. data/spec/opal/core/object_id_spec.rb +56 -0
  507. data/spec/opal/core/proc/call_spec.rb +21 -0
  508. data/spec/opal/core/proc/element_reference_spec.rb +21 -0
  509. data/spec/opal/core/proc/proc_tricks_spec.rb +7 -0
  510. data/spec/opal/core/runtime/begin_spec.rb +39 -0
  511. data/spec/opal/core/runtime/block_send_spec.rb +28 -0
  512. data/spec/opal/core/runtime/block_spec.rb +23 -0
  513. data/spec/opal/core/runtime/bridged_classes_spec.rb +111 -0
  514. data/spec/opal/core/runtime/constants_spec.rb +13 -0
  515. data/spec/opal/core/runtime/donate_spec.rb +53 -0
  516. data/spec/opal/core/runtime/eval_spec.rb +5 -0
  517. data/spec/opal/core/runtime/main_methods_spec.rb +27 -0
  518. data/spec/opal/core/runtime/method_missing_spec.rb +62 -0
  519. data/spec/opal/core/runtime/method_spec.rb +31 -0
  520. data/spec/opal/core/runtime/operator_call_spec.rb +13 -0
  521. data/spec/opal/core/runtime/paren_spec.rb +14 -0
  522. data/spec/opal/core/runtime/rescue_spec.rb +38 -0
  523. data/spec/opal/core/runtime/return_spec.rb +38 -0
  524. data/spec/opal/core/runtime/send_spec.rb +34 -0
  525. data/spec/opal/core/runtime/singleton_class_spec.rb +13 -0
  526. data/spec/opal/core/runtime/super_spec.rb +212 -0
  527. data/spec/opal/core/runtime/truthy_spec.rb +23 -0
  528. data/spec/opal/core/runtime/variables_spec.rb +20 -0
  529. data/spec/opal/core/runtime_spec.rb +58 -0
  530. data/spec/opal/core/source_map_spec.rb +15 -0
  531. data/spec/opal/core/string_spec.rb +11 -0
  532. data/spec/opal/stdlib/erb/erb_spec.rb +30 -0
  533. data/spec/opal/stdlib/erb/inline_block.opalerb +3 -0
  534. data/spec/opal/stdlib/erb/quoted.opalerb +1 -0
  535. data/spec/opal/stdlib/erb/simple.opalerb +1 -0
  536. data/spec/opal/stdlib/js_spec.rb +66 -0
  537. data/spec/opal/stdlib/json/ext_spec.rb +48 -0
  538. data/spec/opal/stdlib/json/parse_spec.rb +33 -0
  539. data/spec/opal/stdlib/native/alias_native_spec.rb +27 -0
  540. data/spec/opal/stdlib/native/each_spec.rb +13 -0
  541. data/spec/opal/stdlib/native/element_reference_spec.rb +16 -0
  542. data/spec/opal/stdlib/native/exposure_spec.rb +33 -0
  543. data/spec/opal/stdlib/native/ext_spec.rb +19 -0
  544. data/spec/opal/stdlib/native/initialize_spec.rb +17 -0
  545. data/spec/opal/stdlib/native/method_missing_spec.rb +51 -0
  546. data/spec/opal/stdlib/native/native_alias_spec.rb +19 -0
  547. data/spec/opal/stdlib/native/native_class_spec.rb +18 -0
  548. data/spec/opal/stdlib/native/native_module_spec.rb +13 -0
  549. data/spec/opal/stdlib/native/native_reader_spec.rb +22 -0
  550. data/spec/opal/stdlib/native/native_writer_spec.rb +30 -0
  551. data/spec/opal/stdlib/native/new_spec.rb +8 -0
  552. data/spec/opal/stdlib/promise/always_spec.rb +30 -0
  553. data/spec/opal/stdlib/promise/error_spec.rb +15 -0
  554. data/spec/opal/stdlib/promise/rescue_spec.rb +44 -0
  555. data/spec/opal/stdlib/promise/then_spec.rb +71 -0
  556. data/spec/opal/stdlib/promise/trace_spec.rb +52 -0
  557. data/spec/opal/stdlib/promise/value_spec.rb +15 -0
  558. data/spec/opal/stdlib/promise/when_spec.rb +34 -0
  559. data/spec/opal/stdlib/template/paths_spec.rb +10 -0
  560. data/spec/opal/stdlib/thread/mutex_spec.rb +40 -0
  561. data/spec/opal/stdlib/thread/thread_queue_spec.rb +32 -0
  562. data/spec/opal/stdlib/thread/thread_spec.rb +60 -0
  563. data/spec/rubyspecs +144 -0
  564. data/spec/spec_helper.rb +53 -0
  565. data/spec/support/mspec_rspec_adapter.rb +33 -0
  566. data/spec/support/parser_helpers.rb +37 -0
  567. data/stdlib/README.md +3 -0
  568. data/stdlib/base64.rb +152 -0
  569. data/stdlib/benchmark.rb +557 -0
  570. data/stdlib/buffer.rb +41 -0
  571. data/stdlib/buffer/array.rb +66 -0
  572. data/stdlib/buffer/view.rb +70 -0
  573. data/stdlib/date.rb +248 -0
  574. data/stdlib/delegate.rb +29 -0
  575. data/stdlib/dir.rb +1 -0
  576. data/stdlib/encoding.rb +170 -0
  577. data/stdlib/enumerator.rb +1 -0
  578. data/stdlib/erb.rb +16 -0
  579. data/stdlib/file.rb +1 -0
  580. data/stdlib/fileutils.rb +0 -0
  581. data/stdlib/forwardable.rb +71 -0
  582. data/stdlib/iconv.rb +0 -0
  583. data/stdlib/js.rb +56 -0
  584. data/stdlib/json.rb +190 -0
  585. data/stdlib/math.rb +370 -0
  586. data/stdlib/native.rb +530 -0
  587. data/stdlib/nodejs.rb +7 -0
  588. data/stdlib/nodejs/dir.rb +13 -0
  589. data/stdlib/nodejs/file.rb +98 -0
  590. data/stdlib/nodejs/fileutils.rb +26 -0
  591. data/stdlib/nodejs/io.rb +2 -0
  592. data/stdlib/nodejs/irb.rb +45 -0
  593. data/stdlib/nodejs/kernel.rb +33 -0
  594. data/stdlib/nodejs/node_modules/.bin/js-yaml +140 -0
  595. data/stdlib/nodejs/node_modules/glob/LICENSE +15 -0
  596. data/stdlib/nodejs/node_modules/glob/README.md +357 -0
  597. data/stdlib/nodejs/node_modules/glob/common.js +177 -0
  598. data/stdlib/nodejs/node_modules/glob/glob.js +649 -0
  599. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/.eslintrc +17 -0
  600. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/LICENSE +15 -0
  601. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/README.md +37 -0
  602. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/inflight.js +44 -0
  603. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE +15 -0
  604. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md +36 -0
  605. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +52 -0
  606. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js +51 -0
  607. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js +33 -0
  608. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/package.json +61 -0
  609. data/stdlib/nodejs/node_modules/glob/node_modules/inflight/test.js +97 -0
  610. data/stdlib/nodejs/node_modules/glob/node_modules/inherits/LICENSE +16 -0
  611. data/stdlib/nodejs/node_modules/glob/node_modules/inherits/README.md +42 -0
  612. data/stdlib/nodejs/node_modules/glob/node_modules/inherits/inherits.js +1 -0
  613. data/stdlib/nodejs/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
  614. data/stdlib/nodejs/node_modules/glob/node_modules/inherits/package.json +51 -0
  615. data/stdlib/nodejs/node_modules/glob/node_modules/inherits/test.js +25 -0
  616. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/.npmignore +1 -0
  617. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/.travis.yml +4 -0
  618. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/LICENSE +23 -0
  619. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/README.md +216 -0
  620. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/benchmark.js +15 -0
  621. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/browser.js +1181 -0
  622. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/minimatch.js +845 -0
  623. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +2 -0
  624. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml +3 -0
  625. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +121 -0
  626. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +8 -0
  627. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +191 -0
  628. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +2 -0
  629. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml +4 -0
  630. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +6 -0
  631. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +80 -0
  632. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +5 -0
  633. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +38 -0
  634. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +73 -0
  635. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +56 -0
  636. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml +4 -0
  637. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +18 -0
  638. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +62 -0
  639. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +6 -0
  640. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +13 -0
  641. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +83 -0
  642. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +39 -0
  643. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +75 -0
  644. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js +32 -0
  645. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt +1075 -0
  646. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/cases.txt +182 -0
  647. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/dollar.js +9 -0
  648. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/empty-option.js +10 -0
  649. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/generate.sh +24 -0
  650. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/negative-increment.js +15 -0
  651. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/nested.js +16 -0
  652. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/order.js +10 -0
  653. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/pad.js +13 -0
  654. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/same-type.js +7 -0
  655. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/sequence.js +50 -0
  656. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/package.json +60 -0
  657. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/basic.js +399 -0
  658. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/brace-expand.js +45 -0
  659. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/defaults.js +274 -0
  660. data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
  661. data/stdlib/nodejs/node_modules/glob/node_modules/once/LICENSE +27 -0
  662. data/stdlib/nodejs/node_modules/glob/node_modules/once/README.md +51 -0
  663. data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE +15 -0
  664. data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +36 -0
  665. data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +52 -0
  666. data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +51 -0
  667. data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +33 -0
  668. data/stdlib/nodejs/node_modules/glob/node_modules/once/once.js +21 -0
  669. data/stdlib/nodejs/node_modules/glob/node_modules/once/package.json +60 -0
  670. data/stdlib/nodejs/node_modules/glob/node_modules/once/test/once.js +23 -0
  671. data/stdlib/nodejs/node_modules/glob/package.json +72 -0
  672. data/stdlib/nodejs/node_modules/glob/sync.js +409 -0
  673. data/stdlib/nodejs/node_modules/js-yaml/HISTORY.md +277 -0
  674. data/stdlib/nodejs/node_modules/js-yaml/LICENSE +21 -0
  675. data/stdlib/nodejs/node_modules/js-yaml/README.md +288 -0
  676. data/stdlib/nodejs/node_modules/js-yaml/bin/js-yaml.js +140 -0
  677. data/stdlib/nodejs/node_modules/js-yaml/bower.json +23 -0
  678. data/stdlib/nodejs/node_modules/js-yaml/dist/js-yaml.js +3666 -0
  679. data/stdlib/nodejs/node_modules/js-yaml/dist/js-yaml.min.js +3 -0
  680. data/stdlib/nodejs/node_modules/js-yaml/examples/custom_types.js +102 -0
  681. data/stdlib/nodejs/node_modules/js-yaml/examples/custom_types.yml +18 -0
  682. data/stdlib/nodejs/node_modules/js-yaml/examples/dumper.js +31 -0
  683. data/stdlib/nodejs/node_modules/js-yaml/examples/dumper.json +22 -0
  684. data/stdlib/nodejs/node_modules/js-yaml/examples/sample_document.js +18 -0
  685. data/stdlib/nodejs/node_modules/js-yaml/examples/sample_document.yml +197 -0
  686. data/stdlib/nodejs/node_modules/js-yaml/index.js +7 -0
  687. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml.js +39 -0
  688. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js +62 -0
  689. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/dumper.js +554 -0
  690. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/exception.js +25 -0
  691. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/loader.js +1581 -0
  692. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/mark.js +78 -0
  693. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema.js +103 -0
  694. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
  695. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
  696. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
  697. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
  698. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
  699. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
  700. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/binary.js +133 -0
  701. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/bool.js +37 -0
  702. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/float.js +110 -0
  703. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/int.js +183 -0
  704. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/function.js +85 -0
  705. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +84 -0
  706. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +27 -0
  707. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
  708. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
  709. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/null.js +36 -0
  710. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js +56 -0
  711. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/pairs.js +61 -0
  712. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
  713. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/set.js +33 -0
  714. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
  715. data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +98 -0
  716. data/stdlib/nodejs/node_modules/js-yaml/node_modules/.bin/esparse +117 -0
  717. data/stdlib/nodejs/node_modules/js-yaml/node_modules/.bin/esvalidate +177 -0
  718. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/HISTORY.md +115 -0
  719. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/LICENSE +21 -0
  720. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/README.md +239 -0
  721. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/arguments.js +36 -0
  722. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/choice.js +22 -0
  723. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/constants.js +59 -0
  724. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/help.js +13 -0
  725. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/nargs.js +33 -0
  726. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/parents.js +28 -0
  727. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/prefix_chars.js +23 -0
  728. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/sub_commands.js +49 -0
  729. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/sum.js +35 -0
  730. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/testformatters.js +270 -0
  731. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/index.js +1 -0
  732. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action.js +146 -0
  733. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/append.js +55 -0
  734. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/append/constant.js +47 -0
  735. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/count.js +40 -0
  736. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/help.js +48 -0
  737. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store.js +50 -0
  738. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/constant.js +43 -0
  739. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/false.js +27 -0
  740. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/true.js +26 -0
  741. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/subparsers.js +148 -0
  742. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/version.js +50 -0
  743. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action_container.js +481 -0
  744. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argparse.js +14 -0
  745. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/error.js +50 -0
  746. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/exclusive.js +54 -0
  747. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/group.js +75 -0
  748. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument_parser.js +1168 -0
  749. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/const.js +18 -0
  750. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/help/added_formatters.js +88 -0
  751. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/help/formatter.js +798 -0
  752. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/namespace.js +77 -0
  753. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.npmignore +2 -0
  754. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.travis.yml +8 -0
  755. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/README.markdown +825 -0
  756. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/bower.json +33 -0
  757. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/component.json +11 -0
  758. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/foo.js +10 -0
  759. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/gulpfile.js +26 -0
  760. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/lib/underscore.string.js +673 -0
  761. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/libpeerconnection.log +0 -0
  762. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/package.json +107 -0
  763. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/LICENSE +23 -0
  764. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/README.md +22 -0
  765. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/package.json +69 -0
  766. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore-min.js +6 -0
  767. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore.js +1415 -0
  768. data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/package.json +62 -0
  769. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/README.md +73 -0
  770. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/bin/esparse.js +117 -0
  771. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/bin/esvalidate.js +177 -0
  772. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/esprima.js +3908 -0
  773. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/package.json +69 -0
  774. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/compat.js +239 -0
  775. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/reflect.js +422 -0
  776. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/run.js +66 -0
  777. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/runner.js +387 -0
  778. data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/test.js +20238 -0
  779. data/stdlib/nodejs/node_modules/js-yaml/package.json +83 -0
  780. data/stdlib/nodejs/package.json +6 -0
  781. data/stdlib/nodejs/require.rb +30 -0
  782. data/stdlib/nodejs/rubygems.rb +68 -0
  783. data/stdlib/nodejs/yaml.rb +11 -0
  784. data/stdlib/observer.rb +202 -0
  785. data/stdlib/opal-parser.rb +54 -0
  786. data/stdlib/opal-source-maps.rb +2 -0
  787. data/stdlib/ostruct.rb +69 -0
  788. data/stdlib/pathname.rb +55 -0
  789. data/stdlib/phantomjs.rb +3 -0
  790. data/stdlib/pp.rb +35 -0
  791. data/stdlib/promise.rb +427 -0
  792. data/stdlib/racc/parser.rb +215 -0
  793. data/stdlib/rbconfig.rb +18 -0
  794. data/stdlib/securerandom.rb +12 -0
  795. data/stdlib/set.rb +170 -0
  796. data/stdlib/singleton.rb +40 -0
  797. data/stdlib/source_map.rb +5 -0
  798. data/stdlib/source_map/map.rb +220 -0
  799. data/stdlib/source_map/mapping.rb +26 -0
  800. data/stdlib/source_map/offset.rb +88 -0
  801. data/stdlib/source_map/version.rb +3 -0
  802. data/stdlib/source_map/vlq.rb +98 -0
  803. data/stdlib/sourcemap.rb +1 -0
  804. data/stdlib/stringio.rb +181 -0
  805. data/stdlib/strscan.rb +166 -0
  806. data/stdlib/template.rb +46 -0
  807. data/stdlib/thread.rb +164 -0
  808. data/stdlib/time.rb +9 -0
  809. data/stdlib/yaml.rb +1 -0
  810. data/tasks/benchmarking.rake +88 -0
  811. data/tasks/building.rake +58 -0
  812. data/tasks/documenting.rake +37 -0
  813. data/tasks/github.rake +19 -0
  814. data/tasks/linting.rake +18 -0
  815. data/tasks/testing.rake +125 -0
  816. data/vendored-minitest/minitest.rb +780 -0
  817. data/vendored-minitest/minitest/assertions.rb +662 -0
  818. data/vendored-minitest/minitest/autorun.rb +12 -0
  819. data/vendored-minitest/minitest/benchmark.rb +426 -0
  820. data/vendored-minitest/minitest/expectations.rb +281 -0
  821. data/vendored-minitest/minitest/hell.rb +11 -0
  822. data/vendored-minitest/minitest/mock.rb +220 -0
  823. data/vendored-minitest/minitest/parallel.rb +65 -0
  824. data/vendored-minitest/minitest/pride.rb +4 -0
  825. data/vendored-minitest/minitest/pride_plugin.rb +142 -0
  826. data/vendored-minitest/minitest/spec.rb +310 -0
  827. data/vendored-minitest/minitest/test.rb +293 -0
  828. data/vendored-minitest/minitest/unit.rb +45 -0
  829. data/vendored-minitest/test/unit.rb +28 -0
  830. metadata +1058 -0
@@ -0,0 +1,107 @@
1
+ {
2
+ "name": "underscore.string",
3
+ "version": "2.4.0",
4
+ "description": "String manipulation extensions for Underscore.js javascript library.",
5
+ "homepage": "http://epeli.github.com/underscore.string/",
6
+ "contributors": [
7
+ {
8
+ "name": "Esa-Matti Suuronen",
9
+ "email": "esa-matti@suuronen.org",
10
+ "url": "http://esa-matti.suuronen.org/"
11
+ },
12
+ {
13
+ "name": "Edward Tsech",
14
+ "email": "edtsech@gmail.com"
15
+ },
16
+ {
17
+ "name": "Pavel Pravosud",
18
+ "email": "pavel@pravosud.com",
19
+ "url": "<https://github.com/rwz>"
20
+ },
21
+ {
22
+ "name": "Sasha Koss",
23
+ "email": "kossnocorp@gmail.com",
24
+ "url": "http://koss.nocorp.me/"
25
+ },
26
+ {
27
+ "name": "Vladimir Dronnikov",
28
+ "email": "dronnikov@gmail.com"
29
+ },
30
+ {
31
+ "name": "Pete Kruckenberg",
32
+ "email": "https://github.com/kruckenb",
33
+ "url": "<https://github.com/kruckenb>"
34
+ },
35
+ {
36
+ "name": "Paul Chavard",
37
+ "email": "paul@chavard.net",
38
+ "url": "<http://tchak.net>"
39
+ },
40
+ {
41
+ "name": "Ed Finkler",
42
+ "email": "coj@funkatron.com",
43
+ "url": "<http://funkatron.com>"
44
+ }
45
+ ],
46
+ "keywords": [
47
+ "underscore",
48
+ "string"
49
+ ],
50
+ "main": "./lib/underscore.string.js",
51
+ "directories": {
52
+ "lib": "./lib"
53
+ },
54
+ "engines": {
55
+ "node": "*"
56
+ },
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "https://github.com/epeli/underscore.string.git"
60
+ },
61
+ "bugs": {
62
+ "url": "https://github.com/epeli/underscore.string/issues"
63
+ },
64
+ "licenses": [
65
+ {
66
+ "type": "MIT"
67
+ }
68
+ ],
69
+ "scripts": {
70
+ "test": "gulp test"
71
+ },
72
+ "devDependencies": {
73
+ "gulp": "~3.8.10",
74
+ "gulp-uglify": "~1.0.1",
75
+ "gulp-qunit": "~1.0.0",
76
+ "gulp-clean": "~0.3.1",
77
+ "gulp-rename": "~1.2.0"
78
+ },
79
+ "_id": "underscore.string@2.4.0",
80
+ "dist": {
81
+ "shasum": "8cdd8fbac4e2d2ea1e7e2e8097c42f442280f85b",
82
+ "tarball": "http://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz"
83
+ },
84
+ "_from": "underscore.string@>=2.4.0 <2.5.0",
85
+ "_npmVersion": "1.3.24",
86
+ "_npmUser": {
87
+ "name": "epeli",
88
+ "email": "esa-matti@suuronen.org"
89
+ },
90
+ "maintainers": [
91
+ {
92
+ "name": "edtsech",
93
+ "email": "edtsech@gmail.com"
94
+ },
95
+ {
96
+ "name": "rwz",
97
+ "email": "rwz@duckroll.ru"
98
+ },
99
+ {
100
+ "name": "epeli",
101
+ "email": "esa-matti@suuronen.org"
102
+ }
103
+ ],
104
+ "_shasum": "8cdd8fbac4e2d2ea1e7e2e8097c42f442280f85b",
105
+ "_resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz",
106
+ "readme": "ERROR: No README data found!"
107
+ }
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative
2
+ Reporters & Editors
3
+
4
+ Permission is hereby granted, free of charge, to any person
5
+ obtaining a copy of this software and associated documentation
6
+ files (the "Software"), to deal in the Software without
7
+ restriction, including without limitation the rights to use,
8
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the
10
+ Software is furnished to do so, subject to the following
11
+ conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ __
2
+ /\ \ __
3
+ __ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
4
+ /\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
5
+ \ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
6
+ \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
7
+ \/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
8
+ \ \____/
9
+ \/___/
10
+
11
+ Underscore.js is a utility-belt library for JavaScript that provides
12
+ support for the usual functional suspects (each, map, reduce, filter...)
13
+ without extending any core JavaScript objects.
14
+
15
+ For Docs, License, Tests, and pre-packed downloads, see:
16
+ http://underscorejs.org
17
+
18
+ Underscore is an open-sourced component of DocumentCloud:
19
+ https://github.com/documentcloud
20
+
21
+ Many thanks to our contributors:
22
+ https://github.com/jashkenas/underscore/contributors
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "underscore",
3
+ "description": "JavaScript's functional programming helper library.",
4
+ "homepage": "http://underscorejs.org",
5
+ "keywords": [
6
+ "util",
7
+ "functional",
8
+ "server",
9
+ "client",
10
+ "browser"
11
+ ],
12
+ "author": {
13
+ "name": "Jeremy Ashkenas",
14
+ "email": "jeremy@documentcloud.org"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git://github.com/jashkenas/underscore.git"
19
+ },
20
+ "main": "underscore.js",
21
+ "version": "1.7.0",
22
+ "devDependencies": {
23
+ "docco": "0.6.x",
24
+ "phantomjs": "1.9.7-1",
25
+ "uglify-js": "2.4.x",
26
+ "eslint": "0.6.x"
27
+ },
28
+ "scripts": {
29
+ "test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true && eslint underscore.js test/*.js test/vendor/runner.js",
30
+ "build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js",
31
+ "doc": "docco underscore.js"
32
+ },
33
+ "licenses": [
34
+ {
35
+ "type": "MIT",
36
+ "url": "https://raw.github.com/jashkenas/underscore/master/LICENSE"
37
+ }
38
+ ],
39
+ "files": [
40
+ "underscore.js",
41
+ "underscore-min.js",
42
+ "LICENSE"
43
+ ],
44
+ "gitHead": "da996e665deb0b69b257e80e3e257c04fde4191c",
45
+ "bugs": {
46
+ "url": "https://github.com/jashkenas/underscore/issues"
47
+ },
48
+ "_id": "underscore@1.7.0",
49
+ "_shasum": "6bbaf0877500d36be34ecaa584e0db9fef035209",
50
+ "_from": "underscore@>=1.7.0 <1.8.0",
51
+ "_npmVersion": "1.4.24",
52
+ "_npmUser": {
53
+ "name": "jashkenas",
54
+ "email": "jashkenas@gmail.com"
55
+ },
56
+ "maintainers": [
57
+ {
58
+ "name": "jashkenas",
59
+ "email": "jashkenas@gmail.com"
60
+ }
61
+ ],
62
+ "dist": {
63
+ "shasum": "6bbaf0877500d36be34ecaa584e0db9fef035209",
64
+ "tarball": "http://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz"
65
+ },
66
+ "directories": {},
67
+ "_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz",
68
+ "readme": "ERROR: No README data found!"
69
+ }
@@ -0,0 +1,6 @@
1
+ // Underscore.js 1.7.0
2
+ // http://underscorejs.org
3
+ // (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
4
+ // Underscore may be freely distributed under the MIT license.
5
+ (function(){var n=this,t=n._,r=Array.prototype,e=Object.prototype,u=Function.prototype,i=r.push,a=r.slice,o=r.concat,l=e.toString,c=e.hasOwnProperty,f=Array.isArray,s=Object.keys,p=u.bind,h=function(n){return n instanceof h?n:this instanceof h?void(this._wrapped=n):new h(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=h),exports._=h):n._=h,h.VERSION="1.7.0";var g=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}};h.iteratee=function(n,t,r){return null==n?h.identity:h.isFunction(n)?g(n,t,r):h.isObject(n)?h.matches(n):h.property(n)},h.each=h.forEach=function(n,t,r){if(null==n)return n;t=g(t,r);var e,u=n.length;if(u===+u)for(e=0;u>e;e++)t(n[e],e,n);else{var i=h.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},h.map=h.collect=function(n,t,r){if(null==n)return[];t=h.iteratee(t,r);for(var e,u=n.length!==+n.length&&h.keys(n),i=(u||n).length,a=Array(i),o=0;i>o;o++)e=u?u[o]:o,a[o]=t(n[e],e,n);return a};var v="Reduce of empty array with no initial value";h.reduce=h.foldl=h.inject=function(n,t,r,e){null==n&&(n=[]),t=g(t,e,4);var u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length,o=0;if(arguments.length<3){if(!a)throw new TypeError(v);r=n[i?i[o++]:o++]}for(;a>o;o++)u=i?i[o]:o,r=t(r,n[u],u,n);return r},h.reduceRight=h.foldr=function(n,t,r,e){null==n&&(n=[]),t=g(t,e,4);var u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length;if(arguments.length<3){if(!a)throw new TypeError(v);r=n[i?i[--a]:--a]}for(;a--;)u=i?i[a]:a,r=t(r,n[u],u,n);return r},h.find=h.detect=function(n,t,r){var e;return t=h.iteratee(t,r),h.some(n,function(n,r,u){return t(n,r,u)?(e=n,!0):void 0}),e},h.filter=h.select=function(n,t,r){var e=[];return null==n?e:(t=h.iteratee(t,r),h.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e)},h.reject=function(n,t,r){return h.filter(n,h.negate(h.iteratee(t)),r)},h.every=h.all=function(n,t,r){if(null==n)return!0;t=h.iteratee(t,r);var e,u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length;for(e=0;a>e;e++)if(u=i?i[e]:e,!t(n[u],u,n))return!1;return!0},h.some=h.any=function(n,t,r){if(null==n)return!1;t=h.iteratee(t,r);var e,u,i=n.length!==+n.length&&h.keys(n),a=(i||n).length;for(e=0;a>e;e++)if(u=i?i[e]:e,t(n[u],u,n))return!0;return!1},h.contains=h.include=function(n,t){return null==n?!1:(n.length!==+n.length&&(n=h.values(n)),h.indexOf(n,t)>=0)},h.invoke=function(n,t){var r=a.call(arguments,2),e=h.isFunction(t);return h.map(n,function(n){return(e?t:n[t]).apply(n,r)})},h.pluck=function(n,t){return h.map(n,h.property(t))},h.where=function(n,t){return h.filter(n,h.matches(t))},h.findWhere=function(n,t){return h.find(n,h.matches(t))},h.max=function(n,t,r){var e,u,i=-1/0,a=-1/0;if(null==t&&null!=n){n=n.length===+n.length?n:h.values(n);for(var o=0,l=n.length;l>o;o++)e=n[o],e>i&&(i=e)}else t=h.iteratee(t,r),h.each(n,function(n,r,e){u=t(n,r,e),(u>a||u===-1/0&&i===-1/0)&&(i=n,a=u)});return i},h.min=function(n,t,r){var e,u,i=1/0,a=1/0;if(null==t&&null!=n){n=n.length===+n.length?n:h.values(n);for(var o=0,l=n.length;l>o;o++)e=n[o],i>e&&(i=e)}else t=h.iteratee(t,r),h.each(n,function(n,r,e){u=t(n,r,e),(a>u||1/0===u&&1/0===i)&&(i=n,a=u)});return i},h.shuffle=function(n){for(var t,r=n&&n.length===+n.length?n:h.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=h.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},h.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=h.values(n)),n[h.random(n.length-1)]):h.shuffle(n).slice(0,Math.max(0,t))},h.sortBy=function(n,t,r){return t=h.iteratee(t,r),h.pluck(h.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var m=function(n){return function(t,r,e){var u={};return r=h.iteratee(r,e),h.each(t,function(e,i){var a=r(e,i,t);n(u,e,a)}),u}};h.groupBy=m(function(n,t,r){h.has(n,r)?n[r].push(t):n[r]=[t]}),h.indexBy=m(function(n,t,r){n[r]=t}),h.countBy=m(function(n,t,r){h.has(n,r)?n[r]++:n[r]=1}),h.sortedIndex=function(n,t,r,e){r=h.iteratee(r,e,1);for(var u=r(t),i=0,a=n.length;a>i;){var o=i+a>>>1;r(n[o])<u?i=o+1:a=o}return i},h.toArray=function(n){return n?h.isArray(n)?a.call(n):n.length===+n.length?h.map(n,h.identity):h.values(n):[]},h.size=function(n){return null==n?0:n.length===+n.length?n.length:h.keys(n).length},h.partition=function(n,t,r){t=h.iteratee(t,r);var e=[],u=[];return h.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},h.first=h.head=h.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:0>t?[]:a.call(n,0,t)},h.initial=function(n,t,r){return a.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},h.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:a.call(n,Math.max(n.length-t,0))},h.rest=h.tail=h.drop=function(n,t,r){return a.call(n,null==t||r?1:t)},h.compact=function(n){return h.filter(n,h.identity)};var y=function(n,t,r,e){if(t&&h.every(n,h.isArray))return o.apply(e,n);for(var u=0,a=n.length;a>u;u++){var l=n[u];h.isArray(l)||h.isArguments(l)?t?i.apply(e,l):y(l,t,r,e):r||e.push(l)}return e};h.flatten=function(n,t){return y(n,t,!1,[])},h.without=function(n){return h.difference(n,a.call(arguments,1))},h.uniq=h.unique=function(n,t,r,e){if(null==n)return[];h.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=h.iteratee(r,e));for(var u=[],i=[],a=0,o=n.length;o>a;a++){var l=n[a];if(t)a&&i===l||u.push(l),i=l;else if(r){var c=r(l,a,n);h.indexOf(i,c)<0&&(i.push(c),u.push(l))}else h.indexOf(u,l)<0&&u.push(l)}return u},h.union=function(){return h.uniq(y(arguments,!0,!0,[]))},h.intersection=function(n){if(null==n)return[];for(var t=[],r=arguments.length,e=0,u=n.length;u>e;e++){var i=n[e];if(!h.contains(t,i)){for(var a=1;r>a&&h.contains(arguments[a],i);a++);a===r&&t.push(i)}}return t},h.difference=function(n){var t=y(a.call(arguments,1),!0,!0,[]);return h.filter(n,function(n){return!h.contains(t,n)})},h.zip=function(n){if(null==n)return[];for(var t=h.max(arguments,"length").length,r=Array(t),e=0;t>e;e++)r[e]=h.pluck(arguments,e);return r},h.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},h.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=h.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}for(;u>e;e++)if(n[e]===t)return e;return-1},h.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=n.length;for("number"==typeof r&&(e=0>r?e+r+1:Math.min(e,r+1));--e>=0;)if(n[e]===t)return e;return-1},h.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=r||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),i=0;e>i;i++,n+=r)u[i]=n;return u};var d=function(){};h.bind=function(n,t){var r,e;if(p&&n.bind===p)return p.apply(n,a.call(arguments,1));if(!h.isFunction(n))throw new TypeError("Bind must be called on a function");return r=a.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(a.call(arguments)));d.prototype=n.prototype;var u=new d;d.prototype=null;var i=n.apply(u,r.concat(a.call(arguments)));return h.isObject(i)?i:u}},h.partial=function(n){var t=a.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===h&&(e[u]=arguments[r++]);for(;r<arguments.length;)e.push(arguments[r++]);return n.apply(this,e)}},h.bindAll=function(n){var t,r,e=arguments.length;if(1>=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=h.bind(n[r],n);return n},h.memoize=function(n,t){var r=function(e){var u=r.cache,i=t?t.apply(this,arguments):e;return h.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},h.delay=function(n,t){var r=a.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},h.defer=function(n){return h.delay.apply(h,[n,1].concat(a.call(arguments,1)))},h.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var l=function(){o=r.leading===!1?0:h.now(),a=null,i=n.apply(e,u),a||(e=u=null)};return function(){var c=h.now();o||r.leading!==!1||(o=c);var f=t-(c-o);return e=this,u=arguments,0>=f||f>t?(clearTimeout(a),a=null,o=c,i=n.apply(e,u),a||(e=u=null)):a||r.trailing===!1||(a=setTimeout(l,f)),i}},h.debounce=function(n,t,r){var e,u,i,a,o,l=function(){var c=h.now()-a;t>c&&c>0?e=setTimeout(l,t-c):(e=null,r||(o=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,a=h.now();var c=r&&!e;return e||(e=setTimeout(l,t)),c&&(o=n.apply(i,u),i=u=null),o}},h.wrap=function(n,t){return h.partial(t,n)},h.negate=function(n){return function(){return!n.apply(this,arguments)}},h.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},h.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},h.before=function(n,t){var r;return function(){return--n>0?r=t.apply(this,arguments):t=null,r}},h.once=h.partial(h.before,2),h.keys=function(n){if(!h.isObject(n))return[];if(s)return s(n);var t=[];for(var r in n)h.has(n,r)&&t.push(r);return t},h.values=function(n){for(var t=h.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},h.pairs=function(n){for(var t=h.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},h.invert=function(n){for(var t={},r=h.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},h.functions=h.methods=function(n){var t=[];for(var r in n)h.isFunction(n[r])&&t.push(r);return t.sort()},h.extend=function(n){if(!h.isObject(n))return n;for(var t,r,e=1,u=arguments.length;u>e;e++){t=arguments[e];for(r in t)c.call(t,r)&&(n[r]=t[r])}return n},h.pick=function(n,t,r){var e,u={};if(null==n)return u;if(h.isFunction(t)){t=g(t,r);for(e in n){var i=n[e];t(i,e,n)&&(u[e]=i)}}else{var l=o.apply([],a.call(arguments,1));n=new Object(n);for(var c=0,f=l.length;f>c;c++)e=l[c],e in n&&(u[e]=n[e])}return u},h.omit=function(n,t,r){if(h.isFunction(t))t=h.negate(t);else{var e=h.map(o.apply([],a.call(arguments,1)),String);t=function(n,t){return!h.contains(e,t)}}return h.pick(n,t,r)},h.defaults=function(n){if(!h.isObject(n))return n;for(var t=1,r=arguments.length;r>t;t++){var e=arguments[t];for(var u in e)n[u]===void 0&&(n[u]=e[u])}return n},h.clone=function(n){return h.isObject(n)?h.isArray(n)?n.slice():h.extend({},n):n},h.tap=function(n,t){return t(n),n};var b=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof h&&(n=n._wrapped),t instanceof h&&(t=t._wrapped);var u=l.call(n);if(u!==l.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]===n)return e[i]===t;var a=n.constructor,o=t.constructor;if(a!==o&&"constructor"in n&&"constructor"in t&&!(h.isFunction(a)&&a instanceof a&&h.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c,f;if("[object Array]"===u){if(c=n.length,f=c===t.length)for(;c--&&(f=b(n[c],t[c],r,e)););}else{var s,p=h.keys(n);if(c=p.length,f=h.keys(t).length===c)for(;c--&&(s=p[c],f=h.has(t,s)&&b(n[s],t[s],r,e)););}return r.pop(),e.pop(),f};h.isEqual=function(n,t){return b(n,t,[],[])},h.isEmpty=function(n){if(null==n)return!0;if(h.isArray(n)||h.isString(n)||h.isArguments(n))return 0===n.length;for(var t in n)if(h.has(n,t))return!1;return!0},h.isElement=function(n){return!(!n||1!==n.nodeType)},h.isArray=f||function(n){return"[object Array]"===l.call(n)},h.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},h.each(["Arguments","Function","String","Number","Date","RegExp"],function(n){h["is"+n]=function(t){return l.call(t)==="[object "+n+"]"}}),h.isArguments(arguments)||(h.isArguments=function(n){return h.has(n,"callee")}),"function"!=typeof/./&&(h.isFunction=function(n){return"function"==typeof n||!1}),h.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},h.isNaN=function(n){return h.isNumber(n)&&n!==+n},h.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===l.call(n)},h.isNull=function(n){return null===n},h.isUndefined=function(n){return n===void 0},h.has=function(n,t){return null!=n&&c.call(n,t)},h.noConflict=function(){return n._=t,this},h.identity=function(n){return n},h.constant=function(n){return function(){return n}},h.noop=function(){},h.property=function(n){return function(t){return t[n]}},h.matches=function(n){var t=h.pairs(n),r=t.length;return function(n){if(null==n)return!r;n=new Object(n);for(var e=0;r>e;e++){var u=t[e],i=u[0];if(u[1]!==n[i]||!(i in n))return!1}return!0}},h.times=function(n,t,r){var e=Array(Math.max(0,n));t=g(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},h.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},h.now=Date.now||function(){return(new Date).getTime()};var _={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},w=h.invert(_),j=function(n){var t=function(t){return n[t]},r="(?:"+h.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};h.escape=j(_),h.unescape=j(w),h.result=function(n,t){if(null==n)return void 0;var r=n[t];return h.isFunction(r)?n[t]():r};var x=0;h.uniqueId=function(n){var t=++x+"";return n?n+t:t},h.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var A=/(.)^/,k={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},O=/\\|'|\r|\n|\u2028|\u2029/g,F=function(n){return"\\"+k[n]};h.template=function(n,t,r){!t&&r&&(t=r),t=h.defaults({},t,h.templateSettings);var e=RegExp([(t.escape||A).source,(t.interpolate||A).source,(t.evaluate||A).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,a,o){return i+=n.slice(u,o).replace(O,F),u=o+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":a&&(i+="';\n"+a+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var a=new Function(t.variable||"obj","_",i)}catch(o){throw o.source=i,o}var l=function(n){return a.call(this,n,h)},c=t.variable||"obj";return l.source="function("+c+"){\n"+i+"}",l},h.chain=function(n){var t=h(n);return t._chain=!0,t};var E=function(n){return this._chain?h(n).chain():n};h.mixin=function(n){h.each(h.functions(n),function(t){var r=h[t]=n[t];h.prototype[t]=function(){var n=[this._wrapped];return i.apply(n,arguments),E.call(this,r.apply(h,n))}})},h.mixin(h),h.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=r[n];h.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],E.call(this,r)}}),h.each(["concat","join","slice"],function(n){var t=r[n];h.prototype[n]=function(){return E.call(this,t.apply(this._wrapped,arguments))}}),h.prototype.value=function(){return this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return h})}).call(this);
6
+ //# sourceMappingURL=underscore-min.map
@@ -0,0 +1,1415 @@
1
+ // Underscore.js 1.7.0
2
+ // http://underscorejs.org
3
+ // (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
4
+ // Underscore may be freely distributed under the MIT license.
5
+
6
+ (function() {
7
+
8
+ // Baseline setup
9
+ // --------------
10
+
11
+ // Establish the root object, `window` in the browser, or `exports` on the server.
12
+ var root = this;
13
+
14
+ // Save the previous value of the `_` variable.
15
+ var previousUnderscore = root._;
16
+
17
+ // Save bytes in the minified (but not gzipped) version:
18
+ var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
19
+
20
+ // Create quick reference variables for speed access to core prototypes.
21
+ var
22
+ push = ArrayProto.push,
23
+ slice = ArrayProto.slice,
24
+ concat = ArrayProto.concat,
25
+ toString = ObjProto.toString,
26
+ hasOwnProperty = ObjProto.hasOwnProperty;
27
+
28
+ // All **ECMAScript 5** native function implementations that we hope to use
29
+ // are declared here.
30
+ var
31
+ nativeIsArray = Array.isArray,
32
+ nativeKeys = Object.keys,
33
+ nativeBind = FuncProto.bind;
34
+
35
+ // Create a safe reference to the Underscore object for use below.
36
+ var _ = function(obj) {
37
+ if (obj instanceof _) return obj;
38
+ if (!(this instanceof _)) return new _(obj);
39
+ this._wrapped = obj;
40
+ };
41
+
42
+ // Export the Underscore object for **Node.js**, with
43
+ // backwards-compatibility for the old `require()` API. If we're in
44
+ // the browser, add `_` as a global object.
45
+ if (typeof exports !== 'undefined') {
46
+ if (typeof module !== 'undefined' && module.exports) {
47
+ exports = module.exports = _;
48
+ }
49
+ exports._ = _;
50
+ } else {
51
+ root._ = _;
52
+ }
53
+
54
+ // Current version.
55
+ _.VERSION = '1.7.0';
56
+
57
+ // Internal function that returns an efficient (for current engines) version
58
+ // of the passed-in callback, to be repeatedly applied in other Underscore
59
+ // functions.
60
+ var createCallback = function(func, context, argCount) {
61
+ if (context === void 0) return func;
62
+ switch (argCount == null ? 3 : argCount) {
63
+ case 1: return function(value) {
64
+ return func.call(context, value);
65
+ };
66
+ case 2: return function(value, other) {
67
+ return func.call(context, value, other);
68
+ };
69
+ case 3: return function(value, index, collection) {
70
+ return func.call(context, value, index, collection);
71
+ };
72
+ case 4: return function(accumulator, value, index, collection) {
73
+ return func.call(context, accumulator, value, index, collection);
74
+ };
75
+ }
76
+ return function() {
77
+ return func.apply(context, arguments);
78
+ };
79
+ };
80
+
81
+ // A mostly-internal function to generate callbacks that can be applied
82
+ // to each element in a collection, returning the desired result — either
83
+ // identity, an arbitrary callback, a property matcher, or a property accessor.
84
+ _.iteratee = function(value, context, argCount) {
85
+ if (value == null) return _.identity;
86
+ if (_.isFunction(value)) return createCallback(value, context, argCount);
87
+ if (_.isObject(value)) return _.matches(value);
88
+ return _.property(value);
89
+ };
90
+
91
+ // Collection Functions
92
+ // --------------------
93
+
94
+ // The cornerstone, an `each` implementation, aka `forEach`.
95
+ // Handles raw objects in addition to array-likes. Treats all
96
+ // sparse array-likes as if they were dense.
97
+ _.each = _.forEach = function(obj, iteratee, context) {
98
+ if (obj == null) return obj;
99
+ iteratee = createCallback(iteratee, context);
100
+ var i, length = obj.length;
101
+ if (length === +length) {
102
+ for (i = 0; i < length; i++) {
103
+ iteratee(obj[i], i, obj);
104
+ }
105
+ } else {
106
+ var keys = _.keys(obj);
107
+ for (i = 0, length = keys.length; i < length; i++) {
108
+ iteratee(obj[keys[i]], keys[i], obj);
109
+ }
110
+ }
111
+ return obj;
112
+ };
113
+
114
+ // Return the results of applying the iteratee to each element.
115
+ _.map = _.collect = function(obj, iteratee, context) {
116
+ if (obj == null) return [];
117
+ iteratee = _.iteratee(iteratee, context);
118
+ var keys = obj.length !== +obj.length && _.keys(obj),
119
+ length = (keys || obj).length,
120
+ results = Array(length),
121
+ currentKey;
122
+ for (var index = 0; index < length; index++) {
123
+ currentKey = keys ? keys[index] : index;
124
+ results[index] = iteratee(obj[currentKey], currentKey, obj);
125
+ }
126
+ return results;
127
+ };
128
+
129
+ var reduceError = 'Reduce of empty array with no initial value';
130
+
131
+ // **Reduce** builds up a single result from a list of values, aka `inject`,
132
+ // or `foldl`.
133
+ _.reduce = _.foldl = _.inject = function(obj, iteratee, memo, context) {
134
+ if (obj == null) obj = [];
135
+ iteratee = createCallback(iteratee, context, 4);
136
+ var keys = obj.length !== +obj.length && _.keys(obj),
137
+ length = (keys || obj).length,
138
+ index = 0, currentKey;
139
+ if (arguments.length < 3) {
140
+ if (!length) throw new TypeError(reduceError);
141
+ memo = obj[keys ? keys[index++] : index++];
142
+ }
143
+ for (; index < length; index++) {
144
+ currentKey = keys ? keys[index] : index;
145
+ memo = iteratee(memo, obj[currentKey], currentKey, obj);
146
+ }
147
+ return memo;
148
+ };
149
+
150
+ // The right-associative version of reduce, also known as `foldr`.
151
+ _.reduceRight = _.foldr = function(obj, iteratee, memo, context) {
152
+ if (obj == null) obj = [];
153
+ iteratee = createCallback(iteratee, context, 4);
154
+ var keys = obj.length !== + obj.length && _.keys(obj),
155
+ index = (keys || obj).length,
156
+ currentKey;
157
+ if (arguments.length < 3) {
158
+ if (!index) throw new TypeError(reduceError);
159
+ memo = obj[keys ? keys[--index] : --index];
160
+ }
161
+ while (index--) {
162
+ currentKey = keys ? keys[index] : index;
163
+ memo = iteratee(memo, obj[currentKey], currentKey, obj);
164
+ }
165
+ return memo;
166
+ };
167
+
168
+ // Return the first value which passes a truth test. Aliased as `detect`.
169
+ _.find = _.detect = function(obj, predicate, context) {
170
+ var result;
171
+ predicate = _.iteratee(predicate, context);
172
+ _.some(obj, function(value, index, list) {
173
+ if (predicate(value, index, list)) {
174
+ result = value;
175
+ return true;
176
+ }
177
+ });
178
+ return result;
179
+ };
180
+
181
+ // Return all the elements that pass a truth test.
182
+ // Aliased as `select`.
183
+ _.filter = _.select = function(obj, predicate, context) {
184
+ var results = [];
185
+ if (obj == null) return results;
186
+ predicate = _.iteratee(predicate, context);
187
+ _.each(obj, function(value, index, list) {
188
+ if (predicate(value, index, list)) results.push(value);
189
+ });
190
+ return results;
191
+ };
192
+
193
+ // Return all the elements for which a truth test fails.
194
+ _.reject = function(obj, predicate, context) {
195
+ return _.filter(obj, _.negate(_.iteratee(predicate)), context);
196
+ };
197
+
198
+ // Determine whether all of the elements match a truth test.
199
+ // Aliased as `all`.
200
+ _.every = _.all = function(obj, predicate, context) {
201
+ if (obj == null) return true;
202
+ predicate = _.iteratee(predicate, context);
203
+ var keys = obj.length !== +obj.length && _.keys(obj),
204
+ length = (keys || obj).length,
205
+ index, currentKey;
206
+ for (index = 0; index < length; index++) {
207
+ currentKey = keys ? keys[index] : index;
208
+ if (!predicate(obj[currentKey], currentKey, obj)) return false;
209
+ }
210
+ return true;
211
+ };
212
+
213
+ // Determine if at least one element in the object matches a truth test.
214
+ // Aliased as `any`.
215
+ _.some = _.any = function(obj, predicate, context) {
216
+ if (obj == null) return false;
217
+ predicate = _.iteratee(predicate, context);
218
+ var keys = obj.length !== +obj.length && _.keys(obj),
219
+ length = (keys || obj).length,
220
+ index, currentKey;
221
+ for (index = 0; index < length; index++) {
222
+ currentKey = keys ? keys[index] : index;
223
+ if (predicate(obj[currentKey], currentKey, obj)) return true;
224
+ }
225
+ return false;
226
+ };
227
+
228
+ // Determine if the array or object contains a given value (using `===`).
229
+ // Aliased as `include`.
230
+ _.contains = _.include = function(obj, target) {
231
+ if (obj == null) return false;
232
+ if (obj.length !== +obj.length) obj = _.values(obj);
233
+ return _.indexOf(obj, target) >= 0;
234
+ };
235
+
236
+ // Invoke a method (with arguments) on every item in a collection.
237
+ _.invoke = function(obj, method) {
238
+ var args = slice.call(arguments, 2);
239
+ var isFunc = _.isFunction(method);
240
+ return _.map(obj, function(value) {
241
+ return (isFunc ? method : value[method]).apply(value, args);
242
+ });
243
+ };
244
+
245
+ // Convenience version of a common use case of `map`: fetching a property.
246
+ _.pluck = function(obj, key) {
247
+ return _.map(obj, _.property(key));
248
+ };
249
+
250
+ // Convenience version of a common use case of `filter`: selecting only objects
251
+ // containing specific `key:value` pairs.
252
+ _.where = function(obj, attrs) {
253
+ return _.filter(obj, _.matches(attrs));
254
+ };
255
+
256
+ // Convenience version of a common use case of `find`: getting the first object
257
+ // containing specific `key:value` pairs.
258
+ _.findWhere = function(obj, attrs) {
259
+ return _.find(obj, _.matches(attrs));
260
+ };
261
+
262
+ // Return the maximum element (or element-based computation).
263
+ _.max = function(obj, iteratee, context) {
264
+ var result = -Infinity, lastComputed = -Infinity,
265
+ value, computed;
266
+ if (iteratee == null && obj != null) {
267
+ obj = obj.length === +obj.length ? obj : _.values(obj);
268
+ for (var i = 0, length = obj.length; i < length; i++) {
269
+ value = obj[i];
270
+ if (value > result) {
271
+ result = value;
272
+ }
273
+ }
274
+ } else {
275
+ iteratee = _.iteratee(iteratee, context);
276
+ _.each(obj, function(value, index, list) {
277
+ computed = iteratee(value, index, list);
278
+ if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
279
+ result = value;
280
+ lastComputed = computed;
281
+ }
282
+ });
283
+ }
284
+ return result;
285
+ };
286
+
287
+ // Return the minimum element (or element-based computation).
288
+ _.min = function(obj, iteratee, context) {
289
+ var result = Infinity, lastComputed = Infinity,
290
+ value, computed;
291
+ if (iteratee == null && obj != null) {
292
+ obj = obj.length === +obj.length ? obj : _.values(obj);
293
+ for (var i = 0, length = obj.length; i < length; i++) {
294
+ value = obj[i];
295
+ if (value < result) {
296
+ result = value;
297
+ }
298
+ }
299
+ } else {
300
+ iteratee = _.iteratee(iteratee, context);
301
+ _.each(obj, function(value, index, list) {
302
+ computed = iteratee(value, index, list);
303
+ if (computed < lastComputed || computed === Infinity && result === Infinity) {
304
+ result = value;
305
+ lastComputed = computed;
306
+ }
307
+ });
308
+ }
309
+ return result;
310
+ };
311
+
312
+ // Shuffle a collection, using the modern version of the
313
+ // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
314
+ _.shuffle = function(obj) {
315
+ var set = obj && obj.length === +obj.length ? obj : _.values(obj);
316
+ var length = set.length;
317
+ var shuffled = Array(length);
318
+ for (var index = 0, rand; index < length; index++) {
319
+ rand = _.random(0, index);
320
+ if (rand !== index) shuffled[index] = shuffled[rand];
321
+ shuffled[rand] = set[index];
322
+ }
323
+ return shuffled;
324
+ };
325
+
326
+ // Sample **n** random values from a collection.
327
+ // If **n** is not specified, returns a single random element.
328
+ // The internal `guard` argument allows it to work with `map`.
329
+ _.sample = function(obj, n, guard) {
330
+ if (n == null || guard) {
331
+ if (obj.length !== +obj.length) obj = _.values(obj);
332
+ return obj[_.random(obj.length - 1)];
333
+ }
334
+ return _.shuffle(obj).slice(0, Math.max(0, n));
335
+ };
336
+
337
+ // Sort the object's values by a criterion produced by an iteratee.
338
+ _.sortBy = function(obj, iteratee, context) {
339
+ iteratee = _.iteratee(iteratee, context);
340
+ return _.pluck(_.map(obj, function(value, index, list) {
341
+ return {
342
+ value: value,
343
+ index: index,
344
+ criteria: iteratee(value, index, list)
345
+ };
346
+ }).sort(function(left, right) {
347
+ var a = left.criteria;
348
+ var b = right.criteria;
349
+ if (a !== b) {
350
+ if (a > b || a === void 0) return 1;
351
+ if (a < b || b === void 0) return -1;
352
+ }
353
+ return left.index - right.index;
354
+ }), 'value');
355
+ };
356
+
357
+ // An internal function used for aggregate "group by" operations.
358
+ var group = function(behavior) {
359
+ return function(obj, iteratee, context) {
360
+ var result = {};
361
+ iteratee = _.iteratee(iteratee, context);
362
+ _.each(obj, function(value, index) {
363
+ var key = iteratee(value, index, obj);
364
+ behavior(result, value, key);
365
+ });
366
+ return result;
367
+ };
368
+ };
369
+
370
+ // Groups the object's values by a criterion. Pass either a string attribute
371
+ // to group by, or a function that returns the criterion.
372
+ _.groupBy = group(function(result, value, key) {
373
+ if (_.has(result, key)) result[key].push(value); else result[key] = [value];
374
+ });
375
+
376
+ // Indexes the object's values by a criterion, similar to `groupBy`, but for
377
+ // when you know that your index values will be unique.
378
+ _.indexBy = group(function(result, value, key) {
379
+ result[key] = value;
380
+ });
381
+
382
+ // Counts instances of an object that group by a certain criterion. Pass
383
+ // either a string attribute to count by, or a function that returns the
384
+ // criterion.
385
+ _.countBy = group(function(result, value, key) {
386
+ if (_.has(result, key)) result[key]++; else result[key] = 1;
387
+ });
388
+
389
+ // Use a comparator function to figure out the smallest index at which
390
+ // an object should be inserted so as to maintain order. Uses binary search.
391
+ _.sortedIndex = function(array, obj, iteratee, context) {
392
+ iteratee = _.iteratee(iteratee, context, 1);
393
+ var value = iteratee(obj);
394
+ var low = 0, high = array.length;
395
+ while (low < high) {
396
+ var mid = low + high >>> 1;
397
+ if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
398
+ }
399
+ return low;
400
+ };
401
+
402
+ // Safely create a real, live array from anything iterable.
403
+ _.toArray = function(obj) {
404
+ if (!obj) return [];
405
+ if (_.isArray(obj)) return slice.call(obj);
406
+ if (obj.length === +obj.length) return _.map(obj, _.identity);
407
+ return _.values(obj);
408
+ };
409
+
410
+ // Return the number of elements in an object.
411
+ _.size = function(obj) {
412
+ if (obj == null) return 0;
413
+ return obj.length === +obj.length ? obj.length : _.keys(obj).length;
414
+ };
415
+
416
+ // Split a collection into two arrays: one whose elements all satisfy the given
417
+ // predicate, and one whose elements all do not satisfy the predicate.
418
+ _.partition = function(obj, predicate, context) {
419
+ predicate = _.iteratee(predicate, context);
420
+ var pass = [], fail = [];
421
+ _.each(obj, function(value, key, obj) {
422
+ (predicate(value, key, obj) ? pass : fail).push(value);
423
+ });
424
+ return [pass, fail];
425
+ };
426
+
427
+ // Array Functions
428
+ // ---------------
429
+
430
+ // Get the first element of an array. Passing **n** will return the first N
431
+ // values in the array. Aliased as `head` and `take`. The **guard** check
432
+ // allows it to work with `_.map`.
433
+ _.first = _.head = _.take = function(array, n, guard) {
434
+ if (array == null) return void 0;
435
+ if (n == null || guard) return array[0];
436
+ if (n < 0) return [];
437
+ return slice.call(array, 0, n);
438
+ };
439
+
440
+ // Returns everything but the last entry of the array. Especially useful on
441
+ // the arguments object. Passing **n** will return all the values in
442
+ // the array, excluding the last N. The **guard** check allows it to work with
443
+ // `_.map`.
444
+ _.initial = function(array, n, guard) {
445
+ return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
446
+ };
447
+
448
+ // Get the last element of an array. Passing **n** will return the last N
449
+ // values in the array. The **guard** check allows it to work with `_.map`.
450
+ _.last = function(array, n, guard) {
451
+ if (array == null) return void 0;
452
+ if (n == null || guard) return array[array.length - 1];
453
+ return slice.call(array, Math.max(array.length - n, 0));
454
+ };
455
+
456
+ // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
457
+ // Especially useful on the arguments object. Passing an **n** will return
458
+ // the rest N values in the array. The **guard**
459
+ // check allows it to work with `_.map`.
460
+ _.rest = _.tail = _.drop = function(array, n, guard) {
461
+ return slice.call(array, n == null || guard ? 1 : n);
462
+ };
463
+
464
+ // Trim out all falsy values from an array.
465
+ _.compact = function(array) {
466
+ return _.filter(array, _.identity);
467
+ };
468
+
469
+ // Internal implementation of a recursive `flatten` function.
470
+ var flatten = function(input, shallow, strict, output) {
471
+ if (shallow && _.every(input, _.isArray)) {
472
+ return concat.apply(output, input);
473
+ }
474
+ for (var i = 0, length = input.length; i < length; i++) {
475
+ var value = input[i];
476
+ if (!_.isArray(value) && !_.isArguments(value)) {
477
+ if (!strict) output.push(value);
478
+ } else if (shallow) {
479
+ push.apply(output, value);
480
+ } else {
481
+ flatten(value, shallow, strict, output);
482
+ }
483
+ }
484
+ return output;
485
+ };
486
+
487
+ // Flatten out an array, either recursively (by default), or just one level.
488
+ _.flatten = function(array, shallow) {
489
+ return flatten(array, shallow, false, []);
490
+ };
491
+
492
+ // Return a version of the array that does not contain the specified value(s).
493
+ _.without = function(array) {
494
+ return _.difference(array, slice.call(arguments, 1));
495
+ };
496
+
497
+ // Produce a duplicate-free version of the array. If the array has already
498
+ // been sorted, you have the option of using a faster algorithm.
499
+ // Aliased as `unique`.
500
+ _.uniq = _.unique = function(array, isSorted, iteratee, context) {
501
+ if (array == null) return [];
502
+ if (!_.isBoolean(isSorted)) {
503
+ context = iteratee;
504
+ iteratee = isSorted;
505
+ isSorted = false;
506
+ }
507
+ if (iteratee != null) iteratee = _.iteratee(iteratee, context);
508
+ var result = [];
509
+ var seen = [];
510
+ for (var i = 0, length = array.length; i < length; i++) {
511
+ var value = array[i];
512
+ if (isSorted) {
513
+ if (!i || seen !== value) result.push(value);
514
+ seen = value;
515
+ } else if (iteratee) {
516
+ var computed = iteratee(value, i, array);
517
+ if (_.indexOf(seen, computed) < 0) {
518
+ seen.push(computed);
519
+ result.push(value);
520
+ }
521
+ } else if (_.indexOf(result, value) < 0) {
522
+ result.push(value);
523
+ }
524
+ }
525
+ return result;
526
+ };
527
+
528
+ // Produce an array that contains the union: each distinct element from all of
529
+ // the passed-in arrays.
530
+ _.union = function() {
531
+ return _.uniq(flatten(arguments, true, true, []));
532
+ };
533
+
534
+ // Produce an array that contains every item shared between all the
535
+ // passed-in arrays.
536
+ _.intersection = function(array) {
537
+ if (array == null) return [];
538
+ var result = [];
539
+ var argsLength = arguments.length;
540
+ for (var i = 0, length = array.length; i < length; i++) {
541
+ var item = array[i];
542
+ if (_.contains(result, item)) continue;
543
+ for (var j = 1; j < argsLength; j++) {
544
+ if (!_.contains(arguments[j], item)) break;
545
+ }
546
+ if (j === argsLength) result.push(item);
547
+ }
548
+ return result;
549
+ };
550
+
551
+ // Take the difference between one array and a number of other arrays.
552
+ // Only the elements present in just the first array will remain.
553
+ _.difference = function(array) {
554
+ var rest = flatten(slice.call(arguments, 1), true, true, []);
555
+ return _.filter(array, function(value){
556
+ return !_.contains(rest, value);
557
+ });
558
+ };
559
+
560
+ // Zip together multiple lists into a single array -- elements that share
561
+ // an index go together.
562
+ _.zip = function(array) {
563
+ if (array == null) return [];
564
+ var length = _.max(arguments, 'length').length;
565
+ var results = Array(length);
566
+ for (var i = 0; i < length; i++) {
567
+ results[i] = _.pluck(arguments, i);
568
+ }
569
+ return results;
570
+ };
571
+
572
+ // Converts lists into objects. Pass either a single array of `[key, value]`
573
+ // pairs, or two parallel arrays of the same length -- one of keys, and one of
574
+ // the corresponding values.
575
+ _.object = function(list, values) {
576
+ if (list == null) return {};
577
+ var result = {};
578
+ for (var i = 0, length = list.length; i < length; i++) {
579
+ if (values) {
580
+ result[list[i]] = values[i];
581
+ } else {
582
+ result[list[i][0]] = list[i][1];
583
+ }
584
+ }
585
+ return result;
586
+ };
587
+
588
+ // Return the position of the first occurrence of an item in an array,
589
+ // or -1 if the item is not included in the array.
590
+ // If the array is large and already in sort order, pass `true`
591
+ // for **isSorted** to use binary search.
592
+ _.indexOf = function(array, item, isSorted) {
593
+ if (array == null) return -1;
594
+ var i = 0, length = array.length;
595
+ if (isSorted) {
596
+ if (typeof isSorted == 'number') {
597
+ i = isSorted < 0 ? Math.max(0, length + isSorted) : isSorted;
598
+ } else {
599
+ i = _.sortedIndex(array, item);
600
+ return array[i] === item ? i : -1;
601
+ }
602
+ }
603
+ for (; i < length; i++) if (array[i] === item) return i;
604
+ return -1;
605
+ };
606
+
607
+ _.lastIndexOf = function(array, item, from) {
608
+ if (array == null) return -1;
609
+ var idx = array.length;
610
+ if (typeof from == 'number') {
611
+ idx = from < 0 ? idx + from + 1 : Math.min(idx, from + 1);
612
+ }
613
+ while (--idx >= 0) if (array[idx] === item) return idx;
614
+ return -1;
615
+ };
616
+
617
+ // Generate an integer Array containing an arithmetic progression. A port of
618
+ // the native Python `range()` function. See
619
+ // [the Python documentation](http://docs.python.org/library/functions.html#range).
620
+ _.range = function(start, stop, step) {
621
+ if (arguments.length <= 1) {
622
+ stop = start || 0;
623
+ start = 0;
624
+ }
625
+ step = step || 1;
626
+
627
+ var length = Math.max(Math.ceil((stop - start) / step), 0);
628
+ var range = Array(length);
629
+
630
+ for (var idx = 0; idx < length; idx++, start += step) {
631
+ range[idx] = start;
632
+ }
633
+
634
+ return range;
635
+ };
636
+
637
+ // Function (ahem) Functions
638
+ // ------------------
639
+
640
+ // Reusable constructor function for prototype setting.
641
+ var Ctor = function(){};
642
+
643
+ // Create a function bound to a given object (assigning `this`, and arguments,
644
+ // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
645
+ // available.
646
+ _.bind = function(func, context) {
647
+ var args, bound;
648
+ if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
649
+ if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
650
+ args = slice.call(arguments, 2);
651
+ bound = function() {
652
+ if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
653
+ Ctor.prototype = func.prototype;
654
+ var self = new Ctor;
655
+ Ctor.prototype = null;
656
+ var result = func.apply(self, args.concat(slice.call(arguments)));
657
+ if (_.isObject(result)) return result;
658
+ return self;
659
+ };
660
+ return bound;
661
+ };
662
+
663
+ // Partially apply a function by creating a version that has had some of its
664
+ // arguments pre-filled, without changing its dynamic `this` context. _ acts
665
+ // as a placeholder, allowing any combination of arguments to be pre-filled.
666
+ _.partial = function(func) {
667
+ var boundArgs = slice.call(arguments, 1);
668
+ return function() {
669
+ var position = 0;
670
+ var args = boundArgs.slice();
671
+ for (var i = 0, length = args.length; i < length; i++) {
672
+ if (args[i] === _) args[i] = arguments[position++];
673
+ }
674
+ while (position < arguments.length) args.push(arguments[position++]);
675
+ return func.apply(this, args);
676
+ };
677
+ };
678
+
679
+ // Bind a number of an object's methods to that object. Remaining arguments
680
+ // are the method names to be bound. Useful for ensuring that all callbacks
681
+ // defined on an object belong to it.
682
+ _.bindAll = function(obj) {
683
+ var i, length = arguments.length, key;
684
+ if (length <= 1) throw new Error('bindAll must be passed function names');
685
+ for (i = 1; i < length; i++) {
686
+ key = arguments[i];
687
+ obj[key] = _.bind(obj[key], obj);
688
+ }
689
+ return obj;
690
+ };
691
+
692
+ // Memoize an expensive function by storing its results.
693
+ _.memoize = function(func, hasher) {
694
+ var memoize = function(key) {
695
+ var cache = memoize.cache;
696
+ var address = hasher ? hasher.apply(this, arguments) : key;
697
+ if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
698
+ return cache[address];
699
+ };
700
+ memoize.cache = {};
701
+ return memoize;
702
+ };
703
+
704
+ // Delays a function for the given number of milliseconds, and then calls
705
+ // it with the arguments supplied.
706
+ _.delay = function(func, wait) {
707
+ var args = slice.call(arguments, 2);
708
+ return setTimeout(function(){
709
+ return func.apply(null, args);
710
+ }, wait);
711
+ };
712
+
713
+ // Defers a function, scheduling it to run after the current call stack has
714
+ // cleared.
715
+ _.defer = function(func) {
716
+ return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
717
+ };
718
+
719
+ // Returns a function, that, when invoked, will only be triggered at most once
720
+ // during a given window of time. Normally, the throttled function will run
721
+ // as much as it can, without ever going more than once per `wait` duration;
722
+ // but if you'd like to disable the execution on the leading edge, pass
723
+ // `{leading: false}`. To disable execution on the trailing edge, ditto.
724
+ _.throttle = function(func, wait, options) {
725
+ var context, args, result;
726
+ var timeout = null;
727
+ var previous = 0;
728
+ if (!options) options = {};
729
+ var later = function() {
730
+ previous = options.leading === false ? 0 : _.now();
731
+ timeout = null;
732
+ result = func.apply(context, args);
733
+ if (!timeout) context = args = null;
734
+ };
735
+ return function() {
736
+ var now = _.now();
737
+ if (!previous && options.leading === false) previous = now;
738
+ var remaining = wait - (now - previous);
739
+ context = this;
740
+ args = arguments;
741
+ if (remaining <= 0 || remaining > wait) {
742
+ clearTimeout(timeout);
743
+ timeout = null;
744
+ previous = now;
745
+ result = func.apply(context, args);
746
+ if (!timeout) context = args = null;
747
+ } else if (!timeout && options.trailing !== false) {
748
+ timeout = setTimeout(later, remaining);
749
+ }
750
+ return result;
751
+ };
752
+ };
753
+
754
+ // Returns a function, that, as long as it continues to be invoked, will not
755
+ // be triggered. The function will be called after it stops being called for
756
+ // N milliseconds. If `immediate` is passed, trigger the function on the
757
+ // leading edge, instead of the trailing.
758
+ _.debounce = function(func, wait, immediate) {
759
+ var timeout, args, context, timestamp, result;
760
+
761
+ var later = function() {
762
+ var last = _.now() - timestamp;
763
+
764
+ if (last < wait && last > 0) {
765
+ timeout = setTimeout(later, wait - last);
766
+ } else {
767
+ timeout = null;
768
+ if (!immediate) {
769
+ result = func.apply(context, args);
770
+ if (!timeout) context = args = null;
771
+ }
772
+ }
773
+ };
774
+
775
+ return function() {
776
+ context = this;
777
+ args = arguments;
778
+ timestamp = _.now();
779
+ var callNow = immediate && !timeout;
780
+ if (!timeout) timeout = setTimeout(later, wait);
781
+ if (callNow) {
782
+ result = func.apply(context, args);
783
+ context = args = null;
784
+ }
785
+
786
+ return result;
787
+ };
788
+ };
789
+
790
+ // Returns the first function passed as an argument to the second,
791
+ // allowing you to adjust arguments, run code before and after, and
792
+ // conditionally execute the original function.
793
+ _.wrap = function(func, wrapper) {
794
+ return _.partial(wrapper, func);
795
+ };
796
+
797
+ // Returns a negated version of the passed-in predicate.
798
+ _.negate = function(predicate) {
799
+ return function() {
800
+ return !predicate.apply(this, arguments);
801
+ };
802
+ };
803
+
804
+ // Returns a function that is the composition of a list of functions, each
805
+ // consuming the return value of the function that follows.
806
+ _.compose = function() {
807
+ var args = arguments;
808
+ var start = args.length - 1;
809
+ return function() {
810
+ var i = start;
811
+ var result = args[start].apply(this, arguments);
812
+ while (i--) result = args[i].call(this, result);
813
+ return result;
814
+ };
815
+ };
816
+
817
+ // Returns a function that will only be executed after being called N times.
818
+ _.after = function(times, func) {
819
+ return function() {
820
+ if (--times < 1) {
821
+ return func.apply(this, arguments);
822
+ }
823
+ };
824
+ };
825
+
826
+ // Returns a function that will only be executed before being called N times.
827
+ _.before = function(times, func) {
828
+ var memo;
829
+ return function() {
830
+ if (--times > 0) {
831
+ memo = func.apply(this, arguments);
832
+ } else {
833
+ func = null;
834
+ }
835
+ return memo;
836
+ };
837
+ };
838
+
839
+ // Returns a function that will be executed at most one time, no matter how
840
+ // often you call it. Useful for lazy initialization.
841
+ _.once = _.partial(_.before, 2);
842
+
843
+ // Object Functions
844
+ // ----------------
845
+
846
+ // Retrieve the names of an object's properties.
847
+ // Delegates to **ECMAScript 5**'s native `Object.keys`
848
+ _.keys = function(obj) {
849
+ if (!_.isObject(obj)) return [];
850
+ if (nativeKeys) return nativeKeys(obj);
851
+ var keys = [];
852
+ for (var key in obj) if (_.has(obj, key)) keys.push(key);
853
+ return keys;
854
+ };
855
+
856
+ // Retrieve the values of an object's properties.
857
+ _.values = function(obj) {
858
+ var keys = _.keys(obj);
859
+ var length = keys.length;
860
+ var values = Array(length);
861
+ for (var i = 0; i < length; i++) {
862
+ values[i] = obj[keys[i]];
863
+ }
864
+ return values;
865
+ };
866
+
867
+ // Convert an object into a list of `[key, value]` pairs.
868
+ _.pairs = function(obj) {
869
+ var keys = _.keys(obj);
870
+ var length = keys.length;
871
+ var pairs = Array(length);
872
+ for (var i = 0; i < length; i++) {
873
+ pairs[i] = [keys[i], obj[keys[i]]];
874
+ }
875
+ return pairs;
876
+ };
877
+
878
+ // Invert the keys and values of an object. The values must be serializable.
879
+ _.invert = function(obj) {
880
+ var result = {};
881
+ var keys = _.keys(obj);
882
+ for (var i = 0, length = keys.length; i < length; i++) {
883
+ result[obj[keys[i]]] = keys[i];
884
+ }
885
+ return result;
886
+ };
887
+
888
+ // Return a sorted list of the function names available on the object.
889
+ // Aliased as `methods`
890
+ _.functions = _.methods = function(obj) {
891
+ var names = [];
892
+ for (var key in obj) {
893
+ if (_.isFunction(obj[key])) names.push(key);
894
+ }
895
+ return names.sort();
896
+ };
897
+
898
+ // Extend a given object with all the properties in passed-in object(s).
899
+ _.extend = function(obj) {
900
+ if (!_.isObject(obj)) return obj;
901
+ var source, prop;
902
+ for (var i = 1, length = arguments.length; i < length; i++) {
903
+ source = arguments[i];
904
+ for (prop in source) {
905
+ if (hasOwnProperty.call(source, prop)) {
906
+ obj[prop] = source[prop];
907
+ }
908
+ }
909
+ }
910
+ return obj;
911
+ };
912
+
913
+ // Return a copy of the object only containing the whitelisted properties.
914
+ _.pick = function(obj, iteratee, context) {
915
+ var result = {}, key;
916
+ if (obj == null) return result;
917
+ if (_.isFunction(iteratee)) {
918
+ iteratee = createCallback(iteratee, context);
919
+ for (key in obj) {
920
+ var value = obj[key];
921
+ if (iteratee(value, key, obj)) result[key] = value;
922
+ }
923
+ } else {
924
+ var keys = concat.apply([], slice.call(arguments, 1));
925
+ obj = new Object(obj);
926
+ for (var i = 0, length = keys.length; i < length; i++) {
927
+ key = keys[i];
928
+ if (key in obj) result[key] = obj[key];
929
+ }
930
+ }
931
+ return result;
932
+ };
933
+
934
+ // Return a copy of the object without the blacklisted properties.
935
+ _.omit = function(obj, iteratee, context) {
936
+ if (_.isFunction(iteratee)) {
937
+ iteratee = _.negate(iteratee);
938
+ } else {
939
+ var keys = _.map(concat.apply([], slice.call(arguments, 1)), String);
940
+ iteratee = function(value, key) {
941
+ return !_.contains(keys, key);
942
+ };
943
+ }
944
+ return _.pick(obj, iteratee, context);
945
+ };
946
+
947
+ // Fill in a given object with default properties.
948
+ _.defaults = function(obj) {
949
+ if (!_.isObject(obj)) return obj;
950
+ for (var i = 1, length = arguments.length; i < length; i++) {
951
+ var source = arguments[i];
952
+ for (var prop in source) {
953
+ if (obj[prop] === void 0) obj[prop] = source[prop];
954
+ }
955
+ }
956
+ return obj;
957
+ };
958
+
959
+ // Create a (shallow-cloned) duplicate of an object.
960
+ _.clone = function(obj) {
961
+ if (!_.isObject(obj)) return obj;
962
+ return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
963
+ };
964
+
965
+ // Invokes interceptor with the obj, and then returns obj.
966
+ // The primary purpose of this method is to "tap into" a method chain, in
967
+ // order to perform operations on intermediate results within the chain.
968
+ _.tap = function(obj, interceptor) {
969
+ interceptor(obj);
970
+ return obj;
971
+ };
972
+
973
+ // Internal recursive comparison function for `isEqual`.
974
+ var eq = function(a, b, aStack, bStack) {
975
+ // Identical objects are equal. `0 === -0`, but they aren't identical.
976
+ // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
977
+ if (a === b) return a !== 0 || 1 / a === 1 / b;
978
+ // A strict comparison is necessary because `null == undefined`.
979
+ if (a == null || b == null) return a === b;
980
+ // Unwrap any wrapped objects.
981
+ if (a instanceof _) a = a._wrapped;
982
+ if (b instanceof _) b = b._wrapped;
983
+ // Compare `[[Class]]` names.
984
+ var className = toString.call(a);
985
+ if (className !== toString.call(b)) return false;
986
+ switch (className) {
987
+ // Strings, numbers, regular expressions, dates, and booleans are compared by value.
988
+ case '[object RegExp]':
989
+ // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
990
+ case '[object String]':
991
+ // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
992
+ // equivalent to `new String("5")`.
993
+ return '' + a === '' + b;
994
+ case '[object Number]':
995
+ // `NaN`s are equivalent, but non-reflexive.
996
+ // Object(NaN) is equivalent to NaN
997
+ if (+a !== +a) return +b !== +b;
998
+ // An `egal` comparison is performed for other numeric values.
999
+ return +a === 0 ? 1 / +a === 1 / b : +a === +b;
1000
+ case '[object Date]':
1001
+ case '[object Boolean]':
1002
+ // Coerce dates and booleans to numeric primitive values. Dates are compared by their
1003
+ // millisecond representations. Note that invalid dates with millisecond representations
1004
+ // of `NaN` are not equivalent.
1005
+ return +a === +b;
1006
+ }
1007
+ if (typeof a != 'object' || typeof b != 'object') return false;
1008
+ // Assume equality for cyclic structures. The algorithm for detecting cyclic
1009
+ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
1010
+ var length = aStack.length;
1011
+ while (length--) {
1012
+ // Linear search. Performance is inversely proportional to the number of
1013
+ // unique nested structures.
1014
+ if (aStack[length] === a) return bStack[length] === b;
1015
+ }
1016
+ // Objects with different constructors are not equivalent, but `Object`s
1017
+ // from different frames are.
1018
+ var aCtor = a.constructor, bCtor = b.constructor;
1019
+ if (
1020
+ aCtor !== bCtor &&
1021
+ // Handle Object.create(x) cases
1022
+ 'constructor' in a && 'constructor' in b &&
1023
+ !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
1024
+ _.isFunction(bCtor) && bCtor instanceof bCtor)
1025
+ ) {
1026
+ return false;
1027
+ }
1028
+ // Add the first object to the stack of traversed objects.
1029
+ aStack.push(a);
1030
+ bStack.push(b);
1031
+ var size, result;
1032
+ // Recursively compare objects and arrays.
1033
+ if (className === '[object Array]') {
1034
+ // Compare array lengths to determine if a deep comparison is necessary.
1035
+ size = a.length;
1036
+ result = size === b.length;
1037
+ if (result) {
1038
+ // Deep compare the contents, ignoring non-numeric properties.
1039
+ while (size--) {
1040
+ if (!(result = eq(a[size], b[size], aStack, bStack))) break;
1041
+ }
1042
+ }
1043
+ } else {
1044
+ // Deep compare objects.
1045
+ var keys = _.keys(a), key;
1046
+ size = keys.length;
1047
+ // Ensure that both objects contain the same number of properties before comparing deep equality.
1048
+ result = _.keys(b).length === size;
1049
+ if (result) {
1050
+ while (size--) {
1051
+ // Deep compare each member
1052
+ key = keys[size];
1053
+ if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
1054
+ }
1055
+ }
1056
+ }
1057
+ // Remove the first object from the stack of traversed objects.
1058
+ aStack.pop();
1059
+ bStack.pop();
1060
+ return result;
1061
+ };
1062
+
1063
+ // Perform a deep comparison to check if two objects are equal.
1064
+ _.isEqual = function(a, b) {
1065
+ return eq(a, b, [], []);
1066
+ };
1067
+
1068
+ // Is a given array, string, or object empty?
1069
+ // An "empty" object has no enumerable own-properties.
1070
+ _.isEmpty = function(obj) {
1071
+ if (obj == null) return true;
1072
+ if (_.isArray(obj) || _.isString(obj) || _.isArguments(obj)) return obj.length === 0;
1073
+ for (var key in obj) if (_.has(obj, key)) return false;
1074
+ return true;
1075
+ };
1076
+
1077
+ // Is a given value a DOM element?
1078
+ _.isElement = function(obj) {
1079
+ return !!(obj && obj.nodeType === 1);
1080
+ };
1081
+
1082
+ // Is a given value an array?
1083
+ // Delegates to ECMA5's native Array.isArray
1084
+ _.isArray = nativeIsArray || function(obj) {
1085
+ return toString.call(obj) === '[object Array]';
1086
+ };
1087
+
1088
+ // Is a given variable an object?
1089
+ _.isObject = function(obj) {
1090
+ var type = typeof obj;
1091
+ return type === 'function' || type === 'object' && !!obj;
1092
+ };
1093
+
1094
+ // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
1095
+ _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
1096
+ _['is' + name] = function(obj) {
1097
+ return toString.call(obj) === '[object ' + name + ']';
1098
+ };
1099
+ });
1100
+
1101
+ // Define a fallback version of the method in browsers (ahem, IE), where
1102
+ // there isn't any inspectable "Arguments" type.
1103
+ if (!_.isArguments(arguments)) {
1104
+ _.isArguments = function(obj) {
1105
+ return _.has(obj, 'callee');
1106
+ };
1107
+ }
1108
+
1109
+ // Optimize `isFunction` if appropriate. Work around an IE 11 bug.
1110
+ if (typeof /./ !== 'function') {
1111
+ _.isFunction = function(obj) {
1112
+ return typeof obj == 'function' || false;
1113
+ };
1114
+ }
1115
+
1116
+ // Is a given object a finite number?
1117
+ _.isFinite = function(obj) {
1118
+ return isFinite(obj) && !isNaN(parseFloat(obj));
1119
+ };
1120
+
1121
+ // Is the given value `NaN`? (NaN is the only number which does not equal itself).
1122
+ _.isNaN = function(obj) {
1123
+ return _.isNumber(obj) && obj !== +obj;
1124
+ };
1125
+
1126
+ // Is a given value a boolean?
1127
+ _.isBoolean = function(obj) {
1128
+ return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
1129
+ };
1130
+
1131
+ // Is a given value equal to null?
1132
+ _.isNull = function(obj) {
1133
+ return obj === null;
1134
+ };
1135
+
1136
+ // Is a given variable undefined?
1137
+ _.isUndefined = function(obj) {
1138
+ return obj === void 0;
1139
+ };
1140
+
1141
+ // Shortcut function for checking if an object has a given property directly
1142
+ // on itself (in other words, not on a prototype).
1143
+ _.has = function(obj, key) {
1144
+ return obj != null && hasOwnProperty.call(obj, key);
1145
+ };
1146
+
1147
+ // Utility Functions
1148
+ // -----------------
1149
+
1150
+ // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
1151
+ // previous owner. Returns a reference to the Underscore object.
1152
+ _.noConflict = function() {
1153
+ root._ = previousUnderscore;
1154
+ return this;
1155
+ };
1156
+
1157
+ // Keep the identity function around for default iteratees.
1158
+ _.identity = function(value) {
1159
+ return value;
1160
+ };
1161
+
1162
+ _.constant = function(value) {
1163
+ return function() {
1164
+ return value;
1165
+ };
1166
+ };
1167
+
1168
+ _.noop = function(){};
1169
+
1170
+ _.property = function(key) {
1171
+ return function(obj) {
1172
+ return obj[key];
1173
+ };
1174
+ };
1175
+
1176
+ // Returns a predicate for checking whether an object has a given set of `key:value` pairs.
1177
+ _.matches = function(attrs) {
1178
+ var pairs = _.pairs(attrs), length = pairs.length;
1179
+ return function(obj) {
1180
+ if (obj == null) return !length;
1181
+ obj = new Object(obj);
1182
+ for (var i = 0; i < length; i++) {
1183
+ var pair = pairs[i], key = pair[0];
1184
+ if (pair[1] !== obj[key] || !(key in obj)) return false;
1185
+ }
1186
+ return true;
1187
+ };
1188
+ };
1189
+
1190
+ // Run a function **n** times.
1191
+ _.times = function(n, iteratee, context) {
1192
+ var accum = Array(Math.max(0, n));
1193
+ iteratee = createCallback(iteratee, context, 1);
1194
+ for (var i = 0; i < n; i++) accum[i] = iteratee(i);
1195
+ return accum;
1196
+ };
1197
+
1198
+ // Return a random integer between min and max (inclusive).
1199
+ _.random = function(min, max) {
1200
+ if (max == null) {
1201
+ max = min;
1202
+ min = 0;
1203
+ }
1204
+ return min + Math.floor(Math.random() * (max - min + 1));
1205
+ };
1206
+
1207
+ // A (possibly faster) way to get the current timestamp as an integer.
1208
+ _.now = Date.now || function() {
1209
+ return new Date().getTime();
1210
+ };
1211
+
1212
+ // List of HTML entities for escaping.
1213
+ var escapeMap = {
1214
+ '&': '&amp;',
1215
+ '<': '&lt;',
1216
+ '>': '&gt;',
1217
+ '"': '&quot;',
1218
+ "'": '&#x27;',
1219
+ '`': '&#x60;'
1220
+ };
1221
+ var unescapeMap = _.invert(escapeMap);
1222
+
1223
+ // Functions for escaping and unescaping strings to/from HTML interpolation.
1224
+ var createEscaper = function(map) {
1225
+ var escaper = function(match) {
1226
+ return map[match];
1227
+ };
1228
+ // Regexes for identifying a key that needs to be escaped
1229
+ var source = '(?:' + _.keys(map).join('|') + ')';
1230
+ var testRegexp = RegExp(source);
1231
+ var replaceRegexp = RegExp(source, 'g');
1232
+ return function(string) {
1233
+ string = string == null ? '' : '' + string;
1234
+ return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
1235
+ };
1236
+ };
1237
+ _.escape = createEscaper(escapeMap);
1238
+ _.unescape = createEscaper(unescapeMap);
1239
+
1240
+ // If the value of the named `property` is a function then invoke it with the
1241
+ // `object` as context; otherwise, return it.
1242
+ _.result = function(object, property) {
1243
+ if (object == null) return void 0;
1244
+ var value = object[property];
1245
+ return _.isFunction(value) ? object[property]() : value;
1246
+ };
1247
+
1248
+ // Generate a unique integer id (unique within the entire client session).
1249
+ // Useful for temporary DOM ids.
1250
+ var idCounter = 0;
1251
+ _.uniqueId = function(prefix) {
1252
+ var id = ++idCounter + '';
1253
+ return prefix ? prefix + id : id;
1254
+ };
1255
+
1256
+ // By default, Underscore uses ERB-style template delimiters, change the
1257
+ // following template settings to use alternative delimiters.
1258
+ _.templateSettings = {
1259
+ evaluate : /<%([\s\S]+?)%>/g,
1260
+ interpolate : /<%=([\s\S]+?)%>/g,
1261
+ escape : /<%-([\s\S]+?)%>/g
1262
+ };
1263
+
1264
+ // When customizing `templateSettings`, if you don't want to define an
1265
+ // interpolation, evaluation or escaping regex, we need one that is
1266
+ // guaranteed not to match.
1267
+ var noMatch = /(.)^/;
1268
+
1269
+ // Certain characters need to be escaped so that they can be put into a
1270
+ // string literal.
1271
+ var escapes = {
1272
+ "'": "'",
1273
+ '\\': '\\',
1274
+ '\r': 'r',
1275
+ '\n': 'n',
1276
+ '\u2028': 'u2028',
1277
+ '\u2029': 'u2029'
1278
+ };
1279
+
1280
+ var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
1281
+
1282
+ var escapeChar = function(match) {
1283
+ return '\\' + escapes[match];
1284
+ };
1285
+
1286
+ // JavaScript micro-templating, similar to John Resig's implementation.
1287
+ // Underscore templating handles arbitrary delimiters, preserves whitespace,
1288
+ // and correctly escapes quotes within interpolated code.
1289
+ // NB: `oldSettings` only exists for backwards compatibility.
1290
+ _.template = function(text, settings, oldSettings) {
1291
+ if (!settings && oldSettings) settings = oldSettings;
1292
+ settings = _.defaults({}, settings, _.templateSettings);
1293
+
1294
+ // Combine delimiters into one regular expression via alternation.
1295
+ var matcher = RegExp([
1296
+ (settings.escape || noMatch).source,
1297
+ (settings.interpolate || noMatch).source,
1298
+ (settings.evaluate || noMatch).source
1299
+ ].join('|') + '|$', 'g');
1300
+
1301
+ // Compile the template source, escaping string literals appropriately.
1302
+ var index = 0;
1303
+ var source = "__p+='";
1304
+ text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
1305
+ source += text.slice(index, offset).replace(escaper, escapeChar);
1306
+ index = offset + match.length;
1307
+
1308
+ if (escape) {
1309
+ source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
1310
+ } else if (interpolate) {
1311
+ source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
1312
+ } else if (evaluate) {
1313
+ source += "';\n" + evaluate + "\n__p+='";
1314
+ }
1315
+
1316
+ // Adobe VMs need the match returned to produce the correct offest.
1317
+ return match;
1318
+ });
1319
+ source += "';\n";
1320
+
1321
+ // If a variable is not specified, place data values in local scope.
1322
+ if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
1323
+
1324
+ source = "var __t,__p='',__j=Array.prototype.join," +
1325
+ "print=function(){__p+=__j.call(arguments,'');};\n" +
1326
+ source + 'return __p;\n';
1327
+
1328
+ try {
1329
+ var render = new Function(settings.variable || 'obj', '_', source);
1330
+ } catch (e) {
1331
+ e.source = source;
1332
+ throw e;
1333
+ }
1334
+
1335
+ var template = function(data) {
1336
+ return render.call(this, data, _);
1337
+ };
1338
+
1339
+ // Provide the compiled source as a convenience for precompilation.
1340
+ var argument = settings.variable || 'obj';
1341
+ template.source = 'function(' + argument + '){\n' + source + '}';
1342
+
1343
+ return template;
1344
+ };
1345
+
1346
+ // Add a "chain" function. Start chaining a wrapped Underscore object.
1347
+ _.chain = function(obj) {
1348
+ var instance = _(obj);
1349
+ instance._chain = true;
1350
+ return instance;
1351
+ };
1352
+
1353
+ // OOP
1354
+ // ---------------
1355
+ // If Underscore is called as a function, it returns a wrapped object that
1356
+ // can be used OO-style. This wrapper holds altered versions of all the
1357
+ // underscore functions. Wrapped objects may be chained.
1358
+
1359
+ // Helper function to continue chaining intermediate results.
1360
+ var result = function(obj) {
1361
+ return this._chain ? _(obj).chain() : obj;
1362
+ };
1363
+
1364
+ // Add your own custom functions to the Underscore object.
1365
+ _.mixin = function(obj) {
1366
+ _.each(_.functions(obj), function(name) {
1367
+ var func = _[name] = obj[name];
1368
+ _.prototype[name] = function() {
1369
+ var args = [this._wrapped];
1370
+ push.apply(args, arguments);
1371
+ return result.call(this, func.apply(_, args));
1372
+ };
1373
+ });
1374
+ };
1375
+
1376
+ // Add all of the Underscore functions to the wrapper object.
1377
+ _.mixin(_);
1378
+
1379
+ // Add all mutator Array functions to the wrapper.
1380
+ _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
1381
+ var method = ArrayProto[name];
1382
+ _.prototype[name] = function() {
1383
+ var obj = this._wrapped;
1384
+ method.apply(obj, arguments);
1385
+ if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
1386
+ return result.call(this, obj);
1387
+ };
1388
+ });
1389
+
1390
+ // Add all accessor Array functions to the wrapper.
1391
+ _.each(['concat', 'join', 'slice'], function(name) {
1392
+ var method = ArrayProto[name];
1393
+ _.prototype[name] = function() {
1394
+ return result.call(this, method.apply(this._wrapped, arguments));
1395
+ };
1396
+ });
1397
+
1398
+ // Extracts the result from a wrapped and chained object.
1399
+ _.prototype.value = function() {
1400
+ return this._wrapped;
1401
+ };
1402
+
1403
+ // AMD registration happens at the end for compatibility with AMD loaders
1404
+ // that may not enforce next-turn semantics on modules. Even though general
1405
+ // practice for AMD registration is to be anonymous, underscore registers
1406
+ // as a named module because, like jQuery, it is a base library that is
1407
+ // popular enough to be bundled in a third party lib, but not be part of
1408
+ // an AMD load request. Those cases could generate an error when an
1409
+ // anonymous define() is called outside of a loader request.
1410
+ if (typeof define === 'function' && define.amd) {
1411
+ define('underscore', [], function() {
1412
+ return _;
1413
+ });
1414
+ }
1415
+ }.call(this));