5.0.0 • Published 3 years ago

caller-callsite v5.0.0

Weekly downloads
10,294,639
License
MIT
Repository
github
Last release
3 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_sample@apardellass/react-native-audio-stream@assystant/firebase@atxm/get-package-name@atxm/metrics@_nomtek/react-native-shimmer-animationact_mvvm_shop_cartagent-get-agent@affinidi/affinidi-auth-sdk-kernel@ali5049/react-native-buttons@adembacaj/react-native-google-pay@alloc/caller-path@amirdiafi/react-native-ios-haptics@alta-ng-timeago/hiamtanh-alta@sephriot/react-native-persistable-uri@sidghimire/react-native-mapbox-navigation@routebuddies/react-native-mapbox-navigationexpress0s@trackier/react-native-trackierfmsl@taingo97/react-native-key-rsa@taingo97/react-native-print-xprinter@taingo97/react-native-rsa@taingo97/react-native-rsa-expo@taingo97/react-native-sunmi-printer@taingo97/react-native-telpo-printer@taingo97/react-native-awesome-module@taingo97/react-native-bluetooth-escpos-printer@taingo97/react-native-bluetooth-xprinter@taingo97/react-native-expo-key-rsa-kt@taingo97/react-native-expo-rsa@taingo97/react-native-generate-key-rsagamification-integration-new@thinxviewx/core-rnfluent.adflow.reactnativesdkfluent.adflow.reactnativesdk-alphaflowable-bpmn-modeler@tasumaniadiabori/react-native-draggable-flatlist@wecraftapps/react-native-use-keyboard@navabi/react-native-ssl-pinning@npm_fluentco/adflow-react-native-sdk@oriduk/ckeditor5-rebuild-musicanote@oriduk/ckeditor5-rebuild-oridukadyen-rngriffin-ui-libraryaffinidi-auth-sdk-kernel@alexshmyrkov/react-ranger@zebracompany/f_editorgenz-native-elementshot-zone-vueawesome-module-kdhelp-widgetap-vue-captchaarchlibraryarifbudixz@aysea/react-native-ui-libraryauto-jest-cucumber@bonsaiswapv3/core@bonsaiswapv3/deploy
5.0.0

3 years ago

4.1.0

5 years ago

4.0.0

5 years ago

3.0.0

6 years ago

2.0.0

8 years ago

1.0.1

8 years ago

1.0.0

9 years ago