Skip to content
Subhajit Sahu edited this page Jul 29, 2022 · 2 revisions

Generate deferred version of a function, that executes after the current stack has cleared.

Similar: defer, delay.


function defer(x)
// x: a function

const xfunction = require('extra-function');


var count = 0;
var fn = xfunction.defer(() => ++count);
fn();
fn();
// `count` incremented after 0s
// `count` incremented after 0s


References

Clone this wiki locally