From 3f362ae951a24798de5a20d2312c0d2c9c772485 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Fri, 25 Nov 2022 11:46:05 +0800 Subject: [PATCH] number_format --- lib/plugins/helper/number_format.ts | 6 +++--- lib/plugins/tag/include_code.ts | 2 +- lib/theme/processors/source.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/plugins/helper/number_format.ts b/lib/plugins/helper/number_format.ts index b6c74a1766..350e1b1129 100644 --- a/lib/plugins/helper/number_format.ts +++ b/lib/plugins/helper/number_format.ts @@ -1,7 +1,7 @@ interface Options { delimiter?: string; separator?: string; - precision?: number | string; + precision?: number; } function numberFormatHelper(num: number, options: Options = {}) { @@ -34,7 +34,7 @@ function numberFormatHelper(num: number, options: Options = {}) { const afterLast = after[precision]; const last = parseInt(after[precision - 1], 10); - afterResult = after.substring(0, precision - 1) + (afterLast < 5 ? last : last + 1); + afterResult = after.substring(0, precision - 1) + (Number(afterLast) < 5 ? last : last + 1); } else { afterResult = after; for (let i = 0, len = precision - afterLength; i < len; i++) { @@ -43,7 +43,7 @@ function numberFormatHelper(num: number, options: Options = {}) { } after = afterResult; - } else if (precision === 0 || precision === '0') { + } else if (precision === 0) { after = ''; } diff --git a/lib/plugins/tag/include_code.ts b/lib/plugins/tag/include_code.ts index e3fa4ae4d6..524d0276c9 100644 --- a/lib/plugins/tag/include_code.ts +++ b/lib/plugins/tag/include_code.ts @@ -60,7 +60,7 @@ export = ctx => function includeCodeTag(args) { return exists(src).then(exist => { if (exist) return readFile(src); - }).then(code => { + }).then((code: string) => { if (!code) return; const lines = code.split('\n'); diff --git a/lib/theme/processors/source.ts b/lib/theme/processors/source.ts index 4233bac613..97688b7ba7 100644 --- a/lib/theme/processors/source.ts +++ b/lib/theme/processors/source.ts @@ -1,5 +1,5 @@ import {Pattern} from 'hexo-util'; -import common from '../../plugins/processor/common'; +import * as common from '../../plugins/processor/common'; export function process(file) { const Asset = this.model('Asset');