UNPKG

1.15 kBSource Map (JSON)View Raw
1{"version":3,"file":"toPromise.js","sourceRoot":"","sources":["../../../src/link/utils/toPromise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,MAAM,UAAU,SAAS,CAAI,UAAyB;IACpD,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,OAAO,IAAI,OAAO,CAAI,UAAC,OAAO,EAAE,MAAM;QACpC,UAAU,CAAC,SAAS,CAAC;YACnB,IAAI,EAAE,UAAA,IAAI;gBACR,IAAI,SAAS,EAAE;oBACb,SAAS,CAAC,IAAI,CACZ,mEAAmE,CACpE,CAAC;iBACH;qBAAM;oBACL,SAAS,GAAG,IAAI,CAAC;oBACjB,OAAO,CAAC,IAAI,CAAC,CAAC;iBACf;YACH,CAAC;YACD,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\nimport { Observable } from '../../utilities';\n\nexport function toPromise<R>(observable: Observable<R>): Promise<R> {\n let completed = false;\n return new Promise<R>((resolve, reject) => {\n observable.subscribe({\n next: data => {\n if (completed) {\n invariant.warn(\n `Promise Wrapper does not support multiple results from Observable`,\n );\n } else {\n completed = true;\n resolve(data);\n }\n },\n error: reject,\n });\n });\n}\n"]}
\No newline at end of file