Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT NPM Version NodeJS Version Modules Ko-fi Liberapay PayPal

A utility for retrieving precise source code coordinates from the execution stack through a simple API.

Features

  • Simple API: Use clear, descriptive functions to fetch caller information.
  • Call Site Extraction: Get a list of all stack frames in the current execution.
  • Caller Identification: Quickly find the file path that called your function.
  • Type Safety: Fully typed with TypeScript for reliable development and autocomplete.
  • Result Pattern: Use a success/failure result type to handle missing stack data safely.
  • Configurable Depth: Limit the number of results returned from the stack trace.

Installation

npm add @zokugun/callsite

Requirements

  • Node.js: v18.20 or higher
  • Modules: ECMAScript Modules (ESM) or CommonJS (CJS)

Quick Start

import { getCallerFile } from '@zokugun/callsite';

function printCallerPath(): void {
   const result = getCallerFile();

   if(result.fails) {
      return;
   }

   const filePath = result.value;

   console.log(`Called by file: ${filePath}`);
}

API Reference

type CallSite = {
   column: number;
   file: string;
   line: number;
};

function getCallSites(maxResult?: number): CallSite[];
function getCallerFile(): DResult<string>;
function getCallerSite(): DResult<CallSite>;

Contributions

Contributions are most welcome. Please:

  • Open issues and feature requests under the repository discussions.
  • Follow the CONTRIBUTING.md.

Donations

Support this project by becoming a financial contributor.

Ko-fi ko-fi.com/daiyam
Liberapay liberapay.com/daiyam/donate
PayPal paypal.me/daiyam99

License

Copyright © 2026-present Baptiste Augrain

Licensed under the MIT license.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages