diff --git a/dist/promisepromise.js b/dist/promisepromise.js index d009d68..82556d1 100644 --- a/dist/promisepromise.js +++ b/dist/promisepromise.js @@ -1,8 +1,4 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.promisePromise = factory()); -}(this, (function () { 'use strict'; +'use strict'; var excuses = ['You must be missing some of the dependencies', 'How is that possible?', 'I couldn\'t find any library that can even do that', 'That wouldn\'t have made economic sense.', 'The project manager told me to do it that way.', 'Try rebooting your router.', 'Are you sure?', 'That\'s a problem with the hosts.', 'It wasn\'t in the spec.', 'The person responsible doesn\'t work here any more.', 'Probably down to the leap year.', 'That code was written by an old developer.', 'Well I\'m surprised it is even working at all.', 'I must have misunderstood.', 'It isn\'t in my ticketing system.', 'Try rebotting.', 'You\'re doing it wrong.', 'It worked fine for me when I developed it.', 'We didn\'t write that part.', 'It\'s always been like that.']; @@ -12,88 +8,14 @@ var classCallCheck = function (instance, Constructor) { } }; - - - - - - - - -var get = function get(object, property, receiver) { - if (object === null) object = Function.prototype; - var desc = Object.getOwnPropertyDescriptor(object, property); - - if (desc === undefined) { - var parent = Object.getPrototypeOf(object); - - if (parent === null) { - return undefined; - } else { - return get(parent, property, receiver); - } - } else if ("value" in desc) { - return desc.value; - } else { - var getter = desc.get; - - if (getter === undefined) { - return undefined; - } - - return getter.call(receiver); - } -}; - - - - - - - - - - - - - - - - - -var set = function set(object, property, value, receiver) { - var desc = Object.getOwnPropertyDescriptor(object, property); - - if (desc === undefined) { - var parent = Object.getPrototypeOf(object); - - if (parent !== null) { - set(parent, property, value, receiver); - } - } else if ("value" in desc && desc.writable) { - desc.value = value; - } else { - var setter = desc.set; - - if (setter !== undefined) { - setter.call(receiver, value); - } - } - - return value; -}; - var getRandomExcuse = function getRandomExcuse() { return excuses[Math.floor(Math.random() * excuses.length)]; }; -var realPromise = Promise; - var PromisePromise = function PromisePromise(init) { classCallCheck(this, PromisePromise); - console.warn(realPromise); - var promise = new realPromise(init); + var promise = new Promise(init); return new Promise(function (resolve, reject) { promise.then(function (response) { var shouldResolve = Math.random() >= 0.5; @@ -102,14 +24,10 @@ var PromisePromise = function PromisePromise(init) { } else { reject(getRandomExcuse()); } - resolve(response); }).catch(function (err) { resolve(err); }); }); }; -return PromisePromise; - -}))); -//# sourceMappingURL=promisepromise.js.map +module.exports = PromisePromise; diff --git a/dist/promisepromise.js.map b/dist/promisepromise.js.map deleted file mode 100644 index c562814..0000000 --- a/dist/promisepromise.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":null,"sources":["../excuses.js","../index.js"],"sourcesContent":["const excuses = [\n 'You must be missing some of the dependencies',\n 'How is that possible?',\n 'I couldn\\'t find any library that can even do that',\n\t'That wouldn\\'t have made economic sense.',\n\t'The project manager told me to do it that way.',\n\t'Try rebooting your router.',\n\t'Are you sure?',\n\t'That\\'s a problem with the hosts.',\n\t'It wasn\\'t in the spec.',\n\t'The person responsible doesn\\'t work here any more.',\n\t'Probably down to the leap year.',\n\t'That code was written by an old developer.',\n\t'Well I\\'m surprised it is even working at all.',\n\t'I must have misunderstood.',\n\t'It isn\\'t in my ticketing system.',\n\t'Try rebotting.',\n\t'You\\'re doing it wrong.',\n\t'It worked fine for me when I developed it.',\n\t'We didn\\'t write that part.',\n\t'It\\'s always been like that.'\n];\n\nexport default excuses;","import excuses from './excuses';\n\nconst getRandomExcuse = () => {\n return excuses[Math.floor(Math.random() * excuses.length)];\n};\n\nconst realPromise = Promise;\nexport default class PromisePromise {\n\tconstructor(init) {\n\t\tconsole.warn(realPromise);\n\t\tconst promise = new realPromise(init);\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tpromise\n\t\t\t\t.then(response => {\n\t\t\t\t\tconst shouldResolve = Math.random() >= 0.5;\n\t\t\t\t\tif (shouldResolve) {\n\t\t\t\t\t\tresolve(response);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treject(getRandomExcuse());\n\t\t\t\t\t}\n resolve(response);\n\t\t\t\t})\n .catch(err => {\n resolve(err);\n });\n\t\t});\n\t}\n}\n\n// window.Promise = PromisePromise;\n"],"names":["excuses","getRandomExcuse","Math","floor","random","length","realPromise","Promise","PromisePromise","init","warn","promise","resolve","reject","then","shouldResolve","response","catch","err"],"mappings":";;;;;;AAAA,IAAMA,UAAU,CACZ,8CADY,EAEZ,uBAFY,EAGZ,oDAHY,EAIf,0CAJe,EAKf,gDALe,EAMf,4BANe,EAOf,eAPe,EAQf,mCARe,EASf,yBATe,EAUf,qDAVe,EAWf,iCAXe,EAYf,4CAZe,EAaf,gDAbe,EAcf,4BAde,EAef,mCAfe,EAgBf,gBAhBe,EAiBf,yBAjBe,EAkBf,4CAlBe,EAmBf,6BAnBe,EAoBf,8BApBe,CAAhB,CAuBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrBA,IAAMC,kBAAkB,SAAlBA,eAAkB,GAAM;QACnBD,QAAQE,KAAKC,KAAL,CAAWD,KAAKE,MAAL,KAAgBJ,QAAQK,MAAnC,CAAR,CAAP;CADJ;;AAIA,IAAMC,cAAcC,OAApB;;IACqBC,iBACpB,wBAAYC,IAAZ,EAAkB;;;SACTC,IAAR,CAAaJ,WAAb;KACMK,UAAU,IAAIL,WAAJ,CAAgBG,IAAhB,CAAhB;QACO,IAAIF,OAAJ,CAAY,UAACK,OAAD,EAAUC,MAAV,EAAqB;UAErCC,IADF,CACO,oBAAY;OACXC,gBAAgBb,KAAKE,MAAL,MAAiB,GAAvC;OACIW,aAAJ,EAAmB;YACVC,QAAR;IADD,MAEO;WACCf,iBAAP;;WAEsBe,QAAR;GARjB,EAUcC,KAVd,CAUoB,eAAO;WACFC,GAAR;GAXjB;EADM,CAAP;EAkBF;;;;"} \ No newline at end of file diff --git a/dist/promisepromise.min.js b/dist/umd/promisepromise.min.js similarity index 81% rename from dist/promisepromise.min.js rename to dist/umd/promisepromise.min.js index 16843fa..f42c0dc 100644 --- a/dist/promisepromise.min.js +++ b/dist/umd/promisepromise.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.promisePromise=t()}(this,function(){"use strict";var e=["You must be missing some of the dependencies","How is that possible?","I couldn't find any library that can even do that","That wouldn't have made economic sense.","The project manager told me to do it that way.","Try rebooting your router.","Are you sure?","That's a problem with the hosts.","It wasn't in the spec.","The person responsible doesn't work here any more.","Probably down to the leap year.","That code was written by an old developer.","Well I'm surprised it is even working at all.","I must have misunderstood.","It isn't in my ticketing system.","Try rebotting.","You're doing it wrong.","It worked fine for me when I developed it.","We didn't write that part.","It's always been like that."],t=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=function(){return e[Math.floor(Math.random()*e.length)]},o=Promise,r=function e(r){t(this,e),console.warn(o);var i=new o(r);return new Promise(function(e,t){i.then(function(o){var r=Math.random()>=.5;r?e(o):t(n()),e(o)}).catch(function(t){e(t)})})};return r}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.promisePromise=t()}(this,function(){"use strict";var e=["You must be missing some of the dependencies","How is that possible?","I couldn't find any library that can even do that","That wouldn't have made economic sense.","The project manager told me to do it that way.","Try rebooting your router.","Are you sure?","That's a problem with the hosts.","It wasn't in the spec.","The person responsible doesn't work here any more.","Probably down to the leap year.","That code was written by an old developer.","Well I'm surprised it is even working at all.","I must have misunderstood.","It isn't in my ticketing system.","Try rebotting.","You're doing it wrong.","It worked fine for me when I developed it.","We didn't write that part.","It's always been like that."],t=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},n=function(){return e[Math.floor(Math.random()*e.length)]},o=function e(o){t(this,e);var r=new Promise(o);return new Promise(function(e,t){r.then(function(o){var r=Math.random()>=.5;r?e(o):t(n())}).catch(function(t){e(t)})})};return o}); diff --git a/index.js b/index.js index b0bd3a4..d13e027 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,9 @@ import excuses from './excuses'; const getRandomExcuse = () => { - return excuses[Math.floor(Math.random() * excuses.length)]; + return excuses[Math.floor(Math.random() * excuses.length)]; }; - export default class PromisePromise { constructor(init) { const promise = new Promise(init); @@ -18,9 +17,9 @@ export default class PromisePromise { reject(getRandomExcuse()); } }) - .catch(err => { - resolve(err); - }); + .catch(err => { + resolve(err); + }); }); } -} \ No newline at end of file +} diff --git a/rollup.config.js b/rollup.config.js index f5017d5..b67b793 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,9 +6,9 @@ import sourcemaps from 'rollup-plugin-sourcemaps'; export default { entry: 'index.js', dest: 'dist/promisepromise.js', - format: 'umd', + format: 'cjs', moduleName: 'promisePromise', - sourceMap: true, + sourceMap: false, plugins: [ resolve({ jsnext: true, diff --git a/rollup.prod.config.js b/rollup.prod.config.js index 5b58141..c0431f7 100644 --- a/rollup.prod.config.js +++ b/rollup.prod.config.js @@ -5,7 +5,7 @@ import commonjs from 'rollup-plugin-commonjs'; export default { entry: 'index.js', - dest: 'dist/promisepromise.min.js', + dest: 'dist/umd/promisepromise.min.js', format: 'umd', moduleName: 'promisePromise', plugins: [