source: trip-planner-front/node_modules/webpack-sources/lib/ConcatSource.js@ 6c1585f

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

initial commit

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5"use strict";
6
7const SourceNode = require("source-map").SourceNode;
8const SourceListMap = require("source-list-map").SourceListMap;
9const Source = require("./Source");
10
11class ConcatSource extends Source {
12 constructor() {
13 super();
14 this.children = [];
15 for(var i = 0; i < arguments.length; i++) {
16 var item = arguments[i];
17 if(item instanceof ConcatSource) {
18 var children = item.children;
19 for(var j = 0; j < children.length; j++)
20 this.children.push(children[j]);
21 } else {
22 this.children.push(item);
23 }
24 }
25 }
26
27 add(item) {
28 if(item instanceof ConcatSource) {
29 var children = item.children;
30 for(var j = 0; j < children.length; j++)
31 this.children.push(children[j]);
32 } else {
33 this.children.push(item);
34 }
35 }
36
37 source() {
38 let source = "";
39 const children = this.children;
40 for(let i = 0; i < children.length; i++) {
41 const child = children[i];
42 source += typeof child === "string" ? child : child.source();
43 }
44 return source;
45 }
46
47 size() {
48 let size = 0;
49 const children = this.children;
50 for(let i = 0; i < children.length; i++) {
51 const child = children[i];
52 size += typeof child === "string" ? child.length : child.size();
53 }
54 return size;
55 }
56
57 node(options) {
58 const node = new SourceNode(null, null, null, this.children.map(function(item) {
59 return typeof item === "string" ? item : item.node(options);
60 }));
61 return node;
62 }
63
64 listMap(options) {
65 const map = new SourceListMap();
66 var children = this.children;
67 for(var i = 0; i < children.length; i++) {
68 var item = children[i];
69 if(typeof item === "string")
70 map.add(item);
71 else
72 map.add(item.listMap(options));
73 }
74 return map;
75 }
76
77 updateHash(hash) {
78 var children = this.children;
79 for(var i = 0; i < children.length; i++) {
80 var item = children[i];
81 if(typeof item === "string")
82 hash.update(item);
83 else
84 item.updateHash(hash);
85 }
86 }
87}
88
89require("./SourceAndMapMixin")(ConcatSource.prototype);
90
91module.exports = ConcatSource;
Note: See TracBrowser for help on using the repository browser.