From 73c10d7a1488ef753a35b14642b1a9cd896ea3c3 Mon Sep 17 00:00:00 2001 From: DCtheTall Date: Sat, 14 Dec 2019 19:02:43 -0500 Subject: [PATCH] Add type check for the argument of greenlet --- greenlet.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/greenlet.js b/greenlet.js index bcf3493..45896e7 100644 --- a/greenlet.js +++ b/greenlet.js @@ -3,6 +3,12 @@ * @public */ export default function greenlet(asyncFunction) { + // Type checking the argument. + const type = typeof asyncFunction; + if (type !== 'function') { + throw new TypeError('Expected function but recevied ' + type); + } + // A simple counter is used to generate worker-global unique ID's for RPC: let currentId = 0;