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.
- Host: GitHub
- URL: https://github.com/xotic750/get-function-name-x
- Owner: Xotic750
- License: mit
- Created: 2015-12-16T00:22:25.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T23:34:35.000Z (about 3 years ago)
- Last Synced: 2025-04-30T20:27:20.998Z (10 months ago)
- Topics: browser, ecmascript6, es6, name, nodejs
- Language: JavaScript
- Homepage:
- Size: 3.24 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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'
```