# core-promise

> An ES6 and Promises/A+ 1.1 fully compliant Promise implementation, that works on IE8+

Latest version **0.3.4** (published 2015-09-15) · 0 weekly downloads

## Install

```sh
npm install core-promise
pnpm add core-promise
yarn add core-promise
bun add core-promise
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2015-09-15 |
| First published | 2015-06-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Bogdan Mustiata |
| Maintainers | bmustiata |
| Keywords | promise, fast, IE8, ES6 |

## Links

- npm: https://www.npmjs.com/package/core-promise
- Repository: https://github.com/bmustiata/core-promise
- Homepage: http://blog.ciplogic.com
- Issues: https://github.com/bmustiata/core-promise/issues
- npm.io page: https://npm.io/package/core-promise

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.3.4 (latest) — 2015-09-15
- 0.3.3 — 2015-09-14
- 0.3.2 — 2015-09-14
- 0.3.1 — 2015-09-12
- 0.3.0 — 2015-09-12
- 0.2.3 — 2015-07-22
- 0.2.2 — 2015-07-02
- 0.2.1 — 2015-07-01
- 0.2.0 — 2015-07-01
- 0.1.3 — 2015-06-30
- 0.1.2 — 2015-06-30
- 0.1.1 — 2015-06-30
- 0.1.0 — 2015-06-29

## README

# core-promise

A promise implementation that is fully conformant to the [Promises/A+ spec](https://github.com/promises-aplus/promises-spec),
passing all the 872 tests from the [reference tests](https://github.com/promises-aplus/promises-tests), and most of the ES6
tests as well (except a few tests that V8 itself fails).

Comes with full TypeScript support.

And works from IE8+ without any dependency.

## IE8, IE9.. Usage

First you will need to fetch the implementation of the promises via bower:

```
bower install core-promise
```

Just include it in the `<head>` of your page a reference to the core-promise js file:

```html
<head>
  <!-- the file is standalone, and has no dependencies -->
  <script type="text/javascript" src="core-promise.js"/>
</head>
```

## Usage in Node

The recommended way to use the `core-promise` is to use the DefaultPromise class, that
will use the native Promise class if it is available (e.g. from node 0.12 up).

```javascript
var Promise = require('core-promise').DefaultPromise,
    CorePromise = require('core-promise').CorePromise;

// ..
// Create new promises with:

var p = new Promise(function(fulfill, reject)) {
    //..
};
```

## Node with TypeScript

If you use TypeScript, then you should know that the core-promise bundles
the definition file inside the module. So in order for you to get autocomplete,
error checking etc, just add a reference to it, like so:

```typescript
/// <reference path="node_modules/core-promise/core-promise.d.ts"/>

import core = require("core-promise");
import Promise = core.DefaultPromise;

Promise.resolve("core-promise")
    .then((x : number) => { // compile error, resolve returns a string
        console.log(x);
    });
```

## Test Failures

### Internet Explorer 9

On IE9 only 2 tests are failing (for strict functions the this comes as the `window` object
instead of `undefined` - this is a browser bug). Irellevant in practice, since you wouldn't
use the `this` context anyway, because it should be undefined.

### Internet Explorer 8

On IE8 multiple tests are failing due to the way the tests themselves are written
(calling `Object.create`, using properties, etc. that the shims are not implementing fully).
The core functional tests that do the then() chaining are passing.

Note that the implementation of `CorePromise` itself is compield in pure ES3 JavaScript, and doesn't need
*any* polyfill, and is literally the tests implementation that fails, and not `core-promise` itself.

### ES6

On ES6, the tests that fail are a very specific corner case of having inheritance of the Promise,
(a broken Promise implementation that inherits another Promise), combined with some illegal calls
of executors outside of the Promise. In reality this is irrelevant and can't happen in
your production code. Furthermore the native V8 promise implementation also fails these tests.

All the other sequence tests in regards with timing, are passing.

* 2015-09-15 v0.3.4 *BugFix* Make the `DefaultPromise` to be of type `PromiseConstructor`.
* 2015-09-15 v0.3.3 *BugFix* Updated the 'main' to point to the right implementation.
* 2015-09-15 v0.3.2 *BugFix* CorePromise implements the Promise interface.
* 2015-09-12 v0.3.1 *BugFix* Fixed definitions.
* 2015-09-12 v0.3.0 Use dts-generator. Removed bower support.
* 2015-07-22 v0.2.3 *BugFix* Added local.d.ts module file.
* 2015-07-02 v0.2.2 *BugFix* Fixed most ES6 tests. Except the ones that V8 itself fails.
* 2015-07-02 v0.2.1 *BugFix* Added d.ts module file. Recompiled bower client.
* 2015-07-01 v0.2.0 ES6 compatible functions added (resolve, all, race, reject).
* 2015-06-30 v0.1.3 Documentation.
* 2015-06-30 v0.1.2 *BugFix* `setTimeout` call it via `()` not `.call` for IE8
* 2015-06-30 v0.1.1 Browserify browser tests via mocha.
* 2015-06-30 v0.1.0 Promises/A+ 1.1 compatible.

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