keichi / binary-parser

A blazing-fast declarative parser builder for binary data
MIT License
857 stars 133 forks source link

Old array of strings work around no longer works due to typing #245

Closed eprincen2 closed 10 months ago

eprincen2 commented 10 months ago

This used to be a solution to getting a simple array of strings rather than an array of objects containing strings.

.array("names",
{
    length: 3,
    type: new Parser().string("", { zeroTerminated: true }),
    formatter: arr => arr.map((item: { name: string }) => item.name)
})

It lo longer works since the formatter is now typed this way:

type Data = number | string | Array<number | Parser> | Parser | Buffer; formatter?: ((value: Data) => any) | undefined;

Do we have a new way to do this, or is there a plan to have a way to parse null terminated stings into a simple array?

eprincen2 commented 10 months ago

My issue. VSCode recommended installing @types/binary-parser and that is there the bad types came from.