@optolith/entity-descriptions 0.1.1 → 0.2.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.
- package/CHANGELOG.md +25 -0
- package/lib/entities/combatTechnique.d.ts +4 -4
- package/lib/entities/combatTechnique.js +7 -7
- package/lib/entities/experienceLevel.d.ts +1 -1
- package/lib/entities/experienceLevel.js +3 -3
- package/lib/entities/focusRule.d.ts +8 -0
- package/lib/entities/focusRule.js +18 -0
- package/lib/entities/liturgicalChant.d.ts +6 -6
- package/lib/entities/liturgicalChant.js +27 -56
- package/lib/entities/optionalRule.d.ts +5 -0
- package/lib/entities/optionalRule.js +16 -0
- package/lib/entities/partial/rated/activatable/castingTime.d.ts +3 -15
- package/lib/entities/partial/rated/activatable/castingTime.js +19 -34
- package/lib/entities/partial/rated/activatable/checkResultBased.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/checkResultBased.js +2 -2
- package/lib/entities/partial/rated/activatable/cost.d.ts +3 -19
- package/lib/entities/partial/rated/activatable/cost.js +82 -99
- package/lib/entities/partial/rated/activatable/duration.d.ts +5 -24
- package/lib/entities/partial/rated/activatable/duration.js +40 -57
- package/lib/entities/partial/rated/activatable/effect.d.ts +3 -3
- package/lib/entities/partial/rated/activatable/effect.js +7 -7
- package/lib/entities/partial/rated/activatable/index.d.ts +5 -33
- package/lib/entities/partial/rated/activatable/index.js +23 -41
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.d.ts +20 -0
- package/lib/entities/partial/rated/activatable/isMinimumMaximum.js +19 -0
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.d.ts +16 -0
- package/lib/entities/partial/rated/activatable/nonModifiableSuffix.js +55 -0
- package/lib/entities/partial/rated/activatable/parensIf.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/parensIf.js +3 -1
- package/lib/entities/partial/rated/activatable/range.d.ts +4 -20
- package/lib/entities/partial/rated/activatable/range.js +59 -100
- package/lib/entities/partial/rated/activatable/speed.d.ts +1 -1
- package/lib/entities/partial/rated/activatable/speed.js +1 -1
- package/lib/entities/partial/rated/activatable/targetCategory.d.ts +3 -7
- package/lib/entities/partial/rated/activatable/targetCategory.js +30 -26
- package/lib/entities/partial/rated/improvementCost.d.ts +2 -2
- package/lib/entities/partial/rated/skillCheck.d.ts +2 -2
- package/lib/entities/partial/responsiveText.d.ts +7 -4
- package/lib/entities/partial/responsiveText.js +8 -2
- package/lib/entities/partial/units/energy.d.ts +12 -0
- package/lib/entities/partial/units/energy.js +30 -0
- package/lib/entities/partial/units/length.d.ts +8 -0
- package/lib/entities/partial/units/length.js +12 -0
- package/lib/entities/partial/units/timeSpan.d.ts +8 -0
- package/lib/entities/partial/units/timeSpan.js +22 -0
- package/lib/entities/skill.d.ts +2 -2
- package/lib/entities/skill.js +3 -3
- package/lib/entities/spell.d.ts +6 -6
- package/lib/entities/spell.js +27 -56
- package/lib/helpers/locale.d.ts +8 -0
- package/lib/helpers/locale.js +1 -0
- package/lib/index.d.ts +45 -1
- package/lib/index.js +22 -1
- package/lib/references/index.d.ts +4 -0
- package/lib/references/index.js +46 -0
- package/lib/references/occurrence.d.ts +4 -0
- package/lib/references/occurrence.js +3 -0
- package/lib/references/page.d.ts +23 -0
- package/lib/references/page.js +61 -0
- package/lib/references/pageRange.d.ts +30 -0
- package/lib/references/pageRange.js +58 -0
- package/package.json +7 -3
- package/lib/entities/partial/rated/activatable/isMaximum.d.ts +0 -6
- package/lib/entities/partial/rated/activatable/isMaximum.js +0 -10
- package/lib/entities/partial/rated/activatable/modifiableParameter.d.ts +0 -8
- package/lib/entities/partial/rated/activatable/modifiableParameter.js +0 -9
- package/lib/entities/partial/rated/activatable/nonModifiable.d.ts +0 -9
- package/lib/entities/partial/rated/activatable/nonModifiable.js +0 -75
- package/lib/entities/partial/rated/activatable/units.d.ts +0 -13
- package/lib/entities/partial/rated/activatable/units.js +0 -53
- package/lib/libraryEntry.d.ts +0 -52
- package/lib/libraryEntry.js +0 -17
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { range } from "@optolith/helpers/array";
|
|
2
|
+
import { comparePage, equalsPage, numberToPage, printPage, succ, } from "./page.js";
|
|
3
|
+
/**
|
|
4
|
+
* Converts a numeric range to a page object range.
|
|
5
|
+
*/
|
|
6
|
+
export const numberRangeToPageRange = (numberRange) => numberRange.last_page === undefined
|
|
7
|
+
? { firstPage: numberToPage(numberRange.first_page) }
|
|
8
|
+
: {
|
|
9
|
+
firstPage: numberToPage(numberRange.first_page),
|
|
10
|
+
lastPage: numberToPage(numberRange.last_page),
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Converts a page object range from the database to a local page object range.
|
|
14
|
+
*/
|
|
15
|
+
export const fromRawPageRange = (pageRange) => pageRange.last_page === undefined
|
|
16
|
+
? { firstPage: pageRange.first_page }
|
|
17
|
+
: {
|
|
18
|
+
firstPage: pageRange.first_page,
|
|
19
|
+
lastPage: pageRange.last_page,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Sorts and combines page ranges while removing duplicates.
|
|
23
|
+
*/
|
|
24
|
+
export const normalizePageRanges = (ranges) => ranges
|
|
25
|
+
.flatMap(({ firstPage, lastPage = firstPage }) => {
|
|
26
|
+
if (firstPage.tag === "Numbered" && lastPage.tag === "Numbered") {
|
|
27
|
+
return range(firstPage.numbered, lastPage.numbered).map((numbered) => ({
|
|
28
|
+
tag: "Numbered",
|
|
29
|
+
numbered,
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return [firstPage, lastPage];
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
.filter((page, i, pages) => pages.findIndex((p) => equalsPage(page, p)) === i)
|
|
37
|
+
.sort(comparePage)
|
|
38
|
+
.reduce((acc, page) => {
|
|
39
|
+
const lastRange = acc[acc.length - 1];
|
|
40
|
+
if (lastRange === undefined) {
|
|
41
|
+
return [{ firstPage: page }];
|
|
42
|
+
}
|
|
43
|
+
const { firstPage, lastPage = firstPage } = lastRange;
|
|
44
|
+
if (equalsPage(page, succ(lastPage))) {
|
|
45
|
+
return [...acc.slice(0, -1), { firstPage, lastPage: page }];
|
|
46
|
+
}
|
|
47
|
+
return [...acc, { firstPage: page }];
|
|
48
|
+
}, []);
|
|
49
|
+
/**
|
|
50
|
+
* Returns a string representation of a page range.
|
|
51
|
+
*/
|
|
52
|
+
export const printPageRange = (translate, pageRange) => pageRange.lastPage === undefined
|
|
53
|
+
? printPage(translate, pageRange.firstPage)
|
|
54
|
+
: `${printPage(translate, pageRange.firstPage)}–${printPage(translate, pageRange.lastPage)}`;
|
|
55
|
+
/**
|
|
56
|
+
* Returns a string representation of a list of page ranges.
|
|
57
|
+
*/
|
|
58
|
+
export const printPageRanges = (translate, pageRanges) => pageRanges.map((pageRange) => printPageRange(translate, pageRange)).join(", ");
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optolith/entity-descriptions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "An interface for generating descriptions for The Dark Eye entities.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js",
|
|
8
|
+
"./entities/*": "./lib/entities/*.js"
|
|
9
|
+
},
|
|
6
10
|
"scripts": {
|
|
7
11
|
"build": "tsc -b",
|
|
8
12
|
"watch": "tsc -b -w",
|
|
9
13
|
"release": "commit-and-tag-version",
|
|
10
|
-
"test": "glob -c \"node --import tsx --test\" \"./
|
|
14
|
+
"test": "glob -c \"node --import tsx --test\" \"./test/**/*.ts\""
|
|
11
15
|
},
|
|
12
16
|
"repository": {
|
|
13
17
|
"type": "git",
|
|
@@ -26,7 +30,7 @@
|
|
|
26
30
|
"@types/node": "^22.7.4",
|
|
27
31
|
"commit-and-tag-version": "^12.4.4",
|
|
28
32
|
"glob": "^11.0.0",
|
|
29
|
-
"optolith-database-schema": "^0.17.
|
|
33
|
+
"optolith-database-schema": "^0.17.2",
|
|
30
34
|
"tsx": "^4.19.1",
|
|
31
35
|
"typescript": "^5.6.2"
|
|
32
36
|
},
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Translate } from "../../../../helpers/translate.js";
|
|
2
|
-
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
3
|
-
/**
|
|
4
|
-
* Returns the text to prepend for the `is_maximum` property.
|
|
5
|
-
*/
|
|
6
|
-
export declare const getTextForIsMaximum: (is_maximum: boolean | undefined, translate: Translate, responsiveText: ResponsiveTextSize) => string;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { responsive } from "../../responsiveText.js";
|
|
2
|
-
/**
|
|
3
|
-
* Returns the text to prepend for the `is_maximum` property.
|
|
4
|
-
*/
|
|
5
|
-
export const getTextForIsMaximum = (is_maximum, translate, responsiveText) => {
|
|
6
|
-
if (is_maximum !== true) {
|
|
7
|
-
return "";
|
|
8
|
-
}
|
|
9
|
-
return responsive(responsiveText, () => translate("no more than "), () => translate("max. "));
|
|
10
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A parameter that is designed to be modifiable.
|
|
3
|
-
*/
|
|
4
|
-
export var ModifiableParameter;
|
|
5
|
-
(function (ModifiableParameter) {
|
|
6
|
-
ModifiableParameter[ModifiableParameter["CastingTime"] = 0] = "CastingTime";
|
|
7
|
-
ModifiableParameter[ModifiableParameter["Cost"] = 1] = "Cost";
|
|
8
|
-
ModifiableParameter[ModifiableParameter["Range"] = 2] = "Range";
|
|
9
|
-
})(ModifiableParameter || (ModifiableParameter = {}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Translate } from "../../../../helpers/translate.js";
|
|
2
|
-
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
3
|
-
import { Entity } from "./entity.js";
|
|
4
|
-
import { ModifiableParameter } from "./modifiableParameter.js";
|
|
5
|
-
/**
|
|
6
|
-
* Returns the suffix for the text of a non-modifiable parameter that indicates
|
|
7
|
-
* that the parameter cannot be modified.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getTextForNonModifiableSuffix: (translate: Translate, entity: Entity, param: ModifiableParameter, responsiveText: ResponsiveTextSize) => string;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
2
|
-
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
3
|
-
import { Entity } from "./entity.js";
|
|
4
|
-
import { ModifiableParameter } from "./modifiableParameter.js";
|
|
5
|
-
/**
|
|
6
|
-
* Returns the suffix for the text of a non-modifiable parameter that indicates
|
|
7
|
-
* that the parameter cannot be modified.
|
|
8
|
-
*/
|
|
9
|
-
export const getTextForNonModifiableSuffix = (translate, entity, param, responsiveText) => {
|
|
10
|
-
if (responsiveText === ResponsiveTextSize.Compressed) {
|
|
11
|
-
switch (entity) {
|
|
12
|
-
case Entity.Spell:
|
|
13
|
-
case Entity.Ritual:
|
|
14
|
-
case Entity.LiturgicalChant:
|
|
15
|
-
case Entity.Ceremony:
|
|
16
|
-
return translate(" (cannot modify)");
|
|
17
|
-
case Entity.Cantrip:
|
|
18
|
-
case Entity.Blessing:
|
|
19
|
-
return "";
|
|
20
|
-
default:
|
|
21
|
-
return assertExhaustive(entity);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
switch (entity) {
|
|
25
|
-
case Entity.Spell:
|
|
26
|
-
switch (param) {
|
|
27
|
-
case ModifiableParameter.CastingTime:
|
|
28
|
-
return translate(" (you cannot use a modification on this spell’s casting time)");
|
|
29
|
-
case ModifiableParameter.Cost:
|
|
30
|
-
return translate(" (you cannot use a modification on this spell’s cost)");
|
|
31
|
-
case ModifiableParameter.Range:
|
|
32
|
-
return translate(" (you cannot use a modification on this spell’s range)");
|
|
33
|
-
default:
|
|
34
|
-
return assertExhaustive(param);
|
|
35
|
-
}
|
|
36
|
-
case Entity.Ritual:
|
|
37
|
-
switch (param) {
|
|
38
|
-
case ModifiableParameter.CastingTime:
|
|
39
|
-
return translate(" (you cannot use a modification on this ritual’s ritual time)");
|
|
40
|
-
case ModifiableParameter.Cost:
|
|
41
|
-
return translate(" (you cannot use a modification on this ritual’s cost)");
|
|
42
|
-
case ModifiableParameter.Range:
|
|
43
|
-
return translate(" (you cannot use a modification on this ritual’s range)");
|
|
44
|
-
default:
|
|
45
|
-
return assertExhaustive(param);
|
|
46
|
-
}
|
|
47
|
-
case Entity.LiturgicalChant:
|
|
48
|
-
switch (param) {
|
|
49
|
-
case ModifiableParameter.CastingTime:
|
|
50
|
-
return translate(" (you cannot use a modification on this chant’s liturgical time)");
|
|
51
|
-
case ModifiableParameter.Cost:
|
|
52
|
-
return translate(" (you cannot use a modification on this chant’s cost)");
|
|
53
|
-
case ModifiableParameter.Range:
|
|
54
|
-
return translate(" (you cannot use a modification on this chant’s range)");
|
|
55
|
-
default:
|
|
56
|
-
return assertExhaustive(param);
|
|
57
|
-
}
|
|
58
|
-
case Entity.Ceremony:
|
|
59
|
-
switch (param) {
|
|
60
|
-
case ModifiableParameter.CastingTime:
|
|
61
|
-
return translate(" (you cannot use a modification on this ceremony’s ceremonial time)");
|
|
62
|
-
case ModifiableParameter.Cost:
|
|
63
|
-
return translate(" (you cannot use a modification on this ceremony’s cost)");
|
|
64
|
-
case ModifiableParameter.Range:
|
|
65
|
-
return translate(" (you cannot use a modification on this ceremony’s range)");
|
|
66
|
-
default:
|
|
67
|
-
return assertExhaustive(param);
|
|
68
|
-
}
|
|
69
|
-
case Entity.Cantrip:
|
|
70
|
-
case Entity.Blessing:
|
|
71
|
-
return "";
|
|
72
|
-
default:
|
|
73
|
-
return assertExhaustive(entity);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Translate } from "../../../../helpers/translate.js";
|
|
2
|
-
import { ResponsiveTextSize } from "../../responsiveText.js";
|
|
3
|
-
import { Entity } from "./entity.js";
|
|
4
|
-
type TimeSpanUnit = "Seconds" | "Minutes" | "Hours" | "Days" | "Weeks" | "Months" | "Years" | "Centuries" | "Actions" | "CombatRounds" | "SeductionActions" | "Rounds";
|
|
5
|
-
/**
|
|
6
|
-
* Returns the text for a time span unit.
|
|
7
|
-
*/
|
|
8
|
-
export declare const formatTimeSpan: (translate: Translate, responsiveTextSize: ResponsiveTextSize, unit: TimeSpanUnit, value: number | string) => string;
|
|
9
|
-
/**
|
|
10
|
-
* Returns the text for a cost unit that is based on the entity type.
|
|
11
|
-
*/
|
|
12
|
-
export declare const formatCost: (translate: Translate, entity: Entity, value: number | string) => string;
|
|
13
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { assertExhaustive } from "@optolith/helpers/typeSafety";
|
|
2
|
-
import { responsive } from "../../responsiveText.js";
|
|
3
|
-
import { Entity } from "./entity.js";
|
|
4
|
-
/**
|
|
5
|
-
* Returns the text for a time span unit.
|
|
6
|
-
*/
|
|
7
|
-
export const formatTimeSpan = (translate, responsiveTextSize, unit, value) => {
|
|
8
|
-
switch (unit) {
|
|
9
|
-
case "Seconds":
|
|
10
|
-
return responsive(responsiveTextSize, () => translate("{0} seconds", value), () => translate("{0} s", value));
|
|
11
|
-
case "Minutes":
|
|
12
|
-
return responsive(responsiveTextSize, () => translate("{0} minutes", value), () => translate("{0} min", value));
|
|
13
|
-
case "Hours":
|
|
14
|
-
return responsive(responsiveTextSize, () => translate("{0} hours", value), () => translate("{0} h", value));
|
|
15
|
-
case "Days":
|
|
16
|
-
return responsive(responsiveTextSize, () => translate("{0} days", value), () => translate("{0} d", value));
|
|
17
|
-
case "Weeks":
|
|
18
|
-
return responsive(responsiveTextSize, () => translate("{0} weeks", value), () => translate("{0} wks.", value));
|
|
19
|
-
case "Months":
|
|
20
|
-
return responsive(responsiveTextSize, () => translate("{0} months", value), () => translate("{0} mos.", value));
|
|
21
|
-
case "Years":
|
|
22
|
-
return responsive(responsiveTextSize, () => translate("{0} years", value), () => translate("{0} yrs.", value));
|
|
23
|
-
case "Centuries":
|
|
24
|
-
return responsive(responsiveTextSize, () => translate("{0} centuries", value), () => translate("{0} cent.", value));
|
|
25
|
-
case "Actions":
|
|
26
|
-
return responsive(responsiveTextSize, () => translate("{0} actions", value), () => translate("{0} act", value));
|
|
27
|
-
case "CombatRounds":
|
|
28
|
-
return responsive(responsiveTextSize, () => translate("{0} combat rounds", value), () => translate("{0} CR", value));
|
|
29
|
-
case "SeductionActions":
|
|
30
|
-
return responsive(responsiveTextSize, () => translate("{0} seduction actions", value), () => translate("{0} SA", value));
|
|
31
|
-
case "Rounds":
|
|
32
|
-
return responsive(responsiveTextSize, () => translate("{0} rounds", value), () => translate("{0} rnds", value));
|
|
33
|
-
default:
|
|
34
|
-
return assertExhaustive(unit);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Returns the text for a cost unit that is based on the entity type.
|
|
39
|
-
*/
|
|
40
|
-
export const formatCost = (translate, entity, value) => {
|
|
41
|
-
switch (entity) {
|
|
42
|
-
case Entity.Cantrip:
|
|
43
|
-
case Entity.Spell:
|
|
44
|
-
case Entity.Ritual:
|
|
45
|
-
return translate("{0} AE", value);
|
|
46
|
-
case Entity.Blessing:
|
|
47
|
-
case Entity.LiturgicalChant:
|
|
48
|
-
case Entity.Ceremony:
|
|
49
|
-
return translate("{0} KP", value);
|
|
50
|
-
default:
|
|
51
|
-
return assertExhaustive(entity);
|
|
52
|
-
}
|
|
53
|
-
};
|
package/lib/libraryEntry.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Compare } from "@optolith/helpers/compare";
|
|
2
|
-
import { PublicationRefs } from "optolith-database-schema/types/source/_PublicationRef";
|
|
3
|
-
import { Translate, TranslateMap } from "./helpers/translate.js";
|
|
4
|
-
/**
|
|
5
|
-
* Creates a function that creates the JSON representation of the rules text for
|
|
6
|
-
* a library entry.
|
|
7
|
-
*/
|
|
8
|
-
export declare const createLibraryEntryCreator: <T, A = undefined>(fn: LibraryEntryCreator<T, A, RawLibraryEntry>) => LibraryEntryCreator<T | undefined, A>;
|
|
9
|
-
/**
|
|
10
|
-
* A function that creates the JSON representation of the rules text for a
|
|
11
|
-
* library entry if given further params to the returned function.
|
|
12
|
-
*/
|
|
13
|
-
export type LibraryEntryCreator<T, A = undefined, R = LibraryEntry> = (entry: T, ...args: A extends undefined ? [] : [A]) => LibraryEntryConfiguredCreator<R>;
|
|
14
|
-
/**
|
|
15
|
-
* A function that is already configures for a specific entity and returns the
|
|
16
|
-
* JSON representation of the rules text for a ibrary entry.
|
|
17
|
-
*/
|
|
18
|
-
export type LibraryEntryConfiguredCreator<R = LibraryEntry> = (params: {
|
|
19
|
-
translate: Translate;
|
|
20
|
-
translateMap: TranslateMap;
|
|
21
|
-
localeCompare: Compare<string>;
|
|
22
|
-
}) => R | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* A JSON representation of the rules text for a library entry.
|
|
25
|
-
*/
|
|
26
|
-
export type LibraryEntry = {
|
|
27
|
-
title: string;
|
|
28
|
-
subtitle?: string;
|
|
29
|
-
className: string;
|
|
30
|
-
content: LibraryEntryContent[];
|
|
31
|
-
src?: PublicationRefs;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* A JSON representation of the rules text for a library entry that has not been
|
|
35
|
-
* cleaned up.
|
|
36
|
-
*/
|
|
37
|
-
export type RawLibraryEntry = {
|
|
38
|
-
title: string;
|
|
39
|
-
subtitle?: string;
|
|
40
|
-
className: string;
|
|
41
|
-
content: (LibraryEntryContent | undefined)[];
|
|
42
|
-
src?: PublicationRefs;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* A slice of the content of a library entry text.
|
|
46
|
-
*/
|
|
47
|
-
export type LibraryEntryContent = {
|
|
48
|
-
label?: string;
|
|
49
|
-
value: string | number;
|
|
50
|
-
noIndent?: boolean;
|
|
51
|
-
className?: string;
|
|
52
|
-
};
|
package/lib/libraryEntry.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { filterNonNullable } from "@optolith/helpers/array";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a function that creates the JSON representation of the rules text for
|
|
4
|
-
* a library entry.
|
|
5
|
-
*/
|
|
6
|
-
export const createLibraryEntryCreator = (fn) => (entry, ...args) => {
|
|
7
|
-
if (entry === undefined) {
|
|
8
|
-
return () => undefined;
|
|
9
|
-
}
|
|
10
|
-
return (params) => {
|
|
11
|
-
const rawEntry = fn(entry, ...args)(params);
|
|
12
|
-
if (rawEntry === undefined) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
return { ...rawEntry, content: filterNonNullable(rawEntry.content) };
|
|
16
|
-
};
|
|
17
|
-
};
|