Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitca1c732

Browse files
committed
Move_.values to Objects category.
Former-commit-id: e85229b53a7697c11f76eae02aef8a4fce3aec3a
1 parent5e8c373 commitca1c732

File tree

1 file changed

+45
-52
lines changed

1 file changed

+45
-52
lines changed

‎lodash.js‎

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,6 @@
333333
}
334334
};
335335

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-
350336
/*--------------------------------------------------------------------------*/
351337

352338
/**
@@ -516,7 +502,7 @@
516502

517503
/**
518504
* 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.
520506
*
521507
*@private
522508
*@param {Object} object The object to inspect.
@@ -708,7 +694,18 @@
708694
* _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
709695
* // => [3, 6, 9] (order is not guaranteed)
710696
*/
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+
});
712709

713710
/**
714711
* Boils down a `collection` to a single value. The initial state of the
@@ -876,28 +873,6 @@
876873
returnvalues(collection);
877874
}
878875

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-
901876
/*--------------------------------------------------------------------------*/
902877

903878
/**
@@ -2236,9 +2211,9 @@
22362211
varextend=createIterator(extendIteratorOptions);
22372212

22382213
/**
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).
22422217
*
22432218
*@static
22442219
*@memberOf _
@@ -2267,9 +2242,9 @@
22672242
});
22682243

22692244
/**
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).
22732248
*
22742249
*@static
22752250
*@memberOf _
@@ -2288,8 +2263,8 @@
22882263
varforOwn=createIterator(baseIteratorOptions,forEachIteratorOptions,forOwnIteratorOptions);
22892264

22902265
/**
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.
22932268
*
22942269
*@static
22952270
*@memberOf _
@@ -2428,7 +2403,7 @@
24282403

24292404
/**
24302405
* 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".
24322407
*
24332408
*@static
24342409
*@memberOf _
@@ -2792,7 +2767,7 @@
27922767
}
27932768

27942769
/**
2795-
* Produces an array ofthe `object`'senumerableown property names.
2770+
* Produces an array of object`'s own enumerable property names.
27962771
*
27972772
*@static
27982773
*@memberOf _
@@ -2844,16 +2819,15 @@
28442819
}
28452820

28462821
/**
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.
28502824
*
28512825
*@static
28522826
*@memberOf _
28532827
*@category Objects
28542828
*@param {Array|Object|String} value The value to inspect.
28552829
*@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.
28572831
*@example
28582832
*
28592833
* _.size([1, 2]);
@@ -2898,6 +2872,25 @@
28982872
returnvalue;
28992873
}
29002874

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+
29012894
/*--------------------------------------------------------------------------*/
29022895

29032896
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp