underscore_extensions 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/assets/javascripts/underscore.js +151 -83
 - data/lib/underscore_extensions/version.rb +2 -2
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e5f7600440a7d295b94fba6fa56f04e1cd0d9e14
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 84c0873a5611a3210fd01fdd905bebad63aa71d7
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: dc8d74e5d9600e40cd7739fbc939b737a15de5e4ede55a5aafacc2b107aeabac98270a0022fd3d82b56269ddef38360c4c0bf55bf1886f0e8690745394d539fa
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8b1a27b5d7c6c4b42f2ec9c55485fafde0bba48043f051fc62ab7721168e36b31c1723207f09670ed35d97888c97e7e2a411730f56d4d50d8e1044ae666f613c
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            //     Underscore.js 1. 
     | 
| 
      
 1 
     | 
    
         
            +
            //     Underscore.js 1.6.0
         
     | 
| 
       2 
2 
     | 
    
         
             
            //     http://underscorejs.org
         
     | 
| 
       3 
     | 
    
         
            -
            //     (c) 2009- 
     | 
| 
      
 3 
     | 
    
         
            +
            //     (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
         
     | 
| 
       4 
4 
     | 
    
         
             
            //     Underscore may be freely distributed under the MIT license.
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            (function() {
         
     | 
| 
         @@ -65,7 +65,7 @@ 
     | 
|
| 
       65 
65 
     | 
    
         
             
              }
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
       67 
67 
     | 
    
         
             
              // Current version.
         
     | 
| 
       68 
     | 
    
         
            -
              _.VERSION = '1. 
     | 
| 
      
 68 
     | 
    
         
            +
              _.VERSION = '1.6.0';
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
       70 
70 
     | 
    
         
             
              // Collection Functions
         
     | 
| 
       71 
71 
     | 
    
         
             
              // --------------------
         
     | 
| 
         @@ -74,7 +74,7 @@ 
     | 
|
| 
       74 
74 
     | 
    
         
             
              // Handles objects with the built-in `forEach`, arrays, and raw objects.
         
     | 
| 
       75 
75 
     | 
    
         
             
              // Delegates to **ECMAScript 5**'s native `forEach` if available.
         
     | 
| 
       76 
76 
     | 
    
         
             
              var each = _.each = _.forEach = function(obj, iterator, context) {
         
     | 
| 
       77 
     | 
    
         
            -
                if (obj == null) return;
         
     | 
| 
      
 77 
     | 
    
         
            +
                if (obj == null) return obj;
         
     | 
| 
       78 
78 
     | 
    
         
             
                if (nativeForEach && obj.forEach === nativeForEach) {
         
     | 
| 
       79 
79 
     | 
    
         
             
                  obj.forEach(iterator, context);
         
     | 
| 
       80 
80 
     | 
    
         
             
                } else if (obj.length === +obj.length) {
         
     | 
| 
         @@ -87,6 +87,7 @@ 
     | 
|
| 
       87 
87 
     | 
    
         
             
                    if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return;
         
     | 
| 
       88 
88 
     | 
    
         
             
                  }
         
     | 
| 
       89 
89 
     | 
    
         
             
                }
         
     | 
| 
      
 90 
     | 
    
         
            +
                return obj;
         
     | 
| 
       90 
91 
     | 
    
         
             
              };
         
     | 
| 
       91 
92 
     | 
    
         | 
| 
       92 
93 
     | 
    
         
             
              // Return the results of applying the iterator to each element.
         
     | 
| 
         @@ -152,10 +153,10 @@ 
     | 
|
| 
       152 
153 
     | 
    
         
             
              };
         
     | 
| 
       153 
154 
     | 
    
         | 
| 
       154 
155 
     | 
    
         
             
              // Return the first value which passes a truth test. Aliased as `detect`.
         
     | 
| 
       155 
     | 
    
         
            -
              _.find = _.detect = function(obj,  
     | 
| 
      
 156 
     | 
    
         
            +
              _.find = _.detect = function(obj, predicate, context) {
         
     | 
| 
       156 
157 
     | 
    
         
             
                var result;
         
     | 
| 
       157 
158 
     | 
    
         
             
                any(obj, function(value, index, list) {
         
     | 
| 
       158 
     | 
    
         
            -
                  if ( 
     | 
| 
      
 159 
     | 
    
         
            +
                  if (predicate.call(context, value, index, list)) {
         
     | 
| 
       159 
160 
     | 
    
         
             
                    result = value;
         
     | 
| 
       160 
161 
     | 
    
         
             
                    return true;
         
     | 
| 
       161 
162 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -166,33 +167,33 @@ 
     | 
|
| 
       166 
167 
     | 
    
         
             
              // Return all the elements that pass a truth test.
         
     | 
| 
       167 
168 
     | 
    
         
             
              // Delegates to **ECMAScript 5**'s native `filter` if available.
         
     | 
| 
       168 
169 
     | 
    
         
             
              // Aliased as `select`.
         
     | 
| 
       169 
     | 
    
         
            -
              _.filter = _.select = function(obj,  
     | 
| 
      
 170 
     | 
    
         
            +
              _.filter = _.select = function(obj, predicate, context) {
         
     | 
| 
       170 
171 
     | 
    
         
             
                var results = [];
         
     | 
| 
       171 
172 
     | 
    
         
             
                if (obj == null) return results;
         
     | 
| 
       172 
     | 
    
         
            -
                if (nativeFilter && obj.filter === nativeFilter) return obj.filter( 
     | 
| 
      
 173 
     | 
    
         
            +
                if (nativeFilter && obj.filter === nativeFilter) return obj.filter(predicate, context);
         
     | 
| 
       173 
174 
     | 
    
         
             
                each(obj, function(value, index, list) {
         
     | 
| 
       174 
     | 
    
         
            -
                  if ( 
     | 
| 
      
 175 
     | 
    
         
            +
                  if (predicate.call(context, value, index, list)) results.push(value);
         
     | 
| 
       175 
176 
     | 
    
         
             
                });
         
     | 
| 
       176 
177 
     | 
    
         
             
                return results;
         
     | 
| 
       177 
178 
     | 
    
         
             
              };
         
     | 
| 
       178 
179 
     | 
    
         | 
| 
       179 
180 
     | 
    
         
             
              // Return all the elements for which a truth test fails.
         
     | 
| 
       180 
     | 
    
         
            -
              _.reject = function(obj,  
     | 
| 
      
 181 
     | 
    
         
            +
              _.reject = function(obj, predicate, context) {
         
     | 
| 
       181 
182 
     | 
    
         
             
                return _.filter(obj, function(value, index, list) {
         
     | 
| 
       182 
     | 
    
         
            -
                  return ! 
     | 
| 
      
 183 
     | 
    
         
            +
                  return !predicate.call(context, value, index, list);
         
     | 
| 
       183 
184 
     | 
    
         
             
                }, context);
         
     | 
| 
       184 
185 
     | 
    
         
             
              };
         
     | 
| 
       185 
186 
     | 
    
         | 
| 
       186 
187 
     | 
    
         
             
              // Determine whether all of the elements match a truth test.
         
     | 
| 
       187 
188 
     | 
    
         
             
              // Delegates to **ECMAScript 5**'s native `every` if available.
         
     | 
| 
       188 
189 
     | 
    
         
             
              // Aliased as `all`.
         
     | 
| 
       189 
     | 
    
         
            -
              _.every = _.all = function(obj,  
     | 
| 
       190 
     | 
    
         
            -
                 
     | 
| 
      
 190 
     | 
    
         
            +
              _.every = _.all = function(obj, predicate, context) {
         
     | 
| 
      
 191 
     | 
    
         
            +
                predicate || (predicate = _.identity);
         
     | 
| 
       191 
192 
     | 
    
         
             
                var result = true;
         
     | 
| 
       192 
193 
     | 
    
         
             
                if (obj == null) return result;
         
     | 
| 
       193 
     | 
    
         
            -
                if (nativeEvery && obj.every === nativeEvery) return obj.every( 
     | 
| 
      
 194 
     | 
    
         
            +
                if (nativeEvery && obj.every === nativeEvery) return obj.every(predicate, context);
         
     | 
| 
       194 
195 
     | 
    
         
             
                each(obj, function(value, index, list) {
         
     | 
| 
       195 
     | 
    
         
            -
                  if (!(result = result &&  
     | 
| 
      
 196 
     | 
    
         
            +
                  if (!(result = result && predicate.call(context, value, index, list))) return breaker;
         
     | 
| 
       196 
197 
     | 
    
         
             
                });
         
     | 
| 
       197 
198 
     | 
    
         
             
                return !!result;
         
     | 
| 
       198 
199 
     | 
    
         
             
              };
         
     | 
| 
         @@ -200,13 +201,13 @@ 
     | 
|
| 
       200 
201 
     | 
    
         
             
              // Determine if at least one element in the object matches a truth test.
         
     | 
| 
       201 
202 
     | 
    
         
             
              // Delegates to **ECMAScript 5**'s native `some` if available.
         
     | 
| 
       202 
203 
     | 
    
         
             
              // Aliased as `any`.
         
     | 
| 
       203 
     | 
    
         
            -
              var any = _.some = _.any = function(obj,  
     | 
| 
       204 
     | 
    
         
            -
                 
     | 
| 
      
 204 
     | 
    
         
            +
              var any = _.some = _.any = function(obj, predicate, context) {
         
     | 
| 
      
 205 
     | 
    
         
            +
                predicate || (predicate = _.identity);
         
     | 
| 
       205 
206 
     | 
    
         
             
                var result = false;
         
     | 
| 
       206 
207 
     | 
    
         
             
                if (obj == null) return result;
         
     | 
| 
       207 
     | 
    
         
            -
                if (nativeSome && obj.some === nativeSome) return obj.some( 
     | 
| 
      
 208 
     | 
    
         
            +
                if (nativeSome && obj.some === nativeSome) return obj.some(predicate, context);
         
     | 
| 
       208 
209 
     | 
    
         
             
                each(obj, function(value, index, list) {
         
     | 
| 
       209 
     | 
    
         
            -
                  if (result || (result =  
     | 
| 
      
 210 
     | 
    
         
            +
                  if (result || (result = predicate.call(context, value, index, list))) return breaker;
         
     | 
| 
       210 
211 
     | 
    
         
             
                });
         
     | 
| 
       211 
212 
     | 
    
         
             
                return !!result;
         
     | 
| 
       212 
213 
     | 
    
         
             
              };
         
     | 
| 
         @@ -232,25 +233,19 @@ 
     | 
|
| 
       232 
233 
     | 
    
         | 
| 
       233 
234 
     | 
    
         
             
              // Convenience version of a common use case of `map`: fetching a property.
         
     | 
| 
       234 
235 
     | 
    
         
             
              _.pluck = function(obj, key) {
         
     | 
| 
       235 
     | 
    
         
            -
                return _.map(obj,  
     | 
| 
      
 236 
     | 
    
         
            +
                return _.map(obj, _.property(key));
         
     | 
| 
       236 
237 
     | 
    
         
             
              };
         
     | 
| 
       237 
238 
     | 
    
         | 
| 
       238 
239 
     | 
    
         
             
              // Convenience version of a common use case of `filter`: selecting only objects
         
     | 
| 
       239 
240 
     | 
    
         
             
              // containing specific `key:value` pairs.
         
     | 
| 
       240 
     | 
    
         
            -
              _.where = function(obj, attrs 
     | 
| 
       241 
     | 
    
         
            -
                 
     | 
| 
       242 
     | 
    
         
            -
                return _[first ? 'find' : 'filter'](obj, function(value) {
         
     | 
| 
       243 
     | 
    
         
            -
                  for (var key in attrs) {
         
     | 
| 
       244 
     | 
    
         
            -
                    if (attrs[key] !== value[key]) return false;
         
     | 
| 
       245 
     | 
    
         
            -
                  }
         
     | 
| 
       246 
     | 
    
         
            -
                  return true;
         
     | 
| 
       247 
     | 
    
         
            -
                });
         
     | 
| 
      
 241 
     | 
    
         
            +
              _.where = function(obj, attrs) {
         
     | 
| 
      
 242 
     | 
    
         
            +
                return _.filter(obj, _.matches(attrs));
         
     | 
| 
       248 
243 
     | 
    
         
             
              };
         
     | 
| 
       249 
244 
     | 
    
         | 
| 
       250 
245 
     | 
    
         
             
              // Convenience version of a common use case of `find`: getting the first object
         
     | 
| 
       251 
246 
     | 
    
         
             
              // containing specific `key:value` pairs.
         
     | 
| 
       252 
247 
     | 
    
         
             
              _.findWhere = function(obj, attrs) {
         
     | 
| 
       253 
     | 
    
         
            -
                return _. 
     | 
| 
      
 248 
     | 
    
         
            +
                return _.find(obj, _.matches(attrs));
         
     | 
| 
       254 
249 
     | 
    
         
             
              };
         
     | 
| 
       255 
250 
     | 
    
         | 
| 
       256 
251 
     | 
    
         
             
              // Return the maximum element or (element-based computation).
         
     | 
| 
         @@ -260,13 +255,15 @@ 
     | 
|
| 
       260 
255 
     | 
    
         
             
                if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
         
     | 
| 
       261 
256 
     | 
    
         
             
                  return Math.max.apply(Math, obj);
         
     | 
| 
       262 
257 
     | 
    
         
             
                }
         
     | 
| 
       263 
     | 
    
         
            -
                 
     | 
| 
       264 
     | 
    
         
            -
                var result = {computed : -Infinity, value: -Infinity};
         
     | 
| 
      
 258 
     | 
    
         
            +
                var result = -Infinity, lastComputed = -Infinity;
         
     | 
| 
       265 
259 
     | 
    
         
             
                each(obj, function(value, index, list) {
         
     | 
| 
       266 
260 
     | 
    
         
             
                  var computed = iterator ? iterator.call(context, value, index, list) : value;
         
     | 
| 
       267 
     | 
    
         
            -
                  computed >  
     | 
| 
      
 261 
     | 
    
         
            +
                  if (computed > lastComputed) {
         
     | 
| 
      
 262 
     | 
    
         
            +
                    result = value;
         
     | 
| 
      
 263 
     | 
    
         
            +
                    lastComputed = computed;
         
     | 
| 
      
 264 
     | 
    
         
            +
                  }
         
     | 
| 
       268 
265 
     | 
    
         
             
                });
         
     | 
| 
       269 
     | 
    
         
            -
                return result 
     | 
| 
      
 266 
     | 
    
         
            +
                return result;
         
     | 
| 
       270 
267 
     | 
    
         
             
              };
         
     | 
| 
       271 
268 
     | 
    
         | 
| 
       272 
269 
     | 
    
         
             
              // Return the minimum element (or element-based computation).
         
     | 
| 
         @@ -274,16 +271,18 @@ 
     | 
|
| 
       274 
271 
     | 
    
         
             
                if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
         
     | 
| 
       275 
272 
     | 
    
         
             
                  return Math.min.apply(Math, obj);
         
     | 
| 
       276 
273 
     | 
    
         
             
                }
         
     | 
| 
       277 
     | 
    
         
            -
                 
     | 
| 
       278 
     | 
    
         
            -
                var result = {computed : Infinity, value: Infinity};
         
     | 
| 
      
 274 
     | 
    
         
            +
                var result = Infinity, lastComputed = Infinity;
         
     | 
| 
       279 
275 
     | 
    
         
             
                each(obj, function(value, index, list) {
         
     | 
| 
       280 
276 
     | 
    
         
             
                  var computed = iterator ? iterator.call(context, value, index, list) : value;
         
     | 
| 
       281 
     | 
    
         
            -
                  computed <  
     | 
| 
      
 277 
     | 
    
         
            +
                  if (computed < lastComputed) {
         
     | 
| 
      
 278 
     | 
    
         
            +
                    result = value;
         
     | 
| 
      
 279 
     | 
    
         
            +
                    lastComputed = computed;
         
     | 
| 
      
 280 
     | 
    
         
            +
                  }
         
     | 
| 
       282 
281 
     | 
    
         
             
                });
         
     | 
| 
       283 
     | 
    
         
            -
                return result 
     | 
| 
      
 282 
     | 
    
         
            +
                return result;
         
     | 
| 
       284 
283 
     | 
    
         
             
              };
         
     | 
| 
       285 
284 
     | 
    
         | 
| 
       286 
     | 
    
         
            -
              // Shuffle an array, using the modern version of the 
     | 
| 
      
 285 
     | 
    
         
            +
              // Shuffle an array, using the modern version of the
         
     | 
| 
       287 
286 
     | 
    
         
             
              // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
         
     | 
| 
       288 
287 
     | 
    
         
             
              _.shuffle = function(obj) {
         
     | 
| 
       289 
288 
     | 
    
         
             
                var rand;
         
     | 
| 
         @@ -297,11 +296,12 @@ 
     | 
|
| 
       297 
296 
     | 
    
         
             
                return shuffled;
         
     | 
| 
       298 
297 
     | 
    
         
             
              };
         
     | 
| 
       299 
298 
     | 
    
         | 
| 
       300 
     | 
    
         
            -
              // Sample **n** random values from  
     | 
| 
       301 
     | 
    
         
            -
              // If **n** is not specified, returns a single random element 
     | 
| 
      
 299 
     | 
    
         
            +
              // Sample **n** random values from a collection.
         
     | 
| 
      
 300 
     | 
    
         
            +
              // If **n** is not specified, returns a single random element.
         
     | 
| 
       302 
301 
     | 
    
         
             
              // The internal `guard` argument allows it to work with `map`.
         
     | 
| 
       303 
302 
     | 
    
         
             
              _.sample = function(obj, n, guard) {
         
     | 
| 
       304 
     | 
    
         
            -
                if ( 
     | 
| 
      
 303 
     | 
    
         
            +
                if (n == null || guard) {
         
     | 
| 
      
 304 
     | 
    
         
            +
                  if (obj.length !== +obj.length) obj = _.values(obj);
         
     | 
| 
       305 
305 
     | 
    
         
             
                  return obj[_.random(obj.length - 1)];
         
     | 
| 
       306 
306 
     | 
    
         
             
                }
         
     | 
| 
       307 
307 
     | 
    
         
             
                return _.shuffle(obj).slice(0, Math.max(0, n));
         
     | 
| 
         @@ -309,12 +309,14 @@ 
     | 
|
| 
       309 
309 
     | 
    
         | 
| 
       310 
310 
     | 
    
         
             
              // An internal function to generate lookup iterators.
         
     | 
| 
       311 
311 
     | 
    
         
             
              var lookupIterator = function(value) {
         
     | 
| 
       312 
     | 
    
         
            -
                 
     | 
| 
      
 312 
     | 
    
         
            +
                if (value == null) return _.identity;
         
     | 
| 
      
 313 
     | 
    
         
            +
                if (_.isFunction(value)) return value;
         
     | 
| 
      
 314 
     | 
    
         
            +
                return _.property(value);
         
     | 
| 
       313 
315 
     | 
    
         
             
              };
         
     | 
| 
       314 
316 
     | 
    
         | 
| 
       315 
317 
     | 
    
         
             
              // Sort the object's values by a criterion produced by an iterator.
         
     | 
| 
       316 
     | 
    
         
            -
              _.sortBy = function(obj,  
     | 
| 
       317 
     | 
    
         
            -
                 
     | 
| 
      
 318 
     | 
    
         
            +
              _.sortBy = function(obj, iterator, context) {
         
     | 
| 
      
 319 
     | 
    
         
            +
                iterator = lookupIterator(iterator);
         
     | 
| 
       318 
320 
     | 
    
         
             
                return _.pluck(_.map(obj, function(value, index, list) {
         
     | 
| 
       319 
321 
     | 
    
         
             
                  return {
         
     | 
| 
       320 
322 
     | 
    
         
             
                    value: value,
         
     | 
| 
         @@ -334,9 +336,9 @@ 
     | 
|
| 
       334 
336 
     | 
    
         | 
| 
       335 
337 
     | 
    
         
             
              // An internal function used for aggregate "group by" operations.
         
     | 
| 
       336 
338 
     | 
    
         
             
              var group = function(behavior) {
         
     | 
| 
       337 
     | 
    
         
            -
                return function(obj,  
     | 
| 
      
 339 
     | 
    
         
            +
                return function(obj, iterator, context) {
         
     | 
| 
       338 
340 
     | 
    
         
             
                  var result = {};
         
     | 
| 
       339 
     | 
    
         
            -
                   
     | 
| 
      
 341 
     | 
    
         
            +
                  iterator = lookupIterator(iterator);
         
     | 
| 
       340 
342 
     | 
    
         
             
                  each(obj, function(value, index) {
         
     | 
| 
       341 
343 
     | 
    
         
             
                    var key = iterator.call(context, value, index, obj);
         
     | 
| 
       342 
344 
     | 
    
         
             
                    behavior(result, key, value);
         
     | 
| 
         @@ -348,7 +350,7 @@ 
     | 
|
| 
       348 
350 
     | 
    
         
             
              // Groups the object's values by a criterion. Pass either a string attribute
         
     | 
| 
       349 
351 
     | 
    
         
             
              // to group by, or a function that returns the criterion.
         
     | 
| 
       350 
352 
     | 
    
         
             
              _.groupBy = group(function(result, key, value) {
         
     | 
| 
       351 
     | 
    
         
            -
                 
     | 
| 
      
 353 
     | 
    
         
            +
                _.has(result, key) ? result[key].push(value) : result[key] = [value];
         
     | 
| 
       352 
354 
     | 
    
         
             
              });
         
     | 
| 
       353 
355 
     | 
    
         | 
| 
       354 
356 
     | 
    
         
             
              // Indexes the object's values by a criterion, similar to `groupBy`, but for
         
     | 
| 
         @@ -367,7 +369,7 @@ 
     | 
|
| 
       367 
369 
     | 
    
         
             
              // Use a comparator function to figure out the smallest index at which
         
     | 
| 
       368 
370 
     | 
    
         
             
              // an object should be inserted so as to maintain order. Uses binary search.
         
     | 
| 
       369 
371 
     | 
    
         
             
              _.sortedIndex = function(array, obj, iterator, context) {
         
     | 
| 
       370 
     | 
    
         
            -
                iterator =  
     | 
| 
      
 372 
     | 
    
         
            +
                iterator = lookupIterator(iterator);
         
     | 
| 
       371 
373 
     | 
    
         
             
                var value = iterator.call(context, obj);
         
     | 
| 
       372 
374 
     | 
    
         
             
                var low = 0, high = array.length;
         
     | 
| 
       373 
375 
     | 
    
         
             
                while (low < high) {
         
     | 
| 
         @@ -399,7 +401,9 @@ 
     | 
|
| 
       399 
401 
     | 
    
         
             
              // allows it to work with `_.map`.
         
     | 
| 
       400 
402 
     | 
    
         
             
              _.first = _.head = _.take = function(array, n, guard) {
         
     | 
| 
       401 
403 
     | 
    
         
             
                if (array == null) return void 0;
         
     | 
| 
       402 
     | 
    
         
            -
                 
     | 
| 
      
 404 
     | 
    
         
            +
                if ((n == null) || guard) return array[0];
         
     | 
| 
      
 405 
     | 
    
         
            +
                if (n < 0) return [];
         
     | 
| 
      
 406 
     | 
    
         
            +
                return slice.call(array, 0, n);
         
     | 
| 
       403 
407 
     | 
    
         
             
              };
         
     | 
| 
       404 
408 
     | 
    
         | 
| 
       405 
409 
     | 
    
         
             
              // Returns everything but the last entry of the array. Especially useful on
         
     | 
| 
         @@ -414,11 +418,8 @@ 
     | 
|
| 
       414 
418 
     | 
    
         
             
              // values in the array. The **guard** check allows it to work with `_.map`.
         
     | 
| 
       415 
419 
     | 
    
         
             
              _.last = function(array, n, guard) {
         
     | 
| 
       416 
420 
     | 
    
         
             
                if (array == null) return void 0;
         
     | 
| 
       417 
     | 
    
         
            -
                if ((n == null) || guard)  
     | 
| 
       418 
     | 
    
         
            -
             
     | 
| 
       419 
     | 
    
         
            -
                } else {
         
     | 
| 
       420 
     | 
    
         
            -
                  return slice.call(array, Math.max(array.length - n, 0));
         
     | 
| 
       421 
     | 
    
         
            -
                }
         
     | 
| 
      
 421 
     | 
    
         
            +
                if ((n == null) || guard) return array[array.length - 1];
         
     | 
| 
      
 422 
     | 
    
         
            +
                return slice.call(array, Math.max(array.length - n, 0));
         
     | 
| 
       422 
423 
     | 
    
         
             
              };
         
     | 
| 
       423 
424 
     | 
    
         | 
| 
       424 
425 
     | 
    
         
             
              // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
         
     | 
| 
         @@ -459,6 +460,17 @@ 
     | 
|
| 
       459 
460 
     | 
    
         
             
                return _.difference(array, slice.call(arguments, 1));
         
     | 
| 
       460 
461 
     | 
    
         
             
              };
         
     | 
| 
       461 
462 
     | 
    
         | 
| 
      
 463 
     | 
    
         
            +
              // Split an array into two arrays: one whose elements all satisfy the given
         
     | 
| 
      
 464 
     | 
    
         
            +
              // predicate, and one whose elements all do not satisfy the predicate.
         
     | 
| 
      
 465 
     | 
    
         
            +
              _.partition = function(array, predicate, context) {
         
     | 
| 
      
 466 
     | 
    
         
            +
                predicate = lookupIterator(predicate);
         
     | 
| 
      
 467 
     | 
    
         
            +
                var pass = [], fail = [];
         
     | 
| 
      
 468 
     | 
    
         
            +
                each(array, function(elem) {
         
     | 
| 
      
 469 
     | 
    
         
            +
                  (predicate.call(context, elem) ? pass : fail).push(elem);
         
     | 
| 
      
 470 
     | 
    
         
            +
                });
         
     | 
| 
      
 471 
     | 
    
         
            +
                return [pass, fail];
         
     | 
| 
      
 472 
     | 
    
         
            +
              };
         
     | 
| 
      
 473 
     | 
    
         
            +
             
     | 
| 
       462 
474 
     | 
    
         
             
              // Produce a duplicate-free version of the array. If the array has already
         
     | 
| 
       463 
475 
     | 
    
         
             
              // been sorted, you have the option of using a faster algorithm.
         
     | 
| 
       464 
476 
     | 
    
         
             
              // Aliased as `unique`.
         
     | 
| 
         @@ -492,7 +504,7 @@ 
     | 
|
| 
       492 
504 
     | 
    
         
             
                var rest = slice.call(arguments, 1);
         
     | 
| 
       493 
505 
     | 
    
         
             
                return _.filter(_.uniq(array), function(item) {
         
     | 
| 
       494 
506 
     | 
    
         
             
                  return _.every(rest, function(other) {
         
     | 
| 
       495 
     | 
    
         
            -
                    return _. 
     | 
| 
      
 507 
     | 
    
         
            +
                    return _.contains(other, item);
         
     | 
| 
       496 
508 
     | 
    
         
             
                  });
         
     | 
| 
       497 
509 
     | 
    
         
             
                });
         
     | 
| 
       498 
510 
     | 
    
         
             
              };
         
     | 
| 
         @@ -507,7 +519,7 @@ 
     | 
|
| 
       507 
519 
     | 
    
         
             
              // Zip together multiple lists into a single array -- elements that share
         
     | 
| 
       508 
520 
     | 
    
         
             
              // an index go together.
         
     | 
| 
       509 
521 
     | 
    
         
             
              _.zip = function() {
         
     | 
| 
       510 
     | 
    
         
            -
                var length = _.max(_.pluck(arguments,  
     | 
| 
      
 522 
     | 
    
         
            +
                var length = _.max(_.pluck(arguments, 'length').concat(0));
         
     | 
| 
       511 
523 
     | 
    
         
             
                var results = new Array(length);
         
     | 
| 
       512 
524 
     | 
    
         
             
                for (var i = 0; i < length; i++) {
         
     | 
| 
       513 
525 
     | 
    
         
             
                  results[i] = _.pluck(arguments, '' + i);
         
     | 
| 
         @@ -613,19 +625,27 @@ 
     | 
|
| 
       613 
625 
     | 
    
         
             
              };
         
     | 
| 
       614 
626 
     | 
    
         | 
| 
       615 
627 
     | 
    
         
             
              // Partially apply a function by creating a version that has had some of its
         
     | 
| 
       616 
     | 
    
         
            -
              // arguments pre-filled, without changing its dynamic `this` context.
         
     | 
| 
      
 628 
     | 
    
         
            +
              // arguments pre-filled, without changing its dynamic `this` context. _ acts
         
     | 
| 
      
 629 
     | 
    
         
            +
              // as a placeholder, allowing any combination of arguments to be pre-filled.
         
     | 
| 
       617 
630 
     | 
    
         
             
              _.partial = function(func) {
         
     | 
| 
       618 
     | 
    
         
            -
                var  
     | 
| 
      
 631 
     | 
    
         
            +
                var boundArgs = slice.call(arguments, 1);
         
     | 
| 
       619 
632 
     | 
    
         
             
                return function() {
         
     | 
| 
       620 
     | 
    
         
            -
                   
     | 
| 
      
 633 
     | 
    
         
            +
                  var position = 0;
         
     | 
| 
      
 634 
     | 
    
         
            +
                  var args = boundArgs.slice();
         
     | 
| 
      
 635 
     | 
    
         
            +
                  for (var i = 0, length = args.length; i < length; i++) {
         
     | 
| 
      
 636 
     | 
    
         
            +
                    if (args[i] === _) args[i] = arguments[position++];
         
     | 
| 
      
 637 
     | 
    
         
            +
                  }
         
     | 
| 
      
 638 
     | 
    
         
            +
                  while (position < arguments.length) args.push(arguments[position++]);
         
     | 
| 
      
 639 
     | 
    
         
            +
                  return func.apply(this, args);
         
     | 
| 
       621 
640 
     | 
    
         
             
                };
         
     | 
| 
       622 
641 
     | 
    
         
             
              };
         
     | 
| 
       623 
642 
     | 
    
         | 
| 
       624 
     | 
    
         
            -
              // Bind  
     | 
| 
       625 
     | 
    
         
            -
              //  
     | 
| 
      
 643 
     | 
    
         
            +
              // Bind a number of an object's methods to that object. Remaining arguments
         
     | 
| 
      
 644 
     | 
    
         
            +
              // are the method names to be bound. Useful for ensuring that all callbacks
         
     | 
| 
      
 645 
     | 
    
         
            +
              // defined on an object belong to it.
         
     | 
| 
       626 
646 
     | 
    
         
             
              _.bindAll = function(obj) {
         
     | 
| 
       627 
647 
     | 
    
         
             
                var funcs = slice.call(arguments, 1);
         
     | 
| 
       628 
     | 
    
         
            -
                if (funcs.length === 0) throw new Error( 
     | 
| 
      
 648 
     | 
    
         
            +
                if (funcs.length === 0) throw new Error('bindAll must be passed function names');
         
     | 
| 
       629 
649 
     | 
    
         
             
                each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
         
     | 
| 
       630 
650 
     | 
    
         
             
                return obj;
         
     | 
| 
       631 
651 
     | 
    
         
             
              };
         
     | 
| 
         @@ -664,12 +684,13 @@ 
     | 
|
| 
       664 
684 
     | 
    
         
             
                var previous = 0;
         
     | 
| 
       665 
685 
     | 
    
         
             
                options || (options = {});
         
     | 
| 
       666 
686 
     | 
    
         
             
                var later = function() {
         
     | 
| 
       667 
     | 
    
         
            -
                  previous = options.leading === false ? 0 :  
     | 
| 
      
 687 
     | 
    
         
            +
                  previous = options.leading === false ? 0 : _.now();
         
     | 
| 
       668 
688 
     | 
    
         
             
                  timeout = null;
         
     | 
| 
       669 
689 
     | 
    
         
             
                  result = func.apply(context, args);
         
     | 
| 
      
 690 
     | 
    
         
            +
                  context = args = null;
         
     | 
| 
       670 
691 
     | 
    
         
             
                };
         
     | 
| 
       671 
692 
     | 
    
         
             
                return function() {
         
     | 
| 
       672 
     | 
    
         
            -
                  var now =  
     | 
| 
      
 693 
     | 
    
         
            +
                  var now = _.now();
         
     | 
| 
       673 
694 
     | 
    
         
             
                  if (!previous && options.leading === false) previous = now;
         
     | 
| 
       674 
695 
     | 
    
         
             
                  var remaining = wait - (now - previous);
         
     | 
| 
       675 
696 
     | 
    
         
             
                  context = this;
         
     | 
| 
         @@ -679,6 +700,7 @@ 
     | 
|
| 
       679 
700 
     | 
    
         
             
                    timeout = null;
         
     | 
| 
       680 
701 
     | 
    
         
             
                    previous = now;
         
     | 
| 
       681 
702 
     | 
    
         
             
                    result = func.apply(context, args);
         
     | 
| 
      
 703 
     | 
    
         
            +
                    context = args = null;
         
     | 
| 
       682 
704 
     | 
    
         
             
                  } else if (!timeout && options.trailing !== false) {
         
     | 
| 
       683 
705 
     | 
    
         
             
                    timeout = setTimeout(later, remaining);
         
     | 
| 
       684 
706 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -692,24 +714,33 @@ 
     | 
|
| 
       692 
714 
     | 
    
         
             
              // leading edge, instead of the trailing.
         
     | 
| 
       693 
715 
     | 
    
         
             
              _.debounce = function(func, wait, immediate) {
         
     | 
| 
       694 
716 
     | 
    
         
             
                var timeout, args, context, timestamp, result;
         
     | 
| 
      
 717 
     | 
    
         
            +
             
     | 
| 
      
 718 
     | 
    
         
            +
                var later = function() {
         
     | 
| 
      
 719 
     | 
    
         
            +
                  var last = _.now() - timestamp;
         
     | 
| 
      
 720 
     | 
    
         
            +
                  if (last < wait) {
         
     | 
| 
      
 721 
     | 
    
         
            +
                    timeout = setTimeout(later, wait - last);
         
     | 
| 
      
 722 
     | 
    
         
            +
                  } else {
         
     | 
| 
      
 723 
     | 
    
         
            +
                    timeout = null;
         
     | 
| 
      
 724 
     | 
    
         
            +
                    if (!immediate) {
         
     | 
| 
      
 725 
     | 
    
         
            +
                      result = func.apply(context, args);
         
     | 
| 
      
 726 
     | 
    
         
            +
                      context = args = null;
         
     | 
| 
      
 727 
     | 
    
         
            +
                    }
         
     | 
| 
      
 728 
     | 
    
         
            +
                  }
         
     | 
| 
      
 729 
     | 
    
         
            +
                };
         
     | 
| 
      
 730 
     | 
    
         
            +
             
     | 
| 
       695 
731 
     | 
    
         
             
                return function() {
         
     | 
| 
       696 
732 
     | 
    
         
             
                  context = this;
         
     | 
| 
       697 
733 
     | 
    
         
             
                  args = arguments;
         
     | 
| 
       698 
     | 
    
         
            -
                  timestamp =  
     | 
| 
       699 
     | 
    
         
            -
                  var later = function() {
         
     | 
| 
       700 
     | 
    
         
            -
                    var last = (new Date()) - timestamp;
         
     | 
| 
       701 
     | 
    
         
            -
                    if (last < wait) {
         
     | 
| 
       702 
     | 
    
         
            -
                      timeout = setTimeout(later, wait - last);
         
     | 
| 
       703 
     | 
    
         
            -
                    } else {
         
     | 
| 
       704 
     | 
    
         
            -
                      timeout = null;
         
     | 
| 
       705 
     | 
    
         
            -
                      if (!immediate) result = func.apply(context, args);
         
     | 
| 
       706 
     | 
    
         
            -
                    }
         
     | 
| 
       707 
     | 
    
         
            -
                  };
         
     | 
| 
      
 734 
     | 
    
         
            +
                  timestamp = _.now();
         
     | 
| 
       708 
735 
     | 
    
         
             
                  var callNow = immediate && !timeout;
         
     | 
| 
       709 
736 
     | 
    
         
             
                  if (!timeout) {
         
     | 
| 
       710 
737 
     | 
    
         
             
                    timeout = setTimeout(later, wait);
         
     | 
| 
       711 
738 
     | 
    
         
             
                  }
         
     | 
| 
       712 
     | 
    
         
            -
                  if (callNow)  
     | 
| 
      
 739 
     | 
    
         
            +
                  if (callNow) {
         
     | 
| 
      
 740 
     | 
    
         
            +
                    result = func.apply(context, args);
         
     | 
| 
      
 741 
     | 
    
         
            +
                    context = args = null;
         
     | 
| 
      
 742 
     | 
    
         
            +
                  }
         
     | 
| 
      
 743 
     | 
    
         
            +
             
     | 
| 
       713 
744 
     | 
    
         
             
                  return result;
         
     | 
| 
       714 
745 
     | 
    
         
             
                };
         
     | 
| 
       715 
746 
     | 
    
         
             
              };
         
     | 
| 
         @@ -731,11 +762,7 @@ 
     | 
|
| 
       731 
762 
     | 
    
         
             
              // allowing you to adjust arguments, run code before and after, and
         
     | 
| 
       732 
763 
     | 
    
         
             
              // conditionally execute the original function.
         
     | 
| 
       733 
764 
     | 
    
         
             
              _.wrap = function(func, wrapper) {
         
     | 
| 
       734 
     | 
    
         
            -
                return  
     | 
| 
       735 
     | 
    
         
            -
                  var args = [func];
         
     | 
| 
       736 
     | 
    
         
            -
                  push.apply(args, arguments);
         
     | 
| 
       737 
     | 
    
         
            -
                  return wrapper.apply(this, args);
         
     | 
| 
       738 
     | 
    
         
            -
                };
         
     | 
| 
      
 765 
     | 
    
         
            +
                return _.partial(wrapper, func);
         
     | 
| 
       739 
766 
     | 
    
         
             
              };
         
     | 
| 
       740 
767 
     | 
    
         | 
| 
       741 
768 
     | 
    
         
             
              // Returns a function that is the composition of a list of functions, each
         
     | 
| 
         @@ -765,8 +792,9 @@ 
     | 
|
| 
       765 
792 
     | 
    
         | 
| 
       766 
793 
     | 
    
         
             
              // Retrieve the names of an object's properties.
         
     | 
| 
       767 
794 
     | 
    
         
             
              // Delegates to **ECMAScript 5**'s native `Object.keys`
         
     | 
| 
       768 
     | 
    
         
            -
              _.keys =  
     | 
| 
       769 
     | 
    
         
            -
                if ( 
     | 
| 
      
 795 
     | 
    
         
            +
              _.keys = function(obj) {
         
     | 
| 
      
 796 
     | 
    
         
            +
                if (!_.isObject(obj)) return [];
         
     | 
| 
      
 797 
     | 
    
         
            +
                if (nativeKeys) return nativeKeys(obj);
         
     | 
| 
       770 
798 
     | 
    
         
             
                var keys = [];
         
     | 
| 
       771 
799 
     | 
    
         
             
                for (var key in obj) if (_.has(obj, key)) keys.push(key);
         
     | 
| 
       772 
800 
     | 
    
         
             
                return keys;
         
     | 
| 
         @@ -921,7 +949,8 @@ 
     | 
|
| 
       921 
949 
     | 
    
         
             
                // from different frames are.
         
     | 
| 
       922 
950 
     | 
    
         
             
                var aCtor = a.constructor, bCtor = b.constructor;
         
     | 
| 
       923 
951 
     | 
    
         
             
                if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
         
     | 
| 
       924 
     | 
    
         
            -
                                         _.isFunction(bCtor) && (bCtor instanceof bCtor)) 
     | 
| 
      
 952 
     | 
    
         
            +
                                         _.isFunction(bCtor) && (bCtor instanceof bCtor))
         
     | 
| 
      
 953 
     | 
    
         
            +
                                    && ('constructor' in a && 'constructor' in b)) {
         
     | 
| 
       925 
954 
     | 
    
         
             
                  return false;
         
     | 
| 
       926 
955 
     | 
    
         
             
                }
         
     | 
| 
       927 
956 
     | 
    
         
             
                // Add the first object to the stack of traversed objects.
         
     | 
| 
         @@ -1061,6 +1090,30 @@ 
     | 
|
| 
       1061 
1090 
     | 
    
         
             
                return value;
         
     | 
| 
       1062 
1091 
     | 
    
         
             
              };
         
     | 
| 
       1063 
1092 
     | 
    
         | 
| 
      
 1093 
     | 
    
         
            +
              _.constant = function(value) {
         
     | 
| 
      
 1094 
     | 
    
         
            +
                return function () {
         
     | 
| 
      
 1095 
     | 
    
         
            +
                  return value;
         
     | 
| 
      
 1096 
     | 
    
         
            +
                };
         
     | 
| 
      
 1097 
     | 
    
         
            +
              };
         
     | 
| 
      
 1098 
     | 
    
         
            +
             
     | 
| 
      
 1099 
     | 
    
         
            +
              _.property = function(key) {
         
     | 
| 
      
 1100 
     | 
    
         
            +
                return function(obj) {
         
     | 
| 
      
 1101 
     | 
    
         
            +
                  return obj[key];
         
     | 
| 
      
 1102 
     | 
    
         
            +
                };
         
     | 
| 
      
 1103 
     | 
    
         
            +
              };
         
     | 
| 
      
 1104 
     | 
    
         
            +
             
     | 
| 
      
 1105 
     | 
    
         
            +
              // Returns a predicate for checking whether an object has a given set of `key:value` pairs.
         
     | 
| 
      
 1106 
     | 
    
         
            +
              _.matches = function(attrs) {
         
     | 
| 
      
 1107 
     | 
    
         
            +
                return function(obj) {
         
     | 
| 
      
 1108 
     | 
    
         
            +
                  if (obj === attrs) return true; //avoid comparing an object to itself.
         
     | 
| 
      
 1109 
     | 
    
         
            +
                  for (var key in attrs) {
         
     | 
| 
      
 1110 
     | 
    
         
            +
                    if (attrs[key] !== obj[key])
         
     | 
| 
      
 1111 
     | 
    
         
            +
                      return false;
         
     | 
| 
      
 1112 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1113 
     | 
    
         
            +
                  return true;
         
     | 
| 
      
 1114 
     | 
    
         
            +
                }
         
     | 
| 
      
 1115 
     | 
    
         
            +
              };
         
     | 
| 
      
 1116 
     | 
    
         
            +
             
     | 
| 
       1064 
1117 
     | 
    
         
             
              // Run a function **n** times.
         
     | 
| 
       1065 
1118 
     | 
    
         
             
              _.times = function(n, iterator, context) {
         
     | 
| 
       1066 
1119 
     | 
    
         
             
                var accum = Array(Math.max(0, n));
         
     | 
| 
         @@ -1077,6 +1130,9 @@ 
     | 
|
| 
       1077 
1130 
     | 
    
         
             
                return min + Math.floor(Math.random() * (max - min + 1));
         
     | 
| 
       1078 
1131 
     | 
    
         
             
              };
         
     | 
| 
       1079 
1132 
     | 
    
         | 
| 
      
 1133 
     | 
    
         
            +
              // A (possibly faster) way to get the current timestamp as an integer.
         
     | 
| 
      
 1134 
     | 
    
         
            +
              _.now = Date.now || function() { return new Date().getTime(); };
         
     | 
| 
      
 1135 
     | 
    
         
            +
             
     | 
| 
       1080 
1136 
     | 
    
         
             
              // List of HTML entities for escaping.
         
     | 
| 
       1081 
1137 
     | 
    
         
             
              var entityMap = {
         
     | 
| 
       1082 
1138 
     | 
    
         
             
                escape: {
         
     | 
| 
         @@ -1273,4 +1329,16 @@ 
     | 
|
| 
       1273 
1329 
     | 
    
         | 
| 
       1274 
1330 
     | 
    
         
             
              });
         
     | 
| 
       1275 
1331 
     | 
    
         | 
| 
      
 1332 
     | 
    
         
            +
              // AMD registration happens at the end for compatibility with AMD loaders
         
     | 
| 
      
 1333 
     | 
    
         
            +
              // that may not enforce next-turn semantics on modules. Even though general
         
     | 
| 
      
 1334 
     | 
    
         
            +
              // practice for AMD registration is to be anonymous, underscore registers
         
     | 
| 
      
 1335 
     | 
    
         
            +
              // as a named module because, like jQuery, it is a base library that is
         
     | 
| 
      
 1336 
     | 
    
         
            +
              // popular enough to be bundled in a third party lib, but not be part of
         
     | 
| 
      
 1337 
     | 
    
         
            +
              // an AMD load request. Those cases could generate an error when an
         
     | 
| 
      
 1338 
     | 
    
         
            +
              // anonymous define() is called outside of a loader request.
         
     | 
| 
      
 1339 
     | 
    
         
            +
              if (typeof define === 'function' && define.amd) {
         
     | 
| 
      
 1340 
     | 
    
         
            +
                define('underscore', [], function() {
         
     | 
| 
      
 1341 
     | 
    
         
            +
                  return _;
         
     | 
| 
      
 1342 
     | 
    
         
            +
                });
         
     | 
| 
      
 1343 
     | 
    
         
            +
              }
         
     | 
| 
       1276 
1344 
     | 
    
         
             
            }).call(this);
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: underscore_extensions
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ryan Dy
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-02-22 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: fuubar
         
     |