@ark7/lazyload
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@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);

Readme

Keywords

Package Sidebar

Install

npm i @ark7/lazyload

Weekly Downloads

41

Version

1.0.2

License

Apache-2.0

Unpacked Size

22.4 kB

Total Files

8

Last publish

Collaborators

  • ark7_inc