Skip to content

A node.js module for simple(r) handling of radix 2 through 36 base encodings.

License

Notifications You must be signed in to change notification settings

thisandagain/baseit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Baseit

Base(x) In --> Base(x) Out

Build Status

Install

npm install baseit

Basic Use

var baseit = require('baseit');

baseit({
	input: 	120000,
	to: 	36,
}, function (err, a) {
	if (err) throw err;

	console.log(a);		// "2klc"
});

Slightly Less Basic Use

var baseit = require('baseit');

baseit({
	input: 	1296,
	from: 	12,
	to: 	36,
	digits: 6
}, function (err, a) {
	if (err) throw err;

	console.log(a);		// "0001n6"
});

Parameters

####input (Required) Integer or string to be converted.

####to (Optional) Target encoding integer. If not specified, "to" will default to 10. Example for Base24: { to: 24 }.

####from (Optional) Input encoding integer. If not specified, "from" will default to 10. Example for Base8: { from: 8 }.

####digits (Optional) Minimum number of digits to return. Will append leading "zeros" to meet digit requirement. Example: { digits: 6 }

Why u no Base64!?

Node.js already has a good way of handling Base64 encoding.

Testing

vows test/*

About

A node.js module for simple(r) handling of radix 2 through 36 base encodings.

Resources

License

Stars

Watchers

Forks

Packages

No packages published