Skip to content

Commit

Permalink
Shave a few bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
alattalatta committed Jan 15, 2024
1 parent cee343b commit dd64a7e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-weeks-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"k-popo": patch
---

Shave a few bytes
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
extends: ['@alattalatta/eslint-config'],
rules: {
'prefer-const': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
},
parserOptions: {
project: [tsconfig],
Expand Down
9 changes: 2 additions & 7 deletions src/getLastChar.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
const getLastChar = (str: string): string => {
let stripped = str.replace(/\([^)]*\)/g, '')

let lastChar = stripped[stripped.length - 1]
if (lastChar == `'` || lastChar == `"`) {
return stripped[stripped.length - 2]
}
return lastChar
let stripped = str.replace(/'|"|\([^)]*\)/g, '')
return stripped[stripped.length - 1] // no path where str is empty
}

export { getLastChar }
1 change: 0 additions & 1 deletion src/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type Parameter = string | readonly [display: string, pronunciation: string]
*/
const ko = (template: Readonly<TemplateStringsArray>, ...words: readonly Parameter[]): string =>
words.reduce<string>((acc, word, index) => {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
let withoutPronunciation = '' + word === word // typeof string

// template is always 1 length longer, this should be safe
Expand Down

0 comments on commit dd64a7e

Please sign in to comment.