()
| 12 | } |
| 13 | |
| 14 | update() { |
| 15 | for(let i=0;i<arguments.length;i++) { |
| 16 | const value = arguments[i]; |
| 17 | if (value == null) |
| 18 | continue; |
| 19 | if(Array.isArray(value)) |
| 20 | this.update.apply(this, value); |
| 21 | else { |
| 22 | let k = 0; |
| 23 | switch (typeof(value)) { |
| 24 | case 'undefined': |
| 25 | case 'function': |
| 26 | continue; |
| 27 | case 'number': |
| 28 | case 'boolean': |
| 29 | k = value; |
| 30 | break; |
| 31 | case 'string': |
| 32 | k = stringHashCode(value); |
| 33 | break; |
| 34 | default: |
| 35 | if(value.updateHashCode) |
| 36 | value.updateHashCode(this); |
| 37 | else |
| 38 | console.log("No updateHashCode for " + value.toString()) |
| 39 | continue; |
| 40 | } |
| 41 | k = k * 0xCC9E2D51; |
| 42 | k = (k << 15) | (k >>> (32 - 15)); |
| 43 | k = k * 0x1B873593; |
| 44 | this.count = this.count + 1; |
| 45 | let hash = this.hash ^ k; |
| 46 | hash = (hash << 13) | (hash >>> (32 - 13)); |
| 47 | hash = hash * 5 + 0xE6546B64; |
| 48 | this.hash = hash; |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | finish() { |
| 54 | let hash = this.hash ^ (this.count * 4); |
no test coverage detected