@qifi/generate
v0.1.0
Published
Stream Generated QR Codes for data transmission
Downloads
54
Readme
@qifi/generate
Stream Generated QR Codes for data transmission
Sponsors
Usage
import {
createGeneraterANSI,
createGeneraterUnicode,
createGeneraterUnicodeCompact,
createGeneraterSVG,
createGeneraterQRCodeArray,
} from '@qifi/generate'
const generaterSvg = createGeneraterSVG(new Uint8Array(file.buffer))
const generaterANSI = createGeneraterANSI(new Uint8Array(file.buffer), {
// Size of each data slice
sliceSize: 250,
// Error correction level
ecc: 'L',
// Border width
border: 2,
})
// display QR Code in terminal
for (const blockQRCode of generaterANSI.fountain()) {
console.log(blockQRCode)
}
With meta data
If you want to transfer the metadata of the file:
import {
appendFileHeaderMetaToBuffer,
readFileHeaderMetaFromBuffer,
} from '@qifi/generate'
const data = new Uint8Array(file.buffer)
const meta = {
filename: file.name,
contentType: file.type,
}
const merged = appendFileHeaderMetaToBuffer(data, meta)
const generater = createGeneraterUnicode(merged)
// Send blocks to the receiver
for (const block of generater.fountain()) {
// display QR Code in terminal
console.log(blockQRCode)
}
and you can use appendMetaToBuffer
and readMetaFromBuffer
to add and read custom metadata.