5.0.0 • Published 4 years ago

caller-callsite v5.0.0

Weekly downloads
10,294,639
License
MIT
Repository
github
Last release
4 years ago

caller-callsite

Get the callsite of the caller function

Install

npm install caller-callsite

Usage

// foo.js
import callerCallsite from 'caller-callsite';

export default function foo() {
	console.log(callerCallsite().getFileName());
	//=> '/Users/sindresorhus/dev/unicorn/bar.js'
}
// bar.js
import foo from './foo.js';
foo();

API

callerCallsite(options?)

Returns a callsite object.

options

Type: object

depth

Type: number\ Default: 0

The callsite depth, meaning how many levels we follow back on the stack trace.

For example:

// foo.js
import callerCallsite from 'caller-callsite';

export default function foo() {
	console.log(callerCallsite().getFileName());
	//=> '/Users/sindresorhus/dev/unicorn/foobar.js'
	console.log(callerCallsite({depth: 1}).getFileName());
	//=> '/Users/sindresorhus/dev/unicorn/bar.js'
	console.log(callerCallsite({depth: 2}).getFileName());
	//=> '/Users/sindresorhus/dev/unicorn/foo.js'
}
// bar.js
import foo from './foo.js';

export default function foo() {
	foo();
}
// foobar.js
import bar from './bar.js';
bar();

caller-patharchetype-libraryeasy-select-rnvuedragdropuploadimagesreact-native-bluetooth2killi8n-react-native-fast-imagern-send-sms@cashremit/cr-streamline-iconsreact-native-template-rfbasecloud-archive-s3airscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfdeneme323112@fundefund/funde_ck@firstblood/nestjs-config@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjamesreact-native-covid-sdkgql_din_modreact-native-thanh-toast-library@thanhnguyen14797/react-native-thanh-toast-libraryreact-native-printer-brothersrn-pdf-reader-offlinereact-native-shekhar-bridge-testwilscanner@oiti/documentoscopy-react-nativequoc-testreact-native-slider-kfluminos-ui-core@everything-registry/sub-chunk-1288jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgp149-tablereact-native-jawwy_samplegriffin-ui-librarytest-library-123test-haptik-libtest-npm-jjmessivue-button-test1webchewifi_configuration_packagesticky-scroll-catchtest-zeo-collecttestnpm_lmnsvavatarvscode-read-manifestvue-compmentvision-camera-plugin-face-detectorvision-camera-plugin-scan-facesvision-camera-base64-resizedv9u-smb2-singstorvantiq-reactvs-tree-plus@dotconf-pro/dotconf-pro@dotconf-pro/dotenv@ct-note/table@cs6/react-native-test-native-view-library@ct-note/image@ct-note/list@ct-note/checklist@ct-note/embed@con-test/react-native-concent-common@damian.lnc/core@damruravihara/react-native-testing-package@corelmax/react-native-my2c2p-sdk@praella/localisationist@rbc-public/react-selectable-fast@routebuddies/react-native-mapbox-navigationgenerator-bootstrap-boilerplate-templatejesusdemojrennsoh88-react-native-scroll-indicatorjesh-calculationjest-auto-snapshotsjnf-accesscontrol-rnttljordy-frijters-test-libjamuskalimkhaled-salem-custom-componentsjawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwyreact-native-experts-sdktest_lib_module_aarquickcapture_react_nativechain_diggerrn-agora-ios-mreact-native-omental-frameworkreact-native-sixdee_test_libstock-ticker-react-widgettypedoc-plugin-toc-group-modtingzi-vuepressu-library
5.0.0

4 years ago

4.1.0

6 years ago

4.0.0

6 years ago

3.0.0

7 years ago

2.0.0

9 years ago

1.0.1

9 years ago

1.0.0

10 years ago