Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Toon.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ public static function estimateTokens(string $toon): int
/**
* Compare TOON vs JSON token usage.
*
* Uses compact format to showcase TOON's token savings benefits.
*
* @return array{toon: string, json: string, toon_tokens: int, json_tokens: int, savings_percent: float}
*/
public static function compare(mixed $value, ?EncodeOptions $options = null): array
public static function compare(mixed $value): array
{
$toon = self::encode($value, $options);
$toon = self::compact($value);
$json = json_encode($value, JSON_THROW_ON_ERROR);

$toonTokens = self::estimateTokens($toon);
Expand Down