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
// A simple script to clear all notifications in Slack. | |
// 1. Open Slack on the web (not in the app as you cannot open the dev tools console) | |
// 2. Copy paste into your console | |
(async () => { | |
function goToNotifications() { | |
const button = document.querySelector('[data-qa="tab_rail_activity_button"]'); | |
if (!(button instanceof HTMLElement)) { | |
throw Error('Count not find activities button'); | |
} | |
button.click(); |
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
// This file polyfills DOMRect | |
// DOMRect is currently not polyfilled by jsdom | |
(() => { | |
if (typeof window === 'undefined') { | |
return; | |
} | |
if (window.DOMRect) { | |
return; | |
} |
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
/* data-transfer-item-list.spec.ts */ | |
import invariant from 'tiny-invariant'; | |
test('add(data, format) should add a string item', done => { | |
const list = new DataTransferItemList(); | |
list.add('Hello world', 'text/plain'); | |
const item: DataTransferItem = list[0]; |
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
// This file polyfills DragEvent for jsdom | |
// https://github.com/jsdom/jsdom/issues/2913 | |
// This file is in JS rather than TS, as our jsdom setup files currently need to be in JS | |
// Good news: DragEvents are almost the same as MouseEvents | |
(() => { | |
if (typeof window === 'undefined') { | |
return; | |
} |
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
function add(a: number, b: number): number { | |
return a + b; | |
} | |
type MyParameters<TFunc extends (...args: any[]) => unknown> = TFunc extends ( | |
...args: infer TArgs | |
) => unknown | |
? TArgs | |
: unknown; |
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
// This file polyfills `Element.prototype.scrollBy` | |
// scrollBy(x-coord, y-coord) | |
// scrollBy(options) | |
(() => { | |
if (typeof Element === 'undefined') { | |
return; | |
} | |
if (typeof Element.prototype.scrollBy !== 'undefined') { | |
return; | |
} |
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 interactions: number[][] = []; | |
function sum(values: number[]) { | |
return values.reduce((acc, current) => acc + current, 0); | |
} | |
function average(values: number[]): number { | |
if (!values.length) { | |
return 0; | |
} |
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
export {}; | |
const allCollectedFps: number[][] = []; | |
function sum(values: number[]) { | |
return values.reduce((acc, current) => acc + current, 0); | |
} | |
function average(values: number[]): number { | |
if (!values.length) { |
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
function average(values: number[]): number { | |
const sum = values.reduce((acc, current) => acc + current, 0); | |
return sum / values.length; | |
} | |
export function standardDeviation(values: number[]): number { | |
/** https://www.mathsisfun.com/data/standard-deviation-formulas.html | |
* 1. Work out the Mean (the simple average of the numbers) | |
* 2. Then for each number: subtract the Mean and square the result | |
* 3. Then work out the mean of those squared differences. |
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
function waitForFrames({ | |
frames, | |
done, | |
}: { | |
frames: number; | |
done: () => void; | |
}): () => void { | |
let frameId: number | null = null; | |
let remainingFrames = frames; |
NewerOlder