# promise-the-earth

> A simple, fully-compliant JavaScript implementation of the Promises/A+ spec

Latest version **0.0.1** (published 2014-01-24) · 0 weekly downloads

## Install

```sh
npm install promise-the-earth
pnpm add promise-the-earth
yarn add promise-the-earth
bun add promise-the-earth
```

## 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.0.1 |
| Published | 2014-01-24 |
| First published | 2014-01-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | denodell |
| Maintainers | denodell |

## Links

- npm: https://www.npmjs.com/package/promise-the-earth
- Repository: https://github.com/denodell/promise-the-earth
- Issues: https://github.com/denodell/promise-the-earth/issues
- npm.io page: https://npm.io/package/promise-the-earth

## Recent versions

- 0.0.1 (latest) — 2014-01-24

## README

# Promise The Earth

A simple, fully-compliant JavaScript implementation of the Promises/A+ spec: http://promisesaplus.com/

Also features the `Promise.all()` method from ES6 Promises - because it's great.

Clocks in at 1.67KB minified (696 bytes gzipped).

## Usage
```
<script src="promise.min.js"></script>
<script>

    // An asynchronous function that waits a certain number of milliseconds. Returns a promise.
    function wait(delayInMilliseconds) {
        return new Promise(function(success, failure) {
            if (delayInMilliseconds <= 0) {
                failure(delayInMilliseconds + " is not a valid value.");
            } else {
                setTimeout(function() {
                    success(delayInMilliseconds);
                }, delayInMilliseconds);
            }
        });
    }

    // Wait for 2 seconds, then execute onSuccess(). If an error occurs, execute onError instead.
    function onSuccess(waitTimeInMilliseconds) {
        console.log("Waited for " + waitTimeInMilliseconds + "ms");
    }

    function onFailure(error) {
        console.log(error);
    }

    wait(2000).then(onSuccess, onError);

    // Execute multiple asynchronous functions simultaneously
    Promise.all([wait(2000), wait(1000), wait(500)], function(values) {
        console.log("Execution will take 2000 milliseconds as each function is executed simultaneously");
        console.log(values); // [2000, 1000, 500]
    })
</script>
```
## Compliance
- Install the test suite locally (https://github.com/promises-aplus/promises-tests) using `npm install`.
- Run the test suite against this library using `npm test`. Everything should pass!

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