Classic reduce (foldl) function but for objects
@param {Object} obj
@param {Function} cb
@param {any} initial
@param {Object} ctx
@return {any}
170715
function reduce (obj, cb, initial, ctx)
{
    var acc = initial;
    for(var key in obj)
        acc = cb.call(ctx, acc, key, obj[key]);
    return acc;
}
103355
public static <A, B> B reduce(final Iterable<A> iterable,
      final B initial, final Function2<A, B> func) {
    B b = initial;
    for (final A item : iterable) {
      b = func.apply(b, item);
    }
    return b;
  }
794857
function(key, ctx, partials, returnFound) {
      var val = false,
          v = null,
          found = false;

      for (var i = ctx.length - 1; i >= 0; i--) {
        v = ctx[i];
        if (v && typeof v == 'object' && key in v) {
          val = v[key];
          found = true;
          break;
        }
      }

      if (!found) {
        return (returnFound) ? false : "";
      }

      if (!returnFound && typeof val == 'function') {
        val = this.lv(val, ctx, partials);
      }

      return val;
    }
1066430
function (obj, pred) {
      var t = {};
      var f = {};
      each(obj, function(x, i) {
        var branch = pred(x, i) ? t : f;
        branch[i] = x;
      });
      return {
        t: t,
        f: f
      };
    }
1337591
function compact(obj) {
  if ('object' != typeof obj) return obj;

  if (isArray(obj)) {
    var ret = [];

    for (var i in obj) {
      if (hasOwnProperty.call(obj, i)) {
        ret.push(obj[i]);
      }
    }

    return ret;
  }

  for (var key in obj) {
    obj[key] = compact(obj[key]);
  }

  return obj;
}
1255213
function mergeRecursive(obj1, obj2) {
  if (!obj1 && obj2) {
    obj1 = {};
  }
  for (var key in obj2) {
    if (!obj2.hasOwnProperty(key)) {
      continue;
    }
    merge(obj1, obj2, key);
  }
  return obj1;
}
562966
function shallowClone(obj) {
    let result = {};
    for (let p in obj) {
        if (obj.hasOwnProperty(p)) {
            result[p] = obj[p];
        }
    }
    return result;
}
900727
function omit(keys, obj) {
  if(!isFoldable(keys)) {
    throw new TypeError('omit: Foldable required for first argument')
  }
  else if(!isObject(obj)) {
    throw new TypeError('omit: Object required for second argument')
  }

  return Object.keys(obj).reduce(omitKeys(keys, obj), {})
}
1166616
function flattenObject(ob) {
  return Object.entries(ob).reduce((accum, el) => {
    const [key, entry] = el;

    if (typeof entry === 'object' && entry !== null) {
      const flatObject = Object.entries(flattenObject(entry));

      flatObject.forEach((flattenedEntry) => {
        const [fkey, fentry] = flattenedEntry;
        // eslint-disable-next-line no-param-reassign
        accum[`${key}.${fkey}`] = fentry;
      });
    } else {
      // eslint-disable-next-line no-param-reassign
      accum[key] = entry;
    }

    return accum;
  }, {});
}
1252889
function ( obj ) {
		var result = [];

		result = obj.reduce( function ( a, b ) {
			return a.concat( b );
		}, result );

		return result;
	}
875329
function ( obj1, obj2 ) {
		var result;

		result = obj1.map( function ( i, idx ) {
			return [i, obj2[idx]];
		});

		return result;
	}
715695
def reduce(function, initval=None):
	
	if initval is None:
		return lambda s: __builtin__.reduce(function, s)
	else:
		return lambda s: __builtin__.reduce(function, s, initval)
1270776
function sortObject(originalSrc, options, done) {
  var callback

  if (options === undefined) {
    // do nothing
  } else if (typeof options === "function") {
    callback = options
  } else {
    callback = done
  }

  if (callback) {
    process.nextTick(function() {
      done(work(originalSrc))
    })
    return
  }

  function work(obj) {
    try {
      // Uses module to sort all objects key names based on standard
      // string ordering.
      var deepSorted = deep_sort_object(obj)

      // Once object keys are sorted, we still need to check for arrays.
      var out = deepInspect(deepSorted)
      return out
    } catch (e) {
      console.log(e)
      throw e
    }
  }

  return work(originalSrc)
}
600578
function removeBlankAttributes(obj) {
  return foldl(function(results, val, key) {
    if (val !== null && val !== undefined) results[key] = val;
    return results;
  }, {}, obj);
}
1172940
function defaultify (obj) {
    return Object.keys(self.defaults).reduce(function (acc, key) {
      if (!acc[key]) { acc[key] = self.defaults[key] }
      return acc;
    }, obj);
  }
1053687
function reduce(arr, iter, base) {
    arr = Immutable.Iterable.isIterable(arr)? arr : Immutable.List(arr);

    return arr.reduce(function(prev, elem, key) {
        return prev
        .then(function(val) {
            return iter(val, elem, key);
        });
    }, Q(base));
}
1051363
function sortObj(obj) {
    return Object.keys(obj).sort()
        .filter(key => obj[key] || obj[key] === 0)
        .reduce((acc, key) => ({ ...acc, [key]: obj[key] }), {});
}