Class names are CamelCase
.
Methods and variables are snake_case
.
Methods with a ?
suffix will return a boolean.
{ | |
"[html]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, | |
"[javascript]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, | |
"[javascriptreact]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, |
function leftPad(str, padLength) { | |
const arr = str.split(" ") | |
Array.from(Array(padLength).keys()).forEach(x => arr.push(" ")) | |
return arr.reverse().join().replace(/,/g, '') | |
} | |
const isArray = (x) => x.hasOwnProperty('length'); | |
const isPositiveInt = (n) => n > 0; |
import {SetStateAction, useCallback} from 'react'; | |
import {create} from "zustand"; | |
export type EqualityFn<T> = (left: T | null | undefined, right: T | null | undefined) => boolean; | |
// eslint-disable-next-line @typescript-eslint/ban-types | |
const isFunction = (fn: unknown): fn is Function => (typeof fn === 'function'); | |
/** | |
* Create a global state |
// Example: https://codepen.io/marcelo-ribeiro/pen/OJmVOyW | |
const accentsMap = new Map([ | |
["A", "Á|À|Ã|Â|Ä"], | |
["a", "á|à|ã|â|ä"], | |
["E", "É|È|Ê|Ë"], | |
["e", "é|è|ê|ë"], | |
["I", "Í|Ì|Î|Ï"], | |
["i", "í|ì|î|ï"], | |
["O", "Ó|Ò|Ô|Õ|Ö"], |
// regular version | |
let dragon = (name, size, element) => | |
name + 'is a ' + | |
size + ' dragon that breathes ' + | |
element + '!'; | |
//usage // usage dragon('zezinho', 'small', 'ice'); | |
// currying version |
const solution = (numbers) => { | |
// returns zero if no numbers are undefined | |
if (!numbers.length) { | |
return 0; | |
} | |
const length = numbers.length; | |
let current, next, largestNumber = 0; | |
const first = numbers[0]; | |
const last = numbers[length - 1]; |