4.0.0 • Published 3 years ago

caller-path v4.0.0

Weekly downloads
12,097,184
License
MIT
Repository
github
Last release
3 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_samplefchatlibfawaterak-online-paymentfawatrak-online-paymentfenglin-uploaderfahad-redux-axios-midlewarefluent.adflow.reactnativesdkfluent.adflow.reactnativesdk-alphafmslfirst-app-lyfuciflowable-bpmn-modelerforkmefrdrk-js-semaphorefreshloadengine-testeslint-plugin-aurelia-event-aggregatorimport-typescriptintegrifyi18ngooglesheethops-modelhot-zone-vuejamuskalimeasy-front-buildeasyplayer-mygriffin-ui-library@emiolo/thalamus-express@enkeledi/react-native-week-month-date-pickergrandjsgnosglify@felipesimmi/react-native-datalogic-module@extrieve_technologies/quickcapture_react_nativegamification-integration-newgenerator-bootstrap-boilerplate-templateframework_test_library_sixdeeframework_test_library_sixdee_newframework_test_library_sixdee_new_newgenz-native-elementsgaurav-react-native-loop@flyde/runtimehelp-widgetjrennsoh88-react-native-scroll-indicatorjordy-frijters-test-libjesusdemol2forlernakhaled-salem-custom-componentsknex-migrate-sql-filejawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwyreact-native-experts-sdk
4.0.0

3 years ago

3.0.1

3 years ago

3.0.0

4 years ago

2.0.0

8 years ago

1.0.0

9 years ago

0.1.0

10 years ago