Socket
Socket
Sign inDemoInstall

get-func-name

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-func-name - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

get-func-name.js

27

index.js

@@ -0,1 +1,9 @@

'use strict';
/* !
* Chai - getFuncName utility
* Copyright(c) 2012-2016 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
/**

@@ -14,5 +22,5 @@ * ### .getFuncName(constructorFn)

const { toString } = Function.prototype;
const functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*/)]+\*\/\s*)*([^\s(/]+)/;
const maxFunctionSourceLength = 512;
var toString = Function.prototype.toString;
var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;
var maxFunctionSourceLength = 512;
function getFuncName(aFunc) {

@@ -23,7 +31,6 @@ if (typeof aFunc !== 'function') {

let name = '';
var 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
const functionSource = toString.call(aFunc);
var functionSource = toString.call(aFunc);
// To avoid unconstrained resource consumption due to pathalogically large function names,

@@ -34,9 +41,9 @@ // we limit the available return value to be less than 512 characters.

}
const match = toString.call(aFunc).match(functionNameMatch);
// 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);
if (match) {
[ name ] = match;
name = match[1];
}
} else {
// If we've got a `name` property we just use it
// eslint-disable-next-line prefer-destructuring
name = aFunc.name;

@@ -48,2 +55,2 @@ }

export { getFuncName };
module.exports = getFuncName;
{
"name": "get-func-name",
"version": "2.0.2",
"description": "Utility for getting a function's name for node and the browser",

@@ -18,5 +19,5 @@ "keywords": [

"files": [
"index.js"
"index.js",
"get-func-name.js"
],
"type": "module",
"main": "./index.js",

@@ -28,7 +29,9 @@ "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 karma.conf.cjs --singleRun=true",
"test:browser": "karma start --singleRun=true",
"test:node": "istanbul cover _mocha",

@@ -44,3 +47,3 @@ "upload-coverage": "lcov-result-merger 'coverage/**/lcov.info' | coveralls; exit 0"

"extends": [
"strict/es6"
"strict/es5"
],

@@ -55,4 +58,3 @@ "env": {

"complexity": 0,
"max-statements": 0,
"prefer-arrow-callback": "off"
"max-statements": 0
}

@@ -62,20 +64,27 @@ },

"devDependencies": {
"coveralls": "^3.1.1",
"eslint": "^7.32.0",
"eslint-config-strict": "^14.0.1",
"browserify": "^13.0.0",
"browserify-istanbul": "^2.0.0",
"coveralls": "2.11.14",
"eslint": "^2.4.0",
"eslint-config-strict": "^9.1.0",
"eslint-plugin-filenames": "^1.1.0",
"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",
"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",
"validate-commit-msg": "^2.3.1"
},
"engines": {
"node": ">= 12"
},
"version": "2.0.1"
"node": "*"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc