Skip to content

Instantly share code, notes, and snippets.

@lorenzoongithub
Created June 4, 2015 19:23
Show Gist options
  • Save lorenzoongithub/5b6014f6d1976805c41e to your computer and use it in GitHub Desktop.
Save lorenzoongithub/5b6014f6d1976805c41e to your computer and use it in GitHub Desktop.
lodash.js
//
// https://lodash.com/ - lodash v3.9.3
//
// A JavaScript utility library delivering consistency, modularity, performance, & extras.
//
// The work here was derived from the examples in here: https://lodash.com/docs
//
load('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.9.3/lodash.js');
x= _.chunk(['a', 'b', 'c', 'd'], 2);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] === null) throw ""
if (x[0].length !== 2) throw ""
if (x[0][0] !== "a") throw ""
if (x[0][1] !== "b") throw ""
if (x[1] === null) throw ""
if (x[1].length !== 2) throw ""
if (x[1][0] !== "c") throw ""
if (x[1][1] !== "d") throw ""
x= _.drop([1, 2, 3]);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 2) throw ""
if (x[1] !== 3) throw ""
x= _.drop([1, 2, 3], 2);
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== 3) throw ""
x= _.drop([1, 2, 3], 5);
if (x === null) throw ""
if (x.length !== 0) throw ""
x= _.dropRight([1, 2, 3]);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 2) throw ""
x= _.dropRight([1, 2, 3], 2);
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== 1) throw ""
x= _.dropRight([1, 2, 3], 5);
if (x === null) throw ""
if (x.length !== 0) throw ""
x= _.dropRightWhile([1, 2, 3], function(n) {
  return n > 1;
});
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== 1) throw ""
var users = [
  { 'user': 'barney',  'active': true },
  { 'user': 'fred',    'active': false },
  { 'user': 'pebbles', 'active': false }
];
x= _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== "barney") throw ""
if (x[1] !== "fred") throw ""
x= _.pluck(_.dropRightWhile(users, 'active', false), 'user');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "barney") throw ""
x= _.dropWhile([1, 2, 3], function(n) {
  return n < 3;
});
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== 3) throw ""
var users = [
  { 'user': 'barney',  'active': false },
  { 'user': 'fred',    'active': false },
  { 'user': 'pebbles', 'active': true }
];
x= _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user');
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== "fred") throw ""
if (x[1] !== "pebbles") throw ""
x= _.pluck(_.dropWhile(users, 'active', false), 'user');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "pebbles") throw ""
var array = [1, 2, 3];
x= _.fill(array, 'a');
if (x === null) throw ""
if (x.length !== 3) throw ""
if (x[0] !== "a") throw ""
if (x[1] !== "a") throw ""
if (x[2] !== "a") throw ""
x= _.fill(Array(3), 2);
if (x === null) throw ""
if (x.length !== 3) throw ""
if (x[0] !== 2) throw ""
if (x[1] !== 2) throw ""
if (x[2] !== 2) throw ""
var users = [
  { 'user': 'barney',  'active': false },
  { 'user': 'fred',    'active': false },
  { 'user': 'pebbles', 'active': true }
];
x= _.findIndex(users, function(chr) {
  return chr.user == 'barney';
});
if (x !== 0) throw ""
x= _.findIndex(users, { 'user': 'fred', 'active': false });
if (x !== 1) throw ""
x= _.findIndex(users, 'active', false);
if (x !== 0) throw ""
var users = [
  { 'user': 'barney',  'active': true },
  { 'user': 'fred',    'active': false },
  { 'user': 'pebbles', 'active': false }
];
x= _.findLastIndex(users, function(chr) {
  return chr.user == 'pebbles';
});
if (x !== 2) throw ""
x= _.findLastIndex(users, { 'user': 'barney', 'active': true });
if (x !== 0) throw ""
x= _.findLastIndex(users, 'active', false);
if (x !== 2) throw ""
x= _.first([1, 2, 3]);
if (x !== 1) throw ""
x= _.flatten([1, [2, 3, [4]]]);
if (x === null) throw ""
if (x.length !== 4) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 2) throw ""
if (x[2] !== 3) throw ""
if (x[3] === null) throw ""
if (x[3].length !== 1) throw ""
if (x[3][0] !== 4) throw ""
x= _.indexOf([1, 2, 1, 2], 2);
if (x !== 1) throw ""
x= _.indexOf([1, 2, 1, 2], 2, 2);
if (x !== 3) throw ""
x= _.lastIndexOf([1, 2, 1, 2], 2);
if (x !== 3) throw ""
x= _.lastIndexOf([1, 2, 1, 2], 2, 2);
if (x !== 1) throw ""
x= _.sortedIndex([30, 50], 40);
if (x !== 1) throw ""
x= _.sortedIndex([4, 4, 5, 5], 5);
if (x !== 2) throw ""
var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } };
x= _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) {
  return this.data[word];
}, dict);
if (x !== 1) throw ""
x= _.take([1, 2, 3]);
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== 1) throw ""
x= _.take([1, 2, 3], 2);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 2) throw ""
x= _.take([1, 2, 3], 5);
if (x === null) throw ""
if (x.length !== 3) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 2) throw ""
if (x[2] !== 3) throw ""
x= _.takeRight([1, 2, 3]);
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== 3) throw ""
x= _.takeRight([1, 2, 3], 2);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 2) throw ""
if (x[1] !== 3) throw ""
x= _.takeRight([1, 2, 3], 5);
if (x === null) throw ""
if (x.length !== 3) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 2) throw ""
if (x[2] !== 3) throw ""
x= _.takeRightWhile([1, 2, 3], function(n) {
  return n > 1;
});
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 2) throw ""
if (x[1] !== 3) throw ""
var users = [
  { 'user': 'barney',  'active': true },
  { 'user': 'fred',    'active': false },
  { 'user': 'pebbles', 'active': false }
];
x= _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "pebbles") throw ""
x= _.pluck(_.takeRightWhile(users, 'active', false), 'user');
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== "fred") throw ""
if (x[1] !== "pebbles") throw ""
x= _.takeWhile([1, 2, 3], function(n) {
  return n < 3;
});
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 2) throw ""
var users = [
  { 'user': 'barney',  'active': false },
  { 'user': 'fred',    'active': false},
  { 'user': 'pebbles', 'active': true }
];
x= _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "barney") throw ""
x= _.pluck(_.takeWhile(users, 'active', false), 'user');
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== "barney") throw ""
if (x[1] !== "fred") throw ""
x= _.uniq([2, 1, 2]);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 2) throw ""
if (x[1] !== 1) throw ""
x= _.uniq([1, 1, 2], true);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 2) throw ""
x= _.uniq([1, 2.5, 1.5, 2], function(n) {
  return this.floor(n);
}, Math);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 2.5) throw ""
x= _.zipObject([['fred', 30], ['barney', 40]]);
if (x === null) throw ""
if (x.fred !== 30) throw ""
if (x.barney !== 40) throw ""
var wrapped = _([1, 2, 3]);
x = wrapped.reduce(function(total, n) {
return total + n;
});
if (x !== 6) throw ""
var squares = wrapped.map(function(n) {
  return n * n;
});
x= _.isArray(squares);
if (x) throw ""
var array = [1, 2];
var wrapper = _(array).push(3);
wrapper = wrapper.commit();
if (array === null) throw ""
if (array.length !== 3) throw ""
if (array[0] !== 1) throw ""
if (array[1] !== 2) throw ""
if (array[2] !== 3) throw ""
x= wrapper.last();
if (x !== 3) throw ""
x= _.at(['a', 'b', 'c'], [0, 2]);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== "a") throw ""
if (x[1] !== "c") throw ""
x= _.countBy([4.3, 6.1, 6.4], function(n) {
  return Math.floor(n);
});
if (x === null) throw ""
if (x[4] !== 1) throw ""
if (x[6] !== 2) throw ""
x= _.countBy([4.3, 6.1, 6.4], function(n) {
  return this.floor(n);
}, Math);
if (x === null) throw ""
if (x[4] !== 1) throw ""
if (x[6] !== 2) throw ""
x= _.every([true, 1, null, 'yes'], Boolean);
if (x) throw ""
var users = [
  { 'user': 'barney', 'active': false },
  { 'user': 'fred',   'active': false }
];
x= _.every(users, { 'user': 'barney', 'active': false });
if (x) throw ""
x= _.every(users, 'active', false);
if (x === false) throw ""
x= _.filter([4, 5, 6], function(n) {
  return n % 2 == 0;
});
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 4) throw ""
if (x[1] !== 6) throw ""
var users = [
  { 'user': 'barney', 'age': 36, 'active': true },
  { 'user': 'fred',   'age': 40, 'active': false }
];
x= _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "barney") throw ""
x= _.pluck(_.filter(users, 'active', false), 'user');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "fred") throw ""
var users = [
  { 'user': 'barney',  'age': 36, 'active': true },
  { 'user': 'fred',    'age': 40, 'active': false },
  { 'user': 'pebbles', 'age': 1,  'active': true }
];
x= _.result(_.find(users, function(chr) {
  return chr.age < 40;
}), 'user');
if (x !== "barney") throw ""
x= _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
if (x !== "pebbles") throw ""
x= _.result(_.find(users, 'active', false), 'user');
if (x !== "fred") throw ""
var users = [
  { 'user': 'barney', 'age': 36, 'active': true },
  { 'user': 'fred',   'age': 40, 'active': false }
];
x= _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user');
if (x !== "barney") throw ""
x= _.groupBy([4.2, 6.1, 6.4], function(n) {
  return Math.floor(n);
});
if (x === null) throw ""
if (x[4] === null) throw ""
if (x[4].length !== 1) throw ""
if (x[4][0] !== 4.2) throw ""
if (x[6] === null) throw ""
if (x[6].length !== 2) throw ""
if (x[6][0] !== 6.1) throw ""
if (x[6][1] !== 6.4) throw ""
x= _.groupBy([4.2, 6.1, 6.4], function(n) {
  return this.floor(n);
}, Math);
if (x === null) throw ""
if (x[4] === null) throw ""
if (x[4].length !== 1) throw ""
if (x[4][0] !== 4.2) throw ""
if (x[6] === null) throw ""
if (x[6].length !== 2) throw ""
if (x[6][0] !== 6.1) throw ""
if (x[6][1] !== 6.4) throw ""
x= _.includes([1, 2, 3], 1);
if (x === false) throw ""
x= _.includes([1, 2, 3], 1, 2);
if (x) throw ""
x= _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
if (x === false) throw ""
var keyData = [
  { 'dir': 'left', 'code': 97 },
  { 'dir': 'right', 'code': 100 }
];
x= _.indexBy(keyData, 'dir');
if (x === null) throw ""
if (x.left === null) throw ""
if (x.left.dir !== "left") throw ""
if (x.left.code !== 97) throw ""
if (x.right === null) throw ""
if (x.right.dir !== "right") throw ""
if (x.right.code !== 100) throw ""
x= _.indexBy(keyData, function(object) {
  return String.fromCharCode(object.code);
});
if (x === null) throw ""
if (x.a === null) throw ""
if (x.a.dir !== "left") throw ""
if (x.a.code !== 97) throw ""
if (x.d === null) throw ""
if (x.d.dir !== "right") throw ""
if (x.d.code !== 100) throw ""
x= _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] === null) throw ""
if (x[0].length !== 3) throw ""
if (x[0][0] !== 1) throw ""
if (x[0][1] !== 5) throw ""
if (x[0][2] !== 7) throw ""
if (x[1] === null) throw ""
if (x[1].length !== 3) throw ""
if (x[1][0] !== 1) throw ""
if (x[1][1] !== 2) throw ""
if (x[1][2] !== 3) throw ""
function timesThree(n) {
  return n * 3;
}
x= _.map([1, 2], timesThree);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 3) throw ""
if (x[1] !== 6) throw ""
x= _.partition([1, 2, 3], function(n) {
  return n % 2;
});
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] === null) throw ""
if (x[0].length !== 2) throw ""
if (x[0][0] !== 1) throw ""
if (x[0][1] !== 3) throw ""
if (x[1] === null) throw ""
if (x[1].length !== 1) throw ""
if (x[1][0] !== 2) throw ""
x= _.partition([1.2, 2.3, 3.4], function(n) {
  return this.floor(n) % 2;
}, Math);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] === null) throw ""
if (x[0].length !== 2) throw ""
if (x[0][0] !== 1.2) throw ""
if (x[0][1] !== 3.4) throw ""
if (x[1] === null) throw ""
if (x[1].length !== 1) throw ""
if (x[1][0] !== 2.3) throw ""
var users = [
  { 'user': 'barney',  'age': 36, 'active': false },
  { 'user': 'fred',    'age': 40, 'active': true },
  { 'user': 'pebbles', 'age': 1,  'active': false }
];
var mapper = function(array) {
  return _.pluck(array, 'user');
};
x= _.map(_.partition(users, { 'age': 1, 'active': false }), mapper);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] === null) throw ""
if (x[0].length !== 1) throw ""
if (x[0][0] !== "pebbles") throw ""
if (x[1] === null) throw ""
if (x[1].length !== 2) throw ""
if (x[1][0] !== "barney") throw ""
if (x[1][1] !== "fred") throw ""
x= _.map(_.partition(users, 'active', false), mapper);
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] === null) throw ""
if (x[0].length !== 2) throw ""
if (x[0][0] !== "barney") throw ""
if (x[0][1] !== "pebbles") throw ""
if (x[1] === null) throw ""
if (x[1].length !== 1) throw ""
if (x[1][0] !== "fred") throw ""
var users = [
  { 'user': 'barney', 'age': 36 },
  { 'user': 'fred',   'age': 40 }
];
x= _.pluck(users, 'user');
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== "barney") throw ""
if (x[1] !== "fred") throw ""
x= _.reduce([1, 2], function(total, n) {
  return total + n;
});
if (x !== 3) throw ""
x= _.reject([1, 2, 3, 4], function(n) {
  return n % 2 == 0;
});
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 3) throw ""
var users = [
  { 'user': 'barney', 'age': 36, 'active': false },
  { 'user': 'fred',   'age': 40, 'active': true }
];
x= _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "barney") throw ""
x= _.pluck(_.reject(users, 'active', false), 'user');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "fred") throw ""
x= _.size([1, 2, 3]);
if (x !== 3) throw ""
x= _.size({ 'a': 1, 'b': 2 });
if (x !== 2) throw ""
x= _.some([null, 0, 'yes', false], Boolean);
if (x === false) throw ""
var users = [
  { 'user': 'barney', 'active': true },
  { 'user': 'fred',   'active': false }
];
x= _.some(users, { 'user': 'barney', 'active': false });
if (x) throw ""
x= _.some(users, 'active', false);
if (x === false) throw ""
x= _.sortBy([1, 2, 3], function(n) {
  return Math.sin(n);
});
if (x === null) throw ""
if (x.length !== 3) throw ""
if (x[0] !== 3) throw ""
if (x[1] !== 1) throw ""
if (x[2] !== 2) throw ""
x= _.sortBy([1, 2, 3], function(n) {
  return this.sin(n);
}, Math);
if (x === null) throw ""
if (x.length !== 3) throw ""
if (x[0] !== 3) throw ""
if (x[1] !== 1) throw ""
if (x[2] !== 2) throw ""
var users = [
  { 'user': 'fred',   'age': 48 },
  { 'user': 'barney', 'age': 36 },
  { 'user': 'fred',   'age': 42 },
  { 'user': 'barney', 'age': 34 }
];
x= _.map(_.sortByAll(users, ['user', 'age']), _.values);
if (x === null) throw ""
if (x.length !== 4) throw ""
if (x[0] === null) throw ""
if (x[0].length !== 2) throw ""
if (x[0][0] !== "barney") throw ""
if (x[0][1] !== 34) throw ""
if (x[1] === null) throw ""
if (x[1].length !== 2) throw ""
if (x[1][0] !== "barney") throw ""
if (x[1][1] !== 36) throw ""
if (x[2] === null) throw ""
if (x[2].length !== 2) throw ""
if (x[2][0] !== "fred") throw ""
if (x[2][1] !== 42) throw ""
if (x[3] === null) throw ""
if (x[3].length !== 2) throw ""
if (x[3][0] !== "fred") throw ""
if (x[3][1] !== 48) throw ""
var users = [
  { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] },
  { 'user': 'fred',   'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] }
];
x= _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "barney") throw ""
x= _.gt(3, 1);
if (x === false) throw ""
x= _.gt(3, 3);
if (x) throw ""
x= _.gte(3, 1);
if (x === false) throw ""
x= _.gte(3, 3);
if (x === false) throw ""
x= _.isArguments(function() { return arguments; }());
if (x === false) throw ""
x= _.isArray([1, 2, 3]);
if (x === false) throw ""
x= _.isBoolean(false);
if (x === false) throw ""
x= _.isDate(new Date);
if (x === false) throw ""
x= _.isElement(document.body);
if (x === false) throw ""
x= _.isEmpty(null);
if (x === false) throw ""
x= _.isEmpty(true);
if (x === false) throw ""
x= _.isEmpty(1);
if (x === false) throw ""
x= _.isEmpty([1, 2, 3]);
if (x) throw ""
x= _.isError(new Error);
if (x === false) throw ""
x= _.isFinite(10);
if (x === false) throw ""
x= _.isFinite('10');
if (x) throw ""
x= _.isFinite(true);
if (x) throw ""
x= _.isFinite(Object(10));
if (x) throw ""
x= _.isFunction(_);
if (x === false) throw ""
var object = { 'user': 'fred', 'age': 40 };
x= _.isMatch(object, { 'age': 40 });
if (x === false) throw ""
x= _.isMatch(object, { 'age': 36 });
if (x) throw ""
x= _.isNaN(NaN);
if (x === false) throw ""
x= _.isNaN(new Number(NaN));
if (x === false) throw ""
x= isNaN(undefined);
if (x === false) throw ""
x= _.isNative(Array.prototype.push);
if (x === false) throw ""
x= _.isNull(null);
if (x === false) throw ""
x= _.isNumber(8.4);
if (x === false) throw ""
x= _.isNumber(NaN);
if (x === false) throw ""
x= _.isObject({});
if (x === false) throw ""
x= _.isObject([1, 2, 3]);
if (x === false) throw ""
function Foo() {
  this.a = 1;
}
x= _.isPlainObject(new Foo);
if (x) throw ""
x= _.isPlainObject([1, 2, 3]);
if (x) throw ""
x= _.isPlainObject({ 'x': 0, 'y': 0 });
if (x === false) throw ""
x= _.isRegExp(/abc/);
if (x === false) throw ""
x= _.isString('abc');
if (x === false) throw ""
x= _.isTypedArray(new Uint8Array);
if (x === false) throw ""
x= _.isUndefined(void 0);
if (x === false) throw ""
x= _.lt(1, 3);
if (x === false) throw ""
x= _.lt(3, 3);
if (x) throw ""
x= _.lte(1, 3);
if (x === false) throw ""
x= _.lte(3, 3);
if (x === false) throw ""
function Foo() {
  this.b = 2;
}
Foo.prototype.c = 3;
x= _.assign({ 'a': 1 }, new Foo);
if (x === null) throw ""
if (x.a !== 1) throw ""
if (x.b !== 2) throw ""
x= _.max([4, 2, 8, 6]);
if (x !== 8) throw ""
x= _.max([]);
if (x !== -Infinity) throw ""
var users = [
  { 'user': 'barney', 'age': 36 },
  { 'user': 'fred',   'age': 40 }
];
x= _.max(users, function(chr) {
  return chr.age;
});
if (x === null) throw ""
if (x.user !== "fred") throw ""
if (x.age !== 40) throw ""
x= _.min([4, 2, 8, 6]);
if (x !== 2) throw ""
x= _.min([]);
if (x !== Infinity) throw ""
var users = [
  { 'user': 'barney', 'age': 36 },
  { 'user': 'fred',   'age': 40 }
];
x= _.min(users, function(chr) {
  return chr.age;
});
if (x === null) throw ""
if (x.user !== "barney") throw ""
if (x.age !== 36) throw ""
x= _.sum([4, 6]);
if (x !== 10) throw ""
x= _.sum({ 'a': 4, 'b': 6 });
if (x !== 10) throw ""
var objects = [
  { 'n': 4 },
  { 'n': 6 }
];
x= _.sum(objects, function(object) {
  return object.n;
});
if (x !== 10) throw ""
x= _.inRange(3, 2, 4);
if (x === false) throw ""
x= _.inRange(4, 8);
if (x === false) throw ""
x= _.inRange(4, 2);
if (x) throw ""
x= _.inRange(2, 2);
if (x) throw ""
x= _.inRange(1.2, 2);
if (x === false) throw ""
x= _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
if (x === null) throw ""
if (x.user !== "fred") throw ""
if (x.age !== 40) throw ""
var object = { 'a': [{ 'b': { 'c': 3 } }] };
x= _.get(object, 'a[0].b.c');
if (x !== 3) throw ""
x= _.get(object, ['a', '0', 'b', 'c']);
if (x !== 3) throw ""
var object = { 'a': { 'b': { 'c': 3 } } };
x= _.has(object, 'a');
if (x === false) throw ""
x= _.has(object, 'a.b.c');
if (x === false) throw ""
var object = { 'a': 1, 'b': 2, 'c': 1 };
x= _.invert(object);
if (x === null) throw ""
if (x[1] !== "c") throw ""
if (x[2] !== "b") throw ""
x= _.mapValues({ 'a': 1, 'b': 2 }, function(n) {
  return n * 3;
});
if (x === null) throw ""
if (x.a !== 3) throw ""
if (x.b !== 6) throw ""
var users = {
  'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
};
var ages = {
  'data': [{ 'age': 36 }, { 'age': 40 }]
};
x= _.merge(users, ages);
if (x === null) throw ""
if (x.data === null) throw ""
if (x.data.length !== 2) throw ""
if (x.data[0] === null) throw ""
if (x.data[0].user !== "barney") throw ""
if (x.data[0].age !== 36) throw ""
if (x.data[1] === null) throw ""
if (x.data[1].user !== "fred") throw ""
if (x.data[1].age !== 40) throw ""
var object = { 'user': 'fred', 'age': 40 };
x= _.omit(object, 'age');
if (x === null) throw ""
if (x.user !== "fred") throw ""
var object = { 'user': 'fred', 'age': 40 };
x= _.pick(object, 'user');
if (x === null) throw ""
if (x.user !== "fred") throw ""
var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
x= _.result(object, 'a[0].b.c1');
if (x !== 3) throw ""
x= _.result(object, 'a[0].b.c2');
if (x !== 4) throw ""
x= _.result(object, 'a.b.c', 'default');
if (x !== "default") throw ""
x= _.transform([2, 3, 4], function(result, n) {
  result.push(n *= n);
  return n % 2 == 0;
});
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 4) throw ""
if (x[1] !== 9) throw ""
x= _.camelCase('Foo Bar');
if (x !== "fooBar") throw ""
x= _.camelCase('--foo-bar');
if (x !== "fooBar") throw ""
x= _.endsWith('abc', 'c');
if (x === false) throw ""
x= _.endsWith('abc', 'b');
if (x) throw ""
x= _.kebabCase('Foo Bar');
if (x !== "foo-bar") throw ""
x= _.kebabCase('fooBar');
if (x !== "foo-bar") throw ""
x= _.padLeft('abc', 6, '_-');
if (x !== "_-_abc") throw ""
x= _.padRight('abc', 6);
if (x !== "abc ") throw ""
x= _.padRight('abc', 6, '_-');
if (x !== "abc_-_") throw ""
x= _.parseInt('08');
if (x !== 8) throw ""
x= _.repeat('*', 3);
if (x !== "***") throw ""
x= _.repeat('abc', 2);
if (x !== "abcabc") throw ""
x= _.snakeCase('Foo Bar');
if (x !== "foo_bar") throw ""
x= _.snakeCase('fooBar');
if (x !== "foo_bar") throw ""
x= _.startCase('--foo-bar');
if (x !== "Foo Bar") throw ""
x= _.startCase('fooBar');
if (x !== "Foo Bar") throw ""
x= _.startsWith('abc', 'a');
if (x === false) throw ""
x= _.startsWith('abc', 'b');
if (x) throw ""
_.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
var compiled = _.template('hello {{ user }}!');
x = compiled({ 'user': 'mustache' });
if (x !== "hello mustache!") throw ""
x= _.trim('  abc  ');
if (x !== "abc") throw ""
x= _.trim('-_-abc-_-', '_-');
if (x !== "abc") throw ""
x= _.trimLeft('  abc  ');
if (x !== "abc  ") throw ""
x= _.trimRight('  abc  ');
if (x !== "  abc") throw ""
x= _.trunc('hi-diddly-ho there, neighborino');
if (x !== "hi-diddly-ho there, neighbo...") throw ""
x= _.trunc('hi-diddly-ho there, neighborino', 24);
if (x !== "hi-diddly-ho there, n...") throw ""
x= _.trunc('hi-diddly-ho there, neighborino', {
  'length': 24,
  'separator': ' '
});
if (x !== "hi-diddly-ho there,...") throw ""
x= _.words('fred, barney, & pebbles');
if (x === null) throw ""
if (x.length !== 3) throw ""
if (x[0] !== "fred") throw ""
if (x[1] !== "barney") throw ""
if (x[2] !== "pebbles") throw ""
var objects = [
  { 'a': { 'b': { 'c': _.constant(2) } } },
  { 'a': { 'b': { 'c': _.constant(1) } } }
];
x= _.map(objects, _.method('a.b.c'));
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 2) throw ""
if (x[1] !== 1) throw ""
var array = _.times(3, _.constant),
    object = { 'a': array, 'b': array, 'c': array };
x= _.map(['a[2]', 'c[0]'], _.methodOf(object));
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 2) throw ""
if (x[1] !== 0) throw ""
function vowels(string) {
  return _.filter(string, function(v) {
    return /[aeiou]/i.test(v);
  });
}
_.mixin({ 'vowels': vowels });
x = _.vowels('fred');
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "e") throw ""
x= _('fred').vowels().value();
if (x === null) throw ""
if (x.length !== 1) throw ""
if (x[0] !== "e") throw ""
var objects = [
  { 'a': { 'b': { 'c': 2 } } },
  { 'a': { 'b': { 'c': 1 } } }
];
x= _.map(objects, _.property('a.b.c'));
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 2) throw ""
if (x[1] !== 1) throw ""
var array = [0, 1, 2],
    object = { 'a': array, 'b': array, 'c': array };
x= _.map(['a[2]', 'c[0]'], _.propertyOf(object));
if (x === null) throw ""
if (x.length !== 2) throw ""
if (x[0] !== 2) throw ""
if (x[1] !== 0) throw ""
x= _.range(4);
if (x === null) throw ""
if (x.length !== 4) throw ""
if (x[0] !== 0) throw ""
if (x[1] !== 1) throw ""
if (x[2] !== 2) throw ""
if (x[3] !== 3) throw ""
x= _.range(1, 5);
if (x === null) throw ""
if (x.length !== 4) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 2) throw ""
if (x[2] !== 3) throw ""
if (x[3] !== 4) throw ""
x= _.range(0, 20, 5);
if (x === null) throw ""
if (x.length !== 4) throw ""
if (x[0] !== 0) throw ""
if (x[1] !== 5) throw ""
if (x[2] !== 10) throw ""
if (x[3] !== 15) throw ""
x= _.range(0, -4, -1);
if (x === null) throw ""
if (x.length !== 4) throw ""
if (x[0] !== 0) throw ""
if (x[1] !== -1) throw ""
if (x[2] !== -2) throw ""
if (x[3] !== -3) throw ""
x= _.range(1, 4, 0);
if (x === null) throw ""
if (x.length !== 3) throw ""
if (x[0] !== 1) throw ""
if (x[1] !== 1) throw ""
if (x[2] !== 1) throw ""
_.mixin({ 'foo': _.constant('foo') });
var lodash = _.runInContext();
lodash.mixin({ 'bar': lodash.constant('bar') });
x= _.isFunction(_.foo);
if (x === false) throw ""
x= _.isFunction(_.bar);
if (x) throw ""
x= lodash.isFunction(lodash.foo);
if (x) throw ""
x= lodash.isFunction(lodash.bar);
if (x === false) throw ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment