2.0.5 • Published 2 years ago

blackhole-qr v2.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

blackhole-qr

Build Status

blackhole-qr allows you to store large amounts of characters or JSON objects in a QR code. using (CBOR, PAKO, HEX). compresses up to 96% of the size.

  • CBOR ( for generate an Uint8Array)
  • PAKO ( for compress Uint8Array, very fast )
  • QRIOUS ( high quality QR library )
  • HEX (Buffer.from(_).toString('hex' )

Features

  • INPUT 30.811 Length
  • OUTPUT 1856 Length
  • RESULT -> 93.98 % Less
  • It takes a value and converts it to QR.
  • The Qr is generated in a canva.
  • Allows to compress large amounts of characters and reduce their size by 80-90%

Usage

npm i blackhole-qr
  1. Create an canvas
 <canvas id="qr"></canvas>
  1. Import module
import { Blackhole }from 'blackhole-qr'
  1. Class instance (canvas, value, qr_size)
     const QR = new Blackhole()
      QR.generate('qr', 'value_to_QR', 300)
  1. Change QR parameters (optional)
     const QR = new Blackhole()
      QR.generate('qr', 'value', 300)
      QR.set.size = 500;
      QR.set.background = 'green';
      QR.set.backgroundAlpha = 0.8;
      QR.set.foreground = 'blue';
      QR.set.foregroundAlpha = 0.8;
      QR.set.level = 'L';
      QR.set.padding = 25;
      QR.set.value = 'https://github.com/neocotic/qrious';
  1. Test
    generateRamdomJSON() {
      let beforeEncodeProcess = [];
      let result = "";
      let characters =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
      let charactersLength = characters.length;
      for (let i = 0; i < 1000; i++) {
        result += characters.charAt(
          Math.floor(Math.random() * charactersLength)
        );
      }

      for (let d = 0; d < 30; d++) {
        beforeEncodeProcess.push({ answer: 5, textarea: result });
      }

      console.log(JSON.stringify(beforeEncodeProcess).length);
      const QR = new Blackhole();
      QR.generate("qr", beforeEncodeProcess, 300);
      console.log(QR.cborHex.length);
    }

INPUT 30.811 Length OUTPUT 1856 Length RESULT -> 93.98 % Less

6.DECODE

     QR.decode()
     QR.decodeByValue('QR.cborHex')

7.ENCODE by value

     QR.encodeByValue('data')

License

MIT https://github.com/Kraphene

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago