@biolibs/glossary 0.0.0-stage → 0.1.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/README.md +43 -2
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/review.d.ts +65 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +68 -0
- package/dist/review.js.map +1 -0
- package/dist/terms.d.ts +87 -0
- package/dist/terms.d.ts.map +1 -0
- package/dist/terms.js +824 -0
- package/dist/terms.js.map +1 -0
- package/package.json +43 -4
- package/src/index.ts +14 -0
- package/src/review.ts +96 -0
- package/src/terms.ts +926 -0
package/README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @biolibs/glossary
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The words of molecular biology, said plainly. Sixty terms, from *cell* to *RMSD*, each in one sentence, one paragraph and a reason anybody needs to know it, with a record of which have been reviewed by a biologist.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @biolibs/glossary
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
This package is the words. [`@biolibs/glossary-react`](../glossary-react) draws a picture for every one of them, and a term is not added here without a picture being added there.
|
|
10
|
+
|
|
11
|
+
## Looking a term up
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { findEntryByName, getEntry, splitByTerms } from "@biolibs/glossary";
|
|
15
|
+
|
|
16
|
+
getEntry("pcr")?.term; // "PCR"
|
|
17
|
+
getEntry("primer")?.definition; // "A short single strand of DNA, usually 18 to 30 bases, that marks where copying should start."
|
|
18
|
+
findEntryByName("primers")?.slug; // "primer"
|
|
19
|
+
|
|
20
|
+
splitByTerms("A primer binds.", new Set()).map((part) => part.slug ?? part.text);
|
|
21
|
+
// [ "A ", "primer", " binds." ]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`splitByTerms` finds the first mention of each term in a piece of text. It is given the set of terms already explained on the page and adds to it, so a term is explained once and not at every mention.
|
|
25
|
+
|
|
26
|
+
## Who has reviewed a term
|
|
27
|
+
|
|
28
|
+
The words and pictures were written by people building software. They may be wrong, and somebody who is learning cannot tell. So a term can carry a review: who checked the definition and the picture, in what capacity, and when.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { REVIEWS, getEntry, reviewOf, reviewWords, termFingerprint } from "@biolibs/glossary";
|
|
32
|
+
|
|
33
|
+
const fingerprint = termFingerprint(getEntry("pcr")!, "<svg>…</svg>"); // twelve characters
|
|
34
|
+
reviewWords(reviewOf("pcr", fingerprint)); // "Not yet reviewed by a biologist"
|
|
35
|
+
REVIEWS.length; // 0
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
A review is of exactly what was read. `termFingerprint` is made from a term's sentence, paragraph, reason and picture, and a review records the fingerprint it was given. If any of those change afterwards, the review is reported as being of an earlier version (`"earlier"`), never as covering what it did not see.
|
|
39
|
+
|
|
40
|
+
`REVIEWS` is empty. Nothing here has been signed off by anybody, and everything that shows a term says so until somebody does. To record a review, a biologist reads the term on the review sheet in `@biolibs/glossary-react`, which shows the fingerprint, and an entry is added to `src/review.ts`.
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* `@biolibs/glossary`: the words of molecular biology, said plainly, with a place for a biologist to
|
|
4
|
+
* sign them off.
|
|
5
|
+
*
|
|
6
|
+
* Sixty terms, from *cell* to *RMSD*. Each has one sentence, one paragraph, a reason anybody needs
|
|
7
|
+
* to know it, and the phrases in running text that mean it. This package is the words and nothing
|
|
8
|
+
* else; `@biolibs/glossary-react` draws a picture for every one of them.
|
|
9
|
+
*
|
|
10
|
+
* - `terms.ts` — the terms, looking one up, and finding them in text
|
|
11
|
+
* - `review.ts` — who has reviewed a term, and whether it has changed since
|
|
12
|
+
*/
|
|
13
|
+
export * from "./terms.js";
|
|
14
|
+
export * from "./review.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* `@biolibs/glossary`: the words of molecular biology, said plainly, with a place for a biologist to
|
|
4
|
+
* sign them off.
|
|
5
|
+
*
|
|
6
|
+
* Sixty terms, from *cell* to *RMSD*. Each has one sentence, one paragraph, a reason anybody needs
|
|
7
|
+
* to know it, and the phrases in running text that mean it. This package is the words and nothing
|
|
8
|
+
* else; `@biolibs/glossary-react` draws a picture for every one of them.
|
|
9
|
+
*
|
|
10
|
+
* - `terms.ts` — the terms, looking one up, and finding them in text
|
|
11
|
+
* - `review.ts` — who has reviewed a term, and whether it has changed since
|
|
12
|
+
*/
|
|
13
|
+
export * from "./terms.js";
|
|
14
|
+
export * from "./review.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/review.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { GlossaryEntry } from "./terms.js";
|
|
2
|
+
/** Somebody's name put to a term. */
|
|
3
|
+
export interface Review {
|
|
4
|
+
/** The term's slug. */
|
|
5
|
+
slug: string;
|
|
6
|
+
/** Who reviewed it. */
|
|
7
|
+
by: string;
|
|
8
|
+
/** In what capacity: a degree, a post, a field. Whatever lets a reader weigh the name. */
|
|
9
|
+
as: string;
|
|
10
|
+
/** The day it was reviewed, as `YYYY-MM-DD`. */
|
|
11
|
+
on: string;
|
|
12
|
+
/** The fingerprint of what was reviewed, from `termFingerprint`. */
|
|
13
|
+
of: string;
|
|
14
|
+
/** Anything the reviewer wanted said. */
|
|
15
|
+
note?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Every review there is. It starts empty: nothing here has been signed off by anybody, and the
|
|
19
|
+
* package says so until somebody does.
|
|
20
|
+
*
|
|
21
|
+
* To record one, a biologist reads the term and its picture on the review sheet in
|
|
22
|
+
* `@biolibs/glossary-react`, which shows the fingerprint to copy, and an entry is added here.
|
|
23
|
+
*/
|
|
24
|
+
export declare const REVIEWS: readonly Review[];
|
|
25
|
+
/**
|
|
26
|
+
* The fingerprint of a term as it stands: its words, and its picture.
|
|
27
|
+
*
|
|
28
|
+
* @param entry - The term.
|
|
29
|
+
* @param picture - The picture as drawn, as text: the SVG a reader is shown.
|
|
30
|
+
* @returns Twelve characters that change if the definition, the detail, the reason or the picture does.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { getEntry, termFingerprint } from "@biolibs/glossary";
|
|
35
|
+
*
|
|
36
|
+
* termFingerprint(getEntry("pcr")!, "<svg>…</svg>").length; // 12
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function termFingerprint(entry: Pick<GlossaryEntry, "slug" | "term" | "definition" | "detail" | "why">, picture: string): string;
|
|
40
|
+
/** Where a term stands with reviewers. */
|
|
41
|
+
export interface ReviewState {
|
|
42
|
+
/** `current` if somebody reviewed it as it stands, `earlier` if only an earlier version, `none` if nobody has. */
|
|
43
|
+
state: "current" | "earlier" | "none";
|
|
44
|
+
/** The reviews of it as it stands. */
|
|
45
|
+
current: Review[];
|
|
46
|
+
/** The reviews of versions that have since changed. */
|
|
47
|
+
earlier: Review[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Where a term stands with reviewers.
|
|
51
|
+
*
|
|
52
|
+
* @param slug - The term.
|
|
53
|
+
* @param fingerprint - Its fingerprint as it stands, from `termFingerprint`.
|
|
54
|
+
* @param reviews - The reviews to look in.
|
|
55
|
+
* @returns Whether it has been reviewed as it stands, only as it was, or not at all.
|
|
56
|
+
*/
|
|
57
|
+
export declare function reviewOf(slug: string, fingerprint: string, reviews?: readonly Review[]): ReviewState;
|
|
58
|
+
/**
|
|
59
|
+
* A review's state, in the words a reader is shown.
|
|
60
|
+
*
|
|
61
|
+
* @param state - From `reviewOf`.
|
|
62
|
+
* @returns One line.
|
|
63
|
+
*/
|
|
64
|
+
export declare function reviewWords(state: ReviewState): string;
|
|
65
|
+
//# sourceMappingURL=review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qCAAqC;AACrC,MAAM,WAAW,MAAM;IACrB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,0FAA0F;IAC1F,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,EAAE,SAAS,MAAM,EAAO,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGtI;AAED,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,kHAAkH;IAClH,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IACtC,sCAAsC;IACtC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,uDAAuD;IACvD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,SAAS,MAAM,EAAY,GAAG,WAAW,CAK7G;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAKtD"}
|
package/dist/review.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A place for a biologist to put their name to a term.
|
|
3
|
+
*
|
|
4
|
+
* The words and pictures here were written by people building software. They may be wrong, and a
|
|
5
|
+
* reader who is learning cannot tell. So each term can carry a review: who checked the definition
|
|
6
|
+
* and the picture, in what capacity, and when. It is optional, and a term without one says so.
|
|
7
|
+
*
|
|
8
|
+
* A review is of exactly what was looked at. Each term has a fingerprint made from its words and
|
|
9
|
+
* its picture, and a review records the fingerprint it was given. If either the words or the
|
|
10
|
+
* picture change afterwards, the fingerprint no longer matches and the review is shown as being of
|
|
11
|
+
* an earlier version, never as covering what it did not see.
|
|
12
|
+
*/
|
|
13
|
+
import { sha1 } from "@biolibs/core";
|
|
14
|
+
/**
|
|
15
|
+
* Every review there is. It starts empty: nothing here has been signed off by anybody, and the
|
|
16
|
+
* package says so until somebody does.
|
|
17
|
+
*
|
|
18
|
+
* To record one, a biologist reads the term and its picture on the review sheet in
|
|
19
|
+
* `@biolibs/glossary-react`, which shows the fingerprint to copy, and an entry is added here.
|
|
20
|
+
*/
|
|
21
|
+
export const REVIEWS = [];
|
|
22
|
+
/**
|
|
23
|
+
* The fingerprint of a term as it stands: its words, and its picture.
|
|
24
|
+
*
|
|
25
|
+
* @param entry - The term.
|
|
26
|
+
* @param picture - The picture as drawn, as text: the SVG a reader is shown.
|
|
27
|
+
* @returns Twelve characters that change if the definition, the detail, the reason or the picture does.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { getEntry, termFingerprint } from "@biolibs/glossary";
|
|
32
|
+
*
|
|
33
|
+
* termFingerprint(getEntry("pcr")!, "<svg>…</svg>").length; // 12
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function termFingerprint(entry, picture) {
|
|
37
|
+
const said = [entry.slug, entry.term, entry.definition, entry.detail, entry.why, picture].join("\u0000");
|
|
38
|
+
return [...sha1(new TextEncoder().encode(said))].map((byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, 12);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Where a term stands with reviewers.
|
|
42
|
+
*
|
|
43
|
+
* @param slug - The term.
|
|
44
|
+
* @param fingerprint - Its fingerprint as it stands, from `termFingerprint`.
|
|
45
|
+
* @param reviews - The reviews to look in.
|
|
46
|
+
* @returns Whether it has been reviewed as it stands, only as it was, or not at all.
|
|
47
|
+
*/
|
|
48
|
+
export function reviewOf(slug, fingerprint, reviews = REVIEWS) {
|
|
49
|
+
const mine = reviews.filter((one) => one.slug === slug);
|
|
50
|
+
const current = mine.filter((one) => one.of === fingerprint);
|
|
51
|
+
const earlier = mine.filter((one) => one.of !== fingerprint);
|
|
52
|
+
return { state: current.length > 0 ? "current" : earlier.length > 0 ? "earlier" : "none", current, earlier };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A review's state, in the words a reader is shown.
|
|
56
|
+
*
|
|
57
|
+
* @param state - From `reviewOf`.
|
|
58
|
+
* @returns One line.
|
|
59
|
+
*/
|
|
60
|
+
export function reviewWords(state) {
|
|
61
|
+
const who = (reviews) => reviews.map((one) => `${one.by}, ${one.as} (${one.on})`).join("; ");
|
|
62
|
+
if (state.state === "current")
|
|
63
|
+
return `Reviewed by ${who(state.current)}`;
|
|
64
|
+
if (state.state === "earlier")
|
|
65
|
+
return `Changed since it was reviewed by ${who(state.earlier)}`;
|
|
66
|
+
return "Not yet reviewed by a biologist";
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.js","sourceRoot":"","sources":["../src/review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAmBrC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAsB,EAAE,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAAC,KAA6E,EAAE,OAAe;IAC5H,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzG,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3H,CAAC;AAYD;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,WAAmB,EAAE,UAA6B,OAAO;IAC9F,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC;IAC7D,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC/G,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAkB;IAC5C,MAAM,GAAG,GAAG,CAAC,OAA0B,EAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxH,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,eAAe,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;IAC1E,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,oCAAoC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/F,OAAO,iCAAiC,CAAC;AAC3C,CAAC"}
|
package/dist/terms.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The terms: general molecular-biology and bioinformatics words, each said in one sentence, then a
|
|
3
|
+
* paragraph, then why anybody needs to know it.
|
|
4
|
+
*
|
|
5
|
+
* Every term has a picture, drawn by `@biolibs/glossary-react`. A term is not added here without
|
|
6
|
+
* one being added there; a test in that package fails if any term has no picture.
|
|
7
|
+
*/
|
|
8
|
+
/** The groups the terms are sorted into. */
|
|
9
|
+
export type Category = "basics" | "molecules" | "genes" | "records" | "lab" | "comparison" | "structure";
|
|
10
|
+
/** Each group, with what to call it and a line about it, in the order they are read. */
|
|
11
|
+
export declare const CATEGORIES: {
|
|
12
|
+
id: Category;
|
|
13
|
+
title: string;
|
|
14
|
+
blurb: string;
|
|
15
|
+
}[];
|
|
16
|
+
/** One term. */
|
|
17
|
+
export interface GlossaryEntry {
|
|
18
|
+
/** How it is named in an address and in code. It never changes. */
|
|
19
|
+
slug: string;
|
|
20
|
+
/** The term, as it is written. */
|
|
21
|
+
term: string;
|
|
22
|
+
/** The group it is in. */
|
|
23
|
+
category: Category;
|
|
24
|
+
/** One sentence. Shown on cards and in hover definitions. */
|
|
25
|
+
definition: string;
|
|
26
|
+
/** A short paragraph of further explanation. */
|
|
27
|
+
detail: string;
|
|
28
|
+
/** Why anyone needs to know this. */
|
|
29
|
+
why: string;
|
|
30
|
+
/** Phrases in lesson text that should link here, longest first where they overlap. */
|
|
31
|
+
match: string[];
|
|
32
|
+
/** The slugs of terms worth reading next. */
|
|
33
|
+
related: string[];
|
|
34
|
+
/** The lessons on the biolibs site that teach it, by slug. */
|
|
35
|
+
lessons: string[];
|
|
36
|
+
/** biolibs packages that work with this concept. */
|
|
37
|
+
packages: string[];
|
|
38
|
+
}
|
|
39
|
+
/** Every term, in the order they are taught. */
|
|
40
|
+
export declare const GLOSSARY: GlossaryEntry[];
|
|
41
|
+
/**
|
|
42
|
+
* Look a term up.
|
|
43
|
+
*
|
|
44
|
+
* @param slug - Its slug.
|
|
45
|
+
* @returns The term, or `undefined` if there is none by that slug.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { getEntry } from "@biolibs/glossary";
|
|
50
|
+
*
|
|
51
|
+
* getEntry("pcr")?.term; // "PCR"
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function getEntry(slug: string): GlossaryEntry | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The term whose name is some text, ignoring case.
|
|
57
|
+
*
|
|
58
|
+
* @param name - The term, or one of the phrases that mean it.
|
|
59
|
+
* @returns The term, or `undefined` if no term goes by that name.
|
|
60
|
+
*/
|
|
61
|
+
export declare function findEntryByName(name: string): GlossaryEntry | undefined;
|
|
62
|
+
/** The pictures shown in each lesson on the biolibs site, by the lesson's slug and then the term's. */
|
|
63
|
+
export declare const LESSON_FIGURES: Record<string, string[]>;
|
|
64
|
+
/** A stretch of text, and the term it mentions if it mentions one. */
|
|
65
|
+
export type TextPart = {
|
|
66
|
+
text: string;
|
|
67
|
+
slug?: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Split text at the first mention of each glossary term.
|
|
71
|
+
*
|
|
72
|
+
* @param text - Plain text.
|
|
73
|
+
* @param seen - Slugs already linked earlier on the page; matched terms are added to it, so each
|
|
74
|
+
* term is linked once per page and not on every mention.
|
|
75
|
+
* @param skip - Lower-case phrases to leave unlinked.
|
|
76
|
+
* @returns The text in pieces, in order, each either plain or the mention of one term.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import { splitByTerms } from "@biolibs/glossary";
|
|
81
|
+
*
|
|
82
|
+
* splitByTerms("A primer binds.", new Set()).map((part) => part.slug ?? part.text);
|
|
83
|
+
* // [ "A ", "primer", " binds." ]
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function splitByTerms(text: string, seen: Set<string>, skip?: ReadonlySet<string>): TextPart[];
|
|
87
|
+
//# sourceMappingURL=terms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terms.d.ts","sourceRoot":"","sources":["../src/terms.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,4CAA4C;AAC5C,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,YAAY,GAAG,WAAW,CAAC;AAEzG,wFAAwF;AACxF,eAAO,MAAM,UAAU,EAAE;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAQtE,CAAC;AAEF,gBAAgB;AAChB,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,sFAAsF;IACtF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,gDAAgD;AAChD,eAAO,MAAM,QAAQ,EAAE,aAAa,EA0xBnC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAGvE;AAED,uGAAuG;AACvG,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CASnD,CAAC;AAWF,sEAAsE;AACtE,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,QAAQ,EAAE,CAapG"}
|