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
export type ArrayInfer<T> = T extends (infer U)[] ? U : never |
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 container = new Map() | |
const relations = new Map() | |
export const use = <T>(type: Key<T>): T => { | |
const concrete = container.get(type) | |
if (!concrete) throw `Provider ${type.name} não registrado` | |
return concrete | |
} | |
const provide = <T>({for: key, use}: For<T>) => { |
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
export const App = () => { | |
const title = "TSX Vanilla"; | |
return ( | |
<> | |
<h1>{title}</h1> | |
</> | |
); | |
}; |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<link rel="icon" type="image/svg+xml" href="/ts.svg" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Vite + TS</title> | |
<style> | |
body { | |
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; |
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
#!/bin/bash | |
pnpm create vite@latest $1 --template vanilla-ts | |
cd $1 | |
nvm use 20 | |
pnpm add three |
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
export interface IdleConfig { | |
maxIdle: number; | |
warnPeriod?: number; | |
scope?: Node; | |
} |
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 Fn<T, R> = (value: T) => R; | |
type Pipe<T, R> = [Fn<T, R>, ...Fn<R, R>[]]; | |
function pipe<T, R>(...[fn, ...fns]: Pipe<T, R>) { | |
return (value: T) => fns.reduce((p, c) => c(p), fn(value)); | |
} |
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
// Exemplo de uso: | |
of(10) | |
.pipe( | |
map((value) => value * 4), | |
filter((value) => value > 2) | |
) | |
.subscribe((value) => console.log(value)); |
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
#!/bin/sh | |
# | |
# This script should be run via curl: | |
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# or via wget: | |
# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# or via fetch: | |
# sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# | |
# As an alternative, you can first download the install script and run it afterwards: |
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
#!/bin/bash | |
# We don't need return codes for "$(command)", only stdout is needed. | |
# Allow `[[ -n "$(command)" ]]`, `func "$(command)"`, pipes, etc. | |
# shellcheck disable=SC2312 | |
set -u | |
abort() { | |
printf "%s\n" "$@" >&2 |