polyfills.Function.name.meta.json Maven / Gradle / Ivy
The newest version!
{"aliases":["es6"],"browsers":{"ie":"9 - 11","chrome":"<33"},"dependencies":["Object.defineProperty"],"repo":"https://github.com/JamesMGreene/Function.name","license":"MIT","docs":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name","spec":"http://www.ecma-international.org/ecma-262/6.0/#sec-setfunctionname","notes":["A polyfill for the basic functionality of the `Function.name` accessor property in its pre-ES6 form.","This polyfilled `Function.name` accessor property can provide you with the name of a named function definition (either a named function declaration or a named function expression).","Unlike other browsers with a similar support level for the pre-ES6 form, this polyfilled `name` accessor property is also intentionally marked as **configurable**.","When polyfilling for Chrome `<5`, the accessor property will be both **configurable** (expected) _AND_ **enumerable** (unexpected) due to having to implement it using [`Object.prototype.__defineGetter__`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__) instead of [`Object.defineProperty`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)."],"detectSource":"'name' in Function.prototype && (function x() {}).name === 'x'","testSource":"","baseDir":"Function/name","hasTests":true,"testsSource":"/* eslint-env mocha, browser */\n/* global proclaim, it */\n\nit('returns the name \"Function\" for Function', function () {\n\tproclaim.equal(Function.name, 'Function');\n});\n\nit('returns an empty string for Function.prototype', function () {\n\tproclaim.equal(\n\t\t(\n\t\t\tFunction.prototype.name === '' ||\n\t\t\t// For \"android/4.4\" configuration only:\n\t\t\tFunction.prototype.name === 'Empty'\n\t\t),\n\t\ttrue\n\t);\n});\n\nit('returns the name \"Function\" for Function.prototype.constructor', function () {\n\tproclaim.equal(Function.prototype.constructor.name, 'Function');\n});\n\nit('returns the name of named function declarations', function () {\n\tfunction foo() {}\n\n\tproclaim.equal(foo.name, 'foo');\n});\n\nit('returns the name of named function expressions', function () {\n\tproclaim.equal((function bar() {}).name, 'bar');\n});\n\nit('returns the name of named function expressions that are assigned to variables', function () {\n\tvar foo = function bar() {};\n\n\tproclaim.equal(foo.name, 'bar');\n});\n\nit('returns an empty string for anonymous function expressions', function () {\n\tproclaim.equal((function () {}).name, '');\n});\n\nit('returns the name \"anonymous\" for functions created with the Function constructor', function () {\n\tvar fn = new Function('');\n\n\tproclaim.equal(\n\t\t(\n\t\t\tfn.name === 'anonymous' ||\n\t\t\t// For \"android/4.4\" configuration only:\n\t\t\tfn.name === ''\n\t\t),\n\t\ttrue\n\t);\n});"}