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
Options: | |
--abort-on-contradictory-flags (Disallow flags or implications overriding each other.) | |
type: bool default: true | |
--allow-overwriting-for-next-flag (temporary disable flag contradiction to allow overwriting just the next flag) | |
type: bool default: false | |
--use-strict (enforce strict mode) | |
type: bool default: false | |
--harmony (enable all completed harmony features) | |
type: bool default: false | |
--harmony-shipping (enable all shipped harmony features) |
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
Options: | |
--abort-on-contradictory-flags (Disallow flags or implications overriding each other.) | |
type: bool default: true | |
--allow-overwriting-for-next-flag (temporary disable flag contradiction to allow overwriting just the next flag) | |
type: bool default: false | |
--use-strict (enforce strict mode) | |
type: bool default: false | |
--harmony (enable all completed harmony features) | |
type: bool default: false | |
--harmony-shipping (enable all shipped harmony features) |
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
[alias] | |
acp = "!f() { git add . && git commit -m \"$1\" && git push; }; f" |
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
// At least one property | |
type AtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & { | |
[K in Keys]-?: Required<Pick<T, K>> | |
}[Keys] | |
type PerformanceBudget = AtLeastOne<{ fcp: number, lcp: number }> | |
// Typed Key |
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 DeepPartial<T> = { | |
[P in keyof T]?: T[P] extends Array<infer U> | |
? Array<DeepPartial<U>> | |
: T[P] extends ReadonlyArray<infer U> | |
? ReadonlyArray<DeepPartial<U>> | |
: DeepPartial<T[P]>; | |
}; | |
// Credits goes to the https://stackoverflow.com/! |
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
import { FC, createContext } from "react"; | |
// Service locator: | |
interface IService { | |
test: () => string; | |
} | |
type ServiceLocator = { | |
myTestService: IService; |
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 { readFileSync } = require("fs"); | |
const rawData = readFileSync('./data.json'); | |
const data = JSON.parse(rawData); | |
const res = data | |
.filter(x => x.args?.data?.renderBlocking) | |
.map(x => ({ | |
timestamp: new Date(x.ts), | |
url: x.args.data.url, | |
priority: x.args.data.priority, |
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 User = { name: string }; | |
type MyModel = { | |
name: string; | |
users: User[]; | |
} | |
type OnlyArrays<TModel> = Exclude<{ [key in keyof TModel]?: TModel[key] extends any[] ? key : never }[keyof TModel], undefined>; | |
type Numbers = '0' | '1' | '2' | '3' | '4' | '5'; | |
type StringKeyof<TModel> = keyof TModel extends string ? keyof TModel : never; |
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 function pipe<I, R1, R>(f1: (a: I) => R1, f2: (a: R1) => R): (a: I) => R; | |
export function pipe<I, I1, R1, R>(f1: (a: I, b: I1) => R1, f2: (a: R1) => R): (a: I, b: I1) => R; | |
export function pipe<I, R1, R2, R>( | |
f1: (a: I) => R1, | |
f2: (a: R1) => R2, | |
f3: (a: R2) => R | |
): (a: I) => R; | |
export function pipe<I, I1, R1, R2, R>( | |
f1: (a: I, b?: I1) => R1, | |
f2: (a: R1) => R2, |
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 IStateMachine<TState,TEvent, TPayload = {}> { | |
getState():TState; | |
dispatch(event: TEvent, payload?: TPayload): IStateMachine<TState,TEvent, TPayload>; | |
} | |
type MyEvent = 'start' | 'move' | 'stop'; | |
type MyState = {speed: number, isHealthy: boolean}; | |
class MyStateMachine implements IStateMachine<MyState, MyEvent> { | |
constructor(private _state: MyState, private readonly _reaction: Record<MyEvent,(state:MyState)=> MyState>){} |