@storyous/common-utils
Advanced tools
Comparing version 6.8.2 to 6.8.3
'use strict'; | ||
const { AppError } = require('../lib/appError'); | ||
const AppError = require('../lib/appError'); | ||
@@ -13,7 +13,8 @@ module.exports = { | ||
encode (number, prefix = '') { | ||
if (String(number).length > 16 || number < 1) { | ||
const mod = number % 36; | ||
if (Number.isNaN(mod) || String(number).length > 16 || Number(number) < 1) { | ||
throw new AppError('Invalid input number'); | ||
} | ||
const mod = number % 36; | ||
let res = ((number + 9876543) * (73 - mod)).toString(30); | ||
@@ -20,0 +21,0 @@ while (res.length % 3 !== 0) { |
{ | ||
"name": "@storyous/common-utils", | ||
"version": "6.8.2", | ||
"version": "6.8.3", | ||
"description": "Common utils for storyous microservices", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -35,2 +35,6 @@ 'use strict'; | ||
}); | ||
it('should throw an AppError, when pass wrong argument', () => { | ||
assert.throws(() => (ID.encode('someString', 'p')), {}); | ||
}); | ||
}); |
72905
2174