pst-extractor 1.8.0 → 1.10.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.
Files changed (64) hide show
  1. package/dist/ColumnDescriptor.class.d.ts +26 -26
  2. package/dist/ColumnDescriptor.class.js +51 -48
  3. package/dist/DescriptorIndexNode.class.d.ts +25 -26
  4. package/dist/DescriptorIndexNode.class.js +53 -53
  5. package/dist/LZFu.class.d.ts +11 -12
  6. package/dist/LZFu.class.js +95 -95
  7. package/dist/NodeInfo.class.d.ts +33 -33
  8. package/dist/NodeInfo.class.js +52 -52
  9. package/dist/NodeMap.class.d.ts +35 -35
  10. package/dist/NodeMap.class.js +86 -83
  11. package/dist/OffsetIndexItem.class.d.ts +23 -24
  12. package/dist/OffsetIndexItem.class.js +45 -45
  13. package/dist/OutlookProperties.d.ts +275 -275
  14. package/dist/OutlookProperties.js +281 -281
  15. package/dist/PSTActivity.class.d.ts +103 -103
  16. package/dist/PSTActivity.class.js +144 -144
  17. package/dist/PSTAppointment.class.d.ts +270 -271
  18. package/dist/PSTAppointment.class.js +376 -376
  19. package/dist/PSTAttachment.class.d.ts +172 -172
  20. package/dist/PSTAttachment.class.js +317 -314
  21. package/dist/PSTContact.class.d.ts +884 -884
  22. package/dist/PSTContact.class.js +1227 -1227
  23. package/dist/PSTDescriptorItem.class.d.ts +45 -46
  24. package/dist/PSTDescriptorItem.class.js +99 -96
  25. package/dist/PSTFile.class.d.ts +215 -216
  26. package/dist/PSTFile.class.js +818 -792
  27. package/dist/PSTFolder.class.d.ts +129 -129
  28. package/dist/PSTFolder.class.js +318 -307
  29. package/dist/PSTMessage.class.d.ts +788 -789
  30. package/dist/PSTMessage.class.js +1321 -1318
  31. package/dist/PSTMessageStore.class.d.ts +13 -13
  32. package/dist/PSTMessageStore.class.js +17 -17
  33. package/dist/PSTNodeInputStream.class.d.ts +122 -123
  34. package/dist/PSTNodeInputStream.class.js +514 -488
  35. package/dist/PSTObject.class.d.ts +133 -134
  36. package/dist/PSTObject.class.js +326 -323
  37. package/dist/PSTRecipient.class.d.ts +65 -65
  38. package/dist/PSTRecipient.class.js +103 -103
  39. package/dist/PSTTable.class.d.ts +52 -52
  40. package/dist/PSTTable.class.js +175 -172
  41. package/dist/PSTTable7C.class.d.ts +45 -45
  42. package/dist/PSTTable7C.class.js +281 -278
  43. package/dist/PSTTableBC.class.d.ts +31 -31
  44. package/dist/PSTTableBC.class.js +111 -108
  45. package/dist/PSTTableItem.class.d.ts +47 -48
  46. package/dist/PSTTableItem.class.js +124 -121
  47. package/dist/PSTTask.class.d.ts +146 -146
  48. package/dist/PSTTask.class.js +205 -205
  49. package/dist/PSTUtil.class.d.ts +134 -135
  50. package/dist/PSTUtil.class.js +795 -790
  51. package/dist/RecurrencePattern.class.d.ts +49 -50
  52. package/dist/RecurrencePattern.class.js +120 -120
  53. package/dist/index.d.ts +6 -6
  54. package/dist/index.js +15 -15
  55. package/example/package.json +7 -7
  56. package/example/test-min.ts +31 -12
  57. package/example/{test-mem.ts → test.ts} +38 -30
  58. package/example/testdata/output.txt +278 -0
  59. package/example/testdata/outputBody.txt +3404 -0
  60. package/example/yarn.lock +112 -50
  61. package/junit.xml +36 -36
  62. package/package.json +28 -27
  63. package/readme.md +1 -3
  64. package/example/test-max.ts +0 -251
@@ -1,31 +1,31 @@
1
- import { PSTNodeInputStream } from './PSTNodeInputStream.class';
2
- import { PSTTable } from './PSTTable.class';
3
- import { PSTTableItem } from './PSTTableItem.class';
4
- export declare class PSTTableBC extends PSTTable {
5
- private items;
6
- private isDescNotYetInitiated;
7
- /**
8
- * Creates an instance of PSTTableBC ("Property Context").
9
- * @param {PSTNodeInputStream} pstNodeInputStream
10
- * @memberof PSTTableBC
11
- */
12
- constructor(pstNodeInputStream: PSTNodeInputStream);
13
- /**
14
- * Get the items parsed out of this table.
15
- * @returns {Map<number, PSTTableItem>}
16
- * @memberof PSTTableBC
17
- */
18
- getItems(): Map<number, PSTTableItem>;
19
- /**
20
- * JSON stringify the items list.
21
- * @returns {string}
22
- * @memberof PSTTable7C
23
- */
24
- itemsJSON(): string;
25
- /**
26
- * JSON stringify the object properties.
27
- * @returns {string}
28
- * @memberof PSTTable7C
29
- */
30
- toJSON(): any;
31
- }
1
+ import { PSTNodeInputStream } from './PSTNodeInputStream.class';
2
+ import { PSTTable } from './PSTTable.class';
3
+ import { PSTTableItem } from './PSTTableItem.class';
4
+ export declare class PSTTableBC extends PSTTable {
5
+ private items;
6
+ private isDescNotYetInitiated;
7
+ /**
8
+ * Creates an instance of PSTTableBC ("Property Context").
9
+ * @param {PSTNodeInputStream} pstNodeInputStream
10
+ * @memberof PSTTableBC
11
+ */
12
+ constructor(pstNodeInputStream: PSTNodeInputStream);
13
+ /**
14
+ * Get the items parsed out of this table.
15
+ * @returns {Map<number, PSTTableItem>}
16
+ * @memberof PSTTableBC
17
+ */
18
+ getItems(): Map<number, PSTTableItem>;
19
+ /**
20
+ * JSON stringify the items list.
21
+ * @returns {string}
22
+ * @memberof PSTTable7C
23
+ */
24
+ itemsJSON(): string;
25
+ /**
26
+ * JSON stringify the object properties.
27
+ * @returns {string}
28
+ * @memberof PSTTable7C
29
+ */
30
+ toJSON(): any;
31
+ }
@@ -1,108 +1,111 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PSTTableBC = void 0;
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
- const long = require("long");
6
- const PSTTable_class_1 = require("./PSTTable.class");
7
- const PSTTableItem_class_1 = require("./PSTTableItem.class");
8
- const PSTUtil_class_1 = require("./PSTUtil.class");
9
- class PSTTableBC extends PSTTable_class_1.PSTTable {
10
- /**
11
- * Creates an instance of PSTTableBC ("Property Context").
12
- * @param {PSTNodeInputStream} pstNodeInputStream
13
- * @memberof PSTTableBC
14
- */
15
- constructor(pstNodeInputStream) {
16
- super(pstNodeInputStream, new Map());
17
- this.items = new Map();
18
- this.isDescNotYetInitiated = false;
19
- if (this.tableTypeByte != 188) {
20
- throw new Error('PSTTableBC::constructor unable to create PSTTableBC, table does not appear to be a bc!');
21
- }
22
- // go through each of the entries
23
- const keyTableInfoNodeInfo = this.getNodeInfo(this.hidRoot);
24
- if (!keyTableInfoNodeInfo) {
25
- throw new Error('PSTTableBC::constructor keyTableInfoNodeInfo is null');
26
- }
27
- const keyTableInfo = Buffer.alloc(keyTableInfoNodeInfo.length());
28
- keyTableInfoNodeInfo.pstNodeInputStream.seek(long.fromValue(keyTableInfoNodeInfo.startOffset));
29
- keyTableInfoNodeInfo.pstNodeInputStream.readCompletely(keyTableInfo);
30
- this.numberOfKeys = Math.trunc(keyTableInfo.length / (this.sizeOfItemKey + this.sizeOfItemValue));
31
- if (this.numberOfKeys == 0) {
32
- // debugger
33
- }
34
- // Read the key table
35
- let offset = 0;
36
- for (let x = 0; x < this.numberOfKeys; x++) {
37
- const item = new PSTTableItem_class_1.PSTTableItem();
38
- item.itemIndex = x;
39
- item.entryType = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(keyTableInfo, offset + 0, offset + 2);
40
- item.entryValueType = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(keyTableInfo, offset + 2, offset + 4).toNumber();
41
- item.entryValueReference = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(keyTableInfo, offset + 4, offset + 8).toNumber();
42
- // Data is in entryValueReference for all types <= 4 bytes long
43
- switch (item.entryValueType) {
44
- case 0x0002: // 16bit integer
45
- item.entryValueReference &= 0xffff;
46
- case 0x0003: // 32bit integer
47
- case 0x000a: // 32bit error code
48
- case 0x0001: // Place-holder
49
- case 0x0004: // 32bit floating
50
- item.isExternalValueReference = true;
51
- break;
52
- case 0x000b: // Boolean - a single byte
53
- item.entryValueReference &= 0xff;
54
- item.isExternalValueReference = true;
55
- break;
56
- case 0x000d:
57
- default:
58
- // Is it in the local heap?
59
- item.isExternalValueReference = true; // Assume not
60
- const nodeInfoNodeInfo = this.getNodeInfo(item.entryValueReference);
61
- if (nodeInfoNodeInfo == null) {
62
- // It's an external reference that we don't deal with here.
63
- }
64
- else {
65
- // Make a copy of the data
66
- const nodeInfo = Buffer.alloc(nodeInfoNodeInfo.length());
67
- nodeInfoNodeInfo.pstNodeInputStream.seek(long.fromValue(nodeInfoNodeInfo.startOffset));
68
- nodeInfoNodeInfo.pstNodeInputStream.readCompletely(nodeInfo);
69
- item.data = nodeInfo; // should be new array, so just use it
70
- item.isExternalValueReference = false;
71
- }
72
- break;
73
- }
74
- offset = offset + 8;
75
- this.items.set(item.entryType.toNumber(), item);
76
- }
77
- this.releaseRawData();
78
- }
79
- /**
80
- * Get the items parsed out of this table.
81
- * @returns {Map<number, PSTTableItem>}
82
- * @memberof PSTTableBC
83
- */
84
- getItems() {
85
- return this.items;
86
- }
87
- /**
88
- * JSON stringify the items list.
89
- * @returns {string}
90
- * @memberof PSTTable7C
91
- */
92
- itemsJSON() {
93
- let s = '';
94
- this.items.forEach((item) => {
95
- s = s + JSON.stringify(item);
96
- });
97
- return s;
98
- }
99
- /**
100
- * JSON stringify the object properties.
101
- * @returns {string}
102
- * @memberof PSTTable7C
103
- */
104
- toJSON() {
105
- return this;
106
- }
107
- }
108
- exports.PSTTableBC = PSTTableBC;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PSTTableBC = void 0;
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ const long_1 = __importDefault(require("long"));
9
+ const PSTTable_class_1 = require("./PSTTable.class");
10
+ const PSTTableItem_class_1 = require("./PSTTableItem.class");
11
+ const PSTUtil_class_1 = require("./PSTUtil.class");
12
+ class PSTTableBC extends PSTTable_class_1.PSTTable {
13
+ /**
14
+ * Creates an instance of PSTTableBC ("Property Context").
15
+ * @param {PSTNodeInputStream} pstNodeInputStream
16
+ * @memberof PSTTableBC
17
+ */
18
+ constructor(pstNodeInputStream) {
19
+ super(pstNodeInputStream, new Map());
20
+ this.items = new Map();
21
+ this.isDescNotYetInitiated = false;
22
+ if (this.tableTypeByte != 188) {
23
+ throw new Error('PSTTableBC::constructor unable to create PSTTableBC, table does not appear to be a bc!');
24
+ }
25
+ // go through each of the entries
26
+ const keyTableInfoNodeInfo = this.getNodeInfo(this.hidRoot);
27
+ if (!keyTableInfoNodeInfo) {
28
+ throw new Error('PSTTableBC::constructor keyTableInfoNodeInfo is null');
29
+ }
30
+ const keyTableInfo = Buffer.alloc(keyTableInfoNodeInfo.length());
31
+ keyTableInfoNodeInfo.pstNodeInputStream.seek(long_1.default.fromValue(keyTableInfoNodeInfo.startOffset));
32
+ keyTableInfoNodeInfo.pstNodeInputStream.readCompletely(keyTableInfo);
33
+ this.numberOfKeys = Math.trunc(keyTableInfo.length / (this.sizeOfItemKey + this.sizeOfItemValue));
34
+ if (this.numberOfKeys == 0) {
35
+ // debugger
36
+ }
37
+ // Read the key table
38
+ let offset = 0;
39
+ for (let x = 0; x < this.numberOfKeys; x++) {
40
+ const item = new PSTTableItem_class_1.PSTTableItem();
41
+ item.itemIndex = x;
42
+ item.entryType = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(keyTableInfo, offset + 0, offset + 2);
43
+ item.entryValueType = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(keyTableInfo, offset + 2, offset + 4).toNumber();
44
+ item.entryValueReference = PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(keyTableInfo, offset + 4, offset + 8).toNumber();
45
+ // Data is in entryValueReference for all types <= 4 bytes long
46
+ switch (item.entryValueType) {
47
+ case 0x0002: // 16bit integer
48
+ item.entryValueReference &= 0xffff;
49
+ case 0x0003: // 32bit integer
50
+ case 0x000a: // 32bit error code
51
+ case 0x0001: // Place-holder
52
+ case 0x0004: // 32bit floating
53
+ item.isExternalValueReference = true;
54
+ break;
55
+ case 0x000b: // Boolean - a single byte
56
+ item.entryValueReference &= 0xff;
57
+ item.isExternalValueReference = true;
58
+ break;
59
+ case 0x000d:
60
+ default:
61
+ // Is it in the local heap?
62
+ item.isExternalValueReference = true; // Assume not
63
+ const nodeInfoNodeInfo = this.getNodeInfo(item.entryValueReference);
64
+ if (nodeInfoNodeInfo == null) {
65
+ // It's an external reference that we don't deal with here.
66
+ }
67
+ else {
68
+ // Make a copy of the data
69
+ const nodeInfo = Buffer.alloc(nodeInfoNodeInfo.length());
70
+ nodeInfoNodeInfo.pstNodeInputStream.seek(long_1.default.fromValue(nodeInfoNodeInfo.startOffset));
71
+ nodeInfoNodeInfo.pstNodeInputStream.readCompletely(nodeInfo);
72
+ item.data = nodeInfo; // should be new array, so just use it
73
+ item.isExternalValueReference = false;
74
+ }
75
+ break;
76
+ }
77
+ offset = offset + 8;
78
+ this.items.set(item.entryType.toNumber(), item);
79
+ }
80
+ this.releaseRawData();
81
+ }
82
+ /**
83
+ * Get the items parsed out of this table.
84
+ * @returns {Map<number, PSTTableItem>}
85
+ * @memberof PSTTableBC
86
+ */
87
+ getItems() {
88
+ return this.items;
89
+ }
90
+ /**
91
+ * JSON stringify the items list.
92
+ * @returns {string}
93
+ * @memberof PSTTable7C
94
+ */
95
+ itemsJSON() {
96
+ let s = '';
97
+ this.items.forEach((item) => {
98
+ s = s + JSON.stringify(item);
99
+ });
100
+ return s;
101
+ }
102
+ /**
103
+ * JSON stringify the object properties.
104
+ * @returns {string}
105
+ * @memberof PSTTable7C
106
+ */
107
+ toJSON() {
108
+ return this;
109
+ }
110
+ }
111
+ exports.PSTTableBC = PSTTableBC;
@@ -1,48 +1,47 @@
1
- /// <reference types="node" />
2
- import * as long from 'long';
3
- export declare class PSTTableItem {
4
- static VALUE_TYPE_PT_UNICODE: number;
5
- static VALUE_TYPE_PT_STRING8: number;
6
- static VALUE_TYPE_PT_BIN: number;
7
- private _itemIndex;
8
- set itemIndex(val: number);
9
- get itemIndex(): number;
10
- private _entryType;
11
- set entryType(val: long);
12
- get entryType(): long;
13
- private _isExternalValueReference;
14
- set isExternalValueReference(val: boolean);
15
- get isExternalValueReference(): boolean;
16
- private _entryValueReference;
17
- set entryValueReference(val: number);
18
- get entryValueReference(): number;
19
- private _entryValueType;
20
- set entryValueType(val: number);
21
- get entryValueType(): number;
22
- private _data;
23
- set data(val: Buffer);
24
- get data(): Buffer;
25
- /**
26
- * Creates an instance of PSTTableItem.
27
- * @memberof PSTTableItem
28
- */
29
- /**
30
- * Get long value from table item.
31
- * @returns
32
- * @memberof PSTTableItem
33
- */
34
- getLongValue(): -1 | long.Long;
35
- /**
36
- * Get string value of data.
37
- * @param {number} [stringType]
38
- * @returns {string}
39
- * @memberof PSTTableItem
40
- */
41
- getStringValue(stringType?: number): string;
42
- /**
43
- * JSON stringify the object properties.
44
- * @returns {string}
45
- * @memberof PSTTableItem
46
- */
47
- toJSON(): any;
48
- }
1
+ import Long from 'long';
2
+ export declare class PSTTableItem {
3
+ static VALUE_TYPE_PT_UNICODE: number;
4
+ static VALUE_TYPE_PT_STRING8: number;
5
+ static VALUE_TYPE_PT_BIN: number;
6
+ private _itemIndex;
7
+ set itemIndex(val: number);
8
+ get itemIndex(): number;
9
+ private _entryType;
10
+ set entryType(val: Long);
11
+ get entryType(): Long;
12
+ private _isExternalValueReference;
13
+ set isExternalValueReference(val: boolean);
14
+ get isExternalValueReference(): boolean;
15
+ private _entryValueReference;
16
+ set entryValueReference(val: number);
17
+ get entryValueReference(): number;
18
+ private _entryValueType;
19
+ set entryValueType(val: number);
20
+ get entryValueType(): number;
21
+ private _data;
22
+ set data(val: Buffer);
23
+ get data(): Buffer;
24
+ /**
25
+ * Creates an instance of PSTTableItem.
26
+ * @memberof PSTTableItem
27
+ */
28
+ /**
29
+ * Get long value from table item.
30
+ * @returns
31
+ * @memberof PSTTableItem
32
+ */
33
+ getLongValue(): -1 | Long;
34
+ /**
35
+ * Get string value of data.
36
+ * @param {number} [stringType]
37
+ * @returns {string}
38
+ * @memberof PSTTableItem
39
+ */
40
+ getStringValue(stringType?: number): string;
41
+ /**
42
+ * JSON stringify the object properties.
43
+ * @returns {string}
44
+ * @memberof PSTTableItem
45
+ */
46
+ toJSON(): any;
47
+ }
@@ -1,121 +1,124 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PSTTableItem = void 0;
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
- const long = require("long");
6
- const PSTUtil_class_1 = require("./PSTUtil.class");
7
- // Generic table item
8
- // Provides some basic string functions
9
- class PSTTableItem {
10
- constructor() {
11
- this._itemIndex = 0;
12
- this._entryType = long.ZERO;
13
- this._isExternalValueReference = false;
14
- this._entryValueReference = 0;
15
- this._entryValueType = 0;
16
- this._data = Buffer.alloc(0);
17
- }
18
- set itemIndex(val) {
19
- this._itemIndex = val;
20
- }
21
- get itemIndex() {
22
- return this._itemIndex;
23
- }
24
- set entryType(val) {
25
- this._entryType = val;
26
- }
27
- get entryType() {
28
- return this._entryType;
29
- }
30
- set isExternalValueReference(val) {
31
- this._isExternalValueReference = val;
32
- }
33
- get isExternalValueReference() {
34
- return this._isExternalValueReference;
35
- }
36
- set entryValueReference(val) {
37
- this._entryValueReference = val;
38
- }
39
- get entryValueReference() {
40
- return this._entryValueReference;
41
- }
42
- set entryValueType(val) {
43
- this._entryValueType = val;
44
- }
45
- get entryValueType() {
46
- return this._entryValueType;
47
- }
48
- set data(val) {
49
- this._data = val;
50
- }
51
- get data() {
52
- return this._data;
53
- }
54
- /**
55
- * Creates an instance of PSTTableItem.
56
- * @memberof PSTTableItem
57
- */
58
- /**
59
- * Get long value from table item.
60
- * @returns
61
- * @memberof PSTTableItem
62
- */
63
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
64
- getLongValue() {
65
- if (this.data.length > 0) {
66
- return PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(this.data);
67
- }
68
- return -1;
69
- }
70
- /**
71
- * Get string value of data.
72
- * @param {number} [stringType]
73
- * @returns {string}
74
- * @memberof PSTTableItem
75
- */
76
- getStringValue(stringType) {
77
- if (!stringType) {
78
- stringType = this.entryValueType;
79
- }
80
- if (stringType === PSTTableItem.VALUE_TYPE_PT_UNICODE) {
81
- // little-endian unicode string
82
- try {
83
- if (this.isExternalValueReference) {
84
- return 'External string reference!';
85
- }
86
- return this.data.toString('utf16le').replace(/\0/g, '');
87
- }
88
- catch (err) {
89
- console.error('Error decoding string: ' +
90
- this.data.toString('utf16le').replace(/\0/g, '') +
91
- '\n' +
92
- err);
93
- return '';
94
- }
95
- }
96
- if (stringType == PSTTableItem.VALUE_TYPE_PT_STRING8) {
97
- return this.data.toString();
98
- }
99
- return 'hex string';
100
- }
101
- /**
102
- * JSON stringify the object properties.
103
- * @returns {string}
104
- * @memberof PSTTableItem
105
- */
106
- toJSON() {
107
- const clone = Object.assign({
108
- itemIndex: this.itemIndex,
109
- entryType: this.entryType,
110
- isExternalValueReference: this.isExternalValueReference,
111
- entryValueReference: this.entryValueReference,
112
- entryValueType: this.entryValueType,
113
- data: this.data,
114
- }, this);
115
- return clone;
116
- }
117
- }
118
- exports.PSTTableItem = PSTTableItem;
119
- PSTTableItem.VALUE_TYPE_PT_UNICODE = 0x1f;
120
- PSTTableItem.VALUE_TYPE_PT_STRING8 = 0x1e;
121
- PSTTableItem.VALUE_TYPE_PT_BIN = 0x102;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PSTTableItem = void 0;
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ const long_1 = __importDefault(require("long"));
9
+ const PSTUtil_class_1 = require("./PSTUtil.class");
10
+ // Generic table item
11
+ // Provides some basic string functions
12
+ class PSTTableItem {
13
+ constructor() {
14
+ this._itemIndex = 0;
15
+ this._entryType = long_1.default.ZERO;
16
+ this._isExternalValueReference = false;
17
+ this._entryValueReference = 0;
18
+ this._entryValueType = 0;
19
+ this._data = Buffer.alloc(0);
20
+ }
21
+ set itemIndex(val) {
22
+ this._itemIndex = val;
23
+ }
24
+ get itemIndex() {
25
+ return this._itemIndex;
26
+ }
27
+ set entryType(val) {
28
+ this._entryType = val;
29
+ }
30
+ get entryType() {
31
+ return this._entryType;
32
+ }
33
+ set isExternalValueReference(val) {
34
+ this._isExternalValueReference = val;
35
+ }
36
+ get isExternalValueReference() {
37
+ return this._isExternalValueReference;
38
+ }
39
+ set entryValueReference(val) {
40
+ this._entryValueReference = val;
41
+ }
42
+ get entryValueReference() {
43
+ return this._entryValueReference;
44
+ }
45
+ set entryValueType(val) {
46
+ this._entryValueType = val;
47
+ }
48
+ get entryValueType() {
49
+ return this._entryValueType;
50
+ }
51
+ set data(val) {
52
+ this._data = val;
53
+ }
54
+ get data() {
55
+ return this._data;
56
+ }
57
+ /**
58
+ * Creates an instance of PSTTableItem.
59
+ * @memberof PSTTableItem
60
+ */
61
+ /**
62
+ * Get long value from table item.
63
+ * @returns
64
+ * @memberof PSTTableItem
65
+ */
66
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
67
+ getLongValue() {
68
+ if (this.data.length > 0) {
69
+ return PSTUtil_class_1.PSTUtil.convertLittleEndianBytesToLong(this.data);
70
+ }
71
+ return -1;
72
+ }
73
+ /**
74
+ * Get string value of data.
75
+ * @param {number} [stringType]
76
+ * @returns {string}
77
+ * @memberof PSTTableItem
78
+ */
79
+ getStringValue(stringType) {
80
+ if (!stringType) {
81
+ stringType = this.entryValueType;
82
+ }
83
+ if (stringType === PSTTableItem.VALUE_TYPE_PT_UNICODE) {
84
+ // little-endian unicode string
85
+ try {
86
+ if (this.isExternalValueReference) {
87
+ return 'External string reference!';
88
+ }
89
+ return this.data.toString('utf16le').replace(/\0/g, '');
90
+ }
91
+ catch (err) {
92
+ console.error('Error decoding string: ' +
93
+ this.data.toString('utf16le').replace(/\0/g, '') +
94
+ '\n' +
95
+ err);
96
+ return '';
97
+ }
98
+ }
99
+ if (stringType == PSTTableItem.VALUE_TYPE_PT_STRING8) {
100
+ return this.data.toString();
101
+ }
102
+ return 'hex string';
103
+ }
104
+ /**
105
+ * JSON stringify the object properties.
106
+ * @returns {string}
107
+ * @memberof PSTTableItem
108
+ */
109
+ toJSON() {
110
+ const clone = Object.assign({
111
+ itemIndex: this.itemIndex,
112
+ entryType: this.entryType,
113
+ isExternalValueReference: this.isExternalValueReference,
114
+ entryValueReference: this.entryValueReference,
115
+ entryValueType: this.entryValueType,
116
+ data: this.data,
117
+ }, this);
118
+ return clone;
119
+ }
120
+ }
121
+ exports.PSTTableItem = PSTTableItem;
122
+ PSTTableItem.VALUE_TYPE_PT_UNICODE = 0x1f;
123
+ PSTTableItem.VALUE_TYPE_PT_STRING8 = 0x1e;
124
+ PSTTableItem.VALUE_TYPE_PT_BIN = 0x102;