Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {createMessageEvent} from 'mock-socket/src/event-factory'
import cloneDeepWith from 'lodash/cloneDeepWith'
export class Server extends BaseServer {
// SocketIO sends server (this) as first arg to connection & connect events, this fixes it
dispatchEvent(event, ...customArguments) {
if (customArguments[0] && customArguments[0] === this) {
customArguments.shift()
}
return super.dispatchEvent(event, ...customArguments)
}
}
// SocketIO class isn't exposed
const serverInstance = new Server('dummy')
const instance = new BaseSocketIOConstructor('dummy')
const BaseSocketIO = Object.getPrototypeOf(instance).constructor
instance.on('connect', () => {
instance.close()
serverInstance.close()
})
// GG
function cloneCustomiser(arg) {
if (typeof arg === 'function') {
return function (...args) {
args = cloneDeepWith(args, cloneCustomiser)
return arg(...args)
}
}
return undefined
}