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
optimacms-0.1.61 spec/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
disco_app-0.18.0 test/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
disco_app-0.18.2 test/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
disco_app-0.16.1 test/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
disco_app-0.15.2 test/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
disco_app-0.18.4 test/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
disco_app-0.18.1 test/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
disco_app-0.14.0 test/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
tang-0.2.1 spec/tang_app/node_modules/webpack-sources/lib/LineToLineMappedSource.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/webpack-sources/lib/LineToLineMappedSource.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/webpack-sources/lib/LineToLineMappedSource.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/webpack-sources/lib/LineToLineMappedSource.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/webpack-sources/lib/LineToLineMappedSource.js
tang-0.2.0 spec/tang_app/node_modules/webpack-sources/lib/LineToLineMappedSource.js
tang-0.1.0 spec/tang_app/node_modules/webpack-sources/lib/LineToLineMappedSource.js
tang-0.0.9 spec/tang_app/node_modules/webpack-sources/lib/LineToLineMappedSource.js
enju_library-0.3.8 spec/dummy/node_modules/webpack-sources/lib/LineToLineMappedSource.js
ilog-0.4.1 node_modules/webpack/node_modules/webpack-sources/lib/LineToLineMappedSource.js