is-class-function
v0.0.1
Published
Check if function is an ES5 constructor or an ES6 class.
Downloads
4
Maintainers
Readme
is-class-function
Checks if function is an ES6 class. Supports classes declared in ES5 style but with at least one additional method in prototype or ES5 classes with inheritance. Native classes like Object, String, Function etc. treats as not a class-functions.
Install
Install on Node.JS with npm
npm install is-class-functionUsage
ES6 classes:
const isClassFn = require('is-class-function')
class EmptyClass {}
isClassFn(EmptyClass) // true
class SecondClass extends EmptyClass {}
isClassFn(SecondClass) // trueES5 classes:
const isClassFn = require('is-class-function')
function func() {}
isClassFn(func) // false
const arrowFn = () => {}
isClassFn(arrowFn) // false
function ES5Class() {}
ES5Class.prototype.method = function() {}
isClassFn(ES5Class) // trueLicense
MIT © Taras Panasyuk
