Skip to content

Instantly share code, notes, and snippets.

View gabsoftware's full-sized avatar

Gabriel Hautclocq gabsoftware

View GitHub Profile
WORMSS / types.d.ts
Last active December 1, 2020 13:26
Typescript: My advanced types I don't want to lose
type Optional<T, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
type AllOrNothing<T> = T | Partial<Record<keyof T, never>>;
type OnlyOne<T> = {
[K in keyof T]: (
Required<Pick<T, K>> & Partial<Record<Exclude<keyof T, K>, never>>
}[keyof T];
type Test = {
gabsoftware / index.html
Last active August 9, 2017 08:55
Finding out the fastest way to loop through an array ( #jsbench #jsperf
<!DOCTYPE html>
<meta charset="utf-8"/>
<title>Finding out the fastest way to loop through an array</title>
<script src=""></script>
<script src="./suite.js"></script>
<h1>Open the console to view the results</h1>