MCPcopy Create free account
hub / github.com/forwardemail/superagent / getProgressMonitor

Function getProgressMonitor

src/node/index.js:1616–1634  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1614 this.emit('request', this);
1615
1616 const getProgressMonitor = () => {
1617 const lengthComputable = true;
1618 const total = req.getHeader('Content-Length');
1619 let loaded = 0;
1620
1621 const progress = new Stream.Transform();
1622 progress._transform = (chunk, encoding, callback) => {
1623 loaded += chunk.length;
1624 this.emit('progress', {
1625 direction: 'upload',
1626 lengthComputable,
1627 loaded,
1628 total
1629 });
1630 callback(null, chunk);
1631 };
1632
1633 return progress;
1634 };
1635
1636 const bufferToChunks = (buffer) => {
1637 const chunkSize = 16 * 1024; // default highWaterMark value

Callers 1

index.jsFile · 0.85

Calls 1

getHeaderMethod · 0.80

Tested by

no test coverage detected