UNPKG

pnpm

Version:

A fast implementation of npm install

6 lines 3.74 kB
/** * cb2promise - Converts whatever standard NodeJS callback function into ES6 standard promise. * @version v1.0.2 * @link https://github.com/Kikobeats/cb2promise * @license MIT */require=function t(n,e,r){function o(u,c){if(!e[u]){if(!n[u]){var f="function"==typeof require&&require;if(!c&&f)return f(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var a=e[u]={exports:{}};n[u][0].call(a.exports,function(t){var e=n[u][1][t];return o(e?e:t)},a,a.exports,t,n,e,r)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(t,n,e){"use strict";var r;r=t("pinkie-promise"),n.exports=function(){var t,n,e,o,i;return t=Array.prototype.slice.call(arguments),e=t.shift(),i=null,o=null,n=function(){var n;return t=Array.prototype.slice.call(arguments),n=t.shift(),n?o(n):i.apply(null,t)},t.push(n),new r(function(n,r){return i=n,o=r,e.apply(null,t)})}},{"pinkie-promise":3}],2:[function(t,n,e){},{}],3:[function(t,n,e){(function(e){"use strict";n.exports=e.Promise||t("pinkie")}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{pinkie:4}],4:[function(t,n,e){"use strict";function r(){for(var t=0;t<x.length;t++)x[t][0](x[t][1]);x=[],d=!1}function o(t,n){x.push([t,n]),d||(d=!0,g(r,0))}function i(t,n){function e(t){f(n,t)}function r(t){a(n,t)}try{t(e,r)}catch(o){r(o)}}function u(t){var n=t.owner,e=n._state,r=n._data,o=t[e],i=t.then;if("function"==typeof o){e=_;try{r=o(r)}catch(u){a(i,u)}}c(i,r)||(e===_&&f(i,r),e===v&&a(i,r))}function c(t,n){var e;try{if(t===n)throw new TypeError("A promises callback cannot return that same promise.");if(n&&("function"==typeof n||"object"==typeof n)){var r=n.then;if("function"==typeof r)return r.call(n,function(r){e||(e=!0,n!==r?f(t,r):s(t,r))},function(n){e||(e=!0,a(t,n))}),!0}}catch(o){return e||a(t,o),!0}return!1}function f(t,n){t!==n&&c(t,n)||s(t,n)}function s(t,n){t._state===w&&(t._state=m,t._data=n,o(p,t))}function a(t,n){t._state===w&&(t._state=m,t._data=n,o(h,t))}function l(t){t._then=t._then.forEach(u)}function p(t){t._state=_,l(t)}function h(t){t._state=v,l(t)}function y(t){if("function"!=typeof t)throw new TypeError("Promise resolver "+t+" is not a function");if(this instanceof y==!1)throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._then=[],i(t,this)}var d,w="pending",m="settled",_="fulfilled",v="rejected",b=function(){},g="undefined"!=typeof setImmediate?setImmediate:setTimeout,x=[];y.prototype={constructor:y,_state:w,_then:null,_data:void 0,then:function(t,n){var e={owner:this,then:new this.constructor(b),fulfilled:t,rejected:n};return this._state===_||this._state===v?o(u,e):this._then.push(e),e.then},"catch":function(t){return this.then(null,t)}},y.all=function(t){if(!Array.isArray(t))throw new TypeError("You must pass an array to Promise.all().");return new y(function(n,e){function r(t){return u++,function(e){i[t]=e,--u||n(i)}}for(var o,i=[],u=0,c=0;c<t.length;c++)o=t[c],o&&"function"==typeof o.then?o.then(r(c),e):i[c]=o;u||n(i)})},y.race=function(t){if(!Array.isArray(t))throw new TypeError("You must pass an array to Promise.race().");return new y(function(n,e){for(var r,o=0;o<t.length;o++)r=t[o],r&&"function"==typeof r.then?r.then(n,e):n(r)})},y.resolve=function(t){return t&&"object"==typeof t&&t.constructor===y?t:new y(function(n){n(t)})},y.reject=function(t){return new y(function(n,e){e(t)})},n.exports=y},{}],cb2promise:[function(t,n,e){"use strict";t("coffee-script/register"),n.exports=t("./lib/cb2promise")},{"./lib/cb2promise":1,"coffee-script/register":2}]},{},[]);