File size: 383 Bytes
4327358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// eslint-disable-next-line @typescript-eslint/no-var-requires
const QRCode = require('qrcode');

export class QR {
  public raw?: string;

  save(raw?: string) {
    this.raw = raw;
  }

  async get(): Promise<Buffer> {
    const url = await QRCode.toDataURL(this.raw);
    const base64 = url.replace(/^data:image\/png;base64,/, '');
    return Buffer.from(base64, 'base64');
  }
}