whatap 1.0.1 → 1.0.2

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.
Files changed (198) hide show
  1. package/README.md +32 -78
  2. package/lib/conf/conf-sys-mon.js +101 -0
  3. package/lib/conf/config-default.js +10 -3
  4. package/lib/conf/configure.js +369 -349
  5. package/lib/conf/license.js +1 -1
  6. package/lib/control/cmd-config.js +24 -0
  7. package/lib/control/control-handler.js +367 -0
  8. package/lib/control/packagectr-helper.js +34 -3
  9. package/lib/core/agent.js +176 -882
  10. package/lib/core/interceptor.js +6 -6
  11. package/lib/core/request-agent.js +27 -0
  12. package/lib/core/shimmer.js +82 -36
  13. package/lib/counter/counter-manager.js +79 -8
  14. package/lib/counter/meter/meter-activex.js +67 -0
  15. package/lib/counter/meter/meter-httpc.js +57 -0
  16. package/lib/counter/meter/meter-resource.js +9 -0
  17. package/lib/counter/meter/meter-service.js +168 -0
  18. package/lib/counter/meter/meter-socket.io.js +51 -0
  19. package/lib/counter/meter/meter-sql.js +71 -0
  20. package/lib/counter/meter/meter-users.js +58 -0
  21. package/lib/counter/meter.js +183 -0
  22. package/lib/counter/task/activetransaction.js +68 -17
  23. package/lib/counter/task/agentinfo.js +107 -0
  24. package/lib/{system → counter/task}/gc-action.js +27 -74
  25. package/lib/counter/task/gcstat.js +34 -0
  26. package/lib/counter/task/heapmem.js +25 -0
  27. package/lib/counter/task/httpc.js +76 -0
  28. package/lib/counter/task/metering-info.js +125 -0
  29. package/lib/counter/task/proc-cpu.js +29 -0
  30. package/lib/counter/task/realtimeuser.js +31 -0
  31. package/lib/counter/task/res/systemECSTask.js +39 -0
  32. package/lib/counter/task/res/systemKubeTask.js +53 -0
  33. package/lib/counter/task/res/util/awsEcsClientThread.js +218 -0
  34. package/lib/counter/task/res/util/linuxProcStatUtil.js +14 -0
  35. package/lib/counter/task/res-sys-cpu.js +62 -0
  36. package/lib/counter/task/service.js +202 -0
  37. package/lib/counter/task/socketio.js +30 -0
  38. package/lib/counter/task/sql.js +105 -0
  39. package/lib/counter/task/systemperf.js +43 -0
  40. package/lib/data/datapack-sender.js +289 -0
  41. package/lib/data/dataprofile-agent.js +162 -0
  42. package/lib/data/datatext-agent.js +135 -0
  43. package/lib/data/event-level.js +15 -0
  44. package/lib/data/test.js +49 -0
  45. package/lib/data/zipprofile.js +197 -0
  46. package/lib/env/constants.js +21 -0
  47. package/lib/error/error-handler.js +437 -0
  48. package/lib/io/data-inputx.js +13 -3
  49. package/lib/io/data-outputx.js +268 -206
  50. package/lib/kube/kube-client.js +144 -0
  51. package/lib/lang/text-types.js +58 -0
  52. package/lib/logger.js +6 -6
  53. package/lib/logsink/line-log-util.js +87 -0
  54. package/lib/logsink/line-log.js +12 -0
  55. package/lib/logsink/log-sender.js +78 -0
  56. package/lib/logsink/log-tracer.js +40 -0
  57. package/lib/logsink/sender-util.js +56 -0
  58. package/lib/logsink/zip/zip-send.js +177 -0
  59. package/lib/net/netflag.js +55 -0
  60. package/lib/net/receiver.js +66 -0
  61. package/lib/net/security-master.js +139 -20
  62. package/lib/net/sender.js +141 -0
  63. package/lib/net/tcp-return.js +18 -0
  64. package/lib/net/tcp-session.js +286 -0
  65. package/lib/net/tcpreq-client-proxy.js +70 -0
  66. package/lib/net/tcprequest-mgr.js +58 -0
  67. package/lib/observers/apollo-server-observer.js +33 -27
  68. package/lib/observers/cluster-observer.js +22 -0
  69. package/lib/observers/express-observer.js +215 -0
  70. package/lib/observers/file-observer.js +184 -0
  71. package/lib/observers/global-observer.js +155 -80
  72. package/lib/observers/grpc-observer.js +336 -0
  73. package/lib/observers/http-observer.js +666 -236
  74. package/lib/observers/maria-observer.js +204 -362
  75. package/lib/observers/memcached-observer.js +56 -0
  76. package/lib/observers/mongo-observer.js +317 -0
  77. package/lib/observers/mongodb-observer.js +169 -226
  78. package/lib/observers/mongoose-observer.js +518 -323
  79. package/lib/observers/mssql-observer.js +177 -418
  80. package/lib/observers/mysql-observer.js +342 -449
  81. package/lib/observers/mysql2-observer.js +396 -358
  82. package/lib/observers/net-observer.js +77 -0
  83. package/lib/observers/oracle-observer.js +559 -384
  84. package/lib/observers/pgsql-observer.js +231 -489
  85. package/lib/observers/prisma-observer.js +303 -92
  86. package/lib/observers/process-observer.js +79 -35
  87. package/lib/observers/promise-observer.js +31 -0
  88. package/lib/observers/redis-observer.js +166 -331
  89. package/lib/observers/schedule-observer.js +67 -0
  90. package/lib/observers/socket.io-observer.js +226 -187
  91. package/lib/observers/stream-observer.js +19 -0
  92. package/lib/observers/thrift-observer.js +197 -0
  93. package/lib/observers/websocket-observer.js +175 -301
  94. package/lib/pack/activestack-pack.js +55 -0
  95. package/lib/pack/apenum.js +8 -0
  96. package/lib/pack/counter-pack.js +3 -0
  97. package/lib/pack/errorsnap-pack.js +69 -0
  98. package/lib/pack/event-pack.js +54 -0
  99. package/lib/pack/hitmap-pack.js +63 -0
  100. package/lib/pack/hitmap-pack1.js +152 -0
  101. package/lib/pack/log-sink-pack.js +14 -52
  102. package/lib/pack/netstat.js +15 -0
  103. package/lib/pack/otype.js +7 -0
  104. package/lib/pack/profile-pack.js +49 -0
  105. package/lib/pack/realtimeuser-pack.js +41 -0
  106. package/lib/pack/stat-general-pack.js +96 -0
  107. package/lib/pack/staterror-pack.js +120 -0
  108. package/lib/pack/stathttpc-pack.js +66 -0
  109. package/lib/pack/stathttpc-rec.js +78 -0
  110. package/lib/pack/statremote-pack.js +46 -0
  111. package/lib/pack/statservice-pack.js +63 -0
  112. package/lib/pack/statservice-pack1.js +88 -0
  113. package/lib/pack/statservice-rec.js +292 -0
  114. package/lib/pack/statservice-rec_dep.js +151 -0
  115. package/lib/pack/statsql-pack.js +69 -0
  116. package/lib/pack/statsql-rec.js +100 -0
  117. package/lib/pack/statuseragent-pack.js +44 -0
  118. package/lib/pack/tagcount-pack.js +4 -4
  119. package/lib/pack/tagctr.js +15 -0
  120. package/lib/pack/text-pack.js +50 -0
  121. package/lib/pack/time-count.js +25 -0
  122. package/lib/pack/websocket.js +15 -0
  123. package/lib/pack/zip-pack.js +70 -0
  124. package/lib/pii/pii-item.js +31 -0
  125. package/lib/pii/pii-mask.js +174 -0
  126. package/lib/plugin/plugin-loadermanager.js +57 -0
  127. package/lib/plugin/plugin.js +75 -0
  128. package/lib/service/tx-record.js +332 -0
  129. package/lib/stat/stat-error.js +116 -0
  130. package/lib/stat/stat-httpc.js +98 -0
  131. package/lib/stat/stat-remote-ip.js +46 -0
  132. package/lib/stat/stat-remote-ipurl.js +88 -0
  133. package/lib/stat/stat-sql.js +113 -0
  134. package/lib/stat/stat-tranx.js +58 -0
  135. package/lib/stat/stat-tx-caller.js +160 -0
  136. package/lib/stat/stat-tx-domain.js +111 -0
  137. package/lib/stat/stat-tx-referer.js +112 -0
  138. package/lib/stat/stat-useragent.js +48 -0
  139. package/lib/stat/timingsender.js +76 -0
  140. package/lib/step/activestack-step.js +38 -0
  141. package/lib/step/dbc-step.js +36 -0
  142. package/lib/step/http-stepx.js +67 -0
  143. package/lib/step/message-step.js +40 -0
  144. package/lib/step/method-stepx.js +45 -0
  145. package/lib/step/resultset-step.js +40 -0
  146. package/lib/step/securemsg-step.js +44 -0
  147. package/lib/step/socket-step.js +46 -0
  148. package/lib/step/sql-stepx.js +68 -0
  149. package/lib/step/sqlxtype.js +16 -0
  150. package/lib/step/step.js +66 -0
  151. package/lib/step/stepenum.js +54 -0
  152. package/lib/topology/link.js +63 -0
  153. package/lib/topology/nodeinfo.js +123 -0
  154. package/lib/topology/status-detector.js +111 -0
  155. package/lib/trace/trace-context-manager.js +113 -25
  156. package/lib/trace/trace-context.js +21 -7
  157. package/lib/trace/trace-httpc.js +17 -11
  158. package/lib/trace/trace-sql.js +29 -21
  159. package/lib/util/anylist.js +103 -0
  160. package/lib/util/cardinality/hyperloglog.js +106 -0
  161. package/lib/util/cardinality/murmurhash.js +31 -0
  162. package/lib/util/cardinality/registerset.js +75 -0
  163. package/lib/util/errordata.js +21 -0
  164. package/lib/util/escape-literal-sql.js +5 -5
  165. package/lib/util/hashutil.js +18 -18
  166. package/lib/util/iputil_x.js +527 -0
  167. package/lib/util/keygen.js +0 -3
  168. package/lib/util/kube-util.js +73 -0
  169. package/lib/util/linkedset.js +1 -2
  170. package/lib/util/nodeutil.js +2 -1
  171. package/lib/util/paramsecurity.js +80 -0
  172. package/lib/util/pre-process.js +13 -0
  173. package/lib/util/process-seq.js +166 -0
  174. package/lib/util/property-util.js +36 -0
  175. package/lib/util/request-queue.js +70 -0
  176. package/lib/util/requestdouble-queue.js +72 -0
  177. package/lib/util/resourceprofile.js +157 -0
  178. package/lib/util/stop-watch.js +30 -0
  179. package/lib/util/system-util.js +10 -0
  180. package/lib/util/userid-util.js +57 -0
  181. package/lib/value/map-value.js +3 -2
  182. package/package.json +9 -4
  183. package/whatap.conf +1 -4
  184. package/agent/darwin/arm64/whatap_nodejs +0 -0
  185. package/agent/linux/amd64/whatap_nodejs +0 -0
  186. package/agent/linux/arm64/whatap_nodejs +0 -0
  187. package/build.txt +0 -4
  188. package/lib/observers/ioredis-observer.js +0 -294
  189. package/lib/udp/async_sender.js +0 -119
  190. package/lib/udp/index.js +0 -17
  191. package/lib/udp/packet_enum.js +0 -52
  192. package/lib/udp/packet_queue.js +0 -69
  193. package/lib/udp/packet_type_enum.js +0 -33
  194. package/lib/udp/param_def.js +0 -72
  195. package/lib/udp/udp_session.js +0 -336
  196. package/lib/util/sql-util.js +0 -178
  197. package/lib/util/trace-helper.js +0 -91
  198. package/lib/util/transfer.js +0 -58
@@ -0,0 +1,103 @@
1
+ var INT = 1;
2
+ var LONG = 2;
3
+ var FLOAT = 3;
4
+ var DOUBLE = 4;
5
+ var STRING = 5;
6
+
7
+ AnyList.INT = 1;
8
+ AnyList.LONG = 2;
9
+ AnyList.FLOAT = 3;
10
+ AnyList.DOUBLE = 4;
11
+ AnyList.STRING = 5;
12
+
13
+ function AnyList(type, len){
14
+ this.type=type;
15
+ this.data = new Array(len);
16
+ }
17
+ AnyList.prototype.getType=function(){
18
+ return this.type;
19
+ };
20
+ AnyList.prototype.put=function(idx, d){
21
+ this.data[idx]=d;
22
+ };
23
+
24
+ AnyList.prototype.get=function(idx){
25
+ return this.data[idx];
26
+ };
27
+ AnyList.prototype.size = function () {
28
+ return this.data ? this.data.length : 0;
29
+ };
30
+ AnyList.prototype.write=function(o){
31
+ switch(this.type){
32
+ case INT: this.writeDecimal(o); return this;
33
+ case LONG: this.writeDecimal(o); return this;
34
+ case FLOAT: this.writeFloat(o); return this;
35
+ case DOUBLE: this.writeDouble(o); return this;
36
+ case STRING: this.writeString(o); return this;
37
+ }
38
+ };
39
+ AnyList.prototype.read=function(i){
40
+ switch(this.type){
41
+ case INT: this.readDecimal(i); return this;
42
+ case LONG: this.readDecimal(i); return this;
43
+ case FLOAT: this.readFloat(i); return this;
44
+ case DOUBLE: this.readDouble(i); return this;
45
+ case STRING: this.readString(i); return this;
46
+ }
47
+ };
48
+
49
+ AnyList.prototype.writeDouble = function (dout) {
50
+ var len =this.size();
51
+ dout.writeInt24BE(len);
52
+ for (var i = 0; i < len; i++) {
53
+ dout.writeDouble(this.get(i));
54
+ }
55
+ };
56
+ AnyList.prototype.readDouble=function(din) {
57
+ var count = din.readInt24BE();
58
+ for (var i = 0; i < count; i++) {
59
+ this.add(din.readDouble());
60
+ }
61
+ };
62
+ AnyList.prototype.writeFloat = function (dout) {
63
+ var len =this.size();
64
+ dout.writeInt24BE(len);
65
+ for (var i = 0; i < len; i++) {
66
+ dout.writeFloat(this.get(i));
67
+ }
68
+ };
69
+ AnyList.prototype.readFloat=function(din) {
70
+ var count = din.readInt24BE();
71
+ for (var i = 0; i < count; i++) {
72
+ this.add(din.readFloat());
73
+ }
74
+ };
75
+
76
+ AnyList.prototype.writeDecimal = function (dout) {
77
+ var len =this.size();
78
+ dout.writeInt24BE(len);
79
+ for (var i = 0; i < len; i++) {
80
+ dout.writeDecimal(this.get(i));
81
+ }
82
+ };
83
+ AnyList.prototype.readDecimal=function(din) {
84
+ var count = din.readInt24BE();
85
+ for (var i = 0; i < count; i++) {
86
+ this.add(din.readDecNumber());
87
+ }
88
+ };
89
+ AnyList.prototype.writeString = function (dout) {
90
+ var len =this.size();
91
+ dout.writeInt24BE(len);
92
+ for (var i = 0; i < len; i++) {
93
+ dout.writeText(this.get(i));
94
+ }
95
+ };
96
+ AnyList.prototype.readString=function(din) {
97
+ var count = din.readInt24BE();
98
+ for (var i = 0; i < count; i++) {
99
+ this.add(din.readText());
100
+ }
101
+ };
102
+
103
+ module.exports = AnyList;
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var RegisterSet = require('./registerset'),
8
+ MurmurHash = require('./murmurhash'),
9
+ DataOutpuxX = require('../../io/data-outputx'),
10
+ Long = require('long');
11
+
12
+
13
+ function HyperLogLog() {
14
+ this.log2m = 10;
15
+ this.registerSet = new RegisterSet(1 << this.log2m);
16
+ var m = 1 << this.log2m;
17
+ this.alphaMM = getAlphaMM(this.log2m, m);
18
+ }
19
+
20
+ HyperLogLog.prototype.offerHashed = function (hashedValue) {
21
+ var j = hashedValue >>> (32 - this.log2m);
22
+ var r = numberOfLeadingZeros((hashedValue << this.log2m) | (1 << (this.log2m - 1)) + 1) + 1;
23
+ return this.registerSet.updateIfGreater(j, r);
24
+ };
25
+ HyperLogLog.prototype.offer = function (o) {
26
+ var val;
27
+ if(o instanceof Long) {
28
+ val = o;
29
+ } else if(typeof o === 'string') {
30
+ val = Long.fromString(o);
31
+ } else if(typeof o === 'number') {
32
+ val = Long.fromNumber(o);
33
+ }
34
+ var x = MurmurHash.hashLong(val);
35
+ return this.offerHashed(x);
36
+ };
37
+ HyperLogLog.prototype.cardinality = function () {
38
+ var registerSum = 0;
39
+ var count = this.registerSet.count;
40
+ var zeros = 0.0;
41
+ for(var j=0; j<this.registerSet.count; j++) {
42
+ var val = this.registerSet.get(j);
43
+ registerSum += 1.0 / (1 << val);
44
+ if(parseFloat(val) === 0.0) {
45
+ zeros++;
46
+ }
47
+ }
48
+ var estimate = this.alphaMM * (1 / registerSum);
49
+ if(estimate <= (5.0 / 2.0) * count) {
50
+ return Math.round(linearCounting(count, zeros));
51
+ } else {
52
+ return Math.round(estimate);
53
+ }
54
+ };
55
+ HyperLogLog.prototype.getBytes = function () {
56
+ var dout = new DataOutpuxX();
57
+ dout.writeInt(this.log2m);
58
+ dout.writeInt(this.registerSet.size);
59
+ var M = this.registerSet.readOnlyBits();
60
+ for(var i=0; i<M.length; i++) {
61
+ dout.writeInt(M[i]);
62
+ }
63
+ return dout.toByteArray();
64
+ };
65
+
66
+ var getAlphaMM = function (p, m) {
67
+ switch (p) {
68
+ case 4:
69
+ return 0.673 * m * m;
70
+ case 5:
71
+ return 0.697 * m * m;
72
+ case 6:
73
+ return 0.709 * m * m;
74
+ default:
75
+ return (0.7213 / (1 + 1.079 / m)) * m * m;
76
+ }
77
+ };
78
+ var linearCounting = function (m, V) {
79
+ return m * Math.log(m / V);
80
+ };
81
+ var numberOfLeadingZeros = function (i) {
82
+ if (i === 0)
83
+ return 32;
84
+ var n = 1;
85
+
86
+ if (i >>> 16 === 0) {
87
+ n += 16;
88
+ i <<= 16;
89
+ }
90
+ if (i >>> 24 === 0) {
91
+ n += 8;
92
+ i <<= 8;
93
+ }
94
+ if (i >>> 28 === 0) {
95
+ n += 4;
96
+ i <<= 4;
97
+ }
98
+ if (i >>> 30 === 0) {
99
+ n += 2;
100
+ i <<= 2;
101
+ }
102
+ n -= i >>> 31;
103
+ return n;
104
+ }
105
+
106
+ module.exports = HyperLogLog;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var Long = require('long');
8
+
9
+ function hash(data) {
10
+ var m = 0x5bd1e995;
11
+ var r = 24;
12
+ var h = 0;
13
+ var k = data.mul(m);
14
+ k = k.getLowBits();
15
+ k ^= k >>> r;
16
+ h ^= Long.fromNumber(k).mul(m).getLowBits();
17
+ k = Long.fromNumber(data.getHighBits()).mul(m).getLowBits();
18
+ k ^= k >>> r;
19
+ h = Long.fromNumber(h).mul(m).getLowBits();
20
+ h ^= Long.fromNumber(k).mul(m).getLowBits();
21
+ h ^= h >>> 13;
22
+ h = Long.fromNumber(h).mul(m).getLowBits();
23
+ h ^= h >>> 15;
24
+ return h;
25
+ };
26
+
27
+ var MurMurHash = {
28
+ hashLong : hash
29
+ };
30
+
31
+ module.exports = MurMurHash;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ const LOG2_BITS_PER_WORD = 6;
8
+ const REGISTER_SIZE = 5;
9
+
10
+ var Long = require('long');
11
+
12
+ function RegisterSet(count) {
13
+ this.count = count;
14
+ this.M = new Array(getSizeForCount(this.count));
15
+ this.size = this.M.length;
16
+ }
17
+
18
+ RegisterSet.prototype.set = function (position, value) {
19
+ var bucketPos = parseInt(position / LOG2_BITS_PER_WORD);
20
+ var shift = REGISTER_SIZE * (position - (bucketPos * LOG2_BITS_PER_WORD));
21
+ this.M[bucketPos] = (this.M[bucketPos] & ~(0x1f << shift) | (value << shift));
22
+ };
23
+ RegisterSet.prototype.get = function (position) {
24
+ var bucketPos = parseInt(position / LOG2_BITS_PER_WORD);
25
+ var shift = REGISTER_SIZE * (position - (bucketPos * LOG2_BITS_PER_WORD));
26
+ return (this.M[bucketPos] & (0x1f << shift)) >>> shift;
27
+ };
28
+ RegisterSet.prototype.updateIfGreater = function (position, value) {
29
+ var bucket = parseInt(position / LOG2_BITS_PER_WORD);
30
+ var shift = REGISTER_SIZE * (position - (bucket * LOG2_BITS_PER_WORD));
31
+ var mask = 0x1f << shift;
32
+
33
+ var curVal = Long.fromNumber(this.M[bucket]).and(mask);
34
+ var newVal = Long.fromNumber(value).shiftLeft(shift);
35
+
36
+ if(newVal.greaterThan(curVal)) {
37
+ var tmp = Long.fromNumber(this.M[bucket]).and(~mask).or(newVal);
38
+ this.M[bucket] = tmp.getLowBits();
39
+ return true;
40
+ } else {
41
+ return false;
42
+ }
43
+ };
44
+ RegisterSet.prototype.merge = function (that) {
45
+
46
+ for(var bucket = 0; bucket < this.M.length; bucket++) {
47
+ var word = 0;
48
+ for(var j=0; j<LOG2_BITS_PER_WORD; j++) {
49
+ var mask = 0x1f << (REGISTER_SIZE * j);
50
+ var thisVal = (this.M[bucket] & mask);
51
+ var thatVal = (that.M[bucket] & mask);
52
+ word |= (thisVal < thatVal) ? thatVal : thisVal;
53
+ }
54
+ this.M[bucket] = word;
55
+ }
56
+ };
57
+ RegisterSet.prototype.readOnlyBits = function () {
58
+ return this.M;
59
+ };
60
+
61
+ function getSizeForCount(count) {
62
+ var bits = getBits(count);
63
+ if(bits === 0) {
64
+ return 1;
65
+ } else if(bits % 32 === 0) {
66
+ return bits;
67
+ } else {
68
+ return bits + 1;
69
+ }
70
+ }
71
+ function getBits(count) {
72
+ return parseInt(count / LOG2_BITS_PER_WORD);
73
+ }
74
+
75
+ module.exports = RegisterSet;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright 2016 the WHATAP project authors. All rights reserved.
3
+ * Use of this source code is governed by a license that
4
+ * can be found in the LICENSE file.
5
+ */
6
+
7
+ var Step = require('../step/step');
8
+
9
+ function ErrorData(error, dbc, service, profile, isStackTrace) {
10
+ this.error = error || {};
11
+ this.dbc = dbc || 0;
12
+ this.service = service || 0;
13
+ this.profile = profile || new Step();
14
+ this.isStackTrace = isStackTrace || null;
15
+ }
16
+
17
+ ErrorData.prototype.toString = function() {
18
+ return "LeakData [error=" + this.error + ", dbc=" + this.dbc + ", service=" + this.service + ", profile=" + this.profile + "]";
19
+ };
20
+
21
+ module.exports = ErrorData;
@@ -173,10 +173,10 @@ EscapeLiteralSQL.prototype._quotation = function () {
173
173
  break;
174
174
  case STAT.ALPHABET:
175
175
  this.parsedSql += this.chars[this.pos];
176
- status = STAT.QUOTATION;
176
+ this.status = STAT.QUOTATION;
177
177
  break;
178
178
  case STAT.NUMBER:
179
- parsedSql += this.chars[this.pos];
179
+ this.parsedSql += this.chars[this.pos];
180
180
  this.status = STAT.QUOTATION;
181
181
  break;
182
182
  case STAT.QUOTATION:
@@ -194,16 +194,16 @@ EscapeLiteralSQL.prototype._dquotation = function () {
194
194
  }
195
195
  this.param += this.chars[this.pos];
196
196
  this.status = STAT.DQUOTATION;
197
- break;;
197
+ break;
198
198
  case STAT.COMMENT:
199
199
  this.parsedSql += this.chars[this.pos];
200
200
  break;
201
201
  case STAT.ALPHABET:
202
202
  this.parsedSql += this.chars[this.pos];
203
- status = STAT.DQUOTATION;
203
+ this.status = STAT.DQUOTATION;
204
204
  break;
205
205
  case STAT.NUMBER:
206
- parsedSql += this.chars[this.pos];
206
+ this.parsedSql += this.chars[this.pos];
207
207
  this.status = STAT.DQUOTATION;
208
208
  break;
209
209
  case STAT.DQUOTATION:
@@ -5,9 +5,9 @@
5
5
  */
6
6
 
7
7
 
8
- var Buffer = require('buffer').Buffer;
8
+ var Buffer = require('buffer').Buffer;
9
9
 
10
- const CRC_TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
10
+ const CRC_TABLE = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
11
11
  0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e,
12
12
  0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064,
13
13
  0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551,
@@ -49,10 +49,10 @@ const CRC_TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
49
49
  0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f,
50
50
  0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
51
51
  0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02,
52
- 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d];
52
+ 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d ];
53
53
 
54
- for (var i = 0; i < CRC_TABLE.length; i++) {
55
- CRC_TABLE[i] = hexToInt(CRC_TABLE[i].toString(16));
54
+ for(var i = 0 ; i < CRC_TABLE.length; i ++){
55
+ CRC_TABLE[i] = hexToInt( CRC_TABLE[i].toString(16) );
56
56
  }
57
57
 
58
58
  function hexToInt(hex) {
@@ -68,35 +68,35 @@ function hexToInt(hex) {
68
68
  }
69
69
 
70
70
  var hashUtil = {
71
- crc32: function (str) {
71
+ crc32 : function(str) {
72
72
  var buf = Buffer.alloc(str.length);
73
73
  buf.write(str, 'utf-8');
74
74
  var crc = 0;
75
75
  crc = crc ^ (-1);
76
- for (var n = 0; n < buf.length; n++) {
76
+ for ( var n = 0; n < buf.length; n++) {
77
77
  crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8);
78
78
  }
79
79
  return crc ^ (-1);
80
80
  },
81
- toStr: function (n, def) {
82
- if (n) {
81
+ toStr: function(n,def){
82
+ if(n){
83
83
  return n.toString();
84
84
  }
85
- return def ? def : '';
85
+ return def? def:'';
86
86
  },
87
- hashFromString: function (str) {
88
- if (str) {
89
- return this.hash(Buffer.from(str));
90
- } else {
91
- return 0;
87
+ hashFromString: function(str){
88
+ if(str){
89
+ return this.hash(Buffer.from(str));
90
+ }else{
91
+ return 0;
92
92
  }
93
93
  },
94
- hash: function (bytes /* bytes[] */) {
94
+ hash: function(bytes /* bytes[] */){
95
95
  var crc = -1;
96
96
  var var2 = bytes;
97
97
  var var3 = bytes.length;
98
98
 
99
- for (var var4 = 0; var4 < var3; ++var4) {
99
+ for(var var4 = 0 ; var4 < var3; ++var4){
100
100
  var b = var2[var4];
101
101
  crc = crc >>> 8 ^ CRC_TABLE[(crc ^ b) & 255];
102
102
  }
@@ -104,7 +104,7 @@ var hashUtil = {
104
104
  crc = crc ^ 0xffffffff;
105
105
  return crc;
106
106
  },
107
- toInt: function (buf /* buf[] */) {
107
+ toInt: function(buf /* buf[] */){
108
108
  var ch1 = buf[0] & 255;
109
109
  var ch2 = buf[1] & 255;
110
110
  var ch3 = buf[2] & 255;