-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 70c9b49
Showing
8 changed files
with
442 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules/ | ||
/tmp | ||
/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 1.0.0 (june 19, 2014) | ||
|
||
* Init release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
// ... | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
Oops, something went wrong.