|
1 | 1 | import { isArray } from "@core/unknownutil/is/array";
|
2 | 2 | import { isBoolean } from "@core/unknownutil/is/boolean";
|
| 3 | +import { isCustomJsonable } from "@core/unknownutil/is/custom-jsonable"; |
3 | 4 | import { isFunction } from "@core/unknownutil/is/function";
|
4 | 5 | import { isInstanceOf } from "@core/unknownutil/is/instance-of";
|
5 | 6 | import { isNullish } from "@core/unknownutil/is/nullish";
|
@@ -81,7 +82,7 @@ export function stringify(value: unknown): string {
|
81 | 82 | if (isExprString(value)) {
|
82 | 83 | return `"${value.replaceAll('"', '\\"')}"`;
|
83 | 84 | }
|
84 |
| - if (isJsonable(value)) { |
| 85 | + if (isCustomJsonable(value)) { |
85 | 86 | value = value.toJSON(key);
|
86 | 87 | if (isVimEvaluatable(value)) {
|
87 | 88 | return toVimExpression(value);
|
@@ -136,19 +137,6 @@ export function stringify(value: unknown): string {
|
136 | 137 | return reduce(value, "");
|
137 | 138 | }
|
138 | 139 |
|
139 |
| -type Jsonable = { |
140 |
| - /** |
141 |
| - * Returns a JSON value that can be specified to {@linkcode JSON.stringify}. |
142 |
| - * |
143 |
| - * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior|toJSON() behavior} |
144 |
| - */ |
145 |
| - toJSON(key: string | number): unknown; |
146 |
| -}; |
147 |
| - |
148 |
| -function isJsonable(x: unknown): x is Jsonable { |
149 |
| - return x != null && isFunction((x as Jsonable).toJSON); |
150 |
| -} |
151 |
| - |
152 | 140 | function isIgnoreRecordValue(x: unknown): boolean {
|
153 | 141 | return isUndefined(x) || isFunction(x) || isSymbol(x);
|
154 | 142 | }
|
|
0 commit comments