From d5017be0c66039818f51c6800ba8f53b41f9ee94 Mon Sep 17 00:00:00 2001 From: Jon Roig Date: Wed, 21 Aug 2024 19:57:37 -0700 Subject: [PATCH] return obj instead of array for name details --- lib/usBabyNames.mjs | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/usBabyNames.mjs b/lib/usBabyNames.mjs index 1e0a4d3..d371fd0 100644 --- a/lib/usBabyNames.mjs +++ b/lib/usBabyNames.mjs @@ -26,7 +26,10 @@ const getDetailed = async (nameInput, sexInput) => { console.log('err', err); reject (err); } - fulfill(rows); + if (!rows.length) { + return fulfill({}); + } + return fulfill(rows[0]); }); }); }; diff --git a/package.json b/package.json index d547711..576c93d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "usbabynames", - "version": "2.0.4", + "version": "2.0.5", "description": "Returns data about baby names used in the United States 1880-2021", "main": "lib/usBabyNames.mjs", "scripts": {