<commit_before>const path = require("path");

module.exports = ({ outputDirectory }) =>
	class Worker {
		constructor(url, options) {
			expect(url).toBeInstanceOf(URL);
			expect(url.origin).toBe("https://test.cases");
			expect(url.pathname.startsWith("/path/")).toBe(true);
			const file = url.pathname.slice(6);
			const workerBootstrap = `
const { parentPort } = require("worker_threads");
const { URL } = require("url");
const path = require("path");
const fs = require("fs");
global.self = global;
self.URL = URL;
const urlToPath = url => {
	if(url.startsWith("https://test.cases/path/")) url = url.slice(24);
	return path.resolve(${JSON.stringify(outputDirectory)}, \`./\${url}\`);
};
self.importScripts = url => {
	require(urlToPath(url));
};
self.fetch = async url => {
	try {
		const buffer = await new Promise((resolve, reject) =>
			fs.readFile(urlToPath(url), (err, b) =>
				err ? reject(err) : resolve(b)
			)
		);
		return {
			status: 200,
			ok: true,
			json: async () => JSON.parse(buffer.toString("utf-8"))
		};<commit_msg>Disallow type:module + importScripts in tests<commit_after>const path = require("path");

module.exports = ({ outputDirectory }) =>
	class Worker {
		constructor(url, options = {}) {
			expect(url).toBeInstanceOf(URL);
			expect(url.origin).toBe("https://test.cases");
			expect(url.pathname.startsWith("/path/")).toBe(true);
			const file = url.pathname.slice(6);
			const workerBootstrap = `
const { parentPort } = require("worker_threads");
const { URL } = require("url");
const path = require("path");
const fs = require("fs");
global.self = global;
self.URL = URL;
const urlToPath = url => {
	if(url.startsWith("https://test.cases/path/")) url = url.slice(24);
	return path.resolve(${JSON.stringify(outputDirectory)}, \`./\${url}\`);
};
self.importScripts = url => {
	${
		options.type === "module"
			? `throw new Error("importScripts is not supported in module workers")`
			: `require(urlToPath(url))`
	};
};
self.fetch = async url => {
	try {
		const buffer = await new Promise((resolve, reject) =>
			fs.readFile(urlToPath(url), (err, b) =>
				err ? reject(err) : resolve(b)
			)
		);
		return {
			status: 200,
			ok: true,
			json: async () => JSON.parse(buffer.toString("utf-8"))
		};
{'fraction_non_alphanumeric': 0.19527418635755683, 'fraction_numerical': 0.006241640659830584, 'mean_word_length': 4.21860465116279, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7037123', 'n_tokens_mistral': 816, 'n_tokens_neox': 751, 'n_words': 153}