chrisguttandin / synchsafe

A module to decode and encode synchsafe integers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

synchsafe

A module to decode and encode synchsafe integers.

version

This module provides two functions to decode and encode synchsafe integers as it is for example required by the ID3 standard. It is a fork of this Gist by raym.

Usage

The synchsafe module is available on npm and can be installed as usual.

npm install synchsafe

You can then import its public functions decode() and encode() like this:

import { decode, encode } from 'synchsafe';

As you might guess, the encode() function turns a regular integer into a synchsafed integer and the decode() function does the opposite. Therefore the following line would evaluate to true.

decode(encode(30201)) === 30201;

About

A module to decode and encode synchsafe integers.

License:MIT License


Languages

Language:JavaScript 82.9%Language:TypeScript 14.2%Language:Shell 2.9%