Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Parse JavaScript source maps

License

NotificationsYou must be signed in to change notification settings

mattrobenolt/python-sourcemap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parse JavaScript source maps.

Based onhttps://github.com/martine/python-sourcemap

Installation

$ pip install sourcemap

Usage

Overview

>>>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'>

Get lines of context

# 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]

Compatibility

  • 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

Stars

Watchers

Forks

Packages

No packages published

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp