src/rs/Name.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 41
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 41
rs 10
wmc 5
mnd 1
bc 5
fnc 4
bpm 1.25
cpm 1.25
noi 0
1
/**
2
 * RS extensions to Name
3
 */
4
module.exports = function(GedcomX){
5
  
6
  // Extend serialization properties
7
  GedcomX.Name.jsonProps.push('preferred');
8
  
9
  // Override init() so that we can deserialize normalized values
10
  var oldInit = GedcomX.Name.prototype.init;
11
  GedcomX.Name.prototype.init = function(json){
12
    oldInit.call(this, json);
13
    if(json){
14
      this.setPreferred(json.preferred);
15
    }
16
  };
17
  
18
  /**
19
   * Set the preferred flag
20
   * 
21
   * @function setPreferred
22
   * @instance
23
   * @memberof Name
24
   * @param {Boolean} preferred
25
   * @return {Name} this
26
   */
27
  GedcomX.Name.prototype.setPreferred = function(preferred){
28
    this.preferred = preferred;
29
    return this;
30
  };
31
  
32
  /**
33
   * Get the preferred flag
34
   * 
35
   * @function getPreferred
36
   * @instance
37
   * @memberof Name
38
   * @return {Boolean} preferred
39
   */
40
  GedcomX.Name.prototype.getPreferred = function(){
41
    return this.preferred;
42
  };
43
  
44
};