gramio 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -67,25 +67,25 @@ function timeoutWebhook(task, timeout, mode) {
67
67
 
68
68
  async function suppressError(fn) {
69
69
  try {
70
- return [await fn(), false];
70
+ return { value: await fn(), caught: false };
71
71
  } catch (error) {
72
- return [error, true];
72
+ return { value: error, caught: true };
73
73
  }
74
74
  }
75
75
  async function withRetries(resultPromise) {
76
- let [result, isFromCatch] = await suppressError(resultPromise);
77
- while (result instanceof TelegramError) {
78
- const retryAfter = result.payload?.retry_after;
76
+ let state = await suppressError(resultPromise);
77
+ while (state.value instanceof TelegramError) {
78
+ const retryAfter = state.value.payload?.retry_after;
79
79
  if (retryAfter) {
80
80
  await sleep(retryAfter * 1e3);
81
- [result, isFromCatch] = await suppressError(resultPromise);
81
+ state = await suppressError(resultPromise);
82
82
  } else {
83
- if (isFromCatch) throw result;
84
- return result;
83
+ if (state.caught) throw state.value;
84
+ return state.value;
85
85
  }
86
86
  }
87
- if (result instanceof Error && isFromCatch) throw result;
88
- return result;
87
+ if (state.caught) throw state.value;
88
+ return state.value;
89
89
  }
90
90
 
91
91
  exports.ErrorKind = ErrorKind;
@@ -65,25 +65,25 @@ function timeoutWebhook(task, timeout, mode) {
65
65
 
66
66
  async function suppressError(fn) {
67
67
  try {
68
- return [await fn(), false];
68
+ return { value: await fn(), caught: false };
69
69
  } catch (error) {
70
- return [error, true];
70
+ return { value: error, caught: true };
71
71
  }
72
72
  }
73
73
  async function withRetries(resultPromise) {
74
- let [result, isFromCatch] = await suppressError(resultPromise);
75
- while (result instanceof TelegramError) {
76
- const retryAfter = result.payload?.retry_after;
74
+ let state = await suppressError(resultPromise);
75
+ while (state.value instanceof TelegramError) {
76
+ const retryAfter = state.value.payload?.retry_after;
77
77
  if (retryAfter) {
78
78
  await sleep(retryAfter * 1e3);
79
- [result, isFromCatch] = await suppressError(resultPromise);
79
+ state = await suppressError(resultPromise);
80
80
  } else {
81
- if (isFromCatch) throw result;
82
- return result;
81
+ if (state.caught) throw state.value;
82
+ return state.value;
83
83
  }
84
84
  }
85
- if (result instanceof Error && isFromCatch) throw result;
86
- return result;
85
+ if (state.caught) throw state.value;
86
+ return state.value;
87
87
  }
88
88
 
89
89
  export { ErrorKind as E, IS_BUN as I, TelegramError as T, simplifyObject as a, debug$updates as d, sleep as s, timeoutWebhook as t, withRetries as w };
package/dist/utils.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var utils = require('./utils-C46rnh-r.cjs');
3
+ var utils = require('./utils-DCXj-tb5.cjs');
4
4
  require('debug');
5
5
 
6
6
 
package/dist/utils.js CHANGED
@@ -1,2 +1,2 @@
1
- export { w as withRetries } from './utils-En0iVLWH.js';
1
+ export { w as withRetries } from './utils-DqK73ALI.js';
2
2
  import 'debug';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gramio",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.6.1",
5
5
  "description": "Powerful, extensible and really type-safe Telegram Bot API framework",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -55,22 +55,22 @@
55
55
  "author": "kravets",
56
56
  "license": "MIT",
57
57
  "devDependencies": {
58
- "@biomejs/biome": "2.4.2",
59
- "@gramio/test": "^0.1.0",
58
+ "@biomejs/biome": "2.4.4",
59
+ "@gramio/test": "^0.3.1",
60
60
  "@types/bun": "^1.3.9",
61
61
  "@types/debug": "^4.1.12",
62
62
  "expect-type": "^1.3.0",
63
- "pkgroll": "^2.26.0",
63
+ "pkgroll": "^2.27.0",
64
64
  "typescript": "^5.9.3"
65
65
  },
66
66
  "dependencies": {
67
- "@gramio/callback-data": "^0.0.3",
68
- "@gramio/composer": "^0.2.0",
67
+ "@gramio/callback-data": "^0.1.0",
68
+ "@gramio/composer": "^0.3.3",
69
69
  "@gramio/contexts": "^0.4.0",
70
70
  "@gramio/files": "^0.3.0",
71
- "@gramio/format": "^0.3.4",
71
+ "@gramio/format": "^0.4.0",
72
72
  "@gramio/keyboards": "^1.3.0",
73
- "@gramio/types": "^9.4.1",
73
+ "@gramio/types": "^9.4.2",
74
74
  "debug": "^4.4.3"
75
75
  },
76
76
  "files": [