degenerator
Advanced tools
Comparing version 2.1.2 to 2.1.3
@@ -20,5 +20,10 @@ "use strict"; | ||
if (!isGen(generatorFunction)) { | ||
if (typeof generatorFunction === 'function') { | ||
return function () { | ||
return Promise.resolve(true).then(() => generatorFunction.call(this, arguments)); | ||
}; | ||
} | ||
throw new Error('The given function must be a generator function'); | ||
} | ||
return function invoker() { | ||
return function () { | ||
const deferred = createDeferred(); | ||
@@ -25,0 +30,0 @@ const generator = generatorFunction.call(this, arguments); |
@@ -127,3 +127,6 @@ "use strict"; | ||
const fn = vm_1.runInNewContext(`${compiled};${returnName}`, options.sandbox, options); | ||
if (supports_async_1.default) { | ||
if (typeof fn !== 'function') { | ||
throw new Error(`Expected a function to be returned, but got ${typeof fn}`); | ||
} | ||
if (isAsyncFunction(fn)) { | ||
return fn; | ||
@@ -137,2 +140,5 @@ } | ||
})(degenerator || (degenerator = {})); | ||
function isAsyncFunction(fn) { | ||
return typeof fn === 'function' && fn.constructor.name === 'AsyncFunction'; | ||
} | ||
/** | ||
@@ -139,0 +145,0 @@ * Returns `true` if `node` has a matching name to one of the entries in the |
{ | ||
"name": "degenerator", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Turns sync functions into async generator functions", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24015
285