source: trip-planner-front/node_modules/webpack-sources/lib/LineToLineMappedSource.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5"use strict";
6
7var SourceNode = require("source-map").SourceNode;
8var SourceMapConsumer = require("source-map").SourceMapConsumer;
9var SourceListMap = require("source-list-map").SourceListMap;
10var Source = require("./Source");
11
12class LineToLineMappedSource extends Source {
13 constructor(value, name, originalSource) {
14 super();
15 this._value = value;
16 this._name = name;
17 this._originalSource = originalSource;
18 }
19
20 source() {
21 return this._value;
22 }
23
24 node(options) {
25 var value = this._value;
26 var name = this._name;
27 var lines = value.split("\n");
28 var node = new SourceNode(null, null, null,
29 lines.map(function(line, idx) {
30 return new SourceNode(idx + 1, 0, name, (line + (idx != lines.length - 1 ? "\n" : "")));
31 })
32 );
33 node.setSourceContent(name, this._originalSource);
34 return node;
35 }
36
37 listMap(options) {
38 return new SourceListMap(this._value, this._name, this._originalSource)
39 }
40
41 updateHash(hash) {
42 hash.update(this._value);
43 hash.update(this._originalSource);
44 }
45}
46
47require("./SourceAndMapMixin")(LineToLineMappedSource.prototype);
48
49module.exports = LineToLineMappedSource;
Note: See TracBrowser for help on using the repository browser.