underscore-rails 1.8.2 → 1.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/underscore-rails/version.rb +1 -1
- data/vendor/assets/javascripts/underscore.js +71 -59
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a008d80de418155c46e0bf3ff3d5bf900e345e29
|
4
|
+
data.tar.gz: 0d2d31ed44f7e2111f89a36b08aa64dc2098b475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cd5241459324537261917568fa0d95aacf9934d875621dbe115c4c1e6d29177efc8e844929378959947fcca575a585f629a5d07d3095bee72ed1ab2a00d3b29
|
7
|
+
data.tar.gz: 0470722ea6b70b43696b47f18c585f3328c33f90968e037858a31032e4a56630aa3946ba1488b106ebca9671a0d040be78a58b0456bbb7e8c28648c106e8d3f2
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Underscore.js 1.8.
|
1
|
+
// Underscore.js 1.8.3
|
2
2
|
// http://underscorejs.org
|
3
3
|
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
4
4
|
// Underscore may be freely distributed under the MIT license.
|
@@ -55,7 +55,7 @@
|
|
55
55
|
}
|
56
56
|
|
57
57
|
// Current version.
|
58
|
-
_.VERSION = '1.8.
|
58
|
+
_.VERSION = '1.8.3';
|
59
59
|
|
60
60
|
// Internal function that returns an efficient (for current engines) version
|
61
61
|
// of the passed-in callback, to be repeatedly applied in other Underscore
|
@@ -122,12 +122,20 @@
|
|
122
122
|
return result;
|
123
123
|
};
|
124
124
|
|
125
|
+
var property = function(key) {
|
126
|
+
return function(obj) {
|
127
|
+
return obj == null ? void 0 : obj[key];
|
128
|
+
};
|
129
|
+
};
|
130
|
+
|
125
131
|
// Helper for collection methods to determine whether a collection
|
126
132
|
// should be iterated as an array or as an object
|
127
133
|
// Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
|
134
|
+
// Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
|
128
135
|
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
|
136
|
+
var getLength = property('length');
|
129
137
|
var isArrayLike = function(collection) {
|
130
|
-
var length = collection
|
138
|
+
var length = getLength(collection);
|
131
139
|
return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
|
132
140
|
};
|
133
141
|
|
@@ -252,11 +260,12 @@
|
|
252
260
|
return false;
|
253
261
|
};
|
254
262
|
|
255
|
-
// Determine if the array or object contains a given
|
263
|
+
// Determine if the array or object contains a given item (using `===`).
|
256
264
|
// Aliased as `includes` and `include`.
|
257
|
-
_.contains = _.includes = _.include = function(obj,
|
265
|
+
_.contains = _.includes = _.include = function(obj, item, fromIndex, guard) {
|
258
266
|
if (!isArrayLike(obj)) obj = _.values(obj);
|
259
|
-
|
267
|
+
if (typeof fromIndex != 'number' || guard) fromIndex = 0;
|
268
|
+
return _.indexOf(obj, item, fromIndex) >= 0;
|
260
269
|
};
|
261
270
|
|
262
271
|
// Invoke a method (with arguments) on every item in a collection.
|
@@ -480,7 +489,7 @@
|
|
480
489
|
// Internal implementation of a recursive `flatten` function.
|
481
490
|
var flatten = function(input, shallow, strict, startIndex) {
|
482
491
|
var output = [], idx = 0;
|
483
|
-
for (var i = startIndex || 0, length = input
|
492
|
+
for (var i = startIndex || 0, length = getLength(input); i < length; i++) {
|
484
493
|
var value = input[i];
|
485
494
|
if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
|
486
495
|
//flatten current level of array or arguments object
|
@@ -511,7 +520,6 @@
|
|
511
520
|
// been sorted, you have the option of using a faster algorithm.
|
512
521
|
// Aliased as `unique`.
|
513
522
|
_.uniq = _.unique = function(array, isSorted, iteratee, context) {
|
514
|
-
if (array == null) return [];
|
515
523
|
if (!_.isBoolean(isSorted)) {
|
516
524
|
context = iteratee;
|
517
525
|
iteratee = isSorted;
|
@@ -520,7 +528,7 @@
|
|
520
528
|
if (iteratee != null) iteratee = cb(iteratee, context);
|
521
529
|
var result = [];
|
522
530
|
var seen = [];
|
523
|
-
for (var i = 0, length = array
|
531
|
+
for (var i = 0, length = getLength(array); i < length; i++) {
|
524
532
|
var value = array[i],
|
525
533
|
computed = iteratee ? iteratee(value, i, array) : value;
|
526
534
|
if (isSorted) {
|
@@ -547,10 +555,9 @@
|
|
547
555
|
// Produce an array that contains every item shared between all the
|
548
556
|
// passed-in arrays.
|
549
557
|
_.intersection = function(array) {
|
550
|
-
if (array == null) return [];
|
551
558
|
var result = [];
|
552
559
|
var argsLength = arguments.length;
|
553
|
-
for (var i = 0, length = array
|
560
|
+
for (var i = 0, length = getLength(array); i < length; i++) {
|
554
561
|
var item = array[i];
|
555
562
|
if (_.contains(result, item)) continue;
|
556
563
|
for (var j = 1; j < argsLength; j++) {
|
@@ -579,7 +586,7 @@
|
|
579
586
|
// Complement of _.zip. Unzip accepts an array of arrays and groups
|
580
587
|
// each array's elements on shared indices
|
581
588
|
_.unzip = function(array) {
|
582
|
-
var length = array && _.max(array,
|
589
|
+
var length = array && _.max(array, getLength).length || 0;
|
583
590
|
var result = Array(length);
|
584
591
|
|
585
592
|
for (var index = 0; index < length; index++) {
|
@@ -593,7 +600,7 @@
|
|
593
600
|
// the corresponding values.
|
594
601
|
_.object = function(list, values) {
|
595
602
|
var result = {};
|
596
|
-
for (var i = 0, length = list
|
603
|
+
for (var i = 0, length = getLength(list); i < length; i++) {
|
597
604
|
if (values) {
|
598
605
|
result[list[i]] = values[i];
|
599
606
|
} else {
|
@@ -603,42 +610,11 @@
|
|
603
610
|
return result;
|
604
611
|
};
|
605
612
|
|
606
|
-
// Return the position of the first occurrence of an item in an array,
|
607
|
-
// or -1 if the item is not included in the array.
|
608
|
-
// If the array is large and already in sort order, pass `true`
|
609
|
-
// for **isSorted** to use binary search.
|
610
|
-
_.indexOf = function(array, item, isSorted) {
|
611
|
-
var i = 0, length = array && array.length;
|
612
|
-
if (typeof isSorted == 'number') {
|
613
|
-
i = isSorted < 0 ? Math.max(0, length + isSorted) : isSorted;
|
614
|
-
} else if (isSorted && length) {
|
615
|
-
i = _.sortedIndex(array, item);
|
616
|
-
return array[i] === item ? i : -1;
|
617
|
-
}
|
618
|
-
if (item !== item) {
|
619
|
-
return _.findIndex(slice.call(array, i), _.isNaN);
|
620
|
-
}
|
621
|
-
for (; i < length; i++) if (array[i] === item) return i;
|
622
|
-
return -1;
|
623
|
-
};
|
624
|
-
|
625
|
-
_.lastIndexOf = function(array, item, from) {
|
626
|
-
var idx = array ? array.length : 0;
|
627
|
-
if (typeof from == 'number') {
|
628
|
-
idx = from < 0 ? idx + from + 1 : Math.min(idx, from + 1);
|
629
|
-
}
|
630
|
-
if (item !== item) {
|
631
|
-
return _.findLastIndex(slice.call(array, 0, idx), _.isNaN);
|
632
|
-
}
|
633
|
-
while (--idx >= 0) if (array[idx] === item) return idx;
|
634
|
-
return -1;
|
635
|
-
};
|
636
|
-
|
637
613
|
// Generator function to create the findIndex and findLastIndex functions
|
638
|
-
function
|
614
|
+
function createPredicateIndexFinder(dir) {
|
639
615
|
return function(array, predicate, context) {
|
640
616
|
predicate = cb(predicate, context);
|
641
|
-
var length = array
|
617
|
+
var length = getLength(array);
|
642
618
|
var index = dir > 0 ? 0 : length - 1;
|
643
619
|
for (; index >= 0 && index < length; index += dir) {
|
644
620
|
if (predicate(array[index], index, array)) return index;
|
@@ -648,16 +624,15 @@
|
|
648
624
|
}
|
649
625
|
|
650
626
|
// Returns the first index on an array-like that passes a predicate test
|
651
|
-
_.findIndex =
|
652
|
-
|
653
|
-
_.findLastIndex = createIndexFinder(-1);
|
627
|
+
_.findIndex = createPredicateIndexFinder(1);
|
628
|
+
_.findLastIndex = createPredicateIndexFinder(-1);
|
654
629
|
|
655
630
|
// Use a comparator function to figure out the smallest index at which
|
656
631
|
// an object should be inserted so as to maintain order. Uses binary search.
|
657
632
|
_.sortedIndex = function(array, obj, iteratee, context) {
|
658
633
|
iteratee = cb(iteratee, context, 1);
|
659
634
|
var value = iteratee(obj);
|
660
|
-
var low = 0, high = array
|
635
|
+
var low = 0, high = getLength(array);
|
661
636
|
while (low < high) {
|
662
637
|
var mid = Math.floor((low + high) / 2);
|
663
638
|
if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
|
@@ -665,11 +640,43 @@
|
|
665
640
|
return low;
|
666
641
|
};
|
667
642
|
|
643
|
+
// Generator function to create the indexOf and lastIndexOf functions
|
644
|
+
function createIndexFinder(dir, predicateFind, sortedIndex) {
|
645
|
+
return function(array, item, idx) {
|
646
|
+
var i = 0, length = getLength(array);
|
647
|
+
if (typeof idx == 'number') {
|
648
|
+
if (dir > 0) {
|
649
|
+
i = idx >= 0 ? idx : Math.max(idx + length, i);
|
650
|
+
} else {
|
651
|
+
length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
|
652
|
+
}
|
653
|
+
} else if (sortedIndex && idx && length) {
|
654
|
+
idx = sortedIndex(array, item);
|
655
|
+
return array[idx] === item ? idx : -1;
|
656
|
+
}
|
657
|
+
if (item !== item) {
|
658
|
+
idx = predicateFind(slice.call(array, i, length), _.isNaN);
|
659
|
+
return idx >= 0 ? idx + i : -1;
|
660
|
+
}
|
661
|
+
for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
|
662
|
+
if (array[idx] === item) return idx;
|
663
|
+
}
|
664
|
+
return -1;
|
665
|
+
};
|
666
|
+
}
|
667
|
+
|
668
|
+
// Return the position of the first occurrence of an item in an array,
|
669
|
+
// or -1 if the item is not included in the array.
|
670
|
+
// If the array is large and already in sort order, pass `true`
|
671
|
+
// for **isSorted** to use binary search.
|
672
|
+
_.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex);
|
673
|
+
_.lastIndexOf = createIndexFinder(-1, _.findLastIndex);
|
674
|
+
|
668
675
|
// Generate an integer Array containing an arithmetic progression. A port of
|
669
676
|
// the native Python `range()` function. See
|
670
677
|
// [the Python documentation](http://docs.python.org/library/functions.html#range).
|
671
678
|
_.range = function(start, stop, step) {
|
672
|
-
if (
|
679
|
+
if (stop == null) {
|
673
680
|
stop = start || 0;
|
674
681
|
start = 0;
|
675
682
|
}
|
@@ -1048,6 +1055,15 @@
|
|
1048
1055
|
// Fill in a given object with default properties.
|
1049
1056
|
_.defaults = createAssigner(_.allKeys, true);
|
1050
1057
|
|
1058
|
+
// Creates an object that inherits from the given prototype object.
|
1059
|
+
// If additional properties are provided then they will be added to the
|
1060
|
+
// created object.
|
1061
|
+
_.create = function(prototype, props) {
|
1062
|
+
var result = baseCreate(prototype);
|
1063
|
+
if (props) _.extendOwn(result, props);
|
1064
|
+
return result;
|
1065
|
+
};
|
1066
|
+
|
1051
1067
|
// Create a (shallow-cloned) duplicate of an object.
|
1052
1068
|
_.clone = function(obj) {
|
1053
1069
|
if (!_.isObject(obj)) return obj;
|
@@ -1125,7 +1141,7 @@
|
|
1125
1141
|
}
|
1126
1142
|
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
1127
1143
|
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
1128
|
-
|
1144
|
+
|
1129
1145
|
// Initializing stack of traversed objects.
|
1130
1146
|
// It's done here since we only need them for objects and arrays comparison.
|
1131
1147
|
aStack = aStack || [];
|
@@ -1276,11 +1292,7 @@
|
|
1276
1292
|
|
1277
1293
|
_.noop = function(){};
|
1278
1294
|
|
1279
|
-
_.property =
|
1280
|
-
return function(obj) {
|
1281
|
-
return obj == null ? void 0 : obj[key];
|
1282
|
-
};
|
1283
|
-
};
|
1295
|
+
_.property = property;
|
1284
1296
|
|
1285
1297
|
// Generates a function for a given object that returns a given property.
|
1286
1298
|
_.propertyOf = function(obj) {
|
@@ -1289,7 +1301,7 @@
|
|
1289
1301
|
};
|
1290
1302
|
};
|
1291
1303
|
|
1292
|
-
// Returns a predicate for checking whether an object has a given set of
|
1304
|
+
// Returns a predicate for checking whether an object has a given set of
|
1293
1305
|
// `key:value` pairs.
|
1294
1306
|
_.matcher = _.matches = function(attrs) {
|
1295
1307
|
attrs = _.extendOwn({}, attrs);
|
@@ -1516,7 +1528,7 @@
|
|
1516
1528
|
// Provide unwrapping proxy for some methods used in engine operations
|
1517
1529
|
// such as arithmetic and JSON stringification.
|
1518
1530
|
_.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
|
1519
|
-
|
1531
|
+
|
1520
1532
|
_.prototype.toString = function() {
|
1521
1533
|
return '' + this._wrapped;
|
1522
1534
|
};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: underscore-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Wenglewski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -17,7 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
-
|
20
|
+
- .gitignore
|
21
21
|
- Gemfile
|
22
22
|
- LICENSE.md
|
23
23
|
- Rakefile
|
@@ -36,17 +36,17 @@ require_paths:
|
|
36
36
|
- lib
|
37
37
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
48
|
rubyforge_project: underscore-rails
|
49
|
-
rubygems_version: 2.
|
49
|
+
rubygems_version: 2.0.14
|
50
50
|
signing_key:
|
51
51
|
specification_version: 4
|
52
52
|
summary: underscore.js asset pipeline provider/wrapper
|