Skip to content

Commit 889e9e1

Browse files
committed
Remove dependency
1 parent e9bf29e commit 889e9e1

File tree

6 files changed

+10
-19
lines changed

6 files changed

+10
-19
lines changed

lib/handle/code.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import repeat from 'repeat-string'
21
import {longestStreak} from 'longest-streak'
32
import {formatCodeAsIndented} from '../util/format-code-as-indented.js'
43
import {checkFence} from '../util/check-fence.js'
@@ -16,7 +15,7 @@ export function code(node, _, context) {
1615
exit = context.enter('codeIndented')
1716
value = indentLines(raw, map)
1817
} else {
19-
const sequence = repeat(marker, Math.max(longestStreak(raw, marker) + 1, 3))
18+
const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3))
2019
let subexit
2120
exit = context.enter('codeFenced')
2221
value = sequence

lib/handle/heading.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import repeat from 'repeat-string'
21
import {formatHeadingAsSetext} from '../util/format-heading-as-setext.js'
32
import {containerPhrasing} from '../util/container-phrasing.js'
43

@@ -18,8 +17,7 @@ export function heading(node, _, context) {
1817
return (
1918
value +
2019
'\n' +
21-
repeat(
22-
rank === 1 ? '=' : '-',
20+
(rank === 1 ? '=' : '-').repeat(
2321
// The whole size…
2422
value.length -
2523
// Minus the position of the character after the last EOL (or
@@ -29,7 +27,7 @@ export function heading(node, _, context) {
2927
)
3028
}
3129

32-
const sequence = repeat('#', rank)
30+
const sequence = '#'.repeat(rank)
3331
exit = context.enter('headingAtx')
3432
subexit = context.enter('phrasing')
3533
value = containerPhrasing(node, context, {before: '# ', after: '\n'})

lib/handle/list-item.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import repeat from 'repeat-string'
21
import {checkBullet} from '../util/check-bullet.js'
32
import {checkListItemIndent} from '../util/check-list-item-indent.js'
43
import {containerFlow} from '../util/container-flow.js'
@@ -34,9 +33,9 @@ export function listItem(node, parent, context) {
3433

3534
function map(line, index, blank) {
3635
if (index) {
37-
return (blank ? '' : repeat(' ', size)) + line
36+
return (blank ? '' : ' '.repeat(size)) + line
3837
}
3938

40-
return (blank ? bullet : bullet + repeat(' ', size - bullet.length)) + line
39+
return (blank ? bullet : bullet + ' '.repeat(size - bullet.length)) + line
4140
}
4241
}

lib/handle/thematic-break.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import repeat from 'repeat-string'
21
import {checkRuleRepeat} from '../util/check-rule-repeat.js'
32
import {checkRule} from '../util/check-rule.js'
43

5-
export function thematicBreak(node, parent, context) {
6-
const value = repeat(
7-
checkRule(context) + (context.options.ruleSpaces ? ' ' : ''),
8-
checkRuleRepeat(context)
9-
)
4+
export function thematicBreak(_, _1, context) {
5+
const value = (
6+
checkRule(context) + (context.options.ruleSpaces ? ' ' : '')
7+
).repeat(checkRuleRepeat(context))
108

119
return context.options.ruleSpaces ? value.slice(0, -1) : value
1210
}

lib/util/container-flow.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import repeat from 'repeat-string'
2-
31
export function containerFlow(parent, context) {
42
const children = parent.children || []
53
const results = []
@@ -31,7 +29,7 @@ export function containerFlow(parent, context) {
3129
}
3230

3331
if (typeof result === 'number') {
34-
return repeat('\n', 1 + Number(result))
32+
return '\n'.repeat(1 + result)
3533
}
3634

3735
if (result === false) {

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"longest-streak": "^3.0.0",
4141
"mdast-util-to-string": "^3.0.0",
4242
"parse-entities": "^3.0.0",
43-
"repeat-string": "^1.0.0",
4443
"zwitch": "^2.0.0"
4544
},
4645
"devDependencies": {

0 commit comments

Comments
 (0)