# callee

> retrieve calling function/method information

Latest version **1.1.1** (published 2017-12-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install callee
pnpm add callee
yarn add callee
bun add callee
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2017-12-07 |
| First published | 2017-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andi Neck |
| Maintainers | andineck |
| Keywords | callsite, context, log linenumber, log column, function context |

## Links

- npm: https://www.npmjs.com/package/callee
- Repository: https://github.com/intesso/callee
- Homepage: https://github.com/intesso/callee#readme
- Issues: https://github.com/intesso/callee/issues
- npm.io page: https://npm.io/package/callee

## Dependencies (1)

- [callsite](https://npm.io/package/callsite.md) ^1.0.0

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2017-12-07
- 1.1.0 — 2017-12-07
- 1.0.0 — 2017-11-30

## README

# 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

```js
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: 

```sh
a null
b a
c a
d c
```

# CallSite methods

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

```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](https://github.com/tj/callsite)

# license

MIT

# author

Andi Neck

---
_Source: https://npm.io/package/callee · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
