@treeviz/gedcom-parser 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/gedcom.d.ts +9 -0
- package/dist/classes/gedcom.d.ts.map +1 -1
- package/dist/classes/index.js +75 -1
- package/dist/cli/index.js +75 -1
- package/dist/index.js +75 -1
- package/dist/interfaces/gedcom.d.ts +6 -0
- package/dist/interfaces/gedcom.d.ts.map +1 -1
- package/dist/utils/index.js +75 -1
- package/package.json +1 -1
package/dist/classes/gedcom.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ import type { SourType } from "./sour";
|
|
|
17
17
|
import type { Sources } from "./sours";
|
|
18
18
|
import type { SubmType } from "./subm";
|
|
19
19
|
import type { Submitters } from "./subms";
|
|
20
|
+
type GedcomObjectPrimitive = string | number | boolean;
|
|
21
|
+
export interface GedcomObjectPatch {
|
|
22
|
+
[key: string]: GedcomObjectPatchValue;
|
|
23
|
+
}
|
|
24
|
+
export type GedcomObjectPatchValue = GedcomObjectPrimitive | GedcomObjectPatch | GedcomObjectPatchValue[] | null | undefined;
|
|
20
25
|
export declare class GedCom extends Common implements IGedcom {
|
|
21
26
|
tagMembers: Record<string, {
|
|
22
27
|
tag: Common;
|
|
@@ -27,6 +32,9 @@ export declare class GedCom extends Common implements IGedcom {
|
|
|
27
32
|
constructor();
|
|
28
33
|
private getMain;
|
|
29
34
|
getList<T extends List = List>(type: MultiTag): T | undefined;
|
|
35
|
+
private createNodeFromPatchValue;
|
|
36
|
+
private applyObjectToCommon;
|
|
37
|
+
applyObject(patch: GedcomObjectPatch): this;
|
|
30
38
|
indis(): Individuals | undefined;
|
|
31
39
|
cloneIndis(target?: IndiKey | IndiType, source?: IndiKey | IndiType, avoidKeys?: MultiTag[], removeFromOriginalList?: boolean): this | undefined;
|
|
32
40
|
mergeIndis(target?: IndiKey | IndiType, source?: IndiKey | IndiType, removeFromOriginalList?: boolean): this | undefined;
|
|
@@ -145,4 +153,5 @@ export declare const validateGedcomContent: (content?: string) => {
|
|
|
145
153
|
* - All family relationships (FAMS/FAMC) are preserved with updated ID references
|
|
146
154
|
*/
|
|
147
155
|
export declare const mergeGedcoms: (targetGedcom: GedComType, sourceGedcom: GedComType, strategy?: MultiTag | "id") => GedComType;
|
|
156
|
+
export {};
|
|
148
157
|
//# sourceMappingURL=gedcom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gedcom.d.ts","sourceRoot":"","sources":["../../src/classes/gedcom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,qBAAqB,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,gBAAgB,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAEX,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAgB,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA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AAE,OAAO,EAAO;IA0B/C;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmN/B;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,gBAAgB,CAAC;AACnD,eAAO,MAAM,YAAY,QAAO,UAE/B,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,eAAe,MAAM,YASnD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GACjC,UAAU,MAAM,KACd;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAqDlC,CAAC;AAgBF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,GACxB,cAAc,UAAU,EACxB,cAAc,UAAU,EACxB,WAAU,QAAQ,GAAG,IAAW,KAC9B,UAkVF,CAAC"}
|
package/dist/classes/index.js
CHANGED
|
@@ -6253,12 +6253,15 @@ var createIndi = (gedcom, id, main, parent) => {
|
|
|
6253
6253
|
|
|
6254
6254
|
// package.json
|
|
6255
6255
|
var package_default = {
|
|
6256
|
-
version: "2.0.
|
|
6256
|
+
version: "2.0.7"};
|
|
6257
6257
|
|
|
6258
6258
|
// src/utils/get-product-details.ts
|
|
6259
6259
|
var getVersion = () => package_default.version;
|
|
6260
6260
|
|
|
6261
6261
|
// src/classes/gedcom.ts
|
|
6262
|
+
var isObjectPatch = (value) => {
|
|
6263
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6264
|
+
};
|
|
6262
6265
|
var GedCom = class extends Common {
|
|
6263
6266
|
constructor() {
|
|
6264
6267
|
super();
|
|
@@ -6283,6 +6286,77 @@ var GedCom = class extends Common {
|
|
|
6283
6286
|
getList(type) {
|
|
6284
6287
|
return this.get(type);
|
|
6285
6288
|
}
|
|
6289
|
+
createNodeFromPatchValue(value, main) {
|
|
6290
|
+
if (value === void 0 || value === null) {
|
|
6291
|
+
return void 0;
|
|
6292
|
+
}
|
|
6293
|
+
const node = createCommon(this, void 0, main);
|
|
6294
|
+
if (Array.isArray(value)) {
|
|
6295
|
+
value.forEach((item) => {
|
|
6296
|
+
const childNode = this.createNodeFromPatchValue(item, node);
|
|
6297
|
+
if (childNode) {
|
|
6298
|
+
node.assign("DATA", childNode);
|
|
6299
|
+
}
|
|
6300
|
+
});
|
|
6301
|
+
return node;
|
|
6302
|
+
}
|
|
6303
|
+
if (isObjectPatch(value)) {
|
|
6304
|
+
this.applyObjectToCommon(node, value);
|
|
6305
|
+
return node;
|
|
6306
|
+
}
|
|
6307
|
+
node.value = String(value);
|
|
6308
|
+
return node;
|
|
6309
|
+
}
|
|
6310
|
+
applyObjectToCommon(target, patch) {
|
|
6311
|
+
Object.entries(patch).forEach(([rawTag, value]) => {
|
|
6312
|
+
if (rawTag === "value") {
|
|
6313
|
+
if (value === null || value === void 0 || Array.isArray(value) || isObjectPatch(value)) {
|
|
6314
|
+
return;
|
|
6315
|
+
}
|
|
6316
|
+
target.value = String(value);
|
|
6317
|
+
return;
|
|
6318
|
+
}
|
|
6319
|
+
if (rawTag === "id") {
|
|
6320
|
+
if (typeof value === "string") {
|
|
6321
|
+
target.id = value;
|
|
6322
|
+
}
|
|
6323
|
+
return;
|
|
6324
|
+
}
|
|
6325
|
+
const tag = rawTag;
|
|
6326
|
+
if (value === void 0) {
|
|
6327
|
+
return;
|
|
6328
|
+
}
|
|
6329
|
+
if (value === null) {
|
|
6330
|
+
target.remove(tag);
|
|
6331
|
+
return;
|
|
6332
|
+
}
|
|
6333
|
+
if (Array.isArray(value)) {
|
|
6334
|
+
target.remove(tag);
|
|
6335
|
+
value.forEach((item) => {
|
|
6336
|
+
const listNode = this.createNodeFromPatchValue(
|
|
6337
|
+
item,
|
|
6338
|
+
target.main ?? this
|
|
6339
|
+
);
|
|
6340
|
+
if (listNode) {
|
|
6341
|
+
target.assign(tag, listNode);
|
|
6342
|
+
}
|
|
6343
|
+
});
|
|
6344
|
+
return;
|
|
6345
|
+
}
|
|
6346
|
+
if (isObjectPatch(value)) {
|
|
6347
|
+
const existing = target.get(tag);
|
|
6348
|
+
const objectNode = existing ?? createCommon(this, void 0, target.main ?? this);
|
|
6349
|
+
this.applyObjectToCommon(objectNode, value);
|
|
6350
|
+
target.set(tag, objectNode);
|
|
6351
|
+
return;
|
|
6352
|
+
}
|
|
6353
|
+
target.set(tag, String(value));
|
|
6354
|
+
});
|
|
6355
|
+
}
|
|
6356
|
+
applyObject(patch) {
|
|
6357
|
+
this.applyObjectToCommon(this, patch);
|
|
6358
|
+
return this;
|
|
6359
|
+
}
|
|
6286
6360
|
indis() {
|
|
6287
6361
|
return this.getList("@@INDI");
|
|
6288
6362
|
}
|
package/dist/cli/index.js
CHANGED
|
@@ -6247,7 +6247,7 @@ var Families = class _Families extends List {
|
|
|
6247
6247
|
|
|
6248
6248
|
// package.json
|
|
6249
6249
|
var package_default = {
|
|
6250
|
-
version: "2.0.
|
|
6250
|
+
version: "2.0.7"};
|
|
6251
6251
|
|
|
6252
6252
|
// src/utils/get-product-details.ts
|
|
6253
6253
|
var isDevelopment = () => {
|
|
@@ -6256,6 +6256,9 @@ var isDevelopment = () => {
|
|
|
6256
6256
|
var getVersion = () => package_default.version;
|
|
6257
6257
|
|
|
6258
6258
|
// src/classes/gedcom.ts
|
|
6259
|
+
var isObjectPatch = (value) => {
|
|
6260
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6261
|
+
};
|
|
6259
6262
|
var GedCom = class extends Common {
|
|
6260
6263
|
constructor() {
|
|
6261
6264
|
super();
|
|
@@ -6280,6 +6283,77 @@ var GedCom = class extends Common {
|
|
|
6280
6283
|
getList(type) {
|
|
6281
6284
|
return this.get(type);
|
|
6282
6285
|
}
|
|
6286
|
+
createNodeFromPatchValue(value, main) {
|
|
6287
|
+
if (value === void 0 || value === null) {
|
|
6288
|
+
return void 0;
|
|
6289
|
+
}
|
|
6290
|
+
const node = createCommon(this, void 0, main);
|
|
6291
|
+
if (Array.isArray(value)) {
|
|
6292
|
+
value.forEach((item) => {
|
|
6293
|
+
const childNode = this.createNodeFromPatchValue(item, node);
|
|
6294
|
+
if (childNode) {
|
|
6295
|
+
node.assign("DATA", childNode);
|
|
6296
|
+
}
|
|
6297
|
+
});
|
|
6298
|
+
return node;
|
|
6299
|
+
}
|
|
6300
|
+
if (isObjectPatch(value)) {
|
|
6301
|
+
this.applyObjectToCommon(node, value);
|
|
6302
|
+
return node;
|
|
6303
|
+
}
|
|
6304
|
+
node.value = String(value);
|
|
6305
|
+
return node;
|
|
6306
|
+
}
|
|
6307
|
+
applyObjectToCommon(target, patch) {
|
|
6308
|
+
Object.entries(patch).forEach(([rawTag, value]) => {
|
|
6309
|
+
if (rawTag === "value") {
|
|
6310
|
+
if (value === null || value === void 0 || Array.isArray(value) || isObjectPatch(value)) {
|
|
6311
|
+
return;
|
|
6312
|
+
}
|
|
6313
|
+
target.value = String(value);
|
|
6314
|
+
return;
|
|
6315
|
+
}
|
|
6316
|
+
if (rawTag === "id") {
|
|
6317
|
+
if (typeof value === "string") {
|
|
6318
|
+
target.id = value;
|
|
6319
|
+
}
|
|
6320
|
+
return;
|
|
6321
|
+
}
|
|
6322
|
+
const tag = rawTag;
|
|
6323
|
+
if (value === void 0) {
|
|
6324
|
+
return;
|
|
6325
|
+
}
|
|
6326
|
+
if (value === null) {
|
|
6327
|
+
target.remove(tag);
|
|
6328
|
+
return;
|
|
6329
|
+
}
|
|
6330
|
+
if (Array.isArray(value)) {
|
|
6331
|
+
target.remove(tag);
|
|
6332
|
+
value.forEach((item) => {
|
|
6333
|
+
const listNode = this.createNodeFromPatchValue(
|
|
6334
|
+
item,
|
|
6335
|
+
target.main ?? this
|
|
6336
|
+
);
|
|
6337
|
+
if (listNode) {
|
|
6338
|
+
target.assign(tag, listNode);
|
|
6339
|
+
}
|
|
6340
|
+
});
|
|
6341
|
+
return;
|
|
6342
|
+
}
|
|
6343
|
+
if (isObjectPatch(value)) {
|
|
6344
|
+
const existing = target.get(tag);
|
|
6345
|
+
const objectNode = existing ?? createCommon(this, void 0, target.main ?? this);
|
|
6346
|
+
this.applyObjectToCommon(objectNode, value);
|
|
6347
|
+
target.set(tag, objectNode);
|
|
6348
|
+
return;
|
|
6349
|
+
}
|
|
6350
|
+
target.set(tag, String(value));
|
|
6351
|
+
});
|
|
6352
|
+
}
|
|
6353
|
+
applyObject(patch) {
|
|
6354
|
+
this.applyObjectToCommon(this, patch);
|
|
6355
|
+
return this;
|
|
6356
|
+
}
|
|
6283
6357
|
indis() {
|
|
6284
6358
|
return this.getList("@@INDI");
|
|
6285
6359
|
}
|
package/dist/index.js
CHANGED
|
@@ -6653,7 +6653,7 @@ var Families = class _Families extends List {
|
|
|
6653
6653
|
// package.json
|
|
6654
6654
|
var package_default = {
|
|
6655
6655
|
name: "@treeviz/gedcom-parser",
|
|
6656
|
-
version: "2.0.
|
|
6656
|
+
version: "2.0.7"};
|
|
6657
6657
|
|
|
6658
6658
|
// src/utils/get-product-details.ts
|
|
6659
6659
|
var isDevelopment = () => {
|
|
@@ -6663,6 +6663,9 @@ var getVersion = () => package_default.version;
|
|
|
6663
6663
|
var getName = () => package_default.name;
|
|
6664
6664
|
|
|
6665
6665
|
// src/classes/gedcom.ts
|
|
6666
|
+
var isObjectPatch = (value) => {
|
|
6667
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6668
|
+
};
|
|
6666
6669
|
var GedCom = class extends Common {
|
|
6667
6670
|
constructor() {
|
|
6668
6671
|
super();
|
|
@@ -6687,6 +6690,77 @@ var GedCom = class extends Common {
|
|
|
6687
6690
|
getList(type) {
|
|
6688
6691
|
return this.get(type);
|
|
6689
6692
|
}
|
|
6693
|
+
createNodeFromPatchValue(value, main) {
|
|
6694
|
+
if (value === void 0 || value === null) {
|
|
6695
|
+
return void 0;
|
|
6696
|
+
}
|
|
6697
|
+
const node = createCommon(this, void 0, main);
|
|
6698
|
+
if (Array.isArray(value)) {
|
|
6699
|
+
value.forEach((item) => {
|
|
6700
|
+
const childNode = this.createNodeFromPatchValue(item, node);
|
|
6701
|
+
if (childNode) {
|
|
6702
|
+
node.assign("DATA", childNode);
|
|
6703
|
+
}
|
|
6704
|
+
});
|
|
6705
|
+
return node;
|
|
6706
|
+
}
|
|
6707
|
+
if (isObjectPatch(value)) {
|
|
6708
|
+
this.applyObjectToCommon(node, value);
|
|
6709
|
+
return node;
|
|
6710
|
+
}
|
|
6711
|
+
node.value = String(value);
|
|
6712
|
+
return node;
|
|
6713
|
+
}
|
|
6714
|
+
applyObjectToCommon(target, patch) {
|
|
6715
|
+
Object.entries(patch).forEach(([rawTag, value]) => {
|
|
6716
|
+
if (rawTag === "value") {
|
|
6717
|
+
if (value === null || value === void 0 || Array.isArray(value) || isObjectPatch(value)) {
|
|
6718
|
+
return;
|
|
6719
|
+
}
|
|
6720
|
+
target.value = String(value);
|
|
6721
|
+
return;
|
|
6722
|
+
}
|
|
6723
|
+
if (rawTag === "id") {
|
|
6724
|
+
if (typeof value === "string") {
|
|
6725
|
+
target.id = value;
|
|
6726
|
+
}
|
|
6727
|
+
return;
|
|
6728
|
+
}
|
|
6729
|
+
const tag = rawTag;
|
|
6730
|
+
if (value === void 0) {
|
|
6731
|
+
return;
|
|
6732
|
+
}
|
|
6733
|
+
if (value === null) {
|
|
6734
|
+
target.remove(tag);
|
|
6735
|
+
return;
|
|
6736
|
+
}
|
|
6737
|
+
if (Array.isArray(value)) {
|
|
6738
|
+
target.remove(tag);
|
|
6739
|
+
value.forEach((item) => {
|
|
6740
|
+
const listNode = this.createNodeFromPatchValue(
|
|
6741
|
+
item,
|
|
6742
|
+
target.main ?? this
|
|
6743
|
+
);
|
|
6744
|
+
if (listNode) {
|
|
6745
|
+
target.assign(tag, listNode);
|
|
6746
|
+
}
|
|
6747
|
+
});
|
|
6748
|
+
return;
|
|
6749
|
+
}
|
|
6750
|
+
if (isObjectPatch(value)) {
|
|
6751
|
+
const existing = target.get(tag);
|
|
6752
|
+
const objectNode = existing ?? createCommon(this, void 0, target.main ?? this);
|
|
6753
|
+
this.applyObjectToCommon(objectNode, value);
|
|
6754
|
+
target.set(tag, objectNode);
|
|
6755
|
+
return;
|
|
6756
|
+
}
|
|
6757
|
+
target.set(tag, String(value));
|
|
6758
|
+
});
|
|
6759
|
+
}
|
|
6760
|
+
applyObject(patch) {
|
|
6761
|
+
this.applyObjectToCommon(this, patch);
|
|
6762
|
+
return this;
|
|
6763
|
+
}
|
|
6690
6764
|
indis() {
|
|
6691
6765
|
return this.getList("@@INDI");
|
|
6692
6766
|
}
|
|
@@ -12,6 +12,11 @@ import type { Sources } from "../classes/sours";
|
|
|
12
12
|
import type { SubmType } from "../classes/subm";
|
|
13
13
|
import type { Submitters } from "../classes/subms";
|
|
14
14
|
import type { FamKey, IndiKey, ObjeKey, RepoKey, SourKey, SubmKey } from "../types/types";
|
|
15
|
+
type GedcomObjectPrimitive = string | number | boolean;
|
|
16
|
+
export interface GedcomObjectPatch {
|
|
17
|
+
[key: string]: GedcomObjectPatchValue;
|
|
18
|
+
}
|
|
19
|
+
export type GedcomObjectPatchValue = GedcomObjectPrimitive | GedcomObjectPatch | GedcomObjectPatchValue[] | null | undefined;
|
|
15
20
|
interface IGedcom extends Common {
|
|
16
21
|
indis: () => Individuals | undefined;
|
|
17
22
|
fams: () => Families | undefined;
|
|
@@ -25,6 +30,7 @@ interface IGedcom extends Common {
|
|
|
25
30
|
sour: (index: number | SourKey) => SourType | undefined;
|
|
26
31
|
repo: (index: number | RepoKey) => RepoType | undefined;
|
|
27
32
|
subm: (index: number | SubmKey) => SubmType | undefined;
|
|
33
|
+
applyObject: (patch: GedcomObjectPatch) => IGedcom;
|
|
28
34
|
}
|
|
29
35
|
export default IGedcom;
|
|
30
36
|
//# sourceMappingURL=gedcom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gedcom.d.ts","sourceRoot":"","sources":["../../src/interfaces/gedcom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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S,CAAC;IAExD,WAAW,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC;CACnD;AAED,eAAe,OAAO,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -6489,7 +6489,7 @@ var isCommonDate = (value) => {
|
|
|
6489
6489
|
// package.json
|
|
6490
6490
|
var package_default = {
|
|
6491
6491
|
name: "@treeviz/gedcom-parser",
|
|
6492
|
-
version: "2.0.
|
|
6492
|
+
version: "2.0.7"};
|
|
6493
6493
|
|
|
6494
6494
|
// src/utils/get-product-details.ts
|
|
6495
6495
|
var isDevelopment = () => {
|
|
@@ -6499,6 +6499,9 @@ var getVersion = () => package_default.version;
|
|
|
6499
6499
|
var getName = () => package_default.name;
|
|
6500
6500
|
|
|
6501
6501
|
// src/classes/gedcom.ts
|
|
6502
|
+
var isObjectPatch = (value) => {
|
|
6503
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6504
|
+
};
|
|
6502
6505
|
var GedCom = class extends Common {
|
|
6503
6506
|
constructor() {
|
|
6504
6507
|
super();
|
|
@@ -6523,6 +6526,77 @@ var GedCom = class extends Common {
|
|
|
6523
6526
|
getList(type) {
|
|
6524
6527
|
return this.get(type);
|
|
6525
6528
|
}
|
|
6529
|
+
createNodeFromPatchValue(value, main) {
|
|
6530
|
+
if (value === void 0 || value === null) {
|
|
6531
|
+
return void 0;
|
|
6532
|
+
}
|
|
6533
|
+
const node = createCommon(this, void 0, main);
|
|
6534
|
+
if (Array.isArray(value)) {
|
|
6535
|
+
value.forEach((item) => {
|
|
6536
|
+
const childNode = this.createNodeFromPatchValue(item, node);
|
|
6537
|
+
if (childNode) {
|
|
6538
|
+
node.assign("DATA", childNode);
|
|
6539
|
+
}
|
|
6540
|
+
});
|
|
6541
|
+
return node;
|
|
6542
|
+
}
|
|
6543
|
+
if (isObjectPatch(value)) {
|
|
6544
|
+
this.applyObjectToCommon(node, value);
|
|
6545
|
+
return node;
|
|
6546
|
+
}
|
|
6547
|
+
node.value = String(value);
|
|
6548
|
+
return node;
|
|
6549
|
+
}
|
|
6550
|
+
applyObjectToCommon(target, patch) {
|
|
6551
|
+
Object.entries(patch).forEach(([rawTag, value]) => {
|
|
6552
|
+
if (rawTag === "value") {
|
|
6553
|
+
if (value === null || value === void 0 || Array.isArray(value) || isObjectPatch(value)) {
|
|
6554
|
+
return;
|
|
6555
|
+
}
|
|
6556
|
+
target.value = String(value);
|
|
6557
|
+
return;
|
|
6558
|
+
}
|
|
6559
|
+
if (rawTag === "id") {
|
|
6560
|
+
if (typeof value === "string") {
|
|
6561
|
+
target.id = value;
|
|
6562
|
+
}
|
|
6563
|
+
return;
|
|
6564
|
+
}
|
|
6565
|
+
const tag = rawTag;
|
|
6566
|
+
if (value === void 0) {
|
|
6567
|
+
return;
|
|
6568
|
+
}
|
|
6569
|
+
if (value === null) {
|
|
6570
|
+
target.remove(tag);
|
|
6571
|
+
return;
|
|
6572
|
+
}
|
|
6573
|
+
if (Array.isArray(value)) {
|
|
6574
|
+
target.remove(tag);
|
|
6575
|
+
value.forEach((item) => {
|
|
6576
|
+
const listNode = this.createNodeFromPatchValue(
|
|
6577
|
+
item,
|
|
6578
|
+
target.main ?? this
|
|
6579
|
+
);
|
|
6580
|
+
if (listNode) {
|
|
6581
|
+
target.assign(tag, listNode);
|
|
6582
|
+
}
|
|
6583
|
+
});
|
|
6584
|
+
return;
|
|
6585
|
+
}
|
|
6586
|
+
if (isObjectPatch(value)) {
|
|
6587
|
+
const existing = target.get(tag);
|
|
6588
|
+
const objectNode = existing ?? createCommon(this, void 0, target.main ?? this);
|
|
6589
|
+
this.applyObjectToCommon(objectNode, value);
|
|
6590
|
+
target.set(tag, objectNode);
|
|
6591
|
+
return;
|
|
6592
|
+
}
|
|
6593
|
+
target.set(tag, String(value));
|
|
6594
|
+
});
|
|
6595
|
+
}
|
|
6596
|
+
applyObject(patch) {
|
|
6597
|
+
this.applyObjectToCommon(this, patch);
|
|
6598
|
+
return this;
|
|
6599
|
+
}
|
|
6526
6600
|
indis() {
|
|
6527
6601
|
return this.getList("@@INDI");
|
|
6528
6602
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeviz/gedcom-parser",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "Lightweight, pluggable GEDCOM parser for JavaScript/TypeScript with optional caching and place matching. Zero browser dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|