source: trip-planner-front/node_modules/define-lazy-prop/index.d.ts@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 802 bytes
RevLine 
[6a3a178]1/**
2Define a [lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) property on an object.
3
4@param object - Object to add property to.
5@param propertyName - Name of the property to add.
6@param fn - Called the first time `propertyName` is accessed.
7
8@example
9```
10import defineLazyProp = require('define-lazy-prop');
11
12const unicorn = {
13 // …
14};
15
16defineLazyProp(unicorn, 'rainbow', () => expensiveComputation());
17
18app.on('user-action', () => {
19 doSomething(unicorn.rainbow);
20});
21```
22*/
23declare function defineLazyProp<
24 ObjectType extends {[key: string]: unknown},
25 PropertyNameType extends string,
26 PropertyValueType
27>(
28 object: ObjectType,
29 propertyName: PropertyNameType,
30 fn: () => PropertyValueType
31): ObjectType & {[K in PropertyNameType]: PropertyValueType};
32
33export = defineLazyProp;
Note: See TracBrowser for help on using the repository browser.