Codibre/fluent-iterable

View on GitHub
src/recipes/take-recipe.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { AnyIterable } from 'augmentative-iterable';
import { Ingredient } from './ingredients';

export function takeRecipe(takeWhile: Ingredient) {
  return function <T>(this: AnyIterable<T>, n: number) {
    let counter = 0;
    return takeWhile.call(this, () => counter++ < n);
  };
}