Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Envelop big blob of data into frames that can be displayed in series of QR Codes
Envelop big blob of data into frames that can be displayed in series of QR Codes.
NB. this library is generic enough to not even be used with QR Codes but still take optimization decision in regard to how QR code works and from empirical tests.
yarn add qrloop
yarn add qrloop
yarn add buffer # required
There are 2 parts of the library, the "exporter" that want to export the data via QR codes and the "importer" that will scan these QR codes and accumulate the frames until it reaches the final result.
The exporter only have 1 function to use: dataToFrames
.
import { dataToFrames } from "qrloop/exporter";
// examples
const frames: string[] = dataToFrames("hello world");
const frames = dataToFrames(Buffer.from([ 0x00, 0x01, ... ]));
const frames = dataToFrames(data, 140, 2);
// dataToFrames( data[, dataSize, replicas ])
// data: the complete data to encode in a series of QR code frames
// dataSize: the number of bytes to use from data for each frame
// replicas: (>= 1) the total number of loops to repeat the frames with varying a nonce. More there is, better the chance to not be stuck on a frame. Experience has shown some QR Code are harder to read.
You can find an implementation example in examples/web-text-exporter
.
There are a few functions you can use to be able to consume and accumulate the frames over time.
The main function is parseFramesReducer
that you feed with each QR Code data and will accumulate a state. Consider that state a black box and prefer using the utility functions to extract out information.
import {
parseFramesReducer,
areFramesComplete,
framesToData,
progressOfFrames
} from "qrloop/importer";
const onResult = finalResult => console.log({ finalResult });
let frames = null;
const onBarCodeScanned = (data: string) => {
try {
frames = parseFramesReducer(frames, data);
if (areFramesComplete(frames)) {
onResult(framesToData(frames).toString());
} else {
console.log("Progress:", progressOfFrames(frames));
}
} catch (e) {
console.warn(e); // a qrcode might fail. maybe the data is corrupted or you scan something that is not relevant.
}
};
You can find an implementation example in examples/rn-text-importer
.
FAQs
Envelop big blob of data into frames that can be displayed in series of QR Codes
The npm package qrloop receives a total of 1,114 weekly downloads. As such, qrloop popularity was classified as popular.
We found that qrloop demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.