This file contains hidden or 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 { ReduceOptions } from './reduceoptions'; | |
| import { wrapWithAbort } from './operators/withabort'; | |
| export async function reduce<T, R = T>( | |
| source: AsyncIterable<T>, | |
| options: ReduceOptions<T, R> | |
| ): Promise<R> { | |
| const { seed, signal, callback } = options; | |
| const hasSeed = options.hasOwnProperty('seed'); | |
| let i = 0; |
This file contains hidden or 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 { AbortError } from '../aborterror'; | |
| export function sleep(dueTime: number, signal?: AbortSignal) { | |
| return new Promise<void>((resolve, reject) => { | |
| if (signal?.aborted) { | |
| reject(new AbortError()); | |
| } | |
| const id = setTimeout(() => { | |
| if (signal?.aborted) { |
This file contains hidden or 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 class AbortError extends Error { | |
| constructor() { | |
| super(); | |
| Object.setPrototypeOf(this, AbortError.prototype); | |
| this.message = 'The operation has been aborted'; | |
| } | |
| } | |
| export function throwIfAborted(signal?: AbortSignal) { | |
| if (signal?.aborted) { |
This file contains hidden or 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
| // New Way | |
| export function orderBy<TSource>( | |
| key: keyof TSource | |
| ): UnaryFunction<AsyncIterable<TSource>, OrderedAsyncIterableX<TKey, TSource>> { | |
| return function orderByOperatorFunction(source: AsyncIterable<TSource>) { | |
| return new OrderedAsyncIterableX<TSource>(source, key, false); | |
| }; | |
| } | |
| // Old way |
This file contains hidden or 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 interface GroupByOptions<TSource, TKey, TValue = TSource> { | |
| keySelector: (value: TSource) => TKey | Promise<TKey>; | |
| elementSelector?: (value: TSource) => TValue | Promise<TValue>; | |
| signal?: AbortSignal; | |
| } | |
| export interface GroupByOptionsWithSelector<TSource, TKey, TValue, TResult> { | |
| keySelector: (value: TSource) => TKey | Promise<TKey>; | |
| elementSelector?: (value: TSource) => TValue | Promise<TValue>; | |
| resultSelector?: ( |
This file contains hidden or 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 { AbortError } from "../util/aborterror"; | |
| export function delay(action: () => void, dueTime: number, signal?: AbortSignal) { | |
| return new Promise((resolve, reject) => { | |
| if (signal?.aborted) { | |
| throw new AbortError(); | |
| } | |
| const id = setTimeout(() => { | |
| if (signal?.aborted) { |
This file contains hidden or 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 { AsyncIterableX } from '../asynciterablex'; | |
| import { OperatorAsyncFunction } from '../../interfaces'; | |
| import { wrapWithAbort } from './withabort'; | |
| export class ConcatAllAsyncIterable<TSource> extends AsyncIterableX<TSource> { | |
| private _source: AsyncIterable<AsyncIterable<TSource>>; | |
| private _signal?: AbortSignal; | |
| constructor(source: AsyncIterable<AsyncIterable<TSource>>, signal?: AbortSignal) { | |
| super(); |
This file contains hidden or 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
| function Get-Files($path = $pwd) { | |
| foreach ($item in Get-ChildItem $path) { | |
| if (Test-Path $item.FullName -PathType Container) { | |
| Get-Files $item.FullName | |
| } else { | |
| $item | |
| } | |
| } | |
| } |
This file contains hidden or 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 move$ = fromEvent(document, 'mousemove') | |
| const down$ = fromEvent(document, 'mousedown') | |
| const up$ = fromEvent(document, 'mouseup') | |
| const mergeFn = downs => { // In case you want the first position | |
| // If you want to deltas between start and end, you might want a map that captures downs versus moves | |
| return move$.pipe(takeUntil($ups)); | |
| }; | |
| const paints$ = move$.pipe( |
This file contains hidden or 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; | |
| using System.Collections.Generic; | |
| using System.ComponentModel.DataAnnotations.Schema; | |
| using System.Data; | |
| using System.Linq; | |
| using System.Linq.Expressions; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using Microsoft.EntityFrameworkCore; | |
| using Microsoft.EntityFrameworkCore.Infrastructure; |