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
{ | |
"name": "debug everything", | |
"type": "node", | |
"request": "launch", | |
"runtimeArgs": ["-r", "ts-node/register"], | |
"args": ["${workspaceRoot}/src/compile.ts"] | |
} |
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 Nat = Zero | Suc Nat deriving (Show) | |
data List a = Nil | Cons a (List a) deriving (Show) | |
addNat :: Nat -> Nat -> Nat | |
addNat Zero x = x | |
addNat (Suc x) y = Suc (addNat x y) | |
mulNat :: Nat -> Nat -> Nat | |
mulNat Zero _ = Zero | |
mulNat (Suc x) y = addNat y (mulNat x y) |
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 getChildWithClassName(element, className) { | |
if (!element || !className) return null; | |
const toIterable = elemList => (elemList ? [...elemList] : []) | |
const searcher = nodes => { | |
if (!nodes || nodes.length < 1) return null; | |
return nodes.find(node => toIterable(node.classList).includes(className)) | |
|| nodes.map(node => searcher(toIterable(node.childNodes))).find(x => x) // 🚀 | |
} |
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
console.time('start') | |
async function myFunction() { | |
const success = Promise.resolve('Yaaay') | |
const promise = new Promise((_, reject) => setTimeout(() => { | |
console.timeEnd('start') | |
reject('Rejection reason') | |
}, 200)) | |
const autoCatchedPromise = promise.catch(error => { | |
console.info('Error caught:', error) |
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 getPropertyDeep = function(rootObject, queryString) { | |
if (queryString.indexOf('.') === -1) return rootObject[queryString] | |
const partialQueryString = queryString.split('.') | |
const partialObject = rootObject[partialQueryString[0]] | |
return getPropertyDeep(partialObject, partialQueryString.slice(1).join('.')) | |
} |