Sha256: 7af1f03b4ca36d7db6c01a18a7ad17fad9d0c77c163be245a9b4b59dbaf1e122

Contents?: true

Size: 1.18 KB

Versions: 30

Compression:

Stored size: 1.18 KB

Contents

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";

var SourceNode = require("source-map").SourceNode;
var SourceMapConsumer = require("source-map").SourceMapConsumer;
var SourceListMap = require("source-list-map").SourceListMap;
var Source = require("./Source");

class LineToLineMappedSource extends Source {
	constructor(value, name, originalSource) {
		super();
		this._value = value;
		this._name = name;
		this._originalSource = originalSource;
	}

	source() {
		return this._value;
	}

	node(options) {
		var value = this._value;
		var name = this._name;
		var lines = value.split("\n");
		var node = new SourceNode(null, null, null,
			lines.map(function(line, idx) {
				return new SourceNode(idx + 1, 0, name, (line + (idx != lines.length - 1 ? "\n" : "")));
			})
		);
		node.setSourceContent(name, this._originalSource);
		return node;
	}

	listMap(options) {
		return new SourceListMap(this._value, this._name, this._originalSource)
	}

	updateHash(hash) {
		hash.update(this._value);
		hash.update(this._originalSource);
	}
}

require("./SourceAndMapMixin")(LineToLineMappedSource.prototype);

module.exports = LineToLineMappedSource;

Version data entries

30 entries across 29 versions & 10 rubygems

Version Path
ilog-0.4.0 node_modules/webpack/node_modules/webpack-sources/lib/LineToLineMappedSource.js
ilog-0.3.3 node_modules/webpack/node_modules/webpack-sources/lib/LineToLineMappedSource.js
jester-data-8.0.0 node_modules/webpack-sources/lib/LineToLineMappedSource.js
ezii-os-5.2.1 node_modules/webpack-sources/lib/LineToLineMappedSource.js
ezii-os-2.0.1 node_modules/webpack-sources/lib/LineToLineMappedSource.js
ezii-os-1.1.0 node_modules/webpack-sources/lib/LineToLineMappedSource.js
ezii-os-1.0.0 node_modules/webpack-sources/lib/LineToLineMappedSource.js
ezii-os-0.0.0.1.0 node_modules/webpack-sources/lib/LineToLineMappedSource.js
ezii-os-0.0.0.0.1 node_modules/webpack-sources/lib/LineToLineMappedSource.js
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/webpack-sources/lib/LineToLineMappedSource.js