@treeviz/gedcom-parser 1.0.13 → 1.0.15
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/index.d.ts +2 -28
- package/dist/classes/index.js +6713 -21
- package/dist/classes/index.js.map +1 -0
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +7826 -24
- package/dist/cli/index.js.map +1 -0
- package/dist/constants/index.d.ts +49 -4
- package/dist/constants/index.js +5797 -4
- package/dist/constants/index.js.map +1 -0
- package/dist/factories/index.d.ts +202 -13
- package/dist/factories/index.js +5782 -8
- package/dist/factories/index.js.map +1 -0
- package/dist/index-BvW-KWJP.d.ts +1654 -0
- package/dist/index.d.ts +9 -28
- package/dist/index.js +7380 -35
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts +2 -12
- package/dist/interfaces/index.js +3 -1
- package/dist/interfaces/index.js.map +1 -0
- package/dist/kinship-translator/index.d.ts +146 -11
- package/dist/kinship-translator/index.js +5727 -9
- package/dist/kinship-translator/index.js.map +1 -0
- package/dist/place-parser-RlXCXZ8F.d.ts +37 -0
- package/dist/structures/index.d.ts +25 -27
- package/dist/structures/index.js +3 -1
- package/dist/structures/index.js.map +1 -0
- package/dist/types/index.d.ts +69 -8
- package/dist/types/index.js +31 -6
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +91 -18
- package/dist/utils/index.js +6953 -17
- package/dist/utils/index.js.map +1 -0
- package/package.json +4 -3
- package/dist/classes/common.d.ts +0 -91
- package/dist/classes/common.d.ts.map +0 -1
- package/dist/classes/common.js +0 -488
- package/dist/classes/date.d.ts +0 -27
- package/dist/classes/date.d.ts.map +0 -1
- package/dist/classes/date.js +0 -178
- package/dist/classes/fam.d.ts +0 -19
- package/dist/classes/fam.d.ts.map +0 -1
- package/dist/classes/fam.js +0 -38
- package/dist/classes/fams.d.ts +0 -16
- package/dist/classes/fams.d.ts.map +0 -1
- package/dist/classes/fams.js +0 -41
- package/dist/classes/gedcom.d.ts +0 -139
- package/dist/classes/gedcom.d.ts.map +0 -1
- package/dist/classes/gedcom.js +0 -910
- package/dist/classes/index.d.ts.map +0 -1
- package/dist/classes/indi.d.ts +0 -323
- package/dist/classes/indi.d.ts.map +0 -1
- package/dist/classes/indi.js +0 -2131
- package/dist/classes/indis.d.ts +0 -55
- package/dist/classes/indis.d.ts.map +0 -1
- package/dist/classes/indis.js +0 -457
- package/dist/classes/list.d.ts +0 -55
- package/dist/classes/list.d.ts.map +0 -1
- package/dist/classes/list.js +0 -440
- package/dist/classes/name.d.ts +0 -20
- package/dist/classes/name.d.ts.map +0 -1
- package/dist/classes/name.js +0 -48
- package/dist/classes/note.d.ts +0 -12
- package/dist/classes/note.d.ts.map +0 -1
- package/dist/classes/note.js +0 -46
- package/dist/classes/obje.d.ts +0 -12
- package/dist/classes/obje.d.ts.map +0 -1
- package/dist/classes/obje.js +0 -81
- package/dist/classes/objes.d.ts +0 -8
- package/dist/classes/objes.d.ts.map +0 -1
- package/dist/classes/objes.js +0 -13
- package/dist/classes/repo.d.ts +0 -11
- package/dist/classes/repo.d.ts.map +0 -1
- package/dist/classes/repo.js +0 -6
- package/dist/classes/repos.d.ts +0 -8
- package/dist/classes/repos.d.ts.map +0 -1
- package/dist/classes/repos.js +0 -13
- package/dist/classes/sour.d.ts +0 -11
- package/dist/classes/sour.d.ts.map +0 -1
- package/dist/classes/sour.js +0 -6
- package/dist/classes/sours.d.ts +0 -8
- package/dist/classes/sours.d.ts.map +0 -1
- package/dist/classes/sours.js +0 -13
- package/dist/classes/subm.d.ts +0 -10
- package/dist/classes/subm.d.ts.map +0 -1
- package/dist/classes/subm.js +0 -6
- package/dist/classes/subms.d.ts +0 -8
- package/dist/classes/subms.d.ts.map +0 -1
- package/dist/classes/subms.js +0 -13
- package/dist/cli/commands/convert.d.ts +0 -3
- package/dist/cli/commands/convert.d.ts.map +0 -1
- package/dist/cli/commands/convert.js +0 -83
- package/dist/cli/commands/extract.d.ts +0 -3
- package/dist/cli/commands/extract.d.ts.map +0 -1
- package/dist/cli/commands/extract.js +0 -85
- package/dist/cli/commands/find.d.ts +0 -3
- package/dist/cli/commands/find.d.ts.map +0 -1
- package/dist/cli/commands/find.js +0 -97
- package/dist/cli/commands/info.d.ts +0 -3
- package/dist/cli/commands/info.d.ts.map +0 -1
- package/dist/cli/commands/info.js +0 -80
- package/dist/cli/commands/merge.d.ts +0 -3
- package/dist/cli/commands/merge.d.ts.map +0 -1
- package/dist/cli/commands/merge.js +0 -61
- package/dist/cli/commands/relatives.d.ts +0 -3
- package/dist/cli/commands/relatives.d.ts.map +0 -1
- package/dist/cli/commands/relatives.js +0 -107
- package/dist/cli/commands/show.d.ts +0 -3
- package/dist/cli/commands/show.d.ts.map +0 -1
- package/dist/cli/commands/show.js +0 -176
- package/dist/cli/commands/stats.d.ts +0 -3
- package/dist/cli/commands/stats.d.ts.map +0 -1
- package/dist/cli/commands/stats.js +0 -59
- package/dist/cli/commands/validate.d.ts +0 -3
- package/dist/cli/commands/validate.d.ts.map +0 -1
- package/dist/cli/commands/validate.js +0 -148
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/utils/formatters.d.ts +0 -69
- package/dist/cli/utils/formatters.d.ts.map +0 -1
- package/dist/cli/utils/formatters.js +0 -125
- package/dist/cli/utils/helpers.d.ts +0 -21
- package/dist/cli/utils/helpers.d.ts.map +0 -1
- package/dist/cli/utils/helpers.js +0 -58
- package/dist/constants/constants.d.ts +0 -14
- package/dist/constants/constants.d.ts.map +0 -1
- package/dist/constants/constants.js +0 -13
- package/dist/constants/filters.d.ts +0 -18
- package/dist/constants/filters.d.ts.map +0 -1
- package/dist/constants/filters.js +0 -44
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/orders.d.ts +0 -17
- package/dist/constants/orders.d.ts.map +0 -1
- package/dist/constants/orders.js +0 -240
- package/dist/factories/cache-factory.d.ts +0 -30
- package/dist/factories/cache-factory.d.ts.map +0 -1
- package/dist/factories/cache-factory.js +0 -43
- package/dist/factories/date-locale-factory.d.ts +0 -30
- package/dist/factories/date-locale-factory.d.ts.map +0 -1
- package/dist/factories/date-locale-factory.js +0 -34
- package/dist/factories/i18n-factory.d.ts +0 -40
- package/dist/factories/i18n-factory.d.ts.map +0 -1
- package/dist/factories/i18n-factory.js +0 -44
- package/dist/factories/index.d.ts.map +0 -1
- package/dist/factories/kinship-factory.d.ts +0 -38
- package/dist/factories/kinship-factory.d.ts.map +0 -1
- package/dist/factories/kinship-factory.js +0 -35
- package/dist/factories/place-parser-provider.d.ts +0 -32
- package/dist/factories/place-parser-provider.d.ts.map +0 -1
- package/dist/factories/place-parser-provider.js +0 -35
- package/dist/factories/place-translator-provider.d.ts +0 -32
- package/dist/factories/place-translator-provider.d.ts.map +0 -1
- package/dist/factories/place-translator-provider.js +0 -35
- package/dist/index.d.ts.map +0 -1
- package/dist/interfaces/common.d.ts +0 -43
- package/dist/interfaces/common.d.ts.map +0 -1
- package/dist/interfaces/common.js +0 -1
- package/dist/interfaces/fam.d.ts +0 -11
- package/dist/interfaces/fam.d.ts.map +0 -1
- package/dist/interfaces/fam.js +0 -1
- package/dist/interfaces/fams.d.ts +0 -9
- package/dist/interfaces/fams.d.ts.map +0 -1
- package/dist/interfaces/fams.js +0 -1
- package/dist/interfaces/gedcom.d.ts +0 -30
- package/dist/interfaces/gedcom.d.ts.map +0 -1
- package/dist/interfaces/gedcom.js +0 -1
- package/dist/interfaces/index.d.ts.map +0 -1
- package/dist/interfaces/indi.d.ts +0 -113
- package/dist/interfaces/indi.d.ts.map +0 -1
- package/dist/interfaces/indi.js +0 -1
- package/dist/interfaces/indis.d.ts +0 -31
- package/dist/interfaces/indis.d.ts.map +0 -1
- package/dist/interfaces/indis.js +0 -1
- package/dist/interfaces/list.d.ts +0 -52
- package/dist/interfaces/list.d.ts.map +0 -1
- package/dist/interfaces/list.js +0 -1
- package/dist/interfaces/obje.d.ts +0 -7
- package/dist/interfaces/obje.d.ts.map +0 -1
- package/dist/interfaces/obje.js +0 -1
- package/dist/interfaces/repo.d.ts +0 -7
- package/dist/interfaces/repo.d.ts.map +0 -1
- package/dist/interfaces/repo.js +0 -1
- package/dist/interfaces/sour.d.ts +0 -7
- package/dist/interfaces/sour.d.ts.map +0 -1
- package/dist/interfaces/sour.js +0 -1
- package/dist/interfaces/subm.d.ts +0 -6
- package/dist/interfaces/subm.d.ts.map +0 -1
- package/dist/interfaces/subm.js +0 -1
- package/dist/kinship-translator/index.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.basic.d.ts +0 -30
- package/dist/kinship-translator/kinship-translator.basic.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.basic.js +0 -74
- package/dist/kinship-translator/kinship-translator.d.ts +0 -26
- package/dist/kinship-translator/kinship-translator.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.de.d.ts +0 -18
- package/dist/kinship-translator/kinship-translator.de.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.de.js +0 -180
- package/dist/kinship-translator/kinship-translator.en.d.ts +0 -18
- package/dist/kinship-translator/kinship-translator.en.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.en.js +0 -182
- package/dist/kinship-translator/kinship-translator.es.d.ts +0 -18
- package/dist/kinship-translator/kinship-translator.es.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.es.js +0 -181
- package/dist/kinship-translator/kinship-translator.fr.d.ts +0 -18
- package/dist/kinship-translator/kinship-translator.fr.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.fr.js +0 -181
- package/dist/kinship-translator/kinship-translator.hu.d.ts +0 -19
- package/dist/kinship-translator/kinship-translator.hu.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.hu.js +0 -226
- package/dist/kinship-translator/kinship-translator.interface.d.ts +0 -19
- package/dist/kinship-translator/kinship-translator.interface.d.ts.map +0 -1
- package/dist/kinship-translator/kinship-translator.interface.js +0 -1
- package/dist/kinship-translator/kinship-translator.js +0 -103
- package/dist/kinship-translator/patterns.de.d.ts +0 -2
- package/dist/kinship-translator/patterns.de.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.de.js +0 -14
- package/dist/kinship-translator/patterns.en.d.ts +0 -2
- package/dist/kinship-translator/patterns.en.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.en.js +0 -14
- package/dist/kinship-translator/patterns.es.d.ts +0 -2
- package/dist/kinship-translator/patterns.es.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.es.js +0 -14
- package/dist/kinship-translator/patterns.fr.d.ts +0 -2
- package/dist/kinship-translator/patterns.fr.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.fr.js +0 -14
- package/dist/kinship-translator/patterns.hu.d.ts +0 -6
- package/dist/kinship-translator/patterns.hu.d.ts.map +0 -1
- package/dist/kinship-translator/patterns.hu.js +0 -97
- package/dist/kinship-translator/translators.d.ts +0 -6
- package/dist/kinship-translator/translators.d.ts.map +0 -1
- package/dist/kinship-translator/translators.js +0 -5
- package/dist/kinship-translator/types.d.ts +0 -9
- package/dist/kinship-translator/types.d.ts.map +0 -1
- package/dist/kinship-translator/types.js +0 -1
- package/dist/structures/address.d.ts +0 -14
- package/dist/structures/address.d.ts.map +0 -1
- package/dist/structures/address.js +0 -1
- package/dist/structures/association.d.ts +0 -13
- package/dist/structures/association.d.ts.map +0 -1
- package/dist/structures/association.js +0 -1
- package/dist/structures/change-date.d.ts +0 -8
- package/dist/structures/change-date.d.ts.map +0 -1
- package/dist/structures/change-date.js +0 -1
- package/dist/structures/creation-date.d.ts +0 -7
- package/dist/structures/creation-date.d.ts.map +0 -1
- package/dist/structures/creation-date.js +0 -1
- package/dist/structures/date.d.ts +0 -9
- package/dist/structures/date.d.ts.map +0 -1
- package/dist/structures/date.js +0 -1
- package/dist/structures/event-detail-structure.d.ts +0 -25
- package/dist/structures/event-detail-structure.d.ts.map +0 -1
- package/dist/structures/event-detail-structure.js +0 -1
- package/dist/structures/family.d.ts +0 -34
- package/dist/structures/family.d.ts.map +0 -1
- package/dist/structures/family.js +0 -1
- package/dist/structures/gedcom.d.ts +0 -59
- package/dist/structures/gedcom.d.ts.map +0 -1
- package/dist/structures/gedcom.js +0 -1
- package/dist/structures/index.d.ts.map +0 -1
- package/dist/structures/individual-event-detail-structure.d.ts +0 -9
- package/dist/structures/individual-event-detail-structure.d.ts.map +0 -1
- package/dist/structures/individual-event-detail-structure.js +0 -1
- package/dist/structures/individual-event-structure.d.ts +0 -83
- package/dist/structures/individual-event-structure.d.ts.map +0 -1
- package/dist/structures/individual-event-structure.js +0 -1
- package/dist/structures/individual.d.ts +0 -40
- package/dist/structures/individual.d.ts.map +0 -1
- package/dist/structures/individual.js +0 -1
- package/dist/structures/lds-ordinance-detail.d.ts +0 -17
- package/dist/structures/lds-ordinance-detail.d.ts.map +0 -1
- package/dist/structures/lds-ordinance-detail.js +0 -1
- package/dist/structures/lds-spouse-sealing.d.ts +0 -7
- package/dist/structures/lds-spouse-sealing.d.ts.map +0 -1
- package/dist/structures/lds-spouse-sealing.js +0 -1
- package/dist/structures/marriage-date.d.ts +0 -11
- package/dist/structures/marriage-date.d.ts.map +0 -1
- package/dist/structures/marriage-date.js +0 -1
- package/dist/structures/multimedia-link.d.ts +0 -16
- package/dist/structures/multimedia-link.d.ts.map +0 -1
- package/dist/structures/multimedia-link.js +0 -1
- package/dist/structures/non-event.d.ts +0 -12
- package/dist/structures/non-event.d.ts.map +0 -1
- package/dist/structures/non-event.js +0 -1
- package/dist/structures/note.d.ts +0 -16
- package/dist/structures/note.d.ts.map +0 -1
- package/dist/structures/note.js +0 -1
- package/dist/structures/personal-name-pieces.d.ts +0 -11
- package/dist/structures/personal-name-pieces.d.ts.map +0 -1
- package/dist/structures/personal-name-pieces.js +0 -1
- package/dist/structures/personal-name.d.ts +0 -16
- package/dist/structures/personal-name.d.ts.map +0 -1
- package/dist/structures/personal-name.js +0 -1
- package/dist/structures/place.d.ts +0 -20
- package/dist/structures/place.d.ts.map +0 -1
- package/dist/structures/place.js +0 -1
- package/dist/structures/repository.d.ts +0 -6
- package/dist/structures/repository.d.ts.map +0 -1
- package/dist/structures/repository.js +0 -1
- package/dist/structures/source-citation.d.ts +0 -27
- package/dist/structures/source-citation.d.ts.map +0 -1
- package/dist/structures/source-citation.js +0 -1
- package/dist/structures/source-repository-citation.d.ts +0 -13
- package/dist/structures/source-repository-citation.d.ts.map +0 -1
- package/dist/structures/source-repository-citation.js +0 -1
- package/dist/structures/source.d.ts +0 -28
- package/dist/structures/source.d.ts.map +0 -1
- package/dist/structures/source.js +0 -1
- package/dist/types/ancestry-media.d.ts +0 -65
- package/dist/types/ancestry-media.d.ts.map +0 -1
- package/dist/types/ancestry-media.js +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/settings.d.ts +0 -12
- package/dist/types/settings.d.ts.map +0 -1
- package/dist/types/settings.js +0 -1
- package/dist/types/types.d.ts +0 -225
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/types.js +0 -26
- package/dist/utils/cache.d.ts +0 -22
- package/dist/utils/cache.d.ts.map +0 -1
- package/dist/utils/cache.js +0 -57
- package/dist/utils/common-creator.d.ts +0 -13
- package/dist/utils/common-creator.d.ts.map +0 -1
- package/dist/utils/common-creator.js +0 -72
- package/dist/utils/date-formatter.d.ts +0 -35
- package/dist/utils/date-formatter.d.ts.map +0 -1
- package/dist/utils/date-formatter.js +0 -207
- package/dist/utils/get-all-prop.d.ts +0 -4
- package/dist/utils/get-all-prop.d.ts.map +0 -1
- package/dist/utils/get-all-prop.js +0 -5
- package/dist/utils/get-family-with.d.ts +0 -5
- package/dist/utils/get-family-with.d.ts.map +0 -1
- package/dist/utils/get-family-with.js +0 -11
- package/dist/utils/get-places.d.ts +0 -21
- package/dist/utils/get-places.d.ts.map +0 -1
- package/dist/utils/get-places.js +0 -77
- package/dist/utils/get-product-details.d.ts +0 -4
- package/dist/utils/get-product-details.d.ts.map +0 -1
- package/dist/utils/get-product-details.js +0 -6
- package/dist/utils/get-raw-size.d.ts +0 -2
- package/dist/utils/get-raw-size.d.ts.map +0 -1
- package/dist/utils/get-raw-size.js +0 -3
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/logger.d.ts +0 -3
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -11
- package/dist/utils/name-formatter.d.ts +0 -10
- package/dist/utils/name-formatter.d.ts.map +0 -1
- package/dist/utils/name-formatter.js +0 -45
- package/dist/utils/nested-group.d.ts +0 -4
- package/dist/utils/nested-group.d.ts.map +0 -1
- package/dist/utils/nested-group.js +0 -34
- package/dist/utils/ordinalize.d.ts +0 -3
- package/dist/utils/ordinalize.d.ts.map +0 -1
- package/dist/utils/ordinalize.js +0 -104
- package/dist/utils/parser.d.ts +0 -17
- package/dist/utils/parser.d.ts.map +0 -1
- package/dist/utils/parser.js +0 -321
- package/dist/utils/place-parser.d.ts +0 -16
- package/dist/utils/place-parser.d.ts.map +0 -1
- package/dist/utils/place-parser.js +0 -46
- package/dist/utils/place-translator.d.ts +0 -6
- package/dist/utils/place-translator.d.ts.map +0 -1
- package/dist/utils/place-translator.js +0 -8
- package/dist/utils/place-types.d.ts +0 -27
- package/dist/utils/place-types.d.ts.map +0 -1
- package/dist/utils/place-types.js +0 -14
- package/dist/utils/range.d.ts +0 -19
- package/dist/utils/range.d.ts.map +0 -1
- package/dist/utils/range.js +0 -265
package/dist/utils/range.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
const toTuple = (r) => {
|
|
2
|
-
if (Array.isArray(r)) {
|
|
3
|
-
const [s, e] = r;
|
|
4
|
-
return [
|
|
5
|
-
s === undefined ? undefined : Number(s),
|
|
6
|
-
e === undefined ? undefined : Number(e),
|
|
7
|
-
];
|
|
8
|
-
}
|
|
9
|
-
if (r === "-" || r === "")
|
|
10
|
-
return [undefined, undefined];
|
|
11
|
-
const [s, e] = r.split("-");
|
|
12
|
-
return [s ? Number(s) : undefined, e ? Number(e) : undefined];
|
|
13
|
-
};
|
|
14
|
-
export const fromTuple = (s, e) => {
|
|
15
|
-
if (s === undefined && e === undefined)
|
|
16
|
-
return "-";
|
|
17
|
-
if (s === undefined)
|
|
18
|
-
return `-${e}`;
|
|
19
|
-
if (e === undefined)
|
|
20
|
-
return `${s}-`;
|
|
21
|
-
return `${s}-${e}`;
|
|
22
|
-
};
|
|
23
|
-
const isValidRange = (range) => {
|
|
24
|
-
if (!Array.isArray(range) &&
|
|
25
|
-
range !== "" &&
|
|
26
|
-
range !== "-" &&
|
|
27
|
-
!/^\d*-\d*$/.test(range)) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (Array.isArray(range) &&
|
|
31
|
-
range.some((r) => typeof r === "string" && isNaN(Number(r)))) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
};
|
|
36
|
-
export const inRange = (year, range, trueIfNoYear = false) => {
|
|
37
|
-
if (!isValidRange(range)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (!year) {
|
|
41
|
-
return trueIfNoYear;
|
|
42
|
-
}
|
|
43
|
-
const [start = -Infinity, end = Infinity] = toTuple(range);
|
|
44
|
-
if (!start && !end) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
if (start && !end) {
|
|
48
|
-
return Number(year) >= Number(start);
|
|
49
|
-
}
|
|
50
|
-
if (!start && end) {
|
|
51
|
-
return Number(year) <= Number(end);
|
|
52
|
-
}
|
|
53
|
-
return Number(start) <= Number(year) && Number(year) <= Number(end);
|
|
54
|
-
};
|
|
55
|
-
export const isIntersectedRange = (range1, range2) => {
|
|
56
|
-
if (!isValidRange(range1) || !isValidRange(range2)) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
const [start1 = -Infinity, end1 = Infinity] = toTuple(range1);
|
|
60
|
-
const [start2 = -Infinity, end2 = Infinity] = toTuple(range2);
|
|
61
|
-
if (!start1 && !end1) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if (!start2 && !end2) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
if (start1 && !end1) {
|
|
68
|
-
if (start2 && !end2) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
if (!start2 && end2) {
|
|
72
|
-
return Number(start1) <= Number(end2);
|
|
73
|
-
}
|
|
74
|
-
return Number(start1) <= Number(end2);
|
|
75
|
-
}
|
|
76
|
-
if (!start1 && end1) {
|
|
77
|
-
if (start2 && !end2) {
|
|
78
|
-
return Number(start2) <= Number(end1);
|
|
79
|
-
}
|
|
80
|
-
if (!start2 && end2) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
return Number(start2) <= Number(end1);
|
|
84
|
-
}
|
|
85
|
-
if (start1 && end1) {
|
|
86
|
-
if (start2 && !end2) {
|
|
87
|
-
return Number(start2) <= Number(end1);
|
|
88
|
-
}
|
|
89
|
-
if (!start2 && end2) {
|
|
90
|
-
return Number(start1) <= Number(end2);
|
|
91
|
-
}
|
|
92
|
-
return Number(start1) <= Number(end2) && Number(start2) <= Number(end1);
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
};
|
|
96
|
-
export const splitRange = (to, by) => {
|
|
97
|
-
const [toStart, toEnd] = toTuple(to);
|
|
98
|
-
const [byStart, byEnd] = toTuple(by);
|
|
99
|
-
// Helper to build the PrimitiveRange string from optional numeric bounds
|
|
100
|
-
const make = (s, e) => fromTuple(s, e);
|
|
101
|
-
// If there is no intersection at all, return the full "to" range
|
|
102
|
-
if (!isIntersectedRange(to, by)) {
|
|
103
|
-
return [{ range: fromTuple(toStart, toEnd), to: true }];
|
|
104
|
-
}
|
|
105
|
-
// Calculate overlap boundaries between the two ranges
|
|
106
|
-
const overlapStart = Math.max(toStart ?? -Infinity, byStart ?? -Infinity);
|
|
107
|
-
const overlapEnd = Math.min(toEnd ?? Infinity, byEnd ?? Infinity);
|
|
108
|
-
const results = [];
|
|
109
|
-
// Lower segment of "to" that lies completely before the overlap
|
|
110
|
-
if ((toStart ?? -Infinity) < overlapStart) {
|
|
111
|
-
const loEnd = overlapStart - 1;
|
|
112
|
-
results.push({
|
|
113
|
-
range: make(toStart, loEnd),
|
|
114
|
-
to: true,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
// The overlapping segment between "to" and "by"
|
|
118
|
-
results.push({
|
|
119
|
-
range: make(Number.isFinite(overlapStart) ? overlapStart : undefined, Number.isFinite(overlapEnd) ? overlapEnd : undefined),
|
|
120
|
-
to: true,
|
|
121
|
-
by: true,
|
|
122
|
-
});
|
|
123
|
-
// Upper segment of "to" that lies completely after the overlap
|
|
124
|
-
if ((toEnd ?? Infinity) > overlapEnd) {
|
|
125
|
-
const hiStart = overlapEnd + 1;
|
|
126
|
-
results.push({
|
|
127
|
-
range: make(hiStart, toEnd),
|
|
128
|
-
to: true,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return results;
|
|
132
|
-
};
|
|
133
|
-
// Additional range splitting utilities for complex operations
|
|
134
|
-
export function parseRangeBounds(rangeKey) {
|
|
135
|
-
const split = rangeKey.split("-");
|
|
136
|
-
const start = split[0] ? Number(split[0]) : undefined;
|
|
137
|
-
const end = split[1] ? Number(split[1]) : undefined;
|
|
138
|
-
return [start, end];
|
|
139
|
-
}
|
|
140
|
-
export function isRangeContained(containedRange, containerRange) {
|
|
141
|
-
const [containedStart, containedEnd] = parseRangeBounds(containedRange);
|
|
142
|
-
const [containerStart, containerEnd] = parseRangeBounds(containerRange);
|
|
143
|
-
const containedStartNum = containedStart ?? -Infinity;
|
|
144
|
-
const containedEndNum = containedEnd ?? Infinity;
|
|
145
|
-
const containerStartNum = containerStart ?? -Infinity;
|
|
146
|
-
const containerEndNum = containerEnd ?? Infinity;
|
|
147
|
-
return (containedStartNum >= containerStartNum &&
|
|
148
|
-
containedEndNum <= containerEndNum);
|
|
149
|
-
}
|
|
150
|
-
export function extractSplitPoints(ranges) {
|
|
151
|
-
const points = new Set();
|
|
152
|
-
ranges.forEach((range) => {
|
|
153
|
-
const [start, end] = parseRangeBounds(range);
|
|
154
|
-
if (start !== undefined)
|
|
155
|
-
points.add(start);
|
|
156
|
-
if (end !== undefined)
|
|
157
|
-
points.add(end + 1);
|
|
158
|
-
});
|
|
159
|
-
return Array.from(points).sort((a, b) => a - b);
|
|
160
|
-
}
|
|
161
|
-
export function generateSplitRanges(splitPoints) {
|
|
162
|
-
const ranges = [];
|
|
163
|
-
for (let i = 0; i < splitPoints.length - 1; i++) {
|
|
164
|
-
const start = splitPoints[i];
|
|
165
|
-
const end = splitPoints[i + 1] - 1;
|
|
166
|
-
ranges.push(fromTuple(start, end));
|
|
167
|
-
}
|
|
168
|
-
return ranges;
|
|
169
|
-
}
|
|
170
|
-
export function splitOverlappingRanges(rangesToValues) {
|
|
171
|
-
if (rangesToValues.length === 0)
|
|
172
|
-
return [];
|
|
173
|
-
const ranges = rangesToValues.map(([range]) => range);
|
|
174
|
-
const splitPoints = extractSplitPoints(ranges);
|
|
175
|
-
// Generate split ranges including open-ended ranges
|
|
176
|
-
const splitRanges = [];
|
|
177
|
-
// Handle ranges before the first split point
|
|
178
|
-
if (splitPoints.length > 0) {
|
|
179
|
-
const firstPoint = splitPoints[0];
|
|
180
|
-
// Check if any range covers before firstPoint
|
|
181
|
-
const hasRangeBeforeFirst = ranges.some((range) => {
|
|
182
|
-
const [start] = parseRangeBounds(range);
|
|
183
|
-
return start === undefined || start < firstPoint;
|
|
184
|
-
});
|
|
185
|
-
if (hasRangeBeforeFirst) {
|
|
186
|
-
splitRanges.push(fromTuple(undefined, firstPoint - 1));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// Generate ranges between split points
|
|
190
|
-
for (let i = 0; i < splitPoints.length - 1; i++) {
|
|
191
|
-
const start = splitPoints[i];
|
|
192
|
-
const end = splitPoints[i + 1] - 1;
|
|
193
|
-
splitRanges.push(fromTuple(start, end));
|
|
194
|
-
}
|
|
195
|
-
// Handle ranges after the last split point
|
|
196
|
-
if (splitPoints.length > 0) {
|
|
197
|
-
const lastPoint = splitPoints[splitPoints.length - 1];
|
|
198
|
-
// Check if any range covers after lastPoint
|
|
199
|
-
const hasRangeAfterLast = ranges.some((range) => {
|
|
200
|
-
const [, end] = parseRangeBounds(range);
|
|
201
|
-
return end === undefined || end >= lastPoint;
|
|
202
|
-
});
|
|
203
|
-
if (hasRangeAfterLast) {
|
|
204
|
-
splitRanges.push(fromTuple(lastPoint, undefined));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return splitRanges
|
|
208
|
-
.map((splitRange) => {
|
|
209
|
-
const matchingValues = [];
|
|
210
|
-
rangesToValues.forEach(([originalRange, value]) => {
|
|
211
|
-
if (isRangeContained(splitRange, originalRange)) {
|
|
212
|
-
matchingValues.push(value);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
return [splitRange, matchingValues];
|
|
216
|
-
})
|
|
217
|
-
.filter(([, values]) => values.length > 0); // Only return ranges that have matching values
|
|
218
|
-
}
|
|
219
|
-
export function findMatchingRangeForSplitRange(splitRange, rangesToValues) {
|
|
220
|
-
const matchingValues = [];
|
|
221
|
-
rangesToValues.forEach(([originalRange, value]) => {
|
|
222
|
-
if (isRangeContained(splitRange, originalRange)) {
|
|
223
|
-
matchingValues.push(value);
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
return matchingValues;
|
|
227
|
-
}
|
|
228
|
-
export function extractSeparationYears(childName, ranges, parentName, ensureArray) {
|
|
229
|
-
const separationYears = [];
|
|
230
|
-
Object.entries(ranges).forEach(([rangeKey, entries]) => {
|
|
231
|
-
if (rangeKey === "names" || !entries) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const pts = entries;
|
|
235
|
-
pts.forEach((pt) => {
|
|
236
|
-
const towns = ensureArray(pt.town);
|
|
237
|
-
const keyDiffersFromTown = !towns.includes(childName);
|
|
238
|
-
const pointsToParent = towns.includes(parentName);
|
|
239
|
-
// Only consider it a parent-child relationship if town array has EXACTLY ONE entry
|
|
240
|
-
const isSingleParent = towns.length === 1;
|
|
241
|
-
// Check if this is a range where the child points to the parent (before separation)
|
|
242
|
-
if (keyDiffersFromTown && pointsToParent && isSingleParent) {
|
|
243
|
-
// The end of this range is when the child separates
|
|
244
|
-
const split = rangeKey.split("-");
|
|
245
|
-
const end = split[1] ? Number(split[1]) : undefined;
|
|
246
|
-
if (typeof end === "number") {
|
|
247
|
-
const separationYear = end + 1;
|
|
248
|
-
if (!separationYears.includes(separationYear)) {
|
|
249
|
-
separationYears.push(separationYear);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// Check if this is a range where the child becomes independent (after separation)
|
|
254
|
-
else if (!keyDiffersFromTown && !pointsToParent) {
|
|
255
|
-
const split = rangeKey.split("-");
|
|
256
|
-
const start = split[0] ? Number(split[0]) : undefined;
|
|
257
|
-
if (typeof start === "number" &&
|
|
258
|
-
!separationYears.includes(start)) {
|
|
259
|
-
separationYears.push(start);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
return separationYears.sort((a, b) => a - b);
|
|
265
|
-
}
|