From 363723fc84f7b8477592e0105aeb331ec9a017af Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 14 Aug 2017 05:01:11 +0200 Subject: node_modules --- node_modules/webpack-sources/lib/CachedSource.js | 116 ++++++++++++----------- 1 file changed, 62 insertions(+), 54 deletions(-) (limited to 'node_modules/webpack-sources/lib/CachedSource.js') diff --git a/node_modules/webpack-sources/lib/CachedSource.js b/node_modules/webpack-sources/lib/CachedSource.js index 50732aebd..0a81c5c45 100644 --- a/node_modules/webpack-sources/lib/CachedSource.js +++ b/node_modules/webpack-sources/lib/CachedSource.js @@ -2,69 +2,77 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -function CachedSource(source) { - this._source = source; - this._cachedSource = undefined; - this._cachedSize = undefined; - this._cachedMaps = {}; +"use strict"; - if(source.node) this.node = function(options) { - return this._source.node(options); - }; +const Source = require("./Source"); - if(source.listMap) this.listMap = function(options) { - return this._source.listMap(options); - }; -} -module.exports = CachedSource; - -CachedSource.prototype.source = function() { - if(typeof this._cachedSource !== "undefined") return this._cachedSource; - return this._cachedSource = this._source.source(); -}; +class CachedSource extends Source { + constructor(source) { + super(); + this._source = source; + this._cachedSource = undefined; + this._cachedSize = undefined; + this._cachedMaps = {}; -CachedSource.prototype.size = function() { - 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(); -}; + if(source.node) this.node = function(options) { + return this._source.node(options); + }; -CachedSource.prototype.sourceAndMap = function(options) { - var key = JSON.stringify(options); - if(typeof this._cachedSource !== "undefined" && key in this._cachedMaps) - return { - source: this._cachedSource, - map: this._cachedMaps[key] + if(source.listMap) this.listMap = function(options) { + return this._source.listMap(options); }; - else if(typeof this._cachedSource !== "undefined") { + } + + 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] = this._source.map(options) - }; - } else if(key in this._cachedMaps) { - return { - source: this._cachedSource = this._source.source(), map: this._cachedMaps[key] }; } - var result = this._source.sourceAndMap(options); - this._cachedSource = result.source; - this._cachedMaps[key] = result.map; - return { - source: this._cachedSource, - map: this._cachedMaps[key] - }; -}; -CachedSource.prototype.map = function(options) { - if(!options) options = {}; - var key = JSON.stringify(options); - if(key in this._cachedMaps) - return this._cachedMaps[key]; - return this._cachedMaps[key] = this._source.map(); -}; + 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(); + } -CachedSource.prototype.updateHash = function(hash) { - this._source.updateHash(hash); -}; + updateHash(hash) { + this._source.updateHash(hash); + } +} + +module.exports = CachedSource; -- cgit v1.2.3