Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pemrouz committed May 4, 2015
0 parents commit b43a141
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
*.log
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: node_js
node_js:
- "0.12"
- "0.11"
- "iojs"

after_script: NODE_ENV=test istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var is = require('is')

module.exports = function fn(candid){
return is.fn(candid) ? candid
: (new Function("return " + candid))()
}
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "fn",
"version": "0.0.0",
"main": "index.js",
"scripts": {
"test": "istanbul test ./node_modules/mocha/bin/_mocha --report html -- -R spec",
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && rm -rf ./coverage"
},
"author": "Pedram Emrouznejad (https://github.com/pemrouz)",
"license": "pemrouz.mit-license.org",
"devDependencies": {
"chai": "^2.3.0",
"coveralls": "^2.11.2",
"istanbul": "^0.3.13",
"mocha": "^2.2.4",
"mocha-lcov-reporter": "0.0.2"
},
"dependencies": {
"is": "git://github.com/utilise/is"
}
}
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var expect = require('chai').expect
, fn = require('./')
, is = require('is')

describe('fn', function() {
it('should convert arg to fn, if not already', function() {
expect(is.fn(fn('function(){}'))).to.be.true
expect(is.fn(fn(String))).to.be.true
})
})

0 comments on commit b43a141

Please sign in to comment.