[Pkg-javascript-commits] [node-fn-name] 01/10: Import Upstream version 2.0.1

Shirish Togarla shirish12-guest at moszumanska.debian.org
Fri Mar 31 17:20:58 UTC 2017


This is an automated email from the git hooks/post-receive script.

shirish12-guest pushed a commit to branch master
in repository node-fn-name.

commit 14d85a250cc3e9726c8522eb3cac0e561328791c
Author: Shirish Togarla <shirishtogarla533 at gmail.com>
Date:   Thu Jan 5 06:34:24 2017 +0000

    Import Upstream version 2.0.1
---
 .editorconfig  | 15 +++++++++++++++
 .gitattributes |  1 +
 .gitignore     |  2 ++
 .jshintrc      | 13 +++++++++++++
 .travis.yml    |  6 ++++++
 index.js       |  8 ++++++++
 license        | 21 +++++++++++++++++++++
 package.json   | 30 ++++++++++++++++++++++++++++++
 readme.md      | 26 ++++++++++++++++++++++++++
 test.js        | 26 ++++++++++++++++++++++++++
 10 files changed, 148 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..86c8f59
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = 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
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a088b6f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+node_modules
+bower_components
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..804f8af
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,13 @@
+{
+	"node": true,
+	"esnext": true,
+	"bitwise": true,
+	"camelcase": true,
+	"curly": true,
+	"immed": true,
+	"newcap": true,
+	"noarg": true,
+	"undef": true,
+	"unused": "vars",
+	"strict": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..dedfc07
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+sudo: false
+language: node_js
+node_js:
+  - 'iojs'
+  - '0.12'
+  - '0.10'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..c893351
--- /dev/null
+++ b/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/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at 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/package.json b/package.json
new file mode 100644
index 0000000..b123584
--- /dev/null
+++ b/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 at gmail.com",
+    "url": "http://sindresorhus.com"
+  },
+  "files": [
+    "index.js"
+  ],
+  "scripts": {
+    "test": "mocha"
+  },
+  "devDependencies": {
+    "mocha": "*"
+  },
+  "engines": {
+    "node": ">=0.10.0"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..6c51f88
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,26 @@
+# 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)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..3cb9440
--- /dev/null
+++ b/test.js
@@ -0,0 +1,26 @@
+'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);
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-fn-name.git



More information about the Pkg-javascript-commits mailing list