update node_modules
This commit is contained in:
parent
4889aac148
commit
195fbc52ad
431 changed files with 52587 additions and 0 deletions
42
node_modules/fn.name/index.js
generated
vendored
Normal file
42
node_modules/fn.name/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
'use strict';
|
||||
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Extract names from functions.
|
||||
*
|
||||
* @param {Function} fn The function who's name we need to extract.
|
||||
* @returns {String} The name of the function.
|
||||
* @public
|
||||
*/
|
||||
module.exports = function name(fn) {
|
||||
if ('string' === typeof fn.displayName && fn.constructor.name) {
|
||||
return fn.displayName;
|
||||
} else if ('string' === typeof fn.name && fn.name) {
|
||||
return fn.name;
|
||||
}
|
||||
|
||||
//
|
||||
// Check to see if the constructor has a name.
|
||||
//
|
||||
if (
|
||||
'object' === typeof fn
|
||||
&& fn.constructor
|
||||
&& 'string' === typeof fn.constructor.name
|
||||
) return fn.constructor.name;
|
||||
|
||||
//
|
||||
// toString the given function and attempt to parse it out of it, or determine
|
||||
// the class.
|
||||
//
|
||||
var named = fn.toString()
|
||||
, type = toString.call(fn).slice(8, -1);
|
||||
|
||||
if ('Function' === type) {
|
||||
named = named.substring(named.indexOf('(') + 1, named.indexOf(')'));
|
||||
} else {
|
||||
named = type;
|
||||
}
|
||||
|
||||
return named || 'anonymous';
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue