This file contains 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 fetchMock = (response) => { | |
window.fetch = jest.fn().mockImplementation(() => | |
new Promise((resolve) => { | |
resolve({ json: () => response }) | |
}) | |
) | |
} | |
const fetchMockRejected = (response) => { | |
window.fetch = jest.fn().mockImplementation(() => |
This file contains 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
// original gist | |
const shuffleArray = arr => arr.sort(() => Math.random() - 0.5); | |
// fully random by @BetonMAN | |
const shuffleArray = arr => arr | |
.map(a => [Math.random(), a]) | |
.sort((a, b) => a[0] - b[0]) | |
.map(a => a[1]); | |
shuffleArray([1, 2, 3]) //[3, 1, 2] |
This file contains 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 { join } = require('path'); | |
const webpack = require('webpack'); | |
const DefinePlugin = webpack.DefinePlugin; | |
module.exports = { | |
target : 'web', | |
entry : './src/index.tsx', | |
output : { | |
chunkFilename : '[id].index.js', | |
filename : 'index.js', |
This file contains 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
// In response to https://twitter.com/housecor/status/930108010558640128 | |
function doubleAfter2Seconds(x) { | |
return new Promise(resolve => { | |
resolve(x * 2); | |
}, 2000); | |
} | |
async function addAsync(x) { | |
const { a, b, c } = await Promise.all([ | |
doubleAfter2Seconds(10), |
This file contains 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 from "react" | |
import {InternalRoutes} from "types/routes" | |
import Link, {LinkProps} from "next/link" | |
export function InternalLink({ | |
routeName, | |
routeParams, | |
...linkProps | |
}: Omit<LinkProps, "href" | "as"> & | |
InternalRoutes & {children: React.ReactChild}) { |
OlderNewer