@jarenjs/md 0.72.0 → 0.72.3
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/dist/types/loader.d.ts +3 -1
- package/docs/LOADER.md +4 -2
- package/package.json +4 -4
- package/src/loader.js +10 -24
package/dist/types/loader.d.ts
CHANGED
|
@@ -47,7 +47,9 @@ export type MdCache = {
|
|
|
47
47
|
* @property {() => void} clear
|
|
48
48
|
*/
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* The shared core LRU with Markdown's numeric-capacity policy: fractions
|
|
51
|
+
* round down, values below one retain nothing, and Infinity or NaN
|
|
52
|
+
* disable capacity eviction.
|
|
51
53
|
* @param {number} [limit]
|
|
52
54
|
* @returns {MdCache}
|
|
53
55
|
*/
|
package/docs/LOADER.md
CHANGED
|
@@ -39,8 +39,10 @@ callbacks key by identity, so equally named plugins with different
|
|
|
39
39
|
implementations never alias. Treat plugin objects and callbacks as
|
|
40
40
|
immutable for the lifetime of a compiled document.
|
|
41
41
|
|
|
42
|
-
- `createMdCache(limit = 64)` — an LRU cache
|
|
43
|
-
shared instance is exported as
|
|
42
|
+
- `createMdCache(limit = 64)` — an LRU cache backed by
|
|
43
|
+
`@jarenjs/core/cache`; the default shared instance is exported as
|
|
44
|
+
`defaultMdCache`. Numeric capacities round down; values below one
|
|
45
|
+
retain no entries. `Infinity` and `NaN` do not trigger eviction.
|
|
44
46
|
- `cache: false` — bypass entirely.
|
|
45
47
|
- `cache.delete(url)` — invalidate the normalized URL's default-options
|
|
46
48
|
entry; `cache.clear()` invalidates every entry, including option variants.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jarenjs/md",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.72.
|
|
4
|
+
"version": "0.72.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./dist/types/index.d.ts",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"prepack": "npm run build:types"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@jarenjs/core": "^0.72.
|
|
77
|
-
"@jarenjs/mermaid": "^0.72.
|
|
78
|
-
"@jarenjs/view": "^0.72.
|
|
76
|
+
"@jarenjs/core": "^0.72.3",
|
|
77
|
+
"@jarenjs/mermaid": "^0.72.3",
|
|
78
|
+
"@jarenjs/view": "^0.72.3"
|
|
79
79
|
}
|
|
80
80
|
}
|
package/src/loader.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* an async iterator of completed top-level blocks.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
import { createBoundedCache } from '@jarenjs/core/cache';
|
|
15
|
+
|
|
14
16
|
import { createIncrementalParser } from './parser.js';
|
|
15
17
|
import { compileMarkdown } from './compiler.js';
|
|
16
18
|
|
|
@@ -37,35 +39,19 @@ import { compileMarkdown } from './compiler.js';
|
|
|
37
39
|
*/
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
|
-
*
|
|
42
|
+
* The shared core LRU with Markdown's numeric-capacity policy: fractions
|
|
43
|
+
* round down, values below one retain nothing, and Infinity or NaN
|
|
44
|
+
* disable capacity eviction.
|
|
41
45
|
* @param {number} [limit]
|
|
42
46
|
* @returns {MdCache}
|
|
43
47
|
*/
|
|
44
48
|
export function createMdCache(limit = 64) {
|
|
45
|
-
|
|
46
|
-
const entries = new Map();
|
|
49
|
+
const cache = createBoundedCache(Math.floor(limit));
|
|
47
50
|
return {
|
|
48
|
-
get
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
entries.set(key, entry);
|
|
53
|
-
}
|
|
54
|
-
return entry;
|
|
55
|
-
},
|
|
56
|
-
set(key, entry) {
|
|
57
|
-
entries.delete(key);
|
|
58
|
-
entries.set(key, entry);
|
|
59
|
-
if (entries.size > limit) {
|
|
60
|
-
entries.delete(entries.keys().next().value);
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
delete(key) {
|
|
64
|
-
return entries.delete(key);
|
|
65
|
-
},
|
|
66
|
-
clear() {
|
|
67
|
-
entries.clear();
|
|
68
|
-
},
|
|
51
|
+
get: cache.get,
|
|
52
|
+
set: limit < 1 ? () => {} : cache.set,
|
|
53
|
+
delete: cache.delete,
|
|
54
|
+
clear: cache.clear,
|
|
69
55
|
};
|
|
70
56
|
}
|
|
71
57
|
|