is-async-function
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -8,2 +8,15 @@ # Changelog | ||
## [v2.1.1](https://github.com/inspect-js/is-async-function/compare/v2.1.0...v2.1.1) - 2025-01-22 | ||
### Fixed | ||
- [Refactor] use `async-function` for the eval parts [`#31`](https://github.com/inspect-js/is-async-function/issues/31) | ||
### Commits | ||
- [Refactor] move `new Function` helper into a separate file [`db36da5`](https://github.com/inspect-js/is-async-function/commit/db36da5467fbbf0f2ae264114be6aa9edf55e218) | ||
- [Dev Deps] update `@arethetypeswrong/cli`, `@types/tape` [`981ab90`](https://github.com/inspect-js/is-async-function/commit/981ab907b700d344b510ca1617fda00a66513aa2) | ||
- [meta] add `exports` [`81bb8e5`](https://github.com/inspect-js/is-async-function/commit/81bb8e578c8cbeeda742715ab7a935c0472866a1) | ||
- [Refactor] skip `getProto` call when `AsyncFunction` does not exist [`dc929a5`](https://github.com/inspect-js/is-async-function/commit/dc929a547a5f7cd1337b176d20135b8cc3cc23cb) | ||
## [v2.1.0](https://github.com/inspect-js/is-async-function/compare/v2.0.0...v2.1.0) - 2025-01-02 | ||
@@ -10,0 +23,0 @@ |
@@ -0,7 +1,9 @@ | ||
import type { AsyncFunction } from 'async-function'; | ||
declare namespace isAsyncFunction { | ||
type AsyncFunction = (...args: any[]) => Promise<any> | ||
export type { AsyncFunction }; | ||
} | ||
declare function isAsyncFunction(fn: unknown): fn is isAsyncFunction.AsyncFunction; | ||
declare function isAsyncFunction(fn: unknown): fn is AsyncFunction; | ||
export = isAsyncFunction; |
21
index.js
@@ -13,15 +13,4 @@ 'use strict'; | ||
var getAsyncFunc = function () { // eslint-disable-line consistent-return | ||
if (!hasToStringTag) { | ||
return false; | ||
} | ||
try { | ||
return Function('return async function () {}')(); | ||
} catch (e) { | ||
} | ||
}; | ||
var getAsyncFunc = require('async-function'); | ||
/** @type {import('.').AsyncFunction | false} */ | ||
var AsyncFunction; | ||
/** @type {import('.')} */ | ||
@@ -42,8 +31,4 @@ module.exports = function isAsyncFunction(fn) { | ||
} | ||
if (typeof AsyncFunction === 'undefined') { | ||
var asyncFunc = getAsyncFunc(); | ||
// eslint-disable-next-line no-extra-parens | ||
AsyncFunction = asyncFunc ? /** @type {import('.').AsyncFunction} */ (getProto(asyncFunc)) : false; | ||
} | ||
return getProto(fn) === AsyncFunction; | ||
var asyncFunc = getAsyncFunc(); | ||
return asyncFunc && asyncFunc.prototype === getProto(fn); | ||
}; |
{ | ||
"name": "is-async-function", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Determine if a function is a native async function.", | ||
"main": "index.js", | ||
"exports": { | ||
".": "./index.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
@@ -44,2 +48,3 @@ "prepack": "npmignore --auto --commentLines=autogenerated", | ||
"dependencies": { | ||
"async-function": "^1.0.0", | ||
"call-bound": "^1.0.3", | ||
@@ -51,3 +56,3 @@ "get-proto": "^1.0.1", | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "^0.17.2", | ||
"@arethetypeswrong/cli": "^0.17.3", | ||
"@ljharb/eslint-config": "^21.1.1", | ||
@@ -58,3 +63,3 @@ "@ljharb/tsconfig": "^0.2.3", | ||
"@types/make-generator-function": "^2.0.3", | ||
"@types/tape": "^5.8.0", | ||
"@types/tape": "^5.8.1", | ||
"auto-changelog": "^2.5.0", | ||
@@ -61,0 +66,0 @@ "encoding": "^0.1.13", |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
23312
0
5
127
+ Addedasync-function@^1.0.0
+ Addedasync-function@1.0.0(transitive)