Skip to main content

enumerate() Function

Information

ts.enumerate(...strs: string[]): TCustomType
  • t.enumerate() allows you to enumerate strings and serialize them compactly.
  • t.enumerate() accepts no more than 255 arguments.
  • You can only pass strings to t.enumerate.

Example Usage

index.ts
import { Serializer, t } from "encodexx"
const serializer = new Serializer({
ages: [t.or(t.uint8, t.enumerate("DEAD", "NOT BORN"))],
status: t.enumerate("CREATE", "READ", "UPDATE", "DELETE")
})
serializer.encode({
ages: [12, "DEAD", "NOT BORN", 124, 200],
status: "READ"
});