basant307/AI_Governance_Project
045
1# define-lazy-prop2 3> Define a [lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) property on an object4 5Useful when the value of a property is expensive to generate, so you want to delay the computation until the property is needed. For example, improving startup performance by deferring nonessential operations.6 7## Install8 9```10$ npm install define-lazy-prop11```12 13## Usage14 15```js16import defineLazyProperty from 'define-lazy-prop';17 18const unicorn = {19 // …20};21 22defineLazyProperty(unicorn, 'rainbow', () => expensiveComputation());23 24app.on('user-action', () => {25 doSomething(unicorn.rainbow);26});27```28 29## API30 31### defineLazyProperty(object, propertyName, valueGetter)32 33#### object34 35Type: `object`36 37Object to add the property to.38 39#### propertyName40 41Type: `string`42 43Name of the property to add.44 45#### valueGetter46 47Type: `Function`48 49Called the first time `propertyName` is accessed. Expected to return a value.50 51## Related52 53- [lazy-value](https://github.com/sindresorhus/lazy-value) - Create a lazily evaluated value54- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import a module lazily55- [p-lazy](https://github.com/sindresorhus/p-lazy) - Create a lazy promise56 