bahai-reflib-data
Advanced tools
Comparing version 0.12.1 to 0.12.2
# CHANGES for `bahai-reflib-data` | ||
## 0.12.2 | ||
- fix(`getIdForWorkSectionAndParagraph`): check for alternative title | ||
- chore: update devDeps. | ||
## 0.12.1 | ||
@@ -4,0 +9,0 @@ |
{ | ||
"name": "bahai-reflib-data", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"author": "Brett Zamir <brettz9@yahoo.com>", | ||
@@ -36,5 +36,5 @@ "contributors": [], | ||
"@brettz9/node-static": "^0.1.1", | ||
"c8": "^7.11.2", | ||
"c8": "^7.11.3", | ||
"chai": "^4.3.6", | ||
"eslint": "^8.14.0", | ||
"eslint": "^8.17.0", | ||
"eslint-config-ash-nazg": "33.1.0", | ||
@@ -47,5 +47,5 @@ "eslint-config-standard": "^17.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jsdoc": "^39.2.9", | ||
"eslint-plugin-jsdoc": "^39.3.2", | ||
"eslint-plugin-markdown": "^2.2.1", | ||
"eslint-plugin-n": "^15.2.0", | ||
"eslint-plugin-n": "^15.2.3", | ||
"eslint-plugin-no-unsanitized": "^4.0.1", | ||
@@ -57,4 +57,4 @@ "eslint-plugin-no-use-extend-native": "^0.5.0", | ||
"jsdom": "^19.0.0", | ||
"mocha": "^9.2.2", | ||
"node-fetch": "^3.2.3", | ||
"mocha": "^10.0.0", | ||
"node-fetch": "^3.2.6", | ||
"promise-throttle": "^1.1.2" | ||
@@ -61,0 +61,0 @@ }, |
@@ -129,2 +129,29 @@ import { | ||
/** | ||
* @param {string} work | ||
* @param {Language} [language] If none is provided, will check all languages | ||
* @returns {Promise<ParagraphIdInfo>} | ||
*/ | ||
async function getSectionsAndParagraphsForWork (work, language) { | ||
const sectionsAndParagraphs = await getSectionsAndParagraphsToIds( | ||
language | ||
); | ||
let sections = sectionsAndParagraphs[work]; | ||
if (!sections) { | ||
// May be using different title | ||
const [works, sectionsHolder] = await Promise.all([ | ||
getWorks(language), | ||
getSections(language) | ||
]); | ||
const url = works.find(({title}) => { | ||
return title === work; | ||
})?.url; | ||
const title = sectionsHolder.mainSections.find(({parentUrl}) => { | ||
return url === parentUrl; | ||
})?.title; | ||
sections = sectionsAndParagraphs[title]; | ||
} | ||
return sections; | ||
} | ||
/** | ||
* @param {string} work | ||
@@ -139,5 +166,6 @@ * @param {string} section | ||
) { | ||
return (await getSectionsAndParagraphsToIds( | ||
language | ||
))[work][section][paragraph]; | ||
const sectionsAndParagraphs = await getSectionsAndParagraphsForWork( | ||
work, language | ||
); | ||
return sectionsAndParagraphs[section][paragraph]; | ||
} | ||
@@ -154,26 +182,10 @@ | ||
) { | ||
const sectionsAndParagraphs = await getSectionsAndParagraphsToIds( | ||
language | ||
const sectionsAndParagraphs = await getSectionsAndParagraphsForWork( | ||
work, language | ||
); | ||
let sections = sectionsAndParagraphs[work]; | ||
if (!sections) { | ||
// May be using different title | ||
const [works, sectionsHolder] = await Promise.all([ | ||
getWorks(language), | ||
getSections(language) | ||
]); | ||
const url = works.find(({title}) => { | ||
return title === work; | ||
})?.url; | ||
const title = sectionsHolder.mainSections.find(({parentUrl}) => { | ||
return url === parentUrl; | ||
})?.title; | ||
sections = sectionsAndParagraphs[title]; | ||
if (!sections) { | ||
return undefined; | ||
} | ||
if (!sectionsAndParagraphs) { | ||
return undefined; | ||
} | ||
const paragraphsToIds = sections[section]; | ||
const paragraphsToIds = sectionsAndParagraphs[section]; | ||
if (!paragraphsToIds) { | ||
@@ -180,0 +192,0 @@ return undefined; |
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
9070851
350132