Skip to content

Commit

Permalink
Merge pull request #230 from stefanpenner/4.x
Browse files Browse the repository at this point in the history
Provide separate auto-polyfill version of this module
  • Loading branch information
stefanpenner committed Sep 27, 2016
2 parents 7508b85 + c692ae7 commit 81eabcd
Show file tree
Hide file tree
Showing 15 changed files with 1,200 additions and 15 deletions.
22 changes: 17 additions & 5 deletions Brocfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,24 @@ var header = stew.map(find('config/versionTemplate.txt'), function(content) {
return content.replace(/VERSION_PLACEHOLDER_STRING/, version());
});

var dist = es6Promise;

function concatAs(tree, outputFile) {
return concat(merge([tree, header]), {
headerFiles: ['config/versionTemplate.txt'],
inputFiles: ['es6-promise.js'],
outputFile: outputFile
});
return merge([
concat(merge([tree, header]), {
headerFiles: ['config/versionTemplate.txt'],
inputFiles: ['es6-promise.js'],
outputFile: outputFile
}),

concat(merge([tree, header]), {
headerFiles: ['config/versionTemplate.txt'],
inputFiles: ['es6-promise.js'],
outputFile: outputFile.replace('es6-promise', 'es6-promise.auto'),
footer: 'ES6Promise.polyfill();',
}),

]);
}

function production(dist, header) {
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Master

# 4.0.0

* no longer polyfill automatically, if needed one can still invoke
`require('es6-promise/auto')` directly.

# 3.3.1

* fix links in readme
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ For API details and how to use promises, see the <a href="http://www.html5rocks.

## Downloads

* [es6-promise 27.86 KB (7.33 KB gzipped)](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/es6-promise.js)
* [es6-promise-min 6.17 KB (2.4 KB gzipped)](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/es6-promise.min.js)
* [es6-promise 27.86 KB (7.33 KB gzipped)](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/lib/es6-promise.js)
* [es6-promise-auto 27.78 KB (7.3 KB gzipped)](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/es6-promise.auto.js) - Automatically provides/replaces `Promise` if missing or broken.
* [es6-promise-min 6.17 KB (2.4 KB gzipped)](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/lib/es6-promise.min.js)
* [es6-promise-auto-min 6.19 KB (2.4 KB gzipped)](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/es6-promise.auto.min.js) - Minified version of `es6-promise-auto` above.

## Node.js

Expand Down Expand Up @@ -60,6 +62,12 @@ To polyfill the global environment (either in Node or in the browser via CommonJ
require('es6-promise').polyfill();
```

Alternatively

```js
require('es6-promise/auto');
```

Notice that we don't assign the result of `polyfill()` to any variable. The `polyfill()` method will patch the global environment (in this case to the `Promise` name) when called.

## Building & Testing
Expand Down
4 changes: 4 additions & 0 deletions auto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file can be required in Browserify and Node.js for automatic polyfill
// To use it: require('es6-promise/auto');
'use strict';
module.exports = require('.').polyfill();
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "es6-promise",
"namespace": "Promise",
"version": "3.3.1",
"version": "4.0.0",
"description": "A polyfill for ES6-style Promises, tracking rsvp",
"authors": [
"Stefan Penner <stefan.penner@gmail.com>"
Expand Down

0 comments on commit 81eabcd

Please sign in to comment.