clio-lazy
Version:
Lazy evaluation for JS and Clio
22 lines (16 loc) • 458 B
Markdown
Lazy evaluation for Clio and JS
In Clio all functions are lazy by default.
You need to use `lazy` to wrap your functions:
```
const lazy = require("clio-lazy");
const lazyAdd = lazy((a, b) => a + b);
const myLazyNumber = lazyAdd(2, 3);
// ^ this will be evaluated only when the value is needed!
// for example if we do:
console.log(myLazyNumber);
// or if we do:
const notLazy = myLazyNumber + 2;
```