source: imaps-frontend/node_modules/function.prototype.name/shim.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: 916 bytes
Line 
1'use strict';
2
3var supportsDescriptors = require('define-properties').supportsDescriptors;
4var functionsHaveNames = require('functions-have-names')();
5var getPolyfill = require('./polyfill');
6var defineProperty = Object.defineProperty;
7var TypeErr = TypeError;
8
9module.exports = function shimName() {
10 var polyfill = getPolyfill();
11 if (functionsHaveNames) {
12 return polyfill;
13 }
14 if (!supportsDescriptors) {
15 throw new TypeErr('Shimming Function.prototype.name support requires ES5 property descriptor support.');
16 }
17 var functionProto = Function.prototype;
18 defineProperty(functionProto, 'name', {
19 configurable: true,
20 enumerable: false,
21 get: function () {
22 var name = polyfill.call(this);
23 if (this !== functionProto) {
24 defineProperty(this, 'name', {
25 configurable: true,
26 enumerable: false,
27 value: name,
28 writable: false
29 });
30 }
31 return name;
32 }
33 });
34 return polyfill;
35};
Note: See TracBrowser for help on using the repository browser.