Kind: global class
- ShredFile
- new ShredFile(settings)
- instance
- .shred(files, [statusCb], [endCb]) ⇒
Promise.<object>
- .shred(files, [statusCb], [endCb]) ⇒
- inner
- ~endCallback :
function - ~statusCallback :
function
- ~endCallback :
ShredFile Class constructor.
| Param | Type | Default | Description |
|---|---|---|---|
| settings | object |
Settings to override the defaults. | |
| [settings.shredPath] | string |
"'/usr/bin/shred'" |
The path to the shred binary. |
| [settings.force] | boolean |
false |
If true, change permissions to allow writing if necessary |
| [settings.iterations] | number |
3 |
Set the number of times to overwrite the file |
| [settings.bytes] | number |
|
The number of bytes to shred |
| [settings.remove] | boolean |
true |
If true, trucates and removes the file after overwriting |
| [settings.zero] | boolean |
true |
If true, add a final overwrite with zeros to hide shredding |
| [settings.debugMode] | boolean |
fakse |
If true, turns on debugging (logs to console) |
Example
// Instantiat with all defaults
const shred = new ShredFile();
// Instantiate with some settings overrides
const shredder = new ShredFile({ iteractions: 5, debugMode: true });Allows one to securely shred a file or a set of files.
Kind: instance method of ShredFile
Returns: Promise.<object> - If no endCb is provided, a Promise will be returned.
Access: public
| Param | Type | Description |
|---|---|---|
| files | string | Array |
A path to a file or an array of paths to files |
| [statusCb] | statusCallback |
(optional) This will be called on each status change (renaming and each overwrite iteration) |
| [endCb] | endCallback |
(optional) This will be called when done. |
Example
const shredder = new ShredFile();
// Do some shredding (Promise-style)
async function doSomeShredding() {
// Shred a single file
const result = await shredder.shred('/path/to/some/file');
// Shred multiple files
const result = await shredder.shred(['/path/to/first/file', '/path/to/second/file']);
// Shred a file with notifications on progress
const result = await shredder.shred('/another/file/to/shred', (action, progress, file, activeFilePath) => {
console.log(`Currently ${action} ${activeFilePath} (${(progress * 100).floor()}%));
});
}
// Do some shredding (callback-style)
function moreShredding(cb) {
shredder.shred('/path/to/file/file', null, (err, file) => {
if (err) {
console.error(err);
cb(err, null);
}
else {
console.log('All Done!');
cb(null, true);
}
});
}This callback belongs to the shred method and will be called (if supplied)
when the shred command has completed or if there is an error.
Kind: inner typedef of ShredFile
| Param | Type | Description |
|---|---|---|
| err | Error |
A standard error message (null if no error) |
| file | string | Array |
The original files parameter passed into this shred method. |
This callback belongs to the shred command and will be called (if supplied) whenever
the shred command sends a STDOUT. Used to show progress of a shred.
Kind: inner typedef of ShredFile
| Param | Type | Description |
|---|---|---|
| action | string |
This will be either 'overwriting' or 'renaming' |
| progress | number |
The percentage of the specific action that is complete (ex. 0.66) |
| file | string | Array |
File name of the file that is currently being acted upon |
| activeFilePath | string |
Full path to the file that is currently being acted upon (does not include file name) |