JSPM

@slimio/lazy

1.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q47063F
  • License MIT

SlimIO Lazy Properties lib

Package Exports

  • @slimio/lazy

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@slimio/lazy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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