Skip to content

Commit 728a91e

Browse files
committed
docs: improve API document
1 parent ff0779e commit 728a91e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ const LAZY_PROXY_HANDLER: ProxyHandler<ProxyTarget<object>> =
184184
);
185185

186186
/**
187-
* Returns an proxy object whose underlying object will be lazily created
187+
* Returns an proxy object backed by `tailCall`, which will be lazily created
188188
* at the first time its properties or methods are used.
189189
*
190190
* `lazy` can eliminate tail calls, preventing stack overflow errors in tail
@@ -291,10 +291,10 @@ export function lazy<T extends object>(tailCall: () => T): T {
291291
/**
292292
* Performs a tail call as soon as possible.
293293
*
294-
* @returns either directly the object returned by `tailCall`, or a proxy
295-
* object if there are any other running tail calls. When a proxy object is
296-
* returned, the underlying object will be created after all the previous tail
297-
* calls are finished.
294+
* `parasitic` returns either exactly the object returned by `tailCall`, or a
295+
* proxy object backed by the object returned by `tailCall`, if there are any
296+
* previously started pending tail calls. In the latter case, the underlying
297+
* object will be created after all the previous tail calls are finished.
298298
*
299299
* @param tailCall the function to create the underlying object
300300
*
@@ -307,16 +307,16 @@ export function lazy<T extends object>(tailCall: () => T): T {
307307
* import { parasitic } from 'tail-call-proxy';
308308
*
309309
* let counter = 0;
310-
* const lazyObject = parasitic(() => {
310+
* const parasiticObject = parasitic(() => {
311311
* counter++;
312312
* return { hello: 'world' };
313313
* });
314314
* expect(counter).toBe(1);
315315
*
316-
* expect(lazyObject.hello).toBe('world');
316+
* expect(parasiticObject.hello).toBe('world');
317317
* expect(counter).toBe(1);
318318
*
319-
* expect(lazyObject.hello).toBe('world');
319+
* expect(parasiticObject.hello).toBe('world');
320320
* expect(counter).toBe(1);
321321
* ```
322322
*

0 commit comments

Comments
 (0)