@thlorenz/function-origin
Get origin of a function
Last updated 3 months ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @thlorenz/function-origin 
SYNC missed versions from official npm registry.

@thlorenz/function-origin

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 hasn't been merged for years.

Installation

npm install @thlorenz/function-origin

Usage

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:

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

Current Tags

  • 3.1.0                                ...           latest (3 months ago)

11 Versions

  • 3.1.0                                ...           3 months ago
  • 3.0.0                                ...           3 months ago
  • 2.2.0                                ...           a year ago
  • 2.1.4                                ...           a year ago
  • 2.1.3                                ...           a year ago
  • 2.1.2                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 3
Dependencies (1)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |