Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Last active October 10, 2017 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattpodwysocki/8b705e6f9dd1c7686ad7cd8c6b5de117 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/8b705e6f9dd1c7686ad7cd8c6b5de117 to your computer and use it in GitHub Desktop.
import { OperatorAsyncFunction } from '../../interfaces';
import { AsyncIterableX } from '../../asynciterable';
import { BufferAsyncIterable } from '../buffer';
export function buffer<TSource>(
count: number,
skip?: number): OperatorAsyncFunction<TSource, TSource[]> {
if (skip == null) { skip = count; }
return function bufferCountOperatorFunction(source: AsyncIterable<TSource>): AsyncIterableX<TSource[]> {
return new BufferAsyncIterable<TSource>(source, count, skip!);
};
}
import { IterableX } from './iterable';
import { AsyncIterableX } from './asynciterable';
export type UnaryFunction<T, R> = (source: T) => R;
export type OperatorFunction<T, R> = UnaryFunction<Iterable<T>, IterableX<R>>;
export type OperatorAsyncFunction<T, R> = UnaryFunction<AsyncIterable<T>, AsyncIterableX<R>>;
export type FactoryOrValue<T> = T | (() => T);
export type MonoTypeOperatorFunction<T> = OperatorFunction<T, T>;
export type MonoTypeOperatorAsyncFunction<T> = OperatorAsyncFunction<T, T>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment