diff --git a/README.md b/README.md index 7e10ef6d..a312f2f2 100644 --- a/README.md +++ b/README.md @@ -392,16 +392,19 @@ js/css.js: ```javascript exports.fetch = function(load) { // return a thenable for fetching (as per specification) - return new Promise(function(resolve, reject) { - var cssFile = load.address; + // alternatively return new Promise(function(resolve, reject)) + return { + then: function(resolve, reject) { + var cssFile = load.address; - var link = document.createElement('link'); - link.rel = 'stylesheet'; - link.href = cssFile; - link.onload = resolve; + var link = document.createElement('link'); + link.rel = 'stylesheet'; + link.href = cssFile; + link.onload = resolve; - document.head.appendChild(link); - }); + document.head.appendChild(link); + } + }; } ``` diff --git a/test/tests/advanced-plugin.js b/test/tests/advanced-plugin.js index c6075d30..574663a4 100644 --- a/test/tests/advanced-plugin.js +++ b/test/tests/advanced-plugin.js @@ -1,17 +1,21 @@ exports.locate = function(load) { - return new Promise(function(resolve, reject) { - setTimeout(function() { - resolve('custom fetch'); - }, 20); - }); + return { + then: function(resolve, reject) { + setTimeout(function() { + resolve('custom fetch'); + }, 20); + } + }; } exports.fetch = function(load) { - return new Promise(function(resolve, reject) { - setTimeout(function() { - resolve(load.address); - }, 20); - }); + return { + then: function(resolve, reject) { + setTimeout(function() { + resolve(load.address); + }, 20); + } + } } exports.translate = function(load) {