node-is-generator-1.0.3/0000775000175000017500000000000015256370071014063 5ustar emfoxemfoxnode-is-generator-1.0.3/.travis.yml0000644000175000017500000000032412676603244016175 0ustar emfoxemfoxlanguage: node_js notifications: email: on_success: never on_failure: change node_js: - "0.11" - "0.12" - "iojs" after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" node-is-generator-1.0.3/test.js0000644000175000017500000000240112676603244015377 0ustar emfoxemfox/* global describe, it */ var assert = require('assert') var isGenerator = require('./') describe('is-generator', function () { describe('generators', function () { it('should return false with non-generators', function () { assert(!isGenerator(null)) assert(!isGenerator(25)) assert(!isGenerator('test')) assert(!isGenerator(/* istanbul ignore next */ function () {})) assert(!isGenerator(/* istanbul ignore next */ function * () {})) }) it('should return true with a generator', function () { assert(isGenerator((/* istanbul ignore next */ function * () {})())) }) }) describe('generator functions', function () { it('should return false with non-generator function', function () { assert(!isGenerator.fn(null)) assert(!isGenerator.fn(25)) assert(!isGenerator.fn('test')) assert(!isGenerator.fn(/* istanbul ignore next */ function () {})) var noConstructorFn = /* istanbul ignore next */ function () {} noConstructorFn.constructor = undefined assert(!isGenerator.fn(noConstructorFn)) }) it('should return true with a generator function', function () { assert(isGenerator.fn(/* istanbul ignore next */ function * () { yield 'something' })) }) }) }) node-is-generator-1.0.3/is-generator.js0000644000175000017500000000110512676603244017017 0ustar emfoxemfox/** * Export generator function checks. */ module.exports = isGenerator module.exports.fn = isGeneratorFunction /** * Check whether an object is a generator. * * @param {Object} obj * @return {Boolean} */ function isGenerator (obj) { return obj && typeof obj.next === 'function' && typeof obj.throw === 'function' } /** * Check whether a function is generator. * * @param {Function} fn * @return {Boolean} */ function isGeneratorFunction (fn) { return typeof fn === 'function' && fn.constructor && fn.constructor.name === 'GeneratorFunction' } node-is-generator-1.0.3/LICENSE0000644000175000017500000000211712676603244015073 0ustar emfoxemfoxThe MIT License (MIT) Copyright (c) 2014 Blake Embrey (hello@blakeembrey.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. node-is-generator-1.0.3/README.md0000644000175000017500000000314612676604646015357 0ustar emfoxemfox# Is Generator [![NPM version][npm-image]][npm-url] [![NPM downloads][downloads-image]][downloads-url] [![Build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] > Check whether a value is a generator or generator function. **Generator:** A specific type of iterator object. [Reference][def-gen]. **Generator Function:** A `function*` declaration, returns a generator object. [Reference][def-gen-fn]. ## Installation ``` npm install is-generator --save ``` ## Usage ```javascript var isGenerator = require('is-generator') var isGeneratorFn = require('is-generator').fn isGenerator(null) //=> false isGenerator(function * () {}) //=> false isGenerator((function * () {})()) //=> true isGeneratorFn(null) //=> false isGeneratorFn(function () {}) //=> false isGeneratorFn(function * () {}) //=> true ``` ## License MIT [npm-image]: https://img.shields.io/npm/v/is-generator.svg?style=flat [npm-url]: https://npmjs.org/package/is-generator [downloads-image]: https://img.shields.io/npm/dm/is-generator.svg?style=flat [downloads-url]: https://npmjs.org/package/is-generator [travis-image]: https://img.shields.io/travis/blakeembrey/is-generator.svg?style=flat [travis-url]: https://travis-ci.org/blakeembrey/is-generator [coveralls-image]: https://img.shields.io/coveralls/blakeembrey/is-generator.svg?style=flat [coveralls-url]: https://coveralls.io/r/blakeembrey/is-generator?branch=master [def-gen]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator [def-gen-fn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function* node-is-generator-1.0.3/.npmignore0000644000175000017500000000004012676603244016056 0ustar emfoxemfox.DS_Store node_modules coverage node-is-generator-1.0.3/package.json0000644000175000017500000000210412676605001016341 0ustar emfoxemfox{ "name": "is-generator", "version": "1.0.3", "description": "Check whether a value is a generator or generator function", "main": "is-generator.js", "scripts": { "lint": "standard", "test-spec": "mocha -R spec --bail", "test-cov": "node --harmony node_modules/.bin/istanbul cover node_modules/mocha/bin/_mocha -- -R spec --bail", "test": "npm run lint && npm run test-cov" }, "repository": { "type": "git", "url": "git://github.com/blakeembrey/is-generator.git" }, "keywords": [ "generator", "generator function", "yield", "function", "await", "es6", "function*" ], "author": { "name": "Blake Embrey", "email": "hello@blakeembrey.com", "url": "http://blakeembrey.me" }, "license": "MIT", "bugs": { "url": "https://github.com/blakeembrey/is-generator/issues" }, "homepage": "https://github.com/blakeembrey/is-generator", "devDependencies": { "istanbul": "git://github.com/gotwarlost/istanbul#harmony", "mocha": "^1.21.4", "pre-commit": "^1.0.7", "standard": "^3.11.1" } }