diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/webpack-sources/lib/CachedSource.js | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/webpack-sources/lib/CachedSource.js')
-rw-r--r-- | node_modules/webpack-sources/lib/CachedSource.js | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/node_modules/webpack-sources/lib/CachedSource.js b/node_modules/webpack-sources/lib/CachedSource.js index 0a81c5c45..940c4d9f3 100644 --- a/node_modules/webpack-sources/lib/CachedSource.js +++ b/node_modules/webpack-sources/lib/CachedSource.js @@ -1,78 +1,78 @@ -/*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
-*/
-"use strict";
-
-const Source = require("./Source");
-
-class CachedSource extends Source {
- constructor(source) {
- super();
- this._source = source;
- this._cachedSource = undefined;
- this._cachedSize = undefined;
- this._cachedMaps = {};
-
- if(source.node) this.node = function(options) {
- return this._source.node(options);
- };
-
- if(source.listMap) this.listMap = function(options) {
- return this._source.listMap(options);
- };
- }
-
- source() {
- if(typeof this._cachedSource !== "undefined") return this._cachedSource;
- return this._cachedSource = this._source.source();
- }
-
- size() {
- if(typeof this._cachedSize !== "undefined") return this._cachedSize;
- if(typeof this._cachedSource !== "undefined")
- return this._cachedSize = this._cachedSource.length;
- return this._cachedSize = this._source.size();
- }
-
- sourceAndMap(options) {
- const key = JSON.stringify(options);
- if(typeof this._cachedSource !== "undefined" && key in this._cachedMaps)
- return {
- source: this._cachedSource,
- map: this._cachedMaps[key]
- };
- else if(typeof this._cachedSource !== "undefined") {
- return {
- source: this._cachedSource,
- map: this._cachedMaps[key] = this._source.map(options)
- };
- } else if(key in this._cachedMaps) {
- return {
- source: this._cachedSource = this._source.source(),
- map: this._cachedMaps[key]
- };
- }
- const result = this._source.sourceAndMap(options);
- this._cachedSource = result.source;
- this._cachedMaps[key] = result.map;
- return {
- source: this._cachedSource,
- map: this._cachedMaps[key]
- };
- }
-
- map(options) {
- if(!options) options = {};
- const key = JSON.stringify(options);
- if(key in this._cachedMaps)
- return this._cachedMaps[key];
- return this._cachedMaps[key] = this._source.map();
- }
-
- updateHash(hash) {
- this._source.updateHash(hash);
- }
-}
-
-module.exports = CachedSource;
+/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Source = require("./Source"); + +class CachedSource extends Source { + constructor(source) { + super(); + this._source = source; + this._cachedSource = undefined; + this._cachedSize = undefined; + this._cachedMaps = {}; + + if(source.node) this.node = function(options) { + return this._source.node(options); + }; + + if(source.listMap) this.listMap = function(options) { + return this._source.listMap(options); + }; + } + + source() { + if(typeof this._cachedSource !== "undefined") return this._cachedSource; + return this._cachedSource = this._source.source(); + } + + size() { + if(typeof this._cachedSize !== "undefined") return this._cachedSize; + if(typeof this._cachedSource !== "undefined") + return this._cachedSize = this._cachedSource.length; + return this._cachedSize = this._source.size(); + } + + sourceAndMap(options) { + const key = JSON.stringify(options); + if(typeof this._cachedSource !== "undefined" && key in this._cachedMaps) + return { + source: this._cachedSource, + map: this._cachedMaps[key] + }; + else if(typeof this._cachedSource !== "undefined") { + return { + source: this._cachedSource, + map: this._cachedMaps[key] = this._source.map(options) + }; + } else if(key in this._cachedMaps) { + return { + source: this._cachedSource = this._source.source(), + map: this._cachedMaps[key] + }; + } + const result = this._source.sourceAndMap(options); + this._cachedSource = result.source; + this._cachedMaps[key] = result.map; + return { + source: this._cachedSource, + map: this._cachedMaps[key] + }; + } + + map(options) { + if(!options) options = {}; + const key = JSON.stringify(options); + if(key in this._cachedMaps) + return this._cachedMaps[key]; + return this._cachedMaps[key] = this._source.map(); + } + + updateHash(hash) { + this._source.updateHash(hash); + } +} + +module.exports = CachedSource; |