{"action":"closed","issue":{"url":"https://api.github.com/repos/nodeschool/discussions/issues/1115","labels_url":"https://api.github.com/repos/nodeschool/discussions/issues/1115/labels{/name}","comments_url":"https://api.github.com/repos/nodeschool/discussions/issues/1115/comments","events_url":"https://api.github.com/repos/nodeschool/discussions/issues/1115/events","html_url":"https://github.com/nodeschool/discussions/issues/1115","id":72431619,"number":1115,"title":"Pass extra parameters to readdir callback function","user":{"login":"mp19uy","id":3887467,"avatar_url":"https://avatars.githubusercontent.com/u/3887467?v=3","gravatar_id":"","url":"https://api.github.com/users/mp19uy","html_url":"https://github.com/mp19uy","followers_url":"https://api.github.com/users/mp19uy/followers","following_url":"https://api.github.com/users/mp19uy/following{/other_user}","gists_url":"https://api.github.com/users/mp19uy/gists{/gist_id}","starred_url":"https://api.github.com/users/mp19uy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mp19uy/subscriptions","organizations_url":"https://api.github.com/users/mp19uy/orgs","repos_url":"https://api.github.com/users/mp19uy/repos","events_url":"https://api.github.com/users/mp19uy/events{/privacy}","received_events_url":"https://api.github.com/users/mp19uy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodeschool/discussions/labels/learnyounode","name":"learnyounode","color":"F0A028"},{"url":"https://api.github.com/repos/nodeschool/discussions/labels/probably-self-resolved","name":"probably-self-resolved","color":"fad8c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-01T13:22:00Z","updated_at":"2015-05-27T16:47:53Z","closed_at":"2015-05-27T16:47:53Z","body":"Currently I'm with MAKE IT MODULAR from learnyournode and I have the following question:\r\nI wan't to know alternative ways to pass extra parameters to a callback function with fixed parameters.\r\nLooking for solutions I found this way, creating a annonymous function with the fixed callback parameters and then inside of it, call the function I want with all the parameters.\r\n\r\nI would like to know from experience programmers:\r\n1) if there is another way to do this? (keep in mind I still want to use the onXXXX functions I defined, I know that if I use anonymous functions the problem I'm having gets solved).\r\n2) and if the way I did it it's acceptable.\r\n\r\nHere's my code.\r\n\r\n```node\r\nvar fs = require('fs');\r\nvar path = require('path');\r\n\r\nmodule.exports = function (dir, ext, callback) {\r\n\tfs.readdir(dir, function(err,dir){ onRead(err,dir,ext,callback) });\r\n}\r\n\r\nfunction onRead(err, list, ext, callback) {\r\n\tif (err)\r\n\t\treturn callback(err);\r\n\t\r\n\tlist = list.filter(filterExt, ext);\r\n\tcallback(null, list);\r\n}\r\n\r\nfunction filterExt(file) {\r\n\treturn (path.extname(file) === '.' + this);\r\n}\r\n```"}}