max-mapper / max-mapper/callback-hell

Curring and closures

Open
#13 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
858
Forks
101
PR merge metrics
No merged PRs in 30d

Description

An example could be:

app.get('something', function (req, res) {
  res.render('view1');
});

app.get('other', function (req, res) {
  res.render('view1');
});

Refactor to:

function respondWithView (viewName) {
 return function ( req, res ) {
   res.render(viewName);
 };
}

app.get('something', respondWithView('view1'));

app.get('other', respondWithView('view2'));

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named. Search the repository's examples or documentation for the shown app.get and res.render snippets, then compare the duplicated handlers with the proposed respondWithView pattern. Done means the matching example uses the closure-based refactoring and preserves the intended rendered views.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.