PHP 8.2.30
Preview: index.js Size: 641 B
/home/byroehnu/.trash/node_modules11/parent-module/index.js

'use strict';
const callsites = require('callsites');

module.exports = filepath => {
	const stacks = callsites();

	if (!filepath) {
		return stacks[2].getFileName();
	}

	let seenVal = false;

	// Skip the first stack as it's this function
	stacks.shift();

	for (const stack of stacks) {
		const parentFilepath = stack.getFileName();

		if (typeof parentFilepath !== 'string') {
			continue;
		}

		if (parentFilepath === filepath) {
			seenVal = true;
			continue;
		}

		// Skip native modules
		if (parentFilepath === 'module.js') {
			continue;
		}

		if (seenVal && parentFilepath !== filepath) {
			return parentFilepath;
		}
	}
};

Directory Contents

Dirs: 0 × Files: 4

Name Size Perms Modified Actions
641 B lrw-r--r-- 2026-02-28 00:26:42
Edit Download
1.08 KB lrw-r--r-- 2026-02-28 00:26:52
Edit Download
712 B lrw-r--r-- 2026-02-28 00:26:32
Edit Download
1.43 KB lrw-r--r-- 2026-02-28 00:27:02
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).