Skip to content

Instantly share code, notes, and snippets.

View bgauryy's full-sized avatar

bgauryy

  • Tel Aviv
View GitHub Profile
@bgauryy
bgauryy / asyncTest.js
Last active May 18, 2019 11:45
Async callbacks in a nutshell
(function () {
const LIMIT = 5;
const bcA = new BroadcastChannel('id');
const bcB = new BroadcastChannel('id');
let flag = false, count = 0;
bcA.onmessage = () => {
console.log('(。_+)\BroadcastChannel');
};
const IPV4Reg = '((([0-9])|(1*[0-9][0-9])|(2[1-4][0-9])|(25[0-5]))\\.){3}(([0-9])|(1*[0-9][0-9])|(2[1-4][0-9])|(25[0-5]))';
const IP4 = `(^${IPV4Reg}$)|(^${IPV4Reg}\\:)|(^${IPV4Reg}\/)`;
function getIPDomain(url) {
const matches = new RegExp(IP4).exec(url);
if (matches && matches[0]) {
return matches[0].replace(/\:|\//, '');
}
}