MCPcopy
hub / github.com/mozilla/source-map / setSourceContent

Method setSourceContent

lib/source-map-generator.js:137–158  ·  view source on GitHub ↗

* Set the source content for a source file.

(aSourceFile, aSourceContent)

Source from the content-addressed store, hash-verified

135 * Set the source content for a source file.
136 */
137 setSourceContent(aSourceFile, aSourceContent) {
138 let source = aSourceFile;
139 if (this._sourceRoot != null) {
140 source = util.relative(this._sourceRoot, source);
141 }
142
143 if (aSourceContent != null) {
144 // Add the source content to the _sourcesContents map.
145 // Create a new _sourcesContents map if the property is null.
146 if (!this._sourcesContents) {
147 this._sourcesContents = Object.create(null);
148 }
149 this._sourcesContents[util.toSetString(source)] = aSourceContent;
150 } else if (this._sourcesContents) {
151 // Remove the source file from the _sourcesContents map.
152 // If the _sourcesContents map is empty, set the property to null.
153 delete this._sourcesContents[util.toSetString(source)];
154 if (Object.keys(this._sourcesContents).length === 0) {
155 this._sourcesContents = null;
156 }
157 }
158 }
159
160 /**
161 * Applies the mappings of a sub-source-map for a specific source file to the

Callers 4

toStringWithSourceMapMethod · 0.95
fromSourceMapMethod · 0.95
applySourceMapMethod · 0.95
expectedMapFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected