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
.grid-container { | |
$max-columns: 6; | |
& { | |
--gap: 0.5rem; | |
--columns: 6; | |
--row-height: 400px; | |
box-sizing: border-box; | |
padding: var(--gap); |
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 createLoader(text: string) { | |
const encoder = new TextEncoder(); | |
const icons = ["[ ]", "[# ]", "[## ]", "[###]"]; | |
let state = 0; | |
const loader = setInterval(() => { | |
Deno.stdout.writeSync(encoder.encode(`\r${icons[state++]} ${text}`)); | |
state %= 4; | |
}, 500); |
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 watch<T extends Record<string | symbol, unknown>>(obj: Record<string | symbol, unknown>): T & { $changes: string[] } { | |
const cache: Record<string | symbol, unknown> = Object.create(null); | |
Object.defineProperty(obj, "$changes", { get: () => cache }); | |
return new Proxy(obj, { | |
set: function(target, key, value) { | |
if (key !== "$changes") { | |
target[key] = value; | |
if (value !== undefined) cache[key] = value; | |
} |
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
/** Holds a bunch of something. */ | |
export class Collection<K, V> extends Map<K, V> { | |
/** | |
* Returns first item that meet the condition specified in your filter function. | |
* Identical in behavior to [Array#find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find). | |
* */ | |
find(fn: (value: V) => boolean) { | |
const iter = this.values(); | |
for (const value of iter) { | |
if (fn(value)) return value; |
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
interface Event<T> { | |
once?: boolean; | |
fn: T[keyof T]; | |
} | |
// deno-lint-ignore no-explicit-any | |
type Arguments<T> = [T] extends [(...args: infer U) => any] ? U : [T] extends [void] ? [] : [T]; | |
/** Strictly typed, fast Event Emitter. */ | |
export class Emitter<T> { |