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,50 +1,49 @@
1
- /// <reference types="node" />
2
- export declare enum RecurFrequency {
3
- Daily = 8202,
4
- Weekly = 8203,
5
- Monthly = 8204,
6
- Yearly = 8205
7
- }
8
- export declare enum PatternType {
9
- Day = 0,
10
- Week = 1,
11
- Month = 2,
12
- MonthEnd = 4,
13
- MonthNth = 3
14
- }
15
- export declare enum EndType {
16
- AfterDate = 8225,
17
- AfterNOccurrences = 8226,
18
- NeverEnd = 8227
19
- }
20
- export declare enum NthOccurrence {
21
- First = 1,
22
- Second = 2,
23
- Third = 3,
24
- Fourth = 4,
25
- Last = 5
26
- }
27
- export declare type WeekSpecific = boolean[] & {
28
- length: 7;
29
- };
30
- export declare type MonthNthSpecific = {
31
- weekdays: WeekSpecific;
32
- nth: NthOccurrence;
33
- };
34
- export declare class RecurrencePattern {
35
- private buffer;
36
- recurFrequency: RecurFrequency;
37
- patternType: PatternType;
38
- firstDateTime: Date;
39
- period: number;
40
- patternTypeSpecific: number | WeekSpecific | MonthNthSpecific | null;
41
- endType: EndType;
42
- occurrenceCount: number;
43
- firstDOW: number;
44
- startDate: Date;
45
- endDate: Date;
46
- constructor(buffer: Buffer);
47
- toJSON(): any;
48
- private readInt;
49
- private readPatternTypeSpecific;
50
- }
1
+ export declare enum RecurFrequency {
2
+ Daily = 8202,
3
+ Weekly = 8203,
4
+ Monthly = 8204,
5
+ Yearly = 8205
6
+ }
7
+ export declare enum PatternType {
8
+ Day = 0,
9
+ Week = 1,
10
+ Month = 2,
11
+ MonthEnd = 4,
12
+ MonthNth = 3
13
+ }
14
+ export declare enum EndType {
15
+ AfterDate = 8225,
16
+ AfterNOccurrences = 8226,
17
+ NeverEnd = 8227
18
+ }
19
+ export declare enum NthOccurrence {
20
+ First = 1,
21
+ Second = 2,
22
+ Third = 3,
23
+ Fourth = 4,
24
+ Last = 5
25
+ }
26
+ export type WeekSpecific = boolean[] & {
27
+ length: 7;
28
+ };
29
+ export type MonthNthSpecific = {
30
+ weekdays: WeekSpecific;
31
+ nth: NthOccurrence;
32
+ };
33
+ export declare class RecurrencePattern {
34
+ private buffer;
35
+ recurFrequency: RecurFrequency;
36
+ patternType: PatternType;
37
+ firstDateTime: Date;
38
+ period: number;
39
+ patternTypeSpecific: number | WeekSpecific | MonthNthSpecific | null;
40
+ endType: EndType;
41
+ occurrenceCount: number;
42
+ firstDOW: number;
43
+ startDate: Date;
44
+ endDate: Date;
45
+ constructor(buffer: Buffer);
46
+ toJSON(): any;
47
+ private readInt;
48
+ private readPatternTypeSpecific;
49
+ }
@@ -1,120 +1,120 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RecurrencePattern = exports.NthOccurrence = exports.EndType = exports.PatternType = exports.RecurFrequency = void 0;
4
- const OFFSETS = {
5
- RecurFrequency: 4,
6
- PatternType: 6,
7
- FirstDateTime: 10,
8
- Period: 14,
9
- PatternTypeSpecific: 22,
10
- EndType: 22,
11
- OccurrenceCount: 26,
12
- FirstDOW: 30,
13
- StartDate: -8,
14
- EndDate: -4,
15
- };
16
- var RecurFrequency;
17
- (function (RecurFrequency) {
18
- RecurFrequency[RecurFrequency["Daily"] = 8202] = "Daily";
19
- RecurFrequency[RecurFrequency["Weekly"] = 8203] = "Weekly";
20
- RecurFrequency[RecurFrequency["Monthly"] = 8204] = "Monthly";
21
- RecurFrequency[RecurFrequency["Yearly"] = 8205] = "Yearly";
22
- })(RecurFrequency = exports.RecurFrequency || (exports.RecurFrequency = {}));
23
- var PatternType;
24
- (function (PatternType) {
25
- PatternType[PatternType["Day"] = 0] = "Day";
26
- PatternType[PatternType["Week"] = 1] = "Week";
27
- PatternType[PatternType["Month"] = 2] = "Month";
28
- PatternType[PatternType["MonthEnd"] = 4] = "MonthEnd";
29
- PatternType[PatternType["MonthNth"] = 3] = "MonthNth";
30
- })(PatternType = exports.PatternType || (exports.PatternType = {}));
31
- var EndType;
32
- (function (EndType) {
33
- EndType[EndType["AfterDate"] = 8225] = "AfterDate";
34
- EndType[EndType["AfterNOccurrences"] = 8226] = "AfterNOccurrences";
35
- EndType[EndType["NeverEnd"] = 8227] = "NeverEnd";
36
- })(EndType = exports.EndType || (exports.EndType = {}));
37
- var NthOccurrence;
38
- (function (NthOccurrence) {
39
- NthOccurrence[NthOccurrence["First"] = 1] = "First";
40
- NthOccurrence[NthOccurrence["Second"] = 2] = "Second";
41
- NthOccurrence[NthOccurrence["Third"] = 3] = "Third";
42
- NthOccurrence[NthOccurrence["Fourth"] = 4] = "Fourth";
43
- NthOccurrence[NthOccurrence["Last"] = 5] = "Last";
44
- })(NthOccurrence = exports.NthOccurrence || (exports.NthOccurrence = {}));
45
- class RecurrencePattern {
46
- constructor(buffer) {
47
- this.buffer = buffer;
48
- const bufferEnd = buffer.length;
49
- let patternTypeOffset = 0;
50
- this.recurFrequency = this.readInt(OFFSETS.RecurFrequency, 1);
51
- this.patternType = this.readInt(OFFSETS.PatternType, 1);
52
- this.firstDateTime = winToJsDate(this.readInt(OFFSETS.FirstDateTime, 2));
53
- this.period = this.readInt(OFFSETS.Period, 2);
54
- this.patternTypeSpecific = this.readPatternTypeSpecific(this.patternType);
55
- switch (this.patternType) {
56
- case PatternType.Week:
57
- case PatternType.Month:
58
- case PatternType.MonthEnd:
59
- patternTypeOffset = 4;
60
- break;
61
- case PatternType.MonthNth:
62
- patternTypeOffset = 8;
63
- break;
64
- }
65
- this.endType = this.readInt(OFFSETS.EndType + patternTypeOffset, 2);
66
- this.occurrenceCount = this.readInt(OFFSETS.OccurrenceCount + patternTypeOffset, 2);
67
- this.firstDOW = this.readInt(OFFSETS.FirstDOW + patternTypeOffset, 2);
68
- this.startDate = winToJsDate(this.readInt(bufferEnd + OFFSETS.StartDate, 2));
69
- this.endDate = winToJsDate(this.readInt(bufferEnd + OFFSETS.EndDate, 2));
70
- }
71
- toJSON() {
72
- return {
73
- recurFrequency: RecurFrequency[this.recurFrequency],
74
- patternType: PatternType[this.patternType],
75
- firstDateTime: this.firstDateTime,
76
- period: this.period,
77
- patternTypeSpecific: this.patternTypeSpecific,
78
- endType: EndType[this.endType],
79
- occurrenceCount: this.occurrenceCount,
80
- firstDOW: this.firstDOW,
81
- startDate: this.startDate,
82
- endDate: this.endDate,
83
- };
84
- }
85
- readInt(offset, size) {
86
- switch (size) {
87
- case 1:
88
- return this.buffer.readInt16LE(offset);
89
- case 2:
90
- return this.buffer.readInt32LE(offset);
91
- }
92
- }
93
- readPatternTypeSpecific(type) {
94
- switch (type) {
95
- case PatternType.Day:
96
- return null;
97
- case PatternType.Week:
98
- return readWeekByte(this.buffer.readInt8(OFFSETS.PatternTypeSpecific));
99
- case PatternType.Month:
100
- case PatternType.MonthEnd:
101
- return this.readInt(OFFSETS.PatternTypeSpecific, 2);
102
- case PatternType.MonthNth:
103
- return {
104
- weekdays: readWeekByte(this.buffer.readInt8(OFFSETS.PatternTypeSpecific)),
105
- nth: this.readInt(OFFSETS.PatternTypeSpecific + 4, 2),
106
- };
107
- }
108
- }
109
- }
110
- exports.RecurrencePattern = RecurrencePattern;
111
- function winToJsDate(dateInt) {
112
- return new Date(dateInt * 60 * 1000 - 1.16444736e13); // subtract milliseconds between 1601-01-01 and 1970-01-01
113
- }
114
- function readWeekByte(byte) {
115
- const weekArr = [];
116
- for (let i = 0; i < 7; ++i) {
117
- weekArr.push(Boolean(byte & (1 << i)));
118
- }
119
- return weekArr;
120
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecurrencePattern = exports.NthOccurrence = exports.EndType = exports.PatternType = exports.RecurFrequency = void 0;
4
+ const OFFSETS = {
5
+ RecurFrequency: 4,
6
+ PatternType: 6,
7
+ FirstDateTime: 10,
8
+ Period: 14,
9
+ PatternTypeSpecific: 22,
10
+ EndType: 22,
11
+ OccurrenceCount: 26,
12
+ FirstDOW: 30,
13
+ StartDate: -8,
14
+ EndDate: -4,
15
+ };
16
+ var RecurFrequency;
17
+ (function (RecurFrequency) {
18
+ RecurFrequency[RecurFrequency["Daily"] = 8202] = "Daily";
19
+ RecurFrequency[RecurFrequency["Weekly"] = 8203] = "Weekly";
20
+ RecurFrequency[RecurFrequency["Monthly"] = 8204] = "Monthly";
21
+ RecurFrequency[RecurFrequency["Yearly"] = 8205] = "Yearly";
22
+ })(RecurFrequency || (exports.RecurFrequency = RecurFrequency = {}));
23
+ var PatternType;
24
+ (function (PatternType) {
25
+ PatternType[PatternType["Day"] = 0] = "Day";
26
+ PatternType[PatternType["Week"] = 1] = "Week";
27
+ PatternType[PatternType["Month"] = 2] = "Month";
28
+ PatternType[PatternType["MonthEnd"] = 4] = "MonthEnd";
29
+ PatternType[PatternType["MonthNth"] = 3] = "MonthNth";
30
+ })(PatternType || (exports.PatternType = PatternType = {}));
31
+ var EndType;
32
+ (function (EndType) {
33
+ EndType[EndType["AfterDate"] = 8225] = "AfterDate";
34
+ EndType[EndType["AfterNOccurrences"] = 8226] = "AfterNOccurrences";
35
+ EndType[EndType["NeverEnd"] = 8227] = "NeverEnd";
36
+ })(EndType || (exports.EndType = EndType = {}));
37
+ var NthOccurrence;
38
+ (function (NthOccurrence) {
39
+ NthOccurrence[NthOccurrence["First"] = 1] = "First";
40
+ NthOccurrence[NthOccurrence["Second"] = 2] = "Second";
41
+ NthOccurrence[NthOccurrence["Third"] = 3] = "Third";
42
+ NthOccurrence[NthOccurrence["Fourth"] = 4] = "Fourth";
43
+ NthOccurrence[NthOccurrence["Last"] = 5] = "Last";
44
+ })(NthOccurrence || (exports.NthOccurrence = NthOccurrence = {}));
45
+ class RecurrencePattern {
46
+ constructor(buffer) {
47
+ this.buffer = buffer;
48
+ const bufferEnd = buffer.length;
49
+ let patternTypeOffset = 0;
50
+ this.recurFrequency = this.readInt(OFFSETS.RecurFrequency, 1);
51
+ this.patternType = this.readInt(OFFSETS.PatternType, 1);
52
+ this.firstDateTime = winToJsDate(this.readInt(OFFSETS.FirstDateTime, 2));
53
+ this.period = this.readInt(OFFSETS.Period, 2);
54
+ this.patternTypeSpecific = this.readPatternTypeSpecific(this.patternType);
55
+ switch (this.patternType) {
56
+ case PatternType.Week:
57
+ case PatternType.Month:
58
+ case PatternType.MonthEnd:
59
+ patternTypeOffset = 4;
60
+ break;
61
+ case PatternType.MonthNth:
62
+ patternTypeOffset = 8;
63
+ break;
64
+ }
65
+ this.endType = this.readInt(OFFSETS.EndType + patternTypeOffset, 2);
66
+ this.occurrenceCount = this.readInt(OFFSETS.OccurrenceCount + patternTypeOffset, 2);
67
+ this.firstDOW = this.readInt(OFFSETS.FirstDOW + patternTypeOffset, 2);
68
+ this.startDate = winToJsDate(this.readInt(bufferEnd + OFFSETS.StartDate, 2));
69
+ this.endDate = winToJsDate(this.readInt(bufferEnd + OFFSETS.EndDate, 2));
70
+ }
71
+ toJSON() {
72
+ return {
73
+ recurFrequency: RecurFrequency[this.recurFrequency],
74
+ patternType: PatternType[this.patternType],
75
+ firstDateTime: this.firstDateTime,
76
+ period: this.period,
77
+ patternTypeSpecific: this.patternTypeSpecific,
78
+ endType: EndType[this.endType],
79
+ occurrenceCount: this.occurrenceCount,
80
+ firstDOW: this.firstDOW,
81
+ startDate: this.startDate,
82
+ endDate: this.endDate,
83
+ };
84
+ }
85
+ readInt(offset, size) {
86
+ switch (size) {
87
+ case 1:
88
+ return this.buffer.readInt16LE(offset);
89
+ case 2:
90
+ return this.buffer.readInt32LE(offset);
91
+ }
92
+ }
93
+ readPatternTypeSpecific(type) {
94
+ switch (type) {
95
+ case PatternType.Day:
96
+ return null;
97
+ case PatternType.Week:
98
+ return readWeekByte(this.buffer.readInt8(OFFSETS.PatternTypeSpecific));
99
+ case PatternType.Month:
100
+ case PatternType.MonthEnd:
101
+ return this.readInt(OFFSETS.PatternTypeSpecific, 2);
102
+ case PatternType.MonthNth:
103
+ return {
104
+ weekdays: readWeekByte(this.buffer.readInt8(OFFSETS.PatternTypeSpecific)),
105
+ nth: this.readInt(OFFSETS.PatternTypeSpecific + 4, 2),
106
+ };
107
+ }
108
+ }
109
+ }
110
+ exports.RecurrencePattern = RecurrencePattern;
111
+ function winToJsDate(dateInt) {
112
+ return new Date(dateInt * 60 * 1000 - 1.16444736e13); // subtract milliseconds between 1601-01-01 and 1970-01-01
113
+ }
114
+ function readWeekByte(byte) {
115
+ const weekArr = [];
116
+ for (let i = 0; i < 7; ++i) {
117
+ weekArr.push(Boolean(byte & (1 << i)));
118
+ }
119
+ return weekArr;
120
+ }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { PSTFile } from './PSTFile.class';
2
- export { PSTTask } from './PSTTask.class';
3
- export { PSTRecipient } from './PSTRecipient.class';
4
- export { PSTAttachment } from './PSTAttachment.class';
5
- export { PSTMessage } from './PSTMessage.class';
6
- export { PSTFolder } from './PSTFolder.class';
1
+ export { PSTFile } from './PSTFile.class';
2
+ export { PSTTask } from './PSTTask.class';
3
+ export { PSTRecipient } from './PSTRecipient.class';
4
+ export { PSTAttachment } from './PSTAttachment.class';
5
+ export { PSTMessage } from './PSTMessage.class';
6
+ export { PSTFolder } from './PSTFolder.class';
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PSTFolder = exports.PSTMessage = exports.PSTAttachment = exports.PSTRecipient = exports.PSTTask = exports.PSTFile = void 0;
4
- var PSTFile_class_1 = require("./PSTFile.class");
5
- Object.defineProperty(exports, "PSTFile", { enumerable: true, get: function () { return PSTFile_class_1.PSTFile; } });
6
- var PSTTask_class_1 = require("./PSTTask.class");
7
- Object.defineProperty(exports, "PSTTask", { enumerable: true, get: function () { return PSTTask_class_1.PSTTask; } });
8
- var PSTRecipient_class_1 = require("./PSTRecipient.class");
9
- Object.defineProperty(exports, "PSTRecipient", { enumerable: true, get: function () { return PSTRecipient_class_1.PSTRecipient; } });
10
- var PSTAttachment_class_1 = require("./PSTAttachment.class");
11
- Object.defineProperty(exports, "PSTAttachment", { enumerable: true, get: function () { return PSTAttachment_class_1.PSTAttachment; } });
12
- var PSTMessage_class_1 = require("./PSTMessage.class");
13
- Object.defineProperty(exports, "PSTMessage", { enumerable: true, get: function () { return PSTMessage_class_1.PSTMessage; } });
14
- var PSTFolder_class_1 = require("./PSTFolder.class");
15
- Object.defineProperty(exports, "PSTFolder", { enumerable: true, get: function () { return PSTFolder_class_1.PSTFolder; } });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PSTFolder = exports.PSTMessage = exports.PSTAttachment = exports.PSTRecipient = exports.PSTTask = exports.PSTFile = void 0;
4
+ var PSTFile_class_1 = require("./PSTFile.class");
5
+ Object.defineProperty(exports, "PSTFile", { enumerable: true, get: function () { return PSTFile_class_1.PSTFile; } });
6
+ var PSTTask_class_1 = require("./PSTTask.class");
7
+ Object.defineProperty(exports, "PSTTask", { enumerable: true, get: function () { return PSTTask_class_1.PSTTask; } });
8
+ var PSTRecipient_class_1 = require("./PSTRecipient.class");
9
+ Object.defineProperty(exports, "PSTRecipient", { enumerable: true, get: function () { return PSTRecipient_class_1.PSTRecipient; } });
10
+ var PSTAttachment_class_1 = require("./PSTAttachment.class");
11
+ Object.defineProperty(exports, "PSTAttachment", { enumerable: true, get: function () { return PSTAttachment_class_1.PSTAttachment; } });
12
+ var PSTMessage_class_1 = require("./PSTMessage.class");
13
+ Object.defineProperty(exports, "PSTMessage", { enumerable: true, get: function () { return PSTMessage_class_1.PSTMessage; } });
14
+ var PSTFolder_class_1 = require("./PSTFolder.class");
15
+ Object.defineProperty(exports, "PSTFolder", { enumerable: true, get: function () { return PSTFolder_class_1.PSTFolder; } });
@@ -6,17 +6,17 @@
6
6
  "pst-extractor": "link:.."
7
7
  },
8
8
  "devDependencies": {
9
- "eslint-config-prettier": "^8.3.0",
10
- "eslint-plugin-prettier": "^3.4.0",
11
- "prettier": "^2.3.2",
12
- "ts-node": "^10.2.0",
13
- "typescript": "^4.3.5"
9
+ "@types/node": "^20.14.10",
10
+ "eslint-config-prettier": "^9.1.0",
11
+ "eslint-plugin-prettier": "^5.1.3",
12
+ "prettier": "^3.3.3",
13
+ "ts-node": "^10.9.2",
14
+ "typescript": "^5.5.3"
14
15
  },
15
16
  "scripts": {
16
17
  "start": "ts-node test-min.ts",
17
18
  "test-min": "ts-node test-min.ts",
18
- "test-mem": "ts-node test-mem.ts",
19
- "test-max": "ts-node test-max.ts"
19
+ "test": "ts-node test.ts"
20
20
  },
21
21
  "eslintConfig": {
22
22
  "extends": [
@@ -1,11 +1,21 @@
1
+ import * as fs from 'fs'
1
2
  import { PSTMessage } from '../src/PSTMessage.class'
2
3
  import { PSTFile } from '../src/PSTFile.class'
3
4
  import { PSTFolder } from '../src/PSTFolder.class'
4
5
  const resolve = require('path').resolve
5
6
 
7
+ const pstFolder = './testdata/'
8
+ const topOutputFolder = './testdataoutput/'
6
9
  let depth = -1
7
10
  let col = 0
8
11
 
12
+ // console log highlight with https://en.wikipedia.org/wiki/ANSI_escape_code
13
+ const ANSI_RED = 31
14
+ const ANSI_YELLOW = 93
15
+ const ANSI_GREEN = 32
16
+ const ANSI_BLUE = 34
17
+ const highlight = (str: string, code: number = ANSI_RED) => '\u001b[' + code + 'm' + str + '\u001b[0m'
18
+
9
19
  /**
10
20
  * Returns a string with visual indication of depth in tree.
11
21
  * @param {number} depth
@@ -51,10 +61,10 @@ function processFolder(folder: PSTFolder): void {
51
61
  while (email != null) {
52
62
  console.log(
53
63
  getDepth(depth) +
54
- 'Sender: ' +
55
- email.senderName +
56
- ', Subject: ' +
57
- email.subject
64
+ 'Sender: ' +
65
+ email.senderName +
66
+ ', Subject: ' +
67
+ email.subject
58
68
  )
59
69
  email = folder.getNextChild()
60
70
  }
@@ -63,12 +73,21 @@ function processFolder(folder: PSTFolder): void {
63
73
  depth--
64
74
  }
65
75
 
66
- console.log('======================= Enron =======================')
67
- const pstFile1 = new PSTFile(resolve('./testdata/enron.pst'))
68
- console.log(pstFile1.getMessageStore().displayName)
69
- processFolder(pstFile1.getRootFolder())
76
+ const directoryListing = fs.readdirSync(pstFolder)
77
+ directoryListing.forEach((filename) => {
78
+ if (filename.endsWith('.pst') || filename.endsWith('.ost')) {
79
+ console.log(highlight(pstFolder + filename, ANSI_GREEN))
80
+
81
+ // time for performance comparison to Java and improvement
82
+ const start = Date.now()
83
+
84
+ // load file into memory buffer, then open as PSTFile
85
+ const pstFile = new PSTFile(fs.readFileSync(pstFolder + filename))
70
86
 
71
- console.log('======================= Repeating events, attachments =======================')
72
- const pstFile2 = new PSTFile(resolve('./testdata/pstextractortest@outlook.com.ost'))
73
- console.log(pstFile2.getMessageStore().displayName)
74
- processFolder(pstFile2.getRootFolder())
87
+ console.log(pstFile.getMessageStore().displayName)
88
+ processFolder(pstFile.getRootFolder())
89
+
90
+ const end = Date.now()
91
+ console.log(highlight(pstFolder + filename + ' processed in ' + (end - start) + ' ms', ANSI_GREEN))
92
+ }
93
+ })
@@ -4,19 +4,24 @@ import { PSTFile } from '../src/PSTFile.class'
4
4
  import { PSTFolder } from '../src/PSTFolder.class'
5
5
  import { PSTMessage } from '../src/PSTMessage.class'
6
6
 
7
- // TODO - location of pst files
8
- const pstFolder = 'C:/github/testdata/'
9
- // TODO - if saveToFS true, location to store extracted files
7
+ const pstFolder = './testdata/'
10
8
  const saveToFS = true
11
- const topOutputFolder = 'C:/github/testdataoutput/'
9
+ const topOutputFolder = './testdataoutput/'
12
10
 
13
11
  const verbose = true
14
12
  const displaySender = true
15
- const displayBody = false
13
+ const displayBody = true
16
14
  let outputFolder = ''
17
15
  let depth = -1
18
16
  let col = 0
19
17
 
18
+ // console log highlight with https://en.wikipedia.org/wiki/ANSI_escape_code
19
+ const ANSI_RED = 31
20
+ const ANSI_YELLOW = 93
21
+ const ANSI_GREEN = 32
22
+ const ANSI_BLUE = 34
23
+ const highlight = (str: string, code: number = ANSI_RED) => '\u001b[' + code + 'm' + str + '\u001b[0m'
24
+
20
25
  /**
21
26
  * Returns a string with visual indication of depth in tree.
22
27
  * @param {number} depth
@@ -52,7 +57,7 @@ function doSaveToFS(
52
57
  // save the msg as a txt file
53
58
  const filename = emailFolder + msg.descriptorNodeId + '.txt'
54
59
  if (verbose) {
55
- console.log('saving msg to ' + filename)
60
+ console.log(highlight('saving msg to ' + filename))
56
61
  }
57
62
  const fd = fs.openSync(filename, 'w')
58
63
  fs.writeSync(fd, msg.clientSubmitTime + '\r\n')
@@ -74,7 +79,7 @@ function doSaveToFS(
74
79
  const filename =
75
80
  emailFolder + msg.descriptorNodeId + '-' + attachment.longFilename
76
81
  if (verbose) {
77
- console.log('saving attachment to ' + filename)
82
+ console.log(highlight('saving attachment to ' + filename, ANSI_BLUE))
78
83
  }
79
84
  try {
80
85
  const fd = fs.openSync(filename, 'w')
@@ -161,10 +166,10 @@ function processFolder(folder: PSTFolder): void {
161
166
  if (verbose) {
162
167
  console.log(
163
168
  getDepth(depth) +
164
- 'Email: ' +
165
- email.descriptorNodeId +
166
- ' - ' +
167
- email.subject
169
+ 'Email: ' +
170
+ email.descriptorNodeId +
171
+ ' - ' +
172
+ email.subject
168
173
  )
169
174
  } else {
170
175
  printDot()
@@ -178,8 +183,9 @@ function processFolder(folder: PSTFolder): void {
178
183
 
179
184
  // display body?
180
185
  if (verbose && displayBody) {
181
- console.log(email.body)
182
- console.log(email.bodyRTF)
186
+ console.log(highlight('email.body', ANSI_YELLOW), email.body)
187
+ console.log(highlight('email.bodyRTF', ANSI_YELLOW), email.bodyRTF)
188
+ console.log(highlight('email.bodyHTML', ANSI_YELLOW), email.bodyHTML)
183
189
  }
184
190
 
185
191
  // save content to fs?
@@ -226,27 +232,29 @@ try {
226
232
 
227
233
  const directoryListing = fs.readdirSync(pstFolder)
228
234
  directoryListing.forEach((filename) => {
229
- console.log(pstFolder + filename)
235
+ if (filename.endsWith('.pst') || filename.endsWith('.ost')) {
236
+ console.log(highlight(pstFolder + filename, ANSI_GREEN))
230
237
 
231
- // time for performance comparison to Java and improvement
232
- const start = Date.now()
238
+ // time for performance comparison to Java and improvement
239
+ const start = Date.now()
233
240
 
234
- // load file into memory buffer, then open as PSTFile
235
- const pstFile = new PSTFile(fs.readFileSync(pstFolder + filename))
241
+ // load file into memory buffer, then open as PSTFile
242
+ const pstFile = new PSTFile(fs.readFileSync(pstFolder + filename))
236
243
 
237
- // make a sub folder for each PST
238
- try {
239
- if (saveToFS) {
240
- outputFolder = topOutputFolder + filename + '/'
241
- fs.mkdirSync(outputFolder)
244
+ // make a sub folder for each PST
245
+ try {
246
+ if (saveToFS) {
247
+ outputFolder = topOutputFolder + filename + '/'
248
+ fs.mkdirSync(outputFolder)
249
+ }
250
+ } catch (err) {
251
+ console.error(err)
242
252
  }
243
- } catch (err) {
244
- console.error(err)
245
- }
246
253
 
247
- console.log(pstFile.getMessageStore().displayName)
248
- processFolder(pstFile.getRootFolder())
254
+ console.log(pstFile.getMessageStore().displayName)
255
+ processFolder(pstFile.getRootFolder())
249
256
 
250
- const end = Date.now()
251
- console.log('processed in ' + (end - start) + ' ms')
257
+ const end = Date.now()
258
+ console.log(highlight(pstFolder + filename + ' processed in ' + (end - start) + ' ms', ANSI_GREEN))
259
+ }
252
260
  })