alicezetion 1.9.7 → 1.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (292) hide show
  1. package/.cache/replit/modules/nodejs-20.res +1 -0
  2. package/.cache/replit/modules/replit.res +1 -0
  3. package/.cache/typescript/5.4/node_modules/.package-lock.json +137 -0
  4. package/.cache/typescript/5.4/node_modules/@types/bluebird/LICENSE +21 -0
  5. package/.cache/typescript/5.4/node_modules/@types/bluebird/README.md +15 -0
  6. package/.cache/typescript/5.4/node_modules/@types/bluebird/index.d.ts +1365 -0
  7. package/.cache/typescript/5.4/node_modules/@types/bluebird/package.json +25 -0
  8. package/.cache/typescript/5.4/node_modules/@types/caseless/LICENSE +21 -0
  9. package/.cache/typescript/5.4/node_modules/@types/caseless/README.md +48 -0
  10. package/.cache/typescript/5.4/node_modules/@types/caseless/index.d.ts +29 -0
  11. package/.cache/typescript/5.4/node_modules/@types/caseless/package.json +35 -0
  12. package/.cache/typescript/5.4/node_modules/@types/cheerio/LICENSE +21 -0
  13. package/.cache/typescript/5.4/node_modules/@types/cheerio/README.md +15 -0
  14. package/.cache/typescript/5.4/node_modules/@types/cheerio/index.d.ts +318 -0
  15. package/.cache/typescript/5.4/node_modules/@types/cheerio/package.json +71 -0
  16. package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +21 -0
  17. package/.cache/typescript/5.4/node_modules/@types/node/README.md +15 -0
  18. package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +8 -0
  19. package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +1040 -0
  20. package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +541 -0
  21. package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +2363 -0
  22. package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +1544 -0
  23. package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +578 -0
  24. package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +452 -0
  25. package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +19 -0
  26. package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +4523 -0
  27. package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +596 -0
  28. package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
  29. package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +476 -0
  30. package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +864 -0
  31. package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +124 -0
  32. package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +170 -0
  33. package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +931 -0
  34. package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +1245 -0
  35. package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +4317 -0
  36. package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +412 -0
  37. package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +1 -0
  38. package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +1908 -0
  39. package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +2418 -0
  40. package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +550 -0
  41. package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +89 -0
  42. package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +2746 -0
  43. package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +315 -0
  44. package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +999 -0
  45. package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +495 -0
  46. package/.cache/typescript/5.4/node_modules/@types/node/package.json +217 -0
  47. package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +191 -0
  48. package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +905 -0
  49. package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +1754 -0
  50. package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +117 -0
  51. package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +153 -0
  52. package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +150 -0
  53. package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +540 -0
  54. package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +430 -0
  55. package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +153 -0
  56. package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +12 -0
  57. package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +83 -0
  58. package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +367 -0
  59. package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +1707 -0
  60. package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +67 -0
  61. package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +1718 -0
  62. package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +97 -0
  63. package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +240 -0
  64. package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +1217 -0
  65. package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +197 -0
  66. package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +208 -0
  67. package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +952 -0
  68. package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +2292 -0
  69. package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +808 -0
  70. package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +924 -0
  71. package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +181 -0
  72. package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +694 -0
  73. package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +530 -0
  74. package/.cache/typescript/5.4/node_modules/@types/npmlog/LICENSE +21 -0
  75. package/.cache/typescript/5.4/node_modules/@types/npmlog/README.md +15 -0
  76. package/.cache/typescript/5.4/node_modules/@types/npmlog/index.d.ts +84 -0
  77. package/.cache/typescript/5.4/node_modules/@types/npmlog/package.json +32 -0
  78. package/.cache/typescript/5.4/node_modules/@types/request/LICENSE +21 -0
  79. package/.cache/typescript/5.4/node_modules/@types/request/README.md +15 -0
  80. package/.cache/typescript/5.4/node_modules/@types/request/index.d.ts +395 -0
  81. package/.cache/typescript/5.4/node_modules/@types/request/package.json +70 -0
  82. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/LICENSE +21 -0
  83. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/README.md +15 -0
  84. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/index.d.ts +321 -0
  85. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/package.json +35 -0
  86. package/.cache/typescript/5.4/node_modules/asynckit/LICENSE +21 -0
  87. package/.cache/typescript/5.4/node_modules/asynckit/README.md +233 -0
  88. package/.cache/typescript/5.4/node_modules/asynckit/bench.js +76 -0
  89. package/.cache/typescript/5.4/node_modules/asynckit/index.js +6 -0
  90. package/.cache/typescript/5.4/node_modules/asynckit/lib/abort.js +29 -0
  91. package/.cache/typescript/5.4/node_modules/asynckit/lib/async.js +34 -0
  92. package/.cache/typescript/5.4/node_modules/asynckit/lib/defer.js +26 -0
  93. package/.cache/typescript/5.4/node_modules/asynckit/lib/iterate.js +75 -0
  94. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  95. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_parallel.js +25 -0
  96. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial.js +25 -0
  97. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  98. package/.cache/typescript/5.4/node_modules/asynckit/lib/state.js +37 -0
  99. package/.cache/typescript/5.4/node_modules/asynckit/lib/streamify.js +141 -0
  100. package/.cache/typescript/5.4/node_modules/asynckit/lib/terminator.js +29 -0
  101. package/.cache/typescript/5.4/node_modules/asynckit/package.json +63 -0
  102. package/.cache/typescript/5.4/node_modules/asynckit/parallel.js +43 -0
  103. package/.cache/typescript/5.4/node_modules/asynckit/serial.js +17 -0
  104. package/.cache/typescript/5.4/node_modules/asynckit/serialOrdered.js +75 -0
  105. package/.cache/typescript/5.4/node_modules/asynckit/stream.js +21 -0
  106. package/.cache/typescript/5.4/node_modules/combined-stream/License +19 -0
  107. package/.cache/typescript/5.4/node_modules/combined-stream/Readme.md +138 -0
  108. package/.cache/typescript/5.4/node_modules/combined-stream/lib/combined_stream.js +208 -0
  109. package/.cache/typescript/5.4/node_modules/combined-stream/package.json +25 -0
  110. package/.cache/typescript/5.4/node_modules/combined-stream/yarn.lock +17 -0
  111. package/.cache/typescript/5.4/node_modules/delayed-stream/License +19 -0
  112. package/.cache/typescript/5.4/node_modules/delayed-stream/Makefile +7 -0
  113. package/.cache/typescript/5.4/node_modules/delayed-stream/Readme.md +141 -0
  114. package/.cache/typescript/5.4/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  115. package/.cache/typescript/5.4/node_modules/delayed-stream/package.json +27 -0
  116. package/.cache/typescript/5.4/node_modules/form-data/License +19 -0
  117. package/.cache/typescript/5.4/node_modules/form-data/README.md +350 -0
  118. package/.cache/typescript/5.4/node_modules/form-data/README.md.bak +350 -0
  119. package/.cache/typescript/5.4/node_modules/form-data/index.d.ts +51 -0
  120. package/.cache/typescript/5.4/node_modules/form-data/lib/browser.js +2 -0
  121. package/.cache/typescript/5.4/node_modules/form-data/lib/form_data.js +483 -0
  122. package/.cache/typescript/5.4/node_modules/form-data/lib/populate.js +10 -0
  123. package/.cache/typescript/5.4/node_modules/form-data/package.json +68 -0
  124. package/.cache/typescript/5.4/node_modules/mime-db/HISTORY.md +507 -0
  125. package/.cache/typescript/5.4/node_modules/mime-db/LICENSE +23 -0
  126. package/.cache/typescript/5.4/node_modules/mime-db/README.md +100 -0
  127. package/.cache/typescript/5.4/node_modules/mime-db/db.json +8519 -0
  128. package/.cache/typescript/5.4/node_modules/mime-db/index.js +12 -0
  129. package/.cache/typescript/5.4/node_modules/mime-db/package.json +60 -0
  130. package/.cache/typescript/5.4/node_modules/mime-types/HISTORY.md +397 -0
  131. package/.cache/typescript/5.4/node_modules/mime-types/LICENSE +23 -0
  132. package/.cache/typescript/5.4/node_modules/mime-types/README.md +113 -0
  133. package/.cache/typescript/5.4/node_modules/mime-types/index.js +188 -0
  134. package/.cache/typescript/5.4/node_modules/mime-types/package.json +44 -0
  135. package/.cache/typescript/5.4/node_modules/types-registry/README.md +2 -0
  136. package/.cache/typescript/5.4/node_modules/types-registry/index.json +1 -0
  137. package/.cache/typescript/5.4/node_modules/types-registry/package.json +20 -0
  138. package/.cache/typescript/5.4/node_modules/undici-types/README.md +6 -0
  139. package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +31 -0
  140. package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +43 -0
  141. package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +18 -0
  142. package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +36 -0
  143. package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +97 -0
  144. package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +34 -0
  145. package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +21 -0
  146. package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +28 -0
  147. package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
  148. package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +241 -0
  149. package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +128 -0
  150. package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +209 -0
  151. package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +39 -0
  152. package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +54 -0
  153. package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +108 -0
  154. package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  155. package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +7 -0
  156. package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +9 -0
  157. package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +4 -0
  158. package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +63 -0
  159. package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +5 -0
  160. package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +50 -0
  161. package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +25 -0
  162. package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +12 -0
  163. package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  164. package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +25 -0
  165. package/.cache/typescript/5.4/node_modules/undici-types/package.json +55 -0
  166. package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +71 -0
  167. package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +19 -0
  168. package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +28 -0
  169. package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +30 -0
  170. package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +61 -0
  171. package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +220 -0
  172. package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +131 -0
  173. package/.cache/typescript/5.4/package-lock.json +149 -0
  174. package/.cache/typescript/5.4/package.json +1 -0
  175. package/index.js +291 -71
  176. package/leiamnash/addExternalModule.js +15 -0
  177. package/leiamnash/addUserToGroup.js +77 -0
  178. package/leiamnash/changeAdminStatus.js +47 -0
  179. package/leiamnash/changeArchivedStatus.js +41 -0
  180. package/{src → leiamnash}/changeAvatar.js +3 -2
  181. package/leiamnash/changeBio.js +64 -0
  182. package/leiamnash/changeBlockedStatus.js +36 -0
  183. package/leiamnash/changeGroupImage.js +105 -0
  184. package/leiamnash/changeNickname.js +43 -0
  185. package/leiamnash/changeThreadColor.js +61 -0
  186. package/leiamnash/changeThreadEmoji.js +41 -0
  187. package/{src → leiamnash}/chat.js +4 -29
  188. package/leiamnash/createNewGroup.js +70 -0
  189. package/leiamnash/createPoll.js +59 -0
  190. package/leiamnash/deleteMessage.js +44 -0
  191. package/leiamnash/deleteThread.js +42 -0
  192. package/leiamnash/editMessage.js +62 -0
  193. package/leiamnash/forwardAttachment.js +47 -0
  194. package/leiamnash/forwardMessage.js +0 -0
  195. package/leiamnash/getCurrentUserID.js +7 -0
  196. package/leiamnash/getEmojiUrl.js +27 -0
  197. package/leiamnash/getFriendsList.js +73 -0
  198. package/leiamnash/getInfoVideo.js +134 -0
  199. package/leiamnash/getThreadHistory.js +537 -0
  200. package/leiamnash/getThreadHistoryDeprecated.js +71 -0
  201. package/leiamnash/getThreadInfo.js +171 -0
  202. package/leiamnash/getThreadInfoDeprecated.js +56 -0
  203. package/leiamnash/getThreadList.js +213 -0
  204. package/leiamnash/getThreadListDeprecated.js +46 -0
  205. package/leiamnash/getThreadPictures.js +59 -0
  206. package/leiamnash/getUserID.js +61 -0
  207. package/leiamnash/getUserInfo.js +66 -0
  208. package/leiamnash/handleFriendRequest.js +46 -0
  209. package/leiamnash/handleMessageRequest.js +47 -0
  210. package/leiamnash/httpGet.js +47 -0
  211. package/leiamnash/httpPost.js +47 -0
  212. package/leiamnash/httpPostFormData.js +42 -0
  213. package/leiamnash/listenMqtt.js +843 -0
  214. package/leiamnash/logout.js +68 -0
  215. package/leiamnash/markAsDelivered.js +47 -0
  216. package/leiamnash/markAsRead.js +70 -0
  217. package/leiamnash/markAsReadAll.js +40 -0
  218. package/leiamnash/markAsSeen.js +48 -0
  219. package/leiamnash/muteThread.js +45 -0
  220. package/leiamnash/pinMessage.js +58 -0
  221. package/leiamnash/react.js +109 -0
  222. package/{src → leiamnash}/refreshFb_dtsg.js +1 -1
  223. package/leiamnash/removeUserFromGroup.js +45 -0
  224. package/leiamnash/resolvePhotoUrl.js +36 -0
  225. package/leiamnash/searchForThread.js +42 -0
  226. package/leiamnash/seen.js +40 -0
  227. package/leiamnash/sendMessage.js +315 -0
  228. package/leiamnash/sendTypingIndicator.js +70 -0
  229. package/leiamnash/setMessageReaction.js +103 -0
  230. package/leiamnash/setPostReaction.js +63 -0
  231. package/leiamnash/setTitle.js +70 -0
  232. package/leiamnash/threadColors.js +41 -0
  233. package/leiamnash/token.js +112 -0
  234. package/leiamnash/unfriend.js +42 -0
  235. package/leiamnash/unsendMessage.js +39 -0
  236. package/{src → leiamnash}/uploadAttachment.js +2 -1
  237. package/package.json +3 -2
  238. package/utils.js +1345 -1382
  239. package/.cache/replit/modules/nodejs-20:v32-20240401-269b323.res +0 -1
  240. package/.cache/replit/modules/replit:v8-20240329-787bc7d.res +0 -1
  241. package/.replit +0 -1
  242. package/src/addExternalModule.js +0 -19
  243. package/src/addUserToGroup.js +0 -113
  244. package/src/changeAdminStatus.js +0 -79
  245. package/src/changeArchivedStatus.js +0 -55
  246. package/src/changeBio.js +0 -77
  247. package/src/changeBlockedStatus.js +0 -47
  248. package/src/changeGroupImage.js +0 -132
  249. package/src/changeNickname.js +0 -59
  250. package/src/changeThreadColor.js +0 -65
  251. package/src/changeThreadEmoji.js +0 -55
  252. package/src/createNewGroup.js +0 -86
  253. package/src/createPoll.js +0 -71
  254. package/src/deleteMessage.js +0 -56
  255. package/src/deleteThread.js +0 -56
  256. package/src/edit.js +0 -66
  257. package/src/forwardAttachment.js +0 -60
  258. package/src/getCurrentUserID.js +0 -7
  259. package/src/getEmojiUrl.js +0 -29
  260. package/src/getFriendsList.js +0 -83
  261. package/src/getThreadHistory.js +0 -666
  262. package/src/getThreadInfo.js +0 -232
  263. package/src/getThreadList.js +0 -241
  264. package/src/getThreadPictures.js +0 -79
  265. package/src/getUserID.js +0 -66
  266. package/src/getUserInfo.js +0 -74
  267. package/src/handleFriendRequest.js +0 -61
  268. package/src/handleMessageRequest.js +0 -65
  269. package/src/httpGet.js +0 -57
  270. package/src/httpPost.js +0 -57
  271. package/src/httpPostFormData.js +0 -63
  272. package/src/listenMqtt.js +0 -854
  273. package/src/logout.js +0 -75
  274. package/src/markAsDelivered.js +0 -58
  275. package/src/markAsRead.js +0 -80
  276. package/src/markAsReadAll.js +0 -50
  277. package/src/markAsSeen.js +0 -59
  278. package/src/muteThread.js +0 -52
  279. package/src/react.js +0 -121
  280. package/src/removeUserFromGroup.js +0 -79
  281. package/src/resolvePhotoUrl.js +0 -45
  282. package/src/searchForThread.js +0 -53
  283. package/src/seen.js +0 -50
  284. package/src/sendMessage.js +0 -477
  285. package/src/sendTypingIndicator.js +0 -103
  286. package/src/setMessageReaction.js +0 -121
  287. package/src/setPostReaction.js +0 -109
  288. package/src/setTitle.js +0 -86
  289. package/src/threadColors.js +0 -131
  290. package/src/unfriend.js +0 -52
  291. package/src/unsendMessage.js +0 -49
  292. /package/{src → leiamnash}/getMessage.js +0 -0
@@ -0,0 +1,1365 @@
1
+ /*!
2
+ * The code following this comment originates from:
3
+ * https://github.com/types/npm-bluebird
4
+ *
5
+ * Note for browser users: use bluebird-global typings instead of this one
6
+ * if you want to use Bluebird via the global Promise symbol.
7
+ *
8
+ * Licensed under:
9
+ * The MIT License (MIT)
10
+ *
11
+ * Copyright (c) 2016 unional
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ * copies of the Software, and to permit persons to whom the Software is
18
+ * furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in
21
+ * all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
+ * THE SOFTWARE.
30
+ */
31
+
32
+ type Constructor<E> = new(...args: any[]) => E;
33
+ type CatchFilter<E> = ((error: E) => boolean) | (object & E);
34
+ type Resolvable<R> = R | PromiseLike<R>;
35
+ type IterateFunction<T, R> = (item: T, index: number, arrayLength: number) => Resolvable<R>;
36
+
37
+ type PromisifyAllKeys<T> = T extends string ? `${T}Async` : never;
38
+ type WithoutLast<T> = T extends [...infer A, any] ? A : [];
39
+ type Last<T> = T extends [...any[], infer L] ? L : never;
40
+ type ExtractCallbackValueType<T> = T extends (error: any, ...data: infer D) => any ? D : never;
41
+
42
+ type PromiseMethod<TArgs, TReturn> = TReturn extends never ? never : (...args: WithoutLast<TArgs>) => Promise<TReturn>;
43
+
44
+ type ExtractAsyncMethod<T> = T extends (...args: infer A) => any
45
+ ? PromiseMethod<A, ExtractCallbackValueType<Last<Required<A>>>[0]>
46
+ : never;
47
+
48
+ type PromisifyAllItems<T> = {
49
+ [K in keyof T as PromisifyAllKeys<K>]: ExtractAsyncMethod<T[K]>;
50
+ };
51
+
52
+ type NonNeverValues<T> = {
53
+ [K in keyof T as T[K] extends never ? never : K]: T[K];
54
+ };
55
+
56
+ // Drop `never` values
57
+ type PromisifyAll<T> = NonNeverValues<PromisifyAllItems<T>> & T;
58
+
59
+ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
60
+ readonly [Symbol.toStringTag]: "Object";
61
+
62
+ /**
63
+ * Create a new promise. The passed in function will receive functions
64
+ * `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
65
+ *
66
+ * If promise cancellation is enabled, passed in function will receive
67
+ * one more function argument `onCancel` that allows to register an optional cancellation callback.
68
+ */
69
+ constructor(
70
+ callback: (
71
+ resolve: (thenableOrResult?: Resolvable<R>) => void,
72
+ reject: (error?: any) => void,
73
+ onCancel?: (callback: () => void) => void,
74
+ ) => void,
75
+ );
76
+
77
+ /**
78
+ * Promises/A+ `.then()`. Returns a new promise chained from this promise.
79
+ *
80
+ * The new promise will be rejected or resolved depending on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
81
+ */
82
+ // Based on PromiseLike.then, but returns a Bluebird instance.
83
+ then<U>(onFulfill?: (value: R) => Resolvable<U>, onReject?: (error: any) => Resolvable<U>): Bluebird<U>; // For simpler signature help.
84
+ then<TResult1 = R, TResult2 = never>(
85
+ onfulfilled?: ((value: R) => Resolvable<TResult1>) | null,
86
+ onrejected?: ((reason: any) => Resolvable<TResult2>) | null,
87
+ ): Bluebird<TResult1 | TResult2>;
88
+
89
+ /**
90
+ * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise.
91
+ *
92
+ * Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
93
+ *
94
+ * Alias `.caught();` for compatibility with earlier ECMAScript version.
95
+ */
96
+ catch<U = R>(onReject: ((error: any) => Resolvable<U>) | undefined | null): Bluebird<U | R>;
97
+
98
+ /**
99
+ * This extends `.catch` to work more like catch-clauses in languages like Java or C#.
100
+ *
101
+ * Instead of manually checking `instanceof` or `.name === "SomeError"`,
102
+ * you may specify a number of error constructors which are eligible for this catch handler.
103
+ * The catch handler that is first met that has eligible constructors specified, is the one that will be called.
104
+ *
105
+ * This method also supports predicate-based filters.
106
+ * If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument.
107
+ * The return result of the predicate will be used determine whether the error handler should be called.
108
+ *
109
+ * Alias `.caught();` for compatibility with earlier ECMAScript version.
110
+ */
111
+ catch<U, E1, E2, E3, E4, E5>(
112
+ filter1: Constructor<E1>,
113
+ filter2: Constructor<E2>,
114
+ filter3: Constructor<E3>,
115
+ filter4: Constructor<E4>,
116
+ filter5: Constructor<E5>,
117
+ onReject: (error: E1 | E2 | E3 | E4 | E5) => Resolvable<U>,
118
+ ): Bluebird<U | R>;
119
+
120
+ catch<U, E1, E2, E3, E4, E5>(
121
+ filter1: Constructor<E1> | CatchFilter<E1>,
122
+ filter2: Constructor<E2> | CatchFilter<E2>,
123
+ filter3: Constructor<E3> | CatchFilter<E3>,
124
+ filter4: Constructor<E4> | CatchFilter<E4>,
125
+ filter5: Constructor<E5> | CatchFilter<E5>,
126
+ onReject: (error: E1 | E2 | E3 | E4 | E5) => Resolvable<U>,
127
+ ): Bluebird<U | R>;
128
+
129
+ catch<U, E1, E2, E3, E4>(
130
+ filter1: Constructor<E1>,
131
+ filter2: Constructor<E2>,
132
+ filter3: Constructor<E3>,
133
+ filter4: Constructor<E4>,
134
+ onReject: (error: E1 | E2 | E3 | E4) => Resolvable<U>,
135
+ ): Bluebird<U | R>;
136
+
137
+ catch<U, E1, E2, E3, E4>(
138
+ filter1: Constructor<E1> | CatchFilter<E1>,
139
+ filter2: Constructor<E2> | CatchFilter<E2>,
140
+ filter3: Constructor<E3> | CatchFilter<E3>,
141
+ filter4: Constructor<E4> | CatchFilter<E4>,
142
+ onReject: (error: E1 | E2 | E3 | E4) => Resolvable<U>,
143
+ ): Bluebird<U | R>;
144
+
145
+ catch<U, E1, E2, E3>(
146
+ filter1: Constructor<E1>,
147
+ filter2: Constructor<E2>,
148
+ filter3: Constructor<E3>,
149
+ onReject: (error: E1 | E2 | E3) => Resolvable<U>,
150
+ ): Bluebird<U | R>;
151
+
152
+ catch<U, E1, E2, E3>(
153
+ filter1: Constructor<E1> | CatchFilter<E1>,
154
+ filter2: Constructor<E2> | CatchFilter<E2>,
155
+ filter3: Constructor<E3> | CatchFilter<E3>,
156
+ onReject: (error: E1 | E2 | E3) => Resolvable<U>,
157
+ ): Bluebird<U | R>;
158
+
159
+ catch<U, E1, E2>(
160
+ filter1: Constructor<E1>,
161
+ filter2: Constructor<E2>,
162
+ onReject: (error: E1 | E2) => Resolvable<U>,
163
+ ): Bluebird<U | R>;
164
+
165
+ catch<U, E1, E2>(
166
+ filter1: Constructor<E1> | CatchFilter<E1>,
167
+ filter2: Constructor<E2> | CatchFilter<E2>,
168
+ onReject: (error: E1 | E2) => Resolvable<U>,
169
+ ): Bluebird<U | R>;
170
+
171
+ catch<U, E1>(
172
+ filter1: Constructor<E1>,
173
+ onReject: (error: E1) => Resolvable<U>,
174
+ ): Bluebird<U | R>;
175
+
176
+ catch<U, E1>(
177
+ // tslint:disable-next-line:unified-signatures
178
+ filter1: Constructor<E1> | CatchFilter<E1>,
179
+ onReject: (error: E1) => Resolvable<U>,
180
+ ): Bluebird<U | R>;
181
+
182
+ /**
183
+ * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise.
184
+ *
185
+ * Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
186
+ *
187
+ * Alias `.caught();` for compatibility with earlier ECMAScript version.
188
+ */
189
+ caught: Bluebird<R>["catch"];
190
+
191
+ /**
192
+ * Like `.catch` but instead of catching all types of exceptions,
193
+ * it only catches those that don't originate from thrown errors but rather from explicit rejections.
194
+ */
195
+ error<U>(onReject: (reason: any) => Resolvable<U>): Bluebird<U>;
196
+
197
+ /**
198
+ * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise.
199
+ *
200
+ * There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
201
+ *
202
+ * Alias `.lastly();` for compatibility with earlier ECMAScript version.
203
+ */
204
+ finally(handler: () => Resolvable<any>): Bluebird<R>;
205
+
206
+ lastly: Bluebird<R>["finally"];
207
+
208
+ /**
209
+ * Create a promise that follows this promise, but is bound to the given `thisArg` value.
210
+ * A bound promise will call its handlers with the bound value set to `this`.
211
+ *
212
+ * Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
213
+ */
214
+ bind(thisArg: any): Bluebird<R>;
215
+
216
+ /**
217
+ * Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
218
+ */
219
+ done<U>(onFulfilled?: (value: R) => Resolvable<U>, onRejected?: (error: any) => Resolvable<U>): void;
220
+
221
+ /**
222
+ * Like `.finally()`, but not called for rejections.
223
+ */
224
+ tap(onFulFill: (value: R) => Resolvable<any>): Bluebird<R>;
225
+
226
+ /**
227
+ * Like `.catch()` but rethrows the error
228
+ */
229
+ tapCatch(onReject: (error?: any) => Resolvable<any>): Bluebird<R>;
230
+
231
+ tapCatch<E1, E2, E3, E4, E5>(
232
+ filter1: Constructor<E1>,
233
+ filter2: Constructor<E2>,
234
+ filter3: Constructor<E3>,
235
+ filter4: Constructor<E4>,
236
+ filter5: Constructor<E5>,
237
+ onReject: (error: E1 | E2 | E3 | E4 | E5) => Resolvable<any>,
238
+ ): Bluebird<R>;
239
+ tapCatch<E1, E2, E3, E4, E5>(
240
+ filter1: Constructor<E1> | CatchFilter<E1>,
241
+ filter2: Constructor<E2> | CatchFilter<E2>,
242
+ filter3: Constructor<E3> | CatchFilter<E3>,
243
+ filter4: Constructor<E4> | CatchFilter<E4>,
244
+ filter5: Constructor<E5> | CatchFilter<E5>,
245
+ onReject: (error: E1 | E2 | E3 | E4 | E5) => Resolvable<any>,
246
+ ): Bluebird<R>;
247
+ tapCatch<E1, E2, E3, E4>(
248
+ filter1: Constructor<E1>,
249
+ filter2: Constructor<E2>,
250
+ filter3: Constructor<E3>,
251
+ filter4: Constructor<E4>,
252
+ onReject: (error: E1 | E2 | E3 | E4) => Resolvable<any>,
253
+ ): Bluebird<R>;
254
+ tapCatch<E1, E2, E3, E4>(
255
+ filter1: Constructor<E1> | CatchFilter<E1>,
256
+ filter2: Constructor<E2> | CatchFilter<E2>,
257
+ filter3: Constructor<E3> | CatchFilter<E3>,
258
+ filter4: Constructor<E4> | CatchFilter<E4>,
259
+ onReject: (error: E1 | E2 | E3 | E4) => Resolvable<any>,
260
+ ): Bluebird<R>;
261
+ tapCatch<E1, E2, E3>(
262
+ filter1: Constructor<E1>,
263
+ filter2: Constructor<E2>,
264
+ filter3: Constructor<E3>,
265
+ onReject: (error: E1 | E2 | E3) => Resolvable<any>,
266
+ ): Bluebird<R>;
267
+ tapCatch<E1, E2, E3>(
268
+ filter1: Constructor<E1> | CatchFilter<E1>,
269
+ filter2: Constructor<E2> | CatchFilter<E2>,
270
+ filter3: Constructor<E3> | CatchFilter<E3>,
271
+ onReject: (error: E1 | E2 | E3) => Resolvable<any>,
272
+ ): Bluebird<R>;
273
+ tapCatch<E1, E2>(
274
+ filter1: Constructor<E1>,
275
+ filter2: Constructor<E2>,
276
+ onReject: (error: E1 | E2) => Resolvable<any>,
277
+ ): Bluebird<R>;
278
+ tapCatch<E1, E2>(
279
+ filter1: Constructor<E1> | CatchFilter<E1>,
280
+ filter2: Constructor<E2> | CatchFilter<E2>,
281
+ onReject: (error: E1 | E2) => Resolvable<any>,
282
+ ): Bluebird<R>;
283
+ tapCatch<E1>(
284
+ filter1: Constructor<E1>,
285
+ onReject: (error: E1) => Resolvable<any>,
286
+ ): Bluebird<R>;
287
+ tapCatch<E1>(
288
+ // tslint:disable-next-line:unified-signatures
289
+ filter1: Constructor<E1> | CatchFilter<E1>,
290
+ onReject: (error: E1) => Resolvable<any>,
291
+ ): Bluebird<R>;
292
+
293
+ /**
294
+ * Same as calling `Promise.delay(ms, this)`.
295
+ */
296
+ delay(ms: number): Bluebird<R>;
297
+
298
+ /**
299
+ * Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason.
300
+ * However, if this promise is not fulfilled or rejected within ms milliseconds, the returned promise
301
+ * is rejected with a TimeoutError or the error as the reason.
302
+ *
303
+ * You may specify a custom error message with the `message` parameter.
304
+ */
305
+ timeout(ms: number, message?: string | Error): Bluebird<R>;
306
+
307
+ /**
308
+ * Register a node-style callback on this promise.
309
+ *
310
+ * When this promise is is either fulfilled or rejected,
311
+ * the node callback will be called back with the node.js convention
312
+ * where error reason is the first argument and success value is the second argument.
313
+ *
314
+ * The error argument will be `null` in case of success.
315
+ * If the `callback` argument is not a function, this method does not do anything.
316
+ */
317
+ nodeify(callback: (err: any, value?: R) => void, options?: Bluebird.SpreadOption): this;
318
+ nodeify(...sink: any[]): this;
319
+ asCallback(callback: (err: any, value?: R) => void, options?: Bluebird.SpreadOption): this;
320
+ asCallback(...sink: any[]): this;
321
+
322
+ /**
323
+ * See if this `promise` has been fulfilled.
324
+ */
325
+ isFulfilled(): boolean;
326
+
327
+ /**
328
+ * See if this `promise` has been rejected.
329
+ */
330
+ isRejected(): boolean;
331
+
332
+ /**
333
+ * See if this `promise` is still defer.
334
+ */
335
+ isPending(): boolean;
336
+
337
+ /**
338
+ * See if this `promise` has been cancelled.
339
+ */
340
+ isCancelled(): boolean;
341
+
342
+ /**
343
+ * See if this `promise` is resolved -> either fulfilled or rejected.
344
+ */
345
+ isResolved(): boolean;
346
+
347
+ /**
348
+ * Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet.
349
+ *
350
+ * throws `TypeError`
351
+ */
352
+ value(): R;
353
+
354
+ /**
355
+ * Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet.
356
+ *
357
+ * throws `TypeError`
358
+ */
359
+ reason(): any;
360
+
361
+ /**
362
+ * Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of
363
+ * the promise as snapshotted at the time of calling `.reflect()`.
364
+ */
365
+ reflect(): Bluebird<Bluebird.Inspection<R>>;
366
+
367
+ /**
368
+ * This is a convenience method for doing:
369
+ *
370
+ * <code>
371
+ * promise.then(function(obj){
372
+ * return obj[propertyName].call(obj, arg...);
373
+ * });
374
+ * </code>
375
+ */
376
+ call<U extends keyof Q, Q>(
377
+ this: Bluebird<Q>,
378
+ propertyName: U,
379
+ ...args: any[]
380
+ ): Bluebird<Q[U] extends (...args: any[]) => any ? ReturnType<Q[U]> : never>;
381
+
382
+ /**
383
+ * This is a convenience method for doing:
384
+ *
385
+ * <code>
386
+ * promise.then(function(obj){
387
+ * return obj[propertyName];
388
+ * });
389
+ * </code>
390
+ */
391
+ get<U extends keyof R>(key: U): Bluebird<R[U]>;
392
+
393
+ /**
394
+ * Convenience method for:
395
+ *
396
+ * <code>
397
+ * .then(function() {
398
+ * return value;
399
+ * });
400
+ * </code>
401
+ *
402
+ * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
403
+ *
404
+ * Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
405
+ */
406
+ return(): Bluebird<void>;
407
+ return<U>(value: U): Bluebird<U>;
408
+ thenReturn(): Bluebird<void>;
409
+ thenReturn<U>(value: U): Bluebird<U>;
410
+
411
+ /**
412
+ * Convenience method for:
413
+ *
414
+ * <code>
415
+ * .then(function() {
416
+ * throw reason;
417
+ * });
418
+ * </code>
419
+ * Same limitations apply as with `.return()`.
420
+ *
421
+ * Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
422
+ */
423
+ throw(reason: Error): Bluebird<never>;
424
+ thenThrow(reason: Error): Bluebird<never>;
425
+
426
+ /**
427
+ * Convenience method for:
428
+ *
429
+ * <code>
430
+ * .catch(function() {
431
+ * return value;
432
+ * });
433
+ * </code>
434
+ *
435
+ * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.catchReturn()`
436
+ */
437
+ catchReturn<U>(value: U): Bluebird<R | U>;
438
+
439
+ // No need to be specific about Error types in these overrides, since there's no handler function
440
+ catchReturn<U>(
441
+ filter1: Constructor<Error>,
442
+ filter2: Constructor<Error>,
443
+ filter3: Constructor<Error>,
444
+ filter4: Constructor<Error>,
445
+ filter5: Constructor<Error>,
446
+ value: U,
447
+ ): Bluebird<R | U>;
448
+ catchReturn<U>(
449
+ filter1: Constructor<Error> | CatchFilter<Error>,
450
+ filter2: Constructor<Error> | CatchFilter<Error>,
451
+ filter3: Constructor<Error> | CatchFilter<Error>,
452
+ filter4: Constructor<Error> | CatchFilter<Error>,
453
+ filter5: Constructor<Error> | CatchFilter<Error>,
454
+ value: U,
455
+ ): Bluebird<R | U>;
456
+ catchReturn<U>(
457
+ filter1: Constructor<Error>,
458
+ filter2: Constructor<Error>,
459
+ filter3: Constructor<Error>,
460
+ filter4: Constructor<Error>,
461
+ value: U,
462
+ ): Bluebird<R | U>;
463
+ catchReturn<U>(
464
+ filter1: Constructor<Error> | CatchFilter<Error>,
465
+ filter2: Constructor<Error> | CatchFilter<Error>,
466
+ filter3: Constructor<Error> | CatchFilter<Error>,
467
+ filter4: Constructor<Error> | CatchFilter<Error>,
468
+ value: U,
469
+ ): Bluebird<R | U>;
470
+ catchReturn<U>(
471
+ filter1: Constructor<Error>,
472
+ filter2: Constructor<Error>,
473
+ filter3: Constructor<Error>,
474
+ value: U,
475
+ ): Bluebird<R | U>;
476
+ catchReturn<U>(
477
+ filter1: Constructor<Error> | CatchFilter<Error>,
478
+ filter2: Constructor<Error> | CatchFilter<Error>,
479
+ filter3: Constructor<Error> | CatchFilter<Error>,
480
+ value: U,
481
+ ): Bluebird<R | U>;
482
+ catchReturn<U>(
483
+ filter1: Constructor<Error>,
484
+ filter2: Constructor<Error>,
485
+ value: U,
486
+ ): Bluebird<R | U>;
487
+ catchReturn<U>(
488
+ filter1: Constructor<Error> | CatchFilter<Error>,
489
+ filter2: Constructor<Error> | CatchFilter<Error>,
490
+ value: U,
491
+ ): Bluebird<R | U>;
492
+ catchReturn<U>(
493
+ filter1: Constructor<Error>,
494
+ value: U,
495
+ ): Bluebird<R | U>;
496
+ catchReturn<U>(
497
+ // tslint:disable-next-line:unified-signatures
498
+ filter1: Constructor<Error> | CatchFilter<Error>,
499
+ value: U,
500
+ ): Bluebird<R | U>;
501
+
502
+ /**
503
+ * Convenience method for:
504
+ *
505
+ * <code>
506
+ * .catch(function() {
507
+ * throw reason;
508
+ * });
509
+ * </code>
510
+ * Same limitations apply as with `.catchReturn()`.
511
+ */
512
+ catchThrow(reason: Error): Bluebird<R>;
513
+
514
+ // No need to be specific about Error types in these overrides, since there's no handler function
515
+ catchThrow(
516
+ filter1: Constructor<Error>,
517
+ filter2: Constructor<Error>,
518
+ filter3: Constructor<Error>,
519
+ filter4: Constructor<Error>,
520
+ filter5: Constructor<Error>,
521
+ reason: Error,
522
+ ): Bluebird<R>;
523
+ catchThrow(
524
+ filter1: Constructor<Error> | CatchFilter<Error>,
525
+ filter2: Constructor<Error> | CatchFilter<Error>,
526
+ filter3: Constructor<Error> | CatchFilter<Error>,
527
+ filter4: Constructor<Error> | CatchFilter<Error>,
528
+ filter5: Constructor<Error> | CatchFilter<Error>,
529
+ reason: Error,
530
+ ): Bluebird<R>;
531
+ catchThrow(
532
+ filter1: Constructor<Error>,
533
+ filter2: Constructor<Error>,
534
+ filter3: Constructor<Error>,
535
+ filter4: Constructor<Error>,
536
+ reason: Error,
537
+ ): Bluebird<R>;
538
+ catchThrow(
539
+ filter1: Constructor<Error> | CatchFilter<Error>,
540
+ filter2: Constructor<Error> | CatchFilter<Error>,
541
+ filter3: Constructor<Error> | CatchFilter<Error>,
542
+ filter4: Constructor<Error> | CatchFilter<Error>,
543
+ reason: Error,
544
+ ): Bluebird<R>;
545
+ catchThrow(
546
+ filter1: Constructor<Error>,
547
+ filter2: Constructor<Error>,
548
+ filter3: Constructor<Error>,
549
+ reason: Error,
550
+ ): Bluebird<R>;
551
+ catchThrow(
552
+ filter1: Constructor<Error> | CatchFilter<Error>,
553
+ filter2: Constructor<Error> | CatchFilter<Error>,
554
+ filter3: Constructor<Error> | CatchFilter<Error>,
555
+ reason: Error,
556
+ ): Bluebird<R>;
557
+ catchThrow(
558
+ filter1: Constructor<Error>,
559
+ filter2: Constructor<Error>,
560
+ reason: Error,
561
+ ): Bluebird<R>;
562
+ catchThrow(
563
+ filter1: Constructor<Error> | CatchFilter<Error>,
564
+ filter2: Constructor<Error> | CatchFilter<Error>,
565
+ reason: Error,
566
+ ): Bluebird<R>;
567
+ catchThrow(
568
+ filter1: Constructor<Error>,
569
+ reason: Error,
570
+ ): Bluebird<R>;
571
+ catchThrow(
572
+ // tslint:disable-next-line:unified-signatures
573
+ filter1: Constructor<Error> | CatchFilter<Error>,
574
+ reason: Error,
575
+ ): Bluebird<R>;
576
+
577
+ /**
578
+ * Convert to String.
579
+ */
580
+ toString(): string;
581
+
582
+ /**
583
+ * This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
584
+ */
585
+ toJSON(): object;
586
+
587
+ /**
588
+ * Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
589
+ */
590
+ spread<U, Q>(this: Bluebird<R & Iterable<Q>>, fulfilledHandler: (...values: Q[]) => Resolvable<U>): Bluebird<U>;
591
+
592
+ /**
593
+ * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
594
+ */
595
+ all<T1, T2, T3, T4, T5>(
596
+ this: Bluebird<[Resolvable<T1>, Resolvable<T2>, Resolvable<T3>, Resolvable<T4>, Resolvable<T5>]>,
597
+ ): Bluebird<[T1, T2, T3, T4, T5]>;
598
+ all<T1, T2, T3, T4>(
599
+ this: Bluebird<[Resolvable<T1>, Resolvable<T2>, Resolvable<T3>, Resolvable<T4>]>,
600
+ ): Bluebird<[T1, T2, T3, T4]>;
601
+ all<T1, T2, T3>(this: Bluebird<[Resolvable<T1>, Resolvable<T2>, Resolvable<T3>]>): Bluebird<[T1, T2, T3]>;
602
+ all<T1, T2>(this: Bluebird<[Resolvable<T1>, Resolvable<T2>]>): Bluebird<[T1, T2]>;
603
+ all<T1>(this: Bluebird<[Resolvable<T1>]>): Bluebird<[T1]>;
604
+ all<R>(this: Bluebird<Iterable<Resolvable<R>>>): Bluebird<R[]>;
605
+
606
+ /**
607
+ * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
608
+ */
609
+ all(): Bluebird<never>;
610
+
611
+ /**
612
+ * Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
613
+ */
614
+ props<K, V>(this: PromiseLike<Map<K, Resolvable<V>>>): Bluebird<Map<K, V>>;
615
+ props<T>(this: PromiseLike<Bluebird.ResolvableProps<T>>): Bluebird<T>;
616
+
617
+ /**
618
+ * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
619
+ */
620
+ any<Q>(this: Bluebird<R & Iterable<Q>>): Bluebird<Q>;
621
+
622
+ /**
623
+ * Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
624
+ */
625
+ any(): Bluebird<never>;
626
+
627
+ /**
628
+ * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
629
+ * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
630
+ */
631
+ some<Q>(this: Bluebird<R & Iterable<Q>>, count: number): Bluebird<R>;
632
+
633
+ /**
634
+ * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
635
+ * Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
636
+ */
637
+ some(count: number): Bluebird<never>;
638
+
639
+ /**
640
+ * Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
641
+ */
642
+ race<Q>(this: Bluebird<R & Iterable<Q>>): Bluebird<Q>;
643
+
644
+ /**
645
+ * Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
646
+ */
647
+ race(): Bluebird<never>;
648
+
649
+ /**
650
+ * Same as calling `Bluebird.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
651
+ */
652
+ map<U, Q>(
653
+ this: Bluebird<R & Iterable<Q>>,
654
+ mapper: IterateFunction<Q, U>,
655
+ options?: Bluebird.ConcurrencyOption,
656
+ ): Bluebird<U[]>;
657
+
658
+ /**
659
+ * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
660
+ */
661
+ reduce<U, Q>(
662
+ this: Bluebird<R & Iterable<Q>>,
663
+ reducer: (memo: U, item: Q, index: number, arrayLength: number) => Resolvable<U>,
664
+ initialValue?: Resolvable<U>,
665
+ ): Bluebird<U>;
666
+
667
+ /**
668
+ * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
669
+ */
670
+ filter<Q>(
671
+ this: Bluebird<R & Iterable<Q>>,
672
+ filterer: IterateFunction<Q, boolean>,
673
+ options?: Bluebird.ConcurrencyOption,
674
+ ): Bluebird<R>;
675
+
676
+ /**
677
+ * Same as calling ``Bluebird.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
678
+ */
679
+ each<Q>(this: Bluebird<R & Iterable<Q>>, iterator: IterateFunction<Q, any>): Bluebird<R>;
680
+
681
+ /**
682
+ * Same as calling ``Bluebird.mapSeries(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
683
+ */
684
+ mapSeries<U, Q>(this: Bluebird<R & Iterable<Q>>, iterator: IterateFunction<Q, U>): Bluebird<U[]>;
685
+
686
+ /**
687
+ * Cancel this `promise`. Will not do anything if this promise is already settled or if the cancellation feature has not been enabled
688
+ */
689
+ cancel(): void;
690
+
691
+ /**
692
+ * Basically sugar for doing: somePromise.catch(function(){});
693
+ *
694
+ * Which is needed in case error handlers are attached asynchronously to the promise later, which would otherwise result in premature unhandled rejection reporting.
695
+ */
696
+ suppressUnhandledRejections(): void;
697
+
698
+ /**
699
+ * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
700
+ *
701
+ * Note about second argument: if it's specifically a true array, its values become respective arguments for the function call.
702
+ * Otherwise it is passed as is as the first argument for the function call.
703
+ *
704
+ * Alias for `attempt();` for compatibility with earlier ECMAScript version.
705
+ */
706
+ static try<R>(fn: () => Resolvable<R>): Bluebird<R>;
707
+ static attempt<R>(fn: () => Resolvable<R>): Bluebird<R>;
708
+
709
+ /**
710
+ * Returns a new function that wraps the given function `fn`.
711
+ * The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
712
+ * This method is convenient when a function can sometimes return synchronously or throw synchronously.
713
+ */
714
+ static method<R>(fn: () => Resolvable<R>): () => Bluebird<R>;
715
+ static method<R, A1>(fn: (arg1: A1) => Resolvable<R>): (arg1: A1) => Bluebird<R>;
716
+ static method<R, A1, A2>(fn: (arg1: A1, arg2: A2) => Resolvable<R>): (arg1: A1, arg2: A2) => Bluebird<R>;
717
+ static method<R, A1, A2, A3>(
718
+ fn: (arg1: A1, arg2: A2, arg3: A3) => Resolvable<R>,
719
+ ): (arg1: A1, arg2: A2, arg3: A3) => Bluebird<R>;
720
+ static method<R, A1, A2, A3, A4>(
721
+ fn: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Resolvable<R>,
722
+ ): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<R>;
723
+ static method<R, A1, A2, A3, A4, A5>(
724
+ fn: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Resolvable<R>,
725
+ ): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<R>;
726
+ static method<R>(fn: (...args: any[]) => Resolvable<R>): (...args: any[]) => Bluebird<R>;
727
+
728
+ /**
729
+ * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
730
+ */
731
+ static resolve(): Bluebird<void>;
732
+ static resolve<R>(value: Resolvable<R>): Bluebird<R>;
733
+
734
+ /**
735
+ * Create a promise that is rejected with the given `reason`.
736
+ */
737
+ static reject(reason: any): Bluebird<never>;
738
+
739
+ /**
740
+ * @deprecated
741
+ * Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution).
742
+ * @see http://bluebirdjs.com/docs/deprecated-apis.html#promise-resolution
743
+ */
744
+ static defer<R>(): Bluebird.Resolver<R>;
745
+
746
+ /**
747
+ * Cast the given `value` to a trusted promise.
748
+ *
749
+ * If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value.
750
+ * If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
751
+ */
752
+ static cast<R>(value: Resolvable<R>): Bluebird<R>;
753
+
754
+ /**
755
+ * Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`.
756
+ */
757
+ static bind(thisArg: any): Bluebird<void>;
758
+
759
+ /**
760
+ * See if `value` is a trusted Promise.
761
+ */
762
+ static is(value: any): boolean;
763
+
764
+ /**
765
+ * Call this right after the library is loaded to enabled long stack traces.
766
+ *
767
+ * Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have already been created.
768
+ * Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
769
+ */
770
+ static longStackTraces(): void;
771
+
772
+ /**
773
+ * Returns a promise that will be resolved with value (or undefined) after given ms milliseconds.
774
+ * If value is a promise, the delay will start counting down when it is fulfilled and the returned
775
+ * promise will be fulfilled with the fulfillment value of the value promise.
776
+ */
777
+ static delay<R>(ms: number, value: Resolvable<R>): Bluebird<R>;
778
+ static delay(ms: number): Bluebird<void>;
779
+
780
+ /**
781
+ * Returns a function that will wrap the given `nodeFunction`.
782
+ *
783
+ * Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function.
784
+ * The node function should conform to node.js convention of accepting a callback as last argument and
785
+ * calling that callback with error as the first argument and success value on the second argument.
786
+ *
787
+ * If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
788
+ *
789
+ * If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
790
+ */
791
+ static promisify<T>(
792
+ func: (callback: (err: any, result?: T) => void) => void,
793
+ options?: Bluebird.PromisifyOptions,
794
+ ): () => Bluebird<T>;
795
+ static promisify<T, A1>(
796
+ func: (arg1: A1, callback: (err: any, result?: T) => void) => void,
797
+ options?: Bluebird.PromisifyOptions,
798
+ ): (arg1: A1) => Bluebird<T>;
799
+ static promisify<T, A1, A2>(
800
+ func: (arg1: A1, arg2: A2, callback: (err: any, result?: T) => void) => void,
801
+ options?: Bluebird.PromisifyOptions,
802
+ ): (arg1: A1, arg2: A2) => Bluebird<T>;
803
+ static promisify<T, A1, A2, A3>(
804
+ func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result?: T) => void) => void,
805
+ options?: Bluebird.PromisifyOptions,
806
+ ): (arg1: A1, arg2: A2, arg3: A3) => Bluebird<T>;
807
+ static promisify<T, A1, A2, A3, A4>(
808
+ func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result?: T) => void) => void,
809
+ options?: Bluebird.PromisifyOptions,
810
+ ): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<T>;
811
+ static promisify<T, A1, A2, A3, A4, A5>(
812
+ func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result?: T) => void) => void,
813
+ options?: Bluebird.PromisifyOptions,
814
+ ): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<T>;
815
+ static promisify(
816
+ nodeFunction: (...args: any[]) => void,
817
+ options?: Bluebird.PromisifyOptions,
818
+ ): (...args: any[]) => Bluebird<any>;
819
+
820
+ /**
821
+ * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain.
822
+ *
823
+ * The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
824
+ *
825
+ * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example,
826
+ * if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
827
+ */
828
+ // TODO how to model promisifyAll?
829
+ static promisifyAll<T extends object>(target: T, options?: Bluebird.PromisifyAllOptions<T>): PromisifyAll<T>;
830
+
831
+ /**
832
+ * Returns a promise that is resolved by a node style callback function.
833
+ */
834
+ static fromNode<T>(
835
+ resolver: (callback: (err: any, result?: T) => void) => void,
836
+ options?: Bluebird.FromNodeOptions,
837
+ ): Bluebird<T>;
838
+ static fromCallback<T>(
839
+ resolver: (callback: (err: any, result?: T) => void) => void,
840
+ options?: Bluebird.FromNodeOptions,
841
+ ): Bluebird<T>;
842
+
843
+ /**
844
+ * Returns a function that can use `yield` to run asynchronous code synchronously.
845
+ *
846
+ * This feature requires the support of generators which are drafted in the next version of the language.
847
+ * Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
848
+ */
849
+ // TODO: After https://github.com/Microsoft/TypeScript/issues/2983 is implemented, we can use
850
+ // the return type propagation of generators to automatically infer the return type T.
851
+ static coroutine<T>(
852
+ generatorFunction: () => IterableIterator<any>,
853
+ options?: Bluebird.CoroutineOptions,
854
+ ): () => Bluebird<T>;
855
+ static coroutine<T, A1>(
856
+ generatorFunction: (a1: A1) => IterableIterator<any>,
857
+ options?: Bluebird.CoroutineOptions,
858
+ ): (a1: A1) => Bluebird<T>;
859
+ static coroutine<T, A1, A2>(
860
+ generatorFunction: (a1: A1, a2: A2) => IterableIterator<any>,
861
+ options?: Bluebird.CoroutineOptions,
862
+ ): (a1: A1, a2: A2) => Bluebird<T>;
863
+ static coroutine<T, A1, A2, A3>(
864
+ generatorFunction: (a1: A1, a2: A2, a3: A3) => IterableIterator<any>,
865
+ options?: Bluebird.CoroutineOptions,
866
+ ): (a1: A1, a2: A2, a3: A3) => Bluebird<T>;
867
+ static coroutine<T, A1, A2, A3, A4>(
868
+ generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4) => IterableIterator<any>,
869
+ options?: Bluebird.CoroutineOptions,
870
+ ): (a1: A1, a2: A2, a3: A3, a4: A4) => Bluebird<T>;
871
+ static coroutine<T, A1, A2, A3, A4, A5>(
872
+ generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => IterableIterator<any>,
873
+ options?: Bluebird.CoroutineOptions,
874
+ ): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Bluebird<T>;
875
+ static coroutine<T, A1, A2, A3, A4, A5, A6>(
876
+ generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => IterableIterator<any>,
877
+ options?: Bluebird.CoroutineOptions,
878
+ ): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Bluebird<T>;
879
+ static coroutine<T, A1, A2, A3, A4, A5, A6, A7>(
880
+ generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => IterableIterator<any>,
881
+ options?: Bluebird.CoroutineOptions,
882
+ ): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Bluebird<T>;
883
+ static coroutine<T, A1, A2, A3, A4, A5, A6, A7, A8>(
884
+ generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator<any>,
885
+ options?: Bluebird.CoroutineOptions,
886
+ ): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Bluebird<T>;
887
+
888
+ /**
889
+ * Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
890
+ *
891
+ * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
892
+ */
893
+ static onPossiblyUnhandledRejection(handler: (reason: any) => any): void;
894
+
895
+ /**
896
+ * Add handler as the handler to call when there is a possibly unhandled rejection.
897
+ * The default handler logs the error stack to stderr or console.error in browsers.
898
+ *
899
+ * Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
900
+ *
901
+ * Note: this hook is specific to the bluebird instance its called on, application developers should use global rejection events.
902
+ */
903
+ static onPossiblyUnhandledRejection(handler?: (error: Error, promise: Bluebird<any>) => void): void;
904
+
905
+ /**
906
+ * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled.
907
+ * The promise's fulfillment value is an array with fulfillment values at respective positions to the original array.
908
+ * If any promise in the array rejects, the returned promise is rejected with the rejection reason.
909
+ */
910
+ // TODO enable more overloads
911
+ // array with promises of different types
912
+ static all<T1, T2, T3, T4, T5>(
913
+ values: [Resolvable<T1>, Resolvable<T2>, Resolvable<T3>, Resolvable<T4>, Resolvable<T5>],
914
+ ): Bluebird<[T1, T2, T3, T4, T5]>;
915
+ static all<T1, T2, T3, T4>(
916
+ values: [Resolvable<T1>, Resolvable<T2>, Resolvable<T3>, Resolvable<T4>],
917
+ ): Bluebird<[T1, T2, T3, T4]>;
918
+ static all<T1, T2, T3>(values: [Resolvable<T1>, Resolvable<T2>, Resolvable<T3>]): Bluebird<[T1, T2, T3]>;
919
+ static all<T1, T2>(values: [Resolvable<T1>, Resolvable<T2>]): Bluebird<[T1, T2]>;
920
+ static all<T1>(values: [Resolvable<T1>]): Bluebird<[T1]>;
921
+ // array with values
922
+ static all<R>(values: Resolvable<Iterable<Resolvable<R>>>): Bluebird<R[]>;
923
+
924
+ static allSettled<T1, T2, T3, T4, T5>(
925
+ values: [Resolvable<T1>, Resolvable<T2>, Resolvable<T3>, Resolvable<T4>, Resolvable<T5>],
926
+ ): Bluebird<
927
+ [
928
+ Bluebird.Inspection<T1>,
929
+ Bluebird.Inspection<T2>,
930
+ Bluebird.Inspection<T3>,
931
+ Bluebird.Inspection<T4>,
932
+ Bluebird.Inspection<T5>,
933
+ ]
934
+ >;
935
+ static allSettled<T1, T2, T3, T4>(
936
+ values: [Resolvable<T1>, Resolvable<T2>, Resolvable<T3>, Resolvable<T4>],
937
+ ): Bluebird<[Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>, Bluebird.Inspection<T4>]>;
938
+ static allSettled<T1, T2, T3>(
939
+ values: [Resolvable<T1>, Resolvable<T2>, Resolvable<T3>],
940
+ ): Bluebird<[Bluebird.Inspection<T1>, Bluebird.Inspection<T2>, Bluebird.Inspection<T3>]>;
941
+ static allSettled<T1, T2>(
942
+ values: [Resolvable<T1>, Resolvable<T2>],
943
+ ): Bluebird<[Bluebird.Inspection<T1>, Bluebird.Inspection<T2>]>;
944
+ static allSettled<T1>(values: [Resolvable<T1>]): Bluebird<[Bluebird.Inspection<T1>]>;
945
+ static allSettled<R>(values: Resolvable<Iterable<Resolvable<R>>>): Bluebird<Array<Bluebird.Inspection<R>>>;
946
+
947
+ /**
948
+ * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled.
949
+ *
950
+ * The promise's fulfillment value is an object with fulfillment values at respective keys to the original object.
951
+ * If any promise in the object rejects, the returned promise is rejected with the rejection reason.
952
+ *
953
+ * If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties.
954
+ * All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
955
+ *
956
+ * *The original object is not modified.*
957
+ */
958
+ // map
959
+ static props<K, V>(map: Resolvable<Map<K, Resolvable<V>>>): Bluebird<Map<K, V>>;
960
+ // trusted promise for object
961
+ static props<T>(object: PromiseLike<Bluebird.ResolvableProps<T>>): Bluebird<T>;
962
+ // object
963
+ static props<T>(object: Bluebird.ResolvableProps<T>): Bluebird<T>; // tslint:disable-line:unified-signatures
964
+
965
+ /**
966
+ * Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
967
+ */
968
+ static any<R>(values: Resolvable<Iterable<Resolvable<R>>>): Bluebird<R>;
969
+
970
+ /**
971
+ * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is
972
+ * fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
973
+ *
974
+ * **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
975
+ */
976
+ static race<R>(values: Resolvable<Iterable<Resolvable<R>>>): Bluebird<R>;
977
+
978
+ /**
979
+ * Initiate a competitive race between multiple promises or values (values will become immediately fulfilled promises).
980
+ * When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of
981
+ * the winners in order of resolution.
982
+ *
983
+ * If too many promises are rejected so that the promise can never become fulfilled,
984
+ * it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
985
+ *
986
+ * *The original array is not modified.*
987
+ */
988
+ static some<R>(values: Resolvable<Iterable<Resolvable<R>>>, count: number): Bluebird<R[]>;
989
+
990
+ /**
991
+ * Promise.join(
992
+ * Promise<any>|any values...,
993
+ * function handler
994
+ * ) -> Promise
995
+ * For coordinating multiple concurrent discrete promises.
996
+ *
997
+ * Note: In 1.x and 0.x Promise.join used to be a Promise.all that took the values in as arguments instead in an array.
998
+ * This behavior has been deprecated but is still supported partially - when the last argument is an immediate function value the new semantics will apply
999
+ */
1000
+ static join<R, A1>(
1001
+ arg1: Resolvable<A1>,
1002
+ handler: (arg1: A1) => Resolvable<R>,
1003
+ ): Bluebird<R>;
1004
+ static join<R, A1, A2>(
1005
+ arg1: Resolvable<A1>,
1006
+ arg2: Resolvable<A2>,
1007
+ handler: (arg1: A1, arg2: A2) => Resolvable<R>,
1008
+ ): Bluebird<R>;
1009
+ static join<R, A1, A2, A3>(
1010
+ arg1: Resolvable<A1>,
1011
+ arg2: Resolvable<A2>,
1012
+ arg3: Resolvable<A3>,
1013
+ handler: (arg1: A1, arg2: A2, arg3: A3) => Resolvable<R>,
1014
+ ): Bluebird<R>;
1015
+ static join<R, A1, A2, A3, A4>(
1016
+ arg1: Resolvable<A1>,
1017
+ arg2: Resolvable<A2>,
1018
+ arg3: Resolvable<A3>,
1019
+ arg4: Resolvable<A4>,
1020
+ handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Resolvable<R>,
1021
+ ): Bluebird<R>;
1022
+ static join<R, A1, A2, A3, A4, A5>(
1023
+ arg1: Resolvable<A1>,
1024
+ arg2: Resolvable<A2>,
1025
+ arg3: Resolvable<A3>,
1026
+ arg4: Resolvable<A4>,
1027
+ arg5: Resolvable<A5>,
1028
+ handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Resolvable<R>,
1029
+ ): Bluebird<R>;
1030
+
1031
+ // variadic array
1032
+ /** @deprecated use .all instead */
1033
+ static join<R>(...values: Array<Resolvable<R>>): Bluebird<R[]>;
1034
+
1035
+ /**
1036
+ * Map an array, or a promise of an array,
1037
+ * which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)`
1038
+ * where `item` is the resolved value of a respective promise in the input array.
1039
+ * If any promise in the input array is rejected the returned promise is rejected as well.
1040
+ *
1041
+ * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
1042
+ *
1043
+ * *The original array is not modified.*
1044
+ */
1045
+ static map<R, U>(
1046
+ values: Resolvable<Iterable<Resolvable<R>>>,
1047
+ mapper: IterateFunction<R, U>,
1048
+ options?: Bluebird.ConcurrencyOption,
1049
+ ): Bluebird<U[]>;
1050
+
1051
+ /**
1052
+ * Reduce an array, or a promise of an array,
1053
+ * which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)`
1054
+ * where `item` is the resolved value of a respective promise in the input array.
1055
+ * If any promise in the input array is rejected the returned promise is rejected as well.
1056
+ *
1057
+ * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
1058
+ *
1059
+ * *The original array is not modified. If no `initialValue` is given and the array doesn't contain at least 2 items,
1060
+ * the callback will not be called and `undefined` is returned.
1061
+ *
1062
+ * If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
1063
+ */
1064
+ static reduce<R, U>(
1065
+ values: Resolvable<Iterable<Resolvable<R>>>,
1066
+ reducer: (total: U, current: R, index: number, arrayLength: number) => Resolvable<U>,
1067
+ initialValue?: Resolvable<U>,
1068
+ ): Bluebird<U>;
1069
+
1070
+ /**
1071
+ * Filter an array, or a promise of an array,
1072
+ * which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)`
1073
+ * where `item` is the resolved value of a respective promise in the input array.
1074
+ * If any promise in the input array is rejected the returned promise is rejected as well.
1075
+ *
1076
+ * The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
1077
+ *
1078
+ * *The original array is not modified.
1079
+ */
1080
+ static filter<R>(
1081
+ values: Resolvable<Iterable<Resolvable<R>>>,
1082
+ filterer: IterateFunction<R, boolean>,
1083
+ option?: Bluebird.ConcurrencyOption,
1084
+ ): Bluebird<R[]>;
1085
+
1086
+ /**
1087
+ * Iterate over an array, or a promise of an array,
1088
+ * which contains promises (or a mix of promises and values) with the given iterator function with the signature `(item, index, value)`
1089
+ * where item is the resolved value of a respective promise in the input array.
1090
+ * Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
1091
+ *
1092
+ * Resolves to the original array unmodified, this method is meant to be used for side effects.
1093
+ * If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
1094
+ */
1095
+ static each<R>(
1096
+ values: Resolvable<Iterable<Resolvable<R>>>,
1097
+ iterator: IterateFunction<R, any>,
1098
+ ): Bluebird<R[]>;
1099
+
1100
+ /**
1101
+ * Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values),
1102
+ * iterate over all the values in the Iterable into an array and iterate over the array serially, in-order.
1103
+ *
1104
+ * Returns a promise for an array that contains the values returned by the iterator function in their respective positions.
1105
+ * The iterator won't be called for an item until its previous item, and the promise returned by the iterator for that item are fulfilled.
1106
+ * This results in a mapSeries kind of utility but it can also be used simply as a side effect iterator similar to Array#forEach.
1107
+ *
1108
+ * If any promise in the input array is rejected or any promise returned by the iterator function is rejected, the result will be rejected as well.
1109
+ */
1110
+ static mapSeries<R, U>(
1111
+ values: Resolvable<Iterable<Resolvable<R>>>,
1112
+ iterator: IterateFunction<R, U>,
1113
+ ): Bluebird<U[]>;
1114
+
1115
+ /**
1116
+ * A meta method used to specify the disposer method that cleans up a resource when using `Promise.using`.
1117
+ *
1118
+ * Returns a Disposer object which encapsulates both the resource as well as the method to clean it up.
1119
+ * The user can pass this object to `Promise.using` to get access to the resource when it becomes available,
1120
+ * as well as to ensure its automatically cleaned up.
1121
+ *
1122
+ * The second argument passed to a disposer is the result promise of the using block, which you can
1123
+ * inspect synchronously.
1124
+ */
1125
+ disposer(disposeFn: (arg: R, promise: Bluebird<R>) => Resolvable<void>): Bluebird.Disposer<R>;
1126
+
1127
+ /**
1128
+ * In conjunction with `.disposer`, using will make sure that no matter what, the specified disposer
1129
+ * will be called when the promise returned by the callback passed to using has settled. The disposer is
1130
+ * necessary because there is no standard interface in node for disposing resources.
1131
+ */
1132
+ static using<R, T>(
1133
+ disposer: Bluebird.Disposer<R>,
1134
+ executor: (transaction: R) => PromiseLike<T>,
1135
+ ): Bluebird<T>;
1136
+ static using<R1, R2, T>(
1137
+ disposer: Bluebird.Disposer<R1>,
1138
+ disposer2: Bluebird.Disposer<R2>,
1139
+ executor: (transaction1: R1, transaction2: R2) => PromiseLike<T>,
1140
+ ): Bluebird<T>;
1141
+ static using<R1, R2, R3, T>(
1142
+ disposer: Bluebird.Disposer<R1>,
1143
+ disposer2: Bluebird.Disposer<R2>,
1144
+ disposer3: Bluebird.Disposer<R3>,
1145
+ executor: (transaction1: R1, transaction2: R2, transaction3: R3) => PromiseLike<T>,
1146
+ ): Bluebird<T>;
1147
+
1148
+ /**
1149
+ * Configure long stack traces, warnings, monitoring and cancellation.
1150
+ * Note that even though false is the default here, a development environment might be detected which automatically
1151
+ * enables long stack traces and warnings.
1152
+ */
1153
+ static config(options: {
1154
+ /** Enable warnings */
1155
+ warnings?: boolean | {
1156
+ /** Enables all warnings except forgotten return statements. */
1157
+ wForgottenReturn: boolean;
1158
+ } | undefined;
1159
+ /** Enable long stack traces */
1160
+ longStackTraces?: boolean | undefined;
1161
+ /** Enable cancellation */
1162
+ cancellation?: boolean | undefined;
1163
+ /** Enable monitoring */
1164
+ monitoring?: boolean | undefined;
1165
+ /** Enable async hooks */
1166
+ asyncHooks?: boolean | undefined;
1167
+ }): void;
1168
+
1169
+ /**
1170
+ * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
1171
+ * If promise cancellation is enabled, passed in function will receive one more function argument `onCancel` that allows to register an optional cancellation callback.
1172
+ */
1173
+ static Promise: typeof Bluebird;
1174
+
1175
+ /**
1176
+ * The version number of the library
1177
+ */
1178
+ static version: string;
1179
+ }
1180
+
1181
+ declare namespace Bluebird {
1182
+ interface ConcurrencyOption {
1183
+ concurrency: number;
1184
+ }
1185
+ interface SpreadOption {
1186
+ spread: boolean;
1187
+ }
1188
+ interface FromNodeOptions {
1189
+ multiArgs?: boolean | undefined;
1190
+ }
1191
+ interface PromisifyOptions {
1192
+ context?: any;
1193
+ multiArgs?: boolean | undefined;
1194
+ }
1195
+ interface PromisifyAllOptions<T> extends PromisifyOptions {
1196
+ suffix?: string | undefined;
1197
+ filter?(name: string, func: (...args: any[]) => any, target?: any, passesDefaultFilter?: boolean): boolean;
1198
+ // The promisifier gets a reference to the original method and should return a function which returns a promise
1199
+ promisifier?(
1200
+ this: T,
1201
+ originalMethod: (...args: any[]) => any,
1202
+ defaultPromisifer: (...args: any[]) => (...args: any[]) => Bluebird<any>,
1203
+ ): () => PromiseLike<any>;
1204
+ }
1205
+ interface CoroutineOptions {
1206
+ yieldHandler(value: any): any;
1207
+ }
1208
+
1209
+ /**
1210
+ * Represents an error is an explicit promise rejection as opposed to a thrown error.
1211
+ * For example, if an error is errbacked by a callback API promisified through undefined or undefined
1212
+ * and is not a typed error, it will be converted to a `OperationalError` which has the original error in
1213
+ * the `.cause` property.
1214
+ *
1215
+ * `OperationalError`s are caught in `.error` handlers.
1216
+ */
1217
+ class OperationalError extends Error {}
1218
+
1219
+ /**
1220
+ * Signals that an operation has timed out. Used as a custom cancellation reason in `.timeout`.
1221
+ */
1222
+ class TimeoutError extends Error {}
1223
+
1224
+ /**
1225
+ * Signals that an operation has been aborted or cancelled. The default reason used by `.cancel`.
1226
+ */
1227
+ class CancellationError extends Error {}
1228
+
1229
+ /**
1230
+ * A collection of errors. `AggregateError` is an array-like object, with numeric indices and a `.length` property.
1231
+ * It supports all generic array methods such as `.forEach` directly.
1232
+ *
1233
+ * `AggregateError`s are caught in `.error` handlers, even if the contained errors are not operational.
1234
+ *
1235
+ * `Promise.some` and `Promise.any` use `AggregateError` as rejection reason when they fail.
1236
+ */
1237
+ class AggregateError extends Error implements ArrayLike<Error> {
1238
+ length: number;
1239
+ [index: number]: Error;
1240
+ join(separator?: string): string;
1241
+ pop(): Error;
1242
+ push(...errors: Error[]): number;
1243
+ shift(): Error;
1244
+ unshift(...errors: Error[]): number;
1245
+ slice(begin?: number, end?: number): AggregateError;
1246
+ filter(
1247
+ callback: (element: Error, index: number, array: AggregateError) => boolean,
1248
+ thisArg?: any,
1249
+ ): AggregateError;
1250
+ forEach(callback: (element: Error, index: number, array: AggregateError) => void, thisArg?: any): undefined;
1251
+ some(callback: (element: Error, index: number, array: AggregateError) => boolean, thisArg?: any): boolean;
1252
+ every(callback: (element: Error, index: number, array: AggregateError) => boolean, thisArg?: any): boolean;
1253
+ map(callback: (element: Error, index: number, array: AggregateError) => boolean, thisArg?: any): AggregateError;
1254
+ indexOf(searchElement: Error, fromIndex?: number): number;
1255
+ lastIndexOf(searchElement: Error, fromIndex?: number): number;
1256
+ reduce(
1257
+ callback: (accumulator: any, element: Error, index: number, array: AggregateError) => any,
1258
+ initialValue?: any,
1259
+ ): any;
1260
+ reduceRight(
1261
+ callback: (previousValue: any, element: Error, index: number, array: AggregateError) => any,
1262
+ initialValue?: any,
1263
+ ): any;
1264
+ sort(compareFunction?: (errLeft: Error, errRight: Error) => number): AggregateError;
1265
+ reverse(): AggregateError;
1266
+ }
1267
+
1268
+ /**
1269
+ * returned by `Bluebird.disposer()`.
1270
+ */
1271
+ class Disposer<R> {}
1272
+
1273
+ /** @deprecated Use PromiseLike<T> directly. */
1274
+ type Thenable<T> = PromiseLike<T>;
1275
+
1276
+ type ResolvableProps<T> = object & { [K in keyof T]: Resolvable<T[K]> };
1277
+
1278
+ interface Resolver<R> {
1279
+ /**
1280
+ * Returns a reference to the controlled promise that can be passed to clients.
1281
+ */
1282
+ promise: Bluebird<R>;
1283
+
1284
+ /**
1285
+ * Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state.
1286
+ */
1287
+ resolve(value: R): void;
1288
+ resolve(): void;
1289
+
1290
+ /**
1291
+ * Reject the underlying promise with `reason` as the rejection reason.
1292
+ */
1293
+ reject(reason: any): void;
1294
+
1295
+ /**
1296
+ * Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property.
1297
+ * The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
1298
+ *
1299
+ * If the the callback is called with multiple success values, the resolver fulfills its promise with an array of the values.
1300
+ */
1301
+ // TODO specify resolver callback
1302
+ callback(err: any, value: R, ...values: R[]): void;
1303
+ }
1304
+
1305
+ interface Inspection<R> {
1306
+ /**
1307
+ * See if the underlying promise was fulfilled at the creation time of this inspection object.
1308
+ */
1309
+ isFulfilled(): boolean;
1310
+
1311
+ /**
1312
+ * See if the underlying promise was rejected at the creation time of this inspection object.
1313
+ */
1314
+ isRejected(): boolean;
1315
+
1316
+ /**
1317
+ * See if the underlying promise was cancelled at the creation time of this inspection object.
1318
+ */
1319
+ isCancelled(): boolean;
1320
+
1321
+ /**
1322
+ * See if the underlying promise was defer at the creation time of this inspection object.
1323
+ */
1324
+ isPending(): boolean;
1325
+
1326
+ /**
1327
+ * Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object.
1328
+ *
1329
+ * throws `TypeError`
1330
+ */
1331
+ value(): R;
1332
+
1333
+ /**
1334
+ * Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object.
1335
+ *
1336
+ * throws `TypeError`
1337
+ */
1338
+ reason(): any;
1339
+ }
1340
+
1341
+ /**
1342
+ * Returns a new independent copy of the Bluebird library.
1343
+ *
1344
+ * This method should be used before you use any of the methods which would otherwise alter the global Bluebird object - to avoid polluting global state.
1345
+ */
1346
+ function getNewLibraryCopy(): typeof Bluebird;
1347
+
1348
+ /**
1349
+ * This is relevant to browser environments with no module loader.
1350
+ *
1351
+ * Release control of the Promise namespace to whatever it was before this library was loaded.
1352
+ * Returns a reference to the library namespace so you can attach it to something else.
1353
+ */
1354
+ function noConflict(): typeof Bluebird;
1355
+
1356
+ /**
1357
+ * Changes how bluebird schedules calls a-synchronously.
1358
+ *
1359
+ * @param scheduler Should be a function that asynchronously schedules
1360
+ * the calling of the passed in function
1361
+ */
1362
+ function setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void;
1363
+ }
1364
+
1365
+ export = Bluebird;