Merge pull request #14007 from Snuffleupagus/writeValue-null
[src/core/writer.js] Support `null` values in the `writeValue` function
This commit is contained in:
commit
064c21d360
@ -89,6 +89,8 @@ function writeValue(value, buffer, transform) {
|
||||
writeDict(value, buffer, transform);
|
||||
} else if (isStream(value)) {
|
||||
writeStream(value, buffer, transform);
|
||||
} else if (value === null) {
|
||||
buffer.push("null");
|
||||
} else {
|
||||
warn(`Unhandled value in writer: ${typeof value}, please file a bug.`);
|
||||
}
|
||||
|
@ -117,6 +117,9 @@ describe("Writer", function () {
|
||||
dict.set("J", true);
|
||||
dict.set("K", false);
|
||||
|
||||
dict.set("NullArr", [null, 10]);
|
||||
dict.set("NullVal", null);
|
||||
|
||||
const buffer = [];
|
||||
writeDict(dict, buffer, null);
|
||||
|
||||
@ -125,7 +128,8 @@ describe("Writer", function () {
|
||||
"/E (\\(hello\\\\world\\)) /F [1.23 4.5 6] " +
|
||||
"/G << /H 123 /I << /Length 8>> stream\n" +
|
||||
"a stream\n" +
|
||||
"endstream\n>> /J true /K false>>";
|
||||
"endstream\n>> /J true /K false " +
|
||||
"/NullArr [null 10] /NullVal null>>";
|
||||
|
||||
expect(buffer.join("")).toEqual(expected);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user