MCPcopy Index your code
hub / github.com/nodejs/node / truncate

Function truncate

lib/internal/fs/promises.js:1517–1525  ·  view source on GitHub ↗
(path, len = 0)

Source from the content-addressed store, hash-verified

1515}
1516
1517async function truncate(path, len = 0) {
1518 const h = vfsState.handlers;
1519 if (h !== null) {
1520 const promise = h.truncate(path, len);
1521 if (promise !== undefined) { await promise; return; }
1522 }
1523 const fd = await open(path, 'r+');
1524 return handleFdClose(ftruncate(fd, len), fd.close);
1525}
1526
1527async function ftruncate(handle, len = 0) {
1528 validateInteger(len, 'len');

Callers 1

getCellFunction · 0.50

Calls 4

handleFdCloseFunction · 0.85
openFunction · 0.70
ftruncateFunction · 0.70
truncateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…