710dd2c0fc6b69dcbc61d11f96e448cdcd916bd49b3ce13487995ac1d9b319db147eb72d857dd851da21a04fdccc52388b01d529f8abb00ecb3199832645be 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # function.prototype.name <sup>[![Version Badge][2]][1]</sup>
  2. [![dependency status][5]][6]
  3. [![dev dependency status][7]][8]
  4. [![License][license-image]][license-url]
  5. [![Downloads][downloads-image]][downloads-url]
  6. [![npm badge][11]][1]
  7. An ES2015 spec-compliant `Function.prototype.name` shim. Invoke its "shim" method to shim Function.prototype.name if it is unavailable.
  8. *Note*: `Function#name` requires a true ES5 environment - specifically, one with ES5 getters.
  9. This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES5-supported environment and complies with the [spec](https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags).
  10. Most common usage:
  11. ## Example
  12. ```js
  13. var functionName = require('function.prototype.name');
  14. var assert = require('assert');
  15. assert.equal(functionName(function foo() {}), 'foo');
  16. functionName.shim();
  17. assert.equal(function foo() {}.name, 'foo');
  18. ```
  19. ## Supported engines
  20. Automatically tested in every minor version of node.
  21. Manually tested in:
  22. - Safari: v4 - v15 <sub>(4, 5, 5.1, 6.0.5, 6.2, 7.1, 8, 9.1.3, 10.1.2, 11.1.2, 12.1, 13.1.2, 14.1.2, 15.3, 15.6.1)</sub>
  23. - Chrome: v15 - v81, v83 - v106<sub>(every integer version)</sub>
  24. - Note: This includes Edge v80+ and Opera v15+, which matches Chrome
  25. - Firefox: v3, v3.6, v4 - v105 <sub>(every integer version)</sub>
  26. - Note: in v42 - v63, `Function.prototype.toString` throws on HTML element constructors, or a Proxy to a function
  27. - Note: in v20 - v35, HTML element constructors are not callable, despite having typeof `function`
  28. - IE: v6 - v11<sub>(every integer version</sub>
  29. - Opera: v11.1, v11.5, v11.6, v12.0, v12.1, v12.14, v12.15, v12.16, v15+ <sub>v15+ matches Chrome</sub>
  30. ## Tests
  31. Simply clone the repo, `npm install`, and run `npm test`
  32. [1]: https://npmjs.org/package/function.prototype.name
  33. [2]: https://versionbadg.es/es-shims/Function.prototype.name.svg
  34. [5]: https://david-dm.org/es-shims/Function.prototype.name.svg
  35. [6]: https://david-dm.org/es-shims/Function.prototype.name
  36. [7]: https://david-dm.org/es-shims/Function.prototype.name/dev-status.svg
  37. [8]: https://david-dm.org/es-shims/Function.prototype.name#info=devDependencies
  38. [11]: https://nodei.co/npm/function.prototype.name.png?downloads=true&stars=true
  39. [license-image]: https://img.shields.io/npm/l/function.prototype.name.svg
  40. [license-url]: LICENSE
  41. [downloads-image]: https://img.shields.io/npm/dm/function.prototype.name.svg
  42. [downloads-url]: https://npm-stat.com/charts.html?package=function.prototype.name