/**
 * This file extends Meteor's Underscore with selected methods from the latest version of Underscore,
 * copied from its source.
 */

// Internal function that returns an efficient (for current engines) version
// of the passed-in callback, to be repeatedly applied in other Underscore
// functions.
var optimizeCb = function(func, context, argCount) {
  if (context === void 0) return func;
  switch (argCount == null ? 3 : argCount) {
    case 1: return function(value) {
      return func.call(context, value);
    };
    case 2: return function(value, other) {
      return func.call(context, value, other);
    };
    case 3: return function(value, index, collection) {
      return func.call(context, value, index, collection);
    };
    case 4: return function(accumulator, value, index, collection) {
      return func.call(context, accumulator, value, index, collection);
    };
  }
  return function() {
    return func.apply(context, arguments);
  };
};

// A mostly-internal function to generate callbacks that can be applied
// to each element in a collection, returning the desired result — either
// identity, an arbitrary callback, a property matcher, or a property accessor.
var cb = function(value, context, argCount) {
  if (value == null) return _.identity;
  if (_.isFunction(value)) return optimizeCb(value, context, argCount);
  if (_.isObject(value)) return _.matcher(value);
  return _.property(value);
};

var property = function(key) {
  return function(obj) {
    return obj == null ? void 0 : obj[key];
  };
};

var getLength = property('length');

// Generator function to create the findIndex and findLastIndex functions
var createPredicateIndexFinder = function(dir) {
  return function(array, predicate, context) {
    predicate = cb(predicate, context);
    var length = getLength(array);
    var index = dir > 0 ? 0 : length - 1;
    for (; index >= 0 && index < length; index += dir) {
      if (predicate(array[index], index, array)) return index;
    }
    return -1;
  };
};

// Returns the first index on an array-like that passes a predicate test
_.findIndex = createPredicateIndexFinder(1);
_.findLastIndex = createPredicateIndexFinder(-1);

// Returns the results of applying the iteratee to each element of the object
  // In contrast to _.map it returns an object
_.mapObject = function(obj, iteratee, context) {
  iteratee = cb(iteratee, context);
  var keys = _.keys(obj),
    length = keys.length,
    results = {};
  for (var index = 0; index < length; index++) {
    var currentKey = keys[index];
    results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
  }
  return results;
};

@@ -2013,16 +2013,28 @@
  %7D;%0A%7D;%0A%0A
+_.mixin(%7B%0A  
 // Retur
@@ -2098,18 +2098,18 @@
 te test%0A
-_.
+  
 findInde
@@ -2105,26 +2105,25 @@
 %0A  findIndex
- =
+:
  createPredi
@@ -2144,12 +2144,12 @@
 r(1)
-;%0A_.
+,%0A  
 find
@@ -2157,18 +2157,17 @@
 astIndex
- =
+:
  createP
@@ -2189,19 +2189,21 @@
 nder(-1)
-;
+,
 %0A%0A
+  
 // Retur
@@ -2319,18 +2319,18 @@
  object%0A
-_.
+  
 mapObjec
@@ -2330,18 +2330,17 @@
 apObject
- =
+:
  functio
@@ -2367,16 +2367,18 @@
 text) %7B%0A
+  
   iterat
@@ -2405,16 +2405,18 @@
 ntext);%0A
+  
   var ke
@@ -2479,16 +2479,18 @@
 = %7B%7D;%0A  
+ 
+ 
 for (var
@@ -2528,24 +2528,26 @@
 ex++) %7B%0A    
+  
 var currentK
@@ -2564,24 +2564,26 @@
 index%5D;%0A    
+ 
+ 
 results%5Bcurr
@@ -2636,20 +2636,24 @@
 , obj);%0A
+  
   %7D%0A
+  
   return
@@ -2662,11 +2662,16 @@
 esults;%0A
-%7D
+  %7D%0A%7D)
 ;%0A

use mixin to add functions so they work with _.chain.