fn-name
Advanced tools
Comparing version 3.0.0 to 4.0.0
10
index.js
@@ -1,9 +0,7 @@ | ||
'use strict'; | ||
module.exports = fn => { | ||
if (typeof fn !== 'function') { | ||
export default function functionName(function_) { | ||
if (typeof function_ !== 'function') { | ||
throw new TypeError('Expected a function'); | ||
} | ||
return fn.displayName || fn.name || (/function ([^(]+)?\(/.exec(fn.toString()) || [])[1]; | ||
}; | ||
return function_.displayName || function_.name || (/function ([^(]+)?\(/.exec(function_.toString()) || [])[1]; | ||
} |
{ | ||
"name": "fn-name", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Get the name of a named function", | ||
"license": "MIT", | ||
"repository": "sindresorhus/fn-name", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=12" | ||
}, | ||
@@ -28,5 +31,5 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^2.3.0", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"xo": "^0.38.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# fn-name [![Build Status](https://travis-ci.org/sindresorhus/fn-name.svg?branch=master)](https://travis-ci.org/sindresorhus/fn-name) | ||
# fn-name | ||
@@ -7,3 +7,2 @@ > Get the name of a named function | ||
## Install | ||
@@ -15,13 +14,11 @@ | ||
## Usage | ||
```js | ||
const fnName = require('fn-name'); | ||
import functionName from 'fn-name'; | ||
fnName(function foo() {}); | ||
functionName(function foo() {}); | ||
//=> 'foo' | ||
``` | ||
--- | ||
@@ -28,0 +25,0 @@ |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2871
Yes
6
33