@loaders.gl/netcdf 3.4.13 → 3.4.15
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/dist/es5/index.js +2 -2
- package/dist/es5/iobuffer/iobuffer.js +223 -314
- package/dist/es5/iobuffer/iobuffer.js.map +1 -1
- package/dist/es5/netcdf-loader.js +12 -45
- package/dist/es5/netcdf-loader.js.map +1 -1
- package/dist/es5/netcdfjs/netcdf-reader.js +78 -139
- package/dist/es5/netcdfjs/netcdf-reader.js.map +1 -1
- package/dist/es5/netcdfjs/read-data.js +11 -11
- package/dist/es5/netcdfjs/read-data.js.map +1 -1
- package/dist/es5/netcdfjs/read-header.js +58 -58
- package/dist/es5/netcdfjs/read-header.js.map +1 -1
- package/dist/es5/netcdfjs/read-type.js +3 -3
- package/dist/es5/netcdfjs/read-type.js.map +1 -1
- package/dist/esm/netcdf-loader.js +1 -1
- package/package.json +3 -3
package/dist/es5/index.js
CHANGED
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "NetCDFLoader", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _netcdfLoader.NetCDFLoader;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "NetCDFReader", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _netcdfReader.NetCDFReader;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
@@ -5,15 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.IOBuffer = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(0, _classCallCheck2.default)(this, IOBuffer);
|
|
9
|
+
const DEFAULT_BYTE_LENGTH = 1024 * 8;
|
|
10
|
+
class IOBuffer {
|
|
11
|
+
constructor() {
|
|
12
|
+
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BYTE_LENGTH;
|
|
13
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
17
14
|
(0, _defineProperty2.default)(this, "buffer", void 0);
|
|
18
15
|
(0, _defineProperty2.default)(this, "byteLength", void 0);
|
|
19
16
|
(0, _defineProperty2.default)(this, "byteOffset", void 0);
|
|
@@ -26,16 +23,16 @@ var IOBuffer = function () {
|
|
|
26
23
|
(0, _defineProperty2.default)(this, "_marks", void 0);
|
|
27
24
|
(0, _defineProperty2.default)(this, "textDecoder", new TextDecoder());
|
|
28
25
|
(0, _defineProperty2.default)(this, "textEncoder", new TextEncoder());
|
|
29
|
-
|
|
26
|
+
let dataIsGiven = false;
|
|
30
27
|
if (typeof data === 'number') {
|
|
31
28
|
data = new ArrayBuffer(data);
|
|
32
29
|
} else {
|
|
33
30
|
dataIsGiven = true;
|
|
34
31
|
this.lastWrittenByte = data.byteLength;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
const offset = options.offset ? options.offset >>> 0 : 0;
|
|
34
|
+
const byteLength = data.byteLength - offset;
|
|
35
|
+
let dvOffset = offset;
|
|
39
36
|
if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {
|
|
40
37
|
if (data.byteLength !== data.buffer.byteLength) {
|
|
41
38
|
dvOffset = data.byteOffset + offset;
|
|
@@ -57,313 +54,225 @@ var IOBuffer = function () {
|
|
|
57
54
|
this._mark = 0;
|
|
58
55
|
this._marks = [];
|
|
59
56
|
}
|
|
60
|
-
(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
value: function mark() {
|
|
104
|
-
this._mark = this.offset;
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: "reset",
|
|
109
|
-
value: function reset() {
|
|
110
|
-
this.offset = this._mark;
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "pushMark",
|
|
115
|
-
value: function pushMark() {
|
|
116
|
-
this._marks.push(this.offset);
|
|
117
|
-
return this;
|
|
118
|
-
}
|
|
119
|
-
}, {
|
|
120
|
-
key: "popMark",
|
|
121
|
-
value: function popMark() {
|
|
122
|
-
var offset = this._marks.pop();
|
|
123
|
-
if (offset === undefined) {
|
|
124
|
-
throw new Error('Mark stack empty');
|
|
125
|
-
}
|
|
126
|
-
this.seek(offset);
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "rewind",
|
|
131
|
-
value: function rewind() {
|
|
132
|
-
this.offset = 0;
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
}, {
|
|
136
|
-
key: "ensureAvailable",
|
|
137
|
-
value: function ensureAvailable() {
|
|
138
|
-
var byteLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
139
|
-
if (!this.available(byteLength)) {
|
|
140
|
-
var lengthNeeded = this.offset + byteLength;
|
|
141
|
-
var newLength = lengthNeeded * 2;
|
|
142
|
-
var newArray = new Uint8Array(newLength);
|
|
143
|
-
newArray.set(new Uint8Array(this.buffer));
|
|
144
|
-
this.buffer = newArray.buffer;
|
|
145
|
-
this.length = this.byteLength = newLength;
|
|
146
|
-
this._data = new DataView(this.buffer);
|
|
147
|
-
}
|
|
148
|
-
return this;
|
|
149
|
-
}
|
|
150
|
-
}, {
|
|
151
|
-
key: "readBoolean",
|
|
152
|
-
value: function readBoolean() {
|
|
153
|
-
return this.readUint8() !== 0;
|
|
154
|
-
}
|
|
155
|
-
}, {
|
|
156
|
-
key: "readInt8",
|
|
157
|
-
value: function readInt8() {
|
|
158
|
-
return this._data.getInt8(this.offset++);
|
|
159
|
-
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "readUint8",
|
|
162
|
-
value: function readUint8() {
|
|
163
|
-
return this._data.getUint8(this.offset++);
|
|
164
|
-
}
|
|
165
|
-
}, {
|
|
166
|
-
key: "readByte",
|
|
167
|
-
value: function readByte() {
|
|
168
|
-
return this.readUint8();
|
|
169
|
-
}
|
|
170
|
-
}, {
|
|
171
|
-
key: "readBytes",
|
|
172
|
-
value: function readBytes() {
|
|
173
|
-
var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
174
|
-
var bytes = new Uint8Array(n);
|
|
175
|
-
for (var i = 0; i < n; i++) {
|
|
176
|
-
bytes[i] = this.readByte();
|
|
177
|
-
}
|
|
178
|
-
return bytes;
|
|
179
|
-
}
|
|
180
|
-
}, {
|
|
181
|
-
key: "readInt16",
|
|
182
|
-
value: function readInt16() {
|
|
183
|
-
var value = this._data.getInt16(this.offset, this.littleEndian);
|
|
184
|
-
this.offset += 2;
|
|
185
|
-
return value;
|
|
186
|
-
}
|
|
187
|
-
}, {
|
|
188
|
-
key: "readUint16",
|
|
189
|
-
value: function readUint16() {
|
|
190
|
-
var value = this._data.getUint16(this.offset, this.littleEndian);
|
|
191
|
-
this.offset += 2;
|
|
192
|
-
return value;
|
|
193
|
-
}
|
|
194
|
-
}, {
|
|
195
|
-
key: "readInt32",
|
|
196
|
-
value: function readInt32() {
|
|
197
|
-
var value = this._data.getInt32(this.offset, this.littleEndian);
|
|
198
|
-
this.offset += 4;
|
|
199
|
-
return value;
|
|
200
|
-
}
|
|
201
|
-
}, {
|
|
202
|
-
key: "readUint32",
|
|
203
|
-
value: function readUint32() {
|
|
204
|
-
var value = this._data.getUint32(this.offset, this.littleEndian);
|
|
205
|
-
this.offset += 4;
|
|
206
|
-
return value;
|
|
207
|
-
}
|
|
208
|
-
}, {
|
|
209
|
-
key: "readFloat32",
|
|
210
|
-
value: function readFloat32() {
|
|
211
|
-
var value = this._data.getFloat32(this.offset, this.littleEndian);
|
|
212
|
-
this.offset += 4;
|
|
213
|
-
return value;
|
|
214
|
-
}
|
|
215
|
-
}, {
|
|
216
|
-
key: "readFloat64",
|
|
217
|
-
value: function readFloat64() {
|
|
218
|
-
var value = this._data.getFloat64(this.offset, this.littleEndian);
|
|
219
|
-
this.offset += 8;
|
|
220
|
-
return value;
|
|
221
|
-
}
|
|
222
|
-
}, {
|
|
223
|
-
key: "readChar",
|
|
224
|
-
value: function readChar() {
|
|
225
|
-
return String.fromCharCode(this.readInt8());
|
|
226
|
-
}
|
|
227
|
-
}, {
|
|
228
|
-
key: "readChars",
|
|
229
|
-
value: function readChars() {
|
|
230
|
-
var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
231
|
-
var result = '';
|
|
232
|
-
for (var i = 0; i < n; i++) {
|
|
233
|
-
result += this.readChar();
|
|
234
|
-
}
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
}, {
|
|
238
|
-
key: "readUtf8",
|
|
239
|
-
value: function readUtf8() {
|
|
240
|
-
var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
241
|
-
return this.textDecoder.decode(this.readBytes(n));
|
|
242
|
-
}
|
|
243
|
-
}, {
|
|
244
|
-
key: "writeBoolean",
|
|
245
|
-
value: function writeBoolean(value) {
|
|
246
|
-
this.writeUint8(value ? 0xff : 0x00);
|
|
247
|
-
return this;
|
|
248
|
-
}
|
|
249
|
-
}, {
|
|
250
|
-
key: "writeInt8",
|
|
251
|
-
value: function writeInt8(value) {
|
|
252
|
-
this.ensureAvailable(1);
|
|
253
|
-
this._data.setInt8(this.offset++, value);
|
|
254
|
-
this._updateLastWrittenByte();
|
|
255
|
-
return this;
|
|
256
|
-
}
|
|
257
|
-
}, {
|
|
258
|
-
key: "writeUint8",
|
|
259
|
-
value: function writeUint8(value) {
|
|
260
|
-
this.ensureAvailable(1);
|
|
261
|
-
this._data.setUint8(this.offset++, value);
|
|
262
|
-
this._updateLastWrittenByte();
|
|
263
|
-
return this;
|
|
264
|
-
}
|
|
265
|
-
}, {
|
|
266
|
-
key: "writeByte",
|
|
267
|
-
value: function writeByte(value) {
|
|
268
|
-
return this.writeUint8(value);
|
|
269
|
-
}
|
|
270
|
-
}, {
|
|
271
|
-
key: "writeBytes",
|
|
272
|
-
value: function writeBytes(bytes) {
|
|
273
|
-
this.ensureAvailable(bytes.length);
|
|
274
|
-
for (var i = 0; i < bytes.length; i++) {
|
|
275
|
-
this._data.setUint8(this.offset++, bytes[i]);
|
|
276
|
-
}
|
|
277
|
-
this._updateLastWrittenByte();
|
|
278
|
-
return this;
|
|
279
|
-
}
|
|
280
|
-
}, {
|
|
281
|
-
key: "writeInt16",
|
|
282
|
-
value: function writeInt16(value) {
|
|
283
|
-
this.ensureAvailable(2);
|
|
284
|
-
this._data.setInt16(this.offset, value, this.littleEndian);
|
|
285
|
-
this.offset += 2;
|
|
286
|
-
this._updateLastWrittenByte();
|
|
287
|
-
return this;
|
|
288
|
-
}
|
|
289
|
-
}, {
|
|
290
|
-
key: "writeUint16",
|
|
291
|
-
value: function writeUint16(value) {
|
|
292
|
-
this.ensureAvailable(2);
|
|
293
|
-
this._data.setUint16(this.offset, value, this.littleEndian);
|
|
294
|
-
this.offset += 2;
|
|
295
|
-
this._updateLastWrittenByte();
|
|
296
|
-
return this;
|
|
297
|
-
}
|
|
298
|
-
}, {
|
|
299
|
-
key: "writeInt32",
|
|
300
|
-
value: function writeInt32(value) {
|
|
301
|
-
this.ensureAvailable(4);
|
|
302
|
-
this._data.setInt32(this.offset, value, this.littleEndian);
|
|
303
|
-
this.offset += 4;
|
|
304
|
-
this._updateLastWrittenByte();
|
|
305
|
-
return this;
|
|
306
|
-
}
|
|
307
|
-
}, {
|
|
308
|
-
key: "writeUint32",
|
|
309
|
-
value: function writeUint32(value) {
|
|
310
|
-
this.ensureAvailable(4);
|
|
311
|
-
this._data.setUint32(this.offset, value, this.littleEndian);
|
|
312
|
-
this.offset += 4;
|
|
313
|
-
this._updateLastWrittenByte();
|
|
314
|
-
return this;
|
|
315
|
-
}
|
|
316
|
-
}, {
|
|
317
|
-
key: "writeFloat32",
|
|
318
|
-
value: function writeFloat32(value) {
|
|
319
|
-
this.ensureAvailable(4);
|
|
320
|
-
this._data.setFloat32(this.offset, value, this.littleEndian);
|
|
321
|
-
this.offset += 4;
|
|
322
|
-
this._updateLastWrittenByte();
|
|
323
|
-
return this;
|
|
324
|
-
}
|
|
325
|
-
}, {
|
|
326
|
-
key: "writeFloat64",
|
|
327
|
-
value: function writeFloat64(value) {
|
|
328
|
-
this.ensureAvailable(8);
|
|
329
|
-
this._data.setFloat64(this.offset, value, this.littleEndian);
|
|
330
|
-
this.offset += 8;
|
|
331
|
-
this._updateLastWrittenByte();
|
|
332
|
-
return this;
|
|
57
|
+
available() {
|
|
58
|
+
let byteLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
59
|
+
return this.offset + byteLength <= this.length;
|
|
60
|
+
}
|
|
61
|
+
isLittleEndian() {
|
|
62
|
+
return this.littleEndian;
|
|
63
|
+
}
|
|
64
|
+
setLittleEndian() {
|
|
65
|
+
this.littleEndian = true;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
isBigEndian() {
|
|
69
|
+
return !this.littleEndian;
|
|
70
|
+
}
|
|
71
|
+
setBigEndian() {
|
|
72
|
+
this.littleEndian = false;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
skip() {
|
|
76
|
+
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
77
|
+
this.offset += n;
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
seek(offset) {
|
|
81
|
+
this.offset = offset;
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
mark() {
|
|
85
|
+
this._mark = this.offset;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
reset() {
|
|
89
|
+
this.offset = this._mark;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
pushMark() {
|
|
93
|
+
this._marks.push(this.offset);
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
popMark() {
|
|
97
|
+
const offset = this._marks.pop();
|
|
98
|
+
if (offset === undefined) {
|
|
99
|
+
throw new Error('Mark stack empty');
|
|
333
100
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
101
|
+
this.seek(offset);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
rewind() {
|
|
105
|
+
this.offset = 0;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
ensureAvailable() {
|
|
109
|
+
let byteLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
110
|
+
if (!this.available(byteLength)) {
|
|
111
|
+
const lengthNeeded = this.offset + byteLength;
|
|
112
|
+
const newLength = lengthNeeded * 2;
|
|
113
|
+
const newArray = new Uint8Array(newLength);
|
|
114
|
+
newArray.set(new Uint8Array(this.buffer));
|
|
115
|
+
this.buffer = newArray.buffer;
|
|
116
|
+
this.length = this.byteLength = newLength;
|
|
117
|
+
this._data = new DataView(this.buffer);
|
|
118
|
+
}
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
readBoolean() {
|
|
122
|
+
return this.readUint8() !== 0;
|
|
123
|
+
}
|
|
124
|
+
readInt8() {
|
|
125
|
+
return this._data.getInt8(this.offset++);
|
|
126
|
+
}
|
|
127
|
+
readUint8() {
|
|
128
|
+
return this._data.getUint8(this.offset++);
|
|
129
|
+
}
|
|
130
|
+
readByte() {
|
|
131
|
+
return this.readUint8();
|
|
132
|
+
}
|
|
133
|
+
readBytes() {
|
|
134
|
+
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
135
|
+
const bytes = new Uint8Array(n);
|
|
136
|
+
for (let i = 0; i < n; i++) {
|
|
137
|
+
bytes[i] = this.readByte();
|
|
338
138
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
139
|
+
return bytes;
|
|
140
|
+
}
|
|
141
|
+
readInt16() {
|
|
142
|
+
const value = this._data.getInt16(this.offset, this.littleEndian);
|
|
143
|
+
this.offset += 2;
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
readUint16() {
|
|
147
|
+
const value = this._data.getUint16(this.offset, this.littleEndian);
|
|
148
|
+
this.offset += 2;
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
readInt32() {
|
|
152
|
+
const value = this._data.getInt32(this.offset, this.littleEndian);
|
|
153
|
+
this.offset += 4;
|
|
154
|
+
return value;
|
|
155
|
+
}
|
|
156
|
+
readUint32() {
|
|
157
|
+
const value = this._data.getUint32(this.offset, this.littleEndian);
|
|
158
|
+
this.offset += 4;
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
readFloat32() {
|
|
162
|
+
const value = this._data.getFloat32(this.offset, this.littleEndian);
|
|
163
|
+
this.offset += 4;
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
readFloat64() {
|
|
167
|
+
const value = this._data.getFloat64(this.offset, this.littleEndian);
|
|
168
|
+
this.offset += 8;
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
readChar() {
|
|
172
|
+
return String.fromCharCode(this.readInt8());
|
|
173
|
+
}
|
|
174
|
+
readChars() {
|
|
175
|
+
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
176
|
+
let result = '';
|
|
177
|
+
for (let i = 0; i < n; i++) {
|
|
178
|
+
result += this.readChar();
|
|
346
179
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
readUtf8() {
|
|
183
|
+
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
184
|
+
return this.textDecoder.decode(this.readBytes(n));
|
|
185
|
+
}
|
|
186
|
+
writeBoolean(value) {
|
|
187
|
+
this.writeUint8(value ? 0xff : 0x00);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
writeInt8(value) {
|
|
191
|
+
this.ensureAvailable(1);
|
|
192
|
+
this._data.setInt8(this.offset++, value);
|
|
193
|
+
this._updateLastWrittenByte();
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
writeUint8(value) {
|
|
197
|
+
this.ensureAvailable(1);
|
|
198
|
+
this._data.setUint8(this.offset++, value);
|
|
199
|
+
this._updateLastWrittenByte();
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
writeByte(value) {
|
|
203
|
+
return this.writeUint8(value);
|
|
204
|
+
}
|
|
205
|
+
writeBytes(bytes) {
|
|
206
|
+
this.ensureAvailable(bytes.length);
|
|
207
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
208
|
+
this._data.setUint8(this.offset++, bytes[i]);
|
|
352
209
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
210
|
+
this._updateLastWrittenByte();
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
writeInt16(value) {
|
|
214
|
+
this.ensureAvailable(2);
|
|
215
|
+
this._data.setInt16(this.offset, value, this.littleEndian);
|
|
216
|
+
this.offset += 2;
|
|
217
|
+
this._updateLastWrittenByte();
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
writeUint16(value) {
|
|
221
|
+
this.ensureAvailable(2);
|
|
222
|
+
this._data.setUint16(this.offset, value, this.littleEndian);
|
|
223
|
+
this.offset += 2;
|
|
224
|
+
this._updateLastWrittenByte();
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
writeInt32(value) {
|
|
228
|
+
this.ensureAvailable(4);
|
|
229
|
+
this._data.setInt32(this.offset, value, this.littleEndian);
|
|
230
|
+
this.offset += 4;
|
|
231
|
+
this._updateLastWrittenByte();
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
writeUint32(value) {
|
|
235
|
+
this.ensureAvailable(4);
|
|
236
|
+
this._data.setUint32(this.offset, value, this.littleEndian);
|
|
237
|
+
this.offset += 4;
|
|
238
|
+
this._updateLastWrittenByte();
|
|
239
|
+
return this;
|
|
240
|
+
}
|
|
241
|
+
writeFloat32(value) {
|
|
242
|
+
this.ensureAvailable(4);
|
|
243
|
+
this._data.setFloat32(this.offset, value, this.littleEndian);
|
|
244
|
+
this.offset += 4;
|
|
245
|
+
this._updateLastWrittenByte();
|
|
246
|
+
return this;
|
|
247
|
+
}
|
|
248
|
+
writeFloat64(value) {
|
|
249
|
+
this.ensureAvailable(8);
|
|
250
|
+
this._data.setFloat64(this.offset, value, this.littleEndian);
|
|
251
|
+
this.offset += 8;
|
|
252
|
+
this._updateLastWrittenByte();
|
|
253
|
+
return this;
|
|
254
|
+
}
|
|
255
|
+
writeChar(str) {
|
|
256
|
+
return this.writeUint8(str.charCodeAt(0));
|
|
257
|
+
}
|
|
258
|
+
writeChars(str) {
|
|
259
|
+
for (let i = 0; i < str.length; i++) {
|
|
260
|
+
this.writeUint8(str.charCodeAt(i));
|
|
357
261
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
writeUtf8(str) {
|
|
265
|
+
const bytes = this.textEncoder.encode(str);
|
|
266
|
+
return this.writeBytes(bytes);
|
|
267
|
+
}
|
|
268
|
+
toArray() {
|
|
269
|
+
return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
|
|
270
|
+
}
|
|
271
|
+
_updateLastWrittenByte() {
|
|
272
|
+
if (this.offset > this.lastWrittenByte) {
|
|
273
|
+
this.lastWrittenByte = this.offset;
|
|
364
274
|
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
}();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
368
277
|
exports.IOBuffer = IOBuffer;
|
|
369
278
|
//# sourceMappingURL=iobuffer.js.map
|