Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Well just don't call them in a chain if you want more context..
const filter = respondWithFilteredResult(res,options);
return filter(interactions); -
This is also termed higher-order function and is one of the most useful low-level patterns you can use in JS. Express middleware and metalsmith plugins are basically that.
If the func has jsdoc comments or TS definitions and you use an editor which shows hints it is super-easy to use and super versatile. -
arekxv10542yYeah this would just not be readable.
Either to use some function composition or to restructure like:
const runFilter = createResponseFilter(response, options);
return runFilter(interactions); -
@webketje yeah, when you're writing middleware.
But this is literally a controller. Supposed to be easy to see what it does, easy to change with new business needs. What the fuck is happening there is anybody's guess.
Q: Does JS allow you to write functions to return functions?
A: Yes it does.
Doesn't mean you should do this. What's wrong with you?
rant
javascript