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
| /** | |
| * Assign to `target` all values from `default`, | |
| * if value under corresponding key in `target` is undefined or null. | |
| * | |
| * --- | |
| * | |
| * <b>Example</b> | |
| * | |
| * With given `target` type: | |
| * |
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 { useCallback, useMemo } from 'react' | |
| import { useImmer } from 'use-immer' | |
| type FnOrValue<T> = T | (() => T) | |
| type InitialValue<T> = Set<T> | T[] | |
| interface SetMethods<T> { | |
| add: (value: T) => void | |
| delete: (value: T) => void |
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
| rules: | |
| no-console: | |
| - warn | |
| - allow: [warn, error] | |
| no-unreachable: warn | |
| no-duplicate-imports: warn | |
| no-var: error | |
| prefer-const: warn |
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 | |
| npm install -D stylelint \ | |
| stylelint-config-css-modules \ | |
| stylelint-config-standard-scss | |
| npm pkg set scripts."lint:css"="stylelint \"src/**/*.{s,}css\"" |
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 id = <T>(x: T): T => x | |
| type EQ<A = unknown, B = A> = (a: A, b: B) => boolean | |
| const eq: EQ = (a, b) => a === b | |
| type Opts<A = unknown, B = A, C = unknown> = { | |
| by: (x: A | B) => C | |
| with: EQ<C> | |
| } |
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 Promised<T = unknown> = T | Promise<T> | |
| type PromisedBy<T, R> = T extends Promise<unknown> ? Promise<R> : R | |
| type Wait = <R, V>(x: Promised<V>, cb: (x: V) => R) => PromisedBy<typeof x, R> | |
| type ReduceAsync = <T, R>( | |
| fn: (memo: R, x: T) => Promised<R>, | |
| xs: Promised<T>[], | |
| seed: Promised<R> | |
| ) => Promised<R> |
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 use(promise) { | |
| if (promise.status === 'fulfilled') { | |
| return promise.value; | |
| } else if (promise.status === 'rejected') { | |
| throw promise.reason; | |
| } else if (promise.status === 'pending') { | |
| throw promise; | |
| } else { | |
| promise.status = 'pending'; | |
| promise.then( |
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 | |
| DIR=. | |
| VERBOSE=false | |
| LOG_TRANSFORM='' | |
| while getopts "d:vj" optname | |
| do | |
| case "$optname" in | |
| "d") DIR=${OPTARG} ;; | |
| "v") VERBOSE=true ;; |
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
| /** | |
| * Borrowed from {@link https://github.com/mika-go-13/janus-typescript-client/blob/c18b41ccdcb2e948829844ef0e1e2302d50accc8/index.d.ts} | |
| */ | |
| /* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any */ | |
| declare module 'janus-gateway' { | |
| declare namespace JanusJS { | |
| interface Dependencies { | |
| adapter: any |
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 React from 'react' | |
| import { useOnMount } from './effects' | |
| // --- | |
| export function useConst<T>(value: T): T { | |
| return React.useRef(value).current | |
| } |
NewerOlder