@socialgouv/kali-data-types 2.615.0 → 2.616.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 (30) hide show
  1. package/package.json +2 -1
  2. package/src/__tests__/index.test.js +15 -15
  3. package/src/helpers/__tests__/checkArticleIdOrCid.test.js +8 -8
  4. package/src/helpers/__tests__/isFile.test.js +14 -14
  5. package/src/helpers/checkArticleIdOrCid.js +6 -6
  6. package/src/helpers/isFile.js +1 -1
  7. package/src/helpers/withArticleIdOrCid.js +2 -2
  8. package/src/index.js +11 -11
  9. package/src/libs/__tests__/getAgreement.test.js +28 -28
  10. package/src/libs/__tests__/getAgreementArticlesWithParentSections.test.js +13 -13
  11. package/src/libs/__tests__/getAgreementArticlesWithPath.test.js +13 -13
  12. package/src/libs/__tests__/getAgreementIdFromIdOrIdcc.test.js +17 -17
  13. package/src/libs/__tests__/getAgreements.test.js +3 -3
  14. package/src/libs/__tests__/getArticleWithParentSections.test.js +19 -19
  15. package/src/libs/__tests__/getArticleWithPath.test.js +19 -19
  16. package/src/libs/__tests__/getArticles.test.js +3 -3
  17. package/src/libs/__tests__/getIndexedArticle.test.js +19 -19
  18. package/src/libs/__tests__/hasAgreement.test.js +23 -23
  19. package/src/libs/__tests__/hasArticle.test.js +14 -14
  20. package/src/libs/getAgreement.js +7 -7
  21. package/src/libs/getAgreementArticlesWithParentSections.js +22 -22
  22. package/src/libs/getAgreementArticlesWithPath.js +11 -11
  23. package/src/libs/getAgreementIdFromIdOrIdcc.js +18 -18
  24. package/src/libs/getAgreements.js +3 -3
  25. package/src/libs/getArticleWithParentSections.js +34 -34
  26. package/src/libs/getArticleWithPath.js +25 -25
  27. package/src/libs/getArticles.js +3 -3
  28. package/src/libs/getIndexedArticle.js +6 -6
  29. package/src/libs/hasAgreement.js +10 -9
  30. package/src/libs/hasArticle.js +6 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socialgouv/kali-data-types",
3
- "version": "2.615.0",
3
+ "version": "2.616.0",
4
4
  "devDependencies": {
5
5
  "@babel/core": "^7.16.0",
6
6
  "@babel/plugin-transform-modules-commonjs": "^7.16.0",
@@ -51,6 +51,7 @@
51
51
  "setup": "node -r esm ./scripts/setup.js",
52
52
  "test": "yarn test:lint && yarn test:type && yarn test:unit --silent",
53
53
  "test:lint": "eslint .",
54
+ "lint:fix": "eslint --fix .",
54
55
  "test:type": "tsc --noEmit",
55
56
  "test:unit": "jest",
56
57
  "test:update": "jest --updateSnapshot",
@@ -4,21 +4,21 @@ import path from "path";
4
4
  import kaliData from "../..";
5
5
 
6
6
  test(`@socialgouv/kali-data`, () => {
7
- const libNames = fs
8
- .readdirSync(path.join(__dirname, "../libs"))
9
- .filter(name => name !== "__tests__");
7
+ const libNames = fs
8
+ .readdirSync(path.join(__dirname, "../libs"))
9
+ .filter(name => name !== "__tests__");
10
10
 
11
- expect(Object.keys(kaliData)).toHaveLength(libNames.length);
11
+ expect(Object.keys(kaliData)).toHaveLength(libNames.length);
12
12
 
13
- expect(kaliData.getAgreement).toBeInstanceOf(Function);
14
- expect(kaliData.getAgreementArticlesWithParentSections).toBeInstanceOf(Function);
15
- expect(kaliData.getAgreementArticlesWithPath).toBeInstanceOf(Function);
16
- expect(kaliData.getAgreementIdFromIdOrIdcc).toBeInstanceOf(Function);
17
- expect(kaliData.getAgreements).toBeInstanceOf(Function);
18
- expect(kaliData.getArticleWithParentSections).toBeInstanceOf(Function);
19
- expect(kaliData.getArticleWithPath).toBeInstanceOf(Function);
20
- expect(kaliData.getArticles).toBeInstanceOf(Function);
21
- expect(kaliData.getIndexedArticle).toBeInstanceOf(Function);
22
- expect(kaliData.hasAgreement).toBeInstanceOf(Function);
23
- expect(kaliData.hasArticle).toBeInstanceOf(Function);
13
+ expect(kaliData.getAgreement).toBeInstanceOf(Function);
14
+ expect(kaliData.getAgreementArticlesWithParentSections).toBeInstanceOf(Function);
15
+ expect(kaliData.getAgreementArticlesWithPath).toBeInstanceOf(Function);
16
+ expect(kaliData.getAgreementIdFromIdOrIdcc).toBeInstanceOf(Function);
17
+ expect(kaliData.getAgreements).toBeInstanceOf(Function);
18
+ expect(kaliData.getArticleWithParentSections).toBeInstanceOf(Function);
19
+ expect(kaliData.getArticleWithPath).toBeInstanceOf(Function);
20
+ expect(kaliData.getArticles).toBeInstanceOf(Function);
21
+ expect(kaliData.getIndexedArticle).toBeInstanceOf(Function);
22
+ expect(kaliData.hasAgreement).toBeInstanceOf(Function);
23
+ expect(kaliData.hasArticle).toBeInstanceOf(Function);
24
24
  });
@@ -1,15 +1,15 @@
1
1
  import checkArticleIdOrCid from "../checkArticleIdOrCid";
2
2
 
3
3
  describe(`helpers/checkArticleIdOrCid()`, () => {
4
- describe(`should not throw`, () => {
5
- it(`with a valid article ID`, () => {
6
- expect(() => checkArticleIdOrCid("KALIARTI123456789012")).not.toThrow();
4
+ describe(`should not throw`, () => {
5
+ it(`with a valid article ID`, () => {
6
+ expect(() => checkArticleIdOrCid("KALIARTI123456789012")).not.toThrow();
7
+ });
7
8
  });
8
- });
9
9
 
10
- describe(`should throw`, () => {
11
- it(`with a malformed article ID`, () => {
12
- expect(() => checkArticleIdOrCid("MALFORMEDID")).toThrow();
10
+ describe(`should throw`, () => {
11
+ it(`with a malformed article ID`, () => {
12
+ expect(() => checkArticleIdOrCid("MALFORMEDID")).toThrow();
13
+ });
13
14
  });
14
- });
15
15
  });
@@ -1,23 +1,23 @@
1
1
  import isFile from "../isFile";
2
2
 
3
3
  describe(`helpers/isFile()`, () => {
4
- describe(`should return true`, () => {
5
- it(`with an existing file absolute path`, () => {
6
- expect(isFile(`${__dirname}/fixtures/aFile`)).toBe(true);
4
+ describe(`should return true`, () => {
5
+ it(`with an existing file absolute path`, () => {
6
+ expect(isFile(`${__dirname}/fixtures/aFile`)).toBe(true);
7
+ });
7
8
  });
8
- });
9
9
 
10
- describe(`should return false`, () => {
11
- it(`with an existing file relative path`, () => {
12
- expect(isFile("./fixtures/aFile")).toBe(false);
13
- });
10
+ describe(`should return false`, () => {
11
+ it(`with an existing file relative path`, () => {
12
+ expect(isFile("./fixtures/aFile")).toBe(false);
13
+ });
14
14
 
15
- it(`with an existing directory path`, () => {
16
- expect(isFile("./fixtures/aDirectory")).toBe(false);
17
- });
15
+ it(`with an existing directory path`, () => {
16
+ expect(isFile("./fixtures/aDirectory")).toBe(false);
17
+ });
18
18
 
19
- it(`with a non-existant file path`, () => {
20
- expect(isFile("./fixtures/aNonexistentFile")).toBe(false);
19
+ it(`with a non-existant file path`, () => {
20
+ expect(isFile("./fixtures/aNonexistentFile")).toBe(false);
21
+ });
21
22
  });
22
- });
23
23
  });
@@ -6,12 +6,12 @@
6
6
  * @returns {void}
7
7
  */
8
8
  function checkArticleIdOrCid(articleIdOrCid) {
9
- if (typeof articleIdOrCid !== "string" || !/^KALIARTI\d{12}$/.test(articleIdOrCid)) {
10
- throw new Error(
11
- `<articleIdOrCid> is malformed (${articleIdOrCid}). ` +
12
- `It must be a valid article ID or CID (string: "KALIARTI123456789012").`,
13
- );
14
- }
9
+ if (typeof articleIdOrCid !== "string" || !/^KALIARTI\d{12}$/.test(articleIdOrCid)) {
10
+ throw new Error(
11
+ `<articleIdOrCid> is malformed (${articleIdOrCid}). ` +
12
+ `It must be a valid article ID or CID (string: "KALIARTI123456789012").`,
13
+ );
14
+ }
15
15
  }
16
16
 
17
17
  module.exports = checkArticleIdOrCid;
@@ -8,7 +8,7 @@ const fs = require("fs");
8
8
  * @returns {boolean}
9
9
  */
10
10
  function isFile(absolutePath) {
11
- return fs.existsSync(absolutePath) && fs.lstatSync(absolutePath).isFile();
11
+ return fs.existsSync(absolutePath) && fs.lstatSync(absolutePath).isFile();
12
12
  }
13
13
 
14
14
  module.exports = isFile;
@@ -4,8 +4,8 @@
4
4
  * @returns {((indexedArticle: KaliData.IndexedArticle) => boolean)}
5
5
  */
6
6
  function withArticleIdOrCid(articleIdOrCid) {
7
- return indexedArticle =>
8
- indexedArticle.articleId === articleIdOrCid || indexedArticle.articleCid === articleIdOrCid;
7
+ return indexedArticle =>
8
+ indexedArticle.articleId === articleIdOrCid || indexedArticle.articleCid === articleIdOrCid;
9
9
  }
10
10
 
11
11
  module.exports = withArticleIdOrCid;
package/src/index.js CHANGED
@@ -13,15 +13,15 @@ const hasAgreement = require("./libs/hasAgreement");
13
13
  const hasArticle = require("./libs/hasArticle");
14
14
 
15
15
  module.exports = {
16
- getAgreement,
17
- getAgreementArticlesWithParentSections,
18
- getAgreementArticlesWithPath,
19
- getAgreementIdFromIdOrIdcc,
20
- getAgreements,
21
- getArticleWithParentSections,
22
- getArticleWithPath,
23
- getArticles,
24
- getIndexedArticle,
25
- hasAgreement,
26
- hasArticle,
16
+ getAgreement,
17
+ getAgreementArticlesWithParentSections,
18
+ getAgreementArticlesWithPath,
19
+ getAgreementIdFromIdOrIdcc,
20
+ getAgreements,
21
+ getArticleWithParentSections,
22
+ getArticleWithPath,
23
+ getArticles,
24
+ getIndexedArticle,
25
+ hasAgreement,
26
+ hasArticle,
27
27
  };
@@ -1,39 +1,39 @@
1
1
  import getAgreement from "../getAgreement";
2
2
 
3
3
  describe(`libs/getAgreement()`, () => {
4
- describe(`should match properties`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- const received = getAgreement("KALICONT000005635444");
4
+ describe(`should match properties`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ const received = getAgreement("KALICONT000005635444");
7
7
 
8
- expect(received.data.id).toBe("KALICONT000005635444");
9
- expect(received.data.num).toBe(1480);
10
- });
11
-
12
- it(`with an existing agreement IDCC (string)`, () => {
13
- const received = getAgreement("1480");
8
+ expect(received.data.id).toBe("KALICONT000005635444");
9
+ expect(received.data.num).toBe(1480);
10
+ });
14
11
 
15
- expect(received.data.id).toBe("KALICONT000005635444");
16
- expect(received.data.num).toBe(1480);
17
- });
12
+ it(`with an existing agreement IDCC (string)`, () => {
13
+ const received = getAgreement("1480");
18
14
 
19
- it(`with an existing agreement IDCC (number)`, () => {
20
- const received = getAgreement(1480);
15
+ expect(received.data.id).toBe("KALICONT000005635444");
16
+ expect(received.data.num).toBe(1480);
17
+ });
21
18
 
22
- expect(received.data.id).toBe("KALICONT000005635444");
23
- expect(received.data.num).toBe(1480);
24
- });
25
- });
26
- describe(`should throw`, () => {
27
- it(`with a nonexistent agreement ID`, () => {
28
- expect(() => getAgreement("KALICONT123456789012")).toThrow();
29
- });
19
+ it(`with an existing agreement IDCC (number)`, () => {
20
+ const received = getAgreement(1480);
30
21
 
31
- it(`with a nonexistent agreement IDCC (string)`, () => {
32
- expect(() => getAgreement("1234")).toThrow();
22
+ expect(received.data.id).toBe("KALICONT000005635444");
23
+ expect(received.data.num).toBe(1480);
24
+ });
33
25
  });
34
-
35
- it(`with a nonexistent agreement IDCC (number)`, () => {
36
- expect(() => getAgreement(1234)).toThrow();
26
+ describe(`should throw`, () => {
27
+ it(`with a nonexistent agreement ID`, () => {
28
+ expect(() => getAgreement("KALICONT123456789012")).toThrow();
29
+ });
30
+
31
+ it(`with a nonexistent agreement IDCC (string)`, () => {
32
+ expect(() => getAgreement("1234")).toThrow();
33
+ });
34
+
35
+ it(`with a nonexistent agreement IDCC (number)`, () => {
36
+ expect(() => getAgreement(1234)).toThrow();
37
+ });
37
38
  });
38
- });
39
39
  });
@@ -1,23 +1,23 @@
1
1
  import getAgreementArticlesWithParentSections from "../getAgreementArticlesWithParentSections";
2
2
 
3
3
  describe(`libs/getAgreementArticlesWithParentSections()`, () => {
4
- describe(`should match snapshot`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- const received = getAgreementArticlesWithParentSections("KALICONT000005635221");
4
+ describe(`should match snapshot`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ const received = getAgreementArticlesWithParentSections("KALICONT000005635221");
7
7
 
8
- expect(received[0].sections.length).toBeGreaterThan(1);
9
- });
8
+ expect(received[0].sections.length).toBeGreaterThan(1);
9
+ });
10
10
 
11
- it(`with an existing agreement IDCC (string)`, () => {
12
- const received = getAgreementArticlesWithParentSections("1480");
11
+ it(`with an existing agreement IDCC (string)`, () => {
12
+ const received = getAgreementArticlesWithParentSections("1480");
13
13
 
14
- expect(received[0].sections.length).toBeGreaterThan(1);
15
- });
14
+ expect(received[0].sections.length).toBeGreaterThan(1);
15
+ });
16
16
 
17
- it(`with an existing agreement IDCC (number)`, () => {
18
- const received = getAgreementArticlesWithParentSections(1480);
17
+ it(`with an existing agreement IDCC (number)`, () => {
18
+ const received = getAgreementArticlesWithParentSections(1480);
19
19
 
20
- expect(received[0].sections.length).toBeGreaterThan(1);
20
+ expect(received[0].sections.length).toBeGreaterThan(1);
21
+ });
21
22
  });
22
- });
23
23
  });
@@ -1,23 +1,23 @@
1
1
  import getAgreementArticlesWithPath from "../getAgreementArticlesWithPath";
2
2
 
3
3
  describe(`libs/getAgreementArticlesWithPath()`, () => {
4
- describe(`should match snapshot`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- const received = getAgreementArticlesWithPath("KALICONT000005635221");
4
+ describe(`should match snapshot`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ const received = getAgreementArticlesWithPath("KALICONT000005635221");
7
7
 
8
- expect(received[0].path.length).toBeGreaterThan(1);
9
- });
8
+ expect(received[0].path.length).toBeGreaterThan(1);
9
+ });
10
10
 
11
- it(`with an existing agreement IDCC (string)`, () => {
12
- const received = getAgreementArticlesWithPath("1480");
11
+ it(`with an existing agreement IDCC (string)`, () => {
12
+ const received = getAgreementArticlesWithPath("1480");
13
13
 
14
- expect(received[0].path.length).toBeGreaterThan(1);
15
- });
14
+ expect(received[0].path.length).toBeGreaterThan(1);
15
+ });
16
16
 
17
- it(`with an existing agreement IDCC (number)`, () => {
18
- const received = getAgreementArticlesWithPath(1480);
17
+ it(`with an existing agreement IDCC (number)`, () => {
18
+ const received = getAgreementArticlesWithPath(1480);
19
19
 
20
- expect(received[0].path.length).toBeGreaterThan(1);
20
+ expect(received[0].path.length).toBeGreaterThan(1);
21
+ });
21
22
  });
22
- });
23
23
  });
@@ -1,27 +1,27 @@
1
1
  import getAgreementIdFromIdOrIdcc from "../getAgreementIdFromIdOrIdcc";
2
2
 
3
3
  describe(`libs/getAgreementIdFromIdOrIdcc()`, () => {
4
- describe(`should return the expected ID`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- expect(getAgreementIdFromIdOrIdcc("KALICONT000005635444")).toBe("KALICONT000005635444");
7
- });
4
+ describe(`should return the expected ID`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ expect(getAgreementIdFromIdOrIdcc("KALICONT000005635444")).toBe("KALICONT000005635444");
7
+ });
8
8
 
9
- it(`with an existing agreement IDCC (string)`, () => {
10
- expect(getAgreementIdFromIdOrIdcc("1480")).toBe("KALICONT000005635444");
11
- });
9
+ it(`with an existing agreement IDCC (string)`, () => {
10
+ expect(getAgreementIdFromIdOrIdcc("1480")).toBe("KALICONT000005635444");
11
+ });
12
12
 
13
- it(`with an existing agreement IDCC (number)`, () => {
14
- expect(getAgreementIdFromIdOrIdcc(1480)).toBe("KALICONT000005635444");
13
+ it(`with an existing agreement IDCC (number)`, () => {
14
+ expect(getAgreementIdFromIdOrIdcc(1480)).toBe("KALICONT000005635444");
15
+ });
15
16
  });
16
- });
17
17
 
18
- describe(`should throw`, () => {
19
- it(`with a malformed input`, () => {
20
- expect(() => getAgreementIdFromIdOrIdcc("MALFORMEDID")).toThrow();
21
- });
18
+ describe(`should throw`, () => {
19
+ it(`with a malformed input`, () => {
20
+ expect(() => getAgreementIdFromIdOrIdcc("MALFORMEDID")).toThrow();
21
+ });
22
22
 
23
- it(`with a nonexistant agreement IDCC`, () => {
24
- expect(() => getAgreementIdFromIdOrIdcc("1234")).toThrow();
23
+ it(`with a nonexistant agreement IDCC`, () => {
24
+ expect(() => getAgreementIdFromIdOrIdcc("1234")).toThrow();
25
+ });
25
26
  });
26
- });
27
27
  });
@@ -1,7 +1,7 @@
1
1
  import getAgreements from "../getAgreements";
2
2
 
3
3
  describe(`libs/getAgreements()`, () => {
4
- it(`should return more than one agreement`, () => {
5
- expect(getAgreements().length).toBeGreaterThan(1);
6
- });
4
+ it(`should return more than one agreement`, () => {
5
+ expect(getAgreements().length).toBeGreaterThan(1);
6
+ });
7
7
  });
@@ -1,29 +1,29 @@
1
1
  import getArticleWithParentSections from "../getArticleWithParentSections";
2
2
 
3
3
  describe(`libs/getArticleWithParentSections()`, () => {
4
- describe(`should match properties`, () => {
5
- it(`with an existing main article ID`, () => {
6
- const received = getArticleWithParentSections("KALIARTI000005781804");
4
+ describe(`should match properties`, () => {
5
+ it(`with an existing main article ID`, () => {
6
+ const received = getArticleWithParentSections("KALIARTI000005781804");
7
7
 
8
- expect(received.data.cid).toBe("KALIARTI000005781804");
9
- expect(received.data.id).toBe("KALIARTI000045466361");
10
- expect(received.sections.length).toBeGreaterThan(1);
11
- });
8
+ expect(received.data.cid).toBe("KALIARTI000005781804");
9
+ expect(received.data.id).toBe("KALIARTI000045466361");
10
+ expect(received.sections.length).toBeGreaterThan(1);
11
+ });
12
12
 
13
- it(`with an existing main article CID`, () => {
14
- const received = getArticleWithParentSections("KALIARTI000005781804");
13
+ it(`with an existing main article CID`, () => {
14
+ const received = getArticleWithParentSections("KALIARTI000005781804");
15
15
 
16
- expect(received.data.cid).toBe("KALIARTI000005781804");
17
- expect(received.data.id).toBe("KALIARTI000045466361");
18
- expect(received.sections.length).toBeGreaterThan(1);
19
- });
16
+ expect(received.data.cid).toBe("KALIARTI000005781804");
17
+ expect(received.data.id).toBe("KALIARTI000045466361");
18
+ expect(received.sections.length).toBeGreaterThan(1);
19
+ });
20
20
 
21
- it(`with an existing additional article ID`, () => {
22
- const received = getArticleWithParentSections("KALIARTI000041787475");
21
+ it(`with an existing additional article ID`, () => {
22
+ const received = getArticleWithParentSections("KALIARTI000041787475");
23
23
 
24
- expect(received.data.cid).toBe("KALIARTI000041787475");
25
- expect(received.data.id).toBe("KALIARTI000041787475");
26
- expect(received.sections.length).toBeGreaterThan(1);
24
+ expect(received.data.cid).toBe("KALIARTI000041787475");
25
+ expect(received.data.id).toBe("KALIARTI000041787475");
26
+ expect(received.sections.length).toBeGreaterThan(1);
27
+ });
27
28
  });
28
- });
29
29
  });
@@ -1,29 +1,29 @@
1
1
  import getArticleWithPath from "../getArticleWithPath";
2
2
 
3
3
  describe(`libs/getArticleWithPath()`, () => {
4
- describe(`should match properties`, () => {
5
- it(`with an existing main article ID`, () => {
6
- const received = getArticleWithPath("KALIARTI000005781818");
4
+ describe(`should match properties`, () => {
5
+ it(`with an existing main article ID`, () => {
6
+ const received = getArticleWithPath("KALIARTI000005781818");
7
7
 
8
- expect(received.data.cid).toBe("KALIARTI000005781818");
9
- expect(received.data.id).toBe("KALIARTI000005781818");
10
- expect(received.path.length).toBeGreaterThan(1);
11
- });
8
+ expect(received.data.cid).toBe("KALIARTI000005781818");
9
+ expect(received.data.id).toBe("KALIARTI000005781818");
10
+ expect(received.path.length).toBeGreaterThan(1);
11
+ });
12
12
 
13
- it(`with an existing main article CID`, () => {
14
- const received = getArticleWithPath("KALIARTI000005781804");
13
+ it(`with an existing main article CID`, () => {
14
+ const received = getArticleWithPath("KALIARTI000005781804");
15
15
 
16
- expect(received.data.cid).toBe("KALIARTI000005781804");
17
- expect(received.data.id).toBe("KALIARTI000045466361");
18
- expect(received.path.length).toBeGreaterThan(1);
19
- });
16
+ expect(received.data.cid).toBe("KALIARTI000005781804");
17
+ expect(received.data.id).toBe("KALIARTI000045466361");
18
+ expect(received.path.length).toBeGreaterThan(1);
19
+ });
20
20
 
21
- it(`with an existing additional article ID`, () => {
22
- const received = getArticleWithPath("KALIARTI000041787475");
21
+ it(`with an existing additional article ID`, () => {
22
+ const received = getArticleWithPath("KALIARTI000041787475");
23
23
 
24
- expect(received.data.cid).toBe("KALIARTI000041787475");
25
- expect(received.data.id).toBe("KALIARTI000041787475");
26
- expect(received.path.length).toBeGreaterThan(1);
24
+ expect(received.data.cid).toBe("KALIARTI000041787475");
25
+ expect(received.data.id).toBe("KALIARTI000041787475");
26
+ expect(received.path.length).toBeGreaterThan(1);
27
+ });
27
28
  });
28
- });
29
29
  });
@@ -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;