aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack-sources/lib/ConcatSource.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/ConcatSource.js
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/webpack-sources/lib/ConcatSource.js')
-rw-r--r--node_modules/webpack-sources/lib/ConcatSource.js104
1 files changed, 53 insertions, 51 deletions
diff --git a/node_modules/webpack-sources/lib/ConcatSource.js b/node_modules/webpack-sources/lib/ConcatSource.js
index 434aa3e5c..8dc712d9c 100644
--- a/node_modules/webpack-sources/lib/ConcatSource.js
+++ b/node_modules/webpack-sources/lib/ConcatSource.js
@@ -2,62 +2,64 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var SourceNode = require("source-map").SourceNode;
-var SourceListMap = require("source-list-map").SourceListMap;
-var Source = require("./Source");
+"use strict";
-function ConcatSource() {
- Source.call(this);
- this.children = Array.prototype.slice.call(arguments);
-}
-module.exports = ConcatSource;
+const SourceNode = require("source-map").SourceNode;
+const SourceListMap = require("source-list-map").SourceListMap;
+const Source = require("./Source");
+
+class ConcatSource extends Source {
+ constructor() {
+ super();
+ this.children = Array.prototype.slice.call(arguments);
+ }
+
+ add(item) {
+ this.children.push(item);
+ }
-ConcatSource.prototype = Object.create(Source.prototype);
-ConcatSource.prototype.constructor = ConcatSource;
+ source() {
+ return this.children.map(function(item) {
+ return typeof item === "string" ? item : item.source();
+ }).join("");
+ }
-ConcatSource.prototype.add = function(item) {
- this.children.push(item);
-};
+ size() {
+ return this.children.map(function(item) {
+ return typeof item === "string" ? item.length : item.size();
+ }).reduce(function(sum, s) {
+ return sum + s;
+ }, 0);
+ }
-ConcatSource.prototype.source = function() {
- return this.children.map(function(item) {
- return typeof item === "string" ? item : item.source();
- }).join("");
-};
+ node(options) {
+ const node = new SourceNode(null, null, null, this.children.map(function(item) {
+ return typeof item === "string" ? item : item.node(options);
+ }));
+ return node;
+ }
-ConcatSource.prototype.size = function() {
- return this.children.map(function(item) {
- return typeof item === "string" ? item.length : item.size();
- }).reduce(function(sum, s) {
- return sum + s;
- }, 0);
-};
+ listMap(options) {
+ const map = new SourceListMap();
+ this.children.forEach(function(item) {
+ if(typeof item === "string")
+ map.add(item);
+ else
+ map.add(item.listMap(options));
+ });
+ return map;
+ }
+
+ updateHash(hash) {
+ this.children.forEach(function(item) {
+ if(typeof item === "string")
+ hash.update(item);
+ else
+ item.updateHash(hash);
+ });
+ }
+}
require("./SourceAndMapMixin")(ConcatSource.prototype);
-ConcatSource.prototype.node = function(options) {
- var node = new SourceNode(null, null, null, this.children.map(function(item) {
- return typeof item === "string" ? item : item.node(options);
- }));
- return node;
-};
-
-ConcatSource.prototype.listMap = function(options) {
- var map = new SourceListMap();
- this.children.forEach(function(item) {
- if(typeof item === "string")
- map.add(item);
- else
- map.add(item.listMap(options));
- });
- return map;
-};
-
-ConcatSource.prototype.updateHash = function(hash) {
- this.children.forEach(function(item) {
- if(typeof item === "string")
- hash.update(item);
- else
- item.updateHash(hash);
- });
-};
+module.exports = ConcatSource;