# threat

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

Latest version **0.1.0** (published 2017-05-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install threat
pnpm add threat
yarn add threat
bun add threat
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-05-12 |
| First published | 2017-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nikhil Chelliah |
| Maintainers | nchilada |

## Links

- npm: https://www.npmjs.com/package/threat
- Repository: https://github.com/nchilada/threat
- Homepage: https://github.com/nchilada/threat#readme
- Issues: https://github.com/nchilada/threat/issues
- npm.io page: https://npm.io/package/threat

## Dependencies (1)

- [es6-promise](https://npm.io/package/es6-promise.md) ^4.0.0

## Recent versions

- 0.1.0 (latest) — 2017-05-12

## README

# Threat

A Threat is like a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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](https://en.wikipedia.org/wiki/Flash_of_unstyled_content) in the context of the [Optimizely Web agent](https://help.optimizely.com/Set_Up_Optimizely/How_the_Optimizely_X_Web_snippet_works%3A_Order_of_execution)).

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!](http://tvtropes.org/pmwiki/pmwiki.php/Main/IsThatAThreat)

---
_Source: https://npm.io/package/threat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
