mirror of
https://github.com/jimeh/node-base58.git
synced 2026-02-19 07:36:40 +00:00
Ensure encode throws an error if receiving anything else than a integer
This commit is contained in:
@@ -4,7 +4,7 @@ class Base58Builder
|
||||
@base = @alphabet.length
|
||||
|
||||
encode: (num) ->
|
||||
throw new Error('Value passed is not a number.') if typeof num != 'number'
|
||||
throw new Error('Value passed is not an integer.') unless /^\d+$/.test num
|
||||
str = ''
|
||||
while num >= @base
|
||||
mod = num % @base
|
||||
|
||||
Reference in New Issue
Block a user