Skip to content

Commit

Permalink
Fix forEach callback function getting called in the wrong context
Browse files Browse the repository at this point in the history
  • Loading branch information
ivkos committed Nov 1, 2017
1 parent f43bc94 commit 7d47091
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Memorija.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,9 @@ export class Memorija<K, V> implements Map<K, V> {
* @param thisArg
*/
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void {
const self = this;

this.map.forEach((v, k) => {
callbackfn(v[1], k, self);
}, thisArg);
callbackfn.apply(thisArg, [v[1], k, this]);
});
}

/**
Expand Down

0 comments on commit 7d47091

Please sign in to comment.