Skip to content

Commit f66ca9d

Browse files
author
Dmitry Ovsyanko
committed
CadNum: [pre]
1 parent d695213 commit f66ca9d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

__tests__/isCadNum.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test ('basic', () => {
2626
'47:14:120300:814',
2727
'47:14:1203001:814',
2828
]) {
29-
29+
3030
expect (isntCadNum (v)).toBeFalsy ()
3131
expect (isCadNum (v)).toBeUndefined ()
3232

@@ -38,7 +38,7 @@ test ('basic', () => {
3838

3939
for (let i = 0; i < 10; i ++) {
4040

41-
const v = randomCadNum (pre || length ? {pre, length} : undefined)
41+
const v = randomCadNum (pre || length ? {pre: pre ? [pre] : pre, length} : undefined)
4242

4343
expect (v).toMatch (RE)
4444
if (pre && length > pre.length + 2) {

lib/CadNum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = class {
5050

5151
let {pre, length} = options
5252

53-
if (!pre) pre = ''
53+
pre = pre ? pre [Math.floor (pre.length * Math.random ())] : ''
5454

5555
if (pre.length === 12 || pre.length === 13) if (pre.charCodeAt (pre.length - 1) !== CH_COLON) pre += ':'
5656

0 commit comments

Comments
 (0)