.wrap() calls last specified function for all calls
atamon opened this issue · 4 comments
atamon commented
Hi,
I found that the .wrap() function acts oddly when being called as follows:
var obj = {
fn1: function () { ... },
fn2: function () { ... },
};
retry.wrap(obj, { nRetries: 3, randomize: true }, ['fn1', 'fn2']);
Both obj.fn1() and obj.fn2() will now call the same original function due to this line https://github.com/tim-kos/node-retry/blob/master/lib/retry.js#L76. The variable original
will be hoisted to the top of the function declaration of wrap
.
I'm going to solve my specific use-case by calling wrap twice, once per function instead. But if you'd like to, I could try to get back with a PR for solving this.
tim-kos commented
Yes, I'd be happy to accept a PR for this.
Nice find!
atamon commented
tim-kos commented
Fixed in #52 (review) Thank you!