Skip to content

Commit 2f3b9b4

Browse files
committed
fix: support symbol as object key
1 parent 0f922d2 commit 2f3b9b4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function createStringifier (customOptions) {
5353
return function stringifyAny (push, x) {
5454
const context = this;
5555
let handler = handlerFor(context.node, options, handlers);
56-
const currentPath = '/' + context.path.join('/');
56+
const currentPath = '/' + context.path.map(String).join('/');
5757
const customization = handlers[currentPath];
5858
const acc = {
5959
context: context,

Diff for: strategies.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,11 @@ function decorateObject () {
244244
}
245245

246246
function sanitizeKey (key) {
247-
return /^[A-Za-z_]+$/.test(key) ? key : JSON.stringify(key);
247+
if (typeof key === 'symbol') {
248+
return key.toString();
249+
} else {
250+
return /^[A-Za-z_]+$/.test(key) ? key : JSON.stringify(key);
251+
}
248252
}
249253

250254
function afterAllChildren (context, push, options) {

0 commit comments

Comments
 (0)