bahai-reflib-data
Advanced tools
Comparing version 0.6.0 to 0.7.0
# CHANGES for `bahai-reflib-data` | ||
## 0.7.0 | ||
- feat: add `getSubsectionUrlForWork` | ||
- feat: add `getUrlForWork` | ||
- fix: build | ||
## 0.6.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "bahai-reflib-data", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"author": "Brett Zamir <brettz9@yahoo.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [], |
@@ -56,3 +56,3 @@ import { | ||
* @param {"fa"|"en"} [language] If none is provided, will check all languages | ||
* @returns {string|undefined} | ||
* @returns {Promise<string|undefined>} | ||
*/ | ||
@@ -92,3 +92,3 @@ async function getIdForUrl (url, language) { | ||
* @param {"fa"|"en"} [language] If none is provided, will check all languages | ||
* @returns {string[]} | ||
* @returns {Promise<string[]>} | ||
*/ | ||
@@ -105,3 +105,3 @@ async function getWorkNames (language) { | ||
* @param {"fa"|"en"} [language] If none is provided, will check all languages | ||
* @returns {string[]} | ||
* @returns {Promise<string[]>} | ||
*/ | ||
@@ -123,5 +123,10 @@ async function getSectionNamesForWork (work, language) { | ||
}) => { | ||
return mainSectionParentUrl === works.find(({url, title}) => { | ||
const found = works.find(({url, title}) => { | ||
return work === title; | ||
}).url; | ||
}); | ||
/* c8 ignore next 3 */ | ||
if (!found) { | ||
return false; | ||
} | ||
return mainSectionParentUrl === found.url; | ||
}); | ||
@@ -134,2 +139,41 @@ return mainSection && mainSection.parentUrl === parentUrl; | ||
/** | ||
* @param {string} work | ||
* @param {"fa"|"en"} [language] If none is provided, will check all languages | ||
* @returns {Promise<string>} | ||
*/ | ||
async function getUrlForWork (work, language) { | ||
const found = (await getWorks(language)).find(({title}) => { | ||
return title === work; | ||
}); | ||
return found && found.url; | ||
} | ||
/** | ||
* @param {string} work | ||
* @param {"fa"|"en"} [language] If none is provided, will check all languages | ||
* @returns {Promise<string>} | ||
*/ | ||
async function getSubsectionUrlForWork (work, language) { | ||
const [works, sections] = await Promise.all([ | ||
getWorks(language), | ||
getSections(language) | ||
]); | ||
const found = sections.mainSections.find(({ | ||
parentUrl: mainSectionParentUrl | ||
}) => { | ||
const innerFound = works.find(({url, title}) => { | ||
return work === title; | ||
}); | ||
/* c8 ignore next 3 */ | ||
if (!innerFound) { | ||
return false; | ||
} | ||
return mainSectionParentUrl === innerFound.url; | ||
}); | ||
return found && found.url; | ||
} | ||
export { | ||
@@ -143,3 +187,5 @@ getWorkSectionAndParagraphForId, | ||
getWorkNames, | ||
getSectionNamesForWork | ||
getSectionNamesForWork, | ||
getUrlForWork, | ||
getSubsectionUrlForWork | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8444421
327470