1.0.2 • Published 4 years ago

@ark7/lazyload v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 years ago

@ark7/lazyload

@ark7/lazyload delays loading of object creation. Object will not be loaded before accessing its properties.

import lazyload from '@ark7/lazyload';

let called = 0;

function fn() {
  called++;
  return { foo: 'bar' };
}

const obj = lazyload(fn)();

called.should.be.equal(0);

obj.foo.should.be.equal('bar');

called.should.be.equal(1);
1.0.2

4 years ago

1.0.1

4 years ago