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
// https://github.com/microsoft/TypeScript/issues/27024 | |
export type Equals<X, Y> = | |
(<T>() => T extends X ? 1 : 2) extends | |
(<T>() => T extends Y ? 1 : 2) ? true : false; |
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
git checkout yourBranch | |
git reset $(git merge-base main $(git branch --show-current)) | |
git add -A | |
git commit -m "one commit on yourBranch" |
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
export type Pipeline = (env: PipelineEnv, next: () => Promise<void>) => Promise<void>; | |
const runPipeline = (pipelines: Pipeline[]) => { | |
return (env: PipelineEnv, next?: Pipeline): Promise<void> => { | |
let index = -1; | |
const dispatch = (i: number): Promise<void> => { | |
if (i <= index) return Promise.reject(new Error('next() called multiple times')); | |
index = i; | |
let fn = pipelines[i]; | |
if (i === pipelines.length) fn = next; |
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
type Many<T> = T | ReadonlyArray<T>; | |
interface Flow { | |
flow<A extends any[], R1, R2, R3, R4, R5, R6, R7>( | |
f1: (...args: A) => R1, | |
f2: (a: R1) => R2, | |
f3: (a: R2) => R3, | |
f4: (a: R3) => R4, | |
f5: (a: R4) => R5, | |
f6: (a: R5) => R6, |
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
type RemoveNever<T> = { [P in keyof T as T[P] extends Function ? P : never]: T[P] }; | |
type A_Methods = RemoveNever<A>; // { render: () => void; } |
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
export type TRequiredKeys<T, keys extends keyof T = keyof T> = | |
Pick<T, Exclude<keyof T, keys>> & { | |
[K in keys]-?: Required<Pick<T, K>> | |
}[keys]; |
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
{-# LANGUAGE TemplateHaskell #-} | |
module TH | |
( embedFile ) | |
where | |
import Data.String (IsString (..)) | |
import Language.Haskell.TH | |
import Language.Haskell.TH.Syntax |
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
const http = require('http') | |
const url = require('url') | |
const path = require('path') | |
const fs = require('fs') | |
const mime = { | |
"html": "text/html", | |
"css": "text/css", | |
"js": "text/javascript", | |
"json": "application/json", | |
"gif": "image/gif", |
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
class Register { | |
constructor() { | |
this.routes = [] | |
} | |
regist(obj, k, fn) { | |
const _i = this.routes.find(function(el) { | |
if((el.key === k || el.key.toString() === k.toString()) | |
&& Object.is(el.obj, obj)) { | |
return el |