pax_global_header 0000666 0000000 0000000 00000000064 14753706321 0014522 g ustar 00root root 0000000 0000000 52 comment=1a9f102c6794a234a6f9546c30704603e9fed2ea
ljharb-async-generator-function-0608a94/ 0000775 0000000 0000000 00000000000 14753706321 0020163 5 ustar 00root root 0000000 0000000 ljharb-async-generator-function-0608a94/.eslintrc 0000664 0000000 0000000 00000000545 14753706321 0022013 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"rules": {
"id-length": "off",
},
"overrides": [
{
"files": "./index.js",
"extends": "@ljharb/eslint-config/node/8",
"rules": {
"id-length": "off",
},
},
{
"files": "./require.mjs",
"extends": "@ljharb/eslint-config/node/16",
"rules": {
"id-length": "off",
},
},
],
}
ljharb-async-generator-function-0608a94/.github/ 0000775 0000000 0000000 00000000000 14753706321 0021523 5 ustar 00root root 0000000 0000000 ljharb-async-generator-function-0608a94/.github/FUNDING.yml 0000664 0000000 0000000 00000001123 14753706321 0023335 0 ustar 00root root 0000000 0000000 # 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/async-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']
ljharb-async-generator-function-0608a94/.github/workflows/ 0000775 0000000 0000000 00000000000 14753706321 0023560 5 ustar 00root root 0000000 0000000 ljharb-async-generator-function-0608a94/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000354 14753706321 0026340 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js < 10'
on: [pull_request, push]
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '< 10'
type: minors
command: npm run tests-only
skip-ls-check: true
ljharb-async-generator-function-0608a94/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000000206 14753706321 0026712 0 ustar 00root root 0000000 0000000 name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
tests:
uses: ljharb/actions/.github/workflows/pretest.yml@main
ljharb-async-generator-function-0608a94/.github/workflows/node-tens.yml 0000664 0000000 0000000 00000000372 14753706321 0026201 0 ustar 00root root 0000000 0000000 name: '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
ljharb-async-generator-function-0608a94/.github/workflows/node-twenties.yml 0000664 0000000 0000000 00000000363 14753706321 0027072 0 ustar 00root root 0000000 0000000 name: '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
ljharb-async-generator-function-0608a94/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000257 14753706321 0025550 0 ustar 00root root 0000000 0000000 name: Automatic Rebase
on: [pull_request_target]
jobs:
_:
uses: ljharb/actions/.github/workflows/rebase.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
ljharb-async-generator-function-0608a94/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000303 14753706321 0030175 0 ustar 00root root 0000000 0000000 name: Require “Allow Edits”
on: [pull_request_target]
jobs:
_:
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main
ljharb-async-generator-function-0608a94/.gitignore 0000664 0000000 0000000 00000001241 14753706321 0022151 0 ustar 00root root 0000000 0000000 # 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
ljharb-async-generator-function-0608a94/.npmrc 0000664 0000000 0000000 00000000067 14753706321 0021306 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
ljharb-async-generator-function-0608a94/.nycrc 0000664 0000000 0000000 00000000213 14753706321 0021276 0 ustar 00root root 0000000 0000000 {
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"exclude": [
"coverage",
"test"
]
}
ljharb-async-generator-function-0608a94/CHANGELOG.md 0000664 0000000 0000000 00000001516 14753706321 0021777 0 ustar 00root root 0000000 0000000 # 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).
## v1.0.0 - 2025-02-14
### Commits
- Initial implementation, tests, readme, types [`5a239d4`](https://github.com/ljharb/async-generator-function/commit/5a239d463b2cbc4658d0dd3baeaaeae9a137e6a0)
- Initial commit [`603f1d9`](https://github.com/ljharb/async-generator-function/commit/603f1d9686f22235a61092abee703674f6fd3ffd)
- npm init [`ba54949`](https://github.com/ljharb/async-generator-function/commit/ba549496656d1cd545813769fd9e06020c1edd41)
- Only apps should have lockfiles [`b66a110`](https://github.com/ljharb/async-generator-function/commit/b66a11020ef902d96a31c523cfb2723c4e2ca998)
ljharb-async-generator-function-0608a94/LICENSE 0000664 0000000 0000000 00000002053 14753706321 0021170 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2016 EduardoRFS
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.
ljharb-async-generator-function-0608a94/README.md 0000664 0000000 0000000 00000004061 14753706321 0021443 0 ustar 00root root 0000000 0000000 # async-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 `AsyncFunction` constructor, when available.
## Getting started
```sh
npm install --save async-generator-function
```
## Usage/Examples
```js
const assert = require('assert');
const AsyncGeneratorFunction = require('async-generator-function')();
const fn = new AsyncGeneratorFunction('return 1');
assert.equal(fn.toString(), 'async function* anonymous(\n) {\nreturn 1\n}');
const iterator = fn();
iterator.next().then(x => {
assert.deepEqual(x, { done: true, value: 1 });
});
```
## Tests
Clone the repo, `npm install`, and run `npm test`
[package-url]: https://npmjs.org/package/async-generator-function
[npm-version-svg]: https://versionbadg.es/ljharb/async-generator-function.svg
[deps-svg]: https://david-dm.org/ljharb/async-generator-function.svg
[deps-url]: https://david-dm.org/ljharb/async-generator-function
[dev-deps-svg]: https://david-dm.org/ljharb/async-generator-function/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/async-generator-function#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/async-generator-function.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/async-generator-function.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/async-generator-function.svg
[downloads-url]: https://npm-stat.com/charts.html?package=async-generator-function
[codecov-image]: https://codecov.io/gh/ljharb/async-generator-function/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/ljharb/async-generator-function/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/async-generator-function
[actions-url]: https://github.com/ljharb/async-generator-function/actions
ljharb-async-generator-function-0608a94/index.d.mts 0000664 0000000 0000000 00000000133 14753706321 0022236 0 ustar 00root root 0000000 0000000 import getAsyncGeneratorFunction = require('.');
export default getAsyncGeneratorFunction; ljharb-async-generator-function-0608a94/index.d.ts 0000664 0000000 0000000 00000001475 14753706321 0022073 0 ustar 00root root 0000000 0000000 import type { AsyncFunction, AsyncFunctionConstructor } from 'async-function';
type AGF = AsyncGeneratorFunction;
declare namespace getAsyncGeneratorFunction {
interface AsyncGeneratorFunction extends AGF, AsyncFunction {
readonly [Symbol.toStringTag]: "AsyncGeneratorFunction";
}
// The constructor for an async generator function, like `(async function*(){}).constructor`
interface AsyncGeneratorFunctionConstructor {
(...args: string[]): AsyncGeneratorFunction;
new (...args: string[]): AsyncGeneratorFunction;
readonly prototype: AsyncGeneratorFunction;
}
export type { AsyncGeneratorFunctionConstructor };
}
declare function getAsyncGeneratorFunction(): getAsyncGeneratorFunction.AsyncGeneratorFunctionConstructor | false;
export = getAsyncGeneratorFunction; ljharb-async-generator-function-0608a94/index.js 0000664 0000000 0000000 00000000373 14753706321 0021633 0 ustar 00root root 0000000 0000000 'use strict';
// eslint-disable-next-line no-extra-parens, no-empty-function
const cached = /** @type {import('.').AsyncGeneratorFunctionConstructor} */ (async function* () {}.constructor);
/** @type {import('.')} */
module.exports = () => cached;
ljharb-async-generator-function-0608a94/index.mjs 0000664 0000000 0000000 00000000216 14753706321 0022004 0 ustar 00root root 0000000 0000000 import getAsyncGeneratorFunction from './index.js';
/** @type {import('./index.d.mts').default} */
export default getAsyncGeneratorFunction;
ljharb-async-generator-function-0608a94/legacy.js 0000664 0000000 0000000 00000000617 14753706321 0021771 0 ustar 00root root 0000000 0000000 'use strict';
/** @type {import('.').AsyncGeneratorFunctionConstructor | false} */
var cached;
/** @type {import('.')} */
module.exports = function getAsyncGeneratorFunction() {
if (typeof cached === 'undefined') {
try {
// eslint-disable-next-line no-new-func
cached = Function('return async function* () {}')().constructor;
} catch (e) {
cached = false;
}
}
return cached;
};
ljharb-async-generator-function-0608a94/package.json 0000664 0000000 0000000 00000004425 14753706321 0022456 0 ustar 00root root 0000000 0000000 {
"name": "async-generator-function",
"version": "1.0.0",
"description": "A function that returns the normally hidden `AsyncGeneratorFunction` 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"
},
"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/ljharb/async-generator-function.git"
},
"keywords": [
"async",
"await",
"function",
"native"
],
"author": "Jordan Harbamd ",
"license": "MIT",
"bugs": {
"url": "https://github.com/ljharb/async-generator-function/issues"
},
"homepage": "https://github.com/ljharb/async-generator-function#readme",
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.3",
"@ljharb/eslint-config": "^21.1.1",
"@ljharb/tsconfig": "^0.2.3",
"@types/semver": "^6.2.7",
"@types/tape": "^5.8.1",
"async-function": "^1.0.0",
"auto-changelog": "^2.5.0",
"eslint": "=8.8.0",
"evalmd": "^0.0.19",
"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"
}
}
ljharb-async-generator-function-0608a94/require.mjs 0000664 0000000 0000000 00000000232 14753706321 0022347 0 ustar 00root root 0000000 0000000 import getAsyncGeneratorFunction from './index.js';
export default getAsyncGeneratorFunction;
export { getAsyncGeneratorFunction as 'module.exports' };
ljharb-async-generator-function-0608a94/test/ 0000775 0000000 0000000 00000000000 14753706321 0021142 5 ustar 00root root 0000000 0000000 ljharb-async-generator-function-0608a94/test/index.js 0000664 0000000 0000000 00000002172 14753706321 0022611 0 ustar 00root root 0000000 0000000 'use strict';
var test = require('tape');
var getProto = require('get-proto');
var semver = require('semver');
var getAsyncGeneratorFunction = require('../');
test('getAsyncGeneratorFunction', function (t) {
var result = getAsyncGeneratorFunction();
/* eslint-env browser */
if (typeof window === 'undefined' && typeof process !== 'undefined') {
t.equal(
!!result,
semver.satisfies(process.version, '>= 10'),
'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 AsyncGeneratorFunction exists
st.equal(typeof result, 'function', 'is a function');
st.equal(getProto(result), Function, 'extends Function');
return result('a', 'return a')(42).next().then(function (a) {
st.deepEqual(a, { done: true, value: 42 }, 'returns an async generator function');
});
}
return st.fail('should never get here');
});
t.test('does not exist', { skip: !!result }, function (st) {
st.equal(result, false, 'is false');
st.end();
});
t.end();
});
ljharb-async-generator-function-0608a94/tsconfig.json 0000664 0000000 0000000 00000000164 14753706321 0022673 0 ustar 00root root 0000000 0000000 {
"extends": "@ljharb/tsconfig",
"compilerOptions": {
"target": "es2021",
},
"exclude": [
"coverage",
],
}