An open API service indexing awesome lists of open source software.

https://github.com/xotic750/get-function-name-x

Get the name of the function.
https://github.com/xotic750/get-function-name-x

browser ecmascript6 es6 name nodejs

Last synced: 10 months ago
JSON representation

Get the name of the function.

Awesome Lists containing this project

README

          


Travis status


Dependency status


devDependency status


npm version


jsDelivr hits


bettercodehub score


Coverage Status

## get-function-name-x

Get the name of the function.

### `module.exports(fn)` ⇒ undefined \| string

This method returns the name of the function, or `undefined` if not
a function.

**Kind**: Exported function
**Returns**: undefined \| string - The name of the function, or `undefined` if
not a function.

| Param | Type | Description |
| ----- | --------------------- | -------------------------------- |
| fn | function | The function to get the name of. |

**Example**

```js
import getFunctionName from 'get-function-name-x';

console.log(getFunctionName()); // undefined
console.log(getFunctionName(Number.MIN_VALUE)); // undefined
console.log(getFunctionName('abc')); // undefined
console.log(getFunctionName(true)); // undefined
console.log(getFunctionName({name: 'abc'})); // undefined
console.log(getFunctionName(function() {})); // ''
console.log(getFunctionName(new Function())); // ''
console.log(getFunctionName(function test1() {})); // 'test1'
console.log(getFunctionName(function* test2() {})); // 'test2'
console.log(getFunctionName(class Test {});) // 'Test'
```