gedcom.json 1.0.8 → 1.0.9

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 (68) hide show
  1. package/.vscode/settings.json +15 -0
  2. package/README.md +246 -256
  3. package/dist/ToJSON/console.js +15 -12
  4. package/dist/ToJSON/console.js.map +1 -1
  5. package/dist/ToJSON/models/DefinitionCache.js.map +1 -1
  6. package/dist/ToJSON/models/LineParsingResult.js.map +1 -1
  7. package/dist/ToJSON/models/ParsedLine.js +1 -1
  8. package/dist/ToJSON/models/ParsedLine.js.map +1 -1
  9. package/dist/ToJSON/models/Parsing.js +8 -6
  10. package/dist/ToJSON/models/Parsing.js.map +1 -1
  11. package/dist/ToJSON/models/ParsingObject.js.map +1 -1
  12. package/dist/ToJSON/models/ParsingOptions.js.map +1 -1
  13. package/dist/ToJSON/models/ParsingPath.js.map +1 -1
  14. package/dist/ToJSON/models/ParsingResult.js.map +1 -1
  15. package/dist/ToJSON/models/StatisticLine.js.map +1 -1
  16. package/dist/ToJSON/models/Statistics.js +2 -2
  17. package/dist/ToJSON/models/Statistics.js.map +1 -1
  18. package/dist/ToJSON/models/Store.js +11 -11
  19. package/dist/ToJSON/models/Store.js.map +1 -1
  20. package/dist/ToJSON/models/TagDefinition.js +11 -11
  21. package/dist/ToJSON/models/TagDefinition.js.map +1 -1
  22. package/dist/ToJSON/parsing/lineHelper.js +8 -8
  23. package/dist/ToJSON/parsing/lineHelper.js.map +1 -1
  24. package/dist/ToJSON/parsing/lineValidation.js +6 -6
  25. package/dist/ToJSON/parsing/lineValidation.js.map +1 -1
  26. package/dist/ToJSON/parsing/parseDate.js +84 -84
  27. package/dist/ToJSON/parsing/parseDate.js.map +1 -1
  28. package/dist/ToJSON/parsing/parseLine.js +8 -8
  29. package/dist/ToJSON/parsing/parseLine.js.map +1 -1
  30. package/dist/ToJSON/parsing/parsing.js +17 -17
  31. package/dist/ToJSON/parsing/parsing.js.map +1 -1
  32. package/dist/ToJSON/parsing/processLine.js +18 -18
  33. package/dist/ToJSON/parsing/processLine.js.map +1 -1
  34. package/dist/ToJSON/processing/manipulateValues.js +9 -10
  35. package/dist/ToJSON/processing/manipulateValues.js.map +1 -1
  36. package/dist/ToJSON/processing/result.js +87 -80
  37. package/dist/ToJSON/processing/result.js.map +1 -1
  38. package/dist/common.js +5 -5
  39. package/dist/common.js.map +1 -1
  40. package/dist/console.js +4 -4
  41. package/dist/console.js.map +1 -1
  42. package/dist/index.js.map +1 -1
  43. package/options/version551.yaml +303 -296
  44. package/package.json +10 -5
  45. package/src/ToJSON/console.ts +67 -67
  46. package/src/ToJSON/models/DefinitionCache.ts +7 -7
  47. package/src/ToJSON/models/LineParsingResult.ts +7 -7
  48. package/src/ToJSON/models/ParsedLine.ts +35 -35
  49. package/src/ToJSON/models/Parsing.ts +45 -41
  50. package/src/ToJSON/models/ParsingObject.ts +16 -16
  51. package/src/ToJSON/models/ParsingOptions.ts +41 -41
  52. package/src/ToJSON/models/ParsingPath.ts +7 -7
  53. package/src/ToJSON/models/ParsingResult.ts +10 -10
  54. package/src/ToJSON/models/StatisticLine.ts +16 -16
  55. package/src/ToJSON/models/Statistics.ts +63 -63
  56. package/src/ToJSON/models/Store.ts +106 -108
  57. package/src/ToJSON/models/TagDefinition.ts +123 -122
  58. package/src/ToJSON/parsing/lineHelper.ts +21 -21
  59. package/src/ToJSON/parsing/lineValidation.ts +39 -40
  60. package/src/ToJSON/parsing/parseDate.ts +280 -286
  61. package/src/ToJSON/parsing/parseLine.ts +33 -33
  62. package/src/ToJSON/parsing/parsing.ts +134 -141
  63. package/src/ToJSON/parsing/processLine.ts +112 -109
  64. package/src/ToJSON/processing/manipulateValues.ts +52 -53
  65. package/src/ToJSON/processing/result.ts +247 -241
  66. package/src/common.ts +14 -14
  67. package/src/console.ts +7 -8
  68. package/src/index.ts +3 -6
@@ -1,81 +1,81 @@
1
- import Parsing from "./models/Parsing";
2
- import ParsingOptions from "./models/ParsingOptions";
1
+ import Parsing from './models/Parsing';
2
+ import ParsingOptions from './models/ParsingOptions';
3
3
 
4
- export function Convert(argv:any) {
5
- let options = new ParsingOptions();
4
+ export function Convert(argv: any) {
5
+ let options = new ParsingOptions();
6
6
 
7
- if (argv.path) {
8
- options.SetFilePath(argv.path as string);
9
- }
7
+ if (argv.path) {
8
+ options.SetFilePath(argv.path as string);
9
+ }
10
10
 
11
- if (argv.opt) {
12
- options.SetConfigFile(argv.opt as string);
13
- }
11
+ if (argv.opt) {
12
+ options.SetConfigFile(argv.opt as string);
13
+ }
14
14
 
15
- if (argv.showProgress) {
16
- options.SetProgressFunction((linesCount: number, lineNumber:number) => {
17
- process.stdout.write(`\rProgress: parsing line ${lineNumber} from ${linesCount}`);
18
- });
19
- }
20
-
21
- let silent = false;
22
- if (argv.silent) {
23
- silent = true;
24
- }
25
-
26
- let onlyStats = false;
27
- if (argv.onlyStats) {
28
- onlyStats = true;
29
- }
30
-
31
- let parse = new Parsing(options);
32
- let start = new Date().getTime();
33
- parse.ParseFileAsync().then(result => {
34
- if (argv.out) {
35
- parse.SaveAs(result.Object, argv.out as string);
36
- }
37
- else {
15
+ if (argv.showProgress) {
16
+ options.SetProgressFunction((linesCount: number, lineNumber: number) => {
17
+ process.stdout.write(`\rProgress: parsing line ${lineNumber} from ${linesCount}`);
18
+ });
19
+ }
38
20
 
39
- if (silent) {
40
- return;
41
- }
21
+ let silent = false;
22
+ if (argv.silent) {
23
+ silent = true;
24
+ }
42
25
 
43
- if (!onlyStats) {
44
- // print in console
45
- console.log(JSON.stringify(result.Object, null, 1));
46
- }
47
- }
26
+ let onlyStats = false;
27
+ if (argv.onlyStats) {
28
+ onlyStats = true;
29
+ }
48
30
 
31
+ let parse = new Parsing(options);
32
+ let start = new Date().getTime();
33
+ parse
34
+ .ParseFileAsync()
35
+ .then((result) => {
36
+ if (argv.out) {
37
+ parse.SaveAs(result.Object, argv.out as string);
38
+ } else {
49
39
  if (silent) {
50
- return;
40
+ return;
51
41
  }
52
42
 
53
- console.log("");
54
- console.log("-----------------------------------------------");
55
- console.log(`Lines: ${result.Statistics.LinesCount}`);
56
- console.log(`Parsed Lines: ${result.Statistics.ParsedLinesCount}`);
57
- console.log(`Not Parsed Lines: ${result.Statistics.NotParsedLinesCount}`);
58
- console.log(`Not Parsed Lines because of user defined Tag: ${result.Statistics.NotParsedLinesWithoutGEDCOMTagCount}`);
59
- console.log(`Incorrect Lines: ${result.Statistics.IncorrectLinesCount}`);
60
- console.log(`Parsing Time: ${(new Date().getTime() - start)} ms`);
61
- console.log("-----------------------------------------------");
62
- console.log("");
63
- if (result.Statistics.NotParsedLinesCount > 0) {
64
- console.log(`Not Parsed Lines: ${result.Statistics.NotParsedLinesList}`);
43
+ if (!onlyStats) {
44
+ // print in console
45
+ console.log(JSON.stringify(result.Object, null, 1));
65
46
  }
47
+ }
66
48
 
67
- if (result.Statistics.IncorrectLinesCount > 0) {
68
- console.log("");
69
- console.log("Incorrect Lines:");
70
- console.log("");
71
- console.log("Line\tText");
72
- console.log("-----------------------------------------------");
73
- result.Statistics.IncorrectLines.forEach((line: any) => {
74
- console.log(`${line.LineNumber}\t${line.Line}`);
75
- });
76
- }
49
+ if (silent) {
50
+ return;
51
+ }
77
52
 
78
- }).catch(e => {
79
- console.log(e);
53
+ console.log('');
54
+ console.log('-----------------------------------------------');
55
+ console.log(`Lines: ${result.Statistics.LinesCount}`);
56
+ console.log(`Parsed Lines: ${result.Statistics.ParsedLinesCount}`);
57
+ console.log(`Not Parsed Lines: ${result.Statistics.NotParsedLinesCount}`);
58
+ console.log(`Not Parsed Lines because of user defined Tag: ${result.Statistics.NotParsedLinesWithoutGEDCOMTagCount}`);
59
+ console.log(`Incorrect Lines: ${result.Statistics.IncorrectLinesCount}`);
60
+ console.log(`Parsing Time: ${new Date().getTime() - start} ms`);
61
+ console.log('-----------------------------------------------');
62
+ console.log('');
63
+ if (result.Statistics.NotParsedLinesCount > 0) {
64
+ console.log(`Not Parsed Lines: ${result.Statistics.NotParsedLinesList}`);
65
+ }
66
+
67
+ if (result.Statistics.IncorrectLinesCount > 0) {
68
+ console.log('');
69
+ console.log('Incorrect Lines:');
70
+ console.log('');
71
+ console.log('Line\tText');
72
+ console.log('-----------------------------------------------');
73
+ result.Statistics.IncorrectLines.forEach((line: any) => {
74
+ console.log(`${line.LineNumber}\t${line.Line}`);
75
+ });
76
+ }
77
+ })
78
+ .catch((e) => {
79
+ console.log(e);
80
80
  });
81
- }
81
+ }
@@ -1,9 +1,9 @@
1
1
  export default class DefinitionCache {
2
- constructor (path: string[], definition: any) {
3
- this.Path = path;
4
- this.Definition = definition;
5
- }
2
+ constructor(path: string[], definition: any) {
3
+ this.Path = path;
4
+ this.Definition = definition;
5
+ }
6
6
 
7
- Path: string[] = [];
8
- Definition: any;
9
- }
7
+ Path: string[] = [];
8
+ Definition: any;
9
+ }
@@ -1,9 +1,9 @@
1
1
  export default class LineParsingResult {
2
- constructor(parsed: Boolean, reason?: string) {
3
- this.Parsed = parsed;
4
- this.Reason = reason;
5
- }
2
+ constructor(parsed: Boolean, reason?: string) {
3
+ this.Parsed = parsed;
4
+ this.Reason = reason;
5
+ }
6
6
 
7
- Parsed: Boolean;
8
- Reason?: string;
9
- }
7
+ Parsed: Boolean;
8
+ Reason?: string;
9
+ }
@@ -2,39 +2,39 @@
2
2
  * Class with informations about the parsed line
3
3
  */
4
4
  export default class ParsedLine {
5
- /**
6
- * @param lineNumber line number
7
- * @param level level in hierarchy
8
- * @param tag line tag
9
- * @param value value = line text without level and tag\reference id
10
- * @param refId reference id
11
- */
12
- constructor(lineNumber: number, level: number, tag: string, value: string = "", refId: string = "") {
13
- this.LineNumber = lineNumber;
14
- this.Level = level;
15
- this.Tag = tag;
16
- this.Value = value;
17
- this.ReferenceId = refId;
18
- }
5
+ /**
6
+ * @param lineNumber line number
7
+ * @param level level in hierarchy
8
+ * @param tag line tag
9
+ * @param value value = line text without level and tag\reference id
10
+ * @param refId reference id
11
+ */
12
+ constructor(lineNumber: number, level: number, tag: string, value: string = '', refId: string = '') {
13
+ this.LineNumber = lineNumber;
14
+ this.Level = level;
15
+ this.Tag = tag;
16
+ this.Value = value;
17
+ this.ReferenceId = refId;
18
+ }
19
19
 
20
- /**
21
- * The reference id of the line when defined
22
- */
23
- ReferenceId: string;
24
- /**
25
- * The line number
26
- */
27
- LineNumber: number;
28
- /**
29
- * The line level
30
- */
31
- Level: number;
32
- /**
33
- * The line tag
34
- */
35
- Tag: string;
36
- /**
37
- * The line value if defined
38
- */
39
- Value: string | undefined;
40
- }
20
+ /**
21
+ * The reference id of the line when defined
22
+ */
23
+ ReferenceId: string;
24
+ /**
25
+ * The line number
26
+ */
27
+ LineNumber: number;
28
+ /**
29
+ * The line level
30
+ */
31
+ Level: number;
32
+ /**
33
+ * The line tag
34
+ */
35
+ Tag: string;
36
+ /**
37
+ * The line value if defined
38
+ */
39
+ Value: string | undefined;
40
+ }
@@ -1,56 +1,60 @@
1
- import { ParseFile, ParseText } from "../parsing/parsing";
2
- import ParsingOptions from "./ParsingOptions";
3
- import ParsingResult from "./ParsingResult";
1
+ import { ParseFile, ParseText } from '../parsing/parsing';
2
+ import ParsingOptions from './ParsingOptions';
3
+ import ParsingResult from './ParsingResult';
4
4
 
5
5
  export default class Parsing {
6
- constructor(parsingOptions?: ParsingOptions) {
7
- this.options = parsingOptions ?? new ParsingOptions();
8
- }
9
-
10
- private options: ParsingOptions;
6
+ constructor(parsingOptions?: ParsingOptions) {
7
+ this.options = parsingOptions ?? new ParsingOptions();
8
+ }
11
9
 
12
- SaveAs(result: Object, path: string) {
13
- require('fs').writeFileSync(path, JSON.stringify(result, null, 1));
14
- }
10
+ private options: ParsingOptions;
15
11
 
16
- ParseText(): ParsingResult {
17
- if (!this.options.GetText()) {
18
- return new ParsingResult({});
19
- }
12
+ SaveAs(result: Object, path: string) {
13
+ require('fs').writeFileSync(path, JSON.stringify(result, null, 1));
14
+ }
20
15
 
21
- return ParseText(this.options.GetText(), this.options.GetConfig(), this.options.GetProgressFunction());
16
+ ParseText(): ParsingResult {
17
+ if (!this.options.GetText()) {
18
+ return new ParsingResult({});
22
19
  }
23
20
 
24
- ParseTextAsync(): Promise<ParsingResult> {
25
- if (!this.options.GetText()) {
26
- return new Promise<ParsingResult>((resolve, reject) => {
27
- reject("No text definied");
28
- });
29
- }
21
+ return ParseText(this.options.GetText(), this.options.GetConfig(), this.options.GetProgressFunction());
22
+ }
30
23
 
31
- return new Promise<ParsingResult>((resolve, reject) => {
32
- resolve(ParseText(this.options.GetText(), this.options.GetConfig(), this.options.GetProgressFunction()));
33
- });
24
+ ParseTextAsync(): Promise<ParsingResult> {
25
+ if (!this.options.GetText()) {
26
+ return new Promise<ParsingResult>((resolve, reject) => {
27
+ reject('No text definied');
28
+ });
34
29
  }
35
30
 
36
- ParseFile(doneCallback: (result: ParsingResult) => void, errorCallback: Function) {
37
- let filePath = this.options.GetFilePath();
38
- if (!filePath) {
39
- return;
40
- }
31
+ return new Promise<ParsingResult>((resolve, reject) => {
32
+ resolve(ParseText(this.options.GetText(), this.options.GetConfig(), this.options.GetProgressFunction()));
33
+ });
34
+ }
41
35
 
42
- ParseFile(filePath, this.options.GetConfig(), doneCallback, errorCallback, this.options.GetProgressFunction());
36
+ ParseFile(doneCallback: (result: ParsingResult) => void, errorCallback: Function) {
37
+ let filePath = this.options.GetFilePath();
38
+ if (!filePath) {
39
+ return;
43
40
  }
44
41
 
45
- ParseFileAsync(): Promise<ParsingResult> {
46
- if (!this.options.GetFilePath()) {
47
- return new Promise<ParsingResult>((resolve, reject) => {
48
- reject("No file path definied");
49
- });
50
- }
42
+ ParseFile(filePath, this.options.GetConfig(), doneCallback, errorCallback, this.options.GetProgressFunction());
43
+ }
51
44
 
52
- return new Promise<ParsingResult>((resolve, reject) => {
53
- this.ParseFile(r => resolve(r), (e:any) => reject(e));
54
- });
45
+ ParseFileAsync(): Promise<ParsingResult> {
46
+ if (!this.options.GetFilePath()) {
47
+ return new Promise<ParsingResult>((resolve, reject) => {
48
+ reject('No file path definied');
49
+ });
55
50
  }
56
- }
51
+
52
+ return new Promise<ParsingResult>((resolve, reject) => {
53
+ this.ParseFile(
54
+ (r) => resolve(r),
55
+ /* istanbul ignore next */
56
+ (e: any) => reject(e)
57
+ );
58
+ });
59
+ }
60
+ }
@@ -1,21 +1,21 @@
1
- import ParsedLine from "./ParsedLine";
2
- import TagDefinition from "./TagDefinition";
1
+ import ParsedLine from './ParsedLine';
2
+ import TagDefinition from './TagDefinition';
3
3
 
4
4
  export default class ParsingObject {
5
- constructor(definition: TagDefinition, line: ParsedLine, actualPath: string[]) {
6
- this.PropertyPath = actualPath;
5
+ constructor(definition: TagDefinition, line: ParsedLine, actualPath: string[]) {
6
+ this.PropertyPath = actualPath;
7
7
 
8
- this.Object = { };
9
- this.Definition = definition;
10
- this.Line = line;
11
- }
8
+ this.Object = {};
9
+ this.Definition = definition;
10
+ this.Line = line;
11
+ }
12
12
 
13
- PropertyPath: string[];
14
- Object: any;
15
- Definition: TagDefinition;
16
- Line: ParsedLine;
13
+ PropertyPath: string[];
14
+ Object: any;
15
+ Definition: TagDefinition;
16
+ Line: ParsedLine;
17
17
 
18
- get StartLevel() {
19
- return this.Line.Level;
20
- }
21
- }
18
+ get StartLevel() {
19
+ return this.Line.Level;
20
+ }
21
+ }
@@ -1,42 +1,42 @@
1
1
  export default class ParsingOptions {
2
- private text?: string;
3
- private filePath?: string;
4
- private config?: string;
5
- private progressFunction?: (linesCount: number, actualLine: number) => void;
6
-
7
- SetText(text: string) {
8
- this.text = text;
9
- }
10
-
11
- SetFilePath(path: string) {
12
- this.filePath = path;
13
- }
14
-
15
- SetConfigFile(path: string) {
16
- this.config = require('fs').readFileSync(path, 'utf8');
17
- }
18
-
19
- SetConfig(config: string) {
20
- this.config = config;
21
- }
22
-
23
- GetText() {
24
- return this.text;
25
- }
26
-
27
- GetFilePath() {
28
- return this.filePath;
29
- }
30
-
31
- GetConfig() {
32
- return this.config ?? require('fs').readFileSync('options/version551.yaml', 'utf8');
33
- }
34
-
35
- SetProgressFunction(func: (linesCount: number, actualLine: number) => void) {
36
- this.progressFunction = func;
37
- }
38
-
39
- GetProgressFunction() : ((linesCount: number, actualLine: number) => void) | undefined {
40
- return this.progressFunction;
41
- }
42
- }
2
+ private text?: string;
3
+ private filePath?: string;
4
+ private config?: string;
5
+ private progressFunction?: (linesCount: number, actualLine: number) => void;
6
+
7
+ SetText(text: string) {
8
+ this.text = text;
9
+ }
10
+
11
+ SetFilePath(path: string) {
12
+ this.filePath = path;
13
+ }
14
+
15
+ SetConfigFile(path: string) {
16
+ this.config = require('fs').readFileSync(path, 'utf8');
17
+ }
18
+
19
+ SetConfig(config: string) {
20
+ this.config = config;
21
+ }
22
+
23
+ GetText() {
24
+ return this.text;
25
+ }
26
+
27
+ GetFilePath() {
28
+ return this.filePath;
29
+ }
30
+
31
+ GetConfig() {
32
+ return this.config ?? require('fs').readFileSync('options/version551.yaml', 'utf8');
33
+ }
34
+
35
+ SetProgressFunction(func: (linesCount: number, actualLine: number) => void) {
36
+ this.progressFunction = func;
37
+ }
38
+
39
+ GetProgressFunction(): ((linesCount: number, actualLine: number) => void) | undefined {
40
+ return this.progressFunction;
41
+ }
42
+ }
@@ -1,9 +1,9 @@
1
1
  export default class ParsingPath {
2
- constructor(tag:string, path: string) {
3
- this.Path = path;
4
- this.Tag = tag;
5
- }
2
+ constructor(tag: string, path: string) {
3
+ this.Path = path;
4
+ this.Tag = tag;
5
+ }
6
6
 
7
- Path: string;
8
- Tag: string;
9
- }
7
+ Path: string;
8
+ Tag: string;
9
+ }
@@ -1,13 +1,13 @@
1
- import Statistics from "./Statistics";
1
+ import Statistics from './Statistics';
2
2
 
3
3
  export default class ParsingResult {
4
- constructor(obj: Object, stats?: Statistics) {
5
- this.Object = obj;
6
-
7
- /* istanbul ignore next */
8
- this.Statistics = stats ?? new Statistics();
9
- }
4
+ constructor(obj: Object, stats?: Statistics) {
5
+ this.Object = obj;
10
6
 
11
- Object: Object;
12
- Statistics: Statistics;
13
- }
7
+ /* istanbul ignore next */
8
+ this.Statistics = stats ?? new Statistics();
9
+ }
10
+
11
+ Object: Object;
12
+ Statistics: Statistics;
13
+ }
@@ -1,22 +1,22 @@
1
1
  /**
2
2
  * Class with informations about a line
3
3
  */
4
- export default class StatisticLine{
5
- constructor(lineNumber: number, line: string, text?: string){
6
- this.LineNumber = lineNumber;
7
- this.Line = line;
8
- this.Text = text;
9
- }
4
+ export default class StatisticLine {
5
+ constructor(lineNumber: number, line: string, text?: string) {
6
+ this.LineNumber = lineNumber;
7
+ this.Line = line;
8
+ this.Text = text;
9
+ }
10
10
 
11
- /**
12
- * line number
13
- */
14
- LineNumber: number;
11
+ /**
12
+ * line number
13
+ */
14
+ LineNumber: number;
15
15
 
16
- /**
17
- * Line content
18
- */
19
- Line: string;
16
+ /**
17
+ * Line content
18
+ */
19
+ Line: string;
20
20
 
21
- Text?: string;
22
- }
21
+ Text?: string;
22
+ }