Skip to content

Commit 8ead266

Browse files
committed
perf(document): add fast path for applying non-nested virtuals to JSON
Re: #14394
1 parent e91fcf4 commit 8ead266

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/document.js

+8
Original file line numberDiff line numberDiff line change
@@ -4130,6 +4130,14 @@ function applyVirtuals(self, json, options, toObjectOptions) {
41304130
}
41314131
assignPath = path.substring(options.path.length + 1);
41324132
}
4133+
if (assignPath.indexOf('.') === -1 && assignPath === path) {
4134+
v = clone(self.get(path, options ? { ...options, noDottedPath: true } : { noDottedPath: true }));
4135+
if (v === void 0) {
4136+
continue;
4137+
}
4138+
json[assignPath] = v;
4139+
continue;
4140+
}
41334141
const parts = assignPath.split('.');
41344142
v = clone(self.get(path), options);
41354143
if (v === void 0) {

0 commit comments

Comments
 (0)