UNPKG

@eluvio/elv-js-helpers

Version:

A collection of Javascript helper functions used by several Eluvio libraries.

37 lines (32 loc) 767 B
'use strict' const kind = require('../Validation/kind') /** * Returns `true` if passed a GeneratorFunction. * * Returns `false` if passed anything else * * @function * @category Boolean * @sig a -> Boolean * @param {*} x - The value to test * @returns {Boolean} * @example * * 'use strict' * const isGeneratorFunction = require('@eluvio/elv-js-helpers/Boolean/isGeneratorFunction') * * function* numbersUpTo(x) { * for (let i = 0; i < x; i++) { * yield i * } * } * * isGeneratorFunction(numbersUpTo) //=> true * * isGeneratorFunction(Math.round) //=> false * * isGeneratorFunction(undefined) //=> false * */ const isGeneratorFunction = x => kind(x) === 'GeneratorFunction' module.exports = isGeneratorFunction