Skip to content

capaj/get-source-code-location

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get-source-code-location

Made specifically for working with babylon SourceLocation objects to extract pieces of code from a source file.

Usage

const getSourceCodeLocation = require('get-source-code-location')

getSourceCode(source, {
  start: { line: 8, column: 2 },
  end: { line: 8, column: 12 }
})
// returns a string on 8th line between collumns 2 and 12
// if the file is shorter than 8 lines, it will throw an error

About

minimalistic module, which can find a portion of a text file when given a SourceLocation

Resources

License

Stars

Watchers

Forks

Packages

No packages published