@socialgouv/kali-data 2.615.0 → 2.617.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.
Files changed (35) hide show
  1. package/data/KALICONT000005635206.json +157 -27
  2. package/data/KALICONT000005635472.json +0 -1
  3. package/data/KALICONT000005635624.json +2 -2
  4. package/data/KALICONT000005635905.json +0 -1
  5. package/data/index.json +14 -42
  6. package/package.json +78 -77
  7. package/src/__tests__/index.test.js +15 -15
  8. package/src/helpers/__tests__/checkArticleIdOrCid.test.js +8 -8
  9. package/src/helpers/__tests__/isFile.test.js +14 -14
  10. package/src/helpers/checkArticleIdOrCid.js +6 -6
  11. package/src/helpers/isFile.js +1 -1
  12. package/src/helpers/withArticleIdOrCid.js +2 -2
  13. package/src/index.js +11 -11
  14. package/src/libs/__tests__/getAgreement.test.js +28 -28
  15. package/src/libs/__tests__/getAgreementArticlesWithParentSections.test.js +13 -13
  16. package/src/libs/__tests__/getAgreementArticlesWithPath.test.js +13 -13
  17. package/src/libs/__tests__/getAgreementIdFromIdOrIdcc.test.js +17 -17
  18. package/src/libs/__tests__/getAgreements.test.js +3 -3
  19. package/src/libs/__tests__/getArticleWithParentSections.test.js +19 -19
  20. package/src/libs/__tests__/getArticleWithPath.test.js +19 -19
  21. package/src/libs/__tests__/getArticles.test.js +3 -3
  22. package/src/libs/__tests__/getIndexedArticle.test.js +19 -19
  23. package/src/libs/__tests__/hasAgreement.test.js +23 -23
  24. package/src/libs/__tests__/hasArticle.test.js +14 -14
  25. package/src/libs/getAgreement.js +7 -7
  26. package/src/libs/getAgreementArticlesWithParentSections.js +22 -22
  27. package/src/libs/getAgreementArticlesWithPath.js +11 -11
  28. package/src/libs/getAgreementIdFromIdOrIdcc.js +18 -18
  29. package/src/libs/getAgreements.js +3 -3
  30. package/src/libs/getArticleWithParentSections.js +34 -34
  31. package/src/libs/getArticleWithPath.js +25 -25
  32. package/src/libs/getArticles.js +3 -3
  33. package/src/libs/getIndexedArticle.js +6 -6
  34. package/src/libs/hasAgreement.js +10 -9
  35. package/src/libs/hasArticle.js +6 -6
@@ -1,7 +1,7 @@
1
1
  import getArticles from "../getArticles";
2
2
 
3
3
  describe(`libs/getArticles()`, () => {
4
- it(`should return more than one article`, () => {
5
- expect(getArticles().length).toBeGreaterThan(1);
6
- });
4
+ it(`should return more than one article`, () => {
5
+ expect(getArticles().length).toBeGreaterThan(1);
6
+ });
7
7
  });
@@ -1,27 +1,27 @@
1
1
  import getIndexedArticle from "../getIndexedArticle";
2
2
 
3
3
  describe(`libs/getIndexedArticle()`, () => {
4
- describe(`should match properties`, () => {
5
- it(`with an existing article ID`, () => {
6
- expect(getIndexedArticle("KALIARTI000023306963")).toMatchObject({
7
- agreementId: "KALICONT000005635085",
8
- articleCid: "KALIARTI000005768420",
9
- articleId: "KALIARTI000023306963",
10
- });
11
- });
4
+ describe(`should match properties`, () => {
5
+ it(`with an existing article ID`, () => {
6
+ expect(getIndexedArticle("KALIARTI000023306963")).toMatchObject({
7
+ agreementId: "KALICONT000005635085",
8
+ articleCid: "KALIARTI000005768420",
9
+ articleId: "KALIARTI000023306963",
10
+ });
11
+ });
12
12
 
13
- it(`with an existing article CID`, () => {
14
- expect(getIndexedArticle("KALIARTI000005768420")).toMatchObject({
15
- agreementId: "KALICONT000005635085",
16
- articleCid: "KALIARTI000005768420",
17
- articleId: "KALIARTI000023306963",
18
- });
13
+ it(`with an existing article CID`, () => {
14
+ expect(getIndexedArticle("KALIARTI000005768420")).toMatchObject({
15
+ agreementId: "KALICONT000005635085",
16
+ articleCid: "KALIARTI000005768420",
17
+ articleId: "KALIARTI000023306963",
18
+ });
19
+ });
19
20
  });
20
- });
21
21
 
22
- describe(`should throw`, () => {
23
- it(`with a nonexistent article ID or CID`, () => {
24
- expect(() => getIndexedArticle("KALIARTI123456789012")).toThrow();
22
+ describe(`should throw`, () => {
23
+ it(`with a nonexistent article ID or CID`, () => {
24
+ expect(() => getIndexedArticle("KALIARTI123456789012")).toThrow();
25
+ });
25
26
  });
26
- });
27
27
  });
@@ -1,35 +1,35 @@
1
1
  import hasAgreement from "../hasAgreement";
2
2
 
3
3
  describe(`libs/hasAgreement()`, () => {
4
- describe(`should return true`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- expect(hasAgreement("KALICONT000005635444")).toBe(true);
7
- });
4
+ describe(`should return true`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ expect(hasAgreement("KALICONT000005635444")).toBe(true);
7
+ });
8
8
 
9
- it(`with an existing agreement IDCC (string)`, () => {
10
- expect(hasAgreement("1480")).toBe(true);
11
- });
9
+ it(`with an existing agreement IDCC (string)`, () => {
10
+ expect(hasAgreement("1480")).toBe(true);
11
+ });
12
12
 
13
- it(`with an existing agreement IDCC (number)`, () => {
14
- expect(hasAgreement(1480)).toBe(true);
13
+ it(`with an existing agreement IDCC (number)`, () => {
14
+ expect(hasAgreement(1480)).toBe(true);
15
+ });
15
16
  });
16
- });
17
17
 
18
- describe(`should return false`, () => {
19
- it(`with a nonexistant agreement ID`, () => {
20
- expect(hasAgreement("KALICONT000001234567")).toBe(false);
21
- });
18
+ describe(`should return false`, () => {
19
+ it(`with a nonexistant agreement ID`, () => {
20
+ expect(hasAgreement("KALICONT000001234567")).toBe(false);
21
+ });
22
22
 
23
- it(`with a nonexistant agreement IDCC (string)`, () => {
24
- expect(hasAgreement("1234")).toBe(false);
25
- });
23
+ it(`with a nonexistant agreement IDCC (string)`, () => {
24
+ expect(hasAgreement("1234")).toBe(false);
25
+ });
26
26
 
27
- it(`with a nonexistant agreement IDCC (number)`, () => {
28
- expect(hasAgreement(1234)).toBe(false);
29
- });
27
+ it(`with a nonexistant agreement IDCC (number)`, () => {
28
+ expect(hasAgreement(1234)).toBe(false);
29
+ });
30
30
 
31
- it(`with a malformed input`, () => {
32
- expect(hasAgreement("MALFORMEDID")).toBe(false);
31
+ it(`with a malformed input`, () => {
32
+ expect(hasAgreement("MALFORMEDID")).toBe(false);
33
+ });
33
34
  });
34
- });
35
35
  });
@@ -1,23 +1,23 @@
1
1
  import hasArticle from "../hasArticle";
2
2
 
3
3
  describe(`libs/hasArticle()`, () => {
4
- describe(`should return true`, () => {
5
- it(`with an existing article ID`, () => {
6
- expect(hasArticle("KALIARTI000023306963")).toBe(true);
7
- });
4
+ describe(`should return true`, () => {
5
+ it(`with an existing article ID`, () => {
6
+ expect(hasArticle("KALIARTI000023306963")).toBe(true);
7
+ });
8
8
 
9
- it(`with an existing article CID`, () => {
10
- expect(hasArticle("KALIARTI000005768420")).toBe(true);
9
+ it(`with an existing article CID`, () => {
10
+ expect(hasArticle("KALIARTI000005768420")).toBe(true);
11
+ });
11
12
  });
12
- });
13
13
 
14
- describe(`should return false`, () => {
15
- it(`with a nonexistant agreement ID`, () => {
16
- expect(hasArticle("KALIARTI123456789012")).toBe(false);
17
- });
14
+ describe(`should return false`, () => {
15
+ it(`with a nonexistant agreement ID`, () => {
16
+ expect(hasArticle("KALIARTI123456789012")).toBe(false);
17
+ });
18
18
 
19
- it(`with a malformed input`, () => {
20
- expect(hasArticle("MALFORMEDID")).toBe(false);
19
+ it(`with a malformed input`, () => {
20
+ expect(hasArticle("MALFORMEDID")).toBe(false);
21
+ });
21
22
  });
22
- });
23
23
  });
@@ -13,15 +13,15 @@ const hasAgreement = require("./hasAgreement");
13
13
  * @returns {KaliData.Agreement}
14
14
  */
15
15
  function getAgreement(agreementIdOrIdcc) {
16
- const agreementId = getAgreementIdFromIdOrIdcc(agreementIdOrIdcc);
17
- if (!hasAgreement(agreementId)) {
18
- throw new Error(`No agreement found with this ID (${agreementId}).`);
19
- }
16
+ const agreementId = getAgreementIdFromIdOrIdcc(agreementIdOrIdcc);
17
+ if (!hasAgreement(agreementId)) {
18
+ throw new Error(`No agreement found with this ID (${agreementId}).`);
19
+ }
20
20
 
21
- const agreement = require(`../../data/${agreementId}.json`);
22
- const agreementWithParents = unistUtilParents(agreement);
21
+ const agreement = require(`../../data/${agreementId}.json`);
22
+ const agreementWithParents = unistUtilParents(agreement);
23
23
 
24
- return agreementWithParents;
24
+ return agreementWithParents;
25
25
  }
26
26
 
27
27
  module.exports = getAgreement;
@@ -16,28 +16,28 @@ const getArticleWithParentSections = require("./getArticleWithParentSections");
16
16
  * @deprecated Use `getAgreementArticlesWithPath()` instead.
17
17
  */
18
18
  function getAgreementArticlesWithParentSections(agreementIdOrIdcc) {
19
- const agreement = getAgreement(agreementIdOrIdcc);
20
-
21
- const articles =
22
- /** @type {{ children: KaliData.AgreementArticle[], type: "root" }} */
23
- (/** @type {*} */ (unistUtilFlatFilter(agreement, { type: "article" })));
24
- const articleIds = articles.children.map(({ data: { id } }) => id);
25
-
26
- const articlesWithParentSections = articleIds.reduce(
27
- (prevArticlesWithParentSections, articleId) => {
28
- try {
29
- const articleWithParentSections = getArticleWithParentSections(articleId);
30
- // console.log(articleWithParentSections);
31
-
32
- return [...prevArticlesWithParentSections, articleWithParentSections];
33
- } catch (err) {
34
- return prevArticlesWithParentSections;
35
- }
36
- },
37
- [],
38
- );
39
-
40
- return articlesWithParentSections;
19
+ const agreement = getAgreement(agreementIdOrIdcc);
20
+
21
+ const articles =
22
+ /** @type {{ children: KaliData.AgreementArticle[], type: "root" }} */
23
+ (/** @type {*} */ (unistUtilFlatFilter(agreement, { type: "article" })));
24
+ const articleIds = articles.children.map(({ data: { id } }) => id);
25
+
26
+ const articlesWithParentSections = articleIds.reduce(
27
+ (prevArticlesWithParentSections, articleId) => {
28
+ try {
29
+ const articleWithParentSections = getArticleWithParentSections(articleId);
30
+ // console.log(articleWithParentSections);
31
+
32
+ return [...prevArticlesWithParentSections, articleWithParentSections];
33
+ } catch (err) {
34
+ return prevArticlesWithParentSections;
35
+ }
36
+ },
37
+ [],
38
+ );
39
+
40
+ return articlesWithParentSections;
41
41
  }
42
42
 
43
43
  module.exports = getAgreementArticlesWithParentSections;
@@ -14,20 +14,20 @@ const getIndexedArticle = require("./getIndexedArticle");
14
14
  * @returns {KaliData.AgreementArticleWithPath[]}
15
15
  */
16
16
  function getAgreementArticlesWithPath(agreementIdOrIdcc) {
17
- const agreement = getAgreement(agreementIdOrIdcc);
17
+ const agreement = getAgreement(agreementIdOrIdcc);
18
18
 
19
- const rootedArticles =
20
- /** @type {{ children: KaliData.AgreementArticle[], type: "root" }} */
21
- (/** @type {*} */ (unistUtilFlatFilter(agreement, { type: "article" })));
19
+ const rootedArticles =
20
+ /** @type {{ children: KaliData.AgreementArticle[], type: "root" }} */
21
+ (/** @type {*} */ (unistUtilFlatFilter(agreement, { type: "article" })));
22
22
 
23
- if (!rootedArticles) {
24
- return [];
25
- }
23
+ if (!rootedArticles) {
24
+ return [];
25
+ }
26
26
 
27
- return rootedArticles.children.map(article => ({
28
- ...article,
29
- path: getIndexedArticle(article.data.cid).path,
30
- }));
27
+ return rootedArticles.children.map(article => ({
28
+ ...article,
29
+ path: getIndexedArticle(article.data.cid).path,
30
+ }));
31
31
  }
32
32
 
33
33
  module.exports = getAgreementArticlesWithPath;
@@ -10,7 +10,7 @@ const INDEXED_AGREEMENTS = getAgreements();
10
10
  * @returns {boolean}
11
11
  */
12
12
  const isAgreementIdcc = idcc =>
13
- typeof idcc === "number" || (typeof idcc === "string" && /^\d{4}$/.test(idcc));
13
+ typeof idcc === "number" || (typeof idcc === "string" && /^\d{4}$/.test(idcc));
14
14
 
15
15
  /**
16
16
  * @param {string} id
@@ -27,27 +27,27 @@ const isAgreementId = id => typeof id === "string" && /^KALICONT\d{12}$/.test(id
27
27
  * @returns {string}
28
28
  */
29
29
  function getAgreementIdFromIdOrIdcc(agreementIdOrIdcc) {
30
- if (isAgreementIdcc(agreementIdOrIdcc)) {
31
- const idcc = Number(agreementIdOrIdcc);
32
- const matchIdcc = ({ num }) => num === idcc;
33
- const maybeAgreement = INDEXED_AGREEMENTS.find(matchIdcc);
34
- if (maybeAgreement === undefined) {
35
- throw new Error(`No agreement found with this IDCC (${idcc}).`);
30
+ if (isAgreementIdcc(agreementIdOrIdcc)) {
31
+ const idcc = Number(agreementIdOrIdcc);
32
+ const matchIdcc = ({ num }) => num === idcc;
33
+ const maybeAgreement = INDEXED_AGREEMENTS.find(matchIdcc);
34
+ if (maybeAgreement === undefined) {
35
+ throw new Error(`No agreement found with this IDCC (${idcc}).`);
36
+ }
37
+
38
+ return maybeAgreement.id;
36
39
  }
37
40
 
38
- return maybeAgreement.id;
39
- }
41
+ if (typeof agreementIdOrIdcc !== "number" && isAgreementId(agreementIdOrIdcc)) {
42
+ const agreementId = agreementIdOrIdcc;
40
43
 
41
- if (typeof agreementIdOrIdcc !== "number" && isAgreementId(agreementIdOrIdcc)) {
42
- const agreementId = agreementIdOrIdcc;
43
-
44
- return agreementId;
45
- }
44
+ return agreementId;
45
+ }
46
46
 
47
- throw new Error(
48
- `<agreementIdOrIdcc> is malformed (${agreementIdOrIdcc}). ` +
49
- `It must be a valid agreement IDCC (string | number) or ID (string: "KALICONT123456789012").`,
50
- );
47
+ throw new Error(
48
+ `<agreementIdOrIdcc> is malformed (${agreementIdOrIdcc}). ` +
49
+ `It must be a valid agreement IDCC (string | number) or ID (string: "KALICONT123456789012").`,
50
+ );
51
51
  }
52
52
 
53
53
  module.exports = getAgreementIdFromIdOrIdcc;
@@ -1,8 +1,8 @@
1
1
  // @ts-check
2
2
 
3
3
  const INDEXED_AGREEMENTS =
4
- /** @type {KaliData.IndexedAgreement[]} */
5
- (require("../../data/index.json"));
4
+ /** @type {KaliData.IndexedAgreement[]} */
5
+ (require("../../data/index.json"));
6
6
 
7
7
  /**
8
8
  * Get the full list of indexed agreements.
@@ -10,7 +10,7 @@ const INDEXED_AGREEMENTS =
10
10
  * @returns {KaliData.IndexedAgreement[]}
11
11
  */
12
12
  function getAgreements() {
13
- return INDEXED_AGREEMENTS;
13
+ return INDEXED_AGREEMENTS;
14
14
  }
15
15
 
16
16
  module.exports = getAgreements;
@@ -24,10 +24,10 @@ const getIndexedArticle = require("./getIndexedArticle");
24
24
  * @returns {AgreementArticleWithParent=}
25
25
  */
26
26
  const findArticleWithData = (agreement, data) =>
27
- unistUtilFind(agreement, {
28
- data,
29
- type: "article",
30
- });
27
+ unistUtilFind(agreement, {
28
+ data,
29
+ type: "article",
30
+ });
31
31
 
32
32
  /**
33
33
  * @param {AgreementArticleWithParent} article
@@ -35,17 +35,17 @@ const findArticleWithData = (agreement, data) =>
35
35
  * @returns {KaliData.AgreementArticleWithParentSections["sections"]}
36
36
  */
37
37
  const getParentSectionsFromArticle = article => {
38
- const sections = [];
39
- let section = article.parent;
38
+ const sections = [];
39
+ let section = article.parent;
40
40
 
41
- while (section) {
42
- const { data, type } = section;
43
- sections.unshift({ data, type });
41
+ while (section) {
42
+ const { data, type } = section;
43
+ sections.unshift({ data, type });
44
44
 
45
- section = section.parent;
46
- }
45
+ section = section.parent;
46
+ }
47
47
 
48
- return sections;
48
+ return sections;
49
49
  };
50
50
 
51
51
  /**
@@ -58,34 +58,34 @@ const getParentSectionsFromArticle = article => {
58
58
  * @deprecated Use `getArticleWithPath()` instead.
59
59
  */
60
60
  function getArticleWithParentSections(articleIdOrCid) {
61
- const { agreementId } = getIndexedArticle(articleIdOrCid);
62
- const agreement = getAgreement(agreementId);
61
+ const { agreementId } = getIndexedArticle(articleIdOrCid);
62
+ const agreement = getAgreement(agreementId);
63
+
64
+ // First attempt with an article ID:
65
+ const maybeArticleWithId = findArticleWithData(agreement, { id: articleIdOrCid });
66
+ if (maybeArticleWithId !== undefined) {
67
+ /** @type {KaliData.AgreementArticleWithParentSections} */
68
+ const articleWithParentSections = {
69
+ ...maybeArticleWithId,
70
+ sections: getParentSectionsFromArticle(maybeArticleWithId),
71
+ };
72
+
73
+ return articleWithParentSections;
74
+ }
75
+
76
+ // Second attempt with an article CID:
77
+ const maybeArticleWithCid = findArticleWithData(agreement, { cid: articleIdOrCid });
78
+ if (maybeArticleWithCid === undefined) {
79
+ throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
80
+ }
63
81
 
64
- // First attempt with an article ID:
65
- const maybeArticleWithId = findArticleWithData(agreement, { id: articleIdOrCid });
66
- if (maybeArticleWithId !== undefined) {
67
82
  /** @type {KaliData.AgreementArticleWithParentSections} */
68
83
  const articleWithParentSections = {
69
- ...maybeArticleWithId,
70
- sections: getParentSectionsFromArticle(maybeArticleWithId),
84
+ ...maybeArticleWithCid,
85
+ sections: getParentSectionsFromArticle(maybeArticleWithCid),
71
86
  };
72
87
 
73
88
  return articleWithParentSections;
74
- }
75
-
76
- // Second attempt with an article CID:
77
- const maybeArticleWithCid = findArticleWithData(agreement, { cid: articleIdOrCid });
78
- if (maybeArticleWithCid === undefined) {
79
- throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
80
- }
81
-
82
- /** @type {KaliData.AgreementArticleWithParentSections} */
83
- const articleWithParentSections = {
84
- ...maybeArticleWithCid,
85
- sections: getParentSectionsFromArticle(maybeArticleWithCid),
86
- };
87
-
88
- return articleWithParentSections;
89
89
  }
90
90
 
91
91
  module.exports = getArticleWithParentSections;
@@ -12,10 +12,10 @@ const getIndexedArticle = require("./getIndexedArticle");
12
12
  * @returns {KaliData.AgreementArticle=}
13
13
  */
14
14
  const findArticleWithData = (agreement, data) =>
15
- unistUtilFind(agreement, {
16
- data,
17
- type: "article",
18
- });
15
+ unistUtilFind(agreement, {
16
+ data,
17
+ type: "article",
18
+ });
19
19
 
20
20
  /**
21
21
  * Get an agreement article unist node with its parent sections path.
@@ -26,32 +26,32 @@ const findArticleWithData = (agreement, data) =>
26
26
  * @returns {KaliData.AgreementArticleWithPath}
27
27
  */
28
28
  function getArticleWithPath(articleIdOrCid) {
29
- const { agreementId, path } = getIndexedArticle(articleIdOrCid);
30
- const agreement = getAgreement(agreementId);
29
+ const { agreementId, path } = getIndexedArticle(articleIdOrCid);
30
+ const agreement = getAgreement(agreementId);
31
+
32
+ // First attempt with an article ID:
33
+ const maybeArticleWithId = findArticleWithData(agreement, { id: articleIdOrCid });
34
+ if (maybeArticleWithId !== undefined) {
35
+ const articleWithPath = {
36
+ ...maybeArticleWithId,
37
+ path,
38
+ };
39
+
40
+ return articleWithPath;
41
+ }
42
+
43
+ // Second attempt with an article CID:
44
+ const maybeArticleWithCid = findArticleWithData(agreement, { cid: articleIdOrCid });
45
+ if (maybeArticleWithCid === undefined) {
46
+ throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
47
+ }
31
48
 
32
- // First attempt with an article ID:
33
- const maybeArticleWithId = findArticleWithData(agreement, { id: articleIdOrCid });
34
- if (maybeArticleWithId !== undefined) {
35
49
  const articleWithPath = {
36
- ...maybeArticleWithId,
37
- path,
50
+ ...maybeArticleWithCid,
51
+ path,
38
52
  };
39
53
 
40
54
  return articleWithPath;
41
- }
42
-
43
- // Second attempt with an article CID:
44
- const maybeArticleWithCid = findArticleWithData(agreement, { cid: articleIdOrCid });
45
- if (maybeArticleWithCid === undefined) {
46
- throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
47
- }
48
-
49
- const articleWithPath = {
50
- ...maybeArticleWithCid,
51
- path,
52
- };
53
-
54
- return articleWithPath;
55
55
  }
56
56
 
57
57
  module.exports = getArticleWithPath;
@@ -1,8 +1,8 @@
1
1
  // @ts-check
2
2
 
3
3
  const INDEXED_ARTICLES =
4
- /** @type {KaliData.IndexedArticle[]} */
5
- (require("../../data/articles/index.json"));
4
+ /** @type {KaliData.IndexedArticle[]} */
5
+ (require("../../data/articles/index.json"));
6
6
 
7
7
  /**
8
8
  * Get the full list of indexed articles.
@@ -10,7 +10,7 @@ const INDEXED_ARTICLES =
10
10
  * @returns {KaliData.IndexedArticle[]}
11
11
  */
12
12
  function getArticles() {
13
- return INDEXED_ARTICLES;
13
+ return INDEXED_ARTICLES;
14
14
  }
15
15
 
16
16
  module.exports = getArticles;
@@ -14,14 +14,14 @@ const INDEXED_ARTICLES = getArticles();
14
14
  * @returns {KaliData.IndexedArticle}
15
15
  */
16
16
  function getIndexedArticle(articleIdOrCid) {
17
- checkArticleIdOrCid(articleIdOrCid);
17
+ checkArticleIdOrCid(articleIdOrCid);
18
18
 
19
- const maybeIndexedArticle = INDEXED_ARTICLES.find(withArticleIdOrCid(articleIdOrCid));
20
- if (maybeIndexedArticle === undefined) {
21
- throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
22
- }
19
+ const maybeIndexedArticle = INDEXED_ARTICLES.find(withArticleIdOrCid(articleIdOrCid));
20
+ if (maybeIndexedArticle === undefined) {
21
+ throw new Error(`No agreement article found with this ID or CID (${articleIdOrCid}).`);
22
+ }
23
23
 
24
- return maybeIndexedArticle;
24
+ return maybeIndexedArticle;
25
25
  }
26
26
 
27
27
  module.exports = getIndexedArticle;
@@ -16,16 +16,17 @@ const INDEXED_AGREEMENTS = getAgreements();
16
16
  * @returns {boolean}
17
17
  */
18
18
  function hasAgreement(agreementIdOrIdcc) {
19
- try {
20
- const agreementId = getAgreementIdFromIdOrIdcc(agreementIdOrIdcc);
21
- const maybeFilePath = path.join(__dirname, `../../data/${agreementId}.json`);
19
+ try {
20
+ const agreementId = getAgreementIdFromIdOrIdcc(agreementIdOrIdcc);
21
+ const maybeFilePath = path.join(__dirname, `../../data/${agreementId}.json`);
22
22
 
23
- return (
24
- INDEXED_AGREEMENTS.find(({ id }) => id === agreementId) !== undefined && isFile(maybeFilePath)
25
- );
26
- } catch (err) {
27
- return false;
28
- }
23
+ return (
24
+ INDEXED_AGREEMENTS.find(({ id }) => id === agreementId) !== undefined &&
25
+ isFile(maybeFilePath)
26
+ );
27
+ } catch (err) {
28
+ return false;
29
+ }
29
30
  }
30
31
 
31
32
  module.exports = hasAgreement;
@@ -14,13 +14,13 @@ const INDEXED_ARTICLES = getArticles();
14
14
  * @returns {boolean}
15
15
  */
16
16
  function hasArticle(articleIdOrCid) {
17
- try {
18
- checkArticleIdOrCid(articleIdOrCid);
17
+ try {
18
+ checkArticleIdOrCid(articleIdOrCid);
19
19
 
20
- return INDEXED_ARTICLES.find(withArticleIdOrCid(articleIdOrCid)) !== undefined;
21
- } catch (err) {
22
- return false;
23
- }
20
+ return INDEXED_ARTICLES.find(withArticleIdOrCid(articleIdOrCid)) !== undefined;
21
+ } catch (err) {
22
+ return false;
23
+ }
24
24
  }
25
25
 
26
26
  module.exports = hasArticle;