synchsafe
v9.0.12
Published
A module to decode and encode synchsafe integers.
Downloads
572
Readme
synchsafe
A module to decode and encode synchsafe integers.
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;