Skip to content

Commit

Permalink
fix(indent,dedent): 插入值支持 number 类型
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Dec 21, 2020
1 parent c212ada commit 926b7cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/dedent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { indent } from './indent'
*/
export function dedent(
literals: TemplateStringsArray,
...interpolations: string[]
...interpolations: Array<string | number>
): string {
const text = indent(literals, ...interpolations)

Expand Down
4 changes: 2 additions & 2 deletions src/utils/indent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
export function indent(
literals: TemplateStringsArray,
...interpolations: string[]
...interpolations: Array<string | number>
): string {
let result = ''

Expand All @@ -21,7 +21,7 @@ export function indent(
let interpolation = interpolations[i]
const match = literal.match(/(?:^|[\r\n]+)([^\S\r\n]*)$/)
if (match && match[1]) {
interpolation = interpolation.replace(
interpolation = String(interpolation).replace(
// fix: 后行断言部分浏览器暂不支持
// /(?<=[\r\n]+)(?=[^\r\n])/g,
/([\r\n]+)(?=[^\r\n])/g,
Expand Down

0 comments on commit 926b7cb

Please sign in to comment.