diff options
Diffstat (limited to 'node_modules/fn-name')
-rw-r--r-- | node_modules/fn-name/index.js | 8 | ||||
-rw-r--r-- | node_modules/fn-name/license | 21 | ||||
-rw-r--r-- | node_modules/fn-name/package.json | 30 | ||||
-rw-r--r-- | node_modules/fn-name/readme.md | 26 |
4 files changed, 85 insertions, 0 deletions
diff --git a/node_modules/fn-name/index.js b/node_modules/fn-name/index.js new file mode 100644 index 000000000..c8933518a --- /dev/null +++ b/node_modules/fn-name/index.js @@ -0,0 +1,8 @@ +'use strict'; +module.exports = function (fn) { + if (typeof fn !== 'function') { + throw new TypeError('Expected a function'); + } + + return fn.displayName || fn.name || (/function ([^\(]+)?\(/.exec(fn.toString()) || [])[1] || null; +}; diff --git a/node_modules/fn-name/license b/node_modules/fn-name/license new file mode 100644 index 000000000..654d0bfe9 --- /dev/null +++ b/node_modules/fn-name/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +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. diff --git a/node_modules/fn-name/package.json b/node_modules/fn-name/package.json new file mode 100644 index 000000000..b123584cb --- /dev/null +++ b/node_modules/fn-name/package.json @@ -0,0 +1,30 @@ +{ + "name": "fn-name", + "version": "2.0.1", + "description": "Get the name of a named function", + "repository": "sindresorhus/fn-name", + "keywords": [ + "function", + "func", + "fn", + "name" + ], + "license": "MIT", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + }, + "files": [ + "index.js" + ], + "scripts": { + "test": "mocha" + }, + "devDependencies": { + "mocha": "*" + }, + "engines": { + "node": ">=0.10.0" + } +} diff --git a/node_modules/fn-name/readme.md b/node_modules/fn-name/readme.md new file mode 100644 index 000000000..6c51f88ef --- /dev/null +++ b/node_modules/fn-name/readme.md @@ -0,0 +1,26 @@ +# fn-name [](https://travis-ci.org/sindresorhus/fn-name) + +> Get the name of a named function + +There is a non-standard [name](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name) property on functions, but it's not supported in all browsers. +This module tries that property then falls back to extracting the name from the function source. + + +## Install + +```sh +$ npm install --save fn-name +``` + + +## Usage + +```js +fnName(function foo() {}); +//=> foo +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) |