Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Jun 19, 2014
0 parents commit 70c9b49
Show file tree
Hide file tree
Showing 8 changed files with 442 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/tmp
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules/
/tmp
/test
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 1.0.0 (june 19, 2014)

* Init release
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# ES6 Promise polyfill

This is a polyfill of [ES6 Promise](https://github.com/domenic/promises-unwrapping). The implementation based on [Jake Archibald implementation](https://github.com/jakearchibald/es6-promise) a subset of [rsvp.js](https://github.com/tildeio/rsvp.js). If you're wanting extra features and more debugging options, check out the [full library](https://github.com/tildeio/rsvp.js).

For API details and how to use promises, see the <a href="http://www.html5rocks.com/en/tutorials/es6/promises/">JavaScript Promises HTML5Rocks article</a>.

## Notes

The main target: implementation should be conformance with browser's implementations and to be minimal as possible in size. So it's strictly polyfill of ES6 Promise specification and nothing more.

It passes both [Promises/A+ test suite](https://github.com/promises-aplus/promises-tests) and [rsvp.js test suite](https://github.com/jakearchibald/es6-promise/tree/master/test). And as small as 2,6KB min (or 1KB min+gzip).

The polyfill uses `setImmediate` if available, or fallback to use `setTimeout`. Use [setImmediate polyfill](https://github.com/YuzuJS/setImmediate) by @YuzuJS to rich better performance.

## How to use

### Browser

To install:

```sh
bower install es6-promise-polyfill
```

To use:

```htmpl
<script src="bower_components/es6-promise-polyfill/promise.min.js"></script>
<script>
var promise = new Promise(...);
</script>
```

### Node.js

To install:

```sh
npm install es6-promise-polyfill
```

To use:

```js
var Promise = require('es6-promise-polyfill').Promise;
var promise = new Promise(...);
```

## Usage in IE<9

`catch` is a reserved word in IE<9, meaning `promise.catch(func)` throws a syntax error. To work around this, use a string to access the property:

```js
promise['catch'](function(err) {
// ...
});
```

Or use `.then` instead:

```js
promise.then(undefined, function(err) {
// ...
});
```
11 changes: 11 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "es6-promise-polyfill",
"version": "1.0.0",
"main": "promise.js",
"ignore": [
".*",
"**/.*",
"node_modules",
"test"
]
}
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "es6-promise-polyfill",
"namespace": "Promise",
"version": "1.0.0",
"author": "Roman Dvornov <rdvornov@gmail.com>",
"description": "A polyfill for ES6 Promise",
"main": "promise.js",
"directories": {
"lib": "lib"
},
"devDependencies": {
},
"scripts": {
},
"repository": {
"type": "git",
"url": "git://github.com/lahmatiy/es6-promise-polyfill.git"
},
"bugs": {
"url": "https://github.com/lahmatiy/es6-promise-polyfill/issues"
},
"keywords": [
"promises",
"futures",
"events"
]
}
Loading

0 comments on commit 70c9b49

Please sign in to comment.