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 { | |
ChangeDetectionStrategy, | |
Component, | |
Injectable, | |
Signal, | |
inject, | |
viewChild, | |
} from '@angular/core'; | |
import { toObservable, toSignal } from '@angular/core/rxjs-interop'; | |
import { |
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
/** | |
* Prefix every property of the type with the given name. | |
* Ignores properties with non-string names. | |
*/ | |
export type NamedObject<Name extends string, T> = { | |
[K in keyof T as `${Name}${K extends string ? Capitalize<K> : never}`]: T[K]; | |
}; | |
type KeySuffix = '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
Either<Exception, string?>[] eithers = | |
[ | |
new Either<Exception, string?>.Right("Text"), | |
new Either<Exception, string?>.Right(null), | |
new Either<Exception, string?>.Left(new Exception("Oops!")), | |
]; | |
var TryStringLength = EitherExtensions.TryInvoke<string?, int>(LegacyFunctions.StringLength); | |
foreach (var either in eithers) |
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 { Directive, HostBinding, Input, NgModule } from "@angular/core"; | |
export type BsFlexDirectionType = "row" | "row-reverse" | "column" | "column-reverse"; | |
export type BsFlexWrapType = "nowrap" | "wrap" | "wrap-reverse"; | |
export type BsFlexDirectionWrapType = "" | `${BsFlexDirectionType}` | `${BsFlexDirectionType} ${BsFlexWrapType}`; | |
export type BsFlexJustifyContentType = | |
| "" |
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 { Observable, BehaviorSubject, Subject, Subscription, queueScheduler } from "rxjs"; | |
import { distinctUntilChanged, map, observeOn, scan, shareReplay, takeUntil, tap } from "rxjs/operators"; | |
export type BsStoreAction<TState> = (lastState: TState) => TState; | |
export type BsStoreDispatcher<TState> = (...actions: BsStoreAction<TState>[]) => void; | |
export type BsStoreSelector<TState> = <R>(projection: (state: TState) => R) => Observable<R>; | |
export type BsStoreEffect<TState> = Observable<BsStoreAction<TState>>; |
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
using System.Threading.Channels; | |
var uberQueue = new UberQueue<string>(Enumerable | |
.Range(0, 10) | |
.Select(queueIndex => new RandomDelayQueue(queueIndex)) | |
.ToArray()); | |
var uberQueueConsumers = Enumerable | |
.Range(0, 3) | |
.Select(consumerIndex => Task.Run(async () => |