Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

digit-array

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

digit-array

Encode and decode numbers in arbitrary bases

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

##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

Keywords

FAQs

Package last updated on 24 Jun 2014

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc