Comparing version 1.0.3 to 1.0.4
@@ -9,5 +9,5 @@ (function (global, factory) { | ||
const BASE = 65535 - OFFSET; | ||
let alpha = []; | ||
let alphabet = []; | ||
for (let i = 0; i < BASE; i++) { | ||
alpha.push(String.fromCharCode(i + OFFSET)); | ||
alphabet.push(String.fromCharCode(i + OFFSET)); | ||
} | ||
@@ -17,14 +17,14 @@ const encode = exports.encode = num => { | ||
if (typeof num !== 'number') num = ~num; | ||
const base = alpha.length; | ||
const base = alphabet.length; | ||
let str = ''; | ||
while (num >= base) { | ||
const mod = num % base; | ||
str = alpha[mod] + str; | ||
str = alphabet[mod] + str; | ||
num = (num - mod) / base; | ||
} | ||
return alpha[num] + str | ||
return alphabet[num] + str | ||
}; | ||
const decode = exports.decode = str => { | ||
let num = 0; | ||
while(str) { | ||
while (str) { | ||
let pos = str[0].charCodeAt(0) - OFFSET; | ||
@@ -31,0 +31,0 @@ if (pos < 0) throw new Error(`Can't find ${str[0]}`) |
{ | ||
"name": "base-65503", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Base 65503 encoder & decoder for numbers", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4199