Proxies for lazy loading expensive objects. Lazy + Proxy === Laxy
Install
$ npm install laxy
Usage
const laxy = require('laxy');
const proxy = laxy(generatorFn)(...argsToPass);
// generatorFn will only be called once, but not until you interact with the proxy in some way:
proxy();
proxy.foo;
Object.keys(proxy); // etc...
// Can be used as a lazy require
const _ = laxy(require)('lodash');
// lodash won't be loaded until you do something with it:
_.isNumber(3);
Basic API
laxy(generatorFn)(...argsToPass)
generatorFn
Type: fn
The function that should be called to generate the object being proxied. This function will be called lazily and only once.
...argsToPass
Type: anything
Any number of arguments may be provided and will be…