nv-string-conti-cache
v1.0.3
Published
Continuous string slice cache with pause / continue support. Ported from a compile-time C implementation to runtime-dynamic JavaScript.
Downloads
318
Readme
nv-string-conti-cache
Continuous string slice cache with pause / continue support.
Ported from a compile-time C implementation to runtime-dynamic JavaScript.
Stores slice ranges instead of substrings.
Install
npm install nv-string-conti-cache
API
const x = require("nv-string-conti-cache");
x(className, ...fields)
x(className, dict)
Returns:
[cache, ref]
Usage
Prebuilt (C-style)
const [o, ref] = x("Cache", { aa: "sss", bb: "rrr", cc: "ttt", });
o.aa(ref); // "sss"
o.bb(ref); // "rrr"
ref === "sssrrrttt"
Streaming
const [o] = x("Cache", "aa", "bb", "cc");
o.aa_si = 0; o.aa_ei = 3;
o.bb_si = 3; o.bb_ei = 6;
Slice API
For each field X:
X(ref) -> string | null
X_si / X_ei -> number
X_has_value() -> boolean
reset_X()
Ranges are [start, end).
pause / conti
o.pause(ref);
o.lefted;
o.conti("next");
Notes
- Flat Array storage
- Runtime-generated field accessors
- Semantics match the original C version
Use cases
- Streaming Tokenizers
License
Any
