UNPKG

chonkie

Version:

🦛 CHONK your texts in TS with Chonkie!✨The no-nonsense lightweight and efficient chunking library.

27 lines • 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CodeChunk = void 0; const base_1 = require("./base"); /** Class to represent code chunks with metadata */ class CodeChunk extends base_1.Chunk { constructor(data) { super(data); this.lang = data.lang; this.nodes = data.nodes; } /** Return a string representation of the CodeChunk */ toString() { return `CodeChunk(text=${this.text}, startIndex=${this.startIndex}, endIndex=${this.endIndex}, tokenCount=${this.tokenCount}, lang=${this.lang}, nodes=${this.nodes})`; } /** Return the CodeChunk as a dictionary-like object */ toDict() { const baseDict = super.toDict(); return Object.assign(Object.assign({}, baseDict), { lang: this.lang, nodes: this.nodes }); } /** Create a CodeChunk object from a dictionary */ static fromDict(data) { return new CodeChunk(data); } } exports.CodeChunk = CodeChunk; //# sourceMappingURL=code.js.map