mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2025-01-09 14:29:27 -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
|
module.exports.timeout = 5000
|
||||||
|
|
||||||
if (!jsEnv.isNode) {
|
if (!jsEnv.isNode) {
|
||||||
module.exports.fn = null
|
const dns = require('dns')
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const dns = require('dns')
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute a fetch request
|
* Execute a fetch request
|
||||||
* @function
|
* @function
|
||||||
* @async
|
* @async
|
||||||
|
@ -40,7 +36,7 @@ const dns = require('dns')
|
||||||
* @param {string} data.domain - The targeted domain
|
* @param {string} data.domain - The targeted domain
|
||||||
* @returns {object}
|
* @returns {object}
|
||||||
*/
|
*/
|
||||||
module.exports.fn = async (data, opts) => {
|
module.exports.fn = async (data, opts) => {
|
||||||
let timeoutHandle
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
|
@ -69,4 +65,7 @@ module.exports.fn = async (data, opts) => {
|
||||||
clearTimeout(timeoutHandle)
|
clearTimeout(timeoutHandle)
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
module.exports.fn = null
|
||||||
}
|
}
|
|
@ -25,15 +25,11 @@ const jsEnv = require("browser-or-node")
|
||||||
*/
|
*/
|
||||||
module.exports.timeout = 20000
|
module.exports.timeout = 20000
|
||||||
|
|
||||||
if (!jsEnv.isNode) {
|
if (jsEnv.isNode) {
|
||||||
module.exports.fn = null
|
const irc = require('irc-upd')
|
||||||
return
|
const validator = require('validator')
|
||||||
}
|
|
||||||
|
|
||||||
const irc = require('irc-upd')
|
/**
|
||||||
const validator = require('validator')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute a fetch request
|
* Execute a fetch request
|
||||||
* @function
|
* @function
|
||||||
* @async
|
* @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
|
* @param {string} opts.claims.irc.nick - The nick to be used by the library to log in
|
||||||
* @returns {object}
|
* @returns {object}
|
||||||
*/
|
*/
|
||||||
module.exports.fn = async (data, opts) => {
|
module.exports.fn = async (data, opts) => {
|
||||||
let timeoutHandle
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
|
@ -92,4 +88,7 @@ module.exports.fn = async (data, opts) => {
|
||||||
clearTimeout(timeoutHandle)
|
clearTimeout(timeoutHandle)
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
module.exports.fn = null
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,20 +25,16 @@ const jsEnv = require("browser-or-node")
|
||||||
*/
|
*/
|
||||||
module.exports.timeout = 5000
|
module.exports.timeout = 5000
|
||||||
|
|
||||||
if (!jsEnv.isNode) {
|
if (jsEnv.isNode) {
|
||||||
module.exports.fn = null
|
const jsdom = require('jsdom')
|
||||||
return
|
const { client, xml } = require('@xmpp/client')
|
||||||
}
|
const debug = require('@xmpp/debug')
|
||||||
|
const validator = require('validator')
|
||||||
|
|
||||||
const jsdom = require('jsdom')
|
let xmpp = null,
|
||||||
const { client, xml } = require('@xmpp/client')
|
|
||||||
const debug = require('@xmpp/debug')
|
|
||||||
const validator = require('validator')
|
|
||||||
|
|
||||||
let xmpp = null,
|
|
||||||
iqCaller = null
|
iqCaller = null
|
||||||
|
|
||||||
const xmppStart = async (service, username, password) => {
|
const xmppStart = async (service, username, password) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const xmpp = client({
|
const xmpp = client({
|
||||||
service: service,
|
service: service,
|
||||||
|
@ -57,9 +53,9 @@ const xmppStart = async (service, username, password) => {
|
||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a fetch request
|
* Execute a fetch request
|
||||||
* @function
|
* @function
|
||||||
* @async
|
* @async
|
||||||
|
@ -72,7 +68,7 @@ const xmppStart = async (service, username, password) => {
|
||||||
* @param {string} opts.claims.xmpp.password - The password used to log in
|
* @param {string} opts.claims.xmpp.password - The password used to log in
|
||||||
* @returns {object}
|
* @returns {object}
|
||||||
*/
|
*/
|
||||||
module.exports.fn = async (data, opts) => {
|
module.exports.fn = async (data, opts) => {
|
||||||
let timeoutHandle
|
let timeoutHandle
|
||||||
const timeoutPromise = new Promise((resolve, reject) => {
|
const timeoutPromise = new Promise((resolve, reject) => {
|
||||||
timeoutHandle = setTimeout(
|
timeoutHandle = setTimeout(
|
||||||
|
@ -140,4 +136,7 @@ module.exports.fn = async (data, opts) => {
|
||||||
clearTimeout(timeoutHandle)
|
clearTimeout(timeoutHandle)
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
module.exports.fn = null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue