Skip to content

Instantly share code, notes, and snippets.

View lindekaer's full-sized avatar
👋
undefined is not a function

Theodor Lindekaer lindekaer

👋
undefined is not a function
View GitHub Profile
@lindekaer
lindekaer / wip.ts
Last active September 8, 2019 15:38
Exhaustive checking in Typescript
/*
Exhaustive checking is the concept of ensuring that all possibilities have
been covered when e.g. handling the different cases for values in an enum.
Below are some snippets to achieve this in Typescript.
*/
enum Job {
Engineer = 'engineer',
KeyAccountManager = 'key-account-manager',
@lindekaer
lindekaer / convert.ts
Last active September 12, 2020 03:59
Convert Google Chrome bookmark timestamp to JS date
// A Webkit timestamp is the number of microseconds from "1st of Jan 1601"
// The magic number 11644473600 is the number of seconds between
// "1st of Jan 1601" and "1st of Jan 1970"
export const converWebkitTimestamp = (webkitTimestamp: number): Date => {
const dateInSeconds = Math.round(webkitTimestamp / 1000000) - 11644473600
return new Date(dateInSeconds * 1000)
}