call-to-promise
Version:
A lightweight, production-ready, universal library for transforming callback-style functions into Promise-based ones. Works seamlessly across Node.js, Deno, and browsers.
1 lines • 1.81 kB
JavaScript
var r={189:r=>{function n(){var r,n,t,e,i=!0;this.isPending=function(){return i},this.isSucceed=function(){return n},this.isFailed=function(){return r},this.__pointerTestingProperty=0,this.isSameObjectAs=function(r){return r.__pointerTestingProperty=3,this.__pointerTestingProperty=4,r.__pointerTestingProperty===this.__pointerTestingProperty},this.resolve=function(){},this.reject=function(){},this.promise=(t=this,e=function(t){if(!i)throw new Error("Promise is not pending");i=!1,n=t,r=!t},new Promise((function(r,n){t.resolve=function(){e(!0),r.apply(t,arguments.length>1?{0:arguments,length:1}:arguments)},t.reject=function(){e(!1),n.apply(t,arguments.length>1?{0:arguments,length:1}:arguments)}})))}r.exports.defer=function(){return new n}},875:(r,n)=>{function t(r){return"string"==typeof r}n.isString=t,n.isArrayOfStrings=function(r){return Array.isArray(r)&&r.every(t)}}},n={};function t(e){var i=n[e];if(void 0!==i)return i.exports;var o=n[e]={exports:{}};return r[e](o,o.exports,t),o.exports}var e={};(()=>{var r=e,n=t(189),i=t(875),o={};function s(r,t){if(!i.isString(r))throw new Error('ID has to be "string" only');return t[r]||(t[r]=n.defer()),t[r]}function u(r,n){if(i.isString(r))return s(r,n).promise;if(i.isArrayOfStrings(r))return Promise.all(r.map((function(r){return s(r,n).promise})));throw new Error("getPromise expecting id(string) or id(array<string>)")}r.id=function(r){return s(r,o)},r.MH=function(r){return s(r,o).resolve},r.RA=function(r){return s(r,o).reject},r.z7=function(r){return u(r,o)},r.jq=function(){var r={};return{id:function(n){return s(n,r)},successfn:function(n){return s(n,r).resolve},failfn:function(n){return s(n,r).reject},when:function(n){return u(n,r)}}}})();var i=e.jq,o=e.RA,s=e.id,u=e.MH,f=e.z7;export{i as build,o as failfn,s as id,u as successfn,f as when};