mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Add type definitions for object-map. * Rename object-map's type variables. Per suggestion from @plantain-00 * object-map: Declare TThis type for thisArg. Per suggestion from @andy-ms.
19 lines
312 B
TypeScript
19 lines
312 B
TypeScript
import objectMap = require('object-map');
|
|
|
|
const obj = {foo: 7, bar: 3, baz: -1};
|
|
|
|
let total = 0;
|
|
const keys: string[] = [];
|
|
objectMap(obj, (val, key) => {
|
|
total += val;
|
|
keys.push(key);
|
|
});
|
|
|
|
const myThis = {
|
|
mul: 2,
|
|
count: 0,
|
|
};
|
|
objectMap(obj, function(val, key) {
|
|
this.count += this.mul * val;
|
|
}, myThis);
|