( self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>> )
| 6530 | * @since 3.10.0 |
| 6531 | */ |
| 6532 | export function head<S extends Schema.Any, A extends ReadonlyArray<unknown>>( |
| 6533 | self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>> |
| 6534 | ): transform<S, OptionFromSelf<SchemaClass<A[number]>>> { |
| 6535 | return transform( |
| 6536 | self, |
| 6537 | OptionFromSelf(getNumberIndexedAccess(typeSchema(self))), |
| 6538 | { |
| 6539 | strict: false, |
| 6540 | decode: (i) => array_.head(i), |
| 6541 | encode: (a) => |
| 6542 | option_.match(a, { |
| 6543 | onNone: () => [], |
| 6544 | onSome: array_.of |
| 6545 | }) |
| 6546 | } |
| 6547 | ) |
| 6548 | } |
| 6549 | |
| 6550 | /** |
| 6551 | * Get the first element of a `NonEmptyReadonlyArray`. |
no test coverage detected