diff options
Diffstat (limited to 'harness/isConstructor.js')
-rw-r--r-- | harness/isConstructor.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/harness/isConstructor.js b/harness/isConstructor.js new file mode 100644 index 000000000..bf7433219 --- /dev/null +++ b/harness/isConstructor.js @@ -0,0 +1,16 @@ +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} |