npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

core-promise

v0.3.4

Published

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

Downloads

370

Readme

core-promise

A promise implementation that is fully conformant to the Promises/A+ spec, passing all the 872 tests from the reference 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:

<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).

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:

/// <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.