📞 Get the location from where you're called from.
npm install call-id
Get the location from where you're called from; a minimalist approach.
Supports both V8 (Chrome, Edge, Opera, NodeJS) and SpiderMonkey (FireFox).
Install with npm or yarn:
``shell`
npm i call-idOR
yarn add call-id
This package comes with its TypeScript type declarations included.
`js
// file.js
import { getCallId } from 'call-id';
function it(title, fn) {
const { file, line, column } = getCallId();
// file: file.js, line: 9, column: 0
}
it('should work', () => {}); // <-- this is line 9
`
The getCallId function is available in 3 ways:import { getCallId } from 'call-id'
* An es module: const { getCallId } = require('call-id')
* A cjs module:
* A browser script bundle: