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
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/lazyUsage 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 ErrorLicence
MIT