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-plusgenerator-bootstrap-boilerplate-templatejesusdemojrennsoh88-react-native-scroll-indicatorjesh-calculationjest-auto-snapshotsjnf-accesscontrol-rnttljordy-frijters-test-libjamuskalimkhaled-salem-custom-componentsimaexhot-zone-vuehelp-widgetlitepie-datepicker-gabeline-consolemanan-react-native-expo-authorize-netm2m-chartjs-plugin-crosshairl2forlernakrown_login_library@wecraftapps/react-native-use-keyboard@vue-helper/vue-keep-alive@tlgeo/react-native-gdal@thinxviewx/core-rn@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdown@thedoctor0/vuex-shared-mutations@trackier/react-native-trackier@vidit-me/react-native-wheely@upacyxou/react-native-draggable-flatlist@yplabs-ltd/react-native-detector@zebracompany/f_editor@zotasys/nativeagent-get-agentaffinidi-auth-sdk-kernelact_mvvm_shop_cartadyen-rnawesome-module-kdarifbudixzap-vue-captchaarchlibraryatom-read-manifest
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

11 years ago