get-func-name
Advanced tools
Comparing version 2.0.2 to 3.0.0
27
index.js
@@ -1,9 +0,1 @@ | ||
'use strict'; | ||
/* ! | ||
* Chai - getFuncName utility | ||
* Copyright(c) 2012-2016 Jake Luer <jake@alogicalparadox.com> | ||
* MIT Licensed | ||
*/ | ||
/** | ||
@@ -22,5 +14,5 @@ * ### .getFuncName(constructorFn) | ||
var toString = Function.prototype.toString; | ||
var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/; | ||
var maxFunctionSourceLength = 512; | ||
const { toString } = Function.prototype; | ||
const functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*/)]+\*\/\s*)*([^\s(/]+)/; | ||
const maxFunctionSourceLength = 512; | ||
function getFuncName(aFunc) { | ||
@@ -31,6 +23,7 @@ if (typeof aFunc !== 'function') { | ||
var name = ''; | ||
let name = ''; | ||
if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') { | ||
// Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined | ||
// eslint-disable-next-line prefer-reflect | ||
var functionSource = toString.call(aFunc); | ||
const functionSource = toString.call(aFunc); | ||
// To avoid unconstrained resource consumption due to pathalogically large function names, | ||
@@ -41,9 +34,9 @@ // we limit the available return value to be less than 512 characters. | ||
} | ||
// Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined | ||
var match = functionSource.match(functionNameMatch); | ||
const match = toString.call(aFunc).match(functionNameMatch); | ||
if (match) { | ||
name = match[1]; | ||
[ name ] = match; | ||
} | ||
} else { | ||
// If we've got a `name` property we just use it | ||
// eslint-disable-next-line prefer-destructuring | ||
name = aFunc.name; | ||
@@ -55,2 +48,2 @@ } | ||
module.exports = getFuncName; | ||
export { getFuncName }; |
{ | ||
"name": "get-func-name", | ||
"version": "2.0.2", | ||
"description": "Utility for getting a function's name for node and the browser", | ||
@@ -19,5 +18,5 @@ "keywords": [ | ||
"files": [ | ||
"index.js", | ||
"get-func-name.js" | ||
"index.js" | ||
], | ||
"type": "module", | ||
"main": "./index.js", | ||
@@ -29,9 +28,7 @@ "repository": { | ||
"scripts": { | ||
"build": "browserify --bare $npm_package_main --standalone getFuncName -o get-func-name.js", | ||
"lint": "eslint --ignore-path .gitignore .", | ||
"prepublish": "npm run build", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post", | ||
"pretest": "npm run lint", | ||
"test": "npm run test:node && npm run test:browser && npm run upload-coverage", | ||
"test:browser": "karma start --singleRun=true", | ||
"test:browser": "karma start karma.conf.cjs --singleRun=true", | ||
"test:node": "istanbul cover _mocha", | ||
@@ -47,3 +44,3 @@ "upload-coverage": "lcov-result-merger 'coverage/**/lcov.info' | coveralls; exit 0" | ||
"extends": [ | ||
"strict/es5" | ||
"strict/es6" | ||
], | ||
@@ -58,3 +55,4 @@ "env": { | ||
"complexity": 0, | ||
"max-statements": 0 | ||
"max-statements": 0, | ||
"prefer-arrow-callback": "off" | ||
} | ||
@@ -64,27 +62,20 @@ }, | ||
"devDependencies": { | ||
"browserify": "^13.0.0", | ||
"browserify-istanbul": "^2.0.0", | ||
"coveralls": "2.11.14", | ||
"eslint": "^2.4.0", | ||
"eslint-config-strict": "^9.1.0", | ||
"coveralls": "^3.1.1", | ||
"eslint": "^7.32.0", | ||
"eslint-config-strict": "^14.0.1", | ||
"eslint-plugin-filenames": "^1.1.0", | ||
"ghooks": "^1.0.1", | ||
"istanbul": "^0.4.2", | ||
"karma": "^1.3.0", | ||
"karma-browserify": "^5.0.2", | ||
"karma-coverage": "^1.1.1", | ||
"karma-mocha": "^1.2.0", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
"karma-sauce-launcher": "^1.0.0", | ||
"lcov-result-merger": "^1.0.2", | ||
"mocha": "^3.1.2", | ||
"phantomjs-prebuilt": "^2.1.5", | ||
"semantic-release": "^4.3.5", | ||
"simple-assert": "^1.0.0", | ||
"travis-after-all": "^1.4.4", | ||
"ghooks": "^2.0.4", | ||
"istanbul": "^0.4.5", | ||
"karma": "^6.3.4", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-mocha": "^2.0.1", | ||
"lcov-result-merger": "^3.1.0", | ||
"mocha": "^9.1.2", | ||
"semantic-release": "^18.0.0", | ||
"validate-commit-msg": "^2.3.1" | ||
}, | ||
"engines": { | ||
"node": "*" | ||
} | ||
"node": ">= 12" | ||
}, | ||
"version": "3.0.0" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
13
1
0
Yes
7784
4
41