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