Skip to content

Commit

Permalink
use String#substring in place of String#slice in test harness
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Jul 30, 2023
1 parent a7da891 commit db2723d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/harness/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ function heredoc (strings, ...values) {
}
let string = values.length
? (strings = strings.slice()).push(strings.pop().trimEnd()) &&
values.reduce((accum, _, idx) => accum + '\x1f' + strings[idx + 1], first.slice(1))
: first.slice(1).trimEnd()
values.reduce((accum, _, idx) => accum + '\x1f' + strings[idx + 1], first.substring(1))
: first.substring(1).trimEnd()
const lines = string.split('\n')
const indentSize = lines.reduce(
(accum, line) =>
accum && line ? (line[0] === ' ' ? Math.min(accum, line.length - line.trimStart().length) : 0) : accum,
Infinity
)
if (indentSize) {
string = lines.map((line) => (line && line[0] === ' ' ? line.slice(indentSize) : line)).join('\n')
string = lines.map((line) => (line && line[0] === ' ' ? line.substring(indentSize) : line)).join('\n')
if (!values.length) return string
strings = string.split('\x1f')
} else if (!values.length) {
Expand Down

0 comments on commit db2723d

Please sign in to comment.