0.1.0 • Published 7 years ago

threat v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Threat

A Threat is like a Promise, except iff it has already resolved or rejected by the time you call .then(...) on it, your handler will be called synchronously (in the current stack frame) rather than being enqueued under an imminent stack frame. This invariant is preserved under Threat.all and Threat.race.

This is useful for applications that seek to preserve synchronicity wherever possible to avoid adverse effects from asynchronicity (e.g. a flash of unoptimized content in the context of the Optimizely Web agent).

But beware: any then handler that you register must be valid when executed synchronously and when executed asynchronously in order to work in all situations.

It's not a Promise, it's a Threat!