Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(688)

Unified Diff: node_modules/vulcanize/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js

Issue 800513006: Added vulcanize under third_party/npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: node_modules/vulcanize/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js
diff --git a/node_modules/karma/node_modules/source-map/lib/source-map/source-map-generator.js b/node_modules/vulcanize/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js
similarity index 90%
copy from node_modules/karma/node_modules/source-map/lib/source-map/source-map-generator.js
copy to node_modules/vulcanize/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js
index 5387fa1d49a2467f37742de0130e4892d11f4b94..fb6d6c38cdd327299b9eedae7f01790e7e0c80e9 100644
--- a/node_modules/karma/node_modules/source-map/lib/source-map/source-map-generator.js
+++ b/node_modules/vulcanize/node_modules/uglify-js/node_modules/source-map/lib/source-map/source-map-generator.js
@@ -55,9 +55,9 @@ define(function (require, exports, module) {
}
};
- if (mapping.source != null) {
+ if (mapping.source) {
newMapping.source = mapping.source;
- if (sourceRoot != null) {
+ if (sourceRoot) {
newMapping.source = util.relative(sourceRoot, newMapping.source);
}
@@ -66,7 +66,7 @@ define(function (require, exports, module) {
column: mapping.originalColumn
};
- if (mapping.name != null) {
+ if (mapping.name) {
newMapping.name = mapping.name;
}
}
@@ -75,7 +75,7 @@ define(function (require, exports, module) {
});
aSourceMapConsumer.sources.forEach(function (sourceFile) {
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
- if (content != null) {
+ if (content) {
generator.setSourceContent(sourceFile, content);
}
});
@@ -101,11 +101,11 @@ define(function (require, exports, module) {
this._validateMapping(generated, original, source, name);
- if (source != null && !this._sources.has(source)) {
+ if (source && !this._sources.has(source)) {
this._sources.add(source);
}
- if (name != null && !this._names.has(name)) {
+ if (name && !this._names.has(name)) {
this._names.add(name);
}
@@ -125,18 +125,18 @@ define(function (require, exports, module) {
SourceMapGenerator.prototype.setSourceContent =
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
var source = aSourceFile;
- if (this._sourceRoot != null) {
+ if (this._sourceRoot) {
source = util.relative(this._sourceRoot, source);
}
- if (aSourceContent != null) {
+ if (aSourceContent !== null) {
// Add the source content to the _sourcesContents map.
// Create a new _sourcesContents map if the property is null.
if (!this._sourcesContents) {
this._sourcesContents = {};
}
this._sourcesContents[util.toSetString(source)] = aSourceContent;
- } else if (this._sourcesContents) {
+ } else {
// Remove the source file from the _sourcesContents map.
// If the _sourcesContents map is empty, set the property to null.
delete this._sourcesContents[util.toSetString(source)];
@@ -164,59 +164,60 @@ define(function (require, exports, module) {
*/
SourceMapGenerator.prototype.applySourceMap =
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
- var sourceFile = aSourceFile;
// If aSourceFile is omitted, we will use the file property of the SourceMap
- if (aSourceFile == null) {
- if (aSourceMapConsumer.file == null) {
+ if (!aSourceFile) {
+ if (!aSourceMapConsumer.file) {
throw new Error(
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
'or the source map\'s "file" property. Both were omitted.'
);
}
- sourceFile = aSourceMapConsumer.file;
+ aSourceFile = aSourceMapConsumer.file;
}
var sourceRoot = this._sourceRoot;
- // Make "sourceFile" relative if an absolute Url is passed.
- if (sourceRoot != null) {
- sourceFile = util.relative(sourceRoot, sourceFile);
+ // Make "aSourceFile" relative if an absolute Url is passed.
+ if (sourceRoot) {
+ aSourceFile = util.relative(sourceRoot, aSourceFile);
}
// Applying the SourceMap can add and remove items from the sources and
// the names array.
var newSources = new ArraySet();
var newNames = new ArraySet();
- // Find mappings for the "sourceFile"
+ // Find mappings for the "aSourceFile"
this._mappings.forEach(function (mapping) {
- if (mapping.source === sourceFile && mapping.originalLine != null) {
+ if (mapping.source === aSourceFile && mapping.originalLine) {
// Check if it can be mapped by the source map, then update the mapping.
var original = aSourceMapConsumer.originalPositionFor({
line: mapping.originalLine,
column: mapping.originalColumn
});
- if (original.source != null) {
+ if (original.source !== null) {
// Copy mapping
mapping.source = original.source;
- if (aSourceMapPath != null) {
+ if (aSourceMapPath) {
mapping.source = util.join(aSourceMapPath, mapping.source)
}
- if (sourceRoot != null) {
+ if (sourceRoot) {
mapping.source = util.relative(sourceRoot, mapping.source);
}
mapping.originalLine = original.line;
mapping.originalColumn = original.column;
- if (original.name != null) {
+ if (original.name !== null && mapping.name !== null) {
+ // Only use the identifier name if it's an identifier
+ // in both SourceMaps
mapping.name = original.name;
}
}
}
var source = mapping.source;
- if (source != null && !newSources.has(source)) {
+ if (source && !newSources.has(source)) {
newSources.add(source);
}
var name = mapping.name;
- if (name != null && !newNames.has(name)) {
+ if (name && !newNames.has(name)) {
newNames.add(name);
}
@@ -227,11 +228,11 @@ define(function (require, exports, module) {
// Copy sourcesContents of applied map.
aSourceMapConsumer.sources.forEach(function (sourceFile) {
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
- if (content != null) {
- if (aSourceMapPath != null) {
+ if (content) {
+ if (aSourceMapPath) {
sourceFile = util.join(aSourceMapPath, sourceFile);
}
- if (sourceRoot != null) {
+ if (sourceRoot) {
sourceFile = util.relative(sourceRoot, sourceFile);
}
this.setSourceContent(sourceFile, content);
@@ -322,7 +323,7 @@ define(function (require, exports, module) {
- previousGeneratedColumn);
previousGeneratedColumn = mapping.generatedColumn;
- if (mapping.source != null) {
+ if (mapping.source) {
result += base64VLQ.encode(this._sources.indexOf(mapping.source)
- previousSource);
previousSource = this._sources.indexOf(mapping.source);
@@ -336,7 +337,7 @@ define(function (require, exports, module) {
- previousOriginalColumn);
previousOriginalColumn = mapping.originalColumn;
- if (mapping.name != null) {
+ if (mapping.name) {
result += base64VLQ.encode(this._names.indexOf(mapping.name)
- previousName);
previousName = this._names.indexOf(mapping.name);
@@ -353,7 +354,7 @@ define(function (require, exports, module) {
if (!this._sourcesContents) {
return null;
}
- if (aSourceRoot != null) {
+ if (aSourceRoot) {
source = util.relative(aSourceRoot, source);
}
var key = util.toSetString(source);
@@ -371,14 +372,12 @@ define(function (require, exports, module) {
function SourceMapGenerator_toJSON() {
var map = {
version: this._version,
+ file: this._file,
sources: this._sources.toArray(),
names: this._names.toArray(),
mappings: this._serializeMappings()
};
- if (this._file != null) {
- map.file = this._file;
- }
- if (this._sourceRoot != null) {
+ if (this._sourceRoot) {
map.sourceRoot = this._sourceRoot;
}
if (this._sourcesContents) {

Powered by Google App Engine
This is Rietveld 408576698