-
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
Description
Description
This codemod should replace zlib.bytesRead with zlib.bytesWritten for consistent stream property naming. It's useful to migrate code that uses the deprecated property which has been removed.
It should replace zlib.bytesRead with zlib.bytesWritten in all zlib transform streams. It should handle both CommonJS and ESM imports. It should preserve usage context and variable assignments. It should maintain the same functionality with updated property names.
Examples
Case 1
Before:
const zlib = require("node:zlib");
const gzip = zlib.createGzip();
gzip.on("end", () => {
console.log("Bytes processed:", gzip.bytesRead);
});
After:
const zlib = require("node:zlib");
const gzip = zlib.createGzip();
gzip.on("end", () => {
console.log("Bytes processed:", gzip.bytesWritten);
});
Case 2
Before:
const zlib = require("node:zlib");
const deflate = zlib.createDeflate();
deflate.on("finish", () => {
const stats = {
input: deflate.bytesRead,
output: deflate.bytesWritten
};
});
After:
const zlib = require("node:zlib");
const deflate = zlib.createDeflate();
deflate.on("finish", () => {
const stats = {
input: deflate.bytesWritten,
output: deflate.bytesWritten
};
});
Case 3
Before:
const zlib = require("node:zlib");
function trackProgress(stream) {
setInterval(() => {
console.log(`Progress: ${stream.bytesRead} bytes`);
}, 1000);
}
After:
const zlib = require("node:zlib");
function trackProgress(stream) {
setInterval(() => {
console.log(`Progress: ${stream.bytesWritten} bytes`);
}, 1000);
}
Case 4
Before:
import { createGzip } from "node:zlib";
const gzip = createGzip();
const bytesProcessed = gzip.bytesRead;
After:
import { createGzip } from "node:zlib";
const gzip = createGzip();
const bytesProcessed = gzip.bytesWritten;
REFS
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
🔖 Todo