|
1322 | 1322 | * @param {Function} func The function to set data on.
|
1323 | 1323 | * @param {*} value The value to set.
|
1324 | 1324 | */
|
1325 |
| - var setBindData = !defineProperty ? noop : function(func, value) { |
| 1325 | + var setBindData = function(func, value) { |
1326 | 1326 | var descriptor = getObject();
|
1327 | 1327 | descriptor.value = value;
|
1328 | 1328 | defineProperty(func, '__bindData__', descriptor);
|
|
2409 | 2409 | * Creates a shallow clone of `object` excluding the specified properties.
|
2410 | 2410 | * Property names may be specified as individual arguments or as arrays of
|
2411 | 2411 | * property names. If a callback is provided it will be executed for each
|
2412 |
| - * property of `object` omitting the properties the callback returns truthy |
| 2412 | + * property of `object` omitting the properties the callback returns truey |
2413 | 2413 | * for. The callback is bound to `thisArg` and invoked with three arguments;
|
2414 | 2414 | * (value, key, object).
|
2415 | 2415 | *
|
|
2483 | 2483 | * Creates a shallow clone of `object` composed of the specified properties.
|
2484 | 2484 | * Property names may be specified as individual arguments or as arrays of
|
2485 | 2485 | * property names. If a callback is provided it will be executed for each
|
2486 |
| - * property of `object` picking the properties the callback returns truthy |
| 2486 | + * property of `object` picking the properties the callback returns truey |
2487 | 2487 | * for. The callback is bound to `thisArg` and invoked with three arguments;
|
2488 | 2488 | * (value, key, object).
|
2489 | 2489 | *
|
|
2729 | 2729 | });
|
2730 | 2730 |
|
2731 | 2731 | /**
|
2732 |
| - * Checks if the given callback returns truthy value for **all** elements of |
| 2732 | + * Checks if the given callback returns truey value for **all** elements of |
2733 | 2733 | * a collection. The callback is bound to `thisArg` and invoked with three
|
2734 | 2734 | * arguments; (value, index|key, collection).
|
2735 | 2735 | *
|
|
2792 | 2792 |
|
2793 | 2793 | /**
|
2794 | 2794 | * Iterates over elements of a collection, returning an array of all elements
|
2795 |
| - * the callback returns truthy for. The callback is bound to `thisArg` and |
| 2795 | + * the callback returns truey for. The callback is bound to `thisArg` and |
2796 | 2796 | * invoked with three arguments; (value, index|key, collection).
|
2797 | 2797 | *
|
2798 | 2798 | * If a property name is provided for `callback` the created "_.pluck" style
|
|
2856 | 2856 |
|
2857 | 2857 | /**
|
2858 | 2858 | * Iterates over elements of a collection, returning the first element that
|
2859 |
| - * the callback returns truthy for. The callback is bound to `thisArg` and |
| 2859 | + * the callback returns truey for. The callback is bound to `thisArg` and |
2860 | 2860 | * invoked with three arguments; (value, index|key, collection).
|
2861 | 2861 | *
|
2862 | 2862 | * If a property name is provided for `callback` the created "_.pluck" style
|
|
3463 | 3463 |
|
3464 | 3464 | /**
|
3465 | 3465 | * The opposite of `_.filter` this method returns the elements of a
|
3466 |
| - * collection that the callback does **not** return truthy for. |
| 3466 | + * collection that the callback does **not** return truey for. |
3467 | 3467 | *
|
3468 | 3468 | * If a property name is provided for `callback` the created "_.pluck" style
|
3469 | 3469 | * callback will return the property value of the given element.
|
|
3590 | 3590 | }
|
3591 | 3591 |
|
3592 | 3592 | /**
|
3593 |
| - * Checks if the callback returns a truthy value for **any** element of a |
| 3593 | + * Checks if the callback returns a truey value for **any** element of a |
3594 | 3594 | * collection. The function returns as soon as it finds a passing value and
|
3595 | 3595 | * does not iterate over the entire collection. The callback is bound to
|
3596 | 3596 | * `thisArg` and invoked with three arguments; (value, index|key, collection).
|
|
3899 | 3899 | /**
|
3900 | 3900 | * Gets the first element or first `n` elements of an array. If a callback
|
3901 | 3901 | * is provided elements at the beginning of the array are returned as long
|
3902 |
| - * as the callback returns truthy. The callback is bound to `thisArg` and |
| 3902 | + * as the callback returns truey. The callback is bound to `thisArg` and |
3903 | 3903 | * invoked with three arguments; (value, index, array).
|
3904 | 3904 | *
|
3905 | 3905 | * If a property name is provided for `callback` the created "_.pluck" style
|
|
3975 | 3975 |
|
3976 | 3976 | /**
|
3977 | 3977 | * Flattens a nested array (the nesting can be to any depth). If `isShallow`
|
3978 |
| - * is truthy, the array will only be flattened a single level. If a callback |
| 3978 | + * is truey, the array will only be flattened a single level. If a callback |
3979 | 3979 | * is provided each element of the array is passed through the callback before
|
3980 | 3980 | * flattening. The callback is bound to `thisArg` and invoked with three
|
3981 | 3981 | * arguments; (value, index, array).
|
|
4065 | 4065 | /**
|
4066 | 4066 | * Gets all but the last element or last `n` elements of an array. If a
|
4067 | 4067 | * callback is provided elements at the end of the array are excluded from
|
4068 |
| - * the result as long as the callback returns truthy. The callback is bound |
| 4068 | + * the result as long as the callback returns truey. The callback is bound |
4069 | 4069 | * to `thisArg` and invoked with three arguments; (value, index, array).
|
4070 | 4070 | *
|
4071 | 4071 | * If a property name is provided for `callback` the created "_.pluck" style
|
|
4198 | 4198 | /**
|
4199 | 4199 | * Gets the last element or last `n` elements of an array. If a callback is
|
4200 | 4200 | * provided elements at the end of the array are returned as long as the
|
4201 |
| - * callback returns truthy. The callback is bound to `thisArg` and invoked |
| 4201 | + * callback returns truey. The callback is bound to `thisArg` and invoked |
4202 | 4202 | * with three arguments; (value, index, array).
|
4203 | 4203 | *
|
4204 | 4204 | * If a property name is provided for `callback` the created "_.pluck" style
|
|
4394 | 4394 | }
|
4395 | 4395 |
|
4396 | 4396 | /**
|
4397 |
| - * Removes all elements from an array that the callback returns truthy for |
| 4397 | + * Removes all elements from an array that the callback returns truey for |
4398 | 4398 | * and returns an array of removed elements. The callback is bound to `thisArg`
|
4399 | 4399 | * and invoked with three arguments; (value, index, array).
|
4400 | 4400 | *
|
|
4446 | 4446 | * The opposite of `_.initial` this method gets all but the first element or
|
4447 | 4447 | * first `n` elements of an array. If a callback function is provided elements
|
4448 | 4448 | * at the beginning of the array are excluded from the result as long as the
|
4449 |
| - * callback returns truthy. The callback is bound to `thisArg` and invoked |
| 4449 | + * callback returns truey. The callback is bound to `thisArg` and invoked |
4450 | 4450 | * with three arguments; (value, index, array).
|
4451 | 4451 | *
|
4452 | 4452 | * If a property name is provided for `callback` the created "_.pluck" style
|
|
4739 | 4739 | /*--------------------------------------------------------------------------*/
|
4740 | 4740 |
|
4741 | 4741 | /**
|
4742 |
| - * Creates a function this is restricted to executing `func` with the `this` |
4743 |
| - * binding and arguments of the created function, only after it is called `n` times. |
| 4742 | + * Creates a function that executes `func`, with the `this` binding and |
| 4743 | + * arguments of the created function, only after being called `n` times. |
4744 | 4744 | *
|
4745 | 4745 | * @static
|
4746 | 4746 | * @memberOf _
|
|
4751 | 4751 | * @returns {Function} Returns the new restricted function.
|
4752 | 4752 | * @example
|
4753 | 4753 | *
|
4754 |
| - * var renderNotes = _.after(notes.length, render); |
4755 |
| - * _.forEach(notes, function(note) { |
4756 |
| - * note.asyncSave({ 'success': renderNotes }); |
| 4754 | + * var saves = ['profile', 'settings']; |
| 4755 | + * |
| 4756 | + * var done = _.after(saves.length, function() { |
| 4757 | + * console.log('Done saving!'); |
| 4758 | + * }); |
| 4759 | + * |
| 4760 | + * _.forEach(saves, function(type) { |
| 4761 | + * asyncSave({ 'type': type, 'complete': done }); |
4757 | 4762 | * });
|
4758 |
| - * // `renderNotes` is run once, after all notes have saved |
| 4763 | + * // => logs 'Done saving!', after all saves have completed |
4759 | 4764 | */
|
4760 | 4765 | function after(n, func) {
|
4761 | 4766 | if (!isFunction(func)) {
|
|
5658 | 5663 | * is given, else it returns the interpolated text.
|
5659 | 5664 | * @example
|
5660 | 5665 | *
|
5661 |
| - * // using a compiled template |
| 5666 | + * // using the "interpolate" delimiter to create a compiled template |
5662 | 5667 | * var compiled = _.template('hello <%= name %>');
|
5663 | 5668 | * compiled({ 'name': 'moe' });
|
5664 | 5669 | * // => 'hello moe'
|
|
5668 | 5673 | * // => '<b><script></b>'
|
5669 | 5674 | *
|
5670 | 5675 | * // using the "evaluate" delimiter to generate HTML
|
5671 |
| - * var list = '<% _.forEach(people, function(name) { %><li><%= name %></li><% }); %>'; |
| 5676 | + * var list = '<% _.forEach(people, function(name) { %><li><%- name %></li><% }); %>'; |
5672 | 5677 | * _.template(list, { 'people': ['moe', 'larry'] });
|
5673 | 5678 | * // => '<li>moe</li><li>larry</li>'
|
5674 | 5679 | *
|
|
0 commit comments