@leyyo/common 1.3.15 → 1.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,14 +5,25 @@
5
5
  * @return {boolean} - is class?
6
6
  * */
7
7
  export function isClass(fn) {
8
- // Class constructor is also a function
9
- if (!(fn && fn.constructor === Function) || fn.prototype === undefined) {
8
+ if (typeof fn !== 'function') {
10
9
  return false;
11
10
  }
12
- // This is a class that extends other class
13
- if (Function.prototype !== Object.getPrototypeOf(fn)) {
14
- return true;
11
+ try {
12
+ return Function.prototype.toString.call(fn).toString().startsWith('class ');
15
13
  }
16
- // Usually a function will only have 'constructor' in the prototype
17
- return Object.getOwnPropertyNames(fn.prototype).length > 1;
14
+ catch (e) {
15
+ return false;
16
+ }
17
+ // // Class constructor is also a function
18
+ // if ( !(fn && fn.constructor === Function) || (fn as Fnc).prototype === undefined) {
19
+ // return false;
20
+ // }
21
+ //
22
+ // // This is a class that extends other class
23
+ // if (Function.prototype !== Object.getPrototypeOf(fn)) {
24
+ // return true;
25
+ // }
26
+ //
27
+ // // Usually a function will only have 'constructor' in the prototype
28
+ // return Object.getOwnPropertyNames((fn as Fnc).prototype).length > 1;
18
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leyyo/common",
3
- "version": "1.3.15",
3
+ "version": "1.3.16",
4
4
  "description": "Leyyo common library",
5
5
  "keywords": [
6
6
  "common"