GitXplorerGitXplorer
J

Function.name

public
53 stars
3 forks
0 issues

Commits

List of commits on branch master.
Unverified
0481ce6041932c49ba263311a67a164dcfe885b1

Clarify browser support and pre-ES6 form compliance, plus add support for Chrome <5

JJamesMGreene committed 8 years ago
Unverified
a2500ace5ff2885cc97b3eb45ec7c92fd9b44d4d

v1.0.2

JJamesMGreene committed 8 years ago
Unverified
9ed9ffa37037a40c5cf1476ca621de4f86874b57

Memoize the resulting name by defining it on the Function instance

JJamesMGreene committed 8 years ago
Unverified
f6a909d75aa981e6ba86cece04726926396784c3

Add .travis.yml to make my Travis CI build run as JS

JJamesMGreene committed 8 years ago
Unverified
3042d89955419e272fc7adec7c0a54bae436bc47

v1.0.1

JJamesMGreene committed 8 years ago
Unverified
18e3c0142ff40666702c8477dfeadb24cacae440

Updated implementation to use a RegExp match instead of replacement for better performance

JJamesMGreene committed 8 years ago

README

The README file for this repository.

Function.name

Overview

A polyfill for the basic functionality of Function.name accessor property in its pre-ES6 form.

Usage

Named function declarations

function hello() {
  /* ... */
}
console.log(hello.name);  // "hello"

Named function expressions

var fn = function foo() {
  /* ... */
};
console.log(fn.name);  // "foo"

Browser Compatibility

Most modern browsers have already supported this basic functionality for quite some time but this polyfill will apply to at least the following:

  • IE >=9 <12
  • Chrome <33

For IE <9, you can still use fn._name() instead.

Caveats

Pre-ES6 Form

  • In short, this means that this polyfilled 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 poyfilled name accessor property is also intentionally marked as configurable.

Chrome <5

Other Documentation