Proposal to Add NonEmptyArrayFromSingleton Function

Would it be useful to add the following:

export const NonEmptyArrayFromSingleton = <A, I, R>(
  value: Schema.Schema<A, I, R>,
) =>
  Schema.transform(
    value,
    Schema.NonEmptyArray(Schema.typeSchema(value)),
    {
      decode: x => [x] as const,
      encode: ([x]) => x,
    },
  )
Was this page helpful?