Codibre/fluent-iterable

View on GitHub
src/sync/distinct.ts

Summary

Maintainability
A
50 mins
Test Coverage
A
100%
import { basic } from './basic-ingredients';
import { distinctRecipe } from '../recipes';
import { all } from './all';
import { filter } from './filter';
import { hasLessOrExactly } from './has-less-or-exactly';
import { partition } from './partition';
import { reduce } from './reduce';
import { Ingredient, ResolverIngredient } from '../recipes/ingredients';

function distinctSyncRecipe(filterOrAll: Ingredient | ResolverIngredient) {
  return distinctRecipe({
    ...basic,
    partition,
    filterOrAll,
    hasLessOrExactly,
    reduce,
  });
}

export const distinct = distinctSyncRecipe(filter);
export const isDistinct = distinctSyncRecipe(all);