UNPKG

chonkie

Version:

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

37 lines (36 loc) • 1.06 kB
import { Chunk } from './base'; /** Interface for tree-sitter Node */ export interface TreeSitterNode { [key: string]: any; } /** Interface for CodeChunk data */ interface CodeChunkData { text: string; startIndex: number; endIndex: number; tokenCount: number; lang?: string; nodes?: TreeSitterNode[]; } /** Class to represent code chunks with metadata */ export declare class CodeChunk extends Chunk { /** The programming language of the code */ lang?: string; /** The tree-sitter AST nodes in the chunk */ nodes?: TreeSitterNode[]; constructor(data: { text: string; startIndex: number; endIndex: number; tokenCount: number; lang?: string; nodes?: TreeSitterNode[]; }); /** Return a string representation of the CodeChunk */ toString(): string; /** Return the CodeChunk as a dictionary-like object */ toDict(): CodeChunkData; /** Create a CodeChunk object from a dictionary */ static fromDict(data: CodeChunkData): CodeChunk; } export {};