severnway / is-function-spec

Specification of function type detection.
MIT No Attribution
0 stars 0 forks source link

Package: is #1

Open gowpen opened 6 years ago

gowpen commented 6 years ago

The is package provides function detection in is.fn().

/**
 * is.fn / is.function (deprecated)
 * Test if `value` is a function.
 *
 * @param {*} value value to test
 * @return {Boolean} true if `value` is a function, false otherwise
 * @api public
 */

is.fn = is['function'] = function (value) {
  var isAlert = typeof window !== 'undefined' && value === window.alert;
  if (isAlert) {
    return true;
  }
  var str = toStr.call(value);
  return str === '[object Function]' || str === '[object GeneratorFunction]' || str === '[object AsyncFunction]';
};