From ed27aec85a1a2b008780bc7105428a39ed26e994 Mon Sep 17 00:00:00 2001 From: Jim Radford Date: Thu, 7 Nov 2013 11:07:40 -0800 Subject: [PATCH] Use instanceof instead of typeof --- run.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/run.js b/run.js index 2c97a1e..aeba256 100644 --- a/run.js +++ b/run.js @@ -2,7 +2,7 @@ module.exports = run; function run(generator, callback) { var iterator; - if (typeof generator === "function") { + if (generator instanceof Function) { // Pass in resume for no-wrap function calls iterator = generator(resume); } @@ -45,19 +45,19 @@ function run(generator, callback) { function start(cont) { // Pass in resume to continuables if one was yielded. - if (typeof cont === "function") return cont(resume()); + if (cont instanceof Function) return cont(resume()); // If an array of continuables is yielded, run in parallel if (Array.isArray(cont)) { for (var i = 0, l = cont.length; i < l; ++i) { - if (typeof cont[i] !== "function") return; + if (!(cont[i] instanceof Function)) return; } return parallel(cont, resume()); } // Also run hash of continuables in parallel, but name results. - if (typeof cont === "object" && Object.getPrototypeOf(cont) === Object.prototype) { + if (cont instanceof Object) { var keys = Object.keys(cont); for (var i = 0, l = keys.length; i < l; ++i) { - if (typeof cont[keys[i]] !== "function") return; + if (!(cont[keys[i]] instanceof Function)) return; } return parallelNamed(keys, cont, resume()); }