CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
index.d.ts32 linesDownload Raw Back to define-lazy-prop
1/**2Define a [lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) property on an object.3 4@param object - Object to add the property to.5@param propertyName - Name of the property to add.6@param valueGetter - Called the first time `propertyName` is accessed.7 8@example9```10import defineLazyProperty from 'define-lazy-prop';11 12const unicorn = {13	// …14};15 16defineLazyProperty(unicorn, 'rainbow', () => expensiveComputation());17 18app.on('user-action', () => {19	doSomething(unicorn.rainbow);20});21```22*/23export default function defineLazyProperty<24	ObjectType extends Record<string, any>,25	PropertyNameType extends string,26	PropertyValueType27>(28	object: ObjectType,29	propertyName: PropertyNameType,30	valueGetter: () => PropertyValueType31): ObjectType & {[K in PropertyNameType]: PropertyValueType};32 
basant307/AI_Governance_Project · CoolFace