aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack-sources/lib/OriginalSource.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/webpack-sources/lib/OriginalSource.js
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/webpack-sources/lib/OriginalSource.js')
-rw-r--r--node_modules/webpack-sources/lib/OriginalSource.js91
1 files changed, 46 insertions, 45 deletions
diff --git a/node_modules/webpack-sources/lib/OriginalSource.js b/node_modules/webpack-sources/lib/OriginalSource.js
index ac80db8a2..24380fcce 100644
--- a/node_modules/webpack-sources/lib/OriginalSource.js
+++ b/node_modules/webpack-sources/lib/OriginalSource.js
@@ -2,6 +2,8 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
+"use strict";
+
var SourceNode = require("source-map").SourceNode;
var SourceMapConsumer = require("source-map").SourceMapConsumer;
var SourceListMap = require("source-list-map").SourceListMap;
@@ -35,54 +37,53 @@ function _splitCode(code) {
return result;
}
-function OriginalSource(value, name) {
- Source.call(this);
- this._value = value;
- this._name = name;
-}
-
-module.exports = OriginalSource;
+class OriginalSource extends Source {
+ constructor(value, name) {
+ super();
+ this._value = value;
+ this._name = name;
+ }
-OriginalSource.prototype = Object.create(Source.prototype);
-OriginalSource.prototype.constructor = OriginalSource;
+ source() {
+ return this._value;
+ }
-OriginalSource.prototype.source = function() {
- return this._value;
-};
+ node(options) {
+ options = options || {};
+ var sourceMap = this._sourceMap;
+ var value = this._value;
+ var name = this._name;
+ var lines = value.split("\n");
+ var node = new SourceNode(null, null, null,
+ lines.map(function(line, idx) {
+ var pos = 0;
+ if(options.columns === false) {
+ var content = line + (idx != lines.length - 1 ? "\n" : "");
+ return new SourceNode(idx + 1, 0, name, content);
+ }
+ return new SourceNode(null, null, null,
+ _splitCode(line + (idx != lines.length - 1 ? "\n" : "")).map(function(item) {
+ if(/^\s*$/.test(item)) return item;
+ var res = new SourceNode(idx + 1, pos, name, item);
+ pos += item.length;
+ return res;
+ })
+ );
+ })
+ );
+ node.setSourceContent(name, value);
+ return node;
+ }
-require("./SourceAndMapMixin")(OriginalSource.prototype);
+ listMap(options) {
+ return new SourceListMap(this._value, this._name, this._value)
+ }
-OriginalSource.prototype.node = function(options) {
- options = options || {};
- var sourceMap = this._sourceMap;
- var value = this._value;
- var name = this._name;
- var lines = value.split("\n");
- var node = new SourceNode(null, null, null,
- lines.map(function(line, idx) {
- var pos = 0;
- if(options.columns === false) {
- var content = line + (idx != lines.length - 1 ? "\n" : "");
- return new SourceNode(idx + 1, 0, name, content);
- }
- return new SourceNode(null, null, null,
- _splitCode(line + (idx != lines.length - 1 ? "\n" : "")).map(function(item) {
- if(/^\s*$/.test(item)) return item;
- var res = new SourceNode(idx + 1, pos, name, item);
- pos += item.length;
- return res;
- })
- );
- })
- );
- node.setSourceContent(name, value);
- return node;
-};
+ updateHash(hash) {
+ hash.update(this._value);
+ }
+}
-OriginalSource.prototype.listMap = function(options) {
- return new SourceListMap(this._value, this._name, this._value)
-};
+require("./SourceAndMapMixin")(OriginalSource.prototype);
-OriginalSource.prototype.updateHash = function(hash) {
- hash.update(this._value);
-};
+module.exports = OriginalSource;