# @thlorenz/function-origin

> Get origin of a function

Latest version **3.1.0** (published 2020-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @thlorenz/function-origin
pnpm add @thlorenz/function-origin
yarn add @thlorenz/function-origin
bun add @thlorenz/function-origin
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2020-08-28 |
| First published | 2017-10-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 10.0.0 |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 4 |
| Author | Vladimir Kurchatkin |
| Maintainers | thlorenz |

## Links

- npm: https://www.npmjs.com/package/@thlorenz/function-origin
- Repository: https://github.com/thlorenz/function-origin
- Homepage: https://github.com/thlorenz/function-origin#readme
- Issues: https://github.com/thlorenz/function-origin/issues
- npm.io page: https://npm.io/package/@thlorenz/function-origin

## Dependencies (1)

- [bindings](https://npm.io/package/bindings.md) ^1.5.0

## Recent versions

- 3.1.0 (latest) — 2020-08-28
- 3.0.0 — 2020-08-17
- 2.2.0 — 2019-12-12
- 2.1.4 — 2019-12-11
- 2.1.3 — 2019-12-11
- 2.1.2 — 2019-12-11
- 2.1.0 — 2019-12-11
- 2.0.1 — 2019-12-11
- 2.0.0 — 2019-12-11
- 1.1.3 — 2017-10-26
- 1.1.2 — 2017-10-26

## README

# @thlorenz/function-origin [![](https://github.com/thlorenz/function-origin/workflows/Node%20CI/badge.svg?branch=master)](https://github.com/thlorenz/function-origin/actions)

Get origin of a function in Node.js

_NOTE_:

This is a version that fixes the bound function problem and works with latest Node.js versions.

The original module seems to be no longer maintained, i.e. this [PR fixing bound function
issues](https://github.com/vkurchatkin/function-origin/pull/8) hasn't been merged for years.

## Installation

```
npm install @thlorenz/function-origin
```

## Usage

```js
const { functionOrigin } = require('@thlorenz/function-origin')
const origin = functionOrigin(someFn)
```

`origin` has the following properties:

 - `file` — source file name;
 - `line` — line number (0-based);
 - `column` — column number (0-based);
 - `inferredName`.

If a function's origin cannot be resolved (as is the case for native functions like
`Math.abs`), an empty origin is returned which looks as follows:

```js
const { EMPTY_ORIGIN_INFO } = require('./')

console.log(EMPTY_ORIGIN_INFO)
// => { line: -1, column: -1, inferredName: '' }
```

Note that in that case `typeof file === 'undefined'` which allows you to detect that case.

# License

MIT

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