MCPcopy
hub / github.com/cujojs/when / map

Function map

keys.js:67–78  ·  view source on GitHub ↗

* Map values in the supplied object's keys * @param {Promise|object} object or promise for object whose key-value pairs * will be reduced * @param {function(value:*, key:String):*} f mapping function which may * return either a promise or a value * @returns {Promise} promise for an objec

(object, f)

Source from the content-addressed store, hash-verified

65 * resolved key-value pairs
66 */
67 function map(object, f) {
68 return toPromise(object).then(function(object) {
69 return all(Object.keys(object).reduce(function(o, k) {
70 o[k] = toPromise(object[k]).fold(mapWithKey, k);
71 return o;
72 }, {}));
73 });
74
75 function mapWithKey(k, x) {
76 return f(x, k);
77 }
78 }
79
80 /**
81 * Resolve all key-value pairs in the supplied object and return a promise

Callers

nothing calls this directly

Calls 1

allFunction · 0.70

Tested by

no test coverage detected