pax_global_header00006660000000000000000000000064134521055470014520gustar00rootroot0000000000000052 comment=223059ea49e662e9811270912517db26eb4bdc80 is-generator-fn-2.1.0/000077500000000000000000000000001345210554700145205ustar00rootroot00000000000000is-generator-fn-2.1.0/.editorconfig000066400000000000000000000002571345210554700172010ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 is-generator-fn-2.1.0/.gitattributes000066400000000000000000000000231345210554700174060ustar00rootroot00000000000000* text=auto eol=lf is-generator-fn-2.1.0/.gitignore000066400000000000000000000000271345210554700165070ustar00rootroot00000000000000node_modules yarn.lock is-generator-fn-2.1.0/.npmrc000066400000000000000000000000231345210554700156330ustar00rootroot00000000000000package-lock=false is-generator-fn-2.1.0/.travis.yml000066400000000000000000000000641345210554700166310ustar00rootroot00000000000000language: node_js node_js: - '10' - '8' - '6' is-generator-fn-2.1.0/index.d.ts000066400000000000000000000010451345210554700164210ustar00rootroot00000000000000declare const isGeneratorFn: { /** Check if something is a generator function. @example ``` import isGeneratorFn = require('is-generator-fn'); isGeneratorFn(function * () {}); //=> true isGeneratorFn(function () {}); //=> false ``` */ (value: unknown): value is GeneratorFunction; // TODO: Remove this for the next major release, refactor the whole definition to: // declare function isGeneratorFn(value: unknown): value is GeneratorFunction; // export = isGeneratorFn; default: typeof isGeneratorFn; }; export = isGeneratorFn; is-generator-fn-2.1.0/index.js000066400000000000000000000005571345210554700161740ustar00rootroot00000000000000'use strict'; const {toString} = Object.prototype; module.exports = value => { if (typeof value !== 'function') { return false; } return (value.constructor && value.constructor.name === 'GeneratorFunction') || toString.call(value) === '[object GeneratorFunction]'; }; // TODO: Remove this for the next major release module.exports.default = module.exports; is-generator-fn-2.1.0/index.test-d.ts000066400000000000000000000005761345210554700174060ustar00rootroot00000000000000import {expectType} from 'tsd'; import isGeneratorFn = require('.'); expectType(isGeneratorFn(function * () {return '🦄'})); expectType(isGeneratorFn(function * () { yield '🦄'; })); expectType(isGeneratorFn(null)); expectType(isGeneratorFn(undefined)); expectType(isGeneratorFn(() => {})); expectType(isGeneratorFn('')); is-generator-fn-2.1.0/license000066400000000000000000000021251345210554700160650ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. is-generator-fn-2.1.0/package.json000066400000000000000000000011461345210554700170100ustar00rootroot00000000000000{ "name": "is-generator-fn", "version": "2.1.0", "description": "Check if something is a generator function", "license": "MIT", "repository": "sindresorhus/is-generator-fn", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=6" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "generator", "function", "func", "fn", "is", "check", "detect", "yield", "type" ], "devDependencies": { "ava": "^1.4.1", "tsd": "^0.7.2", "xo": "^0.24.0" } } is-generator-fn-2.1.0/readme.md000066400000000000000000000012051345210554700162750ustar00rootroot00000000000000# is-generator-fn [![Build Status](https://travis-ci.org/sindresorhus/is-generator-fn.svg?branch=master)](https://travis-ci.org/sindresorhus/is-generator-fn) > Check if something is a [generator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) ## Install ``` $ npm install is-generator-fn ``` ## Usage ```js const isGeneratorFn = require('is-generator-fn'); isGeneratorFn(function * () {}); //=> true isGeneratorFn(function () {}); //=> false ``` ## Related - [is](https://github.com/sindresorhus/is) - Type check values ## License MIT © [Sindre Sorhus](https://sindresorhus.com) is-generator-fn-2.1.0/test.js000066400000000000000000000004741345210554700160420ustar00rootroot00000000000000import test from 'ava'; import isGeneratorFn from '.'; test('main', t => { t.true(isGeneratorFn(function * () {})); t.true(isGeneratorFn(function * () { yield 'unicorn'; })); t.false(isGeneratorFn(null)); t.false(isGeneratorFn(undefined)); t.false(isGeneratorFn(() => {})); t.false(isGeneratorFn('')); });