Skip to content

Commit

Permalink
move isPromise into util folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jonchurch committed Apr 19, 2020
1 parent 88c7398 commit 89ff9cf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
7 changes: 1 addition & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var mixin = require('utils-merge')
var parseUrl = require('parseurl')
var Route = require('./lib/route')
var setPrototypeOf = require('setprototypeof')
var isPromise = require('./lib/util/isPromise')

/**
* Module variables.
Expand Down Expand Up @@ -730,9 +731,3 @@ function wrap (old, fn) {
fn.apply(this, args)
}
}

function isPromise (val) {
return val &&
typeof val === 'object' &&
typeof val.then === 'function'
}
15 changes: 1 addition & 14 deletions lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

var pathRegexp = require('path-to-regexp')
var isPromise = require('./util/isPromise')

/**
* Module variables.
Expand Down Expand Up @@ -187,20 +188,6 @@ function decodeParam (val) {
}
}

/**
* Returns true if the val is a Promise.
*
* @param {*} val
* @return {boolean}
* @private
*/

function isPromise (val) {
return val &&
typeof val === 'object' &&
typeof val.then === 'function'
}

/**
* Loosens the given path for path-to-regexp matching.
*/
Expand Down
15 changes: 15 additions & 0 deletions lib/util/isPromise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Returns true if the val is a Promise.
*
* @param {*} val
* @return {boolean}
* @private
*/

function isPromise (val) {
return val &&
typeof val === 'object' &&
typeof val.then === 'function'
}

module.exports = isPromise

0 comments on commit 89ff9cf

Please sign in to comment.