3102b714288d3bf37f800c3ba4e0c75861a87ad9
[platform/framework/web/crosswalk-tizen.git] /
1 var baseProperty = require('./baseProperty'),
2     constant = require('../utility/constant'),
3     realNames = require('./realNames'),
4     support = require('../support');
5
6 /**
7  * Gets the name of `func`.
8  *
9  * @private
10  * @param {Function} func The function to query.
11  * @returns {string} Returns the function name.
12  */
13 var getFuncName = (function() {
14   if (!support.funcNames) {
15     return constant('');
16   }
17   if (constant.name == 'constant') {
18     return baseProperty('name');
19   }
20   return function(func) {
21     var result = func.name,
22         array = realNames[result],
23         length = array ? array.length : 0;
24
25     while (length--) {
26       var data = array[length],
27           otherFunc = data.func;
28
29       if (otherFunc == null || otherFunc == func) {
30         return data.name;
31       }
32     }
33     return result;
34   };
35 }());
36
37 module.exports = getFuncName;