
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
z-combinator
Advanced tools
Version: 0.1.1
Master build: 
Develop build: 
This library provides a utility function to support the creation of self-referencing anonymous functions.
It can be installed in whichever way you prefer, but I recommend NPM.
The Z Combinator is the same, in principle, as the Y Combinator except it works in languages with applicative (eager) order of execution (arguments are evaluated before the function call) just like JavaScript.
For more information about the Z Combinator please read Douglas Crockford's "The Little JavaScripter".
var z = require('z-combinator');
// Factorial
var factorial = z(function(fn) {
return function(n) {
return 2 >= n ? n : n * fn(n - 1);
}
});
factorial(2) // => 2
factorial(3) // => 6
factorial(4) // => 24
factorial(5) // => 120
Just as you would with any other recursive function, make sure you include some sort of break condition. If you miss it out, the function will recur indefinitely.
var z = require('z-combinator');
z(function(fn) {
return function(n) {
return fn(n + 1); // <= Unconditional recursion
};
})(0);
// => Error: Maximum call stack exceeded
z(function(fn) {
return function(n) {
return 100 <= n ? n : fn(n + 1); // <= Conditional recursion
};
})(0);
// => 100
I accept contributions to the source via Pull Request, but passing unit tests must be included before it will be considered for merge.
$ make install
$ make tests
If you have Vagrant installed, you can build the dev environment to assist development.
The repository will be mounted in /srv.
$ vagrant up
$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)
$ cd /srv
The content of this library is released under the MIT License by Andrew Lawson.
You can find a copy of this license at http://www.opensource.org/licenses/mit or in LICENSE
FAQs
Z Combinator for self-referencing anonymous functions
The npm package z-combinator receives a total of 1 weekly downloads. As such, z-combinator popularity was classified as not popular.
We found that z-combinator 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.