istanbul-middleware icon indicating copy to clipboard operation
istanbul-middleware copied to clipboard

Async version of instrumentSync()

Open ORESoftware opened this issue 7 years ago • 1 comments

Hey, this is looking good

I am wondering if there is an async version of this block:

app.use(function (req, res, next) {
    if (isJSRequiringCoverage(req)) {
        var file = getFilePath(req), //translate request to file name to be delivered
            code = readTheCodeFromFile(file), //use async for a real implementation
            instrumenter = im.getInstrumenter();
        res.send(instrumenter.instrumentSync(code, file));
            //exception handling omitted for brevity
    } else {
        next();
    }
});

something like this:

let  instrumenter = im.getInstrumenter();

app.use(function (req, res, next) {
     let file = getFilePath(req);
     fs.createReadStream(file).pipe(instrumenter.instrument(file)).pipe(res);
});

does something like this exist?

ORESoftware avatar May 31 '17 21:05 ORESoftware

if this is possible, something like this def belongs in the readme...however it would totally make sense if it were pretty much impossible to instrument code asynchronously/line-by-line.

ORESoftware avatar Jun 01 '17 18:06 ORESoftware