This repository was archived by the owner on Feb 20, 2019. It is now read-only.
File tree 4 files changed +54
-0
lines changed
4 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ node_modules
4
4
.nyc_output /
5
5
coverage /
6
6
npm-debug.log
7
+ package-lock.json
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import swapCase from './swap-case'
34
34
import endsWith from './endsWith'
35
35
import round from './round'
36
36
import checkPalindrome from './checkPalindrome'
37
+ import isFunction from './is-function'
37
38
38
39
export {
39
40
isEven ,
@@ -72,4 +73,5 @@ export {
72
73
endsWith ,
73
74
round ,
74
75
checkPalindrome ,
76
+ isFunction ,
75
77
}
Original file line number Diff line number Diff line change
1
+ export default isFunction
2
+
3
+ /**
4
+ * Original source: https://stackoverflow.com/a/7356528/3344977
5
+ *
6
+ * This method checks whether an object passed as an
7
+ * argument is a javascript Function or not
8
+ * @param {Object } functionToCheck - the object to check
9
+ * @return {Boolean } - true if functionToCheck is a function else false
10
+ */
11
+ function isFunction ( functionToCheck ) {
12
+ const getType = { }
13
+ return functionToCheck && getType . toString . call ( functionToCheck ) === '[object Function]'
14
+ }
Original file line number Diff line number Diff line change
1
+ import test from 'ava'
2
+ import { isFunction } from '../src'
3
+
4
+ test ( 'check a function' , t => {
5
+ const func = ( ) => { }
6
+ const expected = true
7
+ const actual = isFunction ( func )
8
+ t . deepEqual ( actual , expected )
9
+ } )
10
+
11
+ test ( 'check an object' , t => {
12
+ const object = { }
13
+ const expected = false
14
+ const actual = isFunction ( object )
15
+ t . deepEqual ( actual , expected )
16
+ } )
17
+
18
+ test ( 'check a string' , t => {
19
+ const string = 'string'
20
+ const expected = false
21
+ const actual = isFunction ( string )
22
+ t . deepEqual ( actual , expected )
23
+ } )
24
+
25
+ test ( 'check a boolean' , t => {
26
+ const boolean = true
27
+ const expected = false
28
+ const actual = isFunction ( boolean )
29
+ t . deepEqual ( actual , expected )
30
+ } )
31
+
32
+ test ( 'check a number' , t => {
33
+ const number = 1
34
+ const expected = false
35
+ const actual = isFunction ( number )
36
+ t . deepEqual ( actual , expected )
37
+ } )
You can’t perform that action at this time.
0 commit comments