- Notifications
You must be signed in to change notification settings - Fork15
Parse JavaScript source maps
License
NotificationsYou must be signed in to change notification settings
mattrobenolt/python-sourcemap
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Parse JavaScript source maps.
Based onhttps://github.com/martine/python-sourcemap
$ pip install sourcemap
>>>importsourcemap>>>sourcemap.discover('...')'jquery.min.map'>>>index=sourcemap.loads('...')>>>index.lookup(line=10,column=10)<Token:dst_line=10dst_column=10src='jquery.js'src_line=50src_col=200name='lol'>
# Load in our original minified file>>>minified=open('jquery.min.js').read()# Discover the path to the source map>>>map_path=sourcemap.discover(minified)# Read and parse our sourcemap>>>index=sourcemap.load(open(map_path))# Look up the line/column from the minified file>>>token=index.lookup(line=0,column=3040)# Grab the line from the original source that this token points to>>>source=open('jquery.js').readlines()>>>culprit=source[token.src_line]# 5 lines before>>>pre_context=source[token.src_line-5:token.src_line]# 5 lines after>>>post_context=source[token.src_line+1:token.src_line+6]
- Python 3.9
- Python 3.10
- Python 3.11
- Python 3.12
- Python 3.13
- PyPy 3.10
About
Parse JavaScript source maps
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.