Skip to content

Instantly share code, notes, and snippets.

@wataruoguchi
Created January 23, 2020 07:32
Show Gist options
  • Save wataruoguchi/6a4f142cb32873f0a693b0246cf784e4 to your computer and use it in GitHub Desktop.
Save wataruoguchi/6a4f142cb32873f0a693b0246cf784e4 to your computer and use it in GitHub Desktop.
Notes for reading istanbuljs

Reading istanbuljs

It's a class file.

class Instrumenter

  • Methods:
    • instrumentSync: It takes code, filename, and inputSourceMap. It creates babelOpts and generate sourcemap and AST with @babel/core#transformSync. The babelOpts is using their own plugin programVisitor. readInitialCoverage is used against the AST generated.
    • instrument: Callback style... not sure if I'm interested.
    • lastFileCoverage: returns fileCoverage property.
    • lastSourceMap: returns sourceMap property.

This is where programVisitor is from. It contains the VisitState class.

class VisitState

  • Methods:
    • shouldIgnore:
    • hintFor:
    • maybeAssignSourceMapURL:
    • counterNeedsHoisting:
    • onEnter:
    • onExit:
    • setAttr:
    • getAttr:
    • increase:
    • insertCounter:
    • insertStatementCounter:
    • insertFunctionCounter:
    • getBranchIncrement:
    • findLeaves:

To be continued

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment