tedious 1.12.3 → 1.14.0
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.
- package/README.md +1 -1
- package/appveyor.yml +9 -5
- package/benchmarks/README.md +33 -0
- package/benchmarks/common.js +82 -0
- package/benchmarks/index.js +34 -0
- package/benchmarks/query/many-result-rows.js +49 -0
- package/benchmarks/query/nvarchar-large.js +44 -0
- package/benchmarks/query/nvarchar-small.js +44 -0
- package/benchmarks/query/varbinary-4.js +42 -0
- package/benchmarks/query/varbinary-huge.js +46 -0
- package/benchmarks/query/varbinary-large.js +46 -0
- package/benchmarks/query/varbinary-small.js +42 -0
- package/benchmarks/token-parser/colmetadata-token.js +42 -0
- package/benchmarks/token-parser/done-token.js +42 -0
- package/benchmarks/token-parser/simple-tokens.js +366 -0
- package/lib/all-headers.js +9 -11
- package/lib/buffertools.js +17 -13
- package/lib/bulk-load.js +196 -169
- package/lib/collation.js +80 -2
- package/lib/connection.js +1086 -1060
- package/lib/data-type.js +450 -253
- package/lib/debug.js +57 -51
- package/lib/errors.js +40 -55
- package/lib/guid-parser.js +12 -36
- package/lib/instance-lookup.js +57 -54
- package/lib/library.js +3 -2
- package/lib/login7-payload.js +187 -180
- package/lib/message-io.js +169 -199
- package/lib/metadata-parser.js +169 -255
- package/lib/ntlm-payload.js +173 -160
- package/lib/packet.js +166 -152
- package/lib/prelogin-payload.js +170 -160
- package/lib/request.js +122 -122
- package/lib/rpcrequest-payload.js +64 -38
- package/lib/special-stored-procedure.js +3 -2
- package/lib/sqlbatch-payload.js +20 -16
- package/lib/stream-parser.js +116 -104
- package/lib/tds-versions.js +5 -8
- package/lib/tedious.js +8 -14
- package/lib/token/colmetadata-token-parser.js +79 -125
- package/lib/token/done-token-parser.js +47 -129
- package/lib/token/env-change-token-parser.js +90 -126
- package/lib/token/infoerror-token-parser.js +47 -125
- package/lib/token/loginack-token-parser.js +36 -74
- package/lib/token/nbcrow-token-parser.js +40 -64
- package/lib/token/order-token-parser.js +26 -43
- package/lib/token/returnstatus-token-parser.js +11 -23
- package/lib/token/returnvalue-token-parser.js +31 -54
- package/lib/token/row-token-parser.js +39 -52
- package/lib/token/sspi-token-parser.js +14 -32
- package/lib/token/stream-parser.js +424 -304
- package/lib/token/token-stream-parser.js +39 -34
- package/lib/token/token.js +3 -6
- package/lib/tracking-buffer/bigint.js +45 -48
- package/lib/tracking-buffer/readable-tracking-buffer.js +238 -223
- package/lib/tracking-buffer/tracking-buffer.js +3 -9
- package/lib/tracking-buffer/writable-tracking-buffer.js +272 -244
- package/lib/transaction.js +112 -102
- package/lib/value-parser.js +559 -1154
- package/package.json +10 -9
- package/benchmarks/benchmarks.coffee +0 -122
- package/benchmarks/query.coffee +0 -57
package/lib/value-parser.js
CHANGED
|
@@ -1,1217 +1,622 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var iconv = require('iconv-lite');
|
|
4
|
+
var sprintf = require('sprintf').sprintf;
|
|
5
|
+
var TYPE = require('./data-type').TYPE;
|
|
6
|
+
var guidParser = require('./guid-parser');
|
|
7
|
+
|
|
8
|
+
var readPrecision = require('./metadata-parser').readPrecision;
|
|
9
|
+
var readScale = require('./metadata-parser').readScale;
|
|
10
|
+
var readCollation = require('./metadata-parser').readCollation;
|
|
11
|
+
var convertLEBytesToString = require('./tracking-buffer/bigint').convertLEBytesToString;
|
|
12
|
+
|
|
13
|
+
var NULL = (1 << 16) - 1;
|
|
14
|
+
var MAX = (1 << 16) - 1;
|
|
15
|
+
var THREE_AND_A_THIRD = 3 + 1 / 3;
|
|
16
|
+
var MONEY_DIVISOR = 10000;
|
|
17
|
+
var PLP_NULL = new Buffer([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]);
|
|
18
|
+
var UNKNOWN_PLP_LEN = new Buffer([0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]);
|
|
19
|
+
var DEFAULT_ENCODING = 'utf8';
|
|
20
|
+
|
|
21
|
+
function readTextPointerNull(parser, type, callback) {
|
|
22
|
+
if (type.hasTextPointerAndTimestamp) {
|
|
23
|
+
parser.readUInt8(function (textPointerLength) {
|
|
24
|
+
if (textPointerLength !== 0) {
|
|
25
|
+
// Appear to be dummy values, so consume and discard them.
|
|
26
|
+
parser.readBuffer(textPointerLength, function () {
|
|
27
|
+
parser.readBuffer(8, function () {
|
|
28
|
+
callback(undefined);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
callback(true);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
callback(undefined);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function readDataLength(parser, type, metaData, textPointerNull, callback) {
|
|
41
|
+
if (textPointerNull) {
|
|
42
|
+
return callback(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (metaData.isVariantValue) {
|
|
46
|
+
return callback(metaData.dataLength);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// s2.2.4.2.1
|
|
50
|
+
switch (type.id & 0x30) {
|
|
51
|
+
case 0x10:
|
|
52
|
+
// xx01xxxx - s2.2.4.2.1.1
|
|
53
|
+
return callback(0);
|
|
54
|
+
|
|
55
|
+
case 0x20:
|
|
56
|
+
// xx10xxxx - s2.2.4.2.1.3
|
|
57
|
+
// Variable length
|
|
58
|
+
if (metaData.dataLength !== MAX) {
|
|
59
|
+
switch (type.dataLengthLength) {
|
|
60
|
+
case 0:
|
|
61
|
+
return callback(undefined);
|
|
62
|
+
|
|
63
|
+
case 1:
|
|
64
|
+
return parser.readUInt8(callback);
|
|
65
|
+
|
|
66
|
+
case 2:
|
|
67
|
+
return parser.readUInt16LE(callback);
|
|
68
|
+
|
|
69
|
+
case 4:
|
|
70
|
+
return parser.readUInt32LE(callback);
|
|
71
|
+
|
|
72
|
+
default:
|
|
73
|
+
return parser.emit('error', new Error('Unsupported dataLengthLength ' + type.dataLengthLength + ' for data type ' + type.name));
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
return callback(undefined);
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
case 0x30:
|
|
81
|
+
return callback(1 << ((type.id & 0x0C) >> 2));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = valueParse;
|
|
86
|
+
function valueParse(parser, metaData, options, callback) {
|
|
87
|
+
var type = metaData.type;
|
|
88
|
+
|
|
89
|
+
readTextPointerNull(parser, type, function (textPointerNull) {
|
|
90
|
+
readDataLength(parser, type, metaData, textPointerNull, function (dataLength) {
|
|
91
|
+
switch (type.name) {
|
|
92
|
+
case 'Null':
|
|
93
|
+
return callback(null);
|
|
94
|
+
|
|
95
|
+
case 'TinyInt':
|
|
96
|
+
return parser.readUInt8(callback);
|
|
97
|
+
|
|
98
|
+
case 'Int':
|
|
99
|
+
return parser.readInt32LE(callback);
|
|
100
|
+
|
|
101
|
+
case 'SmallInt':
|
|
102
|
+
return parser.readInt16LE(callback);
|
|
103
|
+
|
|
104
|
+
case 'BigInt':
|
|
105
|
+
return parser.readBuffer(8, function (buffer) {
|
|
106
|
+
callback(convertLEBytesToString(buffer));
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
case 'IntN':
|
|
110
|
+
switch (dataLength) {
|
|
111
|
+
case 0:
|
|
112
|
+
return callback(null);
|
|
113
|
+
case 1:
|
|
114
|
+
return parser.readUInt8(callback);
|
|
115
|
+
case 2:
|
|
116
|
+
return parser.readInt16LE(callback);
|
|
117
|
+
case 4:
|
|
118
|
+
return parser.readInt32LE(callback);
|
|
119
|
+
case 8:
|
|
120
|
+
return parser.readBuffer(8, function (buffer) {
|
|
121
|
+
callback(convertLEBytesToString(buffer));
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
default:
|
|
125
|
+
return parser.emit('error', new Error('Unsupported dataLength ' + dataLength + ' for IntN'));
|
|
126
|
+
}
|
|
51
127
|
break;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
context$1$0.next = 11;
|
|
55
|
-
return parser.readBuffer(textPointerLength);
|
|
56
|
-
|
|
57
|
-
case 11:
|
|
58
|
-
context$1$0.next = 13;
|
|
59
|
-
return parser.readBuffer(8);
|
|
60
128
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
break;
|
|
64
|
-
|
|
65
|
-
case 15:
|
|
66
|
-
dataLength = 0;
|
|
67
|
-
textPointerNull = true;
|
|
68
|
-
|
|
69
|
-
case 17:
|
|
70
|
-
if (!(!dataLength && dataLength !== 0)) {
|
|
71
|
-
context$1$0.next = 44;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
129
|
+
case 'Real':
|
|
130
|
+
return parser.readFloatLE(callback);
|
|
74
131
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
break;
|
|
132
|
+
case 'Float':
|
|
133
|
+
return parser.readDoubleLE(callback);
|
|
78
134
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
135
|
+
case 'FloatN':
|
|
136
|
+
switch (dataLength) {
|
|
137
|
+
case 0:
|
|
138
|
+
return callback(null);
|
|
139
|
+
case 4:
|
|
140
|
+
return parser.readFloatLE(callback);
|
|
141
|
+
case 8:
|
|
142
|
+
return parser.readDoubleLE(callback);
|
|
82
143
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
144
|
+
default:
|
|
145
|
+
return parser.emit('error', new Error('Unsupported dataLength ' + dataLength + ' for FloatN'));
|
|
146
|
+
}
|
|
86
147
|
break;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
context$1$0.t1 = type.dataLengthLength;
|
|
90
|
-
context$1$0.next = context$1$0.t1 === 0 ? 27 : context$1$0.t1 === 1 ? 29 : context$1$0.t1 === 2 ? 33 : context$1$0.t1 === 4 ? 37 : 41;
|
|
91
|
-
break;
|
|
92
|
-
|
|
93
|
-
case 27:
|
|
94
|
-
dataLength = void 0;
|
|
95
|
-
return context$1$0.abrupt('break', 42);
|
|
96
|
-
|
|
97
|
-
case 29:
|
|
98
|
-
context$1$0.next = 31;
|
|
99
|
-
return parser.readUInt8();
|
|
100
|
-
|
|
101
|
-
case 31:
|
|
102
|
-
dataLength = context$1$0.sent;
|
|
103
|
-
return context$1$0.abrupt('break', 42);
|
|
104
|
-
|
|
105
|
-
case 33:
|
|
106
|
-
context$1$0.next = 35;
|
|
107
|
-
return parser.readUInt16LE();
|
|
108
|
-
|
|
109
|
-
case 35:
|
|
110
|
-
dataLength = context$1$0.sent;
|
|
111
|
-
return context$1$0.abrupt('break', 42);
|
|
112
|
-
|
|
113
|
-
case 37:
|
|
114
|
-
context$1$0.next = 39;
|
|
115
|
-
return parser.readUInt32LE();
|
|
116
|
-
|
|
117
|
-
case 39:
|
|
118
|
-
dataLength = context$1$0.sent;
|
|
119
|
-
return context$1$0.abrupt('break', 42);
|
|
120
|
-
|
|
121
|
-
case 41:
|
|
122
|
-
throw Error("Unsupported dataLengthLength " + type.dataLengthLength + " for data type " + type.name);
|
|
123
|
-
|
|
124
|
-
case 42:
|
|
125
|
-
return context$1$0.abrupt('break', 44);
|
|
126
|
-
|
|
127
|
-
case 43:
|
|
128
|
-
dataLength = 1 << ((type.id & 0x0C) >> 2);
|
|
129
|
-
|
|
130
|
-
case 44:
|
|
131
|
-
context$1$0.t2 = type.name;
|
|
132
|
-
context$1$0.next = context$1$0.t2 === 'Null' ? 47 : context$1$0.t2 === 'TinyInt' ? 49 : context$1$0.t2 === 'Int' ? 53 : context$1$0.t2 === 'SmallInt' ? 57 : context$1$0.t2 === 'BigInt' ? 61 : context$1$0.t2 === 'IntN' ? 66 : context$1$0.t2 === 'Real' ? 90 : context$1$0.t2 === 'Float' ? 94 : context$1$0.t2 === 'FloatN' ? 98 : context$1$0.t2 === 'Money' ? 113 : context$1$0.t2 === 'SmallMoney' ? 113 : context$1$0.t2 === 'MoneyN' ? 113 : context$1$0.t2 === 'Bit' ? 135 : context$1$0.t2 === 'BitN' ? 139 : context$1$0.t2 === 'VarChar' ? 148 : context$1$0.t2 === 'Char' ? 148 : context$1$0.t2 === 'NVarChar' ? 157 : context$1$0.t2 === 'NChar' ? 157 : context$1$0.t2 === 'VarBinary' ? 165 : context$1$0.t2 === 'Binary' ? 165 : context$1$0.t2 === 'Text' ? 173 : context$1$0.t2 === 'NText' ? 180 : context$1$0.t2 === 'Image' ? 187 : context$1$0.t2 === 'Xml' ? 194 : context$1$0.t2 === 'SmallDateTime' ? 197 : context$1$0.t2 === 'DateTime' ? 200 : context$1$0.t2 === 'DateTimeN' ? 203 : context$1$0.t2 === 'TimeN' ? 214 : context$1$0.t2 === 'DateN' ? 224 : context$1$0.t2 === 'DateTime2N' ? 234 : context$1$0.t2 === 'DateTimeOffsetN' ? 244 : context$1$0.t2 === 'NumericN' ? 254 : context$1$0.t2 === 'DecimalN' ? 254 : context$1$0.t2 === 'UniqueIdentifierN' ? 288 : context$1$0.t2 === 'UDT' ? 302 : 305;
|
|
133
|
-
break;
|
|
134
|
-
|
|
135
|
-
case 47:
|
|
136
|
-
value = null;
|
|
137
|
-
return context$1$0.abrupt('break', 307);
|
|
138
|
-
|
|
139
|
-
case 49:
|
|
140
|
-
context$1$0.next = 51;
|
|
141
|
-
return parser.readUInt8();
|
|
142
|
-
|
|
143
|
-
case 51:
|
|
144
|
-
value = context$1$0.sent;
|
|
145
|
-
return context$1$0.abrupt('break', 307);
|
|
146
|
-
|
|
147
|
-
case 53:
|
|
148
|
-
context$1$0.next = 55;
|
|
149
|
-
return parser.readInt32LE();
|
|
150
|
-
|
|
151
|
-
case 55:
|
|
152
|
-
value = context$1$0.sent;
|
|
153
|
-
return context$1$0.abrupt('break', 307);
|
|
154
|
-
|
|
155
|
-
case 57:
|
|
156
|
-
context$1$0.next = 59;
|
|
157
|
-
return parser.readInt16LE();
|
|
158
|
-
|
|
159
|
-
case 59:
|
|
160
|
-
value = context$1$0.sent;
|
|
161
|
-
return context$1$0.abrupt('break', 307);
|
|
162
|
-
|
|
163
|
-
case 61:
|
|
164
|
-
context$1$0.next = 63;
|
|
165
|
-
return parser.readBuffer(8);
|
|
166
|
-
|
|
167
|
-
case 63:
|
|
168
|
-
context$1$0.t3 = context$1$0.sent;
|
|
169
|
-
value = convertLEBytesToString(context$1$0.t3);
|
|
170
|
-
return context$1$0.abrupt('break', 307);
|
|
171
|
-
|
|
172
|
-
case 66:
|
|
173
|
-
context$1$0.t4 = dataLength;
|
|
174
|
-
context$1$0.next = context$1$0.t4 === 0 ? 69 : context$1$0.t4 === 1 ? 71 : context$1$0.t4 === 2 ? 75 : context$1$0.t4 === 4 ? 79 : context$1$0.t4 === 8 ? 83 : 88;
|
|
175
|
-
break;
|
|
176
|
-
|
|
177
|
-
case 69:
|
|
178
|
-
value = null;
|
|
179
|
-
return context$1$0.abrupt('break', 89);
|
|
180
|
-
|
|
181
|
-
case 71:
|
|
182
|
-
context$1$0.next = 73;
|
|
183
|
-
return parser.readUInt8();
|
|
184
|
-
|
|
185
|
-
case 73:
|
|
186
|
-
value = context$1$0.sent;
|
|
187
|
-
return context$1$0.abrupt('break', 89);
|
|
188
|
-
|
|
189
|
-
case 75:
|
|
190
|
-
context$1$0.next = 77;
|
|
191
|
-
return parser.readInt16LE();
|
|
192
|
-
|
|
193
|
-
case 77:
|
|
194
|
-
value = context$1$0.sent;
|
|
195
|
-
return context$1$0.abrupt('break', 89);
|
|
196
|
-
|
|
197
|
-
case 79:
|
|
198
|
-
context$1$0.next = 81;
|
|
199
|
-
return parser.readInt32LE();
|
|
200
|
-
|
|
201
|
-
case 81:
|
|
202
|
-
value = context$1$0.sent;
|
|
203
|
-
return context$1$0.abrupt('break', 89);
|
|
204
|
-
|
|
205
|
-
case 83:
|
|
206
|
-
context$1$0.next = 85;
|
|
207
|
-
return parser.readBuffer(8);
|
|
208
|
-
|
|
209
|
-
case 85:
|
|
210
|
-
context$1$0.t5 = context$1$0.sent;
|
|
211
|
-
value = convertLEBytesToString(context$1$0.t5);
|
|
212
|
-
return context$1$0.abrupt('break', 89);
|
|
213
|
-
|
|
214
|
-
case 88:
|
|
215
|
-
throw new Error("Unsupported dataLength " + dataLength + " for IntN");
|
|
216
|
-
|
|
217
|
-
case 89:
|
|
218
|
-
return context$1$0.abrupt('break', 307);
|
|
219
|
-
|
|
220
|
-
case 90:
|
|
221
|
-
context$1$0.next = 92;
|
|
222
|
-
return parser.readFloatLE();
|
|
223
|
-
|
|
224
|
-
case 92:
|
|
225
|
-
value = context$1$0.sent;
|
|
226
|
-
return context$1$0.abrupt('break', 307);
|
|
227
|
-
|
|
228
|
-
case 94:
|
|
229
|
-
context$1$0.next = 96;
|
|
230
|
-
return parser.readDoubleLE();
|
|
231
|
-
|
|
232
|
-
case 96:
|
|
233
|
-
value = context$1$0.sent;
|
|
234
|
-
return context$1$0.abrupt('break', 307);
|
|
235
|
-
|
|
236
|
-
case 98:
|
|
237
|
-
context$1$0.t6 = dataLength;
|
|
238
|
-
context$1$0.next = context$1$0.t6 === 0 ? 101 : context$1$0.t6 === 4 ? 103 : context$1$0.t6 === 8 ? 107 : 111;
|
|
239
|
-
break;
|
|
240
|
-
|
|
241
|
-
case 101:
|
|
242
|
-
value = null;
|
|
243
|
-
return context$1$0.abrupt('break', 112);
|
|
244
|
-
|
|
245
|
-
case 103:
|
|
246
|
-
context$1$0.next = 105;
|
|
247
|
-
return parser.readFloatLE();
|
|
248
|
-
|
|
249
|
-
case 105:
|
|
250
|
-
value = context$1$0.sent;
|
|
251
|
-
return context$1$0.abrupt('break', 112);
|
|
252
|
-
|
|
253
|
-
case 107:
|
|
254
|
-
context$1$0.next = 109;
|
|
255
|
-
return parser.readDoubleLE();
|
|
256
|
-
|
|
257
|
-
case 109:
|
|
258
|
-
value = context$1$0.sent;
|
|
259
|
-
return context$1$0.abrupt('break', 112);
|
|
260
|
-
|
|
261
|
-
case 111:
|
|
262
|
-
throw new Error("Unsupported dataLength " + dataLength + " for FloatN");
|
|
263
148
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
return context$1$0.abrupt('break', 134);
|
|
285
|
-
|
|
286
|
-
case 124:
|
|
287
|
-
context$1$0.next = 126;
|
|
288
|
-
return parser.readInt32LE();
|
|
289
|
-
|
|
290
|
-
case 126:
|
|
291
|
-
high = context$1$0.sent;
|
|
292
|
-
context$1$0.next = 129;
|
|
293
|
-
return parser.readUInt32LE();
|
|
294
|
-
|
|
295
|
-
case 129:
|
|
296
|
-
low = context$1$0.sent;
|
|
297
|
-
|
|
298
|
-
value = low + 0x100000000 * high;
|
|
299
|
-
value /= MONEY_DIVISOR;
|
|
300
|
-
return context$1$0.abrupt('break', 134);
|
|
301
|
-
|
|
302
|
-
case 133:
|
|
303
|
-
throw new Error("Unsupported dataLength " + dataLength + " for MoneyN");
|
|
304
|
-
|
|
305
|
-
case 134:
|
|
306
|
-
return context$1$0.abrupt('break', 307);
|
|
307
|
-
|
|
308
|
-
case 135:
|
|
309
|
-
context$1$0.next = 137;
|
|
310
|
-
return parser.readUInt8();
|
|
311
|
-
|
|
312
|
-
case 137:
|
|
313
|
-
value = !!context$1$0.sent;
|
|
314
|
-
return context$1$0.abrupt('break', 307);
|
|
315
|
-
|
|
316
|
-
case 139:
|
|
317
|
-
context$1$0.t10 = dataLength;
|
|
318
|
-
context$1$0.next = context$1$0.t10 === 0 ? 142 : context$1$0.t10 === 1 ? 144 : 147;
|
|
319
|
-
break;
|
|
320
|
-
|
|
321
|
-
case 142:
|
|
322
|
-
value = null;
|
|
323
|
-
return context$1$0.abrupt('break', 147);
|
|
324
|
-
|
|
325
|
-
case 144:
|
|
326
|
-
context$1$0.next = 146;
|
|
327
|
-
return parser.readUInt8();
|
|
328
|
-
|
|
329
|
-
case 146:
|
|
330
|
-
value = !!context$1$0.sent;
|
|
331
|
-
|
|
332
|
-
case 147:
|
|
333
|
-
return context$1$0.abrupt('break', 307);
|
|
334
|
-
|
|
335
|
-
case 148:
|
|
336
|
-
codepage = metaData.collation.codepage;
|
|
337
|
-
|
|
338
|
-
if (!(metaData.dataLength === MAX)) {
|
|
339
|
-
context$1$0.next = 154;
|
|
149
|
+
case 'Money':
|
|
150
|
+
case 'SmallMoney':
|
|
151
|
+
case 'MoneyN':
|
|
152
|
+
switch (dataLength) {
|
|
153
|
+
case 0:
|
|
154
|
+
return callback(null);
|
|
155
|
+
case 4:
|
|
156
|
+
return parser.readInt32LE(function (value) {
|
|
157
|
+
callback(value / MONEY_DIVISOR);
|
|
158
|
+
});
|
|
159
|
+
case 8:
|
|
160
|
+
return parser.readInt32LE(function (high) {
|
|
161
|
+
parser.readUInt32LE(function (low) {
|
|
162
|
+
callback((low + 0x100000000 * high) / MONEY_DIVISOR);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
default:
|
|
167
|
+
return parser.emit('error', new Error('Unsupported dataLength ' + dataLength + ' for MoneyN'));
|
|
168
|
+
}
|
|
340
169
|
break;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
return context$1$0.delegateYield(readMaxChars(parser, codepage), 't11', 151);
|
|
344
|
-
|
|
345
|
-
case 151:
|
|
346
|
-
value = context$1$0.t11;
|
|
347
|
-
context$1$0.next = 156;
|
|
348
|
-
break;
|
|
349
170
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
171
|
+
case 'Bit':
|
|
172
|
+
return parser.readUInt8(function (value) {
|
|
173
|
+
callback(!!value);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
case 'BitN':
|
|
177
|
+
switch (dataLength) {
|
|
178
|
+
case 0:
|
|
179
|
+
return callback(null);
|
|
180
|
+
case 1:
|
|
181
|
+
return parser.readUInt8(function (value) {
|
|
182
|
+
callback(!!value);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
362
185
|
break;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
return context$1$0.delegateYield(readMaxNChars(parser), 't13', 159);
|
|
366
|
-
|
|
367
|
-
case 159:
|
|
368
|
-
value = context$1$0.t13;
|
|
369
|
-
context$1$0.next = 164;
|
|
370
|
-
break;
|
|
371
|
-
|
|
372
|
-
case 162:
|
|
373
|
-
return context$1$0.delegateYield(readNChars(parser, dataLength), 't14', 163);
|
|
374
|
-
|
|
375
|
-
case 163:
|
|
376
|
-
value = context$1$0.t14;
|
|
377
186
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
187
|
+
case 'VarChar':
|
|
188
|
+
case 'Char':
|
|
189
|
+
var codepage = metaData.collation.codepage;
|
|
190
|
+
if (metaData.dataLength === MAX) {
|
|
191
|
+
return readMaxChars(parser, codepage, callback);
|
|
192
|
+
} else {
|
|
193
|
+
return readChars(parser, dataLength, codepage, callback);
|
|
194
|
+
}
|
|
384
195
|
break;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return context$1$0.delegateYield(readMaxBinary(parser), 't15', 167);
|
|
388
196
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
case 171:
|
|
398
|
-
value = context$1$0.t16;
|
|
399
|
-
|
|
400
|
-
case 172:
|
|
401
|
-
return context$1$0.abrupt('break', 307);
|
|
402
|
-
|
|
403
|
-
case 173:
|
|
404
|
-
if (!textPointerNull) {
|
|
405
|
-
context$1$0.next = 177;
|
|
197
|
+
case 'NVarChar':
|
|
198
|
+
case 'NChar':
|
|
199
|
+
if (metaData.dataLength === MAX) {
|
|
200
|
+
return readMaxNChars(parser, callback);
|
|
201
|
+
} else {
|
|
202
|
+
return readNChars(parser, dataLength, callback);
|
|
203
|
+
}
|
|
406
204
|
break;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
value = null;
|
|
410
|
-
context$1$0.next = 179;
|
|
411
|
-
break;
|
|
412
|
-
|
|
413
|
-
case 177:
|
|
414
|
-
return context$1$0.delegateYield(readChars(parser, dataLength, metaData.collation.codepage), 't17', 178);
|
|
415
|
-
|
|
416
|
-
case 178:
|
|
417
|
-
value = context$1$0.t17;
|
|
418
205
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
206
|
+
case 'VarBinary':
|
|
207
|
+
case 'Binary':
|
|
208
|
+
if (metaData.dataLength === MAX) {
|
|
209
|
+
return readMaxBinary(parser, callback);
|
|
210
|
+
} else {
|
|
211
|
+
return readBinary(parser, dataLength, callback);
|
|
212
|
+
}
|
|
425
213
|
break;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
value = null;
|
|
429
|
-
context$1$0.next = 186;
|
|
430
|
-
break;
|
|
431
|
-
|
|
432
|
-
case 184:
|
|
433
|
-
return context$1$0.delegateYield(readNChars(parser, dataLength), 't18', 185);
|
|
434
214
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
case 187:
|
|
442
|
-
if (!textPointerNull) {
|
|
443
|
-
context$1$0.next = 191;
|
|
215
|
+
case 'Text':
|
|
216
|
+
if (textPointerNull) {
|
|
217
|
+
return callback(null);
|
|
218
|
+
} else {
|
|
219
|
+
return readChars(parser, dataLength, metaData.collation.codepage, callback);
|
|
220
|
+
}
|
|
444
221
|
break;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
value = null;
|
|
448
|
-
context$1$0.next = 193;
|
|
449
|
-
break;
|
|
450
|
-
|
|
451
|
-
case 191:
|
|
452
|
-
return context$1$0.delegateYield(readBinary(parser, dataLength), 't19', 192);
|
|
453
|
-
|
|
454
|
-
case 192:
|
|
455
|
-
value = context$1$0.t19;
|
|
456
|
-
|
|
457
|
-
case 193:
|
|
458
|
-
return context$1$0.abrupt('break', 307);
|
|
459
|
-
|
|
460
|
-
case 194:
|
|
461
|
-
return context$1$0.delegateYield(readMaxNChars(parser), 't20', 195);
|
|
462
|
-
|
|
463
|
-
case 195:
|
|
464
|
-
value = context$1$0.t20;
|
|
465
|
-
return context$1$0.abrupt('break', 307);
|
|
466
|
-
|
|
467
|
-
case 197:
|
|
468
|
-
return context$1$0.delegateYield(readSmallDateTime(parser, options.useUTC), 't21', 198);
|
|
469
|
-
|
|
470
|
-
case 198:
|
|
471
|
-
value = context$1$0.t21;
|
|
472
|
-
return context$1$0.abrupt('break', 307);
|
|
473
|
-
|
|
474
|
-
case 200:
|
|
475
|
-
return context$1$0.delegateYield(readDateTime(parser, options.useUTC), 't22', 201);
|
|
476
|
-
|
|
477
|
-
case 201:
|
|
478
|
-
value = context$1$0.t22;
|
|
479
|
-
return context$1$0.abrupt('break', 307);
|
|
480
|
-
|
|
481
|
-
case 203:
|
|
482
|
-
context$1$0.t23 = dataLength;
|
|
483
|
-
context$1$0.next = context$1$0.t23 === 0 ? 206 : context$1$0.t23 === 4 ? 208 : context$1$0.t23 === 8 ? 211 : 213;
|
|
484
|
-
break;
|
|
485
|
-
|
|
486
|
-
case 206:
|
|
487
|
-
value = null;
|
|
488
|
-
return context$1$0.abrupt('break', 213);
|
|
489
|
-
|
|
490
|
-
case 208:
|
|
491
|
-
return context$1$0.delegateYield(readSmallDateTime(parser, options.useUTC), 't24', 209);
|
|
492
|
-
|
|
493
|
-
case 209:
|
|
494
|
-
value = context$1$0.t24;
|
|
495
|
-
return context$1$0.abrupt('break', 213);
|
|
496
|
-
|
|
497
|
-
case 211:
|
|
498
|
-
return context$1$0.delegateYield(readDateTime(parser, options.useUTC), 't25', 212);
|
|
499
|
-
|
|
500
|
-
case 212:
|
|
501
|
-
value = context$1$0.t25;
|
|
502
|
-
|
|
503
|
-
case 213:
|
|
504
|
-
return context$1$0.abrupt('break', 307);
|
|
505
|
-
|
|
506
|
-
case 214:
|
|
507
|
-
context$1$0.next = 216;
|
|
508
|
-
return parser.readUInt8();
|
|
509
222
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
223
|
+
case 'NText':
|
|
224
|
+
if (textPointerNull) {
|
|
225
|
+
return callback(null);
|
|
226
|
+
} else {
|
|
227
|
+
return readNChars(parser, dataLength, callback);
|
|
228
|
+
}
|
|
515
229
|
break;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
value = null;
|
|
519
|
-
context$1$0.next = 223;
|
|
520
|
-
break;
|
|
521
|
-
|
|
522
|
-
case 221:
|
|
523
|
-
return context$1$0.delegateYield(readTime(parser, dataLength, metaData.scale, options.useUTC), 't27', 222);
|
|
524
230
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
case 224:
|
|
532
|
-
context$1$0.next = 226;
|
|
533
|
-
return parser.readUInt8();
|
|
534
|
-
|
|
535
|
-
case 226:
|
|
536
|
-
context$1$0.t28 = dataLength = context$1$0.sent;
|
|
537
|
-
|
|
538
|
-
if (!(context$1$0.t28 === 0)) {
|
|
539
|
-
context$1$0.next = 231;
|
|
231
|
+
case 'Image':
|
|
232
|
+
if (textPointerNull) {
|
|
233
|
+
return callback(null);
|
|
234
|
+
} else {
|
|
235
|
+
return readBinary(parser, dataLength, callback);
|
|
236
|
+
}
|
|
540
237
|
break;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
value = null;
|
|
544
|
-
context$1$0.next = 233;
|
|
545
|
-
break;
|
|
546
|
-
|
|
547
|
-
case 231:
|
|
548
|
-
return context$1$0.delegateYield(readDate(parser, options.useUTC), 't29', 232);
|
|
549
238
|
|
|
550
|
-
|
|
551
|
-
|
|
239
|
+
case 'Xml':
|
|
240
|
+
return readMaxNChars(parser, callback);
|
|
552
241
|
|
|
553
|
-
|
|
554
|
-
|
|
242
|
+
case 'SmallDateTime':
|
|
243
|
+
return readSmallDateTime(parser, options.useUTC, callback);
|
|
555
244
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
return parser.readUInt8();
|
|
245
|
+
case 'DateTime':
|
|
246
|
+
return readDateTime(parser, options.useUTC, callback);
|
|
559
247
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
248
|
+
case 'DateTimeN':
|
|
249
|
+
switch (dataLength) {
|
|
250
|
+
case 0:
|
|
251
|
+
return callback(null);
|
|
252
|
+
case 4:
|
|
253
|
+
return readSmallDateTime(parser, options.useUTC, callback);
|
|
254
|
+
case 8:
|
|
255
|
+
return readDateTime(parser, options.useUTC, callback);
|
|
256
|
+
}
|
|
565
257
|
break;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
value = null;
|
|
569
|
-
context$1$0.next = 243;
|
|
570
|
-
break;
|
|
571
|
-
|
|
572
|
-
case 241:
|
|
573
|
-
return context$1$0.delegateYield(readDateTime2(parser, dataLength, metaData.scale, options.useUTC), 't31', 242);
|
|
574
|
-
|
|
575
|
-
case 242:
|
|
576
|
-
value = context$1$0.t31;
|
|
577
258
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
case 246:
|
|
586
|
-
context$1$0.t32 = dataLength = context$1$0.sent;
|
|
587
|
-
|
|
588
|
-
if (!(context$1$0.t32 === 0)) {
|
|
589
|
-
context$1$0.next = 251;
|
|
259
|
+
case 'TimeN':
|
|
260
|
+
if (dataLength === 0) {
|
|
261
|
+
return callback(null);
|
|
262
|
+
} else {
|
|
263
|
+
return readTime(parser, dataLength, metaData.scale, options.useUTC, callback);
|
|
264
|
+
}
|
|
590
265
|
break;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
value = null;
|
|
594
|
-
context$1$0.next = 253;
|
|
595
|
-
break;
|
|
596
|
-
|
|
597
|
-
case 251:
|
|
598
|
-
return context$1$0.delegateYield(readDateTimeOffset(parser, dataLength, metaData.scale), 't33', 252);
|
|
599
|
-
|
|
600
|
-
case 252:
|
|
601
|
-
value = context$1$0.t33;
|
|
602
|
-
|
|
603
|
-
case 253:
|
|
604
|
-
return context$1$0.abrupt('break', 307);
|
|
605
266
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
267
|
+
case 'DateN':
|
|
268
|
+
if (dataLength === 0) {
|
|
269
|
+
return callback(null);
|
|
270
|
+
} else {
|
|
271
|
+
return readDate(parser, options.useUTC, callback);
|
|
272
|
+
}
|
|
609
273
|
break;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
value = null;
|
|
613
|
-
context$1$0.next = 287;
|
|
614
|
-
break;
|
|
615
|
-
|
|
616
|
-
case 258:
|
|
617
|
-
context$1$0.next = 260;
|
|
618
|
-
return parser.readUInt8();
|
|
619
|
-
|
|
620
|
-
case 260:
|
|
621
|
-
context$1$0.t34 = context$1$0.sent;
|
|
622
274
|
|
|
623
|
-
|
|
624
|
-
|
|
275
|
+
case 'DateTime2N':
|
|
276
|
+
if (dataLength === 0) {
|
|
277
|
+
return callback(null);
|
|
278
|
+
} else {
|
|
279
|
+
return readDateTime2(parser, dataLength, metaData.scale, options.useUTC, callback);
|
|
280
|
+
}
|
|
625
281
|
break;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
context$1$0.t35 = 1;
|
|
629
|
-
context$1$0.next = 266;
|
|
630
|
-
break;
|
|
631
|
-
|
|
632
|
-
case 265:
|
|
633
|
-
context$1$0.t35 = -1;
|
|
634
282
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
case 270:
|
|
642
|
-
context$1$0.next = 272;
|
|
643
|
-
return parser.readUInt32LE();
|
|
644
|
-
|
|
645
|
-
case 272:
|
|
646
|
-
value = context$1$0.sent;
|
|
647
|
-
return context$1$0.abrupt('break', 285);
|
|
648
|
-
|
|
649
|
-
case 274:
|
|
650
|
-
return context$1$0.delegateYield(parser.readUNumeric64LE(), 't37', 275);
|
|
651
|
-
|
|
652
|
-
case 275:
|
|
653
|
-
value = context$1$0.t37;
|
|
654
|
-
return context$1$0.abrupt('break', 285);
|
|
655
|
-
|
|
656
|
-
case 277:
|
|
657
|
-
return context$1$0.delegateYield(parser.readUNumeric96LE(), 't38', 278);
|
|
658
|
-
|
|
659
|
-
case 278:
|
|
660
|
-
value = context$1$0.t38;
|
|
661
|
-
return context$1$0.abrupt('break', 285);
|
|
662
|
-
|
|
663
|
-
case 280:
|
|
664
|
-
return context$1$0.delegateYield(parser.readUNumeric128LE(), 't39', 281);
|
|
665
|
-
|
|
666
|
-
case 281:
|
|
667
|
-
value = context$1$0.t39;
|
|
668
|
-
return context$1$0.abrupt('break', 285);
|
|
669
|
-
|
|
670
|
-
case 283:
|
|
671
|
-
throw new Error(sprintf('Unsupported numeric size %d at offset 0x%04X', dataLength - 1, buffer.position));
|
|
672
|
-
|
|
673
|
-
case 285:
|
|
674
|
-
value *= sign;
|
|
675
|
-
value /= Math.pow(10, metaData.scale);
|
|
676
|
-
|
|
677
|
-
case 287:
|
|
678
|
-
return context$1$0.abrupt('break', 307);
|
|
679
|
-
|
|
680
|
-
case 288:
|
|
681
|
-
context$1$0.t40 = dataLength;
|
|
682
|
-
context$1$0.next = context$1$0.t40 === 0 ? 291 : context$1$0.t40 === 0x10 ? 293 : 300;
|
|
683
|
-
break;
|
|
684
|
-
|
|
685
|
-
case 291:
|
|
686
|
-
value = null;
|
|
687
|
-
return context$1$0.abrupt('break', 301);
|
|
688
|
-
|
|
689
|
-
case 293:
|
|
690
|
-
context$1$0.t41 = Buffer;
|
|
691
|
-
context$1$0.next = 296;
|
|
692
|
-
return parser.readBuffer(0x10);
|
|
693
|
-
|
|
694
|
-
case 296:
|
|
695
|
-
context$1$0.t42 = context$1$0.sent;
|
|
696
|
-
data = new context$1$0.t41(context$1$0.t42);
|
|
697
|
-
|
|
698
|
-
value = guidParser.arrayToGuid(data);
|
|
699
|
-
return context$1$0.abrupt('break', 301);
|
|
700
|
-
|
|
701
|
-
case 300:
|
|
702
|
-
throw new Error(sprintf('Unsupported guid size %d at offset 0x%04X', dataLength - 1, buffer.position));
|
|
703
|
-
|
|
704
|
-
case 301:
|
|
705
|
-
return context$1$0.abrupt('break', 307);
|
|
706
|
-
|
|
707
|
-
case 302:
|
|
708
|
-
return context$1$0.delegateYield(readMaxBinary(parser), 't43', 303);
|
|
709
|
-
|
|
710
|
-
case 303:
|
|
711
|
-
value = context$1$0.t43;
|
|
712
|
-
return context$1$0.abrupt('break', 307);
|
|
713
|
-
|
|
714
|
-
case 305:
|
|
715
|
-
throw new Error(sprintf('Unrecognised type %s at offset 0x%04X', type.name, buffer.position));
|
|
716
|
-
|
|
717
|
-
case 307:
|
|
718
|
-
return context$1$0.abrupt('return', value);
|
|
719
|
-
|
|
720
|
-
case 308:
|
|
721
|
-
case 'end':
|
|
722
|
-
return context$1$0.stop();
|
|
723
|
-
}
|
|
724
|
-
}, callee$0$0, this);
|
|
725
|
-
});
|
|
726
|
-
|
|
727
|
-
readBinary = _regeneratorRuntime.mark(function callee$0$0(parser, dataLength) {
|
|
728
|
-
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
729
|
-
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
730
|
-
case 0:
|
|
731
|
-
if (!(dataLength === NULL)) {
|
|
732
|
-
context$1$0.next = 4;
|
|
283
|
+
case 'DateTimeOffsetN':
|
|
284
|
+
if (dataLength === 0) {
|
|
285
|
+
return callback(null);
|
|
286
|
+
} else {
|
|
287
|
+
return readDateTimeOffset(parser, dataLength, metaData.scale, callback);
|
|
288
|
+
}
|
|
733
289
|
break;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
return context$1$0.abrupt('return', null);
|
|
737
290
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
291
|
+
case 'NumericN':
|
|
292
|
+
case 'DecimalN':
|
|
293
|
+
if (dataLength === 0) {
|
|
294
|
+
return callback(null);
|
|
295
|
+
} else {
|
|
296
|
+
return parser.readUInt8(function (sign) {
|
|
297
|
+
sign = sign === 1 ? 1 : -1;
|
|
298
|
+
|
|
299
|
+
var readValue = undefined;
|
|
300
|
+
switch (dataLength - 1) {
|
|
301
|
+
case 4:
|
|
302
|
+
readValue = parser.readUInt32LE;
|
|
303
|
+
break;
|
|
304
|
+
case 8:
|
|
305
|
+
readValue = parser.readUNumeric64LE;
|
|
306
|
+
break;
|
|
307
|
+
case 12:
|
|
308
|
+
readValue = parser.readUNumeric96LE;
|
|
309
|
+
break;
|
|
310
|
+
case 16:
|
|
311
|
+
readValue = parser.readUNumeric128LE;
|
|
312
|
+
break;
|
|
313
|
+
default:
|
|
314
|
+
return parser.emit('error', new Error(sprintf('Unsupported numeric size %d', dataLength - 1)));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
readValue.call(parser, function (value) {
|
|
318
|
+
callback(value * sign / Math.pow(10, metaData.scale));
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
}
|
|
762
322
|
break;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
return context$1$0.abrupt('return', null);
|
|
766
|
-
|
|
767
|
-
case 5:
|
|
768
|
-
context$1$0.t0 = iconv;
|
|
769
|
-
context$1$0.next = 8;
|
|
770
|
-
return parser.readBuffer(dataLength);
|
|
771
323
|
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
readNChars = _regeneratorRuntime.mark(function callee$0$0(parser, dataLength) {
|
|
785
|
-
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
786
|
-
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
787
|
-
case 0:
|
|
788
|
-
if (!(dataLength === NULL)) {
|
|
789
|
-
context$1$0.next = 4;
|
|
324
|
+
case 'UniqueIdentifierN':
|
|
325
|
+
switch (dataLength) {
|
|
326
|
+
case 0:
|
|
327
|
+
return callback(null);
|
|
328
|
+
case 0x10:
|
|
329
|
+
return parser.readBuffer(0x10, function (data) {
|
|
330
|
+
callback(guidParser.arrayToGuid(data));
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
default:
|
|
334
|
+
return parser.emit('error', new Error(sprintf('Unsupported guid size %d', dataLength - 1)));
|
|
335
|
+
}
|
|
790
336
|
break;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
return context$1$0.abrupt('return', null);
|
|
794
|
-
|
|
795
|
-
case 4:
|
|
796
|
-
context$1$0.next = 6;
|
|
797
|
-
return parser.readBuffer(dataLength);
|
|
798
|
-
|
|
799
|
-
case 6:
|
|
800
|
-
return context$1$0.abrupt('return', context$1$0.sent.toString("ucs2"));
|
|
801
|
-
|
|
802
|
-
case 7:
|
|
803
|
-
case 'end':
|
|
804
|
-
return context$1$0.stop();
|
|
805
|
-
}
|
|
806
|
-
}, callee$0$0, this);
|
|
807
|
-
});
|
|
808
337
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
338
|
+
case 'UDT':
|
|
339
|
+
return readMaxBinary(parser, callback);
|
|
340
|
+
|
|
341
|
+
case 'Variant':
|
|
342
|
+
var valueMetaData = metaData.valueMetaData = {};
|
|
343
|
+
Object.defineProperty(valueMetaData, 'isVariantValue', { value: true });
|
|
344
|
+
return parser.readUInt8(function (baseType) {
|
|
345
|
+
return parser.readUInt8(function (propBytes) {
|
|
346
|
+
valueMetaData.dataLength = dataLength - propBytes - 2;
|
|
347
|
+
valueMetaData.type = TYPE[baseType];
|
|
348
|
+
return readPrecision(parser, valueMetaData.type, function (precision) {
|
|
349
|
+
valueMetaData.precision = precision;
|
|
350
|
+
return readScale(parser, valueMetaData.type, function (scale) {
|
|
351
|
+
valueMetaData.scale = scale;
|
|
352
|
+
return readCollation(parser, valueMetaData.type, function (collation) {
|
|
353
|
+
valueMetaData.collation = collation;
|
|
354
|
+
if (baseType === 0xA5 || baseType === 0xAD || baseType === 0xA7 || baseType === 0xAF || baseType === 0xE7 || baseType === 0xEF) {
|
|
355
|
+
return readDataLength(parser, valueMetaData.type, {}, null, function (maxDataLength) {
|
|
356
|
+
valueMetaData.dataLength = maxDataLength;
|
|
357
|
+
return valueParse(parser, valueMetaData, options, callback);
|
|
358
|
+
});
|
|
359
|
+
} else {
|
|
360
|
+
return valueParse(parser, valueMetaData, options, callback);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
default:
|
|
369
|
+
return parser.emit('error', new Error(sprintf('Unrecognised type %s', type.name)));
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function readBinary(parser, dataLength, callback) {
|
|
376
|
+
if (dataLength === NULL) {
|
|
377
|
+
return callback(null);
|
|
378
|
+
} else {
|
|
379
|
+
return parser.readBuffer(dataLength, callback);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function readChars(parser, dataLength, codepage, callback) {
|
|
384
|
+
if (codepage == null) {
|
|
385
|
+
codepage = DEFAULT_ENCODING;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (dataLength === NULL) {
|
|
389
|
+
return callback(null);
|
|
390
|
+
} else {
|
|
391
|
+
return parser.readBuffer(dataLength, function (data) {
|
|
392
|
+
callback(iconv.decode(data, codepage));
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function readNChars(parser, dataLength, callback) {
|
|
398
|
+
if (dataLength === NULL) {
|
|
399
|
+
return callback(null);
|
|
400
|
+
} else {
|
|
401
|
+
return parser.readBuffer(dataLength, function (data) {
|
|
402
|
+
callback(data.toString('ucs2'));
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function readMaxBinary(parser, callback) {
|
|
408
|
+
return readMax(parser, callback);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function readMaxChars(parser, codepage, callback) {
|
|
412
|
+
if (codepage == null) {
|
|
413
|
+
codepage = DEFAULT_ENCODING;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
readMax(parser, function (data) {
|
|
417
|
+
if (data) {
|
|
418
|
+
callback(iconv.decode(data, codepage));
|
|
419
|
+
} else {
|
|
420
|
+
callback(null);
|
|
821
421
|
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
codepage = DEFAULT_ENCODING;
|
|
832
|
-
}
|
|
833
|
-
return context$1$0.delegateYield(readMax(parser), 't0', 2);
|
|
834
|
-
|
|
835
|
-
case 2:
|
|
836
|
-
if (!(data = context$1$0.t0)) {
|
|
837
|
-
context$1$0.next = 6;
|
|
838
|
-
break;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
return context$1$0.abrupt('return', iconv.decode(data, codepage));
|
|
842
|
-
|
|
843
|
-
case 6:
|
|
844
|
-
return context$1$0.abrupt('return', null);
|
|
845
|
-
|
|
846
|
-
case 7:
|
|
847
|
-
case 'end':
|
|
848
|
-
return context$1$0.stop();
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function readMaxNChars(parser, callback) {
|
|
426
|
+
readMax(parser, function (data) {
|
|
427
|
+
if (data) {
|
|
428
|
+
callback(data.toString('ucs2'));
|
|
429
|
+
} else {
|
|
430
|
+
callback(null);
|
|
849
431
|
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function readMax(parser, callback) {
|
|
436
|
+
parser.readBuffer(8, function (type) {
|
|
437
|
+
if (type.equals(PLP_NULL)) {
|
|
438
|
+
return callback(null);
|
|
439
|
+
} else if (type.equals(UNKNOWN_PLP_LEN)) {
|
|
440
|
+
return readMaxUnknownLength(parser, callback);
|
|
441
|
+
} else {
|
|
442
|
+
var low = type.readUInt32LE(0);
|
|
443
|
+
var high = type.readUInt32LE(4);
|
|
444
|
+
|
|
445
|
+
if (high >= 2 << 53 - 32) {
|
|
446
|
+
console.warn('Read UInt64LE > 53 bits : high=' + high + ', low=' + low);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
var expectedLength = low + 0x100000000 * high;
|
|
450
|
+
return readMaxKnownLength(parser, expectedLength, callback);
|
|
865
451
|
}
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
readMax = _regeneratorRuntime.mark(function callee$0$0(parser) {
|
|
870
|
-
var expectedLength, high, low, type;
|
|
871
|
-
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
872
|
-
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
873
|
-
case 0:
|
|
874
|
-
context$1$0.next = 2;
|
|
875
|
-
return parser.readBuffer(8);
|
|
876
|
-
|
|
877
|
-
case 2:
|
|
878
|
-
type = context$1$0.sent;
|
|
879
|
-
|
|
880
|
-
if (!type.equals(PLP_NULL)) {
|
|
881
|
-
context$1$0.next = 7;
|
|
882
|
-
break;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
return context$1$0.abrupt('return', null);
|
|
886
|
-
|
|
887
|
-
case 7:
|
|
888
|
-
if (!type.equals(UNKNOWN_PLP_LEN)) {
|
|
889
|
-
context$1$0.next = 12;
|
|
890
|
-
break;
|
|
891
|
-
}
|
|
452
|
+
});
|
|
453
|
+
}
|
|
892
454
|
|
|
893
|
-
|
|
455
|
+
function readMaxKnownLength(parser, totalLength, callback) {
|
|
456
|
+
var data = new Buffer(totalLength);
|
|
894
457
|
|
|
895
|
-
|
|
896
|
-
|
|
458
|
+
var offset = 0;
|
|
459
|
+
function next(done) {
|
|
460
|
+
parser.readUInt32LE(function (chunkLength) {
|
|
461
|
+
if (!chunkLength) {
|
|
462
|
+
return done();
|
|
463
|
+
}
|
|
897
464
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
if (high >= 2 << 53 - 32) {
|
|
902
|
-
console.warn("Read UInt64LE > 53 bits : high=" + high + ", low=" + low);
|
|
903
|
-
}
|
|
904
|
-
expectedLength = low + 0x100000000 * high;
|
|
905
|
-
return context$1$0.delegateYield(readMaxKnownLength(parser, expectedLength), 't1', 17);
|
|
465
|
+
parser.readBuffer(chunkLength, function (chunk) {
|
|
466
|
+
chunk.copy(data, offset);
|
|
467
|
+
offset += chunkLength;
|
|
906
468
|
|
|
907
|
-
|
|
908
|
-
|
|
469
|
+
next(done);
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
}
|
|
909
473
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
474
|
+
next(function () {
|
|
475
|
+
if (offset !== totalLength) {
|
|
476
|
+
parser.emit('error', new Error('Partially Length-prefixed Bytes unmatched lengths : expected ' + totalLength + ', but got ' + offset + ' bytes'));
|
|
913
477
|
}
|
|
914
|
-
}, callee$0$0, this);
|
|
915
|
-
});
|
|
916
|
-
|
|
917
|
-
readMaxKnownLength = _regeneratorRuntime.mark(function callee$0$0(parser, totalLength) {
|
|
918
|
-
var chunkLength, data, offset;
|
|
919
|
-
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
920
|
-
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
921
|
-
case 0:
|
|
922
|
-
data = new Buffer(totalLength);
|
|
923
|
-
offset = 0;
|
|
924
|
-
|
|
925
|
-
case 2:
|
|
926
|
-
context$1$0.next = 4;
|
|
927
|
-
return parser.readUInt32LE();
|
|
928
|
-
|
|
929
|
-
case 4:
|
|
930
|
-
if (!(chunkLength = context$1$0.sent)) {
|
|
931
|
-
context$1$0.next = 13;
|
|
932
|
-
break;
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
context$1$0.next = 7;
|
|
936
|
-
return parser.readBuffer(chunkLength);
|
|
937
|
-
|
|
938
|
-
case 7:
|
|
939
|
-
context$1$0.t0 = data;
|
|
940
|
-
context$1$0.t1 = offset;
|
|
941
|
-
context$1$0.sent.copy(context$1$0.t0, context$1$0.t1);
|
|
942
|
-
|
|
943
|
-
offset += chunkLength;
|
|
944
|
-
context$1$0.next = 2;
|
|
945
|
-
break;
|
|
946
|
-
|
|
947
|
-
case 13:
|
|
948
|
-
if (!(offset !== totalLength)) {
|
|
949
|
-
context$1$0.next = 15;
|
|
950
|
-
break;
|
|
951
|
-
}
|
|
952
478
|
|
|
953
|
-
|
|
479
|
+
callback(data);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
954
482
|
|
|
955
|
-
|
|
956
|
-
|
|
483
|
+
function readMaxUnknownLength(parser, callback) {
|
|
484
|
+
var chunks = [];
|
|
957
485
|
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
readMaxUnknownLength = _regeneratorRuntime.mark(function callee$0$0(parser) {
|
|
966
|
-
var chunkLength, chunks, length;
|
|
967
|
-
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
968
|
-
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
969
|
-
case 0:
|
|
970
|
-
length = 0;
|
|
971
|
-
chunks = [];
|
|
972
|
-
|
|
973
|
-
case 2:
|
|
974
|
-
context$1$0.next = 4;
|
|
975
|
-
return parser.readUInt32LE();
|
|
976
|
-
|
|
977
|
-
case 4:
|
|
978
|
-
if (!(chunkLength = context$1$0.sent)) {
|
|
979
|
-
context$1$0.next = 13;
|
|
980
|
-
break;
|
|
981
|
-
}
|
|
486
|
+
var length = 0;
|
|
487
|
+
function next(done) {
|
|
488
|
+
parser.readUInt32LE(function (chunkLength) {
|
|
489
|
+
if (!chunkLength) {
|
|
490
|
+
return done();
|
|
491
|
+
}
|
|
982
492
|
|
|
493
|
+
parser.readBuffer(chunkLength, function (chunk) {
|
|
494
|
+
chunks.push(chunk);
|
|
983
495
|
length += chunkLength;
|
|
984
|
-
context$1$0.t0 = chunks;
|
|
985
|
-
context$1$0.next = 9;
|
|
986
|
-
return parser.readBuffer(chunkLength);
|
|
987
|
-
|
|
988
|
-
case 9:
|
|
989
|
-
context$1$0.t1 = context$1$0.sent;
|
|
990
|
-
context$1$0.t0.push.call(context$1$0.t0, context$1$0.t1);
|
|
991
|
-
context$1$0.next = 2;
|
|
992
|
-
break;
|
|
993
|
-
|
|
994
|
-
case 13:
|
|
995
|
-
return context$1$0.abrupt('return', Buffer.concat(chunks, length));
|
|
996
|
-
|
|
997
|
-
case 14:
|
|
998
|
-
case 'end':
|
|
999
|
-
return context$1$0.stop();
|
|
1000
|
-
}
|
|
1001
|
-
}, callee$0$0, this);
|
|
1002
|
-
});
|
|
1003
|
-
|
|
1004
|
-
readSmallDateTime = _regeneratorRuntime.mark(function callee$0$0(parser, useUTC) {
|
|
1005
|
-
var days, minutes, value;
|
|
1006
|
-
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
1007
|
-
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
1008
|
-
case 0:
|
|
1009
|
-
context$1$0.next = 2;
|
|
1010
|
-
return parser.readUInt16LE();
|
|
1011
|
-
|
|
1012
|
-
case 2:
|
|
1013
|
-
days = context$1$0.sent;
|
|
1014
|
-
context$1$0.next = 5;
|
|
1015
|
-
return parser.readUInt16LE();
|
|
1016
|
-
|
|
1017
|
-
case 5:
|
|
1018
|
-
minutes = context$1$0.sent;
|
|
1019
|
-
|
|
1020
|
-
if (useUTC) {
|
|
1021
|
-
value = new Date(Date.UTC(1900, 0, 1));
|
|
1022
|
-
value.setUTCDate(value.getUTCDate() + days);
|
|
1023
|
-
value.setUTCMinutes(value.getUTCMinutes() + minutes);
|
|
1024
|
-
} else {
|
|
1025
|
-
value = new Date(1900, 0, 1);
|
|
1026
|
-
value.setDate(value.getDate() + days);
|
|
1027
|
-
value.setMinutes(value.getMinutes() + minutes);
|
|
1028
|
-
}
|
|
1029
|
-
return context$1$0.abrupt('return', value);
|
|
1030
|
-
|
|
1031
|
-
case 8:
|
|
1032
|
-
case 'end':
|
|
1033
|
-
return context$1$0.stop();
|
|
1034
|
-
}
|
|
1035
|
-
}, callee$0$0, this);
|
|
1036
|
-
});
|
|
1037
|
-
|
|
1038
|
-
readDateTime = _regeneratorRuntime.mark(function callee$0$0(parser, useUTC) {
|
|
1039
|
-
var days, milliseconds, threeHundredthsOfSecond, value;
|
|
1040
|
-
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
1041
|
-
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
1042
|
-
case 0:
|
|
1043
|
-
context$1$0.next = 2;
|
|
1044
|
-
return parser.readInt32LE();
|
|
1045
|
-
|
|
1046
|
-
case 2:
|
|
1047
|
-
days = context$1$0.sent;
|
|
1048
|
-
context$1$0.next = 5;
|
|
1049
|
-
return parser.readUInt32LE();
|
|
1050
|
-
|
|
1051
|
-
case 5:
|
|
1052
|
-
threeHundredthsOfSecond = context$1$0.sent;
|
|
1053
|
-
|
|
1054
|
-
milliseconds = threeHundredthsOfSecond * THREE_AND_A_THIRD;
|
|
1055
|
-
if (useUTC) {
|
|
1056
|
-
value = new Date(Date.UTC(1900, 0, 1));
|
|
1057
|
-
value.setUTCDate(value.getUTCDate() + days);
|
|
1058
|
-
value.setUTCMilliseconds(value.getUTCMilliseconds() + milliseconds);
|
|
1059
|
-
} else {
|
|
1060
|
-
value = new Date(1900, 0, 1);
|
|
1061
|
-
value.setDate(value.getDate() + days);
|
|
1062
|
-
value.setMilliseconds(value.getMilliseconds() + milliseconds);
|
|
1063
|
-
}
|
|
1064
|
-
return context$1$0.abrupt('return', value);
|
|
1065
496
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
497
|
+
next(done);
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
next(function () {
|
|
503
|
+
callback(Buffer.concat(chunks, length));
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function readSmallDateTime(parser, useUTC, callback) {
|
|
508
|
+
parser.readUInt16LE(function (days) {
|
|
509
|
+
parser.readUInt16LE(function (minutes) {
|
|
510
|
+
var value = undefined;
|
|
511
|
+
if (useUTC) {
|
|
512
|
+
value = new Date(Date.UTC(1900, 0, 1));
|
|
513
|
+
value.setUTCDate(value.getUTCDate() + days);
|
|
514
|
+
value.setUTCMinutes(value.getUTCMinutes() + minutes);
|
|
515
|
+
} else {
|
|
516
|
+
value = new Date(1900, 0, 1);
|
|
517
|
+
value.setDate(value.getDate() + days);
|
|
518
|
+
value.setMinutes(value.getMinutes() + minutes);
|
|
519
|
+
}
|
|
520
|
+
callback(value);
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
function readDateTime(parser, useUTC, callback) {
|
|
526
|
+
parser.readInt32LE(function (days) {
|
|
527
|
+
parser.readUInt32LE(function (threeHundredthsOfSecond) {
|
|
528
|
+
var milliseconds = threeHundredthsOfSecond * THREE_AND_A_THIRD;
|
|
529
|
+
|
|
530
|
+
var value = undefined;
|
|
531
|
+
if (useUTC) {
|
|
532
|
+
value = new Date(Date.UTC(1900, 0, 1));
|
|
533
|
+
value.setUTCDate(value.getUTCDate() + days);
|
|
534
|
+
value.setUTCMilliseconds(value.getUTCMilliseconds() + milliseconds);
|
|
535
|
+
} else {
|
|
536
|
+
value = new Date(1900, 0, 1);
|
|
537
|
+
value.setDate(value.getDate() + days);
|
|
538
|
+
value.setMilliseconds(value.getMilliseconds() + milliseconds);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
callback(value);
|
|
542
|
+
});
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function readTime(parser, dataLength, scale, useUTC, callback) {
|
|
547
|
+
var readValue = undefined;
|
|
548
|
+
switch (dataLength) {
|
|
549
|
+
case 3:
|
|
550
|
+
readValue = parser.readUInt24LE;
|
|
551
|
+
break;
|
|
552
|
+
case 4:
|
|
553
|
+
readValue = parser.readUInt32LE;
|
|
554
|
+
break;
|
|
555
|
+
case 5:
|
|
556
|
+
readValue = parser.readUInt40LE;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
readValue.call(parser, function (value) {
|
|
560
|
+
if (scale < 7) {
|
|
561
|
+
for (var i = scale; i < 7; i++) {
|
|
562
|
+
value *= 10;
|
|
563
|
+
}
|
|
1069
564
|
}
|
|
1070
|
-
}, callee$0$0, this);
|
|
1071
|
-
});
|
|
1072
|
-
|
|
1073
|
-
readTime = _regeneratorRuntime.mark(function callee$0$0(parser, dataLength, scale, useUTC) {
|
|
1074
|
-
var date, i, j, ref, value;
|
|
1075
|
-
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
1076
|
-
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
1077
|
-
case 0:
|
|
1078
|
-
context$1$0.t0 = dataLength;
|
|
1079
|
-
context$1$0.next = context$1$0.t0 === 3 ? 3 : context$1$0.t0 === 4 ? 6 : context$1$0.t0 === 5 ? 10 : 12;
|
|
1080
|
-
break;
|
|
1081
|
-
|
|
1082
|
-
case 3:
|
|
1083
|
-
return context$1$0.delegateYield(parser.readUInt24LE(), 't1', 4);
|
|
1084
|
-
|
|
1085
|
-
case 4:
|
|
1086
|
-
value = context$1$0.t1;
|
|
1087
|
-
return context$1$0.abrupt('break', 12);
|
|
1088
|
-
|
|
1089
|
-
case 6:
|
|
1090
|
-
context$1$0.next = 8;
|
|
1091
|
-
return parser.readUInt32LE();
|
|
1092
|
-
|
|
1093
|
-
case 8:
|
|
1094
|
-
value = context$1$0.sent;
|
|
1095
|
-
return context$1$0.abrupt('break', 12);
|
|
1096
|
-
|
|
1097
|
-
case 10:
|
|
1098
|
-
return context$1$0.delegateYield(parser.readUInt40LE(), 't2', 11);
|
|
1099
|
-
|
|
1100
|
-
case 11:
|
|
1101
|
-
value = context$1$0.t2;
|
|
1102
|
-
|
|
1103
|
-
case 12:
|
|
1104
|
-
if (scale < 7) {
|
|
1105
|
-
for (i = j = ref = scale + 1; ref <= 7 ? j <= 7 : j >= 7; i = ref <= 7 ? ++j : --j) {
|
|
1106
|
-
value *= 10;
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
if (useUTC) {
|
|
1110
|
-
date = new Date(Date.UTC(1970, 0, 1, 0, 0, 0, value / 10000));
|
|
1111
|
-
} else {
|
|
1112
|
-
date = new Date(1970, 0, 1, 0, 0, 0, value / 10000);
|
|
1113
|
-
}
|
|
1114
|
-
Object.defineProperty(date, "nanosecondsDelta", {
|
|
1115
|
-
enumerable: false,
|
|
1116
|
-
value: value % 10000 / Math.pow(10, 7)
|
|
1117
|
-
});
|
|
1118
|
-
return context$1$0.abrupt('return', date);
|
|
1119
|
-
|
|
1120
|
-
case 16:
|
|
1121
|
-
case 'end':
|
|
1122
|
-
return context$1$0.stop();
|
|
1123
|
-
}
|
|
1124
|
-
}, callee$0$0, this);
|
|
1125
|
-
});
|
|
1126
|
-
|
|
1127
|
-
readDate = _regeneratorRuntime.mark(function callee$0$0(parser, useUTC) {
|
|
1128
|
-
var days;
|
|
1129
|
-
return _regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
1130
|
-
while (1) switch (context$1$0.prev = context$1$0.next) {
|
|
1131
|
-
case 0:
|
|
1132
|
-
return context$1$0.delegateYield(parser.readUInt24LE(), 't0', 1);
|
|
1133
565
|
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
break;
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
return context$1$0.abrupt('return', new Date(Date.UTC(2000, 0, days - 730118)));
|
|
1143
|
-
|
|
1144
|
-
case 6:
|
|
1145
|
-
return context$1$0.abrupt('return', new Date(2000, 0, days - 730118));
|
|
1146
|
-
|
|
1147
|
-
case 7:
|
|
1148
|
-
case 'end':
|
|
1149
|
-
return context$1$0.stop();
|
|
566
|
+
var date = undefined;
|
|
567
|
+
if (useUTC) {
|
|
568
|
+
date = new Date(Date.UTC(1970, 0, 1, 0, 0, 0, value / 10000));
|
|
569
|
+
} else {
|
|
570
|
+
date = new Date(1970, 0, 1, 0, 0, 0, value / 10000);
|
|
1150
571
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
case 3:
|
|
1166
|
-
days = context$1$0.t1;
|
|
1167
|
-
|
|
1168
|
-
if (useUTC) {
|
|
1169
|
-
date = new Date(Date.UTC(2000, 0, days - 730118, 0, 0, 0, +time));
|
|
1170
|
-
} else {
|
|
1171
|
-
date = new Date(2000, 0, days - 730118, time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds());
|
|
1172
|
-
}
|
|
1173
|
-
Object.defineProperty(date, "nanosecondsDelta", {
|
|
1174
|
-
enumerable: false,
|
|
1175
|
-
value: time.nanosecondsDelta
|
|
1176
|
-
});
|
|
1177
|
-
return context$1$0.abrupt('return', date);
|
|
1178
|
-
|
|
1179
|
-
case 7:
|
|
1180
|
-
case 'end':
|
|
1181
|
-
return context$1$0.stop();
|
|
572
|
+
Object.defineProperty(date, 'nanosecondsDelta', {
|
|
573
|
+
enumerable: false,
|
|
574
|
+
value: value % 10000 / Math.pow(10, 7)
|
|
575
|
+
});
|
|
576
|
+
callback(date);
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function readDate(parser, useUTC, callback) {
|
|
581
|
+
parser.readUInt24LE(function (days) {
|
|
582
|
+
if (useUTC) {
|
|
583
|
+
callback(new Date(Date.UTC(2000, 0, days - 730118)));
|
|
584
|
+
} else {
|
|
585
|
+
callback(new Date(2000, 0, days - 730118));
|
|
1182
586
|
}
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
return context$1$0.delegateYield(readTime(parser, dataLength - 5, scale, true), 't0', 1);
|
|
1192
|
-
|
|
1193
|
-
case 1:
|
|
1194
|
-
time = context$1$0.t0;
|
|
1195
|
-
return context$1$0.delegateYield(parser.readUInt24LE(), 't1', 3);
|
|
1196
|
-
|
|
1197
|
-
case 3:
|
|
1198
|
-
days = context$1$0.t1;
|
|
1199
|
-
context$1$0.next = 6;
|
|
1200
|
-
return parser.readInt16LE();
|
|
1201
|
-
|
|
1202
|
-
case 6:
|
|
1203
|
-
offset = context$1$0.sent;
|
|
1204
|
-
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function readDateTime2(parser, dataLength, scale, useUTC, callback) {
|
|
591
|
+
readTime(parser, dataLength - 3, scale, useUTC, function (time) {
|
|
592
|
+
parser.readUInt24LE(function (days) {
|
|
593
|
+
var date = undefined;
|
|
594
|
+
if (useUTC) {
|
|
1205
595
|
date = new Date(Date.UTC(2000, 0, days - 730118, 0, 0, 0, +time));
|
|
1206
|
-
|
|
596
|
+
} else {
|
|
597
|
+
date = new Date(2000, 0, days - 730118, time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds());
|
|
598
|
+
}
|
|
599
|
+
Object.defineProperty(date, 'nanosecondsDelta', {
|
|
600
|
+
enumerable: false,
|
|
601
|
+
value: time.nanosecondsDelta
|
|
602
|
+
});
|
|
603
|
+
callback(date);
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function readDateTimeOffset(parser, dataLength, scale, callback) {
|
|
609
|
+
readTime(parser, dataLength - 5, scale, true, function (time) {
|
|
610
|
+
parser.readUInt24LE(function (days) {
|
|
611
|
+
// offset
|
|
612
|
+
parser.readInt16LE(function () {
|
|
613
|
+
var date = new Date(Date.UTC(2000, 0, days - 730118, 0, 0, 0, +time));
|
|
614
|
+
Object.defineProperty(date, 'nanosecondsDelta', {
|
|
1207
615
|
enumerable: false,
|
|
1208
616
|
value: time.nanosecondsDelta
|
|
1209
617
|
});
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
}
|
|
1216
|
-
}, callee$0$0, this);
|
|
1217
|
-
});
|
|
618
|
+
callback(date);
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
}
|