4 Commits

4 changed files with 9 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ for short URLs among other things. Flickr is one the biggest sites that makes
use of it for short photo URLs.
For example `6857269519` becomes `brXijP` when Base58 encoded, and hence the
Flickr short URL is: [`http://flic.kr/p/brXijP`](http://flic.kr/p/brXijP)
Flickr short URL is: `http://flic.kr/p/brXijP`
## Installation

View File

@@ -1,6 +1,6 @@
{
"name": "base58",
"version": "0.0.2",
"version": "0.1.0",
"keywords": "base58",
"description": "Base58 encoding and decoding",
"licenses": [{
@@ -15,7 +15,7 @@
"repository" : {
"type" : "git",
"url" : "http://github.com/jimeh/node-base58.git"
"url" : "https://github.com/jimeh/node-base58.git"
},
"main": "./lib/base58",

View File

@@ -5,6 +5,7 @@ class Base58Builder
encode: (num) ->
throw new Error('Value passed is not an integer.') unless /^\d+$/.test num
num = parseInt(num) unless typeof num == 'number'
str = ''
while num >= @base
mod = num % @base

View File

@@ -10,6 +10,11 @@ describe 'Base58', ->
for str, num of examples
Base58.encode(num).should.eql(str)
describe 'when passed a string only containing numbers', ->
it 'encodes string after first converting it to an integer', ->
for str, num of examples
Base58.encode(num.toString()).should.eql(str)
describe 'when passed a float', ->
it 'throws an error', ->
(-> Base58.encode(3.14)).should