Completed
Push — master ( 2281e8...8b163e )
by Justin
01:35
created

src/utils.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 23
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 0
c 1
b 1
f 0
nc 3
dl 0
loc 23
rs 10
wmc 1
mnd 0
bc 1
fnc 1
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A module.exports.isInstance 0 3 1
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
};