
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
transform-file
Advanced tools
Transform a file as a stream in place (with a temp file, but retaining inode info)
Take a look at the test folder for more usages, but the basic idea is you pass in a file, a transform callback and a done callback and it calls the transform callback on each chunk passing in a buffer and a boolean that's true if it's the last chunk in the file, the callback can be async or sync, by either accepting a third arg or not. Here's an example:
var transformFile = require('transform-file');
transformFile(
__dirname + '/package.json',
function(buffer, isLastChunk) {
return buffer.toString().toUpperCase() + (isLastChunk ? '\n\n\n' : '');
},
function() {
fs.readFile(__dirname + '/package.json', function(err, buffer) {
console.log(buffer.toString()); // uppercase with trailing newlines
});
}
);
// same as above just async
transformFile(
__dirname + '/package.json',
function(buffer, isLastChunk, next) {
setTimeout(function() {
// notice we use next() and not return
next(buffer.toString().toUpperCase() + (isLastChunk ? '\n\n\n' : ''));
}, 10);
},
function() {
fs.readFile(__dirname + '/package.json', function(err, buffer) {
console.log(buffer.toString()); // uppercase with trailing newlines
});
}
);
FAQs
transform file in place using streams and temp files
The npm package transform-file receives a total of 7,263 weekly downloads. As such, transform-file popularity was classified as popular.
We found that transform-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket investigates hidden protestware in npm packages that blocks user interaction and plays the Ukrainian anthem for Russian-language visitors.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.