@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
56 lines • 1.89 kB
TypeScript
//#region src/utils/chunkJSON.d.ts
/**
* Split & reassemble JSON by character budget.
* - Measures serialized size using JSON.stringify(..).length (characters).
* - Ensures each chunk is itself valid JSON.
* - Very large strings are split into safe pieces using getChunk and re-concatenated on assemble.
* - Protects against circular structures (JSON can't serialize those anyway).
*/
type JSONPrimitive = string | number | boolean | null;
type JSONValue = JSONPrimitive | JSONObject | JSONArray;
type JSONObject = {
[k: string]: JSONValue;
};
type JSONArray = JSONValue[];
type Path = Array<string | number>;
type SetPatch = {
op: 'set';
path: Path;
value: JSONValue;
};
type StrAppendPatch = {
op: 'str-append';
path: Path;
value: string;
index: number;
total: number;
};
type Patch = SetPatch | StrAppendPatch;
type RootType = 'object' | 'array';
type JsonChunk = {
schemaVersion: 1;
index: number;
total: number;
rootType: RootType;
checksum: string;
entries: Patch[];
};
/**
* Split JSON into chunks constrained by character count of serialized chunk.
*/
declare const chunkJSON: (value: JSONObject | JSONArray, maxChars: number) => JsonChunk[];
/**
* Reassemble JSON from chunks.
* - Validates checksums and indices.
* - Applies 'set' patches and merges string pieces from 'str-append'.
*/
/**
* Reconstruct content from a single chunk without validation.
* Useful for processing individual chunks in a pipeline where you don't have all chunks yet.
* Note: This will only reconstruct the partial content contained in this chunk.
*/
declare const reconstructFromSingleChunk: (chunk: JsonChunk) => JSONObject | JSONArray;
declare const assembleJSON: (chunks: JsonChunk[]) => JSONObject | JSONArray;
//#endregion
export { JSONObject, JsonChunk, assembleJSON, chunkJSON, reconstructFromSingleChunk };
//# sourceMappingURL=chunkJSON.d.ts.map