Term
|
Definition
The semantic version number. |
|
|
Term
|
Definition
function square(n) { return n * n; }
var wrapped = f([1, 2, 3]); // Returns an unwrapped value.
wrapped.reduce(_.add); // 6
// Returns a wrapped value.
var squares = wrapped.map(square);
_.isArray(squares); // false
_.isArray(squares.value()); // true |
|
|
Term
|
Definition
|
|
Term
|
Definition
var saves = ['profile', 'settings'];
var done = _.f(saves.length, () => { console.log('done saving!'); });
_.forEach(saves, type => { asyncSave({ 'type': type, 'complete': done });
}); // => Logs 'done saving!' after the two async saves have completed. |
|
|
Term
|
Definition
_.map(['6', '8', '10'], _.f(parseInt, 1)); // [6, 8, 10] |
|
|
Term
|
Definition
function Foo() { this.a = 1; }
function Bar() { this.c = 3; }
Foo.prototype.b = 2;
Bar.prototype.d = 4;
_.f({ 'a': 0 }, new Foo, new Bar); // { 'a': 1, 'c': 3 } |
|
|
Term
|
Definition
function Foo() { this.a = 1; }
function Bar() { this.c = 3; }
Foo.prototype.b = 2;
Bar.prototype.d = 4;
_.f({ 'a': 0 }, new Foo, new Bar); // { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } |
|
|
Term
|
Definition
function customizer(objValue, srcValue) { return _.isUndefined(objValue) ? srcValue : objValue; }
var defaults = _.partialRight(_.f, customizer);
defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); // { 'a': 1, 'b': 2 } |
|
|
Term
|
Definition
function customizer(objValue, srcValue) { return _.isUndefined(objValue) ? srcValue : objValue; }
var defaults = _.partialRight(_.f, customizer);
defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); // { 'a': 1, 'b': 2 } |
|
|
Term
|
Definition
var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
_.f(object, ['a[0].b.c', 'a[1]']); // [3, 4] |
|
|
Term
|
Definition
// Avoid throwing errors for invalid selectors.
var elements = _.f(function(selector) { return document.querySelectorAll(selector); }, '>_>');
if (_.isError(elements)) { elements = []; } |
|
|
Term
|
Definition
jQuery(element).on('click', _.f(5, addContactToList)); // Allows adding up to 4 contacts to the list. |
|
|
Term
|
Definition
function greet(greeting, punctuation) { return greeting + ' ' + this.user + punctuation; }
var object = { 'user': 'fred' };
var bound = _.f(greet, object, 'hi'); bound('!'); // 'hi fred!' // Bound with placeholders.
var bound = _.f(greet, object, _, '!');
bound('hi'); // 'hi fred!' |
|
|
Term
|
Definition
var view = { 'label': 'docs', 'click': () => { console.log('clicked ' + this.label); } };
_.f(view, ['click']);
jQuery(element).on('click', view.click); // Logs 'clicked docs' when clicked. |
|
|
Term
|
Definition
var object = { 'user': 'fred', 'greet': function(greeting, punctuation) { return greeting + ' ' + this.user + punctuation; } }; var bound = _.f(object, 'greet', 'hi'); bound('!'); // => 'hi fred!' object.greet = function(greeting, punctuation) { return greeting + 'ya ' + this.user + punctuation; }; bound('!'); // => 'hiya fred!' // Bound with placeholders. var bound = _.f(object, 'greet', _, '!'); bound('hi'); // => 'hiya fred!' |
|
|
Term
|
Definition
_.f('Foo Bar'); // => 'fooBar' _.f('--foo-bar--'); // => 'fooBar' _.f('__FOO_BAR__'); // => 'fooBar' |
|
|
Term
|
Definition
|
|
Term
|
Definition
_.f(1); // => [1] _.f({ 'a': 1 }); // => [{ 'a': 1 }] _.f('abc'); // => ['abc'] _.f(null); // => [null] _.f(undefined); // => [undefined] _.f(); // => [] var array = [1, 2, 3]; console.log(_.f(array) === array); // => true |
|
|
Term
|
Definition
_.f(4.006); // => 5 _.f(6.004, 2); // => 6.01 _.f(6040, -2); // => 6100 |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }, { 'user': 'pebbles', 'age': 1 } ]; var youngest = _ .f(users) .sortBy('age') .map(function(o) { return o.user + ' is ' + o.age; }) .head() .value(); // => 'pebbles is 1' |
|
|
Term
|
Definition
_.f(['a', 'b', 'c', 'd'], 2); // => [['a', 'b'], ['c', 'd']] _.f(['a', 'b', 'c', 'd'], 3); // => [['a', 'b', 'c'], ['d']] |
|
|
Term
|
Definition
_.f(-10, -5, 5); // => -5 _.f(10, -5, 5); // => 5 |
|
|
Term
|
Definition
var objects = [{ 'a': 1 }, { 'b': 2 }]; var shallow = _.f(objects); console.log(shallow[0] === objects[0]); // => true |
|
|
Term
|
Definition
var objects = [{ 'a': 1 }, { 'b': 2 }]; var deep = _.f(objects); console.log(deep[0] === objects[0]); // => false |
|
|
Term
|
Definition
function customizer(value) { if (_.isElement(value)) { return value.cloneNode(true); } } var el = _.f(document.body, customizer); console.log(el === document.body); // => false console.log(el.nodeName); // => 'BODY' console.log(el.childNodes.length); // => 20 |
|
|
Term
|
Definition
function customizer(value) { if (_.isElement(value)) { return value.cloneNode(false); } } var el = _.f(document.body, customizer); console.log(el === document.body); // => false console.log(el.nodeName); // => 'BODY' console.log(el.childNodes.length); // => 0 |
|
|
Term
|
Definition
_.f([0, 1, false, 2, '', 3]); // => [1, 2, 3] |
|
|
Term
|
Definition
var array = [1]; var other = _.f(array, 2, [3], [[4]]); console.log(other); // => [1, 2, 3, [4]] console.log(array); // => [1] |
|
|
Term
|
Definition
var func = _.f([ [_.matches({ 'a': 1 }), _.constant('matches A')], [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], [_.stubTrue, _.constant('no match')] ]); func({ 'a': 1, 'b': 2 }); // => 'matches A' func({ 'a': 0, 'b': 1 }); // => 'matches B' func({ 'a': '1', 'b': '2' }); // => 'no match' |
|
|
Term
|
Definition
var objects = [ { 'a': 2, 'b': 1 }, { 'a': 1, 'b': 2 } ]; _.filter(objects, _.f({ 'b': function(n) { return n > 1; } })); // => [{ 'a': 1, 'b': 2 }] |
|
|
Term
|
Definition
var object = { 'a': 1, 'b': 2 }; _.f(object, { 'b': function(n) { return n > 1; } }); // => true _.f(object, { 'b': function(n) { return n > 2; } }); // => false |
|
|
Term
|
Definition
var objects = _.times(2, _.f({ 'a': 1 })); console.log(objects); // => [{ 'a': 1 }, { 'a': 1 }] console.log(objects[0] === objects[1]); // => true |
|
|
Term
|
Definition
_.f([6.1, 4.2, 6.3], Math.floor); // => { '4': 1, '6': 2 } // The `_.property` iteratee shorthand. _.f(['one', 'two', 'three'], 'length'); // => { '3': 2, '5': 1 } |
|
|
Term
|
Definition
function Shape() { this.x = 0; this.y = 0; } function Circle() { Shape.call(this); } Circle.prototype = _.f(Shape.prototype, { 'constructor': Circle }); var circle = new Circle; circle instanceof Circle; // => true circle instanceof Shape; // => true |
|
|
Term
|
Definition
var abc = function(a, b, c) { return [a, b, c]; }; var curried = _.f(abc); curried(1)(2)(3); // => [1, 2, 3] curried(1, 2)(3); // => [1, 2, 3] curried(1, 2, 3); // => [1, 2, 3] // Curried with placeholders. curried(1)(_, 3)(2); // => [1, 2, 3] |
|
|
Term
|
Definition
var abc = function(a, b, c) { return [a, b, c]; }; var curried = _.f(abc); curried(3)(2)(1); // => [1, 2, 3] curried(2, 3)(1); // => [1, 2, 3] curried(1, 2, 3); // => [1, 2, 3] // Curried with placeholders. curried(3)(1, _)(2); // => [1, 2, 3] |
|
|
Term
|
Definition
// Avoid costly calculations while the window size is in flux. jQuery(window).on('resize', _.f(calculateLayout, 150)); // Invoke `sendMail` when clicked, debouncing subsequent calls. jQuery(element).on('click', _.f(sendMail, 300, { 'leading': true, 'trailing': false })); // Ensure `batchLog` is invoked once after 1 second of debounced calls. var debounced = _.f(batchLog, 250, { 'maxWait': 1000 }); var source = new EventSource('/stream'); jQuery(source).on('message', debounced); // Cancel the trailing debounced invocation. jQuery(window).on('popstate', debounced.cancel); |
|
|
Term
|
Definition
_.f('déjà vu'); // => 'deja vu' |
|
|
Term
|
Definition
_.f(1, 10); // => 1 _.f(undefined, 10); // => 10 |
|
|
Term
|
Definition
_.f({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); // => { 'a': 1, 'b': 2 } |
|
|
Term
|
Definition
_.f({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); // => { 'a': { 'b': 2, 'c': 3 } } |
|
|
Term
|
Definition
_.f(function(text) { console.log(text); }, 'deferred'); // => Logs 'deferred' after one millisecond. |
|
|
Term
|
Definition
_.f(function(text) { console.log(text); }, 1000, 'later'); // => Logs 'later' after one second. |
|
|
Term
|
Definition
_.f([2, 1], [2, 3]); // => [1] |
|
|
Term
|
Definition
_.f([2.1, 1.2], [2.3, 3.4], Math.floor); // => [1.2] // The `_.property` iteratee shorthand. _.f([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); // => [{ 'x': 2 }] |
|
|
Term
|
Definition
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; _.f(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); // => [{ 'x': 2, 'y': 1 }] |
|
|
Term
|
Definition
|
|
Term
|
Definition
_.f([1, 2, 3]); // => [2, 3] _.f([1, 2, 3], 2); // => [3] _.f([1, 2, 3], 5); // => [] _.f([1, 2, 3], 0); // => [1, 2, 3] |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => [1, 2] _.f([1, 2, 3], 2); // => [1] _.f([1, 2, 3], 5); // => [] _.f([1, 2, 3], 0); // => [1, 2, 3] |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'active': true }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': false } ]; _.f(users, function(o) { return !o.active; }); // => objects for ['barney'] // The `_.matches` iteratee shorthand. _.f(users, { 'user': 'pebbles', 'active': false }); // => objects for ['barney', 'fred'] // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => objects for ['barney'] // The `_.property` iteratee shorthand. _.f(users, 'active'); // => objects for ['barney', 'fred', 'pebbles'] |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'active': false }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': true } ]; _.f(users, function(o) { return !o.active; }); // => objects for ['pebbles'] // The `_.matches` iteratee shorthand. _.f(users, { 'user': 'barney', 'active': false }); // => objects for ['fred', 'pebbles'] // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => objects for ['pebbles'] // The `_.property` iteratee shorthand. _.f(users, 'active'); // => objects for ['barney', 'fred', 'pebbles'] |
|
|
Term
|
Definition
_.f('abc', 'c'); // => true _.f('abc', 'b'); // => false _.f('abc', 'b', 2); // => true |
|
|
Term
|
Definition
var object = { 'a': 1 }; var other = { 'a': 1 }; _.f(object, object); // => true _.f(object, other); // => false _.f('a', 'a'); // => true _.f('a', Object('a')); // => false _.f(NaN, NaN); // => true |
|
|
Term
|
Definition
_.f('fred, barney, & pebbles'); // => 'fred, barney, & pebbles' |
|
|
Term
|
Definition
_.f('[lodash](https://lodash.com/)'); // => '\[lodash\]\(https://lodash\.com/\)' |
|
|
Term
|
Definition
_.f([true, 1, null, 'yes'], Boolean); // => false var users = [ { 'user': 'barney', 'age': 36, 'active': false }, { 'user': 'fred', 'age': 40, 'active': false } ]; // The `_.matches` iteratee shorthand. _.f(users, { 'user': 'barney', 'active': false }); // => false // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => true // The `_.property` iteratee shorthand. _.f(users, 'active'); // => false |
|
|
Term
|
Definition
var array = [1, 2, 3]; _.f(array, 'a'); console.log(array); // => ['a', 'a', 'a'] _.f(Array(3), 2); // => [2, 2, 2] _.f([4, 6, 8, 10], '*', 1, 3); // => [4, '*', '*', 10] |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'age': 36, 'active': true }, { 'user': 'fred', 'age': 40, 'active': false } ]; _.f(users, function(o) { return !o.active; }); // => objects for ['fred'] // The `_.matches` iteratee shorthand. _.f(users, { 'age': 36, 'active': true }); // => objects for ['barney'] // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => objects for ['fred'] // The `_.property` iteratee shorthand. _.f(users, 'active'); // => objects for ['barney'] |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'age': 36, 'active': true }, { 'user': 'fred', 'age': 40, 'active': false }, { 'user': 'pebbles', 'age': 1, 'active': true } ]; _.f(users, function(o) { return o.age < 40; }); // => object for 'barney' // The `_.matches` iteratee shorthand. _.f(users, { 'age': 1, 'active': true }); // => object for 'pebbles' // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => object for 'fred' // The `_.property` iteratee shorthand. _.f(users, 'active'); // => object for 'barney' |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'active': false }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': true } ]; _.f(users, function(o) { return o.user == 'barney'; }); // => 0 // The `_.matches` iteratee shorthand. _.f(users, { 'user': 'fred', 'active': false }); // => 1 // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => 0 // The `_.property` iteratee shorthand. _.f(users, 'active'); // => 2 |
|
|
Term
|
Definition
var users = { 'barney': { 'age': 36, 'active': true }, 'fred': { 'age': 40, 'active': false }, 'pebbles': { 'age': 1, 'active': true } }; _.f(users, function(o) { return o.age < 40; }); // => 'barney' (iteration order is not guaranteed) // The `_.matches` iteratee shorthand. _.f(users, { 'age': 1, 'active': true }); // => 'pebbles' // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => 'fred' // The `_.property` iteratee shorthand. _.f(users, 'active'); // => 'barney' |
|
|
Term
|
Definition
_.f([1, 2, 3, 4], function(n) { return n % 2 == 1; }); // => 3 |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'active': true }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': false } ]; _.f(users, function(o) { return o.user == 'pebbles'; }); // => 2 // The `_.matches` iteratee shorthand. _.f(users, { 'user': 'barney', 'active': true }); // => 0 // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => 2 // The `_.property` iteratee shorthand. _.f(users, 'active'); // => 0 |
|
|
Term
|
Definition
var users = { 'barney': { 'age': 36, 'active': true }, 'fred': { 'age': 40, 'active': false }, 'pebbles': { 'age': 1, 'active': true } }; _.findLastKey(users, function(o) { return o.age < 40; }); // => returns 'pebbles' assuming `_.f` returns 'barney' // The `_.matches` iteratee shorthand. _.f(users, { 'age': 36, 'active': true }); // => 'barney' // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => 'fred' // The `_.property` iteratee shorthand. _.f(users, 'active'); // => 'pebbles' |
|
|
Term
|
Definition
function duplicate(n) { return [n, n]; } _.f([1, 2], duplicate); // => [1, 1, 2, 2] |
|
|
Term
|
Definition
function duplicate(n) { return [[[n, n]]]; } _.f([1, 2], duplicate); // => [1, 1, 2, 2] |
|
|
Term
|
Definition
function duplicate(n) { return [[[n, n]]]; } _.f([1, 2], duplicate, 2); // => [[1, 1], [2, 2] |
|
|
Term
|
Definition
_.f([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5] |
|
|
Term
|
Definition
_.f([1, [2, [3, [4]], 5]]); // => [1, 2, 3, 4, 5] |
|
|
Term
|
Definition
var array = [1, [2, [3, [4]], 5]]; _.f(array, 1); // => [1, 2, [3, [4]], 5] _.f(array, 2); // => [1, 2, 3, [4], 5] |
|
|
Term
|
Definition
var flipped = _.f(function() { return _.toArray(arguments); }); flipped('a', 'b', 'c', 'd'); // => ['d', 'c', 'b', 'a'] |
|
|
Term
|
Definition
_.f(4.006); // => 4 _.f(0.046, 2); // => 0.04 _.f(4060, -2); // => 4000 |
|
|
Term
|
Definition
function square(n) { return n * n; } var addSquare = _.f([_.add, square]); addSquare(1, 2); // => 9 |
|
|
Term
|
Definition
function square(n) { return n * n; } var addSquare = _.f([square, _.add]); addSquare(1, 2); // => 9 |
|
|
Term
|
Definition
_.f([1, 2], function(value) { console.log(value); }); // => Logs `1` then `2`. _.f({ 'a': 1, 'b': 2 }, function(value, key) { console.log(key); }); // => Logs 'a' then 'b' (iteration order is not guaranteed). |
|
|
Term
|
Definition
_.f([1, 2], function(value) { console.log(value); }); // => Logs `2` then `1`. |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo, function(value, key) { console.log(key); }); // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo, function(value, key) { console.log(key); }); // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo, function(value, key) { console.log(key); }); // => Logs 'a' then 'b' (iteration order is not guaranteed). |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo, function(value, key) { console.log(key); }); // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. |
|
|
Term
|
Definition
_.f([['a', 1], ['b', 2]]); // => { 'a': 1, 'b': 2 } |
|
|
Term
|
Definition
function Foo() { this.a = _.constant('a'); this.b = _.constant('b'); } Foo.prototype.c = _.constant('c'); _.f(new Foo); // => ['a', 'b'] |
|
|
Term
|
Definition
function Foo() { this.a = _.constant('a'); this.b = _.constant('b'); } Foo.prototype.c = _.constant('c'); _.f(new Foo); // => ['a', 'b', 'c'] |
|
|
Term
|
Definition
var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.f(object, 'a[0].b.c'); // => 3 _.f(object, ['a', '0', 'b', 'c']); // => 3 _.f(object, 'a.b.c', 'default'); // => 'default' |
|
|
Term
|
Definition
_.f([6.1, 4.2, 6.3], Math.floor); // => { '4': [4.2], '6': [6.1, 6.3] } // The `_.property` iteratee shorthand. _.f(['one', 'two', 'three'], 'length'); // => { '3': ['one', 'two'], '5': ['three'] } |
|
|
Term
|
Definition
_.f(3, 1); // => true _.f(3, 3); // => false _.f(1, 3); // => false |
|
|
Term
|
Definition
_.f(3, 1); // => true _.f(3, 3); // => true _.f(1, 3); // => false |
|
|
Term
|
Definition
var object = { 'a': { 'b': 2 } }; var other = _.create({ 'a': _.create({ 'b': 2 }) }); _.f(object, 'a'); // => true _.f(object, 'a.b'); // => true _.f(object, ['a', 'b']); // => true _.f(other, 'a'); // => false |
|
|
Term
|
Definition
var object = _.create({ 'a': _.create({ 'b': 2 }) }); _.f(object, 'a'); // => true _.f(object, 'a.b'); // => true _.f(object, ['a', 'b']); // => true _.f(object, 'b'); // => false |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => 1 _.head([]); // => undefined |
|
|
Term
|
Definition
var object = { 'a': 1 }; console.log(_.f(object) === object); // => true |
|
|
Term
|
Definition
_.f(3, 2, 4); // => true _.f(4, 8); // => true _.f(4, 2); // => false _.f(2, 2); // => false _.f(1.2, 2); // => true _.f(5.2, 4); // => false _.f(-3, -2, -6); // => true |
|
|
Term
|
Definition
_.f([1, 2, 3], 1); // => true _.f([1, 2, 3], 1, 2); // => false _.f({ 'a': 1, 'b': 2 }, 1); // => true _.f('abcd', 'bc'); // => true |
|
|
Term
|
Definition
_.f([1, 2, 1, 2], 2); // => 1 // Search from the `fromIndex`. _.f([1, 2, 1, 2], 2, 2); // => 3 |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => [1, 2] |
|
|
Term
|
Definition
_.f([2, 1], [2, 3]); // => [2] |
|
|
Term
|
Definition
_.f([2.1, 1.2], [2.3, 3.4], Math.floor); // => [2.1] // The `_.property` iteratee shorthand. _.f([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); // => [{ 'x': 1 }] |
|
|
Term
|
Definition
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; _.f(objects, others, _.isEqual); // => [{ 'x': 1, 'y': 2 }] |
|
|
Term
|
Definition
var object = { 'a': 1, 'b': 2, 'c': 1 }; _.f(object); // => { '1': 'c', '2': 'b' } |
|
|
Term
|
Definition
var object = { 'a': 1, 'b': 2, 'c': 1 }; _.f(object); // => { '1': ['a', 'c'], '2': ['b'] } _.f(object, function(value) { return 'group' + value; }); // => { 'group1': ['a', 'c'], 'group2': ['b'] } |
|
|
Term
|
Definition
var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; _.f(object, 'a[0].b.c.slice', 1, 3); // => [2, 3] |
|
|
Term
|
Definition
_.f([[5, 1, 7], [3, 2, 1]], 'sort'); // => [[1, 5, 7], [1, 2, 3]] _.f([123, 456], String.prototype.split, ''); // => [['1', '2', '3'], ['4', '5', '6']] |
|
|
Term
|
Definition
_.f(function() { return arguments; }()); // => true _.f([1, 2, 3]); // => false |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => true _.f(document.body.children); // => false _.f('abc'); // => false _.f(_.noop); // => false |
|
|
Term
|
Definition
_.f(new ArrayBuffer(2)); // => true _.f(new Array(2)); // => false |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => true _.f(document.body.children); // => true _.f('abc'); // => true _.f(_.noop); // => false |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => true _.f(document.body.children); // => true _.f('abc'); // => false _.f(_.noop); // => false |
|
|
Term
|
Definition
_.f(false); // => true _.f(null); // => false |
|
|
Term
|
Definition
_.f(new Buffer(2)); // => true _.f(new Uint8Array(2)); // => false |
|
|
Term
|
Definition
_.f(new Date); // => true _.f('Mon April 23 2012'); // => false |
|
|
Term
|
Definition
_.f(document.body);
// => true
_.f("<body>");
// => false |
|
|
Term
|
Definition
_.f(null); // => true _.f(true); // => true _.f(1); // => true _.f([1, 2, 3]); // => false _.f({ 'a': 1 }); // => false |
|
|
Term
|
Definition
var object = { 'a': 1 }; var other = { 'a': 1 }; _.f(object, other); // => true object === other; // => false |
|
|
Term
|
Definition
function isGreeting(value) { return /^h(?:i|ello)$/.test(value); } function customizer(objValue, othValue) { if (isGreeting(objValue) && isGreeting(othValue)) { return true; } } var array = ['hello', 'goodbye']; var other = ['hi', 'goodbye']; _.f(array, other, customizer); // => true |
|
|
Term
|
Definition
_.f(new Error); // => true _.f(Error); // => false |
|
|
Term
|
Definition
_.f(3); // => true _.f(Number.MIN_VALUE); // => true _.f(Infinity); // => false _.f('3'); // => false |
|
|
Term
|
Definition
_.f(_); // => true _.f(/abc/); // => false |
|
|
Term
|
Definition
_.f(3); // => true _.f(Number.MIN_VALUE); // => false _.f(Infinity); // => false _.f('3'); // => false |
|
|
Term
|
Definition
_.f(3); // => true _.f(Number.MIN_VALUE); // => false _.f(Infinity); // => false _.f('3'); // => false |
|
|
Term
|
Definition
_.f(new Map); // => true _.f(new WeakMap); // => false |
|
|
Term
|
Definition
var object = { 'a': 1, 'b': 2 }; _.f(object, { 'b': 2 }); // => true _.f(object, { 'b': 1 }); // => false |
|
|
Term
|
Definition
function isGreeting(value) { return /^h(?:i|ello)$/.test(value); } function customizer(objValue, srcValue) { if (isGreeting(objValue) && isGreeting(srcValue)) { return true; } } var object = { 'greeting': 'hello' }; var source = { 'greeting': 'hi' }; _.f(object, source, customizer); // => true |
|
|
Term
|
Definition
_.f(NaN); // => true _.f(new Number(NaN)); // => true isNaN(undefined); // => true _.f(undefined); // => false |
|
|
Term
|
Definition
_.f(Array.prototype.push); // => true _.f(_); // => false |
|
|
Term
|
Definition
_.f(null); // => true _.f(void 0); // => true _.f(NaN); // => false |
|
|
Term
|
Definition
_.f(null); // => true _.f(void 0); // => false |
|
|
Term
|
Definition
_.f(3); // => true _.f(Number.MIN_VALUE); // => true _.f(Infinity); // => true _.f('3'); // => false |
|
|
Term
|
Definition
_.f({}); // => true _.f([1, 2, 3]); // => true _.f(_.noop); // => true _.f(null); // => false |
|
|
Term
|
Definition
_.f({}); // => true _.f([1, 2, 3]); // => true _.f(_.noop); // => false _.f(null); // => false |
|
|
Term
|
Definition
function Foo() { this.a = 1; } _.f(new Foo); // => false _.f([1, 2, 3]); // => false _.f({ 'x': 0, 'y': 0 }); // => true _.f(Object.create(null)); // => true |
|
|
Term
|
Definition
_.f(/abc/); // => true _.f('/abc/'); // => false |
|
|
Term
|
Definition
_.f(3); // => true _.f(Number.MIN_VALUE); // => false _.f(Infinity); // => false _.f('3'); // => false |
|
|
Term
|
Definition
_.f(new Set); // => true _.f(new WeakSet); // => false |
|
|
Term
|
Definition
_.f('abc'); // => true _.f(1); // => false |
|
|
Term
|
Definition
_.f(Symbol.iterator); // => true _.f('abc'); // => false |
|
|
Term
|
Definition
_.f(new Uint8Array); // => true _.f([]); // => false |
|
|
Term
|
Definition
_.f(void 0); // => true _.f(null); // => false |
|
|
Term
|
Definition
_.f(new WeakMap); // => true _.f(new Map); // => false |
|
|
Term
|
Definition
_.f(new WeakSet); // => true _.f(new Set); // => false |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'age': 36, 'active': true }, { 'user': 'fred', 'age': 40, 'active': false } ]; // The `_.matches` iteratee shorthand. _.filter(users, _.f({ 'user': 'barney', 'active': true })); // => [{ 'user': 'barney', 'age': 36, 'active': true }] // The `_.matchesProperty` iteratee shorthand. _.filter(users, _.f(['user', 'fred'])); // => [{ 'user': 'fred', 'age': 40 }] // The `_.property` iteratee shorthand. _.map(users, _.f('user')); // => ['barney', 'fred'] // Create custom iteratee shorthands. _.f = _.wrap(_.iteratee, function(iteratee, func) { return !_.isRegExp(func) ? iteratee(func) : function(string) { return func.test(string); }; }); _.filter(['abc', 'def'], /ef/); // => ['def'] |
|
|
Term
|
Definition
_.f(['a', 'b', 'c'], '~'); // => 'a~b~c' |
|
|
Term
|
Definition
_.f('Foo Bar'); // => 'foo-bar' _.f('fooBar'); // => 'foo-bar' _.f('__FOO_BAR__'); // => 'foo-bar' |
|
|
Term
|
Definition
var array = [ { 'dir': 'left', 'code': 97 }, { 'dir': 'right', 'code': 100 } ]; _.f(array, function(o) { return String.fromCharCode(o.code); }); // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } _.f(array, 'dir'); // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo); // => ['a', 'b'] (iteration order is not guaranteed) _.f('hi'); // => ['0', '1'] |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo); // => ['a', 'b', 'c'] (iteration order is not guaranteed) |
|
|
Term
|
Definition
|
|
Term
|
Definition
_.f([1, 2, 1, 2], 2); // => 3 // Search from the `fromIndex`. _.f([1, 2, 1, 2], 2, 2); // => 1 |
|
|
Term
|
Definition
_.f('--Foo-Bar--'); // => 'foo bar' _.f('fooBar'); // => 'foo bar' _.f('__FOO_BAR__'); // => 'foo bar' |
|
|
Term
|
Definition
_.f('Fred'); // => 'fred' _.f('FRED'); // => 'fRED' |
|
|
Term
|
Definition
_.f(1, 3); // => true _.f(3, 3); // => false _.f(3, 1); // => false |
|
|
Term
|
Definition
_.f(1, 3); // => true _.f(3, 3); // => true _.f(3, 1); // => false |
|
|
Term
|
Definition
function square(n) { return n * n; } _.f([4, 8], square); // => [16, 64] _.f({ 'a': 4, 'b': 8 }, square); // => [16, 64] (iteration order is not guaranteed) var users = [ { 'user': 'barney' }, { 'user': 'fred' } ]; // The `_.property` iteratee shorthand. _.f(users, 'user'); // => ['barney', 'fred'] |
|
|
Term
|
Definition
_.f({ 'a': 1, 'b': 2 }, function(value, key) { return key + value; }); // => { 'a1': 1, 'b2': 2 } |
|
|
Term
|
Definition
var users = { 'fred': { 'user': 'fred', 'age': 40 }, 'pebbles': { 'user': 'pebbles', 'age': 1 } }; _.f(users, function(o) { return o.age; }); // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) // The `_.property` iteratee shorthand. _.f(users, 'age'); // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) |
|
|
Term
|
Definition
var objects = [ { 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 } ]; _.filter(objects, _.f({ 'a': 4, 'c': 6 })); // => [{ 'a': 4, 'b': 5, 'c': 6 }] |
|
|
Term
|
Definition
var objects = [ { 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 } ]; _.find(objects, _.f('a', 4)); // => { 'a': 4, 'b': 5, 'c': 6 } |
|
|
Term
|
Definition
_.f([4, 2, 8, 6]); // => 8 _.f([]); // => undefined |
|
|
Term
|
Definition
var objects = [{ 'n': 1 }, { 'n': 2 }]; _.f(objects, function(o) { return o.n; }); // => { 'n': 2 } // The `_.property` iteratee shorthand. _.f(objects, 'n'); // => { 'n': 2 } |
|
|
Term
|
Definition
_.f([4, 2, 8, 6]); // => 5 |
|
|
Term
|
Definition
var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; _.f(objects, function(o) { return o.n; }); // => 5 // The `_.property` iteratee shorthand. _.f(objects, 'n'); // => 5 |
|
|
Term
|
Definition
var object = { 'a': 1, 'b': 2 }; var other = { 'c': 3, 'd': 4 }; var values = _.f(_.values); values(object); // => [1, 2] values(other); // => [3, 4] object.a = 2; values(object); // => [1, 2] // Modify the result cache. values.cache.set(object, ['a', 'b']); values(object); // => ['a', 'b'] // Replace `_.memoize.Cache`. _.memoize.Cache = WeakMap; |
|
|
Term
|
Definition
var object = { 'a': [{ 'b': 2 }, { 'd': 4 }] }; var other = { 'a': [{ 'c': 3 }, { 'e': 5 }] }; _.f(object, other); // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } |
|
|
Term
|
Definition
function customizer(objValue, srcValue) { if (_.isArray(objValue)) { return objValue.concat(srcValue); } } var object = { 'a': [1], 'b': [2] }; var other = { 'a': [3], 'b': [4] }; _.f(object, other, customizer); // => { 'a': [1, 3], 'b': [2, 4] } |
|
|
Term
|
Definition
var objects = [ { 'a': { 'b': _.constant(2) } }, { 'a': { 'b': _.constant(1) } } ]; _.map(objects, _.f('a.b')); // => [2, 1] _.map(objects, _.f(['a', 'b'])); // => [2, 1] |
|
|
Term
|
Definition
var array = _.times(3, _.constant), object = { 'a': array, 'b': array, 'c': array }; _.map(['a[2]', 'c[0]'], _.f(object)); // => [2, 0] _.map([['a', '2'], ['c', '0']], _.f(object)); // => [2, 0] |
|
|
Term
|
Definition
_.f([4, 2, 8, 6]); // => 2 _.f([]); // => undefined |
|
|
Term
|
Definition
var objects = [{ 'n': 1 }, { 'n': 2 }]; _.f(objects, function(o) { return o.n; }); // => { 'n': 1 } // The `_.property` iteratee shorthand. _.f(objects, 'n'); // => { 'n': 1 } |
|
|
Term
|
Definition
function vowels(string) { return _.filter(string, function(v) { return /[aeiou]/i.test(v); }); } _.f({ 'vowels': vowels }); _.vowels('fred'); // => ['e'] _('fred').vowels().value(); // => ['e'] _.f({ 'vowels': vowels }, { 'chain': false }); _('fred').vowels(); // => ['e'] |
|
|
Term
|
Definition
|
|
Term
|
Definition
function isEven(n) { return n % 2 == 0; } _.filter([1, 2, 3, 4, 5, 6], _.f(isEven)); // => [1, 3, 5] |
|
|
Term
|
Definition
|
|
Term
|
Definition
_.times(2, _.f); // => [undefined, undefined] |
|
|
Term
|
Definition
_.defer(function(stamp) { console.log(_.now() - stamp); }, _.f()); // => Logs the number of milliseconds it took for the deferred invocation. |
|
|
Term
|
Definition
var array = ['a', 'b', 'c', 'd']; _.f(array, 1); // => 'b' _.f(array, -2); // => 'c'; |
|
|
Term
|
Definition
var func = _.f(1); func('a', 'b', 'c', 'd'); // => 'b' var func = _.f(-2); func('a', 'b', 'c', 'd'); // => 'c' |
|
|
Term
|
Definition
var object = { 'a': 1, 'b': '2', 'c': 3 }; _.f(object, ['a', 'c']); // => { 'b': '2' } |
|
|
Term
|
Definition
var object = { 'a': 1, 'b': '2', 'c': 3 }; _.f(object, _.isNumber); // => { 'b': '2' } |
|
|
Term
|
Definition
var initialize = _.f(createApplication); initialize(); initialize(); // => `createApplication` is invoked once |
|
|
Term
|
Definition
var users = [ { 'user': 'fred', 'age': 48 }, { 'user': 'barney', 'age': 34 }, { 'user': 'fred', 'age': 40 }, { 'user': 'barney', 'age': 36 } ]; // Sort by `user` in ascending order and by `age` in descending order. _.f(users, ['user', 'age'], ['asc', 'desc']); // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] |
|
|
Term
|
Definition
var func = _.f([Math.max, Math.min]); func(1, 2, 3, 4); // => [4, 1] |
|
|
Term
|
Definition
function doubled(n) { return n * 2; } function square(n) { return n * n; } var func = _.f(function(x, y) { return [x, y]; }, [square, doubled]); func(9, 3); // => [81, 6] func(10, 5); // => [100, 10] |
|
|
Term
|
Definition
var func = _.f([Boolean, isFinite]); func('1'); // => true func(null); // => false func(NaN); // => false |
|
|
Term
|
Definition
var func = _.f([Boolean, isFinite]); func('1'); // => true func(null); // => true func(NaN); // => false |
|
|
Term
|
Definition
_.f('abc', 8); // => ' abc ' _.f('abc', 8, '_-'); // => '_-abc_-_' _.f('abc', 3); // => 'abc' |
|
|
Term
|
Definition
_.f('abc', 6); // => 'abc ' _.f('abc', 6, '_-'); // => 'abc_-_' _.f('abc', 3); // => 'abc' |
|
|
Term
|
Definition
_.f('abc', 6); // => ' abc' _.f('abc', 6, '_-'); // => '_-_abc' _.f('abc', 3); // => 'abc' |
|
|
Term
|
Definition
_.f('08'); // => 8 _.map(['6', '08', '10'], _.f); // => [6, 8, 10] |
|
|
Term
|
Definition
function greet(greeting, name) { return greeting + ' ' + name; } var sayHelloTo = _.f(greet, 'hello'); sayHelloTo('fred'); // => 'hello fred' // Partially applied with placeholders. var greetFred = _.f(greet, _, 'fred'); greetFred('hi'); // => 'hi fred' |
|
|
Term
|
Definition
function greet(greeting, name) { return greeting + ' ' + name; } var greetFred = _.f(greet, 'fred'); greetFred('hi'); // => 'hi fred' // Partially applied with placeholders. var sayHelloTo = _.f(greet, 'hello', _); sayHelloTo('fred'); // => 'hello fred' |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'age': 36, 'active': false }, { 'user': 'fred', 'age': 40, 'active': true }, { 'user': 'pebbles', 'age': 1, 'active': false } ]; _.f(users, function(o) { return o.active; }); // => objects for [['fred'], ['barney', 'pebbles']] // The `_.matches` iteratee shorthand. _.f(users, { 'age': 1, 'active': false }); // => objects for [['pebbles'], ['barney', 'fred']] // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => objects for [['barney', 'pebbles'], ['fred']] // The `_.property` iteratee shorthand. _.f(users, 'active'); // => objects for [['fred'], ['barney', 'pebbles']] |
|
|
Term
|
Definition
var object = { 'a': 1, 'b': '2', 'c': 3 }; _.f(object, ['a', 'c']); // => { 'a': 1, 'c': 3 } |
|
|
Term
|
Definition
var object = { 'a': 1, 'b': '2', 'c': 3 }; _.f(object, _.isNumber); // => { 'a': 1, 'c': 3 } |
|
|
Term
|
Definition
var objects = [ { 'a': { 'b': 2 } }, { 'a': { 'b': 1 } } ]; _.map(objects, _.f('a.b')); // => [2, 1] _.map(_.sortBy(objects, _.f(['a', 'b'])), 'a.b'); // => [1, 2] |
|
|
Term
|
Definition
var array = [0, 1, 2], object = { 'a': array, 'b': array, 'c': array }; _.map(['a[2]', 'c[0]'], _.f(object)); // => [2, 0] _.map([['a', '2'], ['c', '0']], _.f(object)); // => [2, 0] |
|
|
Term
|
Definition
var wrapped = f([1, 2]); wrapped[Symbol.iterator]() === wrapped; // => true Array.from(wrapped); // => [1, 2] |
|
|
Term
|
Definition
var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; f(object).f(['a[0].b.c', 'a[1]']).value(); // => [3, 4] |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 } ]; // A sequence without explicit chaining. f(users).head(); // => { 'user': 'barney', 'age': 36 } // A sequence with explicit chaining. f(users) .f() .head() .pick('user') .value(); // => { 'user': 'barney' } |
|
|
Term
|
Definition
var array = [1, 2]; var wrapped = f(array).push(3); console.log(array); // => [1, 2] wrapped = wrapped.f(); console.log(array); // => [1, 2, 3] wrapped.last(); // => 3 console.log(array); // => [1, 2, 3] |
|
|
Term
|
Definition
var wrapped = f([1, 2]); wrapped.f(); // => { 'done': false, 'value': 1 } wrapped.f(); // => { 'done': false, 'value': 2 } wrapped.f(); // => { 'done': true, 'value': undefined } |
|
|
Term
|
Definition
function square(n) { return n * n; } var wrapped = f([1, 2]).map(square); var other = wrapped.f([3, 4]); other.value(); // => [9, 16] wrapped.value(); // => [1, 4] |
|
|
Term
|
Definition
var array = [1, 2, 3]; f(array).f().value() // => [3, 2, 1] console.log(array); // => [3, 2, 1] |
|
|
Term
|
Definition
f([1, 2, 3]).f(); // => [1, 2, 3] |
|
|
Term
|
Definition
var array = ['a', 'b', 'c', 'a', 'b', 'c']; _.f(array, 'a', 'c'); console.log(array); // => ['b', 'b'] |
|
|
Term
|
Definition
var array = ['a', 'b', 'c', 'a', 'b', 'c']; _.f(array, ['a', 'c']); console.log(array); // => ['b', 'b'] |
|
|
Term
|
Definition
var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; _.f(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); console.log(array); // => [{ 'x': 2 }] |
|
|
Term
|
Definition
var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; _.f(array, [{ 'x': 3, 'y': 4 }], _.isEqual); console.log(array); // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] |
|
|
Term
|
Definition
var array = ['a', 'b', 'c', 'd']; var pulled = _.f(array, [1, 3]); console.log(array); // => ['a', 'c'] console.log(pulled); // => ['b', 'd'] |
|
|
Term
|
Definition
_.f(0, 5); // => an integer between 0 and 5 _.f(5); // => also an integer between 0 and 5 _.f(5, true); // => a floating-point number between 0 and 5 _.f(1.2, 5.2); // => a floating-point number between 1.2 and 5.2 |
|
|
Term
|
Definition
_.f(4); // => [0, 1, 2, 3] _.f(-4); // => [0, -1, -2, -3] _.f(1, 5); // => [1, 2, 3, 4] _.f(0, 20, 5); // => [0, 5, 10, 15] _.f(0, -4, -1); // => [0, -1, -2, -3] _.f(1, 4, 0); // => [1, 1, 1] _.f(0); // => [] |
|
|
Term
|
Definition
_.f(4); // => [3, 2, 1, 0] _.f(-4); // => [-3, -2, -1, 0] _.f(1, 5); // => [4, 3, 2, 1] _.f(0, 20, 5); // => [15, 10, 5, 0] _.f(0, -4, -1); // => [-3, -2, -1, 0] _.f(1, 4, 0); // => [1, 1, 1] _.f(0); // => [] |
|
|
Term
|
Definition
var rearged = _.f(function(a, b, c) { return [a, b, c]; }, [2, 0, 1]); rearged('b', 'c', 'a') // => ['a', 'b', 'c'] |
|
|
Term
|
Definition
_.f([1, 2], function(sum, n) { return sum + n; }, 0); // => 3 _.f({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { (result[value] || (result[value] = [])).push(key); return result; }, {}); // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) |
|
|
Term
|
Definition
var array = [[0, 1], [2, 3], [4, 5]]; _.f(array, function(flattened, other) { return flattened.concat(other); }, []); // => [4, 5, 2, 3, 0, 1] |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'age': 36, 'active': false }, { 'user': 'fred', 'age': 40, 'active': true } ]; _.f(users, function(o) { return !o.active; }); // => objects for ['fred'] // The `_.matches` iteratee shorthand. _.f(users, { 'age': 40, 'active': true }); // => objects for ['barney'] // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => objects for ['fred'] // The `_.property` iteratee shorthand. _.f(users, 'active'); // => objects for ['barney'] |
|
|
Term
|
Definition
var array = [1, 2, 3, 4]; var evens = _.f(array, function(n) { return n % 2 == 0; }); console.log(array); // => [1, 3] console.log(evens); // => [2, 4] |
|
|
Term
|
Definition
_.f('*', 3); // => '***' _.f('abc', 2); // => 'abcabc' _.f('abc', 0); // => '' |
|
|
Term
|
Definition
_.f('Hi Fred', 'Fred', 'Barney'); // => 'Hi Barney' |
|
|
Term
|
Definition
var say = _.f(function(what, names) { return what + ' ' + _.initial(names).join(', ') + (_.size(names) > 1 ? ', & ' : '') + _.last(names); }); say('hello', 'fred', 'barney', 'pebbles'); // => 'hello fred, barney, & pebbles' |
|
|
Term
|
Definition
var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; _.f(object, 'a[0].b.c1'); // => 3 _.f(object, 'a[0].b.c2'); // => 4 _.f(object, 'a[0].b.c3', 'default'); // => 'default' _.f(object, 'a[0].b.c3', _.constant('default')); // => 'default' |
|
|
Term
|
Definition
var array = [1, 2, 3]; _.f(array); // => [3, 2, 1] console.log(array); // => [3, 2, 1] |
|
|
Term
|
Definition
_.f(4.006); // => 4 _.f(4.006, 2); // => 4.01 _.f(4060, -2); // => 4100 |
|
|
Term
|
Definition
_.mixin({ 'foo': _.constant('foo') }); var lodash = _.f(); lodash.mixin({ 'bar': lodash.constant('bar') }); _.isFunction(_.foo); // => true _.isFunction(_.bar); // => false lodash.isFunction(lodash.foo); // => false lodash.isFunction(lodash.bar); // => true // Create a suped-up `defer` in Node.js. var defer = _.f({ 'setTimeout': setImmediate }).defer; |
|
|
Term
|
Definition
_.f([1, 2, 3, 4]); // => 2 |
|
|
Term
|
Definition
_.f([1, 2, 3], 2); // => [3, 1] _.f([1, 2, 3], 4); // => [2, 3, 1] |
|
|
Term
|
Definition
var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.f(object, 'a[0].b.c', 4); console.log(object.a[0].b.c); // => 4 _.f(object, ['x', '0', 'y', 'z'], 5); console.log(object.x[0].y.z); // => 5 |
|
|
Term
|
Definition
var object = {}; _.f(object, '[0][1]', 'a', Object); // => { '0': { '1': 'a' } } |
|
|
Term
|
Definition
_.f([1, 2, 3, 4]); // => [4, 1, 3, 2] |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => 3 _.size({ 'a': 1, 'b': 2 }); // => 2 _.f('pebbles'); // => 7 |
|
|
Term
|
Definition
var array = [1, 2, 3];
_.f(array, 1, 2); // => [2] |
|
|
Term
|
Definition
_.f('Foo Bar'); // => 'foo_bar' _.f('fooBar'); // => 'foo_bar' _.f('--FOO-BAR--'); // => 'foo_bar' |
|
|
Term
|
Definition
_.f([null, 0, 'yes', false], Boolean); // => true var users = [ { 'user': 'barney', 'active': true }, { 'user': 'fred', 'active': false } ]; // The `_.matches` iteratee shorthand. _.f(users, { 'user': 'barney', 'active': false }); // => false // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => true // The `_.property` iteratee shorthand. _.f(users, 'active'); // => true |
|
|
Term
|
Definition
var users = [ { 'user': 'fred', 'age': 48 }, { 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }, { 'user': 'barney', 'age': 34 } ]; _.f(users, [function(o) { return o.user; }]); // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] _.f(users, ['user', 'age']); // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] |
|
|
Term
|
Definition
_.f([30, 50], 40); // => 1 |
|
|
Term
|
Definition
var objects = [{ 'x': 4 }, { 'x': 5 }]; _.f(objects, { 'x': 4 }, function(o) { return o.x; }); // => 0 // The `_.property` iteratee shorthand. _.f(objects, { 'x': 4 }, 'x'); // => 0 |
|
|
Term
|
Definition
_.f([4, 5, 5, 5, 6], 5); // => 1 |
|
|
Term
|
Definition
_.f([4, 5, 5, 5, 6], 5); // => 4 |
|
|
Term
|
Definition
var objects = [{ 'x': 4 }, { 'x': 5 }]; _.f(objects, { 'x': 4 }, function(o) { return o.x; }); // => 1 // The `_.property` iteratee shorthand. _.f(objects, { 'x': 4 }, 'x'); // => 1 |
|
|
Term
|
Definition
_.f([4, 5, 5, 5, 6], 5); // => 3 |
|
|
Term
|
Definition
_.f([1, 1, 2]); // => [1, 2] |
|
|
Term
|
Definition
_.f([1.1, 1.2, 2.3, 2.4], Math.floor); // => [1.1, 2.3] |
|
|
Term
|
Definition
_.f('a-b-c', '-', 2); // => ['a', 'b'] |
|
|
Term
|
Definition
var say = _.f(function(who, what) { return who + ' says ' + what; }); say(['fred', 'hello']); // => 'fred says hello' var numbers = Promise.all([ Promise.resolve(40), Promise.resolve(36) ]); numbers.then(_.f(function(x, y) { return x + y; })); // => a Promise of 76 |
|
|
Term
|
Definition
_.f('--foo-bar--'); // => 'Foo Bar' _.f('fooBar'); // => 'Foo Bar' _.f('__FOO_BAR__'); // => 'FOO BAR' |
|
|
Term
|
Definition
_.f('abc', 'a'); // => true _.f('abc', 'b'); // => false _.f('abc', 'b', 1); // => true |
|
|
Term
|
Definition
var arrays = _.times(2, _.f); console.log(arrays); // => [[], []] console.log(arrays[0] === arrays[1]); // => false |
|
|
Term
|
Definition
_.times(2, _.f); // => [false, false] |
|
|
Term
|
Definition
var objects = _.times(2, _.f); console.log(objects); // => [{}, {}] console.log(objects[0] === objects[1]); // => false |
|
|
Term
|
Definition
_.times(2, _.f); // => ['', ''] |
|
|
Term
|
Definition
_.times(2, _.f); // => [true, true] |
|
|
Term
|
Definition
|
|
Term
|
Definition
_.f([4, 2, 8, 6]); // => 20 |
|
|
Term
|
Definition
var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; _.f(objects, function(o) { return o.n; }); // => 20 // The `_.property` iteratee shorthand. _.f(objects, 'n'); // => 20 |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => [2, 3] |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => [1]
_.f([1, 2, 3], 2); // => [1, 2] _.f([1, 2, 3], 5); // => [1, 2, 3] _.f([1, 2, 3], 0); // => [] |
|
|
Term
|
Definition
_.f([1, 2, 3]); // => [3] _.f([1, 2, 3], 2); // => [2, 3] _.f([1, 2, 3], 5); // => [1, 2, 3] _.f([1, 2, 3], 0); // => [] |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'active': true }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': false } ]; _.f(users, function(o) { return !o.active; }); // => objects for ['fred', 'pebbles'] // The `_.matches` iteratee shorthand. _.f(users, { 'user': 'pebbles', 'active': false }); // => objects for ['pebbles'] // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => objects for ['fred', 'pebbles'] // The `_.property` iteratee shorthand. _.f(users, 'active'); // => [] |
|
|
Term
|
Definition
var users = [ { 'user': 'barney', 'active': false }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': true } ]; _.f(users, function(o) { return !o.active; }); // => objects for ['barney', 'fred'] // The `_.matches` iteratee shorthand. _.f(users, { 'user': 'barney', 'active': false }); // => objects for ['barney'] // The `_.matchesProperty` iteratee shorthand. _.f(users, ['active', false]); // => objects for ['barney', 'fred'] // The `_.property` iteratee shorthand. _.f(users, 'active'); // => [] |
|
|
Term
|
Definition
_([1, 2, 3]) .f(function(array) { // Mutate input array. array.pop(); }) .reverse() .value(); // => [2, 1] |
|
|
Term
|
Definition
// Use the "interpolate" delimiter to create a compiled template.
var compiled = _.f('hello <%= user %>!');
compiled({ 'user': 'fred' });
// => 'hello fred!'
// Use the HTML "escape" delimiter to escape data property values.
var compiled = _.f('<b><%- value %></b>');
compiled({ 'value': '<script>' });
// => '<b><script></b>'
// Use the "evaluate" delimiter to execute JavaScript and generate HTML.
var compiled = _.f('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
compiled({ 'users': ['fred', 'barney'] });
// => '<li>fred</li><li>barney</li>'
// Use the internal `print` function in "evaluate" delimiters.
var compiled = _.f('<% print("hello " + user); %>!');
compiled({ 'user': 'barney' });
// => 'hello barney!'
// Use the ES template literal delimiter as an "interpolate" delimiter.
// Disable support by replacing the "interpolate" delimiter.
var compiled = _.f('hello ${ user }!');
compiled({ 'user': 'pebbles' });
// => 'hello pebbles!'
// Use backslashes to treat delimiters as plain text.
var compiled = _.f('<%= "\\<%- value %\\>" %>');
compiled({ 'value': 'ignored' });
// => '<%- value %>'
// Use the `imports` option to import `jQuery` as `jq`.
var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
var compiled = _.f(text, { 'imports': { 'jq': jQuery } });
compiled({ 'users': ['fred', 'barney'] });
// => '<li>fred</li><li>barney</li>'
// Use the `sourceURL` option to specify a custom sourceURL for the template.
var compiled = _.f('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
compiled(data);
// => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
// Use the `variable` option to ensure a with-statement isn't used in the compiled template.
var compiled = _.f('hi <%= data.user %>!', { 'variable': 'data' });
compiled.source;
// => function(data) {
// var __t, __p = '';
// __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
// return __p;
// }
// Use custom template delimiters.
_.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
var compiled = _.f('hello {{ user }}!');
compiled({ 'user': 'mustache' });
// => 'hello mustache!'
// Use the `source` property to inline compiled templates for meaningful
// line numbers in error messages and stack traces.
fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
var JST = {\
"main": ' + _.f(mainText).source + '\
};\
'); |
|
|
Term
|
Definition
Used to change template delimiters. |
|
|
Term
|
Definition
Used to detect data property values to be HTML-escaped. |
|
|
Term
templateSettings.evaluate |
|
Definition
Used to detect code to be evaluated. |
|
|
Term
|
Definition
Used to import variables into the compiled template. |
|
|
Term
templateSettings.imports._ |
|
Definition
A reference to the lodash function. |
|
|
Term
templateSettings.interpolate |
|
Definition
Used to detect data property values to inject. |
|
|
Term
templateSettings.variable |
|
Definition
Used to reference the data object in the template text. |
|
|
Term
|
Definition
// Avoid excessively updating the position while scrolling. jQuery(window).on('scroll', _.f(updatePosition, 100)); // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. var throttled = _.f(renewToken, 300000, { 'trailing': false }); jQuery(element).on('click', throttled); // Cancel the trailing throttled invocation. jQuery(window).on('popstate', throttled.cancel); |
|
|
Term
|
Definition
_(' abc ') .chain() .trim() .f(function(value) { return [value]; }) .value(); // => ['abc'] |
|
|
Term
|
Definition
_.f(3, String); // => ['0', '1', '2'] _.f(4, _.constant(0)); // => [0, 0, 0, 0] |
|
|
Term
|
Definition
_.f({ 'a': 1, 'b': 2 }); // => [1, 2] _.f('abc'); // => ['a', 'b', 'c'] _.f(1); // => [] _.f(null); // => [] |
|
|
Term
|
Definition
_.f(3.2); // => 3.2 _.f(Number.MIN_VALUE); // => 5e-324 _.f(Infinity); // => 1.7976931348623157e+308 _.f('3.2'); // => 3.2 |
|
|
Term
|
Definition
_.f(3.2); // => 3 _.f(Number.MIN_VALUE); // => 0 _.f(Infinity); // => 1.7976931348623157e+308 _.f('3.2'); // => 3 |
|
|
Term
|
Definition
_.f(3.2); // => 3 _.f(Number.MIN_VALUE); // => 0 _.f(Infinity); // => 4294967295 _.f('3.2'); // => 3 |
|
|
Term
|
Definition
_.f('--Foo-Bar--'); // => '--foo-bar--' _.f('fooBar'); // => 'foobar' _.f('__FOO_BAR__'); // => '__foo_bar__' |
|
|
Term
|
Definition
_.f(3.2); // => 3.2 _.f(Number.MIN_VALUE); // => 5e-324 _.f(Infinity); // => Infinity _.f('3.2'); // => 3.2 |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo); // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo); // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) |
|
|
Term
|
Definition
_.f('a.b.c'); // => ['a', 'b', 'c'] _.f('a[0].b.c'); // => ['a', '0', 'b', 'c'] |
|
|
Term
|
Definition
function Foo() { this.b = 2; } Foo.prototype.c = 3; _.assign({ 'a': 1 }, new Foo); // => { 'a': 1, 'b': 2 } _.assign({ 'a': 1 }, _.f(new Foo)); // => { 'a': 1, 'b': 2, 'c': 3 } |
|
|
Term
|
Definition
_.f(3.2); // => 3 _.f(Number.MIN_VALUE); // => 0 _.f(Infinity); // => 9007199254740991 _.f('3.2'); // => 3 |
|
|
Term
|
Definition
_.f(null); // => '' _.f(-0); // => '-0' _.f([1, 2, 3]); // => '1,2,3' |
|
|
Term
|
Definition
_.f('--foo-bar--'); // => '--FOO-BAR--' _.f('fooBar'); // => 'FOOBAR' _.f('__foo_bar__'); // => '__FOO_BAR__' |
|
|
Term
|
Definition
_.f([2, 3, 4], function(result, n) { result.push(n *= n); return n % 2 == 0; }, []); // => [4, 9] _.f({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { (result[value] || (result[value] = [])).push(key); }, {}); // => { '1': ['a', 'c'], '2': ['b'] } |
|
|
Term
|
Definition
_.f(' abc '); // => 'abc' _.f('-_-abc-_-', '_-'); // => 'abc' _.map([' foo ', ' bar '], _.f); // => ['foo', 'bar'] |
|
|
Term
|
Definition
_.f(' abc '); // => ' abc' _.f('-_-abc-_-', '_-'); // => '-_-abc' |
|
|
Term
|
Definition
_.f(' abc '); // => 'abc ' _.f('-_-abc-_-', '_-'); // => 'abc-_-' |
|
|
Term
|
Definition
_.f('hi-diddly-ho there, neighborino'); // => 'hi-diddly-ho there, neighbo...' _.f('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); // => 'hi-diddly-ho there,...' _.f('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); // => 'hi-diddly-ho there...' _.f('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); // => 'hi-diddly-ho there, neig [...]' |
|
|
Term
|
Definition
_.map(['6', '8', '10'], _.f(parseInt)); // => [6, 8, 10] |
|
|
Term
|
Definition
_.f('fred, barney, & pebbles'); // => 'fred, barney, & pebbles' |
|
|
Term
|
Definition
_.f([2], [1, 2]); // => [2, 1] |
|
|
Term
|
Definition
_.f([2.1], [1.2, 2.3], Math.floor); // => [2.1, 1.2] // The `_.property` iteratee shorthand. _.f([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); // => [{ 'x': 1 }, { 'x': 2 }] |
|
|
Term
|
Definition
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; _.f(objects, others, _.isEqual); // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] |
|
|
Term
|
Definition
_.f([2, 1, 2]); // => [2, 1] |
|
|
Term
|
Definition
_.f([2.1, 1.2, 2.3], Math.floor); // => [2.1, 1.2] // The `_.property` iteratee shorthand. _.f([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); // => [{ 'x': 1 }, { 'x': 2 }] |
|
|
Term
|
Definition
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; _.f(objects, _.isEqual); // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] |
|
|
Term
|
Definition
_.f('contact_'); // => 'contact_104' _.f(); // => '105' |
|
|
Term
|
Definition
var object = { 'a': [{ 'b': { 'c': 7 } }] }; _.f(object, 'a[0].b.c'); // => true console.log(object); // => { 'a': [{ 'b': {} }] }; _.f(object, ['a', '0', 'b', 'c']); // => true console.log(object); // => { 'a': [{ 'b': {} }] }; |
|
|
Term
|
Definition
var array = [['a', 1, true], ['b', 2, false]]; _.f(array); // => [['a', 'b'], [1, 2], [true, false]] |
|
|
Term
|
Definition
var array = [[1, 10, 100], [2, 20, 200]]; _.f(array, _.add); // => [3, 30, 300] |
|
|
Term
|
Definition
var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.f(object, 'a[0].b.c', function(n) { return n * n; }); console.log(object.a[0].b.c); // => 9 _.f(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); console.log(object.x[0].y.z); // => 0 |
|
|
Term
|
Definition
var object = {}; _.f(object, '[0][1]', _.constant('a'), Object); // => { '0': { '1': 'a' } } |
|
|
Term
|
Definition
_.f('--foo-bar'); // => 'FOO BAR' _.f('fooBar'); // => 'FOO BAR' _.f('__foo_bar__'); // => 'FOO BAR' |
|
|
Term
|
Definition
_.f('fred'); // => 'Fred' _.f('FRED'); // => 'FRED' |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo); // => [1, 2] (iteration order is not guaranteed) _.f('hi'); // => ['h', 'i'] |
|
|
Term
|
Definition
function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.f(new Foo); // => [1, 2, 3] (iteration order is not guaranteed) |
|
|
Term
|
Definition
_.f([2, 1, 2, 3], 1, 2); // => [3] |
|
|
Term
|
Definition
_.f('fred, barney, & pebbles'); // => ['fred', 'barney', 'pebbles'] _.f('fred, barney, & pebbles', /[^, ]+/g); // => ['fred', 'barney', '&', 'pebbles'] |
|
|
Term
|
Definition
var p = _.f(_.escape, function(func, text) {
return ' ' + func(text) + ' ';
});
p('fred, barney, & pebbles');
// => 'fred, barney, & pebbles ' |
|
|
Term
|
Definition
_.f([2, 1], [2, 3]); // => [1, 3] |
|
|
Term
|
Definition
_.f([2.1, 1.2], [2.3, 3.4], Math.floor); // => [1.2, 3.4] // The `_.property` iteratee shorthand. _.f([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); // => [{ 'x': 2 }] |
|
|
Term
|
Definition
var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; _.f(objects, others, _.isEqual); // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] |
|
|
Term
|
Definition
_.f(['a', 'b'], [1, 2], [true, false]); // => [['a', 1, true], ['b', 2, false]] |
|
|
Term
|
Definition
_.f(['a', 'b'], [1, 2]); // => { 'a': 1, 'b': 2 } |
|
|
Term
|
Definition
_.f(['a.b[0].c', 'a.b[1].d'], [1, 2]); // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } |
|
|
Term
|
Definition
_.f([1, 2], [10, 20], [100, 200], function(a, b, c) { return a + b + c; }); // => [111, 222] |
|
|