Skip to content

isGenerator

Subhajit Sahu edited this page Jul 29, 2022 · 2 revisions

Check if value is a generator function.

Similar: is, isAsync, isGenerator.


function isGenerator(v)
// v: a value
const xfunction = require('extra-function');


function* naturalNumbers() {
  for (var i=0;; ++i)
    yield i;
}

xfunction.isGenerator(naturalNumbers);
// → true

xfunction.isGenerator(() => 0);
// → false


References

Clone this wiki locally