Update vendored modules
Paul O’Shannessy committed
Aug 19, 2014 at 23:14 UTC
182379305a92c86f415837f30cb0afac3acf361d
3 files changed
+32
-49
src/vendor/core/mapObject.js
+30
-24
@@ -16,37 +16,43 @@
16
* @providesModule mapObject
17
*/
18
19
-"use strict";
19
+'use strict';
20
+
21
+var hasOwnProperty = Object.prototype.hasOwnProperty;
22
23
/**
22
- * For each key/value pair, invokes callback func and constructs a resulting
23
- * object which contains, for every key in obj, values that are the result of
24
- * of invoking the function:
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
24
+ * Executes the provided `callback` once for each enumerable own property in the
25
+ * object and constructs a new object from the results. The `callback` is
26
+ * invoked with three arguments:
27
+ *
28
+ * - the property value
29
+ * - the property name
30
+ * - the object being traversed
31
+ *
32
+ * Properties that are added after the call to `mapObject` will not be visited
33
+ * by `callback`. If the values of existing properties are changed, the value
34
+ * passed to `callback` will be the value at the time `mapObject` visits them.
35
+ * Properties that are deleted before being visited are not visited.
36
+ *
37
+ * @grep function objectMap()
38
+ * @grep function objMap()
39
+ *
40
+ * @param {?object} object
41
+ * @param {function} callback
42
+ * @param {*} context
43
+ * @return {?object}
44
*/
38
-function mapObject(obj, func, context) {
39
- if (!obj) {
45
+function mapObject(object, callback, context) {
46
+ if (!object) {
47
return null;
48
}
42
- var i = 0;
43
- var ret = {};
44
- for (var key in obj) {
45
- if (obj.hasOwnProperty(key)) {
46
- ret[key] = func.call(context, obj[key], key, i++);
49
+ var result = {};
50
+ for (var name in object) {
51
+ if (hasOwnProperty.call(object, name)) {
52
+ result[name] = callback.call(context, object[name], name, object);
53
}
54
}
49
- return ret;
55
+ return result;
56
}
57
58
module.exports = mapObject;
src/vendor/core/merge.js
+1
-8
@@ -26,14 +26,7 @@
26
* @return {object} The shallow extension of one by two.
27
*/
28
var merge = function(one, two) {
29
- var result = {};
30
- if (one != null) {
31
- Object.assign(result, one);
32
- }
33
- if (two != null) {
34
- Object.assign(result, two);
35
- }
36
- return result;
29
+ return Object.assign({}, one, two);
30
};
31
32
module.exports = merge;
src/vendor/core/mergeInto.js
+1
-17
@@ -19,20 +19,4 @@
19
20
"use strict";
21
22
-/**
23
- * Shallow merges two structures by mutating the first parameter.
24
- *
25
- * @param {object|function} one Object to be merged into.
26
- * @param {?object} two Optional object with properties to merge from.
27
- * @return {object|function} The first argument coerced into an object.
28
- */
29
-function mergeInto(one, two) {
30
- if (two != null) {
31
- return Object.assign(one, two);
32
- } else {
33
- // This ensures that we throw the right error if one is of the wrong type
34
- return Object.assign(one);
35
- }
36
-}
37
-
38
-module.exports = mergeInto;
22
+module.exports = Object.assign;