copymitter
v10.3.2
Published
copy files with emitter
Downloads
3,298
Maintainers
Readme
Copymitter

Copy files with emitter (even from and to zip archives). It will emit event on every percent of copied chunk of data.
Good for making progress bars.
Install
npm i copymitterHow to use?
import {copymitter} from 'copymitter';
const cwd = process.cwd();
const from = `${cwd}/pipe-io`;
const to = `${cwd}/example`;
const abortOnError = false;
const cp = copymitter(from, to, ['LICENSE', 'README.md', 'package.json']);
cp.on('file', (from, to) => {
console.log(`${from} -> ${to}`);
});
cp.on('directory', (from, to) => {
console.log(`${from} -> ${to}`);
});
cp.on('progress', (percent) => {
console.log(percent);
if (percent >= 50) {
cp.pause();
cp.continue();
}
});
cp.on('pause', () => {
console.log('paused');
cp.continue();
});
cp.on('error', (error) => {
console.error(error.message);
if (abortOnError) {
cp.abort();
return;
}
cp.continue();
});
cp.on('abort', () => {
console.log('Copying aborted');
});
cp.on('end', ({errors}) => {
console.log('Copying ended up');
});
cp.pause();Related
- Remy - Remove files with emitter.
- Jaguar - Pack and extract .tar.gz archives with emitter.
- OneZip - Pack and extract zip archives with emitter.
- Tar-to-zip - Convert tar and tar.gz archives to zip.
License
MIT
