Skip to content

Commit 6caf0b4

Browse files
refactor: polishing
1 parent 4ac5ed1 commit 6caf0b4

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

src/affine.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const transform = (input, options) => {
1616
if (!LEGAL_MULT_KEYS.includes(options.keys[0])) {
1717
throw new Error('Illegal keys')
1818
}
19+
1920
return [...input].map(c => rotateAndMultiply(c, getRotateAndMultiplyConfig(options))).join('')
2021
}
2122

src/morse.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ export const decode = (input, options = {}) => {
99
if (decodedCharacter) {
1010
return decodedCharacter[0]
1111
}
12-
throwOrSilent(options, `Undecodable character ${character}`)
1312

14-
return options.omitUnknownCharacter ? '' : character
13+
return throwOrSilent(options, `Undecodable character ${character}`) || options.omitUnknownCharacter ? '' : character
1514
}).join('')
1615
}
1716

@@ -25,9 +24,7 @@ export const encode = (input, options = {}) => {
2524
return encodedCharacter[1]
2625
}
2726

28-
throwOrSilent(options, `Unencodable character ${character}`)
29-
30-
return options.omitUnknownCharacter ? '' : character
27+
return throwOrSilent(options, `Unencodable character ${character}`) || options.omitUnknownCharacter ? '' : character
3128
}).join(options.separator)
3229
}
3330

src/multiTap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export const encode = (input, options = {}) => {
77
const decodedCharacter = Object.entries(alphabetWithSpaceKey(options.customMapping)).find(([, v]) => v.includes(c))
88
if (decodedCharacter) {
99
const amount = decodedCharacter[1].indexOf(c) + 1
10-
return (options.exponentForm ? `${decodedCharacter[0]}^${amount}` : `${decodedCharacter[0]}`.repeat(amount))
10+
return options.exponentForm ? `${decodedCharacter[0]}^${amount}` : `${decodedCharacter[0]}`.repeat(amount)
1111
}
1212
return throwOrSilent(options, `Unencodable character ${c}`)
1313
})
14-
.filter(c => c.length)
14+
.filter(Boolean)
1515
.join(options.withSpacing ? ' ' : '')
1616
}
1717

src/multiplicative.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ const encode = (input, options = {}) => {
77
}
88

99
const decode = (input, options = {}) => {
10-
options = { ...DEFAULT_OPTIONS, ...options }
11-
options.decode = true
10+
options = { ...DEFAULT_OPTIONS, ...options, decode: true }
1211

1312
return transform(input, options)
1413
}

src/polybius.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const encode = (input, options = {}) => {
3535
}
3636

3737
return `${row}${col}`
38-
}).filter(c => c.length).join(' ')
38+
}).filter(Boolean).join(' ')
3939
}
4040

4141
const decode = (input, options = {}) => {

0 commit comments

Comments
 (0)