Skip to content

Commit

Permalink
Remove repeat-string
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 1, 2021
1 parent f9e30d5 commit a76fb9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import {phrasing} from 'hast-util-phrasing'
import {whitespace} from 'hast-util-whitespace'
import {isElement} from 'hast-util-is-element'
import {whitespaceSensitiveTagNames} from 'html-whitespace-sensitive-tag-names'
// @ts-expect-error: to do remove.
import repeat from 'repeat-string'

const minify = rehypeMinifyWhitespace({newlines: true})

Expand All @@ -41,7 +39,7 @@ export default function rehypeFormat(options = {}) {
let indentInitial = options.indentInitial

if (typeof indent === 'number') {
indent = repeat(' ', indent)
indent = ' '.repeat(indent)
}

// Default to indenting the initial level.
Expand Down Expand Up @@ -102,7 +100,7 @@ export default function rehypeFormat(options = {}) {

child.value = child.value.replace(
/ *\n/g,
'$&' + repeat(indent, level)
'$&' + String(indent).repeat(level)
)
}
}
Expand Down Expand Up @@ -151,7 +149,8 @@ export default function rehypeFormat(options = {}) {
const tail = list[list.length - 1]
const previous = whitespace(tail) ? list[list.length - 2] : tail
const replace =
(blank(previous) && blank(next) ? '\n\n' : '\n') + repeat(indent, level)
(blank(previous) && blank(next) ? '\n\n' : '\n') +
String(indent).repeat(Math.max(level, 0))

if (tail && tail.type === 'text') {
tail.value = whitespace(tail) ? replace : tail.value + replace
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"hast-util-whitespace": "^2.0.0",
"html-whitespace-sensitive-tag-names": "^2.0.0",
"rehype-minify-whitespace": "^5.0.0",
"repeat-string": "^1.0.0",
"unified": "^10.0.0",
"unist-util-visit-parents": "^5.0.0"
},
Expand Down

0 comments on commit a76fb9d

Please sign in to comment.