source: imaps-frontend/node_modules/functions-have-names/index.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 774 bytes
RevLine 
[d565449]1'use strict';
2
3var functionsHaveNames = function functionsHaveNames() {
4 return typeof function f() {}.name === 'string';
5};
6
7var gOPD = Object.getOwnPropertyDescriptor;
8if (gOPD) {
9 try {
10 gOPD([], 'length');
11 } catch (e) {
12 // IE 8 has a broken gOPD
13 gOPD = null;
14 }
15}
16
17functionsHaveNames.functionsHaveConfigurableNames = function functionsHaveConfigurableNames() {
18 if (!functionsHaveNames() || !gOPD) {
19 return false;
20 }
21 var desc = gOPD(function () {}, 'name');
22 return !!desc && !!desc.configurable;
23};
24
25var $bind = Function.prototype.bind;
26
27functionsHaveNames.boundFunctionsHaveNames = function boundFunctionsHaveNames() {
28 return functionsHaveNames() && typeof $bind === 'function' && function f() {}.bind().name !== '';
29};
30
31module.exports = functionsHaveNames;
Note: See TracBrowser for help on using the repository browser.