gokart 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/assets/config/config-debug.json +22 -0
  2. data/assets/config/config-release.json +22 -0
  3. data/assets/config.rb +1 -1
  4. data/assets/src/server/config/config.go +46 -0
  5. data/assets/src/server/controller/home.go +43 -0
  6. data/assets/src/server/controller/static_assets.go +57 -0
  7. data/assets/src/server/main.go +59 -17
  8. data/assets/src/server/view/home.go +28 -0
  9. data/assets/src/www/app/erb_helpers/erb_helper.rb +4 -2
  10. data/assets/src/www/app/scripts/application.js.coffee +9 -4
  11. data/assets/src/www/app/scripts/pages/home.js +6 -0
  12. data/assets/src/www/app/scripts/vendor_wrapper.js +11 -0
  13. data/assets/src/www/app/templates/application.gotmpl +5 -2
  14. data/assets/src/www/app/templates/base.gotmpl.erb +1 -1
  15. data/assets/src/www/app/templates/{home.gotmpl → pages/home.gotmpl} +12 -7
  16. data/assets/src/www/app/templates/partials/test.gotmpl +3 -0
  17. data/assets/src/www/app/templates/partials/test2.gotmpl +5 -0
  18. data/assets/src/www/app/templates/partials_end.gotmpl +1 -0
  19. data/assets/src/www/app/templates/partials_start.gotmpl +1 -0
  20. data/assets/src/www/spec/all-spec.js +1 -1
  21. data/assets/src/www/spec/helpers/mocks.coffee +1 -1
  22. data/assets/src/www/vendor/js/backbone.js +1478 -0
  23. data/assets/src/www/vendor/js/mustache.js +625 -0
  24. data/assets/src/www/vendor/js/underscore-min.js +5 -0
  25. data/assets/src/www/vendor/js/underscore.js +1204 -0
  26. data/assets/tasks/server.rake +9 -9
  27. data/assets/tasks/www.rake +2 -18
  28. data/bin/gokart +7 -0
  29. data/lib/gokart/base.rb +1 -1
  30. data/lib/gokart/environment.rb +27 -1
  31. data/lib/gokart/version.rb +1 -1
  32. metadata +49 -38
  33. data/assets/src/server/http_handler.go +0 -139
  34. data/assets/src/server/my_test.go +0 -13
  35. data/assets/src/server/templates.go +0 -42
  36. data/assets/src/www/app/partials/index.html +0 -92
  37. data/assets/src/www/app/scripts/main.js.coffee +0 -9
@@ -0,0 +1,1204 @@
1
+ // Underscore.js 1.4.2
2
+ // http://underscorejs.org
3
+ // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
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 `global` on the server.
12
+ var root = this;
13
+
14
+ // Save the previous value of the `_` variable.
15
+ var previousUnderscore = root._;
16
+
17
+ // Establish the object that gets returned to break out of a loop iteration.
18
+ var breaker = {};
19
+
20
+ // Save bytes in the minified (but not gzipped) version:
21
+ var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
22
+
23
+ // Create quick reference variables for speed access to core prototypes.
24
+ var push = ArrayProto.push,
25
+ slice = ArrayProto.slice,
26
+ concat = ArrayProto.concat,
27
+ unshift = ArrayProto.unshift,
28
+ toString = ObjProto.toString,
29
+ hasOwnProperty = ObjProto.hasOwnProperty;
30
+
31
+ // All **ECMAScript 5** native function implementations that we hope to use
32
+ // are declared here.
33
+ var
34
+ nativeForEach = ArrayProto.forEach,
35
+ nativeMap = ArrayProto.map,
36
+ nativeReduce = ArrayProto.reduce,
37
+ nativeReduceRight = ArrayProto.reduceRight,
38
+ nativeFilter = ArrayProto.filter,
39
+ nativeEvery = ArrayProto.every,
40
+ nativeSome = ArrayProto.some,
41
+ nativeIndexOf = ArrayProto.indexOf,
42
+ nativeLastIndexOf = ArrayProto.lastIndexOf,
43
+ nativeIsArray = Array.isArray,
44
+ nativeKeys = Object.keys,
45
+ nativeBind = FuncProto.bind;
46
+
47
+ // Create a safe reference to the Underscore object for use below.
48
+ var _ = function(obj) {
49
+ if (obj instanceof _) return obj;
50
+ if (!(this instanceof _)) return new _(obj);
51
+ this._wrapped = obj;
52
+ };
53
+
54
+ // Export the Underscore object for **Node.js**, with
55
+ // backwards-compatibility for the old `require()` API. If we're in
56
+ // the browser, add `_` as a global object via a string identifier,
57
+ // for Closure Compiler "advanced" mode.
58
+ if (typeof exports !== 'undefined') {
59
+ if (typeof module !== 'undefined' && module.exports) {
60
+ exports = module.exports = _;
61
+ }
62
+ exports._ = _;
63
+ } else {
64
+ root._ = _;
65
+ }
66
+
67
+ // Current version.
68
+ _.VERSION = '1.4.2';
69
+
70
+ // Collection Functions
71
+ // --------------------
72
+
73
+ // The cornerstone, an `each` implementation, aka `forEach`.
74
+ // Handles objects with the built-in `forEach`, arrays, and raw objects.
75
+ // Delegates to **ECMAScript 5**'s native `forEach` if available.
76
+ var each = _.each = _.forEach = function(obj, iterator, context) {
77
+ if (obj == null) return;
78
+ if (nativeForEach && obj.forEach === nativeForEach) {
79
+ obj.forEach(iterator, context);
80
+ } else if (obj.length === +obj.length) {
81
+ for (var i = 0, l = obj.length; i < l; i++) {
82
+ if (iterator.call(context, obj[i], i, obj) === breaker) return;
83
+ }
84
+ } else {
85
+ for (var key in obj) {
86
+ if (_.has(obj, key)) {
87
+ if (iterator.call(context, obj[key], key, obj) === breaker) return;
88
+ }
89
+ }
90
+ }
91
+ };
92
+
93
+ // Return the results of applying the iterator to each element.
94
+ // Delegates to **ECMAScript 5**'s native `map` if available.
95
+ _.map = _.collect = function(obj, iterator, context) {
96
+ var results = [];
97
+ if (obj == null) return results;
98
+ if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
99
+ each(obj, function(value, index, list) {
100
+ results[results.length] = iterator.call(context, value, index, list);
101
+ });
102
+ return results;
103
+ };
104
+
105
+ // **Reduce** builds up a single result from a list of values, aka `inject`,
106
+ // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
107
+ _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
108
+ var initial = arguments.length > 2;
109
+ if (obj == null) obj = [];
110
+ if (nativeReduce && obj.reduce === nativeReduce) {
111
+ if (context) iterator = _.bind(iterator, context);
112
+ return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
113
+ }
114
+ each(obj, function(value, index, list) {
115
+ if (!initial) {
116
+ memo = value;
117
+ initial = true;
118
+ } else {
119
+ memo = iterator.call(context, memo, value, index, list);
120
+ }
121
+ });
122
+ if (!initial) throw new TypeError('Reduce of empty array with no initial value');
123
+ return memo;
124
+ };
125
+
126
+ // The right-associative version of reduce, also known as `foldr`.
127
+ // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
128
+ _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
129
+ var initial = arguments.length > 2;
130
+ if (obj == null) obj = [];
131
+ if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
132
+ if (context) iterator = _.bind(iterator, context);
133
+ return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
134
+ }
135
+ var length = obj.length;
136
+ if (length !== +length) {
137
+ var keys = _.keys(obj);
138
+ length = keys.length;
139
+ }
140
+ each(obj, function(value, index, list) {
141
+ index = keys ? keys[--length] : --length;
142
+ if (!initial) {
143
+ memo = obj[index];
144
+ initial = true;
145
+ } else {
146
+ memo = iterator.call(context, memo, obj[index], index, list);
147
+ }
148
+ });
149
+ if (!initial) throw new TypeError('Reduce of empty array with no initial value');
150
+ return memo;
151
+ };
152
+
153
+ // Return the first value which passes a truth test. Aliased as `detect`.
154
+ _.find = _.detect = function(obj, iterator, context) {
155
+ var result;
156
+ any(obj, function(value, index, list) {
157
+ if (iterator.call(context, value, index, list)) {
158
+ result = value;
159
+ return true;
160
+ }
161
+ });
162
+ return result;
163
+ };
164
+
165
+ // Return all the elements that pass a truth test.
166
+ // Delegates to **ECMAScript 5**'s native `filter` if available.
167
+ // Aliased as `select`.
168
+ _.filter = _.select = function(obj, iterator, context) {
169
+ var results = [];
170
+ if (obj == null) return results;
171
+ if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
172
+ each(obj, function(value, index, list) {
173
+ if (iterator.call(context, value, index, list)) results[results.length] = value;
174
+ });
175
+ return results;
176
+ };
177
+
178
+ // Return all the elements for which a truth test fails.
179
+ _.reject = function(obj, iterator, context) {
180
+ return _.filter(obj, function(value, index, list) {
181
+ return !iterator.call(context, value, index, list);
182
+ }, context);
183
+ };
184
+
185
+ // Determine whether all of the elements match a truth test.
186
+ // Delegates to **ECMAScript 5**'s native `every` if available.
187
+ // Aliased as `all`.
188
+ _.every = _.all = function(obj, iterator, context) {
189
+ iterator || (iterator = _.identity);
190
+ var result = true;
191
+ if (obj == null) return result;
192
+ if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
193
+ each(obj, function(value, index, list) {
194
+ if (!(result = result && iterator.call(context, value, index, list))) return breaker;
195
+ });
196
+ return !!result;
197
+ };
198
+
199
+ // Determine if at least one element in the object matches a truth test.
200
+ // Delegates to **ECMAScript 5**'s native `some` if available.
201
+ // Aliased as `any`.
202
+ var any = _.some = _.any = function(obj, iterator, context) {
203
+ iterator || (iterator = _.identity);
204
+ var result = false;
205
+ if (obj == null) return result;
206
+ if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
207
+ each(obj, function(value, index, list) {
208
+ if (result || (result = iterator.call(context, value, index, list))) return breaker;
209
+ });
210
+ return !!result;
211
+ };
212
+
213
+ // Determine if the array or object contains a given value (using `===`).
214
+ // Aliased as `include`.
215
+ _.contains = _.include = function(obj, target) {
216
+ if (obj == null) return false;
217
+ if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
218
+ return any(obj, function(value) {
219
+ return value === target;
220
+ });
221
+ };
222
+
223
+ // Invoke a method (with arguments) on every item in a collection.
224
+ _.invoke = function(obj, method) {
225
+ var args = slice.call(arguments, 2);
226
+ return _.map(obj, function(value) {
227
+ return (_.isFunction(method) ? method : value[method]).apply(value, args);
228
+ });
229
+ };
230
+
231
+ // Convenience version of a common use case of `map`: fetching a property.
232
+ _.pluck = function(obj, key) {
233
+ return _.map(obj, function(value){ return value[key]; });
234
+ };
235
+
236
+ // Convenience version of a common use case of `filter`: selecting only objects
237
+ // with specific `key:value` pairs.
238
+ _.where = function(obj, attrs) {
239
+ if (_.isEmpty(attrs)) return [];
240
+ return _.filter(obj, function(value) {
241
+ for (var key in attrs) {
242
+ if (_.has(attrs, key) && attrs[key] !== value[key]) return false;
243
+ }
244
+ return true;
245
+ });
246
+ };
247
+
248
+ // Return the maximum element or (element-based computation).
249
+ // Can't optimize arrays of integers longer than 65,535 elements.
250
+ // See: https://bugs.webkit.org/show_bug.cgi?id=80797
251
+ _.max = function(obj, iterator, context) {
252
+ if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
253
+ return Math.max.apply(Math, obj);
254
+ }
255
+ if (!iterator && _.isEmpty(obj)) return -Infinity;
256
+ var result = {computed : -Infinity, value: -Infinity};
257
+ each(obj, function(value, index, list) {
258
+ var computed = iterator ? iterator.call(context, value, index, list) : value;
259
+ computed >= result.computed && (result = {value : value, computed : computed});
260
+ });
261
+ return result.value;
262
+ };
263
+
264
+ // Return the minimum element (or element-based computation).
265
+ _.min = function(obj, iterator, context) {
266
+ if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
267
+ return Math.min.apply(Math, obj);
268
+ }
269
+ if (!iterator && _.isEmpty(obj)) return Infinity;
270
+ var result = {computed : Infinity, value: Infinity};
271
+ each(obj, function(value, index, list) {
272
+ var computed = iterator ? iterator.call(context, value, index, list) : value;
273
+ computed < result.computed && (result = {value : value, computed : computed});
274
+ });
275
+ return result.value;
276
+ };
277
+
278
+ // Shuffle an array.
279
+ _.shuffle = function(obj) {
280
+ var rand;
281
+ var index = 0;
282
+ var shuffled = [];
283
+ each(obj, function(value) {
284
+ rand = _.random(index++);
285
+ shuffled[index - 1] = shuffled[rand];
286
+ shuffled[rand] = value;
287
+ });
288
+ return shuffled;
289
+ };
290
+
291
+ // An internal function to generate lookup iterators.
292
+ var lookupIterator = function(value) {
293
+ return _.isFunction(value) ? value : function(obj){ return obj[value]; };
294
+ };
295
+
296
+ // Sort the object's values by a criterion produced by an iterator.
297
+ _.sortBy = function(obj, value, context) {
298
+ var iterator = lookupIterator(value);
299
+ return _.pluck(_.map(obj, function(value, index, list) {
300
+ return {
301
+ value : value,
302
+ index : index,
303
+ criteria : iterator.call(context, value, index, list)
304
+ };
305
+ }).sort(function(left, right) {
306
+ var a = left.criteria;
307
+ var b = right.criteria;
308
+ if (a !== b) {
309
+ if (a > b || a === void 0) return 1;
310
+ if (a < b || b === void 0) return -1;
311
+ }
312
+ return left.index < right.index ? -1 : 1;
313
+ }), 'value');
314
+ };
315
+
316
+ // An internal function used for aggregate "group by" operations.
317
+ var group = function(obj, value, context, behavior) {
318
+ var result = {};
319
+ var iterator = lookupIterator(value || _.identity);
320
+ each(obj, function(value, index) {
321
+ var key = iterator.call(context, value, index, obj);
322
+ behavior(result, key, value);
323
+ });
324
+ return result;
325
+ };
326
+
327
+ // Groups the object's values by a criterion. Pass either a string attribute
328
+ // to group by, or a function that returns the criterion.
329
+ _.groupBy = function(obj, value, context) {
330
+ return group(obj, value, context, function(result, key, value) {
331
+ (_.has(result, key) ? result[key] : (result[key] = [])).push(value);
332
+ });
333
+ };
334
+
335
+ // Counts instances of an object that group by a certain criterion. Pass
336
+ // either a string attribute to count by, or a function that returns the
337
+ // criterion.
338
+ _.countBy = function(obj, value, context) {
339
+ return group(obj, value, context, function(result, key, value) {
340
+ if (!_.has(result, key)) result[key] = 0;
341
+ result[key]++;
342
+ });
343
+ };
344
+
345
+ // Use a comparator function to figure out the smallest index at which
346
+ // an object should be inserted so as to maintain order. Uses binary search.
347
+ _.sortedIndex = function(array, obj, iterator, context) {
348
+ iterator = iterator == null ? _.identity : lookupIterator(iterator);
349
+ var value = iterator.call(context, obj);
350
+ var low = 0, high = array.length;
351
+ while (low < high) {
352
+ var mid = (low + high) >>> 1;
353
+ iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid;
354
+ }
355
+ return low;
356
+ };
357
+
358
+ // Safely convert anything iterable into a real, live array.
359
+ _.toArray = function(obj) {
360
+ if (!obj) return [];
361
+ if (obj.length === +obj.length) return slice.call(obj);
362
+ return _.values(obj);
363
+ };
364
+
365
+ // Return the number of elements in an object.
366
+ _.size = function(obj) {
367
+ if (obj == null) return 0;
368
+ return (obj.length === +obj.length) ? obj.length : _.keys(obj).length;
369
+ };
370
+
371
+ // Array Functions
372
+ // ---------------
373
+
374
+ // Get the first element of an array. Passing **n** will return the first N
375
+ // values in the array. Aliased as `head` and `take`. The **guard** check
376
+ // allows it to work with `_.map`.
377
+ _.first = _.head = _.take = function(array, n, guard) {
378
+ if (array == null) return void 0;
379
+ return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
380
+ };
381
+
382
+ // Returns everything but the last entry of the array. Especially useful on
383
+ // the arguments object. Passing **n** will return all the values in
384
+ // the array, excluding the last N. The **guard** check allows it to work with
385
+ // `_.map`.
386
+ _.initial = function(array, n, guard) {
387
+ return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
388
+ };
389
+
390
+ // Get the last element of an array. Passing **n** will return the last N
391
+ // values in the array. The **guard** check allows it to work with `_.map`.
392
+ _.last = function(array, n, guard) {
393
+ if (array == null) return void 0;
394
+ if ((n != null) && !guard) {
395
+ return slice.call(array, Math.max(array.length - n, 0));
396
+ } else {
397
+ return array[array.length - 1];
398
+ }
399
+ };
400
+
401
+ // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
402
+ // Especially useful on the arguments object. Passing an **n** will return
403
+ // the rest N values in the array. The **guard**
404
+ // check allows it to work with `_.map`.
405
+ _.rest = _.tail = _.drop = function(array, n, guard) {
406
+ return slice.call(array, (n == null) || guard ? 1 : n);
407
+ };
408
+
409
+ // Trim out all falsy values from an array.
410
+ _.compact = function(array) {
411
+ return _.filter(array, function(value){ return !!value; });
412
+ };
413
+
414
+ // Internal implementation of a recursive `flatten` function.
415
+ var flatten = function(input, shallow, output) {
416
+ each(input, function(value) {
417
+ if (_.isArray(value)) {
418
+ shallow ? push.apply(output, value) : flatten(value, shallow, output);
419
+ } else {
420
+ output.push(value);
421
+ }
422
+ });
423
+ return output;
424
+ };
425
+
426
+ // Return a completely flattened version of an array.
427
+ _.flatten = function(array, shallow) {
428
+ return flatten(array, shallow, []);
429
+ };
430
+
431
+ // Return a version of the array that does not contain the specified value(s).
432
+ _.without = function(array) {
433
+ return _.difference(array, slice.call(arguments, 1));
434
+ };
435
+
436
+ // Produce a duplicate-free version of the array. If the array has already
437
+ // been sorted, you have the option of using a faster algorithm.
438
+ // Aliased as `unique`.
439
+ _.uniq = _.unique = function(array, isSorted, iterator, context) {
440
+ if (_.isFunction(isSorted)) {
441
+ context = iterator;
442
+ iterator = isSorted;
443
+ isSorted = false;
444
+ }
445
+ var initial = iterator ? _.map(array, iterator, context) : array;
446
+ var results = [];
447
+ var seen = [];
448
+ each(initial, function(value, index) {
449
+ if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) {
450
+ seen.push(value);
451
+ results.push(array[index]);
452
+ }
453
+ });
454
+ return results;
455
+ };
456
+
457
+ // Produce an array that contains the union: each distinct element from all of
458
+ // the passed-in arrays.
459
+ _.union = function() {
460
+ return _.uniq(concat.apply(ArrayProto, arguments));
461
+ };
462
+
463
+ // Produce an array that contains every item shared between all the
464
+ // passed-in arrays.
465
+ _.intersection = function(array) {
466
+ var rest = slice.call(arguments, 1);
467
+ return _.filter(_.uniq(array), function(item) {
468
+ return _.every(rest, function(other) {
469
+ return _.indexOf(other, item) >= 0;
470
+ });
471
+ });
472
+ };
473
+
474
+ // Take the difference between one array and a number of other arrays.
475
+ // Only the elements present in just the first array will remain.
476
+ _.difference = function(array) {
477
+ var rest = concat.apply(ArrayProto, slice.call(arguments, 1));
478
+ return _.filter(array, function(value){ return !_.contains(rest, value); });
479
+ };
480
+
481
+ // Zip together multiple lists into a single array -- elements that share
482
+ // an index go together.
483
+ _.zip = function() {
484
+ var args = slice.call(arguments);
485
+ var length = _.max(_.pluck(args, 'length'));
486
+ var results = new Array(length);
487
+ for (var i = 0; i < length; i++) {
488
+ results[i] = _.pluck(args, "" + i);
489
+ }
490
+ return results;
491
+ };
492
+
493
+ // Converts lists into objects. Pass either a single array of `[key, value]`
494
+ // pairs, or two parallel arrays of the same length -- one of keys, and one of
495
+ // the corresponding values.
496
+ _.object = function(list, values) {
497
+ if (list == null) return {};
498
+ var result = {};
499
+ for (var i = 0, l = list.length; i < l; i++) {
500
+ if (values) {
501
+ result[list[i]] = values[i];
502
+ } else {
503
+ result[list[i][0]] = list[i][1];
504
+ }
505
+ }
506
+ return result;
507
+ };
508
+
509
+ // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
510
+ // we need this function. Return the position of the first occurrence of an
511
+ // item in an array, or -1 if the item is not included in the array.
512
+ // Delegates to **ECMAScript 5**'s native `indexOf` if available.
513
+ // If the array is large and already in sort order, pass `true`
514
+ // for **isSorted** to use binary search.
515
+ _.indexOf = function(array, item, isSorted) {
516
+ if (array == null) return -1;
517
+ var i = 0, l = array.length;
518
+ if (isSorted) {
519
+ if (typeof isSorted == 'number') {
520
+ i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted);
521
+ } else {
522
+ i = _.sortedIndex(array, item);
523
+ return array[i] === item ? i : -1;
524
+ }
525
+ }
526
+ if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted);
527
+ for (; i < l; i++) if (array[i] === item) return i;
528
+ return -1;
529
+ };
530
+
531
+ // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
532
+ _.lastIndexOf = function(array, item, from) {
533
+ if (array == null) return -1;
534
+ var hasIndex = from != null;
535
+ if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) {
536
+ return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item);
537
+ }
538
+ var i = (hasIndex ? from : array.length);
539
+ while (i--) if (array[i] === item) return i;
540
+ return -1;
541
+ };
542
+
543
+ // Generate an integer Array containing an arithmetic progression. A port of
544
+ // the native Python `range()` function. See
545
+ // [the Python documentation](http://docs.python.org/library/functions.html#range).
546
+ _.range = function(start, stop, step) {
547
+ if (arguments.length <= 1) {
548
+ stop = start || 0;
549
+ start = 0;
550
+ }
551
+ step = arguments[2] || 1;
552
+
553
+ var len = Math.max(Math.ceil((stop - start) / step), 0);
554
+ var idx = 0;
555
+ var range = new Array(len);
556
+
557
+ while(idx < len) {
558
+ range[idx++] = start;
559
+ start += step;
560
+ }
561
+
562
+ return range;
563
+ };
564
+
565
+ // Function (ahem) Functions
566
+ // ------------------
567
+
568
+ // Reusable constructor function for prototype setting.
569
+ var ctor = function(){};
570
+
571
+ // Create a function bound to a given object (assigning `this`, and arguments,
572
+ // optionally). Binding with arguments is also known as `curry`.
573
+ // Delegates to **ECMAScript 5**'s native `Function.bind` if available.
574
+ // We check for `func.bind` first, to fail fast when `func` is undefined.
575
+ _.bind = function bind(func, context) {
576
+ var bound, args;
577
+ if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
578
+ if (!_.isFunction(func)) throw new TypeError;
579
+ args = slice.call(arguments, 2);
580
+ return bound = function() {
581
+ if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
582
+ ctor.prototype = func.prototype;
583
+ var self = new ctor;
584
+ var result = func.apply(self, args.concat(slice.call(arguments)));
585
+ if (Object(result) === result) return result;
586
+ return self;
587
+ };
588
+ };
589
+
590
+ // Bind all of an object's methods to that object. Useful for ensuring that
591
+ // all callbacks defined on an object belong to it.
592
+ _.bindAll = function(obj) {
593
+ var funcs = slice.call(arguments, 1);
594
+ if (funcs.length == 0) funcs = _.functions(obj);
595
+ each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
596
+ return obj;
597
+ };
598
+
599
+ // Memoize an expensive function by storing its results.
600
+ _.memoize = function(func, hasher) {
601
+ var memo = {};
602
+ hasher || (hasher = _.identity);
603
+ return function() {
604
+ var key = hasher.apply(this, arguments);
605
+ return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
606
+ };
607
+ };
608
+
609
+ // Delays a function for the given number of milliseconds, and then calls
610
+ // it with the arguments supplied.
611
+ _.delay = function(func, wait) {
612
+ var args = slice.call(arguments, 2);
613
+ return setTimeout(function(){ return func.apply(null, args); }, wait);
614
+ };
615
+
616
+ // Defers a function, scheduling it to run after the current call stack has
617
+ // cleared.
618
+ _.defer = function(func) {
619
+ return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
620
+ };
621
+
622
+ // Returns a function, that, when invoked, will only be triggered at most once
623
+ // during a given window of time.
624
+ _.throttle = function(func, wait) {
625
+ var context, args, timeout, result;
626
+ var previous = 0;
627
+ var later = function() {
628
+ previous = new Date;
629
+ timeout = null;
630
+ result = func.apply(context, args);
631
+ };
632
+ return function() {
633
+ var now = new Date;
634
+ var remaining = wait - (now - previous);
635
+ context = this;
636
+ args = arguments;
637
+ if (remaining <= 0) {
638
+ clearTimeout(timeout);
639
+ previous = now;
640
+ result = func.apply(context, args);
641
+ } else if (!timeout) {
642
+ timeout = setTimeout(later, remaining);
643
+ }
644
+ return result;
645
+ };
646
+ };
647
+
648
+ // Returns a function, that, as long as it continues to be invoked, will not
649
+ // be triggered. The function will be called after it stops being called for
650
+ // N milliseconds. If `immediate` is passed, trigger the function on the
651
+ // leading edge, instead of the trailing.
652
+ _.debounce = function(func, wait, immediate) {
653
+ var timeout, result;
654
+ return function() {
655
+ var context = this, args = arguments;
656
+ var later = function() {
657
+ timeout = null;
658
+ if (!immediate) result = func.apply(context, args);
659
+ };
660
+ var callNow = immediate && !timeout;
661
+ clearTimeout(timeout);
662
+ timeout = setTimeout(later, wait);
663
+ if (callNow) result = func.apply(context, args);
664
+ return result;
665
+ };
666
+ };
667
+
668
+ // Returns a function that will be executed at most one time, no matter how
669
+ // often you call it. Useful for lazy initialization.
670
+ _.once = function(func) {
671
+ var ran = false, memo;
672
+ return function() {
673
+ if (ran) return memo;
674
+ ran = true;
675
+ memo = func.apply(this, arguments);
676
+ func = null;
677
+ return memo;
678
+ };
679
+ };
680
+
681
+ // Returns the first function passed as an argument to the second,
682
+ // allowing you to adjust arguments, run code before and after, and
683
+ // conditionally execute the original function.
684
+ _.wrap = function(func, wrapper) {
685
+ return function() {
686
+ var args = [func];
687
+ push.apply(args, arguments);
688
+ return wrapper.apply(this, args);
689
+ };
690
+ };
691
+
692
+ // Returns a function that is the composition of a list of functions, each
693
+ // consuming the return value of the function that follows.
694
+ _.compose = function() {
695
+ var funcs = arguments;
696
+ return function() {
697
+ var args = arguments;
698
+ for (var i = funcs.length - 1; i >= 0; i--) {
699
+ args = [funcs[i].apply(this, args)];
700
+ }
701
+ return args[0];
702
+ };
703
+ };
704
+
705
+ // Returns a function that will only be executed after being called N times.
706
+ _.after = function(times, func) {
707
+ if (times <= 0) return func();
708
+ return function() {
709
+ if (--times < 1) {
710
+ return func.apply(this, arguments);
711
+ }
712
+ };
713
+ };
714
+
715
+ // Object Functions
716
+ // ----------------
717
+
718
+ // Retrieve the names of an object's properties.
719
+ // Delegates to **ECMAScript 5**'s native `Object.keys`
720
+ _.keys = nativeKeys || function(obj) {
721
+ if (obj !== Object(obj)) throw new TypeError('Invalid object');
722
+ var keys = [];
723
+ for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
724
+ return keys;
725
+ };
726
+
727
+ // Retrieve the values of an object's properties.
728
+ _.values = function(obj) {
729
+ var values = [];
730
+ for (var key in obj) if (_.has(obj, key)) values.push(obj[key]);
731
+ return values;
732
+ };
733
+
734
+ // Convert an object into a list of `[key, value]` pairs.
735
+ _.pairs = function(obj) {
736
+ var pairs = [];
737
+ for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]);
738
+ return pairs;
739
+ };
740
+
741
+ // Invert the keys and values of an object. The values must be serializable.
742
+ _.invert = function(obj) {
743
+ var result = {};
744
+ for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key;
745
+ return result;
746
+ };
747
+
748
+ // Return a sorted list of the function names available on the object.
749
+ // Aliased as `methods`
750
+ _.functions = _.methods = function(obj) {
751
+ var names = [];
752
+ for (var key in obj) {
753
+ if (_.isFunction(obj[key])) names.push(key);
754
+ }
755
+ return names.sort();
756
+ };
757
+
758
+ // Extend a given object with all the properties in passed-in object(s).
759
+ _.extend = function(obj) {
760
+ each(slice.call(arguments, 1), function(source) {
761
+ for (var prop in source) {
762
+ obj[prop] = source[prop];
763
+ }
764
+ });
765
+ return obj;
766
+ };
767
+
768
+ // Return a copy of the object only containing the whitelisted properties.
769
+ _.pick = function(obj) {
770
+ var copy = {};
771
+ var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
772
+ each(keys, function(key) {
773
+ if (key in obj) copy[key] = obj[key];
774
+ });
775
+ return copy;
776
+ };
777
+
778
+ // Return a copy of the object without the blacklisted properties.
779
+ _.omit = function(obj) {
780
+ var copy = {};
781
+ var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
782
+ for (var key in obj) {
783
+ if (!_.contains(keys, key)) copy[key] = obj[key];
784
+ }
785
+ return copy;
786
+ };
787
+
788
+ // Fill in a given object with default properties.
789
+ _.defaults = function(obj) {
790
+ each(slice.call(arguments, 1), function(source) {
791
+ for (var prop in source) {
792
+ if (obj[prop] == null) obj[prop] = source[prop];
793
+ }
794
+ });
795
+ return obj;
796
+ };
797
+
798
+ // Create a (shallow-cloned) duplicate of an object.
799
+ _.clone = function(obj) {
800
+ if (!_.isObject(obj)) return obj;
801
+ return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
802
+ };
803
+
804
+ // Invokes interceptor with the obj, and then returns obj.
805
+ // The primary purpose of this method is to "tap into" a method chain, in
806
+ // order to perform operations on intermediate results within the chain.
807
+ _.tap = function(obj, interceptor) {
808
+ interceptor(obj);
809
+ return obj;
810
+ };
811
+
812
+ // Internal recursive comparison function for `isEqual`.
813
+ var eq = function(a, b, aStack, bStack) {
814
+ // Identical objects are equal. `0 === -0`, but they aren't identical.
815
+ // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
816
+ if (a === b) return a !== 0 || 1 / a == 1 / b;
817
+ // A strict comparison is necessary because `null == undefined`.
818
+ if (a == null || b == null) return a === b;
819
+ // Unwrap any wrapped objects.
820
+ if (a instanceof _) a = a._wrapped;
821
+ if (b instanceof _) b = b._wrapped;
822
+ // Compare `[[Class]]` names.
823
+ var className = toString.call(a);
824
+ if (className != toString.call(b)) return false;
825
+ switch (className) {
826
+ // Strings, numbers, dates, and booleans are compared by value.
827
+ case '[object String]':
828
+ // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
829
+ // equivalent to `new String("5")`.
830
+ return a == String(b);
831
+ case '[object Number]':
832
+ // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
833
+ // other numeric values.
834
+ return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
835
+ case '[object Date]':
836
+ case '[object Boolean]':
837
+ // Coerce dates and booleans to numeric primitive values. Dates are compared by their
838
+ // millisecond representations. Note that invalid dates with millisecond representations
839
+ // of `NaN` are not equivalent.
840
+ return +a == +b;
841
+ // RegExps are compared by their source patterns and flags.
842
+ case '[object RegExp]':
843
+ return a.source == b.source &&
844
+ a.global == b.global &&
845
+ a.multiline == b.multiline &&
846
+ a.ignoreCase == b.ignoreCase;
847
+ }
848
+ if (typeof a != 'object' || typeof b != 'object') return false;
849
+ // Assume equality for cyclic structures. The algorithm for detecting cyclic
850
+ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
851
+ var length = aStack.length;
852
+ while (length--) {
853
+ // Linear search. Performance is inversely proportional to the number of
854
+ // unique nested structures.
855
+ if (aStack[length] == a) return bStack[length] == b;
856
+ }
857
+ // Add the first object to the stack of traversed objects.
858
+ aStack.push(a);
859
+ bStack.push(b);
860
+ var size = 0, result = true;
861
+ // Recursively compare objects and arrays.
862
+ if (className == '[object Array]') {
863
+ // Compare array lengths to determine if a deep comparison is necessary.
864
+ size = a.length;
865
+ result = size == b.length;
866
+ if (result) {
867
+ // Deep compare the contents, ignoring non-numeric properties.
868
+ while (size--) {
869
+ if (!(result = eq(a[size], b[size], aStack, bStack))) break;
870
+ }
871
+ }
872
+ } else {
873
+ // Objects with different constructors are not equivalent, but `Object`s
874
+ // from different frames are.
875
+ var aCtor = a.constructor, bCtor = b.constructor;
876
+ if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
877
+ _.isFunction(bCtor) && (bCtor instanceof bCtor))) {
878
+ return false;
879
+ }
880
+ // Deep compare objects.
881
+ for (var key in a) {
882
+ if (_.has(a, key)) {
883
+ // Count the expected number of properties.
884
+ size++;
885
+ // Deep compare each member.
886
+ if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
887
+ }
888
+ }
889
+ // Ensure that both objects contain the same number of properties.
890
+ if (result) {
891
+ for (key in b) {
892
+ if (_.has(b, key) && !(size--)) break;
893
+ }
894
+ result = !size;
895
+ }
896
+ }
897
+ // Remove the first object from the stack of traversed objects.
898
+ aStack.pop();
899
+ bStack.pop();
900
+ return result;
901
+ };
902
+
903
+ // Perform a deep comparison to check if two objects are equal.
904
+ _.isEqual = function(a, b) {
905
+ return eq(a, b, [], []);
906
+ };
907
+
908
+ // Is a given array, string, or object empty?
909
+ // An "empty" object has no enumerable own-properties.
910
+ _.isEmpty = function(obj) {
911
+ if (obj == null) return true;
912
+ if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
913
+ for (var key in obj) if (_.has(obj, key)) return false;
914
+ return true;
915
+ };
916
+
917
+ // Is a given value a DOM element?
918
+ _.isElement = function(obj) {
919
+ return !!(obj && obj.nodeType === 1);
920
+ };
921
+
922
+ // Is a given value an array?
923
+ // Delegates to ECMA5's native Array.isArray
924
+ _.isArray = nativeIsArray || function(obj) {
925
+ return toString.call(obj) == '[object Array]';
926
+ };
927
+
928
+ // Is a given variable an object?
929
+ _.isObject = function(obj) {
930
+ return obj === Object(obj);
931
+ };
932
+
933
+ // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
934
+ each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
935
+ _['is' + name] = function(obj) {
936
+ return toString.call(obj) == '[object ' + name + ']';
937
+ };
938
+ });
939
+
940
+ // Define a fallback version of the method in browsers (ahem, IE), where
941
+ // there isn't any inspectable "Arguments" type.
942
+ if (!_.isArguments(arguments)) {
943
+ _.isArguments = function(obj) {
944
+ return !!(obj && _.has(obj, 'callee'));
945
+ };
946
+ }
947
+
948
+ // Optimize `isFunction` if appropriate.
949
+ if (typeof (/./) !== 'function') {
950
+ _.isFunction = function(obj) {
951
+ return typeof obj === 'function';
952
+ };
953
+ }
954
+
955
+ // Is a given object a finite number?
956
+ _.isFinite = function(obj) {
957
+ return isFinite( obj ) && !isNaN( parseFloat(obj) );
958
+ };
959
+
960
+ // Is the given value `NaN`? (NaN is the only number which does not equal itself).
961
+ _.isNaN = function(obj) {
962
+ return _.isNumber(obj) && obj != +obj;
963
+ };
964
+
965
+ // Is a given value a boolean?
966
+ _.isBoolean = function(obj) {
967
+ return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
968
+ };
969
+
970
+ // Is a given value equal to null?
971
+ _.isNull = function(obj) {
972
+ return obj === null;
973
+ };
974
+
975
+ // Is a given variable undefined?
976
+ _.isUndefined = function(obj) {
977
+ return obj === void 0;
978
+ };
979
+
980
+ // Shortcut function for checking if an object has a given property directly
981
+ // on itself (in other words, not on a prototype).
982
+ _.has = function(obj, key) {
983
+ return hasOwnProperty.call(obj, key);
984
+ };
985
+
986
+ // Utility Functions
987
+ // -----------------
988
+
989
+ // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
990
+ // previous owner. Returns a reference to the Underscore object.
991
+ _.noConflict = function() {
992
+ root._ = previousUnderscore;
993
+ return this;
994
+ };
995
+
996
+ // Keep the identity function around for default iterators.
997
+ _.identity = function(value) {
998
+ return value;
999
+ };
1000
+
1001
+ // Run a function **n** times.
1002
+ _.times = function(n, iterator, context) {
1003
+ for (var i = 0; i < n; i++) iterator.call(context, i);
1004
+ };
1005
+
1006
+ // Return a random integer between min and max (inclusive).
1007
+ _.random = function(min, max) {
1008
+ if (max == null) {
1009
+ max = min;
1010
+ min = 0;
1011
+ }
1012
+ return min + (0 | Math.random() * (max - min + 1));
1013
+ };
1014
+
1015
+ // List of HTML entities for escaping.
1016
+ var entityMap = {
1017
+ escape: {
1018
+ '&': '&amp;',
1019
+ '<': '&lt;',
1020
+ '>': '&gt;',
1021
+ '"': '&quot;',
1022
+ "'": '&#x27;',
1023
+ '/': '&#x2F;'
1024
+ }
1025
+ };
1026
+ entityMap.unescape = _.invert(entityMap.escape);
1027
+
1028
+ // Regexes containing the keys and values listed immediately above.
1029
+ var entityRegexes = {
1030
+ escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'),
1031
+ unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g')
1032
+ };
1033
+
1034
+ // Functions for escaping and unescaping strings to/from HTML interpolation.
1035
+ _.each(['escape', 'unescape'], function(method) {
1036
+ _[method] = function(string) {
1037
+ if (string == null) return '';
1038
+ return ('' + string).replace(entityRegexes[method], function(match) {
1039
+ return entityMap[method][match];
1040
+ });
1041
+ };
1042
+ });
1043
+
1044
+ // If the value of the named property is a function then invoke it;
1045
+ // otherwise, return it.
1046
+ _.result = function(object, property) {
1047
+ if (object == null) return null;
1048
+ var value = object[property];
1049
+ return _.isFunction(value) ? value.call(object) : value;
1050
+ };
1051
+
1052
+ // Add your own custom functions to the Underscore object.
1053
+ _.mixin = function(obj) {
1054
+ each(_.functions(obj), function(name){
1055
+ var func = _[name] = obj[name];
1056
+ _.prototype[name] = function() {
1057
+ var args = [this._wrapped];
1058
+ push.apply(args, arguments);
1059
+ return result.call(this, func.apply(_, args));
1060
+ };
1061
+ });
1062
+ };
1063
+
1064
+ // Generate a unique integer id (unique within the entire client session).
1065
+ // Useful for temporary DOM ids.
1066
+ var idCounter = 0;
1067
+ _.uniqueId = function(prefix) {
1068
+ var id = idCounter++;
1069
+ return prefix ? prefix + id : id;
1070
+ };
1071
+
1072
+ // By default, Underscore uses ERB-style template delimiters, change the
1073
+ // following template settings to use alternative delimiters.
1074
+ _.templateSettings = {
1075
+ evaluate : /<%([\s\S]+?)%>/g,
1076
+ interpolate : /<%=([\s\S]+?)%>/g,
1077
+ escape : /<%-([\s\S]+?)%>/g
1078
+ };
1079
+
1080
+ // When customizing `templateSettings`, if you don't want to define an
1081
+ // interpolation, evaluation or escaping regex, we need one that is
1082
+ // guaranteed not to match.
1083
+ var noMatch = /(.)^/;
1084
+
1085
+ // Certain characters need to be escaped so that they can be put into a
1086
+ // string literal.
1087
+ var escapes = {
1088
+ "'": "'",
1089
+ '\\': '\\',
1090
+ '\r': 'r',
1091
+ '\n': 'n',
1092
+ '\t': 't',
1093
+ '\u2028': 'u2028',
1094
+ '\u2029': 'u2029'
1095
+ };
1096
+
1097
+ var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
1098
+
1099
+ // JavaScript micro-templating, similar to John Resig's implementation.
1100
+ // Underscore templating handles arbitrary delimiters, preserves whitespace,
1101
+ // and correctly escapes quotes within interpolated code.
1102
+ _.template = function(text, data, settings) {
1103
+ settings = _.defaults({}, settings, _.templateSettings);
1104
+
1105
+ // Combine delimiters into one regular expression via alternation.
1106
+ var matcher = new RegExp([
1107
+ (settings.escape || noMatch).source,
1108
+ (settings.interpolate || noMatch).source,
1109
+ (settings.evaluate || noMatch).source
1110
+ ].join('|') + '|$', 'g');
1111
+
1112
+ // Compile the template source, escaping string literals appropriately.
1113
+ var index = 0;
1114
+ var source = "__p+='";
1115
+ text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
1116
+ source += text.slice(index, offset)
1117
+ .replace(escaper, function(match) { return '\\' + escapes[match]; });
1118
+ source +=
1119
+ escape ? "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'" :
1120
+ interpolate ? "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'" :
1121
+ evaluate ? "';\n" + evaluate + "\n__p+='" : '';
1122
+ index = offset + match.length;
1123
+ });
1124
+ source += "';\n";
1125
+
1126
+ // If a variable is not specified, place data values in local scope.
1127
+ if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
1128
+
1129
+ source = "var __t,__p='',__j=Array.prototype.join," +
1130
+ "print=function(){__p+=__j.call(arguments,'');};\n" +
1131
+ source + "return __p;\n";
1132
+
1133
+ try {
1134
+ var render = new Function(settings.variable || 'obj', '_', source);
1135
+ } catch (e) {
1136
+ e.source = source;
1137
+ throw e;
1138
+ }
1139
+
1140
+ if (data) return render(data, _);
1141
+ var template = function(data) {
1142
+ return render.call(this, data, _);
1143
+ };
1144
+
1145
+ // Provide the compiled function source as a convenience for precompilation.
1146
+ template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}';
1147
+
1148
+ return template;
1149
+ };
1150
+
1151
+ // Add a "chain" function, which will delegate to the wrapper.
1152
+ _.chain = function(obj) {
1153
+ return _(obj).chain();
1154
+ };
1155
+
1156
+ // OOP
1157
+ // ---------------
1158
+ // If Underscore is called as a function, it returns a wrapped object that
1159
+ // can be used OO-style. This wrapper holds altered versions of all the
1160
+ // underscore functions. Wrapped objects may be chained.
1161
+
1162
+ // Helper function to continue chaining intermediate results.
1163
+ var result = function(obj) {
1164
+ return this._chain ? _(obj).chain() : obj;
1165
+ };
1166
+
1167
+ // Add all of the Underscore functions to the wrapper object.
1168
+ _.mixin(_);
1169
+
1170
+ // Add all mutator Array functions to the wrapper.
1171
+ each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
1172
+ var method = ArrayProto[name];
1173
+ _.prototype[name] = function() {
1174
+ var obj = this._wrapped;
1175
+ method.apply(obj, arguments);
1176
+ if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0];
1177
+ return result.call(this, obj);
1178
+ };
1179
+ });
1180
+
1181
+ // Add all accessor Array functions to the wrapper.
1182
+ each(['concat', 'join', 'slice'], function(name) {
1183
+ var method = ArrayProto[name];
1184
+ _.prototype[name] = function() {
1185
+ return result.call(this, method.apply(this._wrapped, arguments));
1186
+ };
1187
+ });
1188
+
1189
+ _.extend(_.prototype, {
1190
+
1191
+ // Start chaining a wrapped Underscore object.
1192
+ chain: function() {
1193
+ this._chain = true;
1194
+ return this;
1195
+ },
1196
+
1197
+ // Extracts the result from a wrapped and chained object.
1198
+ value: function() {
1199
+ return this._wrapped;
1200
+ }
1201
+
1202
+ });
1203
+
1204
+ }).call(this);