Closed sant123 closed 3 months ago
Hi !
Unless I misunderstood, I think you can already do something like this:
import { readAll, Buffer } from "jsr:@std/io"
import { qrcode } from "jsr:@libs/qrcode"
const buffer = new Buffer(new TextEncoder().encode("HELLO")) // For example, but assuming you already have a buffer
console.log(qrcode(new TextDecoder().decode(await readAll(buffer)), {output:"console"}))
I feel like TextDecoder.decode
+ readAll
is not so bad, but depending on use case if it's frequent/convenient enough I might add support for it
I see, well looking at qrcodegen.ts from nayuki got my attention encodeBinary is supported. For my use case would not look so bad but may be extra performance that can be saved using this directly instead? It would be nice that the same method nayuki supports be supported in this library.
Anyway this is a great work @lowlighter !!
I've added Uint8Array
as direct input (which is basically the same as nayuki's Array<byte>
since type byte = number
,
I don't think it'll increase performance by a lot since QR codes have a maximum size of ~3000 bytes, but at least it'll avoid indeed having to perform multiple encode/decode operations just to get the correct typing which is still nice
Thanks for your suggestion and support !
Thank you so much, I really appreciate it 😁
Hi, I’m curious if will be support for transforming buffers to qr code? Currently it supports strings or URL only.
Thanks!!