diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/webpack-sources/lib/ConcatSource.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
Diffstat (limited to 'node_modules/webpack-sources/lib/ConcatSource.js')
-rw-r--r-- | node_modules/webpack-sources/lib/ConcatSource.js | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/node_modules/webpack-sources/lib/ConcatSource.js b/node_modules/webpack-sources/lib/ConcatSource.js index 8dc712d9c..b2b59707b 100644 --- a/node_modules/webpack-sources/lib/ConcatSource.js +++ b/node_modules/webpack-sources/lib/ConcatSource.js @@ -11,25 +11,47 @@ const Source = require("./Source"); class ConcatSource extends Source {
constructor() {
super();
- this.children = Array.prototype.slice.call(arguments);
+ this.children = [];
+ for(var i = 0; i < arguments.length; i++) {
+ var item = arguments[i];
+ if(item instanceof ConcatSource) {
+ var children = item.children;
+ for(var j = 0; j < children.length; j++)
+ this.children.push(children[j]);
+ } else {
+ this.children.push(item);
+ }
+ }
}
add(item) {
- this.children.push(item);
+ if(item instanceof ConcatSource) {
+ var children = item.children;
+ for(var j = 0; j < children.length; j++)
+ this.children.push(children[j]);
+ } else {
+ this.children.push(item);
+ }
}
source() {
- return this.children.map(function(item) {
- return typeof item === "string" ? item : item.source();
- }).join("");
+ let source = "";
+ const children = this.children;
+ for(let i = 0; i < children.length; i++) {
+ const child = children[i];
+ source += typeof child === "string" ? child : child.source();
+ }
+ return source;
}
size() {
- return this.children.map(function(item) {
- return typeof item === "string" ? item.length : item.size();
- }).reduce(function(sum, s) {
- return sum + s;
- }, 0);
+ let size = 0;
+ const children = this.children;
+ for(let i = 0; i < children.length; i++) {
+ const child = children[i];
+ size += typeof child === "string" ? child.length : child.size();
+ }
+ return size;
}
node(options) {
@@ -41,22 +63,26 @@ class ConcatSource extends Source { listMap(options) {
const map = new SourceListMap();
- this.children.forEach(function(item) {
+ var children = this.children;
+ for(var i = 0; i < children.length; i++) {
+ var item = children[i];
if(typeof item === "string")
map.add(item);
else
map.add(item.listMap(options));
- });
+ }
return map;
}
updateHash(hash) {
- this.children.forEach(function(item) {
+ var children = this.children;
+ for(var i = 0; i < children.length; i++) {
+ var item = children[i];
if(typeof item === "string")
hash.update(item);
else
item.updateHash(hash);
- });
+ }
}
}
|