4.0.0 • Published 4 years ago

caller-path v4.0.0

Weekly downloads
12,097,184
License
MIT
Repository
github
Last release
4 years ago

caller-path

Get the path of the caller function

Install

npm install caller-path

Usage

// foo.js
import callerPath from 'caller-path';

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

If the caller's callsite object getFileName was not defined for some reason, it will return undefined.

API

callerPath(options?)

Get the path of the caller function.

depth

Type: number\ Default: 0

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

For example:

// foo.js
import callerPath from 'caller-path';

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

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

require-uncached@shvmeless/testingarchetype-libraryeasy-select-rnvuedragdropuploadimagesreact-native-bluetooth2killi8n-react-native-fast-imagern-send-sms@arisageha/react-lazyload@arisageha/react-lazyload-fix@cashremit/cr-streamline-iconsreact-native-template-rfbasefit-integration-testscloud-archive-s3airscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfdeneme323112@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjamesreact-native-covid-sdkgql_din_modreact-native-thanh-toast-librarymutasi-bca@thanhnguyen14797/react-native-thanh-toast-libraryvmodulecthpb-plugin-socialreact-native-printer-brothersrn-pdf-reader-offlinereact-native-shekhar-bridge-testukor-remasterwilscanner@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-test1webchewow.js-juzix-js-checkerx-code-inspectwifi_configuration_packagesplit-requiresticky-scroll-catchtest-zeo-collecttestnpm_lmnsvavatarvue-compmentvision-camera-plugin-face-detectorvision-camera-plugin-scan-facesvision-camera-base64-resizedv9u-smb2-singstorvcloudcam-playkit-js-hlsvantiq-reactvideo-multi-uploadervs-tree-plus@dotconf-pro/dotconf-pro@dotconf-pro/dotenv@ds-tools/theme.css@ct-note/table@cs6/react-native-test-native-view-library@ct-note/image@ct-note/list@ct-note/checklist@ct-note/embed@cseitz/graphql@con-test/react-native-concent-common@damian.lnc/core@damruravihara/react-native-testing-package@corelmax/react-native-my2c2p-sdk@caneco/siema@rstacruz/pnpm@praella/localisationist@rbc-public/react-selectable-fast@routebuddies/react-native-mapbox-navigationgenerator-bootstrap-boilerplate-templatejesusdemojrennsoh88-react-native-scroll-indicatorjesh-calculationjnf-accesscontrol-rnttljordy-frijters-test-libjamuskalimkhaled-salem-custom-components
4.0.0

4 years ago

3.0.1

4 years ago

3.0.0

6 years ago

2.0.0

9 years ago

1.0.0

10 years ago

0.1.0

11 years ago