MCPcopy Create free account
hub / github.com/Effect-TS/effect / isUniqueKey

Function isUniqueKey

packages/effect/src/Schema.ts:9159–9174  ·  view source on GitHub ↗
(annotations?: Annotations.Filter)

Source from the content-addressed store, hash-verified

9157 * @since 4.0.0
9158 */
9159export function isUniqueKey<Key, Value>(annotations?: Annotations.Filter) {
9160 return makeFilter<ReadonlyArray<readonly [Key, Value]>>(
9161 (input) => Arr.dedupe(input.map(([key]) => key)).length === input.length,
9162 {
9163 expected: "an array with unique keys",
9164 representation: {
9165 id: "effect/schema/isUniqueKey",
9166 payload: null
9167 },
9168 arbitraryConstraint: {
9169 uniqueBy: (entry: readonly [Key, Value]) => entry[0]
9170 },
9171 ...annotations
9172 }
9173 )
9174}
9175/**
9176 * Type-level representation of {@link NonEmptyString}.
9177 *

Callers 1

HashMapFunction · 0.85

Calls 2

makeFilterFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected