arela
Version:
AI-powered CTO with multi-agent orchestration, code summarization, visual testing (web + mobile) for blazing fast development.
29 lines • 810 B
JavaScript
export class JsonCompressor {
compress(data) {
try {
return JSON.stringify(data);
}
catch (error) {
const message = error?.message ?? String(error);
throw new Error(`JSON compression failed: ${message}`);
}
}
decompress(data) {
try {
return JSON.parse(data);
}
catch (error) {
const message = error?.message ?? String(error);
throw new Error(`JSON decompression failed: ${message}`);
}
}
getTokenCount(data) {
// Rough estimate: 1 token ≈ 4 characters
// For accurate counting, use tiktoken later
return Math.ceil(data.length / 4);
}
getName() {
return "json";
}
}
//# sourceMappingURL=json-compressor.js.map