Skip to main content

literal() function

Информация

ts.literal(str: string): TCustomType
  • t.literal() allows you to define a constant string value.
  • You can only pass one string into t.literal

Пример использования

index.ts
import { Serializer, t } from "encodexx"
const serializer = new Serializer({
ages: [t.or(t.uint8, t.literal("NONE"))],
status: t.literal("CREATE")
})
serializer.encode({
ages: [12, "NONE", "NONE", 124, 200],
status: "CREATE"
});