Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 23 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | module.exports = { |
||
2 | |||
3 | /** |
||
4 | * Check whether the given object is an instance of the specified class. |
||
5 | * The necessity for this is discussed in PR #13: https://github.com/rootsdev/gedcomx-js/pull/13 |
||
6 | * |
||
7 | * We put this functionality in a method to be DRY, even though it's short. |
||
8 | * This could easily change in the future for correction and performance. |
||
9 | * |
||
10 | * It could be handy to expose this on GedcomX somewhere so that users of the |
||
11 | * library can use it too. But then we would need to add a way for them to |
||
12 | * easily get the _gedxClass property without being tied to that private |
||
13 | * property name. In other words, a static method such as Person.getClass() |
||
14 | * |
||
15 | * @param {Object} obj |
||
16 | * @param {String} className |
||
17 | * @returns {Boolean} |
||
18 | */ |
||
19 | isInstance: function(obj, className){ |
||
20 | return obj && Object.getPrototypeOf(obj) !== Object.prototype && obj._gedxClass === className; |
||
21 | } |
||
22 | |||
23 | }; |