@treeviz/gedcom-parser 1.0.1

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 (321) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +954 -0
  3. package/dist/classes/common.d.ts +87 -0
  4. package/dist/classes/common.d.ts.map +1 -0
  5. package/dist/classes/common.js +481 -0
  6. package/dist/classes/date.d.ts +26 -0
  7. package/dist/classes/date.d.ts.map +1 -0
  8. package/dist/classes/date.js +176 -0
  9. package/dist/classes/fam.d.ts +19 -0
  10. package/dist/classes/fam.d.ts.map +1 -0
  11. package/dist/classes/fam.js +38 -0
  12. package/dist/classes/fams.d.ts +16 -0
  13. package/dist/classes/fams.d.ts.map +1 -0
  14. package/dist/classes/fams.js +41 -0
  15. package/dist/classes/gedcom.d.ts +89 -0
  16. package/dist/classes/gedcom.d.ts.map +1 -0
  17. package/dist/classes/gedcom.js +421 -0
  18. package/dist/classes/index.d.ts +19 -0
  19. package/dist/classes/index.d.ts.map +1 -0
  20. package/dist/classes/index.js +19 -0
  21. package/dist/classes/indi.d.ts +298 -0
  22. package/dist/classes/indi.d.ts.map +1 -0
  23. package/dist/classes/indi.js +2049 -0
  24. package/dist/classes/indis.d.ts +54 -0
  25. package/dist/classes/indis.d.ts.map +1 -0
  26. package/dist/classes/indis.js +439 -0
  27. package/dist/classes/list.d.ts +55 -0
  28. package/dist/classes/list.d.ts.map +1 -0
  29. package/dist/classes/list.js +440 -0
  30. package/dist/classes/name.d.ts +20 -0
  31. package/dist/classes/name.d.ts.map +1 -0
  32. package/dist/classes/name.js +48 -0
  33. package/dist/classes/note.d.ts +12 -0
  34. package/dist/classes/note.d.ts.map +1 -0
  35. package/dist/classes/note.js +46 -0
  36. package/dist/classes/obje.d.ts +12 -0
  37. package/dist/classes/obje.d.ts.map +1 -0
  38. package/dist/classes/obje.js +81 -0
  39. package/dist/classes/objes.d.ts +8 -0
  40. package/dist/classes/objes.d.ts.map +1 -0
  41. package/dist/classes/objes.js +13 -0
  42. package/dist/classes/repo.d.ts +11 -0
  43. package/dist/classes/repo.d.ts.map +1 -0
  44. package/dist/classes/repo.js +6 -0
  45. package/dist/classes/repos.d.ts +8 -0
  46. package/dist/classes/repos.d.ts.map +1 -0
  47. package/dist/classes/repos.js +13 -0
  48. package/dist/classes/sour.d.ts +11 -0
  49. package/dist/classes/sour.d.ts.map +1 -0
  50. package/dist/classes/sour.js +6 -0
  51. package/dist/classes/sours.d.ts +8 -0
  52. package/dist/classes/sours.d.ts.map +1 -0
  53. package/dist/classes/sours.js +13 -0
  54. package/dist/classes/subm.d.ts +10 -0
  55. package/dist/classes/subm.d.ts.map +1 -0
  56. package/dist/classes/subm.js +6 -0
  57. package/dist/classes/subms.d.ts +8 -0
  58. package/dist/classes/subms.d.ts.map +1 -0
  59. package/dist/classes/subms.js +13 -0
  60. package/dist/constants/constants.d.ts +14 -0
  61. package/dist/constants/constants.d.ts.map +1 -0
  62. package/dist/constants/constants.js +13 -0
  63. package/dist/constants/filters.d.ts +17 -0
  64. package/dist/constants/filters.d.ts.map +1 -0
  65. package/dist/constants/filters.js +44 -0
  66. package/dist/constants/index.d.ts +4 -0
  67. package/dist/constants/index.d.ts.map +1 -0
  68. package/dist/constants/index.js +4 -0
  69. package/dist/constants/orders.d.ts +17 -0
  70. package/dist/constants/orders.d.ts.map +1 -0
  71. package/dist/constants/orders.js +240 -0
  72. package/dist/factories/cache-factory.d.ts +30 -0
  73. package/dist/factories/cache-factory.d.ts.map +1 -0
  74. package/dist/factories/cache-factory.js +43 -0
  75. package/dist/factories/date-locale-factory.d.ts +30 -0
  76. package/dist/factories/date-locale-factory.d.ts.map +1 -0
  77. package/dist/factories/date-locale-factory.js +34 -0
  78. package/dist/factories/i18n-factory.d.ts +40 -0
  79. package/dist/factories/i18n-factory.d.ts.map +1 -0
  80. package/dist/factories/i18n-factory.js +44 -0
  81. package/dist/factories/index.d.ts +5 -0
  82. package/dist/factories/index.d.ts.map +1 -0
  83. package/dist/factories/index.js +5 -0
  84. package/dist/factories/kinship-factory.d.ts +38 -0
  85. package/dist/factories/kinship-factory.d.ts.map +1 -0
  86. package/dist/factories/kinship-factory.js +35 -0
  87. package/dist/factories/place-parser-provider.d.ts +32 -0
  88. package/dist/factories/place-parser-provider.d.ts.map +1 -0
  89. package/dist/factories/place-parser-provider.js +35 -0
  90. package/dist/factories/place-translator-provider.d.ts +32 -0
  91. package/dist/factories/place-translator-provider.d.ts.map +1 -0
  92. package/dist/factories/place-translator-provider.js +35 -0
  93. package/dist/index.d.ts +78 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +44 -0
  96. package/dist/interfaces/common.d.ts +43 -0
  97. package/dist/interfaces/common.d.ts.map +1 -0
  98. package/dist/interfaces/common.js +1 -0
  99. package/dist/interfaces/fam.d.ts +11 -0
  100. package/dist/interfaces/fam.d.ts.map +1 -0
  101. package/dist/interfaces/fam.js +1 -0
  102. package/dist/interfaces/fams.d.ts +9 -0
  103. package/dist/interfaces/fams.d.ts.map +1 -0
  104. package/dist/interfaces/fams.js +1 -0
  105. package/dist/interfaces/gedcom.d.ts +30 -0
  106. package/dist/interfaces/gedcom.d.ts.map +1 -0
  107. package/dist/interfaces/gedcom.js +1 -0
  108. package/dist/interfaces/index.d.ts +12 -0
  109. package/dist/interfaces/index.d.ts.map +1 -0
  110. package/dist/interfaces/index.js +1 -0
  111. package/dist/interfaces/indi.d.ts +109 -0
  112. package/dist/interfaces/indi.d.ts.map +1 -0
  113. package/dist/interfaces/indi.js +1 -0
  114. package/dist/interfaces/indis.d.ts +31 -0
  115. package/dist/interfaces/indis.d.ts.map +1 -0
  116. package/dist/interfaces/indis.js +1 -0
  117. package/dist/interfaces/list.d.ts +52 -0
  118. package/dist/interfaces/list.d.ts.map +1 -0
  119. package/dist/interfaces/list.js +1 -0
  120. package/dist/interfaces/obje.d.ts +7 -0
  121. package/dist/interfaces/obje.d.ts.map +1 -0
  122. package/dist/interfaces/obje.js +1 -0
  123. package/dist/interfaces/repo.d.ts +7 -0
  124. package/dist/interfaces/repo.d.ts.map +1 -0
  125. package/dist/interfaces/repo.js +1 -0
  126. package/dist/interfaces/sour.d.ts +7 -0
  127. package/dist/interfaces/sour.d.ts.map +1 -0
  128. package/dist/interfaces/sour.js +1 -0
  129. package/dist/interfaces/subm.d.ts +6 -0
  130. package/dist/interfaces/subm.d.ts.map +1 -0
  131. package/dist/interfaces/subm.js +1 -0
  132. package/dist/kinship-translator/index.d.ts +11 -0
  133. package/dist/kinship-translator/index.d.ts.map +1 -0
  134. package/dist/kinship-translator/index.js +10 -0
  135. package/dist/kinship-translator/kinship-translator.basic.d.ts +30 -0
  136. package/dist/kinship-translator/kinship-translator.basic.d.ts.map +1 -0
  137. package/dist/kinship-translator/kinship-translator.basic.js +74 -0
  138. package/dist/kinship-translator/kinship-translator.d.ts +26 -0
  139. package/dist/kinship-translator/kinship-translator.d.ts.map +1 -0
  140. package/dist/kinship-translator/kinship-translator.de.d.ts +18 -0
  141. package/dist/kinship-translator/kinship-translator.de.d.ts.map +1 -0
  142. package/dist/kinship-translator/kinship-translator.de.js +180 -0
  143. package/dist/kinship-translator/kinship-translator.en.d.ts +18 -0
  144. package/dist/kinship-translator/kinship-translator.en.d.ts.map +1 -0
  145. package/dist/kinship-translator/kinship-translator.en.js +182 -0
  146. package/dist/kinship-translator/kinship-translator.es.d.ts +18 -0
  147. package/dist/kinship-translator/kinship-translator.es.d.ts.map +1 -0
  148. package/dist/kinship-translator/kinship-translator.es.js +181 -0
  149. package/dist/kinship-translator/kinship-translator.fr.d.ts +18 -0
  150. package/dist/kinship-translator/kinship-translator.fr.d.ts.map +1 -0
  151. package/dist/kinship-translator/kinship-translator.fr.js +181 -0
  152. package/dist/kinship-translator/kinship-translator.hu.d.ts +19 -0
  153. package/dist/kinship-translator/kinship-translator.hu.d.ts.map +1 -0
  154. package/dist/kinship-translator/kinship-translator.hu.js +226 -0
  155. package/dist/kinship-translator/kinship-translator.interface.d.ts +19 -0
  156. package/dist/kinship-translator/kinship-translator.interface.d.ts.map +1 -0
  157. package/dist/kinship-translator/kinship-translator.interface.js +1 -0
  158. package/dist/kinship-translator/kinship-translator.js +103 -0
  159. package/dist/kinship-translator/patterns.de.d.ts +2 -0
  160. package/dist/kinship-translator/patterns.de.d.ts.map +1 -0
  161. package/dist/kinship-translator/patterns.de.js +14 -0
  162. package/dist/kinship-translator/patterns.en.d.ts +2 -0
  163. package/dist/kinship-translator/patterns.en.d.ts.map +1 -0
  164. package/dist/kinship-translator/patterns.en.js +14 -0
  165. package/dist/kinship-translator/patterns.es.d.ts +2 -0
  166. package/dist/kinship-translator/patterns.es.d.ts.map +1 -0
  167. package/dist/kinship-translator/patterns.es.js +14 -0
  168. package/dist/kinship-translator/patterns.fr.d.ts +2 -0
  169. package/dist/kinship-translator/patterns.fr.d.ts.map +1 -0
  170. package/dist/kinship-translator/patterns.fr.js +14 -0
  171. package/dist/kinship-translator/patterns.hu.d.ts +6 -0
  172. package/dist/kinship-translator/patterns.hu.d.ts.map +1 -0
  173. package/dist/kinship-translator/patterns.hu.js +97 -0
  174. package/dist/kinship-translator/translators.d.ts +6 -0
  175. package/dist/kinship-translator/translators.d.ts.map +1 -0
  176. package/dist/kinship-translator/translators.js +5 -0
  177. package/dist/kinship-translator/types.d.ts +9 -0
  178. package/dist/kinship-translator/types.d.ts.map +1 -0
  179. package/dist/kinship-translator/types.js +1 -0
  180. package/dist/structures/address.d.ts +14 -0
  181. package/dist/structures/address.d.ts.map +1 -0
  182. package/dist/structures/address.js +1 -0
  183. package/dist/structures/association.d.ts +13 -0
  184. package/dist/structures/association.d.ts.map +1 -0
  185. package/dist/structures/association.js +1 -0
  186. package/dist/structures/change-date.d.ts +8 -0
  187. package/dist/structures/change-date.d.ts.map +1 -0
  188. package/dist/structures/change-date.js +1 -0
  189. package/dist/structures/creation-date.d.ts +7 -0
  190. package/dist/structures/creation-date.d.ts.map +1 -0
  191. package/dist/structures/creation-date.js +1 -0
  192. package/dist/structures/date.d.ts +9 -0
  193. package/dist/structures/date.d.ts.map +1 -0
  194. package/dist/structures/date.js +1 -0
  195. package/dist/structures/event-detail-structure.d.ts +25 -0
  196. package/dist/structures/event-detail-structure.d.ts.map +1 -0
  197. package/dist/structures/event-detail-structure.js +1 -0
  198. package/dist/structures/family.d.ts +34 -0
  199. package/dist/structures/family.d.ts.map +1 -0
  200. package/dist/structures/family.js +1 -0
  201. package/dist/structures/gedcom.d.ts +60 -0
  202. package/dist/structures/gedcom.d.ts.map +1 -0
  203. package/dist/structures/gedcom.js +1 -0
  204. package/dist/structures/index.d.ts +25 -0
  205. package/dist/structures/index.d.ts.map +1 -0
  206. package/dist/structures/index.js +1 -0
  207. package/dist/structures/individual-event-detail-structure.d.ts +9 -0
  208. package/dist/structures/individual-event-detail-structure.d.ts.map +1 -0
  209. package/dist/structures/individual-event-detail-structure.js +1 -0
  210. package/dist/structures/individual-event-structure.d.ts +83 -0
  211. package/dist/structures/individual-event-structure.d.ts.map +1 -0
  212. package/dist/structures/individual-event-structure.js +1 -0
  213. package/dist/structures/individual.d.ts +40 -0
  214. package/dist/structures/individual.d.ts.map +1 -0
  215. package/dist/structures/individual.js +1 -0
  216. package/dist/structures/lds-ordinance-detail.d.ts +17 -0
  217. package/dist/structures/lds-ordinance-detail.d.ts.map +1 -0
  218. package/dist/structures/lds-ordinance-detail.js +1 -0
  219. package/dist/structures/lds-spouse-sealing.d.ts +7 -0
  220. package/dist/structures/lds-spouse-sealing.d.ts.map +1 -0
  221. package/dist/structures/lds-spouse-sealing.js +1 -0
  222. package/dist/structures/marriage-date.d.ts +11 -0
  223. package/dist/structures/marriage-date.d.ts.map +1 -0
  224. package/dist/structures/marriage-date.js +1 -0
  225. package/dist/structures/multimedia-link.d.ts +16 -0
  226. package/dist/structures/multimedia-link.d.ts.map +1 -0
  227. package/dist/structures/multimedia-link.js +1 -0
  228. package/dist/structures/non-event.d.ts +12 -0
  229. package/dist/structures/non-event.d.ts.map +1 -0
  230. package/dist/structures/non-event.js +1 -0
  231. package/dist/structures/note.d.ts +16 -0
  232. package/dist/structures/note.d.ts.map +1 -0
  233. package/dist/structures/note.js +1 -0
  234. package/dist/structures/personal-name-pieces.d.ts +11 -0
  235. package/dist/structures/personal-name-pieces.d.ts.map +1 -0
  236. package/dist/structures/personal-name-pieces.js +1 -0
  237. package/dist/structures/personal-name.d.ts +16 -0
  238. package/dist/structures/personal-name.d.ts.map +1 -0
  239. package/dist/structures/personal-name.js +1 -0
  240. package/dist/structures/place.d.ts +20 -0
  241. package/dist/structures/place.d.ts.map +1 -0
  242. package/dist/structures/place.js +1 -0
  243. package/dist/structures/repository.d.ts +6 -0
  244. package/dist/structures/repository.d.ts.map +1 -0
  245. package/dist/structures/repository.js +1 -0
  246. package/dist/structures/source-citation.d.ts +27 -0
  247. package/dist/structures/source-citation.d.ts.map +1 -0
  248. package/dist/structures/source-citation.js +1 -0
  249. package/dist/structures/source-repository-citation.d.ts +13 -0
  250. package/dist/structures/source-repository-citation.d.ts.map +1 -0
  251. package/dist/structures/source-repository-citation.js +1 -0
  252. package/dist/structures/source.d.ts +28 -0
  253. package/dist/structures/source.d.ts.map +1 -0
  254. package/dist/structures/source.js +1 -0
  255. package/dist/types/ancestry-media.d.ts +65 -0
  256. package/dist/types/ancestry-media.d.ts.map +1 -0
  257. package/dist/types/ancestry-media.js +1 -0
  258. package/dist/types/index.d.ts +4 -0
  259. package/dist/types/index.d.ts.map +1 -0
  260. package/dist/types/index.js +4 -0
  261. package/dist/types/settings.d.ts +12 -0
  262. package/dist/types/settings.d.ts.map +1 -0
  263. package/dist/types/settings.js +1 -0
  264. package/dist/types/types.d.ts +220 -0
  265. package/dist/types/types.d.ts.map +1 -0
  266. package/dist/types/types.js +26 -0
  267. package/dist/utils/cache.d.ts +22 -0
  268. package/dist/utils/cache.d.ts.map +1 -0
  269. package/dist/utils/cache.js +57 -0
  270. package/dist/utils/common-creator.d.ts +13 -0
  271. package/dist/utils/common-creator.d.ts.map +1 -0
  272. package/dist/utils/common-creator.js +72 -0
  273. package/dist/utils/date-formatter.d.ts +35 -0
  274. package/dist/utils/date-formatter.d.ts.map +1 -0
  275. package/dist/utils/date-formatter.js +207 -0
  276. package/dist/utils/get-all-prop.d.ts +4 -0
  277. package/dist/utils/get-all-prop.d.ts.map +1 -0
  278. package/dist/utils/get-all-prop.js +5 -0
  279. package/dist/utils/get-family-with.d.ts +5 -0
  280. package/dist/utils/get-family-with.d.ts.map +1 -0
  281. package/dist/utils/get-family-with.js +11 -0
  282. package/dist/utils/get-places.d.ts +21 -0
  283. package/dist/utils/get-places.d.ts.map +1 -0
  284. package/dist/utils/get-places.js +77 -0
  285. package/dist/utils/get-product-details.d.ts +4 -0
  286. package/dist/utils/get-product-details.d.ts.map +1 -0
  287. package/dist/utils/get-product-details.js +6 -0
  288. package/dist/utils/get-raw-size.d.ts +2 -0
  289. package/dist/utils/get-raw-size.d.ts.map +1 -0
  290. package/dist/utils/get-raw-size.js +3 -0
  291. package/dist/utils/index.d.ts +17 -0
  292. package/dist/utils/index.d.ts.map +1 -0
  293. package/dist/utils/index.js +18 -0
  294. package/dist/utils/logger.d.ts +3 -0
  295. package/dist/utils/logger.d.ts.map +1 -0
  296. package/dist/utils/logger.js +11 -0
  297. package/dist/utils/name-formatter.d.ts +10 -0
  298. package/dist/utils/name-formatter.d.ts.map +1 -0
  299. package/dist/utils/name-formatter.js +45 -0
  300. package/dist/utils/nested-group.d.ts +4 -0
  301. package/dist/utils/nested-group.d.ts.map +1 -0
  302. package/dist/utils/nested-group.js +34 -0
  303. package/dist/utils/ordinalize.d.ts +3 -0
  304. package/dist/utils/ordinalize.d.ts.map +1 -0
  305. package/dist/utils/ordinalize.js +104 -0
  306. package/dist/utils/parser.d.ts +17 -0
  307. package/dist/utils/parser.d.ts.map +1 -0
  308. package/dist/utils/parser.js +322 -0
  309. package/dist/utils/place-parser.d.ts +16 -0
  310. package/dist/utils/place-parser.d.ts.map +1 -0
  311. package/dist/utils/place-parser.js +46 -0
  312. package/dist/utils/place-translator.d.ts +6 -0
  313. package/dist/utils/place-translator.d.ts.map +1 -0
  314. package/dist/utils/place-translator.js +8 -0
  315. package/dist/utils/place-types.d.ts +27 -0
  316. package/dist/utils/place-types.d.ts.map +1 -0
  317. package/dist/utils/place-types.js +14 -0
  318. package/dist/utils/range.d.ts +19 -0
  319. package/dist/utils/range.d.ts.map +1 -0
  320. package/dist/utils/range.js +265 -0
  321. package/package.json +153 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Place-related types for GEDCOM parser
3
+ * These are simple types used by the Indi class for place filtering
4
+ */
5
+ import type { Common } from "../classes/common";
6
+ export interface Place {
7
+ type: PlaceType;
8
+ raw: string;
9
+ parts: string[];
10
+ level?: number;
11
+ source?: string;
12
+ key?: string;
13
+ index?: number;
14
+ obj?: Common;
15
+ ref?: Common;
16
+ place?: string;
17
+ }
18
+ export declare enum PlaceType {
19
+ All = "ALL",
20
+ Birth = "BIRT",
21
+ Marriage = "MARR",
22
+ Death = "DEAT",
23
+ Events = "EVEN",
24
+ Military = "_MILT",
25
+ MilitaryId = "_MILTID"
26
+ }
27
+ //# sourceMappingURL=place-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"place-types.d.ts","sourceRoot":"","sources":["../../src/utils/place-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,KAAK;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,SAAS;IACpB,GAAG,QAAQ;IACX,KAAK,SAAS;IACd,QAAQ,SAAS;IACjB,KAAK,SAAS;IACd,MAAM,SAAS;IACf,QAAQ,UAAU;IAClB,UAAU,YAAY;CACtB"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Place-related types for GEDCOM parser
3
+ * These are simple types used by the Indi class for place filtering
4
+ */
5
+ export var PlaceType;
6
+ (function (PlaceType) {
7
+ PlaceType["All"] = "ALL";
8
+ PlaceType["Birth"] = "BIRT";
9
+ PlaceType["Marriage"] = "MARR";
10
+ PlaceType["Death"] = "DEAT";
11
+ PlaceType["Events"] = "EVEN";
12
+ PlaceType["Military"] = "_MILT";
13
+ PlaceType["MilitaryId"] = "_MILTID";
14
+ })(PlaceType || (PlaceType = {}));
@@ -0,0 +1,19 @@
1
+ export type PrimitiveRange = "" | "-" | `-${number}` | `${number}-` | `${number}-${number}`;
2
+ export type Range = PrimitiveRange | [(string | number)?, (string | number)?] | [string | number, (string | number)?];
3
+ export interface SplitResult {
4
+ range: PrimitiveRange;
5
+ to?: boolean;
6
+ by?: boolean;
7
+ }
8
+ export declare const fromTuple: (s?: number, e?: number) => PrimitiveRange;
9
+ export declare const inRange: (year: string | number | undefined, range: Range, trueIfNoYear?: boolean) => boolean;
10
+ export declare const isIntersectedRange: (range1: Range, range2: Range) => boolean;
11
+ export declare const splitRange: (to: Range, by: Range) => SplitResult[];
12
+ export declare function parseRangeBounds(rangeKey: PrimitiveRange): [number | undefined, number | undefined];
13
+ export declare function isRangeContained(containedRange: PrimitiveRange, containerRange: PrimitiveRange): boolean;
14
+ export declare function extractSplitPoints(ranges: PrimitiveRange[]): number[];
15
+ export declare function generateSplitRanges(splitPoints: number[]): PrimitiveRange[];
16
+ export declare function splitOverlappingRanges<T>(rangesToValues: Array<[PrimitiveRange, T]>): Array<[PrimitiveRange, T[]]>;
17
+ export declare function findMatchingRangeForSplitRange<T>(splitRange: PrimitiveRange, rangesToValues: Array<[PrimitiveRange, T]>): T[];
18
+ export declare function extractSeparationYears(childName: string, ranges: Record<string, unknown[]>, parentName: string, ensureArray: (x: unknown) => unknown[]): number[];
19
+ //# sourceMappingURL=range.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../src/utils/range.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACvB,EAAE,GACF,GAAG,GACH,IAAI,MAAM,EAAE,GACZ,GAAG,MAAM,GAAG,GACZ,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AACzB,MAAM,MAAM,KAAK,GACd,cAAc,GACd,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GACxC,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACzC,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,cAAc,CAAC;IACtB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,EAAE,CAAC,EAAE,OAAO,CAAC;CACb;AAeD,eAAO,MAAM,SAAS,GAAI,IAAI,MAAM,EAAE,IAAI,MAAM,KAAG,cAKlD,CAAC;AAsBF,eAAO,MAAM,OAAO,GACnB,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,EACjC,OAAO,KAAK,EACZ,sBAAoB,YAyBpB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,QAAQ,KAAK,EAAE,QAAQ,KAAK,YAqD9D,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,IAAI,KAAK,EAAE,IAAI,KAAK,KAAG,WAAW,EA+C5D,CAAC;AAIF,wBAAgB,gBAAgB,CAC/B,QAAQ,EAAE,cAAc,GACtB,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAK1C;AAED,wBAAgB,gBAAgB,CAC/B,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,GAC5B,OAAO,CAaT;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAUrE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAU3E;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,cAAc,EAAE,KAAK,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,GACxC,KAAK,CAAC,CAAC,cAAc,EAAE,CAAC,EAAE,CAAC,CAAC,CAuD9B;AAED,wBAAgB,8BAA8B,CAAC,CAAC,EAC/C,UAAU,EAAE,cAAc,EAC1B,cAAc,EAAE,KAAK,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,GACxC,CAAC,EAAE,CAUL;AAED,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EACjC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,OAAO,EAAE,GACpC,MAAM,EAAE,CA2CV"}
@@ -0,0 +1,265 @@
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
+ }
package/package.json ADDED
@@ -0,0 +1,153 @@
1
+ {
2
+ "name": "@treeviz/gedcom-parser",
3
+ "version": "1.0.1",
4
+ "description": "Lightweight, pluggable GEDCOM parser for JavaScript/TypeScript with optional caching and place matching. Zero browser dependencies.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./utils": {
14
+ "types": "./dist/utils/index.d.ts",
15
+ "import": "./dist/utils/index.js"
16
+ },
17
+ "./utils/cache": {
18
+ "types": "./dist/utils/cache.d.ts",
19
+ "import": "./dist/utils/cache.js"
20
+ },
21
+ "./utils/get-raw-size": {
22
+ "types": "./dist/utils/get-raw-size.d.ts",
23
+ "import": "./dist/utils/get-raw-size.js"
24
+ },
25
+ "./utils/parser": {
26
+ "types": "./dist/utils/parser.d.ts",
27
+ "import": "./dist/utils/parser.js"
28
+ },
29
+ "./classes": {
30
+ "types": "./dist/classes/index.d.ts",
31
+ "import": "./dist/classes/index.js"
32
+ },
33
+ "./classes/*": {
34
+ "types": "./dist/classes/*.d.ts",
35
+ "import": "./dist/classes/*.js"
36
+ },
37
+ "./factories": {
38
+ "types": "./dist/factories/index.d.ts",
39
+ "import": "./dist/factories/index.js"
40
+ },
41
+ "./factories/*": {
42
+ "types": "./dist/factories/*.d.ts",
43
+ "import": "./dist/factories/*.js"
44
+ },
45
+ "./constants": {
46
+ "types": "./dist/constants/index.d.ts",
47
+ "import": "./dist/constants/index.js"
48
+ },
49
+ "./constants/*": {
50
+ "types": "./dist/constants/*.d.ts",
51
+ "import": "./dist/constants/*.js"
52
+ },
53
+ "./structures": {
54
+ "types": "./dist/structures/index.d.ts",
55
+ "import": "./dist/structures/index.js"
56
+ },
57
+ "./structures/*": {
58
+ "types": "./dist/structures/*.d.ts",
59
+ "import": "./dist/structures/*.js"
60
+ },
61
+ "./kinship-translator": {
62
+ "types": "./dist/kinship-translator/index.d.ts",
63
+ "import": "./dist/kinship-translator/index.js"
64
+ },
65
+ "./kinship-translator/*": {
66
+ "types": "./dist/kinship-translator/*.d.ts",
67
+ "import": "./dist/kinship-translator/*.js"
68
+ },
69
+ "./interfaces": {
70
+ "types": "./dist/interfaces/index.d.ts",
71
+ "import": "./dist/interfaces/index.js"
72
+ },
73
+ "./interfaces/*": {
74
+ "types": "./dist/interfaces/*.d.ts",
75
+ "import": "./dist/interfaces/*.js"
76
+ },
77
+ "./types": {
78
+ "types": "./dist/types/index.d.ts",
79
+ "import": "./dist/types/index.js"
80
+ },
81
+ "./types/*": {
82
+ "types": "./dist/types/*.d.ts",
83
+ "import": "./dist/types/*.js"
84
+ },
85
+ "./utils/*": {
86
+ "types": "./dist/utils/*.d.ts",
87
+ "import": "./dist/utils/*.js"
88
+ },
89
+ "./__tests__/test-utils": {
90
+ "types": "./src/__tests__/test-utils/index.ts",
91
+ "import": "./src/__tests__/test-utils/index.ts"
92
+ }
93
+ },
94
+ "files": [
95
+ "dist",
96
+ "README.md",
97
+ "LICENSE"
98
+ ],
99
+ "scripts": {
100
+ "build": "tsc -p tsconfig.json",
101
+ "dev": "tsc -p tsconfig.json --watch",
102
+ "test": "vitest run",
103
+ "test:watch": "vitest",
104
+ "prepublishOnly": "npm run build"
105
+ },
106
+ "repository": {
107
+ "type": "git",
108
+ "url": "git+https://github.com/idavidka/gedcom-parser.git"
109
+ },
110
+ "bugs": {
111
+ "url": "https://github.com/idavidka/gedcom-parser/issues"
112
+ },
113
+ "homepage": "https://github.com/idavidka/gedcom-parser#readme",
114
+ "keywords": [
115
+ "gedcom",
116
+ "genealogy",
117
+ "parser",
118
+ "family-tree",
119
+ "typescript",
120
+ "pluggable",
121
+ "gedcom-parser",
122
+ "gedcom55",
123
+ "gedcom-5.5.1",
124
+ "family-history",
125
+ "ancestry",
126
+ "lineage",
127
+ "pedigree",
128
+ "treeviz",
129
+ "cache",
130
+ "place-matching",
131
+ "ssr",
132
+ "browser",
133
+ "nodejs"
134
+ ],
135
+ "author": {
136
+ "name": "idavidka & @treeviz contributors",
137
+ "url": "https://github.com/idavidka"
138
+ },
139
+ "license": "MIT",
140
+ "dependencies": {
141
+ "date-fns": "^2.30.0",
142
+ "lodash": "^4.17.21"
143
+ },
144
+ "devDependencies": {
145
+ "@types/lodash": "^4.17.13",
146
+ "@types/node": "^20.17.23",
147
+ "typescript": "^5.6.3",
148
+ "vitest": "^3.0.7"
149
+ },
150
+ "engines": {
151
+ "node": ">=20.0.0"
152
+ }
153
+ }