Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

digit-array

0.2.5 • Public • Published

DigitArray

The DigitArray library is designed to encode and decode numbers in arbirtary bases.

Example

var decimalValue = new DigitArray(10, [1, 3, 3, 7]);
 
var binaryValue = decimalValue.toBase(2);
 
var hexValue = decimalValue.toBase(16);
 
var encodedDecimalValue = decimalValue.encode('0123456789');
// "1337"
 
var encodedBinaryValue = binaryValue.encode('01');
// "10100111001"
 
var encodedHexValue = hexValue.encode('0123456789abcdef');
// "539"
 
DigitArray.decode(encodedDecimalValue, 10, '0123456789').toNumber();
// 1337
 
DigitArray.decode(encodedBinaryValue, 2, '01').toNumber();
// 1337
 
DigitArray.decode(encodedHexValue, 16, '0123456789abcdef').toNumber();
// 1337

Dev setup

Requirements:

  • npm
  • gulp

Install dependencies:

npm install -g gulp
npm install

Build library:

Modify the source files in the src directory, then run gulp to build DigitArray.js and DigitArray.min.js in the root directory.

gulp

Install

npm i digit-array

DownloadsWeekly Downloads

7

Version

0.2.5

License

BSD-2-Clause

Last publish

Collaborators

  • avatar