Skip to content

isGenerator

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

Check if value is a generator function.

Similar: [is], [isAsync], isGenerator.


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


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

isGenerator(naturalNumbers);
// → true

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


References

Clone this wiki locally