Socket
Socket
Sign inDemoInstall

callee

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    callee

retrieve calling function/method information


Version published
Weekly downloads
74
decreased by-7.5%
Maintainers
1
Install size
7.53 kB
Created
Weekly downloads
 

Readme

Source

callee

retrieve calling function/method information (tiny wrapper for callsite)

api

  • callee() returns the CallSite Object of the calling function. alias for callee(1)
  • callee(2) returns the CallSite Object of the calling function of the calling function.
  • callee('MyClass') returns the CallSite Object of the calling function, method or type with the name 'MyClass'
  • callee('MyClass', true) same as the above, but caches the callsite index (WARNING: use this with caution)
  • callee.invalidate() invalidates the cached callsite index

usage

const callee = require('callee')

function a() {
  console.log('a', callee().getFunctionName())
  b()
}

function b() {
  console.log('b', callee().getFunctionName())
  c()
}

let c = () => {
  console.log('c', callee(2).getFunctionName())
  d()
}

let d = () => {
  console.log('d', callee().getFunctionName())
}

a()

it prints out:

a null
b a
c a
d c

CallSite methods

see: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/callsite/index.d.ts

  getThis(): any;
  getTypeName(): string;
  getFunctionName(): string;
  getMethodName(): string;
  getFileName(): string;
  getLineNumber(): number;
  getColumnNumber(): number;
  getFunction(): Function;
  getEvalOrigin(): string;
  isNative(): boolean;
  isToplevel(): boolean;
  isEval(): boolean;
  isConstructor(): boolean;
  getRelativeFileName(): string;

NOTE: getRelativeFileName() is an added function

dependencies

single dependency: callsite

license

MIT

author

Andi Neck

Keywords

FAQs

Last updated on 07 Dec 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc