Skip to content

Commit

Permalink
chore(ts): small tweaks to make typescript happier
Browse files Browse the repository at this point in the history
- Use trimStart/trimEnd instead of deprecated trimLeft/trimRight
- Target es2019, which is when trimLeft/Right/Start/End methods
  became available (at least according to tsc)
  • Loading branch information
isaacs committed Apr 28, 2023
1 parent af3145d commit 6c439eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class UI {
const match = source.match(/^ */)
const leadingWhitespace = match ? match[0].length : 0
const target = previousLine.text
const targetTextWidth = mixin.stringWidth(target.trimRight())
const targetTextWidth = mixin.stringWidth(target.trimEnd())

if (!previousLine.span) {
return source
Expand All @@ -223,13 +223,13 @@ export class UI {

previousLine.hidden = true

return target.trimRight() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimLeft()
return target.trimEnd() + ' '.repeat(leadingWhitespace - targetTextWidth) + source.trimStart()
}

private rasterize (row: ColumnArray) {
const rrows: string[][] = []
const widths = this.columnWidths(row)
let wrapped
let wrapped: string[]

// word wrap all columns, and create
// a data-structure that is easy to rasterize.
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"outDir": "build",
"rootDir": ".",
"sourceMap": false,
"target": "es2017",
"target": "es2019",
"moduleResolution": "node",
"module": "es2015"
},
Expand All @@ -14,4 +14,4 @@
"exclude": [
"lib/cjs.ts"
]
}
}

0 comments on commit 6c439eb

Please sign in to comment.