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> = Partial<{ | |
[key in keyof T]: DeepPartial<T[key]> | ((obj: T[key]) => boolean) | |
}> | ((obj: T) => boolean); | |
type MatchHandlerFunc<T> = (obj: T) => void; | |
interface IMatch<T> { | |
when (matchObj: DeepPartial<T>, cb?: MatchHandlerFunc<T>): IMatch<T>; | |
default (cb: MatchHandlerFunc<T>): IMatch<T>; | |
evaluate (): 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
/****************Data model type***************/ | |
interface Endpoint< | |
T_Path extends string = string, | |
> { | |
path: T_Path | |
} | |
// Examples |
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 MaybeAbortablePromise<T> = AbortablePromise<T> | Promise<T>; | |
export class AbortablePromise<T> implements PromiseLike<T> { | |
readonly promise: Promise<T>; | |
readonly abortController: AbortController; | |
static resolve<T>(value: T, abortController?: AbortController): AbortablePromise<T>; | |
static resolve(abortController?: AbortController): AbortablePromise<void>; | |
static resolve<T>(value: T | undefined, abortController: AbortController = new AbortController()) { | |
return new AbortablePromise(Promise.resolve(value), abortController) |
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 CompareNumbers< | |
T extends number, | |
U extends number, | |
A extends any[] = [], | |
> = T extends U | |
? 0 : A['length'] extends T | |
? -1 | |
: A['length'] extends U | |
? 1 | |
: CompareNumbers<T, U, ['a', ...A]> |
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
/** | |
* Exposes internal promise methods on the class that resolves a result of type T | |
*/ | |
abstract class PromiseBuilder<T> implements Promise<T> { | |
/** | |
* Result to be returned when builder is resolved | |
*/ | |
protected abstract _fetchResult(): Promise<T> |
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
/** | |
* The purpose of this decorator is to re-assign the default value when the incoming value is null or undefined. | |
* This can be modified to ignore null or undefined as an incoming value. | |
*/ | |
type UseDefaultOptions = { | |
whenNull?: boolean; | |
whenUndefined?: boolean; | |
}; |
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
npm r -g $(node -e "console.log(process.argv.filter((e) => e !== '├──' && e !== '└──').filter((_, i) => i > 1).map((e) => e.split('@')[0]).filter((e) => e !== 'npm').join(' '))" $(npm list -g -depth 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
// | |
// BTOTransparentViewController.m | |
// | |
// Created by Brian Olencki on 10/31/17. | |
// | |
#import "BTOTransparentViewController.h" | |
@interface BTOTransparentViewController () |
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
/* | |
Valid password condition: | |
• At least 8 characters long | |
• At least one upper-case letter | |
• At least one lower-case letter | |
• At least one numeric digit | |
*/ | |
((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])){8,} |
NewerOlder