How to use the truncateSync function from fs
Find comprehensive JavaScript fs.truncateSync code examples handpicked from public code repositorys.
GitHub: blockcollider/bcnode
86 87 88 89 90 91 92 93 94 95
exports.stat = co.promisify(fs.stat); exports.statSync = fs.statSync; exports.symlink = co.promisify(fs.symlink); exports.symlinkSync = fs.symlinkSync; exports.truncate = co.promisify(fs.truncate); exports.truncateSync = fs.truncateSync; exports.unlink = co.promisify(fs.unlink); exports.unlinkSync = fs.unlinkSync; exports.unwatchFile = fs.unwatchFile; exports.utimes = co.promisify(fs.utimes);
22
45
26
135 136 137 138 139 140 141 142 143 144 145 146
// filled with zeroes. { const file1 = path.resolve(tmp, 'truncate-file-1.txt'); fs.writeFileSync(file1, 'Hi'); fs.truncateSync(file1, 4); assert(fs.readFileSync(file1).equals(Buffer.from('Hi\u0000\u0000'))); } {
0
0
0
+ 5 other calls in file
fs.readFileSync is the most popular function in fs (2736 examples)