MCPcopy Create free account
hub / github.com/effect-app/libs / ReadonlySetFromArray

Function ReadonlySetFromArray

packages/effect-app/src/Schema/ext.ts:291–306  ·  view source on GitHub ↗
(value: ValueSchema)

Source from the content-addressed store, hash-verified

289 * An annotated `S.Array` of unique items that decodes to a `ReadonlySet`.
290 */
291export const ReadonlySetFromArray = <ValueSchema extends S.Top>(value: ValueSchema) => {
292 const from = S
293 .Array(value)
294 .annotate({ ...concurrencyUnbounded, expected: "an array of unique items that will be decoded as a ReadonlySet" })
295 const to = S.instanceOf(Set) as S.instanceOf<ReadonlySet<ValueSchema["Type"]>>
296 const schema = from.pipe(
297 S.decodeTo(
298 to,
299 SchemaTransformation.transform({
300 decode: (arr) => new Set(arr) as ReadonlySet<ValueSchema["Type"]>,
301 encode: (set) => [...set]
302 })
303 )
304 )
305 return schema
306}
307
308/**
309 * An annotated `S.Array` of key-value tuples that decodes to a `ReadonlyMap`.

Callers 1

ReadonlySetFunction · 0.85

Calls 3

annotateMethod · 0.65
pipeMethod · 0.65
transformMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…