Skip to content

Commit 385077d

Browse files
committed
👍 use [@core/unknownutil@4.3.0/is/custom-jsonable]
1 parent 45d330b commit 385077d

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

deno.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
]
4343
},
4444
"imports": {
45-
"@core/unknownutil": "jsr:@core/unknownutil@^4.1.0",
45+
"@core/unknownutil": "jsr:@core/unknownutil@^4.3.0",
4646
"@denops/core": "jsr:@denops/core@^7.0.0",
4747
"@denops/test": "jsr:@denops/test@^3.0.1",
4848
"@lambdalisue/errorutil": "jsr:@lambdalisue/errorutil@^1.0.0",

eval/stringify.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isArray } from "@core/unknownutil/is/array";
22
import { isBoolean } from "@core/unknownutil/is/boolean";
3+
import { isCustomJsonable } from "@core/unknownutil/is/custom-jsonable";
34
import { isFunction } from "@core/unknownutil/is/function";
45
import { isInstanceOf } from "@core/unknownutil/is/instance-of";
56
import { isNullish } from "@core/unknownutil/is/nullish";
@@ -81,7 +82,7 @@ export function stringify(value: unknown): string {
8182
if (isExprString(value)) {
8283
return `"${value.replaceAll('"', '\\"')}"`;
8384
}
84-
if (isJsonable(value)) {
85+
if (isCustomJsonable(value)) {
8586
value = value.toJSON(key);
8687
if (isVimEvaluatable(value)) {
8788
return toVimExpression(value);
@@ -136,19 +137,6 @@ export function stringify(value: unknown): string {
136137
return reduce(value, "");
137138
}
138139

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-
152140
function isIgnoreRecordValue(x: unknown): boolean {
153141
return isUndefined(x) || isFunction(x) || isSymbol(x);
154142
}

helper/expr_string.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export function isExprString(x: unknown): x is ExprString {
136136
})(x);
137137
}
138138

139+
// NOTE: Do not use [@core/unknownutil@4.3.0/is/custom-jsonable], it's changes behaviour.
139140
function isJsonable(x: unknown): x is Jsonable {
140141
return x != null && isFunction((x as Jsonable).toJSON);
141142
}

0 commit comments

Comments
 (0)