# function.name-polyfill

> Polyfill for the basic functionality of `Function.name` accessor property in its pre-ES6 form

Latest version **1.0.6** (published 2018-05-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install function.name-polyfill
pnpm add function.name-polyfill
yarn add function.name-polyfill
bun add function.name-polyfill
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2018-05-16 |
| First published | 2016-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | James M. Greene |
| Maintainers | jamesmgreene |
| Keywords | pre-es6, function.name, fn.name, polyfill, ie, chrome |

## Links

- npm: https://www.npmjs.com/package/function.name-polyfill
- Repository: https://github.com/JamesMGreene/Function.name
- Homepage: https://github.com/JamesMGreene/Function.name#readme
- Issues: https://github.com/JamesMGreene/Function.name/issues
- npm.io page: https://npm.io/package/function.name-polyfill

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2018-05-16
- 1.0.5 — 2016-10-24
- 1.0.4 — 2016-10-24
- 1.0.3 — 2016-10-23
- 1.0.2 — 2016-10-22
- 1.0.1 — 2016-10-22
- 1.0.0 — 2016-07-18

## README

# `Function.name`

## Overview

A polyfill for the basic functionality of [`Function.name`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name) accessor property in its [pre-ES6 form](#pre-es6-form).


## Usage

### Named function declarations

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

### Named function expressions

```js
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`

 - When polyfilling for Chrome `<5`, the accessor property will be **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).


## Other Documentation

 - [ES6 / ES2015 specification for `Function.name`](http://www.ecma-international.org/ecma-262/6.0/#sec-setfunctionname)

---
_Source: https://npm.io/package/function.name-polyfill · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
