Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
dethunking-compose
Advanced tools
[Function composition](https://en.wikipedia.org/wiki/Function composition) allows the writing of declarative functional code. I like to pair this style of coding with large functions at the top of a file followed by the definitions of the smaller functions out of which it's composed.
Unfortunately, if you are writing in javascript and using function expressions rather than function statements (because, for example, you are writing curried functions) these can be difficult to combine.
Because the arguments to a javascript function are eagerly evaluated, the functions you are composing have to be defined above the point that you compose them.
This module allows you to pass a series of thunks to a compose function (thus delaying their evaluation) which you allows you to define the smaller functions later (it still has to be before their actual use).
This module also stringifies in a debuggable way.
I'm not sure this module is worth using without the low affordance for writing thunks provided by ES6 arrow functions.
var compose = require('dethunk-compose')
var triple_add_3 = module.exports = compose(
() => add_2
, () => add_1
, () => triple
)
var add_2 = compose(
() => add_1
, () => add_1
)
var add_1 = x => x + 1
var triple = x => x * 3
If you prefer to compose left-to-right, you can use the pipe API.
var pipe = require('dethunk-compose).pipe
var triple_add_3 = module.exports = pipe(
() => triple
, () => add_1
, () => add_2
)
...
FAQs
Lazy evaluation + compose
The npm package dethunking-compose receives a total of 7 weekly downloads. As such, dethunking-compose popularity was classified as not popular.
We found that dethunking-compose demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.