This file contains hidden or 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
| type GetParams< | |
| Text extends string, | |
| Result extends string = '' | |
| > = | |
| Text extends `${ infer L }${ infer R }` | |
| ? L extends '/' | |
| ? Result | |
| : GetParams<R, `${ Result }${ L }`> | |
| : Result |
This file contains hidden or 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
| type ConcatUntil | |
| < | |
| Text extends string, | |
| Delimiter extends string, | |
| Result extends string = '' | |
| > = | |
| Text extends `${infer L}${infer R}` | |
| ? L extends Delimiter | |
| ? Result | |
| : ConcatUntil<R, `${Result}${L}` > |
This file contains hidden or 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
| <script> | |
| let twoFactor; | |
| let isCorrect = true; | |
| $: isCorrect | |
| function maybeRight() { | |
| console.log(twoFactor) | |
| Math.random() > 0.5 ? isCorrect = true : isCorrect = false; | |
| } | |
This file contains hidden or 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 ARGUMENT_NAMES = /([^\s,]+)/g; | |
| function stripeFunction(func: Function) { | |
| const fnStr = func.toString() | |
| const args = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(ARGUMENT_NAMES); | |
| const body = fnStr.slice(fnStr.indexOf('{') + 1, fnStr.lastIndexOf('}')); | |
| return { | |
| args: args || [] as string[], | |
| body: body |
This file contains hidden or 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 ARGUMENT_NAMES = /([^\s,]+)/g; | |
| function stripeFunction(func: Function) { | |
| const fnStr = func.toString() | |
| const args = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(ARGUMENT_NAMES); | |
| const body = fnStr.slice(fnStr.indexOf('{') + 1, fnStr.lastIndexOf('}')); | |
| return { | |
| args: args || [] as string[], | |
| body: body |
This file contains hidden or 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 outer(props) { | |
| const self = this; | |
| self.outer = 'outer'; | |
| function inner(props, ctx) { | |
| const self = this; | |
| self.inner = 'inner'; | |
| ctx.outer = 'outer-malucao' | |
| return { | |
| inner: self.inner, | |
| ctx: ctx.outer, |
This file contains hidden or 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 l = [...Array(100).keys()]; | |
| const fizz = (n) => (n % 3 === 0 ? "Fizz" : ""); | |
| const buzz = (n) => (n % 5 === 0 ? "Buzz" : ""); | |
| const fizzBuzzSolver = (number) => | |
| `${fizz(number)}${buzz(number)}` || "Nenhum"; | |
| l.forEach((number) => console.log(`${number}: ${fizzBuzzSolver(number)}`)); |
This file contains hidden or 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
| import type {Application} from './server' | |
| const client = () => { | |
| const call = <Args>(name: string, args: Args) => { | |
| // impl.... | |
| } | |
| return{ | |
| call | |
| } as Application | |
| } |
This file contains hidden or 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
| type Creator = | |
| <Name extends string, Args, Response> | |
| (name: Name, runner: (args: Args) => Response, subModule?: RCreator<Name, Args, Response>) => | |
| RCreator<Name, Args, Response> | |
| const createModule: Creator = (name, runner, subModule) => { | |
| return { | |
| ...subModule, |
This file contains hidden or 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
| type Numeros = ['zero', 'um', 'dois', 'tres', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove']; | |
| type Dezenas = ['','','vinte', 'trinta', 'quarenta', 'cinquenta', 'sessenta', 'setenta', 'oitenta', 'noventa']; | |
| type Cem = ['cem']; | |
| type Centenas = ['cento', 'duzentos', 'trezentos', 'quatrocentos', 'quinhentos', 'seiscentos', 'setecentos', 'oitocentos', 'novecentos']; | |
| type GetWords<Str extends string, Curr extends string = ''> = | |
| Str extends `${infer L}${infer R}` | |
| ? L extends ' ' | |
| ? Curr | |
| : GetWords<R, `${Curr}${L}`> |