Skip to content

Commit ef0c193

Browse files
committed
Initial commit
1 parent c0674f5 commit ef0c193

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/util.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var isFunction = function(fn) {
2+
return fn && {}.toString.call(fn) === '[object Function]';
3+
}
4+
5+
module.exports = {
6+
isFunction
7+
}

test/util.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var assert = require('assert');
2+
var util = require('../src/util');
3+
4+
5+
describe('util', function() {
6+
describe('isFunction', function() {
7+
8+
it('function should be properly detected', function() {
9+
var f = function(f) { console.log(f); };
10+
assert.equal(util.isFunction(f), true);
11+
assert.equal(util.isFunction(console.log), true);
12+
assert.equal(util.isFunction('foo'), false);
13+
assert.equal(util.isFunction([1, 2]), false);
14+
});
15+
16+
});
17+
});

0 commit comments

Comments
 (0)