Returns an proxy object backed by tailCall, which will be lazily created at the first time its properties or methods are used. The initializer passed

Atry/tail-call-proxy

submited by
Style Pass
2023-01-26 08:00:09

Returns an proxy object backed by tailCall, which will be lazily created at the first time its properties or methods are used.

The initializer passed to lazy should not be called until the first to access lazyObject.hello. When lazyObject.hello is accessed more than once, the second access would not trigger the initializer again.

However, if you replace return xxx with return lazy(() => xxx), it will use a constant size of stack memory and avoid the stack overflow.

parasitic returns either exactly the object returned by tailCall, or a proxy object backed by the object returned by tailCall, if there are any previously started pending tail calls. In the latter case, the underlying object will be created after all the previous tail calls are finished.

parasitic is useful when you need tail call optimization while you don't need the lazy evaluation. It can be used together with lazy alternately.

Leave a Comment