@slimio/lazy
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Lazy

Maintenance MIT V1.0

SlimIO Little lib to set Lazy Properties on JavaScript Objects!

Warning Lazy Property are set to writable: false

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @slimio/lazy
# or
$ yarn add @slimio/lazy

Usage example

// lp stand for Lazy Proxy
const lp = Lazy.of({});

lp.set("foo", () => "bar");
lp.set("hello", () => {
    // Do job here
});

module.exports = lp.value;

Under the hood the lib use the ECMAScript Reflection API to ensure that the property is set (else it will throw an Error).

const obj = Object.freeze({});
Lazy.defineProperty(obj, "foo", () => "bar"); // throw Error

Licence

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @slimio/lazy

Weekly Downloads

2

Version

1.2.0

License

MIT

Unpacked Size

5.64 kB

Total Files

5

Last publish

Collaborators

  • fraxken
  • alexandre.malaj