main
Last change
on this file since d565449 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
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var functionsHaveNames = function functionsHaveNames() {
|
---|
4 | return typeof function f() {}.name === 'string';
|
---|
5 | };
|
---|
6 |
|
---|
7 | var gOPD = Object.getOwnPropertyDescriptor;
|
---|
8 | if (gOPD) {
|
---|
9 | try {
|
---|
10 | gOPD([], 'length');
|
---|
11 | } catch (e) {
|
---|
12 | // IE 8 has a broken gOPD
|
---|
13 | gOPD = null;
|
---|
14 | }
|
---|
15 | }
|
---|
16 |
|
---|
17 | functionsHaveNames.functionsHaveConfigurableNames = function functionsHaveConfigurableNames() {
|
---|
18 | if (!functionsHaveNames() || !gOPD) {
|
---|
19 | return false;
|
---|
20 | }
|
---|
21 | var desc = gOPD(function () {}, 'name');
|
---|
22 | return !!desc && !!desc.configurable;
|
---|
23 | };
|
---|
24 |
|
---|
25 | var $bind = Function.prototype.bind;
|
---|
26 |
|
---|
27 | functionsHaveNames.boundFunctionsHaveNames = function boundFunctionsHaveNames() {
|
---|
28 | return functionsHaveNames() && typeof $bind === 'function' && function f() {}.bind().name !== '';
|
---|
29 | };
|
---|
30 |
|
---|
31 | module.exports = functionsHaveNames;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.