pax_global_header00006660000000000000000000000064150670200260014510gustar00rootroot0000000000000052 comment=e44c753dc1205a5a1cd45176acbcd139c8d68a7b TimothyGu-generator-function-3a583cd/000077500000000000000000000000001506702002600176645ustar00rootroot00000000000000TimothyGu-generator-function-3a583cd/.eslintrc000066400000000000000000000003451506702002600215120ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "overrides": [ { "files": "./index.js", "extends": "@ljharb/eslint-config/node/8" }, { "files": "./require.mjs", "extends": "@ljharb/eslint-config/node/16", }, ], } TimothyGu-generator-function-3a583cd/.github/000077500000000000000000000000001506702002600212245ustar00rootroot00000000000000TimothyGu-generator-function-3a583cd/.github/FUNDING.yml000066400000000000000000000011151506702002600230370ustar00rootroot00000000000000# These are supported funding model platforms github: [ljharb] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: npm/generator-function community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] TimothyGu-generator-function-3a583cd/.github/workflows/000077500000000000000000000000001506702002600232615ustar00rootroot00000000000000TimothyGu-generator-function-3a583cd/.github/workflows/node-aught.yml000066400000000000000000000004451506702002600260420ustar00rootroot00000000000000name: 'Tests: node.js < 10' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '< 10' notable: '1.0' # io.js v1 introduced AsyncFunction type: minors command: npm run tests-only skip-ls-check: true TimothyGu-generator-function-3a583cd/.github/workflows/node-pretest.yml000066400000000000000000000002061506702002600264130ustar00rootroot00000000000000name: 'Tests: pretest/posttest' on: [pull_request, push] jobs: tests: uses: ljharb/actions/.github/workflows/pretest.yml@main TimothyGu-generator-function-3a583cd/.github/workflows/node-tens.yml000066400000000000000000000003721506702002600257020ustar00rootroot00000000000000name: 'Tests: node.js 10 - 20' on: [pull_request, push] permissions: contents: read jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '>= 10 < 20' type: minors command: npm run tests-only TimothyGu-generator-function-3a583cd/.github/workflows/node-twenties.yml000066400000000000000000000003631506702002600265730ustar00rootroot00000000000000name: 'Tests: node.js >= 20' on: [pull_request, push] permissions: contents: read jobs: tests: uses: ljharb/actions/.github/workflows/node.yml@main with: range: '>= 20' type: minors command: npm run tests-only TimothyGu-generator-function-3a583cd/.github/workflows/rebase.yml000066400000000000000000000002571506702002600252510ustar00rootroot00000000000000name: Automatic Rebase on: [pull_request_target] jobs: _: uses: ljharb/actions/.github/workflows/rebase.yml@main secrets: token: ${{ secrets.GITHUB_TOKEN }} TimothyGu-generator-function-3a583cd/.github/workflows/require-allow-edits.yml000066400000000000000000000003031506702002600276760ustar00rootroot00000000000000name: Require “Allow Edits” on: [pull_request_target] jobs: _: name: "Require “Allow Edits”" runs-on: ubuntu-latest steps: - uses: ljharb/require-allow-edits@main TimothyGu-generator-function-3a583cd/.gitignore000066400000000000000000000012411506702002600216520ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules jspm_packages # Optional npm cache directory .npm # Optional REPL history .node_repl_history # Only apps should have lockfiles npm-shrinkwrap.json package-lock.json yarn.lock .npmignore TimothyGu-generator-function-3a583cd/.npmrc000066400000000000000000000000671506702002600210070ustar00rootroot00000000000000package-lock=false allow-same-version=true message=v%s TimothyGu-generator-function-3a583cd/.nycrc000066400000000000000000000002131506702002600207770ustar00rootroot00000000000000{ "all": true, "check-coverage": false, "reporter": ["text-summary", "text", "html", "json"], "exclude": [ "coverage", "test" ] } TimothyGu-generator-function-3a583cd/CHANGELOG.md000066400000000000000000000025011506702002600214730ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [v2.0.1](https://github.com/TimothyGu/generator-function/compare/v2.0.0...v2.0.1) - 2025-09-30 ### Commits - [meta] fix repo URL [`f5d05f2`](https://github.com/TimothyGu/generator-function/commit/f5d05f278e1f0660c418bf0b867e0013873da48c) ## [v2.0.0](https://github.com/TimothyGu/generator-function/compare/v1.0.0...v2.0.0) - 2025-09-29 ### Commits - Initial reimplementation, tests, readme, types [`e5940de`](https://github.com/TimothyGu/generator-function/commit/e5940de4328fc70ad27aa4bab4245f6c9ce62a44) - [meta] remove unused files [`460bbe9`](https://github.com/TimothyGu/generator-function/commit/460bbe9cc6c89f9fdab05a001dc924308124613b) - [Dev Deps] add missing peer dep [`b873c0d`](https://github.com/TimothyGu/generator-function/commit/b873c0dad8f38b08e2acc4bd5204a90dde0fe051) - [meta] fix FUNDING.yml [`9ae9d43`](https://github.com/TimothyGu/generator-function/commit/9ae9d432a0c06d698e1aeb20b1161ca8a08b3cbb) ## v1.0.0 - 2015-10-10 ### Commits - Initial commit [`176e0cd`](https://github.com/TimothyGu/generator-function/commit/176e0cd3a5ebb004aa666c6eecbe5a968efbddf9) TimothyGu-generator-function-3a583cd/LICENSE.md000066400000000000000000000020561506702002600212730ustar00rootroot00000000000000Copyright (c) 2015 Tiancheng “Timothy” Gu 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. TimothyGu-generator-function-3a583cd/README.md000066400000000000000000000037051506702002600211500ustar00rootroot00000000000000# generator-function [![Version Badge][npm-version-svg]][package-url] [![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][npm-badge-png]][package-url] A function that returns the normally hidden `GeneratorFunction` constructor, when available. ## Getting started ```sh npm install --save generator-function ``` ## Usage/Examples ```js const assert = require('assert'); const GeneratorFunction = require('generator-function')(); const fn = new GeneratorFunction('return 1'); assert.equal(fn.toString(), 'function* anonymous(\n) {\nreturn 1\n}'); const iterator = fn(); assert.deepEqual(iterator.next(), { done: true, value: 1 }); ``` ## Tests Clone the repo, `npm install`, and run `npm test` [package-url]: https://npmjs.org/package/generator-function [npm-version-svg]: https://versionbadg.es/TimothyGu/generator-function.svg [deps-svg]: https://david-dm.org/TimothyGu/generator-function.svg [deps-url]: https://david-dm.org/TimothyGu/generator-function [dev-deps-svg]: https://david-dm.org/TimothyGu/generator-function/dev-status.svg [dev-deps-url]: https://david-dm.org/TimothyGu/generator-function#info=devDependencies [npm-badge-png]: https://nodei.co/npm/generator-function.png?downloads=true&stars=true [license-image]: https://img.shields.io/npm/l/generator-function.svg [license-url]: LICENSE [downloads-image]: https://img.shields.io/npm/dm/generator-function.svg [downloads-url]: https://npm-stat.com/charts.html?package=generator-function [codecov-image]: https://codecov.io/gh/TimothyGu/generator-function/branch/main/graphs/badge.svg [codecov-url]: https://app.codecov.io/gh/TimothyGu/generator-function/ [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/TimothyGu/generator-function [actions-url]: https://github.com/TimothyGu/generator-function/actions TimothyGu-generator-function-3a583cd/index.d.mts000066400000000000000000000001411506702002600217360ustar00rootroot00000000000000import type getGeneratorFunction = require('./index.d.ts'); export default getGeneratorFunction;TimothyGu-generator-function-3a583cd/index.d.ts000066400000000000000000000001561506702002600215670ustar00rootroot00000000000000declare function getGeneratorFunction(): GeneratorFunctionConstructor | false; export = getGeneratorFunction;TimothyGu-generator-function-3a583cd/index.js000066400000000000000000000003441506702002600213320ustar00rootroot00000000000000'use strict'; // eslint-disable-next-line no-extra-parens, no-empty-function const cached = /** @type {GeneratorFunctionConstructor} */ (function* () {}.constructor); /** @type {import('.')} */ module.exports = () => cached; TimothyGu-generator-function-3a583cd/index.mjs000066400000000000000000000002041506702002600215020ustar00rootroot00000000000000import getGeneratorFunction from './index.js'; /** @type {import('./index.d.mts').default} */ export default getGeneratorFunction; TimothyGu-generator-function-3a583cd/legacy.js000066400000000000000000000005741506702002600214740ustar00rootroot00000000000000'use strict'; /** @type {GeneratorFunctionConstructor | false} */ var cached; /** @type {import('./index.js')} */ module.exports = function getGeneratorFunction() { if (typeof cached === 'undefined') { try { // eslint-disable-next-line no-new-func cached = Function('return function* () {}')().constructor; } catch (e) { cached = false; } } return cached; }; TimothyGu-generator-function-3a583cd/package.json000066400000000000000000000044561506702002600221630ustar00rootroot00000000000000{ "name": "generator-function", "version": "2.0.1", "description": "A function that returns the normally hidden `GeneratorFunction` constructor", "main": "./legacy.js", "jsnext:main": "./index.mjs", "module": "./index.mjs", "exports": { ".": [ { "module-sync": "./require.mjs", "import": "./index.mjs", "default": "./index.js" }, "./index.js" ], "./package.json": "./package.json" }, "sideEffects": false, "scripts": { "prepack": "npmignore --auto --commentLines=autogenerated", "prepublish": "not-in-publish || npm run prepublishOnly", "prepublishOnly": "safe-publish-latest", "pretest": "npm run --silent lint", "test": "npm run tests-only", "posttest": "npx npm@\">=10.2\" audit --production", "tests-only": "nyc tape 'test/**/*.js'", "prelint": "evalmd README.md", "lint": "eslint --ext=js,mjs .", "postlint": "tsc && attw -P", "version": "auto-changelog && git add CHANGELOG.md", "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" }, "repository": { "type": "git", "url": "git+https://github.com/TimothyGu/generator-function.git" }, "keywords": [ "generator", "function", "native" ], "author": "Jordan Harbamd ", "license": "MIT", "bugs": { "url": "https://github.com/TimothyGu/generator-function/issues" }, "homepage": "https://github.com/TimothyGu/generator-function#readme", "devDependencies": { "@arethetypeswrong/cli": "^0.18.2", "@ljharb/eslint-config": "^21.2.0", "@ljharb/tsconfig": "^0.3.2", "@types/semver": "^6.2.7", "@types/tape": "^5.8.1", "auto-changelog": "^2.5.0", "encoding": "^0.1.13", "eslint": "=8.8.0", "evalmd": "^0.0.19", "generator-function": "file:.", "get-proto": "^1.0.1", "in-publish": "^2.0.1", "npmignore": "^0.3.1", "nyc": "^10.3.2", "safe-publish-latest": "^2.0.0", "semver": "^6.3.1", "tape": "^5.9.0", "typescript": "next" }, "engines": { "node": ">= 0.4" }, "auto-changelog": { "output": "CHANGELOG.md", "template": "keepachangelog", "unreleased": false, "commitLimit": false, "backfillLimit": false, "hideCredit": true }, "publishConfig": { "ignore": [ ".github/workflows" ] }, "testling": { "files": "test/index.js" } } TimothyGu-generator-function-3a583cd/require.mjs000066400000000000000000000002131506702002600220470ustar00rootroot00000000000000import getGeneratorFunction from './index.js'; export default getGeneratorFunction; export { getGeneratorFunction as 'module.exports' }; TimothyGu-generator-function-3a583cd/test/000077500000000000000000000000001506702002600206435ustar00rootroot00000000000000TimothyGu-generator-function-3a583cd/test/index.js000066400000000000000000000022151506702002600223100ustar00rootroot00000000000000'use strict'; var test = require('tape'); var getProto = require('get-proto'); var semver = require('semver'); var getGeneratorFunction = require('generator-function'); test('getGeneratorFunction', function (t) { var result = getGeneratorFunction(); /* eslint-env browser */ if (typeof window === 'undefined' && typeof process !== 'undefined') { t.equal( !!result, semver.satisfies(process.version, '>= 1'), 'result is present or absent as expected for node ' + process.version ); } t.test('exists', { skip: !result }, function (st) { if (result && getProto) { // TS can't infer `skip`, or that getProto definitely exists if GeneratorFunction exists st.equal(typeof result, 'function', 'is a function'); st.equal(getProto(result), Function, 'extends Function'); var iterator = result('a', 'return a')(42); st.deepEqual(iterator.next(), { value: 42, done: true }, 'returns a generator function which returns an iterator'); } else { st.fail('should never get here'); } st.end(); }); t.test('does not exist', { skip: !!result }, function (st) { st.equal(result, false, 'is false'); st.end(); }); t.end(); }); TimothyGu-generator-function-3a583cd/tsconfig.json000066400000000000000000000001641506702002600223740ustar00rootroot00000000000000{ "extends": "@ljharb/tsconfig", "compilerOptions": { "target": "es2021", }, "exclude": [ "coverage", ], }