How to use the isFunction function from util

Find comprehensive JavaScript util.isFunction code examples handpicked from public code repositorys.

133
134
135
136
137
138
139
140
141
142
  // false
```


<div id="isFunction" class="anchor"></div>
## util.isFunction(object)

> 稳定度:0 - 已废弃

如果给定的 'object' 是 `Function`,返回 `true`。否则,返回 `false`。
fork icon21
star icon99
watch icon2

+ 3 other calls in file

312
313
314
315
316
317
318
319
320
321

// To avoid recursion in the case that type === "newListener"! Before
// adding it to the listeners, first emit "newListener".
if (this._events.newListener)
  this.emit('newListener', type,
            util.isFunction(listener.listener) ?
            listener.listener : listener);

if (!this._events[type])
  // Optimize the case of one listener. Don't need the extra array object.
fork icon1
star icon14
watch icon2

105
106
107
108
109
110
111
112
113
      options.host = args[1];
    }
  }

  var cb = args[args.length - 1];
  return util.isFunction(cb) ? [options, cb] : [options];
}
exports._normalizeConnectArgs = normalizeConnectArgs;

fork icon0
star icon11
watch icon3

381
382
383
384
385
386
387
388
389
390
obj[Symbol.toStringTag] = 'Error';
util.isError(obj);
// Returns: true
```

### util.isFunction(object)
<!-- YAML
added: v0.11.5
deprecated: v4.0.0
-->
fork icon0
star icon6
watch icon1

78
79
80
81
82
83
84
85
86
87
    }
  };
}

function maybeCallback(cb) {
  return util.isFunction(cb) ? cb : rethrow();
}

// Ensure that callbacks run in the global context. Only use this function
// for callbacks that are passed to the binding layer, callbacks that are
fork icon0
star icon3
watch icon3