Skip to content

Instantly share code, notes, and snippets.

@onosendi
Created June 30, 2023 17:54
Show Gist options
  • Save onosendi/b1173faff9d6e79eb1fa1164ca9bb8ea to your computer and use it in GitHub Desktop.
Save onosendi/b1173faff9d6e79eb1fa1164ca9bb8ea to your computer and use it in GitHub Desktop.
function connect(address) {
return new Promise((resolve, reject) => {
const server = new WebSocket(address);
server.onopen = () => {
resolve(server);
};
server.onerror = (e) => {
reject(e);
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment