pax_global_header00006660000000000000000000000064126012012310014476gustar00rootroot0000000000000052 comment=4e7e99e94301e20cf9a919d01688848e0b9d09ef fn-name-2.0.1/000077500000000000000000000000001260120123100130175ustar00rootroot00000000000000fn-name-2.0.1/.editorconfig000066400000000000000000000003371260120123100154770ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [package.json] indent_style = space indent_size = 2 [*.md] trim_trailing_whitespace = false fn-name-2.0.1/.gitattributes000066400000000000000000000000141260120123100157050ustar00rootroot00000000000000* text=auto fn-name-2.0.1/.gitignore000066400000000000000000000000361260120123100150060ustar00rootroot00000000000000node_modules bower_components fn-name-2.0.1/.jshintrc000066400000000000000000000002761260120123100146510ustar00rootroot00000000000000{ "node": true, "esnext": true, "bitwise": true, "camelcase": true, "curly": true, "immed": true, "newcap": true, "noarg": true, "undef": true, "unused": "vars", "strict": true } fn-name-2.0.1/.travis.yml000066400000000000000000000001101260120123100151200ustar00rootroot00000000000000sudo: false language: node_js node_js: - 'iojs' - '0.12' - '0.10' fn-name-2.0.1/index.js000066400000000000000000000003511260120123100144630ustar00rootroot00000000000000'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; }; fn-name-2.0.1/license000066400000000000000000000021371260120123100143670ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (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. fn-name-2.0.1/package.json000066400000000000000000000010021260120123100152760ustar00rootroot00000000000000{ "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" } } fn-name-2.0.1/readme.md000066400000000000000000000011711260120123100145760ustar00rootroot00000000000000# fn-name [![Build Status](https://travis-ci.org/sindresorhus/fn-name.svg?branch=master)](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) fn-name-2.0.1/test.js000066400000000000000000000010671260120123100143400ustar00rootroot00000000000000'use strict'; var assert = require('assert'); var fnName = require('./'); it('should return the name of named functions', function () { assert.equal(fnName(function foo() {}), 'foo'); }); it('anonymous', function () { assert.equal(fnName(function() {}), null); assert.equal(fnName(function () {}), null); }); it('nested', function () { assert.equal(fnName(function () { function nested() {} }), null); }); it('nested callback', function () { function call (fn) { fn() } assert.equal(fnName(function () { call(function callback () {}); }), null); });