npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mediacomem/biosentiers-qrcode

v2.1.2

Published

QR code binary format parser/serializer for BioSentiers

Downloads

15

Readme

BioSentiers QR Code

QR code binary format parser/serializer for BioSentiers.

This library can encode and decode QR code data for the BioSentiers application.

Encoding transforms an object into a byte array or other formats (see options):

var encoded = bioqr.encode({
  version: 1,
  excursion: {
    creatorName: 'Räksmörgås º¬∆',
    id: 'x728s',
    date: moment().milliseconds(0).toDate(),
    name: 'ジ エクスクルシオン',
    participant: {
      id: 'f8',
      name: 'Bob',
    },
    themes: ['bird', 'flower'],
    zones: [1, 3]
  }
});

Decoding transforms the encoded data back into the original object:

var decoded = bioqr.decode(encoded);
console.log(decoded.creatorName); // Räksmörgås

The encoded data can be used in a QR code in binary format.

Options

An options object can be passed to encode or decode as the second argument. The following options are available:

  • format - String - Customize the output format

    bioqr.encode(data); // [ 0x01, 0x87, 0x18, 0xC0, ... ] (raw byte array)
    bioqr.encode(data, { format: 'numeric' }); // "430981398715409183..." (for a numeric QR code)
    bioqr.encode(data, { format: 'string' }) // "\u0001\u0087\u0018\u00C0..." (8-bit string)

    The same format option must be given for decoding.

  • themes - Array|Function - An array of reference values or function to encode/decode the themes bitmask

    // Assuming the bitmask value is 3 (00000011 in binary),
    // so the first two indices (0 and 1) are active
    bioqr.decode(data, { themes: [ 'foo', 'bar', 'baz' ] }).excursion.themes; // [ 'foo', 'bar' ]
    bioqr.decode(data, { themes: (i) => i * 2 }).excursion.themes; // [ 0, 2 ]
  • zones - Array|Function - An array of reference values or function to encode/decode the zones bitmask

    // Assuming the bitmask value is 3 (00000011 in binary),
    // so the first two indices (0 and 1) are active
    bioqr.decode(data, { zones: [ 'foo', 'bar', 'baz' ] }).excursion.zones; // [ 'foo', 'bar' ]
    bioqr.decode(data, { zones: (i) => i * 2 }).excursion.zones; // [ 0, 2 ]

Encoding

Data is encoded in the smallest possible number of bytes. The version property of the data object specifies which encoding version to use.

All versions

  • Offsets and sizes are in bytes
  • Integer and UTF-8 bytes are in big endian order
  • Dates are truncated to the second (millisecond precision is lost)
  • Dates are unsigned 32-bit integers with a max value of 2 ^ 32 - 1 seconds from the Unix epoch (the largest date that can be represented is Sun, 07 Feb 2106 06:28:15)
  • Bitmask offsets 0 and 7 correspond to the least significant and most significant bit, respectively, in a 1-byte bitmask
  • Strings must be truncated if they have too many bytes
  • Strings must be padded with spaces to fit the expected byte length

Version 1

Field | Offset | Size | Type | Description :--- | :--- | :--- | :--- | :--- version | 0 | 1 | uint8 | The binary format version (1-255) creator name | 1 | 40 | UTF-8 string | The name of the user who manages the excursion excursion id | 41 | 5 | UTF-8 string | The unique identifier of the excursion excursion date | 46 | 4 | uint32 (Unix timestamp in seconds) | The date at which the excursion was planned excursion name | 50 | 60 | UTF-8 string | The name of the excursion participant id | 110 | 2 | UTF-8 string | The identifier of the participant (unique for the excursion) participant name | 112 | 20 | UTF-8 string | The name of the participant POI type(s) | 132 | 1 | uint8 bitmask | A bitmask where each bit is a boolean flag to activate (1) or deactivate (0) each POI type zone(s) | 133 | 1 | uint8 bitmask | A bitmask where each bit is a boolean flag to activate (1) or deactivate (0) each zone in the trail

  • A data payload is exactly 134 bytes long and should fit within a version 10 QR code (57x57 modules) in binary format with error correction level Q

POI themes

Themes | Bitmask offset :--- | :--- bird | 0 butterfly | 1 flower | 2 tree | 3

Trail zones

Zones are assumed to be sequential. Bitmask offsets correspond to each zone in order: 0 is the first zone, 7 is the last one (if there are that many).