diff options
author | Maximilian Krambach <[email protected]> | 2018-09-19 08:56:36 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-09-19 08:56:36 +0000 |
commit | 7f149586062ebae8114f64078771cb25579f5003 (patch) | |
tree | afb8f87c0a8195ce8cf320115edc80019c9fd0af /lang/js/src/index.js | |
parent | docs: python bindings (diff) | |
download | gpgme-7f149586062ebae8114f64078771cb25579f5003.tar.gz gpgme-7f149586062ebae8114f64078771cb25579f5003.zip |
js: add configuration option on startup
--
* src/index.js: Added an optional configuration object for the startup.
* configuration: timeout - the initial check for a connection ran into
timeouts on slower testing machines. 500ms for initial startup is
not sufficient everywhere. The default timeout was raised to 1000ms,
and as an option this timeout can be increased even further.
* BrowsertestExtension: Set the initial connection timeouts to 2
seconds, to be able to test on slower machines.
Diffstat (limited to 'lang/js/src/index.js')
-rw-r--r-- | lang/js/src/index.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lang/js/src/index.js b/lang/js/src/index.js index c52460cc..b8e4274d 100644 --- a/lang/js/src/index.js +++ b/lang/js/src/index.js @@ -31,13 +31,17 @@ import { Connection } from './Connection'; * connection once, and then offers the available functions as method of the * response object. * An unsuccessful attempt will reject as a GPGME_Error. + * @param {Object} config (optional) configuration options + * @param {Number} config.timeout set the timeout for the initial connection + * check. On some machines and operating systems a default timeout of 500 ms is + * too low, so a higher number might be attempted. * @returns {Promise<GpgME>} * @async */ -function init (){ +function init ({ timeout = 500 } = {}){ return new Promise(function (resolve, reject){ const connection = new Connection; - connection.checkConnection(false).then( + connection.checkConnection(false, timeout).then( function (result){ if (result === true) { resolve(new GpgME()); |