|
333 | 333 | } |
334 | 334 | }; |
335 | 335 |
|
336 | | -/** Reusable iterator options for `map` and `values` */ |
337 | | -varmapIteratorOptions={ |
338 | | -'init':'', |
339 | | -'exit':'if (!collection) return []', |
340 | | -'beforeLoop':{ |
341 | | -'array':'result = Array(length)', |
342 | | -'object':'result = []' |
343 | | -}, |
344 | | -'inLoop':{ |
345 | | -'array':'result[index] = callback(collection[index], index, collection)', |
346 | | -'object':'result.push(callback(collection[index], index, collection))' |
347 | | -} |
348 | | -}; |
349 | | - |
350 | 336 | /*--------------------------------------------------------------------------*/ |
351 | 337 |
|
352 | 338 | /** |
|
516 | 502 |
|
517 | 503 | /** |
518 | 504 | * A shim implementation of `Object.keys` that produces an array of the given |
519 | | - * object'senumerableown property names. |
| 505 | + * object's own enumerable property names. |
520 | 506 | * |
521 | 507 | *@private |
522 | 508 | *@param {Object} object The object to inspect. |
|
708 | 694 | * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); |
709 | 695 | * // => [3, 6, 9] (order is not guaranteed) |
710 | 696 | */ |
711 | | -varmap=createIterator(baseIteratorOptions,mapIteratorOptions); |
| 697 | +varmap=createIterator(baseIteratorOptions,{ |
| 698 | +'init':'', |
| 699 | +'exit':'if (!collection) return []', |
| 700 | +'beforeLoop':{ |
| 701 | +'array':'result = Array(length)', |
| 702 | +'object':'result = []' |
| 703 | +}, |
| 704 | +'inLoop':{ |
| 705 | +'array':'result[index] = callback(collection[index], index, collection)', |
| 706 | +'object':'result.push(callback(collection[index], index, collection))' |
| 707 | +} |
| 708 | +}); |
712 | 709 |
|
713 | 710 | /** |
714 | 711 | * Boils down a `collection` to a single value. The initial state of the |
|
876 | 873 | returnvalues(collection); |
877 | 874 | } |
878 | 875 |
|
879 | | -/** |
880 | | - * Produces an array of enumerable own property values of the `collection`. |
881 | | - * |
882 | | - *@static |
883 | | - *@memberOf _ |
884 | | - *@alias methods |
885 | | - *@category Collections |
886 | | - *@param {Array|Object} collection The collection to inspect. |
887 | | - *@returns {Array} Returns a new array of property values. |
888 | | - *@example |
889 | | - * |
890 | | - * _.values({ 'one': 1, 'two': 2, 'three': 3 }); |
891 | | - * // => [1, 2, 3] |
892 | | - */ |
893 | | -varvalues=createIterator(mapIteratorOptions,{ |
894 | | -'args':'collection', |
895 | | -'inLoop':{ |
896 | | -'array':'result[index] = collection[index]', |
897 | | -'object':'result.push(collection[index])' |
898 | | -} |
899 | | -}); |
900 | | - |
901 | 876 | /*--------------------------------------------------------------------------*/ |
902 | 877 |
|
903 | 878 | /** |
|
2236 | 2211 | varextend=createIterator(extendIteratorOptions); |
2237 | 2212 |
|
2238 | 2213 | /** |
2239 | | - * Iterates overan`object`'senumerableown and inherited properties, |
2240 | | - *executingthe `callback` for each property. The `callback` is bound to |
2241 | | - *`thisArg` andinvoked with 3 arguments; (value, key, object). |
| 2214 | + * Iterates over `object`'s own and inheritedenumerableproperties, executing |
| 2215 | + * the `callback` for each property. The `callback` is bound to `thisArg` and |
| 2216 | + * invoked with 3 arguments; (value, key, object). |
2242 | 2217 | * |
2243 | 2218 | *@static |
2244 | 2219 | *@memberOf _ |
|
2267 | 2242 | }); |
2268 | 2243 |
|
2269 | 2244 | /** |
2270 | | - * Iterates overan`object`'senumerableown properties, executing the |
2271 | | - *`callback`for each property. The `callback` is bound to `thisArg` and |
2272 | | - *invoked with 3arguments; (value, key, object). |
| 2245 | + * Iterates over `object`'s ownenumerableproperties, executing the `callback` |
| 2246 | + * for each property. The `callback` is bound to `thisArg` and invoked with 3 |
| 2247 | + * arguments; (value, key, object). |
2273 | 2248 | * |
2274 | 2249 | *@static |
2275 | 2250 | *@memberOf _ |
|
2288 | 2263 | varforOwn=createIterator(baseIteratorOptions,forEachIteratorOptions,forOwnIteratorOptions); |
2289 | 2264 |
|
2290 | 2265 | /** |
2291 | | - * Produces a sorted array of the properties, own and inherited, of `object` |
2292 | | - * that have function values. |
| 2266 | + * Produces a sorted array of theenumerableproperties, own and inherited, |
| 2267 | + *of `object`that have function values. |
2293 | 2268 | * |
2294 | 2269 | *@static |
2295 | 2270 | *@memberOf _ |
|
2428 | 2403 |
|
2429 | 2404 | /** |
2430 | 2405 | * Checks if a `value` is empty. Arrays or strings with a length of `0` and |
2431 | | - * objects with noenumerableown properties are considered "empty". |
| 2406 | + * objects with no own enumerable properties are considered "empty". |
2432 | 2407 | * |
2433 | 2408 | *@static |
2434 | 2409 | *@memberOf _ |
|
2792 | 2767 | } |
2793 | 2768 |
|
2794 | 2769 | /** |
2795 | | - * Produces an array ofthe `object`'senumerableown property names. |
| 2770 | + * Produces an array of object`'s own enumerable property names. |
2796 | 2771 | * |
2797 | 2772 | *@static |
2798 | 2773 | *@memberOf _ |
|
2844 | 2819 | } |
2845 | 2820 |
|
2846 | 2821 | /** |
2847 | | - * Gets the size of a `value` by returning `value.length` if `value` is a |
2848 | | - * string or array, or the number of enumerable own properties if `value` is |
2849 | | - * an object. |
| 2822 | + * Gets the size of `value` by returning `value.length` if `value` is a string |
| 2823 | + * or array, or the number of own enumerable properties if `value` is an object. |
2850 | 2824 | * |
2851 | 2825 | *@static |
2852 | 2826 | *@memberOf _ |
2853 | 2827 | *@category Objects |
2854 | 2828 | *@param {Array|Object|String} value The value to inspect. |
2855 | 2829 | *@returns {Number} Returns `value.length` if `value` is a string or array, |
2856 | | - * or the number ofenumerableown properties if `value` is an object. |
| 2830 | + * or the number of own enumerable properties if `value` is an object. |
2857 | 2831 | *@example |
2858 | 2832 | * |
2859 | 2833 | * _.size([1, 2]); |
|
2898 | 2872 | returnvalue; |
2899 | 2873 | } |
2900 | 2874 |
|
| 2875 | +/** |
| 2876 | + * Produces an array of `object`'s own enumerable property values. |
| 2877 | + * |
| 2878 | + *@static |
| 2879 | + *@memberOf _ |
| 2880 | + *@category Objects |
| 2881 | + *@param {Object} object The object to inspect. |
| 2882 | + *@returns {Array} Returns a new array of property values. |
| 2883 | + *@example |
| 2884 | + * |
| 2885 | + * _.values({ 'one': 1, 'two': 2, 'three': 3 }); |
| 2886 | + * // => [1, 2, 3] |
| 2887 | + */ |
| 2888 | +varvalues=createIterator({ |
| 2889 | +'args':'object', |
| 2890 | +'init':'[]', |
| 2891 | +'inLoop':'result.push(object[index])' |
| 2892 | +}); |
| 2893 | + |
2901 | 2894 | /*--------------------------------------------------------------------------*/ |
2902 | 2895 |
|
2903 | 2896 | /** |
|