MCPcopy
hub / github.com/Effect-TS/effect / headNonEmpty

Function headNonEmpty

packages/effect/src/Schema.ts:6556–6568  ·  view source on GitHub ↗
(
  self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
)

Source from the content-addressed store, hash-verified

6554 * @since 3.12.0
6555 */
6556export function headNonEmpty<S extends Schema.Any, A extends array_.NonEmptyReadonlyArray<unknown>>(
6557 self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
6558): transform<S, SchemaClass<A[number]>> {
6559 return transform(
6560 self,
6561 getNumberIndexedAccess(typeSchema(self)),
6562 {
6563 strict: false,
6564 decode: (i) => array_.headNonEmpty(i),
6565 encode: (a) => array_.of(a)
6566 }
6567 )
6568}
6569
6570/**
6571 * Retrieves the first element of a `ReadonlyArray`.

Callers 2

Array.tsFile · 0.85
unprependFunction · 0.85

Calls 4

typeSchemaFunction · 0.85
transformInterface · 0.70
getNumberIndexedAccessFunction · 0.70
ofMethod · 0.65

Tested by

no test coverage detected