Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bahai-reflib-data

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bahai-reflib-data - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

4

CHANGES.md
# CHANGES for `bahai-reflib-data`
## 0.9.0
- feat: add `getFullInfoForUrl`
## 0.8.0

@@ -4,0 +8,0 @@

4

package.json
{
"name": "bahai-reflib-data",
"version": "0.8.0",
"version": "0.9.0",
"author": "Brett Zamir <brettz9@yahoo.com>",

@@ -62,3 +62,3 @@ "contributors": [],

"build-data": "node tools/index.js",
"eslint": "eslint --ext=js,cjs,mjs,md,html",
"eslint": "eslint --ext=js,cjs,mjs,md,html .",
"lint": "npm run eslint --",

@@ -65,0 +65,0 @@ "mocha": "mocha --require chai/register-expect.js --delay",

@@ -7,2 +7,87 @@ import {

/**
* @todo Should build optimized version to avoid all this processing
* @param {string} url
* @param {"fa"|"en"} [language] If none is provided, will check all languages
* @returns {Promise<{work: string, section: string, paragraph: number}|false>}
*/
async function getFullInfoForUrl (url, language) {
const [
idsToSectionsAndParagraphs, works, sections
] = await Promise.all([
getIdsToSectionsAndParagraphs(language),
getWorks(language),
getSections(language)
]);
const {
groups: {id}
} = url.match(/\/\d#(?<id>\d+)$/u) || {groups: {}};
if (!id) {
return false;
}
const workSectionParagraph = idsToSectionsAndParagraphs[id];
const subSectionInfo = sections.subSections.find(({
url: subSectionUrl, parentUrl, title: sectionTitle
}) => {
return subSectionUrl === url;
});
/* c8 ignore next 3 */
if (!subSectionInfo) {
return false;
}
// See discussion below on another `sections.mainSections.find`
const mainSectionInfo = sections.mainSections.find(({
parentUrl: mainSectionParentUrl
}) => {
return mainSectionParentUrl === subSectionInfo.parentUrl;
});
/* c8 ignore next 3 */
if (!mainSectionInfo) {
return false;
}
const workInfo = works.find(({url: workUrl}) => {
return subSectionInfo.parentUrl === workUrl;
});
/* c8 ignore next 3 */
if (!workInfo) {
return false;
}
const {
parentUrl: subSectionParentUrl,
url: subSectionUrl,
title: subSectionTitle,
id: subSectionId
} = subSectionInfo;
const {
parentUrl: mainSectionParentUrl,
url: mainSectionUrl,
title: mainSectionTitle,
id: mainSectionId
} = mainSectionInfo;
const {
parentUrl: workParentUrl,
url: workUrl,
title: workTitle
} = workInfo;
return {
...workSectionParagraph,
subSectionParentUrl, subSectionUrl, subSectionTitle, subSectionId,
mainSectionParentUrl, mainSectionUrl, mainSectionTitle, mainSectionId,
workParentUrl, workUrl, workTitle
};
}
/**
* @param {string} id

@@ -151,3 +236,3 @@ * @param {"fa"|"en"} [language] If none is provided, will check all languages

}) => {
const found = works.find(({url, title}) => {
const found = works.find(({title}) => {
return work === title;

@@ -194,3 +279,3 @@ });

// See discussion above on another `sections.mainSections.find`
const innerFound = works.find(({url, title}) => {
const innerFound = works.find(({title}) => {
return work === title;

@@ -226,3 +311,3 @@ });

}) => {
const found = works.find(({url, title}) => {
const found = works.find(({title}) => {
return work === title;

@@ -245,2 +330,3 @@ });

export {
getFullInfoForUrl,
getWorkSectionAndParagraphForId,

@@ -247,0 +333,0 @@ getIdForWorkSectionAndParagraph,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc