Rename objMap to mapObject
mapObject fits better with other module names ("flattenChildren", "traverseAllChildren" etc.) and highlights that it only works with objects - which is going to be more important once we'll have an ES6 Map polyfill.
Christoph Pojer committed
Mar 25, 2014 at 12:29 UTC
6cbeee1e59d036588f63a71ada23be25bdb74d2b
2 files changed
+10
-5
src/core/ReactCompositeComponent.js
+2
-2
@@ -35,7 +35,7 @@ var keyMirror = require('keyMirror');
35
var merge = require('merge');
36
var mixInto = require('mixInto');
37
var monitorCodeUse = require('monitorCodeUse');
38
-var objMap = require('objMap');
38
+var mapObject = require('mapObject');
39
var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
40
var warning = require('warning');
41
@@ -542,7 +542,7 @@ function mergeObjectsWithNoDuplicateKeys(one, two) {
542
'mergeObjectsWithNoDuplicateKeys(): Cannot merge non-objects'
543
);
544
545
- objMap(two, function(value, key) {
545
+ mapObject(two, function(value, key) {
546
invariant(
547
one[key] === undefined,
548
'mergeObjectsWithNoDuplicateKeys(): ' +
src/vendor/core/mapObject.js
renamed
+8
-3
@@ -13,7 +13,7 @@
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
- * @providesModule objMap
16
+ * @providesModule mapObject
17
*/
18
19
"use strict";
@@ -25,12 +25,17 @@
25
*
26
* func(value, key, iteration)
27
*
28
+ * Grepable names:
29
+ *
30
+ * function objectMap()
31
+ * function objMap()
32
+ *
33
* @param {?object} obj Object to map keys over
34
* @param {function} func Invoked for each key/val pair.
35
* @param {?*} context
36
* @return {?object} Result of mapping or null if obj is falsey
37
*/
33
-function objMap(obj, func, context) {
38
+function mapObject(obj, func, context) {
39
if (!obj) {
40
return null;
41
}
@@ -44,4 +49,4 @@ function objMap(obj, func, context) {
49
return ret;
50
}
51
47
-module.exports = objMap;
52
+module.exports = mapObject;