Skip to content

Commit

Permalink
feat: add is.promise
Browse files Browse the repository at this point in the history
  • Loading branch information
pemrouz committed Jul 27, 2016
1 parent c481ecb commit e0d1302
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
29 changes: 17 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
module.exports = is
is.fn = isFunction
is.str = isString
is.num = isNumber
is.obj = isObject
is.lit = isLiteral
is.bol = isBoolean
is.truthy = isTruthy
is.falsy = isFalsy
is.arr = isArray
is.null = isNull
is.def = isDef
is.in = isIn
is.fn = isFunction
is.str = isString
is.num = isNumber
is.obj = isObject
is.lit = isLiteral
is.bol = isBoolean
is.truthy = isTruthy
is.falsy = isFalsy
is.arr = isArray
is.null = isNull
is.def = isDef
is.in = isIn
is.promise = isPromise

function is(v){
return function(d){
Expand Down Expand Up @@ -63,6 +64,10 @@ function isDef(d) {
return typeof d !== 'undefined'
}

function isPromise(d) {
return d instanceof Promise
}

function isIn(set) {
return function(d){
return !set ? false
Expand Down
7 changes: 7 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,11 @@ describe('is', function() {
expect(is.bol('')).to.be.equal(false)
})

it('should check if promise', function(){
expect(is.promise(true)).to.be.equal(false)
expect(is.promise({})).to.be.equal(false)
expect(is.promise()).to.be.equal(false)
expect(is.promise(new Promise(String))).to.be.equal(true)
})

})

0 comments on commit e0d1302

Please sign in to comment.