blob: f0c4069e01a47463691cd4b573c684fede4c3ffe [file] [log] [blame]
Yang Guo4fd355c2019-09-19 10:59:03 +02001(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.getFuncName = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2'use strict';
3
4/* !
5 * Chai - getFuncName utility
6 * Copyright(c) 2012-2016 Jake Luer <jake@alogicalparadox.com>
7 * MIT Licensed
8 */
9
10/**
11 * ### .getFuncName(constructorFn)
12 *
13 * Returns the name of a function.
14 * When a non-function instance is passed, returns `null`.
15 * This also includes a polyfill function if `aFunc.name` is not defined.
16 *
17 * @name getFuncName
18 * @param {Function} funct
19 * @namespace Utils
20 * @api public
21 */
22
23var toString = Function.prototype.toString;
24var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;
25function getFuncName(aFunc) {
26 if (typeof aFunc !== 'function') {
27 return null;
28 }
29
30 var name = '';
31 if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') {
32 // Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined
33 var match = toString.call(aFunc).match(functionNameMatch);
34 if (match) {
35 name = match[1];
36 }
37 } else {
38 // If we've got a `name` property we just use it
39 name = aFunc.name;
40 }
41
42 return name;
43}
44
45module.exports = getFuncName;
46
47},{}]},{},[1])(1)
48});