mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2025-01-09 06:19:29 -07:00
Make jsenv detection conditional without return
This commit is contained in:
parent
da59262c45
commit
e0dc5f4b21
3 changed files with 215 additions and 218 deletions
|
@ -26,13 +26,9 @@ const jsEnv = require("browser-or-node")
|
|||
module.exports.timeout = 5000
|
||||
|
||||
if (!jsEnv.isNode) {
|
||||
module.exports.fn = null
|
||||
return
|
||||
}
|
||||
const dns = require('dns')
|
||||
|
||||
const dns = require('dns')
|
||||
|
||||
/**
|
||||
/**
|
||||
* Execute a fetch request
|
||||
* @function
|
||||
* @async
|
||||
|
@ -40,7 +36,7 @@ const dns = require('dns')
|
|||
* @param {string} data.domain - The targeted domain
|
||||
* @returns {object}
|
||||
*/
|
||||
module.exports.fn = async (data, opts) => {
|
||||
module.exports.fn = async (data, opts) => {
|
||||
let timeoutHandle
|
||||
const timeoutPromise = new Promise((resolve, reject) => {
|
||||
timeoutHandle = setTimeout(
|
||||
|
@ -69,4 +65,7 @@ module.exports.fn = async (data, opts) => {
|
|||
clearTimeout(timeoutHandle)
|
||||
return result
|
||||
})
|
||||
}
|
||||
} else {
|
||||
module.exports.fn = null
|
||||
}
|
|
@ -25,15 +25,11 @@ const jsEnv = require("browser-or-node")
|
|||
*/
|
||||
module.exports.timeout = 20000
|
||||
|
||||
if (!jsEnv.isNode) {
|
||||
module.exports.fn = null
|
||||
return
|
||||
}
|
||||
if (jsEnv.isNode) {
|
||||
const irc = require('irc-upd')
|
||||
const validator = require('validator')
|
||||
|
||||
const irc = require('irc-upd')
|
||||
const validator = require('validator')
|
||||
|
||||
/**
|
||||
/**
|
||||
* Execute a fetch request
|
||||
* @function
|
||||
* @async
|
||||
|
@ -44,7 +40,7 @@ const validator = require('validator')
|
|||
* @param {string} opts.claims.irc.nick - The nick to be used by the library to log in
|
||||
* @returns {object}
|
||||
*/
|
||||
module.exports.fn = async (data, opts) => {
|
||||
module.exports.fn = async (data, opts) => {
|
||||
let timeoutHandle
|
||||
const timeoutPromise = new Promise((resolve, reject) => {
|
||||
timeoutHandle = setTimeout(
|
||||
|
@ -92,4 +88,7 @@ module.exports.fn = async (data, opts) => {
|
|||
clearTimeout(timeoutHandle)
|
||||
return result
|
||||
})
|
||||
}
|
||||
} else {
|
||||
module.exports.fn = null
|
||||
}
|
||||
|
|
|
@ -25,20 +25,16 @@ const jsEnv = require("browser-or-node")
|
|||
*/
|
||||
module.exports.timeout = 5000
|
||||
|
||||
if (!jsEnv.isNode) {
|
||||
module.exports.fn = null
|
||||
return
|
||||
}
|
||||
if (jsEnv.isNode) {
|
||||
const jsdom = require('jsdom')
|
||||
const { client, xml } = require('@xmpp/client')
|
||||
const debug = require('@xmpp/debug')
|
||||
const validator = require('validator')
|
||||
|
||||
const jsdom = require('jsdom')
|
||||
const { client, xml } = require('@xmpp/client')
|
||||
const debug = require('@xmpp/debug')
|
||||
const validator = require('validator')
|
||||
|
||||
let xmpp = null,
|
||||
let xmpp = null,
|
||||
iqCaller = null
|
||||
|
||||
const xmppStart = async (service, username, password) => {
|
||||
const xmppStart = async (service, username, password) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xmpp = client({
|
||||
service: service,
|
||||
|
@ -57,9 +53,9 @@ const xmppStart = async (service, username, password) => {
|
|||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Execute a fetch request
|
||||
* @function
|
||||
* @async
|
||||
|
@ -72,7 +68,7 @@ const xmppStart = async (service, username, password) => {
|
|||
* @param {string} opts.claims.xmpp.password - The password used to log in
|
||||
* @returns {object}
|
||||
*/
|
||||
module.exports.fn = async (data, opts) => {
|
||||
module.exports.fn = async (data, opts) => {
|
||||
let timeoutHandle
|
||||
const timeoutPromise = new Promise((resolve, reject) => {
|
||||
timeoutHandle = setTimeout(
|
||||
|
@ -140,4 +136,7 @@ module.exports.fn = async (data, opts) => {
|
|||
clearTimeout(timeoutHandle)
|
||||
return result
|
||||
})
|
||||
}
|
||||
} else {
|
||||
module.exports.fn = null
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue