Skip to content

Commit b99188a

Browse files
committed
fix: use compact in compare method to showcase token savings benefits
- Changed compare method to use compact() instead of encode() - Removed off on off off off off off off off off on off on off off off off off on off off off on on off off off off on off off off off off off off off off off off off on off off off off off off off on off on on off off off on off off on off off on off off on off on off off on off on off off off off on off off off on off off on off off off off off off off off on off on off off on off off off off off off off off off off off off on off off off on off on off on on off off off off on on on off on on off on off on on off off off off on on off off on off off off off off on off off on off off on off off off off off off on off off off off on on off on off off off off off on off on off off off off off off off off off off on on off on off off off parameter since compare should always showcase best-case savings - Ensures TOON's token efficiency is properly demonstrated
1 parent 090986f commit b99188a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/Toon.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ public static function estimateTokens(string $toon): int
8585
/**
8686
* Compare TOON vs JSON token usage.
8787
*
88+
* Uses compact format to showcase TOON's token savings benefits.
89+
*
8890
* @return array{toon: string, json: string, toon_tokens: int, json_tokens: int, savings_percent: float}
8991
*/
90-
public static function compare(mixed $value, ?EncodeOptions $options = null): array
92+
public static function compare(mixed $value): array
9193
{
92-
$toon = self::encode($value, $options);
94+
$toon = self::compact($value);
9395
$json = json_encode($value, JSON_THROW_ON_ERROR);
9496

9597
$toonTokens = self::estimateTokens($toon);

0 commit comments

Comments
 (0)