This file is indexed.

/usr/lib/nodejs/rollup-plugin-replace/index.js is in node-rollup-plugin-replace 2.0.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"use strict";
var magic$string$$ = require("magic-string"), rollup$pluginutils$$ = require("rollup-pluginutils");

function escape(str) {
	return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}

function functor(thing) {
	if (typeof thing === 'function') return thing;
	return () => thing;
}

function longest(a, b) {
	return b.length - a.length;
}

function replace(options) {
        if (!options) options = {};
	const filter = rollup$pluginutils$$.createFilter(options.include, options.exclude);
	const { delimiters } = options;

	let values;

	if (options.values) {
		values = options.values;
	} else {
		values = Object.assign({}, options);
		delete values.delimiters;
		delete values.include;
		delete values.exclude;
	}

	const keys = Object.keys(values).sort(longest).map(escape);

	const pattern = delimiters ?
		new RegExp(
			`${escape(delimiters[0])}(${keys.join('|')})${escape(delimiters[1])}`,
			'g'
		) :
		new RegExp(
			`\\b(${keys.join('|')})\\b`,
			'g'
		);

	// convert all values to functions
	Object.keys(values).forEach(key => {
		values[key] = functor(values[key]);
	});

	return {
		name: 'replace',

		transform(code, id) {
			if (!filter(id)) return null;

			const magicString = new magic$string$$["default"](code);

			let hasReplacements = false;
			let match;
			let start, end, replacement;

			while ((match = pattern.exec(code))) {
				hasReplacements = true;

				start = match.index;
				end = start + match[0].length;
				replacement = String(values[match[1]](id));

				magicString.overwrite(start, end, replacement);
			}

			if (!hasReplacements) return null;

			let result = { code: magicString.toString() };
			if (options.sourceMap !== false && options.sourcemap !== false)
				result.map = magicString.generateMap({ hires: true });

			return result;
		}
	};
}

module.exports = replace;