UNPKG

@fsi-open/mock-socket

Version:

Javascript mocking library for websockets and socket.io

12 lines (11 loc) 517 B
/* * This delay allows the thread to finish assigning its on* methods * before invoking the delay callback. This is purely a timing hack. * http://geekabyte.blogspot.com/2014/01/javascript-effect-of-setting-settimeout.html * * @param {callback: function} the callback which will be invoked after the timeout * @parma {context: object} the context in which to invoke the function */ export default function delay(callback, context) { setTimeout(timeoutContext => callback.call(timeoutContext), 4, context); }