@abasb75/dicom-parser 0.0.0-test1 → 0.0.0-test11

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/Dataset.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ import { DicomDate, DicomPatientModule, DicomPixelModule, DicomScalingModule, DicomTime, DicomVOILutModule, Tags } from "./types";
2
+ declare class Dataset {
3
+ /** duration of parse */
4
+ start: number;
5
+ end: number | undefined;
6
+ tags: Tags;
7
+ transferSyntaxUID: string;
8
+ dataView: DataView;
9
+ studyInstanceUID: string;
10
+ studyID: string;
11
+ seriesInstanceUID: string;
12
+ seriesNumber: number | string | undefined;
13
+ studyDate: string | DicomDate;
14
+ studyTime: number | DicomTime | string | undefined;
15
+ pixelRepresentation: number | string | undefined;
16
+ littleEndian: boolean;
17
+ pixeSpacing: number | number[] | string | undefined;
18
+ accessionNumber: string;
19
+ bitsAllocated: number | string | undefined;
20
+ bitsStored: number | string | undefined;
21
+ highBit: number | string | undefined;
22
+ imageType: number | string | number[] | string[] | undefined;
23
+ modality: number | string | number[] | string[] | undefined;
24
+ seriesDescription: string;
25
+ rows: string | number | undefined;
26
+ columns: string | number | undefined;
27
+ patientSex: any;
28
+ /** modules */
29
+ voiLUTModule: DicomVOILutModule;
30
+ patientModule: DicomPatientModule;
31
+ pixelModule: DicomPixelModule;
32
+ scalingModule: DicomScalingModule;
33
+ constructor(tags: Tags, dataView: DataView, littleEndian: boolean, start: number, end: number);
34
+ hasPixelData(): boolean;
35
+ getPixelData(frame?: number): Promise<DataView>;
36
+ getVOILutModule(): DicomVOILutModule;
37
+ getPatientModule(): DicomPatientModule;
38
+ getPixelModule(): DicomPixelModule;
39
+ getScalingModule(): DicomScalingModule;
40
+ date(group: number, element: number): string | {
41
+ year: string;
42
+ month: string;
43
+ day: string;
44
+ };
45
+ time(group: number, element: number): string | {
46
+ hour: string;
47
+ minute: string;
48
+ second: string;
49
+ };
50
+ int(group: number, element: number): number | undefined;
51
+ get(group: number, element: number): string;
52
+ string(group: number, element: number): string;
53
+ getValue(element: number | string, elementId?: number | string, vr?: string): string | number | DataView | (string | number)[] | undefined;
54
+ private _getValue;
55
+ private _reformatToString;
56
+ }
57
+ export default Dataset;
package/Dataset.js ADDED
@@ -0,0 +1,469 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import PixelData from "./PixelData";
38
+ import Tag from "./Tag";
39
+ import Value from "./Value";
40
+ var Dataset = /** @class */ (function () {
41
+ function Dataset(tags, dataView, littleEndian, start, end) {
42
+ /** duration of parse */
43
+ Object.defineProperty(this, "start", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: void 0
48
+ });
49
+ Object.defineProperty(this, "end", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: void 0
54
+ });
55
+ Object.defineProperty(this, "tags", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: void 0
60
+ });
61
+ Object.defineProperty(this, "transferSyntaxUID", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: "1.2.840.10008.1.2"
66
+ });
67
+ Object.defineProperty(this, "dataView", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: void 0
72
+ });
73
+ Object.defineProperty(this, "studyInstanceUID", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: ""
78
+ });
79
+ Object.defineProperty(this, "studyID", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: ""
84
+ });
85
+ Object.defineProperty(this, "seriesInstanceUID", {
86
+ enumerable: true,
87
+ configurable: true,
88
+ writable: true,
89
+ value: void 0
90
+ });
91
+ Object.defineProperty(this, "seriesNumber", {
92
+ enumerable: true,
93
+ configurable: true,
94
+ writable: true,
95
+ value: void 0
96
+ });
97
+ Object.defineProperty(this, "studyDate", {
98
+ enumerable: true,
99
+ configurable: true,
100
+ writable: true,
101
+ value: void 0
102
+ });
103
+ Object.defineProperty(this, "studyTime", {
104
+ enumerable: true,
105
+ configurable: true,
106
+ writable: true,
107
+ value: void 0
108
+ });
109
+ Object.defineProperty(this, "pixelRepresentation", {
110
+ enumerable: true,
111
+ configurable: true,
112
+ writable: true,
113
+ value: void 0
114
+ });
115
+ Object.defineProperty(this, "littleEndian", {
116
+ enumerable: true,
117
+ configurable: true,
118
+ writable: true,
119
+ value: void 0
120
+ });
121
+ Object.defineProperty(this, "pixeSpacing", {
122
+ enumerable: true,
123
+ configurable: true,
124
+ writable: true,
125
+ value: void 0
126
+ });
127
+ Object.defineProperty(this, "accessionNumber", {
128
+ enumerable: true,
129
+ configurable: true,
130
+ writable: true,
131
+ value: void 0
132
+ });
133
+ Object.defineProperty(this, "bitsAllocated", {
134
+ enumerable: true,
135
+ configurable: true,
136
+ writable: true,
137
+ value: void 0
138
+ });
139
+ Object.defineProperty(this, "bitsStored", {
140
+ enumerable: true,
141
+ configurable: true,
142
+ writable: true,
143
+ value: void 0
144
+ });
145
+ Object.defineProperty(this, "highBit", {
146
+ enumerable: true,
147
+ configurable: true,
148
+ writable: true,
149
+ value: void 0
150
+ });
151
+ Object.defineProperty(this, "imageType", {
152
+ enumerable: true,
153
+ configurable: true,
154
+ writable: true,
155
+ value: void 0
156
+ });
157
+ Object.defineProperty(this, "modality", {
158
+ enumerable: true,
159
+ configurable: true,
160
+ writable: true,
161
+ value: void 0
162
+ });
163
+ Object.defineProperty(this, "seriesDescription", {
164
+ enumerable: true,
165
+ configurable: true,
166
+ writable: true,
167
+ value: void 0
168
+ });
169
+ Object.defineProperty(this, "rows", {
170
+ enumerable: true,
171
+ configurable: true,
172
+ writable: true,
173
+ value: void 0
174
+ });
175
+ Object.defineProperty(this, "columns", {
176
+ enumerable: true,
177
+ configurable: true,
178
+ writable: true,
179
+ value: void 0
180
+ });
181
+ Object.defineProperty(this, "patientSex", {
182
+ enumerable: true,
183
+ configurable: true,
184
+ writable: true,
185
+ value: void 0
186
+ });
187
+ /** modules */
188
+ Object.defineProperty(this, "voiLUTModule", {
189
+ enumerable: true,
190
+ configurable: true,
191
+ writable: true,
192
+ value: void 0
193
+ });
194
+ Object.defineProperty(this, "patientModule", {
195
+ enumerable: true,
196
+ configurable: true,
197
+ writable: true,
198
+ value: void 0
199
+ });
200
+ Object.defineProperty(this, "pixelModule", {
201
+ enumerable: true,
202
+ configurable: true,
203
+ writable: true,
204
+ value: void 0
205
+ });
206
+ Object.defineProperty(this, "scalingModule", {
207
+ enumerable: true,
208
+ configurable: true,
209
+ writable: true,
210
+ value: void 0
211
+ });
212
+ this.tags = tags;
213
+ this.dataView = dataView;
214
+ this.littleEndian = littleEndian;
215
+ this.studyID = this.get(0x0020, 0x0010);
216
+ this.studyInstanceUID = this.string(0x0020, 0x000D);
217
+ this.seriesInstanceUID = this.get(0x0020, 0x000E);
218
+ this.seriesNumber = this.get(0x0020, 0x0011);
219
+ this.studyDate = this.date(0x0008, 0x0020);
220
+ this.studyTime = this.time(0x0008, 0x0030);
221
+ this.accessionNumber = this.string(0x0008, 0x0050);
222
+ this.imageType = this.get(0x0008, 0x0008);
223
+ this.modality = this.get(0x0008, 0x0060);
224
+ this.seriesDescription = this.string(0x0008, 0x103E);
225
+ this.patientSex = this.get(0x0010, 0x0040);
226
+ this.voiLUTModule = this.getVOILutModule();
227
+ this.patientModule = this.getPatientModule();
228
+ this.pixelModule = this.getPixelModule();
229
+ this.scalingModule = this.getScalingModule();
230
+ this.start = start;
231
+ this.end = end;
232
+ }
233
+ Object.defineProperty(Dataset.prototype, "hasPixelData", {
234
+ enumerable: false,
235
+ configurable: true,
236
+ writable: true,
237
+ value: function () {
238
+ if (this.tags['0x7FE00010']
239
+ || this.tags['0x7FE00008']
240
+ || this.tags['0x7FE00009']) {
241
+ return true;
242
+ }
243
+ return false;
244
+ }
245
+ });
246
+ Object.defineProperty(Dataset.prototype, "getPixelData", {
247
+ enumerable: false,
248
+ configurable: true,
249
+ writable: true,
250
+ value: function () {
251
+ return __awaiter(this, arguments, void 0, function (frame) {
252
+ if (frame === void 0) { frame = 0; }
253
+ return __generator(this, function (_a) {
254
+ switch (_a.label) {
255
+ case 0: return [4 /*yield*/, PixelData.get(this, frame)];
256
+ case 1: return [2 /*return*/, _a.sent()];
257
+ }
258
+ });
259
+ });
260
+ }
261
+ });
262
+ Object.defineProperty(Dataset.prototype, "getVOILutModule", {
263
+ enumerable: false,
264
+ configurable: true,
265
+ writable: true,
266
+ value: function () {
267
+ return {
268
+ voiLUTFunction: this.get(0x0028, 0x1056),
269
+ windowWidth: this.int(0x0028, 0x1051),
270
+ windowCenter: this.int(0x0028, 0x1050),
271
+ voiLUTSequence: this.get(0x0028, 0x3010),
272
+ lutDescriptor: this.get(0x0028, 0x3002),
273
+ lutExplanation: this.get(0x0028, 0x3003),
274
+ lutData: this.get(0x0028, 0x3006),
275
+ windowCenterAndWidthExplanation: this.get(0x0028, 0x1055),
276
+ };
277
+ }
278
+ });
279
+ Object.defineProperty(Dataset.prototype, "getPatientModule", {
280
+ enumerable: false,
281
+ configurable: true,
282
+ writable: true,
283
+ value: function () {
284
+ return {
285
+ patientName: this.get(0x0010, 0x0010),
286
+ patientID: this.get(0x0010, 0x0020),
287
+ typeofPatientID: this.get(0x0010, 0x0022),
288
+ patientSex: this.get(0x0010, 0x0040),
289
+ patientBirthDate: this.get(0x0010, 0x0030),
290
+ patientAge: this.get(0x0010, 0x1010),
291
+ patientSize: this.get(0x0010, 0x1020),
292
+ otherPatientIDs: this.get(0x0010, 0x1000),
293
+ otherPatientNames: this.get(0x0010, 0x1001),
294
+ patientWeight: this.get(0x0010, 0x1030),
295
+ };
296
+ }
297
+ });
298
+ Object.defineProperty(Dataset.prototype, "getPixelModule", {
299
+ enumerable: false,
300
+ configurable: true,
301
+ writable: true,
302
+ value: function () {
303
+ return {
304
+ photometricInterpretation: this.get(0x0028, 0x0004),
305
+ numberOfFrames: this.int(0x0028, 0x0008),
306
+ pixelRepresentation: this.int(0x0028, 0x0103),
307
+ pixeSpacing: this.get(0x0028, 0x0030),
308
+ rows: this.int(0x0028, 0x0010),
309
+ columns: this.int(0x0028, 0x0011),
310
+ bitsAllocated: this.int(0x0028, 0x0100),
311
+ highBit: this.int(0x0028, 0x0102),
312
+ bitsStored: this.int(0x0028, 0x0101),
313
+ samplesPerPixel: this.int(0x0028, 0x0002),
314
+ pixelDataProviderURL: this.get(0x0028, 0x7FE0),
315
+ pixelPaddingRangeLimit: this.get(0x0028, 0x0121),
316
+ extendedOffsetTable: this.get(0x7FE0, 0x0001),
317
+ extendedOffsetTableLengths: this.get(0x7FE0, 0x0002),
318
+ pixelAspectRatio: this.get(0x0028, 0x0034)
319
+ };
320
+ }
321
+ });
322
+ Object.defineProperty(Dataset.prototype, "getScalingModule", {
323
+ enumerable: false,
324
+ configurable: true,
325
+ writable: true,
326
+ value: function () {
327
+ return {
328
+ rescaleSlope: this.int(0x0028, 0x1053),
329
+ rescaleIntercept: this.int(0x0028, 0x1052),
330
+ modality: this.modality,
331
+ };
332
+ }
333
+ });
334
+ Object.defineProperty(Dataset.prototype, "date", {
335
+ enumerable: false,
336
+ configurable: true,
337
+ writable: true,
338
+ value: function (group, element) {
339
+ var dateValue = this.get(group, element);
340
+ if (/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/.exec(dateValue)) {
341
+ var dateVaues = dateValue.split('-');
342
+ return {
343
+ year: dateVaues[0],
344
+ month: dateVaues[1],
345
+ day: dateVaues[2],
346
+ };
347
+ }
348
+ return dateValue;
349
+ }
350
+ });
351
+ Object.defineProperty(Dataset.prototype, "time", {
352
+ enumerable: false,
353
+ configurable: true,
354
+ writable: true,
355
+ value: function (group, element) {
356
+ var dateValue = this.get(group, element);
357
+ if (/^[0-9]{2}\:[0-9]{2}\:[0-9]{2}$/.exec(dateValue)) {
358
+ var dateVaues = dateValue.split(':');
359
+ return {
360
+ hour: dateVaues[0],
361
+ minute: dateVaues[1],
362
+ second: dateVaues[2],
363
+ };
364
+ }
365
+ return dateValue;
366
+ }
367
+ });
368
+ Object.defineProperty(Dataset.prototype, "int", {
369
+ enumerable: false,
370
+ configurable: true,
371
+ writable: true,
372
+ value: function (group, element) {
373
+ var is = this.get(group, element);
374
+ if (typeof is === "number") {
375
+ return is;
376
+ }
377
+ else if (Array.isArray(is) && typeof is[0] === "number") {
378
+ return is[0];
379
+ }
380
+ else {
381
+ return undefined;
382
+ }
383
+ }
384
+ });
385
+ Object.defineProperty(Dataset.prototype, "get", {
386
+ enumerable: false,
387
+ configurable: true,
388
+ writable: true,
389
+ value: function (group, element) {
390
+ var value = this.getValue(group, element);
391
+ return value;
392
+ }
393
+ });
394
+ Object.defineProperty(Dataset.prototype, "string", {
395
+ enumerable: false,
396
+ configurable: true,
397
+ writable: true,
398
+ value: function (group, element) {
399
+ return this.getValue(group, element, 'string') + "";
400
+ }
401
+ });
402
+ Object.defineProperty(Dataset.prototype, "getValue", {
403
+ enumerable: false,
404
+ configurable: true,
405
+ writable: true,
406
+ value: function (element, elementId, vr) {
407
+ var _a;
408
+ if (!element && !elementId) {
409
+ return "";
410
+ }
411
+ var _group, _element = "";
412
+ if (typeof element === 'string' && element.length >= 8) {
413
+ var el = element.replace(/^0[xX]/, '');
414
+ if (el.length !== 8) {
415
+ return "";
416
+ }
417
+ _group = el.slice(0, 3);
418
+ _element = el.slice(4, 7);
419
+ }
420
+ else if (typeof element === 'number' && element > 0xffff) {
421
+ var el = Tag.intTo4digitString(element);
422
+ _group = el.slice(0, 3);
423
+ _element = el.slice(4, 7);
424
+ }
425
+ else {
426
+ _group = this._reformatToString(element);
427
+ _element = this._reformatToString(elementId);
428
+ if (!_group || !_element)
429
+ return "";
430
+ }
431
+ var key = "0x".concat(_group).concat(_element);
432
+ if (!this.tags[key]) {
433
+ return "";
434
+ }
435
+ var _vr = vr || ((_a = this.tags[key]) === null || _a === void 0 ? void 0 : _a.vr) || Tag.getTagVRFromDictionary(_group, _element) || "AA";
436
+ return this._getValue(this.tags[key], _vr);
437
+ }
438
+ });
439
+ Object.defineProperty(Dataset.prototype, "_getValue", {
440
+ enumerable: false,
441
+ configurable: true,
442
+ writable: true,
443
+ value: function (tag, vr) {
444
+ if (vr === void 0) { vr = "AA"; }
445
+ var offset = tag.offset;
446
+ if (!offset)
447
+ return "";
448
+ var len = tag.valueLength;
449
+ var value = Value.byVr(this.dataView, offset, len, vr, this.littleEndian);
450
+ tag.value = value;
451
+ return value;
452
+ }
453
+ });
454
+ Object.defineProperty(Dataset.prototype, "_reformatToString", {
455
+ enumerable: false,
456
+ configurable: true,
457
+ writable: true,
458
+ value: function (input) {
459
+ if (!input)
460
+ return "";
461
+ if (typeof input === "string") {
462
+ return input.replace(/^0[xX]/, '');
463
+ }
464
+ return Tag.intTo4digitString(input);
465
+ }
466
+ });
467
+ return Dataset;
468
+ }());
469
+ export default Dataset;
package/Loader.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ declare class Loader {
2
+ private dicomSrc;
3
+ private xhr;
4
+ constructor(dicomSrc?: string);
5
+ load(dicomSrc?: string | File): Promise<ArrayBuffer | undefined>;
6
+ cancel(): void;
7
+ }
8
+ export default Loader;
package/Loader.js ADDED
@@ -0,0 +1,105 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var Loader = /** @class */ (function () {
38
+ function Loader(dicomSrc) {
39
+ Object.defineProperty(this, "dicomSrc", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: void 0
44
+ });
45
+ Object.defineProperty(this, "xhr", {
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true,
49
+ value: void 0
50
+ });
51
+ this.dicomSrc = dicomSrc;
52
+ this.xhr = new XMLHttpRequest();
53
+ }
54
+ Object.defineProperty(Loader.prototype, "load", {
55
+ enumerable: false,
56
+ configurable: true,
57
+ writable: true,
58
+ value: function (dicomSrc) {
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ var dicom_1;
61
+ var _this = this;
62
+ return __generator(this, function (_a) {
63
+ if (typeof dicomSrc === "string") {
64
+ dicom_1 = dicomSrc || this.dicomSrc;
65
+ if (!dicom_1)
66
+ return [2 /*return*/];
67
+ return [2 /*return*/, new Promise(function (resolve, reject) {
68
+ _this.xhr.onload = function () {
69
+ resolve(_this.xhr.response);
70
+ };
71
+ _this.xhr.onerror = function () {
72
+ reject(_this.xhr);
73
+ };
74
+ _this.xhr.responseType = 'arraybuffer';
75
+ _this.xhr.open('GET', dicom_1, true);
76
+ _this.xhr.send();
77
+ })];
78
+ }
79
+ else if (dicomSrc instanceof File) {
80
+ return [2 /*return*/, new Promise(function (resolve, reject) {
81
+ dicomSrc.arrayBuffer().then(function (arrayBuffer) {
82
+ resolve(arrayBuffer);
83
+ }).catch(function (reason) { return reject(reason); });
84
+ })];
85
+ }
86
+ return [2 /*return*/, new Promise(function (resolve, reject) {
87
+ if (false)
88
+ resolve(new ArrayBuffer(1));
89
+ reject("dicom source is not valid");
90
+ })];
91
+ });
92
+ });
93
+ }
94
+ });
95
+ Object.defineProperty(Loader.prototype, "cancel", {
96
+ enumerable: false,
97
+ configurable: true,
98
+ writable: true,
99
+ value: function () {
100
+ this.xhr.abort();
101
+ }
102
+ });
103
+ return Loader;
104
+ }());
105
+ export default Loader;
package/Parser.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import Dataset from "./Dataset";
2
+ declare class Parser {
3
+ private start;
4
+ private end;
5
+ private arrayBuffer;
6
+ private offset;
7
+ private dataView;
8
+ private tags;
9
+ private dataSet;
10
+ private EXEPTED;
11
+ private VRS;
12
+ private IMPLICT_TRANSFER_SYNTAXES;
13
+ private BIG_ENDIAN_TRANSFER_SYNTAXES;
14
+ private DEFLATED_TRANSFER_SYNTAXES;
15
+ private littleEndian;
16
+ private implicit;
17
+ private transferSyntaxUID;
18
+ private inflated;
19
+ constructor(arrayBuffer: ArrayBuffer);
20
+ parse(): Dataset;
21
+ getDataset(): Dataset | undefined;
22
+ getElements(): void;
23
+ getValue(len: number): ArrayBuffer;
24
+ getNextGroupAndElement(): {
25
+ group: number;
26
+ element: number;
27
+ };
28
+ getNextVR(groupInt: number, elementInt: number): string;
29
+ concatArrayBuffers: (buffer1: ArrayBuffer, buffer2: ArrayBuffer) => ArrayBufferLike;
30
+ }
31
+ export default Parser;