# Source Map JS
[![NPM](https://nodei.co/npm/source-map-js.png?downloads=true&downloadRank=true)](https://www.npmjs.com/package/source-map-js)
Difference between original [source-map](https://github.com/mozilla/source-map):
> TL,DR: it's fork of original source-map@0.6, but with perfomance optimizations.
This journey starts from [source-map@0.7.0](https://github.com/mozilla/source-map/blob/master/CHANGELOG.md#070). Some part of it was rewritten to Rust and WASM and API became async.
It's still a major block for many libraries like PostCSS or Sass for example because they need to migrate the whole API to the async way. This is the reason why 0.6.1 has 2x more downloads than 0.7.3 while it's faster several times.
![Downloads count](media/downloads.png)
More important that WASM version has some optimizations in JS code too. This is why [community asked to create branch for 0.6 version](https://github.com/mozilla/source-map/issues/324) and port these optimizations but, sadly, the answer was «no». A bit later I discovered [the issue](https://github.com/mozilla/source-map/issues/370) created by [Ben Rothman (@benthemonkey)](https://github.com/benthemonkey) with no response at all.
[Roman Dvornov (@lahmatiy)](https://github.com/lahmatiy) wrote a [serveral posts](https://t.me/gorshochekvarit/76) (russian, only, sorry) about source-map library in his own Telegram channel. He mentioned the article [«Maybe you don't need Rust and WASM to speed up your JS»](https://mrale.ph/blog/2018/02/03/maybe-you-dont-need-rust-to-speed-up-your-js.html) written by [Vyacheslav Egorov (@mraleph)](https://github.com/mraleph). This article contains optimizations and hacks that lead to almost the same performance compare to WASM implementation.
I decided to fork the original source-map and port these optimizations from the article and several others PR from the original source-map.
---------
This is a library to generate and consume the source map format
[described here][format].
[format]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
## Use with Node
$ npm install source-map-js
<!-- ## Use on the Web
<script src="https://raw.githubusercontent.com/mozilla/source-map/master/dist/source-map.min.js" defer></script> -->
--------------------------------------------------------------------------------
<!-- `npm run toc` to regenerate the Table of Contents -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents
- [Examples](#examples)
- [Consuming a source map](#consuming-a-source-map)
- [Generating a source map](#generating-a-source-map)
- [With SourceNode (high level API)](#with-sourcenode-high-level-api)
- [With SourceMapGenerator (low level API)](#with-sourcemapgenerator-low-level-api)
- [API](#api)
- [SourceMapConsumer](#sourcemapconsumer)
- [new SourceMapConsumer(rawSourceMap)](#new-sourcemapconsumerrawsourcemap)
- [SourceMapConsumer.prototype.computeColumnSpans()](#sourcemapconsumerprototypecomputecolumnspans)
- [SourceMapConsumer.prototype.originalPositionFor(generatedPosition)](#sourcemapconsumerprototypeoriginalpositionforgeneratedposition)
- [SourceMapConsumer.prototype.generatedPositionFor(originalPosition)](#sourcemapconsumerprototypegeneratedpositionfororiginalposition)
- [SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)](#sourcemapconsumerprototypeallgeneratedpositionsfororiginalposition)
- [SourceMapConsumer.prototype.hasContentsOfAllSources()](#sourcemapconsumerprototypehascontentsofallsources)
- [SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])](#sourcemapconsumerprototypesourcecontentforsource-returnnullonmissing)
- [SourceMapConsumer.prototype.eachMapping(callback, context, order)](#sourcemapconsumerprototypeeachmappingcallback-context-order)
- [SourceMapGenerator](#sourcemapgenerator)
- [new SourceMapGenerator([startOfSourceMap])](#new-sourcemapgeneratorstartofsourcemap)
- [SourceMapGenerator.fromSourceMap(sourceMapConsumer)](#sourcemapgeneratorfromsourcemapsourcemapconsumer)
- [SourceMapGenerator.prototype.addMapping(mapping)](#sourcemapgeneratorprototypeaddmappingmapping)
- [SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)](#sourcemapgeneratorprototypesetsourcecontentsourcefile-sourcecontent)
- [SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])](#sourcemapgeneratorprototypeapplysourcemapsourcemapconsumer-sourcefile-sourcemappath)
- [SourceMapGenerator.prototype.toString()](#sourcemapgeneratorprototypetostring)
- [SourceNode](#sourcenode)
- [new SourceNode([line, column, source[, chunk[, name]]])](#new-sourcenodeline-column-source-chunk-name)
- [SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])](#sourcenodefromstringwithsourcemapcode-sourcemapconsumer-relativepath)
- [SourceNode.prototype.add(chunk)](#sourcenodeprototypeaddchunk)
- [SourceNode.prototype.prepend(chunk)](#sourcenodeprototypeprependchunk)
- [SourceNode.prototype.setSourceContent(sourceFile, sourceContent)](#sourcenodeprototypesetsourcecontentsourcefile-sourcecontent)
- [SourceNode.prototype.walk(fn)](#sourcenodeprototypewalkfn)
- [SourceNode.prototype.walkSourceContents(fn)](#sourcenodeprototypewalksourcecontentsfn)
- [SourceNode.prototype.join(sep)](#sourcenodeprototypejoinsep)
- [SourceNode.prototype.replaceRight(pattern, replacement)](#sourcenodeprototypereplacerightpattern-replacement)
- [SourceNode.prototype.toString()](#sourcenodeprototypetostring)
- [SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])](#sourcenodeprototypetostringwithsourcemapstartofsourcemap)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Examples
### Consuming a source map
```js
var rawSourceMap = {
version: 3,
file: 'min.js',
names: ['bar', 'baz', 'n'],
sources: ['one.js', 'two.js'],
sourceRoot: 'http://example.com/www/js/',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
};
var smc = new SourceMapConsumer(rawSourceMap);
console.log(smc.sources);
// [ 'http://example.com/www/js/one.js',
// 'http://example.com/www/js/two.js' ]
console.log(smc.originalPositionFor({
line: 2,
column: 28
}));
// { source: 'http://example.com/www/js/two.js',
// line: 2,
// column: 10,
// name: 'n' }
console.log(smc.generatedPositionFor({
source: 'http://example.com/www/js/two.js',
line: 2,
column: 10
}));
// { line: 2, column: 28 }
smc.eachMapping(function (m) {
// ...
});
```
### Generating a source map
In depth guide:
[**Compiling to JavaScript, and Debugging with Source Maps**](https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/)
#### With SourceNode (high level API)
```js
function compile(ast) {
switch (ast.type) {
case 'BinaryExpression':
return new SourceNode(
ast.location.line,
ast.location.column,
ast.location.source,
[compile(ast.left), " + ", compile(ast.right)]
);
case 'Literal':
return new SourceNode(
ast.location.line,
ast.location.column,
ast.location.source,
String(ast.value)
);
// ...
default:
throw new Error("Bad AST");
}
}
var ast = parse("40 + 2", "add.js");
console.log(compile(ast).toStringWithSourceMap({
file: 'add.js'
}));
// { code: '40 + 2',
// map: [object SourceMapGenerator] }
```
#### With SourceMapGenerator (low level API)
```js
var map = new SourceMapGenerator({
file: "source-mapped.js"
});
map.addMapping({
generated: {
line: 10,
column: 35
},
source: "foo.js",
original: {
line: 33,
column: 2
},
name: "christopher"
});
console.log(map.toString());
// '{"version":3,"file":"source-mapped.js","sources"
没有合适的资源?快使用搜索试试~ 我知道了~
远程问诊小程序医生端,在线接待患者
共2000个文件
js:771个
json:450个
vue:261个
需积分: 5 0 下载量 86 浏览量
2024-05-14
14:28:48
上传
评论
收藏 35.19MB RAR 举报
温馨提示
远程问诊小程序医生端,在线接待患者
资源推荐
资源详情
资源评论
收起资源包目录
远程问诊小程序医生端,在线接待患者 (2000个子文件)
02b4da62b9507cb78ccbb6306a02b5c4f3ea47 3KB
04f5751135f8b4656630a1942a1b6973994c18 427KB
056e4c60574559b2833e42b3ed8c0fc4cf3d73 789B
05708a4f42cb8f94963c8560854781eb0c93ff 184B
07610a4901835744fdd02319a86b831def2d42 452B
077f5dafe4ea3780999933518963b8b6551d8d 85B
07b5a9058b9a61e80bd6ac2af87dc8657b6299 498B
09e4205eed6b0d0288860e5f4ccddcb9ff1549 46B
0a777a82cc1e3d9c69fcfacd426087d86557cd 188B
0ac941e1568d59c89b67cb649051a14608ee79 2KB
0d6f490f5e79df9ef4749e77ae71f6e9600391 3KB
0dfddc3d7d397dfb2ee4178b59576353d25386 4KB
0f4a68874f575d3296364aeeb0a02c253eae39 190B
0fce3f1c38480a8e531564d9ba537bdd7d10dd 137B
13d1689e9de9aa4b454ff977edb79d2f9dcd1e 147B
15284ab3df6ba544c5ac10fc2841d74dd6531b 2KB
15305d26ce839c2d9b01864ec9bca7a799e58e 909B
16688c167eac017f66ca97e2aa2a4a8fc4b648 3KB
16d32410dc830029ffad845d74c8764d6a8b96 250B
182ca3203101836c7fb33bdc8a895524415bc5 568B
1abfdca32a168192aba135b224221590478b8a 3KB
1aec281393445a2bc9f89da2d80dfcf0b7efe8 135B
1d14a08b18a31d47ef55eb687fd42848c029d7 46B
1da2381d57fcb507d09d03d4f53590a09959c4 3KB
1df69abacc9b13f81248e8073933841e95f296 3KB
1e7d6ad5a090acc0ee685d373bbf205a4e7bbb 214B
1edf7a9959c9f400cd3e07a40eb7bc891efb45 333B
1f870b99ab61d66de1c57d0444d39e0e7b358e 57B
1f8c90de691934e247f718b49134bb4845d0ab 60B
2007c3fb6a14dd0c6c356e5daf7b62da1d8113 99B
2078aa3d0b666805ca837de82a4bb0b530d216 1KB
23bf324e195b62424731223263077936462638 4KB
2561141c8d852d19f7ef9170bde2e762539900 845B
2633c0b399d119fe940b19fb48ee0efd986ca1 557B
2753df8244c278ca329f1c2a5f3240410bfc41 135B
291aa3a79faba1dd68edd4da167d12d3d776b2 1KB
2a39d1b5d3b1c29434c74db378e1240b6dcb9a 58B
2a3bd8ec4b65959254995b7d681d805f976f96 162B
2c184936c42c4fc40e539c556ba06f5b373ffe 484B
3139b09e34d03b814f729b985159796bf2f636 503B
348c1b32baa5abb52f8b336af60bfd5411ed84 59B
3939df4f1e879efc3bb9a36a6cea2c75ff4f4c 81B
3a3c549862b58863baf4e5550aa92d9c74e069 184B
3e818bffddcd11afb49185715c19fa4c07c091 205B
3edfc806f1da770743e3f564c1a14bc3345885 162B
409cb1e0c3f91d9671d66cd166849f229df885 376B
418a86fa95ef73aebf82ba0a881aa0cdb33fa8 320B
42c268d464bd4093653baea44ea7abb85e1496 77B
430d4b0b7e586a0307a4e95df15f0e18fee027 3KB
43531eece73f0d263bab01ea408abd0739a65b 2KB
43612483a678b05513bdc4085e3822c4e21b24 42B
43e800b5a6351b4aa4874a59d543415228b20f 992B
473080ebfdcfc0d06e45ea9db9a7c282335f45 536B
48e77155fb9ab3afc57075245e4d3d0d5073ff 94B
4ad0b0e99d6b57f063f253370184e1fae1e9d7 342B
4f9eaa77da1c5b66be8e59849cececdf941994 137B
548cd97e482682c284e9f97585d8b3de4a852b 68B
56716aa32e13cee19beb25013f62c289facf4a 11KB
5754105949d002336c4d6d2f9d7561d7b75fc6 2KB
583637c2716ae0c4f99d9ac0c5aa816c475355 612B
58d3010130922cd9c333371eb31a232c57d79a 1KB
625d6860faa27668cb251f8afce6c770e03b6e 4KB
62999f14282887a7a77a837b5247abb373e25a 59B
62bab4cd8d7bf4837de0827e41c45f8336bc3b 55B
63403561621e582d68cd70d4791a4b4ea3ce71 3KB
649fe18d9444424b6b4c87737790d5bdd0b800 384B
65e4e4ee6469ae97a13825fd6eb1a22c08fe6d 4KB
673e7c38b29f62e6a4c867372b132ab6ec0e90 986B
68e144a71b34ae74d6fa3ca6e0ed8ecad8ed44 120B
6907602484e68865bc30ad41f1c25960b15d13 374B
69380c7a63b19875fdd0b1e423a5a66eaa7243 2KB
6b580f7824445bc1439e94b2cb76167d7d1191 6KB
6d7c2c82dacf7c5a0390818031ac462561a039 218B
6e0002dea455c3a77efb33dfbaa6003ffa24ae 1KB
6fb12652d9acd1221e0c4e99df250032d1f74a 717B
72a72b3decbbc3287a51c6b45d859fc435b4ce 59B
74dc824a5c72140d917b79c9b28a87213b8019 88B
76e18411e4eeab7f874892395824ab75f0601b 135B
76ee686095349934ad6830dbf50d8511ee7aa6 292B
788c58ad9e051ea4760ae66666cccd30a236a3 133B
7a2ffc536a20c4fdd050f2d4e4fbdc32f953b3 214B
7ae57d78d042beb146168d5fece899046f37cb 2KB
7bc1f7c2f5cea9ce80b021fbe974776c58a00a 58B
7c0f849695eb2ad9768ce1df8ebecfe738c7fb 56B
7d3109c55cc972729ceafbcc748b3ea5eb4992 1KB
7e8018a32a477797409e4ef51c80b4ec832135 186B
7faab777eabc0f9aa4d058b64ce2eaebd94c06 312B
813bf5d3d6db90efc3981270c636833f6c4b85 470B
829e5c9f88673fffac7cce28bcff9e9165a613 83B
82f73b72883c771e70a599748fe26bc2a2a3dc 1KB
8590d6ce9255ac5d1d485dc171e5464a0a2da6 2KB
875d8117deca1a97f1becf92504d45a150df21 136B
8b46c92b2c9fd636a2d3db63a4fcb05f8b70d2 3KB
8bf57c8e263de7864ecc81b6917712cdfff30c 2KB
9023b8ad0242a283bff127a59b1113c0f6d5be 59B
93265dfb90c8ea1e66349a06121af1bb3a1f21 112B
957f7be7cf5128b9df57002baccbbb38575fa9 132B
95afa79dfac0313466c8443c111652e3a5d582 6KB
95d9b9b591d923658345e09167182f5cac2d7a 2KB
95e305a683b5c30636766462d76571d46fd8a1 171B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
程序员涛涛
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功