pax_global_header 0000666 0000000 0000000 00000000064 15212630365 0014515 g ustar 00root root 0000000 0000000 52 comment=99c8c07f8b9a22ef074853e022523990321e647c
es-shims-Function.prototype.name-7b9e6dd/ 0000775 0000000 0000000 00000000000 15212630365 0020521 5 ustar 00root root 0000000 0000000 es-shims-Function.prototype.name-7b9e6dd/.editorconfig 0000664 0000000 0000000 00000000645 15212630365 0023203 0 ustar 00root root 0000000 0000000 root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = off
[CHANGELOG.md]
indent_style = space
indent_size = 2
[README.md]
indent_style = space
indent_size = 2
[*.{d.ts,{,m}js}]
block_comment_start = /*
block_comment = *
block_comment_end = */
[*.json]
max_line_length = off
[Makefile]
max_line_length = off
es-shims-Function.prototype.name-7b9e6dd/.github/ 0000775 0000000 0000000 00000000000 15212630365 0022061 5 ustar 00root root 0000000 0000000 es-shims-Function.prototype.name-7b9e6dd/.github/FUNDING.yml 0000664 0000000 0000000 00000001122 15212630365 0023672 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/function.prototype.name
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
es-shims-Function.prototype.name-7b9e6dd/.github/workflows/ 0000775 0000000 0000000 00000000000 15212630365 0024116 5 ustar 00root root 0000000 0000000 es-shims-Function.prototype.name-7b9e6dd/.github/workflows/browsers.yml 0000664 0000000 0000000 00000001317 15212630365 0026511 0 ustar 00root root 0000000 0000000 name: 'Tests: browsers'
on:
workflow_dispatch:
inputs:
sha:
description: 'SHA to test'
required: true
default: main
type: string
browser:
description: 'Browser to test'
default: ''
type: string
jobs:
tests:
uses: ljharb/actions/.github/workflows/browser.yml@main
with:
browser: ${{ inputs.browser }}
sha: ${{ inputs.sha }}
secrets:
username: ${{ secrets.BROWSERSTACK_USERNAME }}
accessKey: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
browser:
name: 'browser tests (${{ inputs.browser }} @ ${{ inputs.sha }})'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
es-shims-Function.prototype.name-7b9e6dd/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000533 15212630365 0026675 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js < 10'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '< 10'
type: minors
command: npm run tests-only
node:
name: 'node < 10'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true
es-shims-Function.prototype.name-7b9e6dd/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000000245 15212630365 0027253 0 ustar 00root root 0000000 0000000 name: 'Tests: pretest/posttest'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/pretest.yml@main
es-shims-Function.prototype.name-7b9e6dd/.github/workflows/node-tens.yml 0000664 0000000 0000000 00000000547 15212630365 0026543 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js 10 - 20'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 10 < 20'
type: minors
command: npm run tests-only
node:
name: 'node 10 - 20'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true
es-shims-Function.prototype.name-7b9e6dd/.github/workflows/node-twenties.yml 0000664 0000000 0000000 00000000536 15212630365 0027432 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js >= 20'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 20'
type: minors
command: npm run tests-only
node:
name: 'node >= 20'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true
es-shims-Function.prototype.name-7b9e6dd/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000473 15212630365 0026106 0 ustar 00root root 0000000 0000000 name: Automatic Rebase
on: [pull_request_target]
permissions:
contents: write # for ljharb/rebase to push code to rebase
pull-requests: read # for ljharb/rebase to get info about PR
jobs:
_:
uses: ljharb/actions/.github/workflows/rebase.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
es-shims-Function.prototype.name-7b9e6dd/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000515 15212630365 0030540 0 ustar 00root root 0000000 0000000 name: Require “Allow Edits”
on: [pull_request_target]
permissions:
contents: read
jobs:
_:
permissions:
pull-requests: read # for ljharb/require-allow-edits to check 'allow edits' on PR
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main
es-shims-Function.prototype.name-7b9e6dd/.gitignore 0000664 0000000 0000000 00000001177 15212630365 0022517 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage/
.nyc_output/
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
node_modules
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
# Only apps should have lockfiles.
yarn.lock
npm-shrinkwrap.json
package-lock.json
.npmignore
es-shims-Function.prototype.name-7b9e6dd/.npmrc 0000664 0000000 0000000 00000000067 15212630365 0021644 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
es-shims-Function.prototype.name-7b9e6dd/.nycrc 0000664 0000000 0000000 00000000213 15212630365 0021634 0 ustar 00root root 0000000 0000000 {
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"exclude": [
"coverage",
"test"
]
}
es-shims-Function.prototype.name-7b9e6dd/CHANGELOG.md 0000664 0000000 0000000 00000025706 15212630365 0022344 0 ustar 00root root 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.2.0](https://github.com/es-shims/Function.prototype.name/compare/v1.1.8...v1.2.0) - 2026-06-11
### Commits
- [New] add types [`2536496`](https://github.com/es-shims/Function.prototype.name/commit/2536496734512e81d8c3d127ebe2c3fddbe2e211)
- [Dev Deps] update `eslint` [`fa6890a`](https://github.com/es-shims/Function.prototype.name/commit/fa6890a58d9fe84c90091b2fb54178b0a5476f70)
- [Refactor] use `is-document.all` [`7fe6fc3`](https://github.com/es-shims/Function.prototype.name/commit/7fe6fc3ac677b9e8f5f73661e15c7c8e5f453743)
- [Refactor] better support cjs-module-lexer [`1552d61`](https://github.com/es-shims/Function.prototype.name/commit/1552d61bcd8d01b31cf51da58f2d241da11c76f0)
- [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `eslint`, `for-each`, `has-strict-mode`, `make-generator-function`, `npmignore`, `tape` [`dc47ed5`](https://github.com/es-shims/Function.prototype.name/commit/dc47ed5a539e5f3c289c4f8f3e88d4556115b1d2)
- [Robustness] use `es-errors`, `es-define-property` [`ef06a13`](https://github.com/es-shims/Function.prototype.name/commit/ef06a13351b4e3b4db514fde7ab46977c90d9200)
- [Deps] update `call-bind`, `call-bound`, `hasown` [`2f4d6f9`](https://github.com/es-shims/Function.prototype.name/commit/2f4d6f962980bbe01ef69ea2fcbed26088a51a79)
- [actions] update workflows [`204f04f`](https://github.com/es-shims/Function.prototype.name/commit/204f04fe080278ba21199b6a8d9662d3678313f5)
## [v1.1.8](https://github.com/es-shims/Function.prototype.name/compare/v1.1.7...v1.1.8) - 2024-12-19
### Commits
- [actions] split out node 10-20, and 20+ [`b5ea555`](https://github.com/es-shims/Function.prototype.name/commit/b5ea555b2a4db8eb531bccb4d6b2c916de9b8089)
- [Refactor] use `call-bound` directly [`f6a6c64`](https://github.com/es-shims/Function.prototype.name/commit/f6a6c640f7f209c3fc1ea65c0eb31e622e2c9399)
## [v1.1.7](https://github.com/es-shims/Function.prototype.name/compare/v1.1.6...v1.1.7) - 2024-12-15
### Commits
- [actions] split out node 10-20, and 20+ [`47155b0`](https://github.com/es-shims/Function.prototype.name/commit/47155b0bef19c37e5cf9dfff393bc14c6079959a)
- [Refactor] use `hasown` and `is-callable` directly, instead of `es-abstract` [`d5118d6`](https://github.com/es-shims/Function.prototype.name/commit/d5118d65f89f8af4d1109943955ba65f88f4aa6b)
- [Deps] update `call-bind`, `define-properties`, `es-abstract` [`cfa8b2e`](https://github.com/es-shims/Function.prototype.name/commit/cfa8b2e4fcfa437dde6436c2c34e3eb4bb646907)
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `auto-changelog`, `npmignore`, `tape` [`2077d9a`](https://github.com/es-shims/Function.prototype.name/commit/2077d9a9039c7cbf78816188bf486560366437bc)
- [Tests] replace `aud` with `npm audit` [`219e0a4`](https://github.com/es-shims/Function.prototype.name/commit/219e0a43a3de2d96e78ec61a43ccb61be40d8da8)
- [Dev Deps] add missing peer dep [`0b16b2b`](https://github.com/es-shims/Function.prototype.name/commit/0b16b2b1013b3c92793bcf87c573eab356e00388)
## [v1.1.6](https://github.com/es-shims/Function.prototype.name/compare/v1.1.5...v1.1.6) - 2023-08-28
### Commits
- [actions] reuse common workflows [`5f6bfba`](https://github.com/es-shims/Function.prototype.name/commit/5f6bfba9d2c42fbac8f4812396bc71f79464846c)
- [meta] use `npmignore` to autogenerate an npmignore file [`28ea2f9`](https://github.com/es-shims/Function.prototype.name/commit/28ea2f9a9dd48623cba04e94c491033f1c9d1e90)
- [Fix] properly recognize `document.all` in IE 6-8 [`316d676`](https://github.com/es-shims/Function.prototype.name/commit/316d67641d54bf221ed5edfdb9e04af3b98caad8)
- [Fix] only return an own `name` [`d647609`](https://github.com/es-shims/Function.prototype.name/commit/d6476090e110733b52a922f4d0dbfdbc9478c653)
- [Tests] add browserstack browser tests [`67ae402`](https://github.com/es-shims/Function.prototype.name/commit/67ae402aabcad83df2f7d7e356d059a84fe71f44)
- [meta] better `eccheck` command [`728df4c`](https://github.com/es-shims/Function.prototype.name/commit/728df4cc81a51a131a36c0768c4adb7668ad7569)
- [meta] add `auto-changelog` [`dbb700b`](https://github.com/es-shims/Function.prototype.name/commit/dbb700b38ef4c18e0ce0670a2ffface9ffd251a0)
- [readme] fix eclint [`c98fdf1`](https://github.com/es-shims/Function.prototype.name/commit/c98fdf1bc5451de667945c41187a67022f750001)
- [readme] add tested browsers [`d41325c`](https://github.com/es-shims/Function.prototype.name/commit/d41325ceec61627f63281d0649e4e0004f3e0609)
- [actions] update rebase action to use reusable workflow [`085f340`](https://github.com/es-shims/Function.prototype.name/commit/085f3400785cd4f3fb762b73b095f5dfb795a0b3)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `safe-publish-latest`, `tape` [`3f071ce`](https://github.com/es-shims/Function.prototype.name/commit/3f071cef2e1feebfd7d0daea7d6392c2feada091)
- [actions] update codecov uploader [`a187b4f`](https://github.com/es-shims/Function.prototype.name/commit/a187b4fd07dbbeee12e8dc60651f122ab3f41f8d)
- [Deps] update `define-properties`, `es-abstract` [`3ca42ef`](https://github.com/es-shims/Function.prototype.name/commit/3ca42ef76d5d4016d1ea87d806dc7e4a09d9b4f8)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`8de25d2`](https://github.com/es-shims/Function.prototype.name/commit/8de25d2b9b523bd385b0bf3bb9213c11ecf8f1ba)
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `aud`, `tape` [`8b04da7`](https://github.com/es-shims/Function.prototype.name/commit/8b04da71695a1b9cf285ee926ffeec55b543595b)
- [Dev Deps] update `@ljharb/eslint-config`, `aud`, `tape` [`39d8538`](https://github.com/es-shims/Function.prototype.name/commit/39d853854136a749c94e10f9fb06ba73903671a6)
- [meta] reorder scripts [`054f96b`](https://github.com/es-shims/Function.prototype.name/commit/054f96b5e88e08e65c4e27bcb799c7cea2bc3462)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`bebee89`](https://github.com/es-shims/Function.prototype.name/commit/bebee894a7989aef6e9db0dc8b16cbd9134b629c)
- [Dev Deps] update `aud`, `tape` [`8e68159`](https://github.com/es-shims/Function.prototype.name/commit/8e681599b4fbf26e921f61fd603da0524369b72c)
- [Tests] handle Function.prototype in Opera 12.1 [`f3b8f9a`](https://github.com/es-shims/Function.prototype.name/commit/f3b8f9a40b88f6da5ad41b874c3f2acf6fb30378)
- [Deps] update `es-abstract`, `functions-have-names` [`6a59889`](https://github.com/es-shims/Function.prototype.name/commit/6a598893f013182070479a8cc52afd44e556561f)
- [Deps] update `define-properties`, `es-abstract` [`cd1c5e7`](https://github.com/es-shims/Function.prototype.name/commit/cd1c5e773c3740ec563a26e657d764aba7c35a8c)
- [Deps] update `es-abstract` [`3584585`](https://github.com/es-shims/Function.prototype.name/commit/35845851109f767e3bc84ebef989ca93e5851276)
- [Deps] update `es-abstract` [`0e2f6d9`](https://github.com/es-shims/Function.prototype.name/commit/0e2f6d99d554a8b6b7c835702c8408832f9a2684)
- [Deps] update `es-abstract` [`b11748e`](https://github.com/es-shims/Function.prototype.name/commit/b11748ebbda2d840ac625ae6627cfdb090b94434)
- [Dev Deps] update `tape` [`d787a81`](https://github.com/es-shims/Function.prototype.name/commit/d787a81a1e1ce6d00dda6272e93a43bb193b1286)
- [Deps] update `es-abstract` [`4692639`](https://github.com/es-shims/Function.prototype.name/commit/469263915b07db8342f0aad29ad7eba083bea277)
- [Dev Deps] add `in-publish` [`568e263`](https://github.com/es-shims/Function.prototype.name/commit/568e2635099de326768f40d9e0eacbd024861676)
1.1.5 / 2021-10-01
=================
* [Deps] update `es-abstract`
* [meta] use `prepublishOnly` script for npm 7+
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `aud`, `tape`
* [actions] update workflows
* [actions] use `node/install` instead of `node/run`; use `codecov` action
1.1.4 / 2021-02-22
=================
* [readme] remove travis badge
* [meta] remove audit-level
* [meta] gitignore coverage output
* [meta] do not publish github action workflow files
* [Deps] update `call-bind`, `es-abstract`, `functions-have-names`
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-strict-mode`, `tape`
* [Tests] increase coverage
* [actions] update workflows
1.1.3 / 2020-11-27
=================
* [Deps] update `es-abstract`, `functions-have-names`; use `call-bind` where applicable
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`, `make-arrow-function`, `make-generator-function`; add `aud`, `make-async-function`
* [actions] add "Allow Edits" workflow
* [actions] switch Automatic Rebase workflow to `pull_request_target` event
* [Tests] migrate tests to Github Actions
* [Tests] run `nyc` on all tests
* [Tests] add `implementation` test; run `es-shim-api` in postlint; use `tape` runner
* [Tests] only audit prod deps
1.1.2 / 2019-12-14
=================
* [Refactor] use `es-abstract`
* [Deps] update `functions-have-names`
* [meta] add `funding` field
* [meta] fix repo capitalization
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`
* [Tests] use shared travis-ci configs
* [actions] add automatic rebasing / merge commit blocking
1.1.1 / 2019-07-24
=================
* [Refactor] use `functions-have-names`
* [meta] clean up package.json scripts
* [meta] update links
* [meta] create FUNDING.yml
* [Deps] update `is-callable`, `define-properties`
* [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`, `safe-publish-latest`, `covert`
* [Tests] use `eccheck` over `editorconfig-tools`
* [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops
* [Tests] up to `node` `v11.7`, `v10.15`, `v9.11`, `v8.15`, `v6.16`, `v4.9`
* [Test] remove `jscs`
1.1.0 / 2017-12-31
=================
* [New] add `auto` entry point
* [Deps] update `function-bind`
* [Dev Deps] update `uglify-register`, `tape`, `nsp`, `eslint`, `@ljharb/eslint-config`, `@es-shims/api`
* [Tests] up to `node` `v9.3`, `v8.9`, `v6.12`; use `nvm install-latest-npm`; pin included builds to LTS
1.0.3 / 2017-07-21
=================
* [Fix] be robust against function name mangling
* [Refactor] move function name detection to separate file
1.0.2 / 2017-07-14
=================
* [Refactor] shim: Remove unnecessary `!functionsHaveNames` check
1.0.1 / 2017-07-11
=================
* [Fix] in IE 9-11, we must rely on `.call` being available (#13)
* [Fix] ensure that `Function.prototype.name` does not erase the getter
* [Deps] update `is-callable`
* [Dev Deps] add `safe-publish-latest`
* [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config`, `@es-shims/api`
* [Tests] up to `node` `v8.1`; `v7.10`, `v6.11`, `v4.8`; improve matrix; newer npm fails on older nodes
* [Tests] use `Object` to avoid function name inference in node 7
1.0.0 / 2016-02-27
=================
* Initial release.
es-shims-Function.prototype.name-7b9e6dd/LICENSE 0000664 0000000 0000000 00000002071 15212630365 0021526 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2016 Jordan Harband
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
es-shims-Function.prototype.name-7b9e6dd/README.md 0000664 0000000 0000000 00000005004 15212630365 0021777 0 ustar 00root root 0000000 0000000 # function.prototype.name [![Version Badge][2]][1]
[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][11]][1]
An ES2015 spec-compliant `Function.prototype.name` shim. Invoke its "shim" method to shim Function.prototype.name if it is unavailable.
*Note*: `Function#name` requires a true ES5 environment - specifically, one with ES5 getters.
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).
Most common usage:
## Example
```js
var functionName = require('function.prototype.name');
var assert = require('assert');
assert.equal(functionName(function foo() {}), 'foo');
functionName.shim();
assert.equal(function foo() {}.name, 'foo');
```
## Supported engines
Automatically tested in every minor version of node.
Manually tested in:
- Safari: v4 - v15 (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)
- Chrome: v15 - v81, v83 - v106(every integer version)
- Note: This includes Edge v80+ and Opera v15+, which matches Chrome
- Firefox: v3, v3.6, v4 - v105 (every integer version)
- Note: in v42 - v63, `Function.prototype.toString` throws on HTML element constructors, or a Proxy to a function
- Note: in v20 - v35, HTML element constructors are not callable, despite having typeof `function`
- IE: v6 - v11(every integer version
- Opera: v11.1, v11.5, v11.6, v12.0, v12.1, v12.14, v12.15, v12.16, v15+ v15+ matches Chrome
## Tests
Simply clone the repo, `npm install`, and run `npm test`
[1]: https://npmjs.org/package/function.prototype.name
[2]: https://versionbadg.es/es-shims/Function.prototype.name.svg
[5]: https://david-dm.org/es-shims/Function.prototype.name.svg
[6]: https://david-dm.org/es-shims/Function.prototype.name
[7]: https://david-dm.org/es-shims/Function.prototype.name/dev-status.svg
[8]: https://david-dm.org/es-shims/Function.prototype.name#info=devDependencies
[11]: https://nodei.co/npm/function.prototype.name.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/function.prototype.name.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/function.prototype.name.svg
[downloads-url]: https://npm-stat.com/charts.html?package=function.prototype.name
es-shims-Function.prototype.name-7b9e6dd/auto.d.ts 0000664 0000000 0000000 00000000013 15212630365 0022255 0 ustar 00root root 0000000 0000000 export {};
es-shims-Function.prototype.name-7b9e6dd/auto.js 0000664 0000000 0000000 00000000044 15212630365 0022025 0 ustar 00root root 0000000 0000000 'use strict';
require('./shim')();
es-shims-Function.prototype.name-7b9e6dd/eslint.config.mjs 0000664 0000000 0000000 00000000511 15212630365 0023773 0 ustar 00root root 0000000 0000000 import ljharb from '@ljharb/eslint-config/flat';
export default [
...ljharb,
{
rules: {
eqeqeq: ['error', 'allow-null'],
'max-lines-per-function': 'off',
'new-cap': [
'error', {
capIsNewExceptions: [
'HasOwnProperty',
'IsCallable',
],
},
],
'no-extra-parens': 'off',
},
},
];
es-shims-Function.prototype.name-7b9e6dd/helpers/ 0000775 0000000 0000000 00000000000 15212630365 0022163 5 ustar 00root root 0000000 0000000 es-shims-Function.prototype.name-7b9e6dd/helpers/functionsHaveNames.js 0000664 0000000 0000000 00000000142 15212630365 0026316 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = require('functions-have-names')();
// TODO: semver-major, remove
es-shims-Function.prototype.name-7b9e6dd/implementation.d.ts 0000664 0000000 0000000 00000000323 15212630365 0024336 0 ustar 00root root 0000000 0000000 /**
* An ES2015 spec-compliant `Function.prototype.name` getter implementation.
*
* @returns The name of the function it is called on.
*/
declare function getName(this: Function): string;
export = getName;
es-shims-Function.prototype.name-7b9e6dd/implementation.js 0000664 0000000 0000000 00000002423 15212630365 0024105 0 ustar 00root root 0000000 0000000 'use strict';
var IsCallable = require('is-callable');
var hasOwn = require('hasown');
var functionsHaveNames = require('functions-have-names')();
var $TypeError = require('es-errors/type');
var callBound = require('call-bound');
var isDDA = require('is-document.all');
var $functionToString = callBound('Function.prototype.toString');
var $stringMatch = callBound('String.prototype.match');
var classRegex = /^class /;
/** @param {unknown} fn */
var isClass = function isClassConstructor(fn) {
if (IsCallable(fn)) {
return false;
}
if (typeof fn !== 'function') {
return false;
}
try {
var match = $stringMatch($functionToString(fn), classRegex);
return !!match;
} catch (e) {}
return false;
};
var regex = /\s*function\s+([^(\s]*)\s*/;
var functionProto = Function.prototype;
/** @type {import('./implementation')} */
module.exports = function getName() {
if (isDDA(this) || (!isClass(this) && !IsCallable(this))) {
throw new $TypeError('Function.prototype.name sham getter called on non-function');
}
if (functionsHaveNames && hasOwn(this, 'name')) {
return this.name;
}
if (this === functionProto) {
return '';
}
var str = $functionToString(this);
var match = $stringMatch(str, regex);
var name = match && match[1];
return /** @type {string} */ (name);
};
es-shims-Function.prototype.name-7b9e6dd/index.d.ts 0000664 0000000 0000000 00000000654 15212630365 0022427 0 ustar 00root root 0000000 0000000 import implementation = require('./implementation');
import getPolyfill = require('./polyfill');
import shim = require('./shim');
/**
* Returns the name of the given function.
*
* @param fn - The function whose name to retrieve.
* @returns The name of the function.
*/
declare function getName(fn: Function): string;
declare namespace getName {
export {
getPolyfill,
implementation,
shim,
};
}
export = getName;
es-shims-Function.prototype.name-7b9e6dd/index.js 0000664 0000000 0000000 00000000600 15212630365 0022162 0 ustar 00root root 0000000 0000000 'use strict';
var callBind = require('call-bind');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
var bound = callBind(implementation);
/** @type {import('.')} */
module.exports = bound;
module.exports.getPolyfill = getPolyfill;
module.exports.implementation = implementation;
module.exports.shim = shim;
es-shims-Function.prototype.name-7b9e6dd/package.json 0000664 0000000 0000000 00000005633 15212630365 0023016 0 ustar 00root root 0000000 0000000 {
"name": "function.prototype.name",
"version": "1.2.0",
"author": "Jordan Harband ",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"description": "An ES2015 spec-compliant `Function.prototype.name` shim",
"license": "MIT",
"main": "index.js",
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepublishOnly": "safe-publish-latest",
"pretest": "npm run lint",
"test": "npm run --silent tests-only",
"posttest": "npx npm@'>=10.2' audit --production",
"tests-only": "nyc tape 'test/**/*.js'",
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
"lint": "eslint .",
"postlint": "es-shim-api --bound && tsc -p . && attw -P",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"repository": {
"type": "git",
"url": "git://github.com/es-shims/Function.prototype.name.git"
},
"keywords": [
"Function.prototype.name",
"function",
"name",
"ES6",
"ES2015",
"shim",
"polyfill",
"es-shim API"
],
"dependencies": {
"call-bind": "^1.0.9",
"call-bound": "^1.0.4",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"functions-have-names": "^1.2.3",
"has-property-descriptors": "^1.0.2",
"hasown": "^2.0.4",
"is-callable": "^1.2.7",
"is-document.all": "^1.0.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.3",
"@es-shims/api": "^2.5.1",
"@ljharb/eslint-config": "^22.2.3",
"@ljharb/tsconfig": "^0.3.2",
"@types/call-bind": "^1.0.5",
"@types/functions-have-names": "^1.2.2",
"@types/is-callable": "^1.1.2",
"auto-changelog": "^2.6.0",
"eclint": "^2.8.1",
"eslint": "^10.4.1",
"for-each": "^0.3.5",
"has-strict-mode": "^1.1.0",
"in-publish": "^2.0.1",
"jiti": "^0.0.0",
"make-arrow-function": "^1.2.0",
"make-async-function": "^1.0.0",
"make-generator-function": "^2.1.0",
"npmignore": "^0.3.5",
"nyc": "^10.3.2",
"safe-publish-latest": "^2.0.0",
"tape": "^5.10.0",
"typescript": "next",
"uglify-register": "^1.0.1"
},
"testling": {
"files": "test/index.js",
"browsers": [
"iexplore/9.0..latest",
"firefox/4.0..6.0",
"firefox/15.0..latest",
"firefox/nightly",
"chrome/4.0..10.0",
"chrome/20.0..latest",
"chrome/canary",
"opera/11.6..latest",
"opera/next",
"safari/5.0..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2"
]
},
"engines": {
"node": ">= 0.4"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true,
"startingVersion": "v1.1.6"
},
"publishConfig": {
"ignore": [
".github/workflows"
]
}
}
es-shims-Function.prototype.name-7b9e6dd/polyfill.d.ts 0000664 0000000 0000000 00000000337 15212630365 0023150 0 ustar 00root root 0000000 0000000 import implementation = require('./implementation');
/**
* Gets the most compliant `Function.prototype.name` getter implementation to use.
*/
declare function getPolyfill(): typeof implementation;
export = getPolyfill;
es-shims-Function.prototype.name-7b9e6dd/polyfill.js 0000664 0000000 0000000 00000000253 15212630365 0022711 0 ustar 00root root 0000000 0000000 'use strict';
var implementation = require('./implementation');
/** @type {import('./polyfill')} */
module.exports = function getPolyfill() {
return implementation;
};
es-shims-Function.prototype.name-7b9e6dd/shim.d.ts 0000664 0000000 0000000 00000000447 15212630365 0022260 0 ustar 00root root 0000000 0000000 import implementation = require('./implementation');
/**
* Installs a `Function.prototype.name` getter in engines where functions lack names, and returns the polyfill implementation.
*/
declare function shimFunctionPrototypeName(): typeof implementation;
export = shimFunctionPrototypeName;
es-shims-Function.prototype.name-7b9e6dd/shim.js 0000664 0000000 0000000 00000002023 15212630365 0022014 0 ustar 00root root 0000000 0000000 'use strict';
var supportsDescriptors = require('has-property-descriptors')();
var functionsHaveNames = require('functions-have-names')();
var $TypeError = require('es-errors/type');
var getPolyfill = require('./polyfill');
var defineProperty = require('es-define-property');
/** @type {import('./shim')} */
module.exports = function shimName() {
var polyfill = getPolyfill();
if (functionsHaveNames) {
return polyfill;
}
if (!supportsDescriptors || !defineProperty) {
throw new $TypeError('Shimming Function.prototype.name support requires ES5 property descriptor support.');
}
var functionProto = Function.prototype;
defineProperty(functionProto, 'name', {
configurable: true,
enumerable: false,
get: function () {
var name = polyfill.call(this);
if (this !== functionProto) {
/** @type {Exclude} */ (defineProperty)(this, 'name', {
configurable: true,
enumerable: false,
value: name,
writable: false
});
}
return name;
}
});
return polyfill;
};
es-shims-Function.prototype.name-7b9e6dd/test/ 0000775 0000000 0000000 00000000000 15212630365 0021500 5 ustar 00root root 0000000 0000000 es-shims-Function.prototype.name-7b9e6dd/test/implementation.js 0000664 0000000 0000000 00000001175 15212630365 0025067 0 ustar 00root root 0000000 0000000 'use strict';
var implementation = require('../implementation');
var callBind = require('call-bind');
var test = require('tape');
var hasStrictMode = require('has-strict-mode')();
var runTests = require('./tests');
test('as a function', function (t) {
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
/* eslint no-useless-call: 0 */
st['throws'](function () { implementation.call(undefined); }, TypeError, 'undefined is not an object');
st['throws'](function () { implementation.call(null); }, TypeError, 'null is not an object');
st.end();
});
runTests(callBind(implementation), t);
t.end();
});
es-shims-Function.prototype.name-7b9e6dd/test/index.js 0000664 0000000 0000000 00000001630 15212630365 0023145 0 ustar 00root root 0000000 0000000 'use strict';
var getName = require('../');
var test = require('tape');
var runTests = require('./tests');
test('as a function', function (t) {
t.test('non-functions', function (st) {
st['throws'](function () { getName(); }, TypeError, 'undefined is not a function');
st['throws'](function () { getName(null); }, TypeError, 'null is not a function');
st['throws'](function () { getName(true); }, TypeError, 'true is not a function');
st['throws'](function () { getName(false); }, TypeError, 'false is not a function');
st['throws'](function () { getName('foo'); }, TypeError, '"foo" is not a function');
st['throws'](function () { getName([]); }, TypeError, '[] is not a function');
st['throws'](function () { getName({}); }, TypeError, '{} is not a function');
st['throws'](function () { getName(/a/g); }, TypeError, '/a/g is not a function');
st.end();
});
runTests(getName, t);
t.end();
});
es-shims-Function.prototype.name-7b9e6dd/test/shimmed.js 0000664 0000000 0000000 00000001151 15212630365 0023462 0 ustar 00root root 0000000 0000000 'use strict';
require('../auto');
var test = require('tape');
var supportsDescriptors = require('has-property-descriptors')();
var isEnumerable = Object.prototype.propertyIsEnumerable;
var runTests = require('./tests');
test('shimmed', function (t) {
t.test('enumerability', { skip: !supportsDescriptors }, function (et) {
et.equal(false, isEnumerable.call(Function.prototype, 'name'), 'Function#name is not enumerable');
et.equal(false, isEnumerable.call(function foo() {}, 'name'), 'a function’s name is not enumerable');
et.end();
});
runTests(function (fn) { return fn.name; }, t);
t.end();
});
es-shims-Function.prototype.name-7b9e6dd/test/tests.js 0000664 0000000 0000000 00000007057 15212630365 0023211 0 ustar 00root root 0000000 0000000 'use strict';
var functionsHaveNames = require('functions-have-names')();
var arrows = require('make-arrow-function').list();
var generators = require('make-generator-function')();
var asyncs = require('make-async-function').list();
var IsCallable = require('is-callable');
var forEach = require('for-each');
var foo = Object(function foo() {}); // eslint-disable-line no-shadow
var anon = Object(function () {});
var evalled = Object(Function()); // eslint-disable-line no-new-func
module.exports = function (getName, t) {
t.test('functions', function (st) {
if (functionsHaveNames) {
st.equal(getName(foo), foo.name, 'foo has name "foo"');
st.equal(getName(anon), anon.name, 'anonymous function has name of empty string');
st.equal(getName(evalled), evalled.name, 'eval-d function has name "anonymous" (or empty string)');
}
st.equal(getName(foo), 'foo', 'foo has name "foo"');
st.equal(getName(anon), '', 'anonymous function has name of empty string');
var evalledName = getName(evalled);
st.equal(evalledName === 'anonymous' || evalledName === '', true, 'eval-d function has name "anonymous" (or empty string');
st.end();
});
t.test('arrow functions', { skip: arrows.length === 0 }, function (st) {
st.equal(true, functionsHaveNames, 'functions have names in any env with arrow functions');
forEach(arrows, function (arrowFn) {
st.equal(getName(arrowFn), arrowFn.name, 'arrow function name matches for ' + arrowFn);
});
st.end();
});
t.test('generators', { skip: generators.length === 0 }, function (st) {
st.equal(true, functionsHaveNames, 'functions have names in any env with generator functions');
forEach(generators, function (genFn) {
st.equal(getName(genFn), genFn.name, 'generator function name matches for ' + genFn);
});
st.end();
});
t.test('asyncs', { skip: asyncs.length === 0 }, function (st) {
st.equal(true, functionsHaveNames, 'functions have names in any env with async functions');
forEach(asyncs, function (asyncFn) {
st.equal(getName(asyncFn), asyncFn.name, 'async function name matches for ' + asyncFn);
});
st.end();
});
t.test('Function.prototype.name', function (st) {
st.equal(getName(function before() {}), 'before', 'function prior to accessing Function.prototype has the right name');
var protoName = getName(Function.prototype);
// on <= node v2.5, this is "Empty"; on Opera 12.1, "Function.prototype" - otherwise, the empty string
st.equal(protoName === '' || protoName === 'Empty' || protoName === 'Function.prototype', true, 'Function.prototype has the right name');
st.equal(getName(function after() {}), 'after', 'function after accessing Function.prototype has the right name');
st.end();
});
t.test('DOM', function (st) {
/* globals document: false */
st.test('document.all', { skip: typeof document !== 'object' }, function (s2t) {
s2t['throws'](
function () { getName(document.all); },
TypeError,
'a document.all has no name'
);
s2t.end();
});
forEach([
'HTMLElement',
'HTMLAnchorElement'
], function (name) {
var constructor = global[name];
st.test(name, { skip: !constructor }, function (s2t) {
s2t.match(typeof constructor, /^(?:function|object)$/, name + ' is a function or an object');
if (IsCallable(constructor)) {
try {
s2t.equal(getName(constructor), name, name + ' has the right name');
} catch (e) {
s2t.fail(e);
}
} else {
s2t['throws'](
function () { getName(constructor); },
TypeError,
name + ' is not callable'
);
}
s2t.end();
});
});
st.end();
});
};
es-shims-Function.prototype.name-7b9e6dd/test/uglified.js 0000664 0000000 0000000 00000000520 15212630365 0023623 0 ustar 00root root 0000000 0000000 'use strict';
var test = require('tape');
var runTests = require('./tests');
test('with uglify', function (t) {
/* eslint global-require: 0 */
require('uglify-register/api').register({
exclude: [/\/node_modules\//, /\/test\//],
uglify: { mangle: true }
});
var getName = require('../');
runTests(getName, t);
t.end();
});
es-shims-Function.prototype.name-7b9e6dd/tsconfig.json 0000664 0000000 0000000 00000000173 15212630365 0023231 0 ustar 00root root 0000000 0000000 {
"extends": "@ljharb/tsconfig",
"compilerOptions": {
"target": "ES2021"
},
"exclude": [
"coverage",
"test"
]
}