We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
promisify()
1 parent fb2bd6d commit 8a0c02aCopy full SHA for 8a0c02a
ddterm/util/promise.js
@@ -5,6 +5,21 @@
5
import GLib from 'gi://GLib';
6
import Gio from 'gi://Gio';
7
8
+export function promisify(start, finish) {
9
+ return function (...args) {
10
+ return new Promise((resolve, reject) => {
11
+ // eslint-disable-next-line no-invalid-this
12
+ start.call(this, ...args, (source, result) => {
13
+ try {
14
+ resolve(finish.call(source, result));
15
+ } catch (error) {
16
+ reject(error);
17
+ }
18
+ });
19
20
+ };
21
+}
22
+
23
export async function wait_timeout(message, timeout_ms, cancellable = null) {
24
let source, cancel_handler;
25
0 commit comments