Skip to content

Commit 83a1f3d

Browse files
authored
Remove deprecated new Buffer() (#41)
1 parent ace8030 commit 83a1f3d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/index.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ describe("javascript-stringify", () => {
247247
});
248248

249249
describeIf("Buffer", typeof (Buffer as any) === "function", () => {
250-
it("should stringify", test(Buffer.from("test"), "new Buffer('test')"));
250+
it(
251+
"should stringify",
252+
test(Buffer.from("test"), "Buffer.from('dGVzdA==', 'base64')")
253+
);
251254
});
252255

253256
describeIf("BigInt", typeof (BigInt as any) === "function", () => {

src/object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { arrayToString } from "./array";
88
*/
99
export const objectToString: ToString = (value, space, next, key) => {
1010
if (typeof (Buffer as unknown) === "function" && Buffer.isBuffer(value)) {
11-
return `new Buffer(${next(value.toString())})`;
11+
return `Buffer.from(${next(value.toString("base64"))}, 'base64')`;
1212
}
1313

1414
// Use the internal object string to select stringify method.

0 commit comments

Comments
 (0)