kazuemon / asn1

TypeScript friendly ASN.1 schema definition, encoding and decoding library
MIT License
1 stars 0 forks source link

v0.1 #1

Closed kazuemon closed 5 months ago

kazuemon commented 9 months ago
kazuemon commented 9 months ago

📔 Note: Choice Usecase

Define schema

const schema = choice({
  elements: {
    hello: integer({
      tagClass: TagClass.CONTEXT_SPECIFIC,
      tagType: 0,
    }),
    world: octetString({
      tagClass: TagClass.CONTEXT_SPECIFIC,
      tagType: 1,
    }),
  },
});

TS Type

type t1 =
| {
    hello: number
  }
| {
    world: string
  }