axetroy / axetroy/godefer

Error when using default parameters: `TypeError: defer is not a function`

Open
#5 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
19
Forks
1
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a**

- [x] bug report => search github for a similar issue or PR before submitting
- [ ] feature request
- [ ] support request

**Current behavior**
When using default parameters in the wrapper function, the defer function is not defined.

**Expected behavior**
`defer()` should still work when default parameters are used.

**More detail**
Example:
```
const godefer = require('godefer');

const getUserInfo = godefer(async function(username, test='', defer) {
defer(function(err, result) {
console.log('defer');
});

console.log('return');
return {'data':'ok'};
});

await getUserInfo('axetroy')
.then(function(info) {
console.log(info);
})
.catch(function(err) {
console.error(err);
});
```

Environment:

Node: v10.15.3
NPM: 6.9.0

Contributor guide

Open the contributing guide

Research direction

Start at the package entry point that implements the `godefer` wrapper and reproduce the provided example with a default parameter. Trace how the wrapper identifies the `defer` argument; done means `defer()` works when the wrapped function includes `test=''` before it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.