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://developer.mozilla.org/en-US/docs/Web/HTTP/Status */ | |
export type HttpStatusCode = Information | Successful | Redirection | ClientError | ServerError; | |
/** https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#information_responses */ | |
export enum Information { | |
/** This interim response indicates that the client should continue the request or ignore the response if the request is already finished. */ | |
Continue = 100, | |
/** This code is sent in response to an Upgrade request header from the client and indicates the protocol the server is switching to. */ | |
SwitchingProtocols = 101, |
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
/** | |
* An array of mutable key-value pairs from an object, including optional keys. | |
* | |
* @see {@linkcode ReadonlyEntries} for a readonly version. | |
* | |
* @example | |
* | |
* ```ts | |
* Entries<{ a: number, b: string }> | |
* // => (["a", number] | ["b", string])[] |
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
/** | |
* Returns the result of calling the function (if it is a function) or the value itself. | |
* | |
* @example | |
* | |
* ```ts | |
* callable(() => true) | |
* // => true | |
* | |
* callable(false) |
- No loops
- No IF statements
- Functions are a single return
- No side effects
- No assignment in functions
- No arrays
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 { fromEvent, pipe } = Rx; | |
const { scan, throttleTime } = RxOperators; | |
const tick = () => scan(next => next + 1, 0); | |
const throttled = () => throttleTime(500); | |
const paced = () => pipe(throttled(), tick()); | |
fromEvent(document, 'click').pipe(paced()); |
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 const environment = (...features: ReadonlyArray<Record<string, unknown>>) => ({ | |
redirectTo: { | |
pwa: 'http://localhost:8100', | |
}, | |
...features.reduce((acc, next) => ({ ...acc, ...next}), {}) | |
} as const); | |
// environment(withFoo(), withBar(), ...) |
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 range = ({ min = 0, max = 10, step = 1}): number[] => { | |
return min > max ? [] : [min, ...range({ min: min + 1, max, step})].filter(item => item % step === 0); | |
} |
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 backoff = (config?: { readonly scale?: number; readonly count?: number; }): readonly number[] => { | |
return [...Array(config?.count ?? 4).keys()].map(item => 2 ** item * (config?.scale ?? 1)); | |
} | |
const backoff$ = (config?: { readonly delay?: number; readonly count?: number; readonly scale?: number;}) => { | |
return from([...Array(config?.count ?? 4).keys()]).pipe( | |
concatMap(next => timer((config?.scale ?? 2) ** next * (config?.delay ?? 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
TypeScript Type Definitions Files |
NewerOlder