gedcom-d3 2.5.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,14 @@
2
2
  "permissions": {
3
3
  "allow": [
4
4
  "Bash(chmod:*)",
5
- "Bash(./publish.sh:*)"
5
+ "Bash(./publish.sh:*)",
6
+ "Bash(while read hash msg)",
7
+ "Bash(do echo \"=== $msg \\($hash\\) ===\")",
8
+ "Bash(done)",
9
+ "Bash(npm run release:*)",
10
+ "Bash(npm whoami:*)",
11
+ "Bash(npm login:*)",
12
+ "Bash(npm publish:*)"
6
13
  ]
7
14
  }
8
15
  }
package/d3ize.js CHANGED
@@ -191,6 +191,14 @@ const getFirstName = (p) => {
191
191
  return firstNameNode.data;
192
192
  }
193
193
  } else {
194
+ // Fallback: extract given name from NAME value (e.g. "Harry /Potter/")
195
+ const nameData = nameNode.data || "";
196
+ const slashIndex = nameData.indexOf("/");
197
+ const givenPart = (slashIndex !== -1 ? nameData.slice(0, slashIndex) : nameData).trim();
198
+ if (givenPart) {
199
+ const spaceIndex = givenPart.indexOf(" ");
200
+ return spaceIndex !== -1 ? givenPart.slice(0, spaceIndex) : givenPart;
201
+ }
194
202
  return "?";
195
203
  }
196
204
  } else {
@@ -245,7 +253,7 @@ const getGender = (p) => {
245
253
  if (genderNode) {
246
254
  return genderNode.data;
247
255
  } else {
248
- return "Unknown";
256
+ return "U";
249
257
  }
250
258
  };
251
259
 
@@ -266,6 +274,12 @@ const getDOB = (p) => {
266
274
  }
267
275
  };
268
276
 
277
+ // Extract a 4-digit year from a date string
278
+ const extractYear = (dateStr) => {
279
+ const match = dateStr.match(/\b(\d{4})\b/);
280
+ return match ? match[1] : "?";
281
+ };
282
+
269
283
  // Get year of birth
270
284
  const getYOB = (p) => {
271
285
  // Find 'BIRT' tag
@@ -274,7 +288,7 @@ const getYOB = (p) => {
274
288
  // Find 'DATE' tag
275
289
  let dateNode = (dobNode.tree.filter(hasTag("DATE")) || [])[0];
276
290
  if (dateNode) {
277
- return dateNode.data.slice(-4);
291
+ return extractYear(dateNode.data);
278
292
  } else {
279
293
  return "?";
280
294
  }
@@ -303,7 +317,6 @@ const getPOB = (p) => {
303
317
  // Get date of death
304
318
  const getDOD = (p) => {
305
319
  // Find 'DEAT' tag
306
- let dobNode = (p.tree.filter(hasTag("BIRT")) || [])[0];
307
320
  let dodNode = (p.tree.filter(hasTag("DEAT")) || [])[0];
308
321
  if (dodNode) {
309
322
  // Find 'DATE' tag
@@ -313,15 +326,8 @@ const getDOD = (p) => {
313
326
  } else {
314
327
  return "?";
315
328
  }
316
- } else if (dobNode) {
317
- let dateNode = (dobNode.tree.filter(hasTag("DATE")) || [])[0];
318
- if (dateNode) {
319
- return dateNode.data.slice(-4) + 100;
320
- } else {
321
- return "?";
322
- }
323
329
  } else {
324
- return "Present";
330
+ return "?";
325
331
  }
326
332
  };
327
333
 
@@ -340,7 +346,7 @@ const getYOD = (p) => {
340
346
 
341
347
  // If death date listed
342
348
  if (dateNode) {
343
- return dateNode.data.slice(-4);
349
+ return extractYear(dateNode.data);
344
350
  } else {
345
351
  return "?";
346
352
  }
@@ -352,7 +358,8 @@ const getYOD = (p) => {
352
358
  // If DOB listed
353
359
  if (dateNode) {
354
360
  // If born > 100 yrs ago, call dead
355
- if (dateNode.data.slice(-4) < thisYear - 100) {
361
+ let birthYear = extractYear(dateNode.data);
362
+ if (birthYear !== "?" && Number(birthYear) < thisYear - 100) {
356
363
  return "?";
357
364
  } else {
358
365
  return "Present";
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "gedcom-d3",
3
- "version": "2.5.0",
3
+ "version": "2.9.0",
4
4
  "description": "A GEDCOM parser, which translates GEDCOM (.ged) files into D3 capable JSON. This package is specifically designed to prepare data for use in https://github.com/oh-kay-blanket/blood-lines",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "publish": "./publish.sh minor"
8
+ "release": "./publish.sh minor"
9
9
  },
10
10
  "keywords": [
11
11
  "gedcom",