From 708280b1c87bd4e3a0d344638c4b02e92e15fd55 Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Tue, 14 Jul 2026 21:51:23 +0800 Subject: [PATCH] fix: remove spurious diff noise in filter files Restore misc.ts from origin/next with LF line endings and re-apply only memoryLimit removal, avoiding CRLF and blank-line churn in the export block. Co-authored-by: Cursor --- src/filters/misc.ts | 62 +++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/filters/misc.ts b/src/filters/misc.ts index 33f428953..8a24ba754 100644 --- a/src/filters/misc.ts +++ b/src/filters/misc.ts @@ -1,42 +1,48 @@ -import { isFalsy } from '../render/boolean' -import { identify, isArray, isString, toValue } from '../util/underscore' -import { FilterImpl } from '../template' +import { isFalsy } from '../render/boolean' +import { identify, isArray, isString, toValue } from '../util/underscore' +import { FilterImpl } from '../template' + function defaultFilter (this: FilterImpl, value: T1, defaultValue: T2, ...args: Array<[string, any]>): T1 | T2 { - value = toValue(value) - if (isArray(value) || isString(value)) return value.length ? value : defaultValue - if (value === false && (new Map(args)).get('allow_false')) return false as T1 + value = toValue(value) + if (isArray(value) || isString(value)) return value.length ? value : defaultValue + if (value === false && (new Map(args)).get('allow_false')) return false as T1 return isFalsy(value, this.context) ? defaultValue : value -} +} + function json (this: FilterImpl, value: any, space = 0) { return JSON.stringify(value, undefined, space) -} +} + function inspect (this: FilterImpl, value: any, space = 0) { - const ancestors: object[] = [] + const ancestors: object[] = [] return JSON.stringify(value, function (this: unknown, _key: unknown, value: any) { if (typeof value !== 'object' || value === null) { return value - } - // `this` is the object that value is contained in, i.e., its direct parent. - while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) ancestors.pop() + } + // `this` is the object that value is contained in, i.e., its direct parent. + while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) ancestors.pop() if (ancestors.includes(value)) { return '[Circular]' - } - ancestors.push(value) + } + ancestors.push(value) return value }, space) -} +} + function to_integer (value: any) { return Number(value) -} -const raw = { - raw: true, - handler: identify -} -export default { - default: defaultFilter, - raw, - jsonify: json, - to_integer, - json, - inspect -} +} + +const raw = { + raw: true, + handler: identify +} + +export default { + default: defaultFilter, + raw, + jsonify: json, + to_integer, + json, + inspect +}