This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint no-console: 0 */ | |
/* eslint no-unused-vars: 0 */ | |
const https = require('https'); | |
const goodUrl = 'https://jsonplaceholder.typicode.com/users/1'; | |
const badUrl = 'https://jsonplaceholder.typicode.com/foo'; | |
const badDomain = 'https://no.such.url'; | |
const externalCall = (url, t = 0) => new Promise((resolve, reject) => { | |
setTimeout(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { createContext, useState } from 'react'; | |
import PropTypes from 'prop-types'; | |
const mq = 'screen and (max-width: 671px)'; | |
const ResponsiveContext = createContext(); | |
const ResponsiveContextProvider = ({ children }) => { | |
const [isMobile, setIsMobile] = useState(window.matchMedia(mq).matches); | |
matchMedia(mq).addEventListener('change', e => setIsMobile(e.matches)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require('net'); | |
const getOpenPort = async (port, maxPort) => { | |
const isPortAvail = (currentPort) => new Promise((resolve, reject) => { | |
const tester = net.createServer() | |
.once('error', (err) => (err.code === 'EADDRINUSE' ? resolve(false) : reject(err))) | |
.once('listening', () => tester.once('close', () => resolve(true)).close()) | |
.listen(currentPort); | |
}); | |
OlderNewer