Package Exports
- get-fn-name
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (get-fn-name) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
get-fn-name

Get function name with strictness and correctness in mind. Also works for arrow functions and getting correct name of bounded functions. Powered by fn-name.
Install
npm i get-fn-name --save
Usage
For more use-cases see the tests
const getFnName = require('get-fn-name')
getFnName
Trying to get the name of
val
function.
Params
val
{Function}: Regular or arrow (es2015/es6, also know asfat arrow
) function.returns
{String|null}: The name of function ornull
otherwise.
Example
var name = require('get-fn-name')
console.log(name(function () { return 1 })) // => null
console.log(name(function named () { return 2 })) // => 'named'
// arrows
console.log(name(() => 3)) // => null
console.log(name(() => { return 4 })) // => null
console.log(name((a, b, c) => a + b + c)) // => null
console.log(name((a, b) => { return a + b })) // => null
Related
- bind-context: Bind context to a function and preserves her name. Can be… more | homepage
- fn-name: Get the name of a named function | homepage
- get-comments: Extract javascript comments on per character basis. Comment object compatible with… more | homepage
- get-installed-path: Get the installation path of the given package if it is… more | homepage
- global-modules: The directory used by npm for globally installed npm modules. | homepage
- global-prefix: Get the npm global path prefix. | homepage
- parse-function: Parse a function, arrow function or string to object with name,… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.