brevit 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +21 -78
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,24 +1,24 @@
1
- # Brevit.js
1
+ # brevit
2
2
 
3
3
  A high-performance JavaScript library for semantically compressing and optimizing data before sending it to a Large Language Model (LLM). Dramatically reduce token costs while maintaining data integrity and readability.
4
4
 
5
5
  ## Table of Contents
6
6
 
7
- - [Why Brevit.js?](#why-brevitjs)
7
+ - [Why brevit?](#why-brevit)
8
8
  - [Key Features](#key-features)
9
- - [When Not to Use Brevit.js](#when-not-to-use-brevitjs)
9
+ - [When Not to Use brevit](#when-not-to-use-brevit)
10
10
  - [Benchmarks](#benchmarks)
11
11
  - [Installation & Quick Start](#installation--quick-start)
12
12
  - [Playgrounds](#playgrounds)
13
13
  - [CLI](#cli)
14
14
  - [Format Overview](#format-overview)
15
15
  - [API](#api)
16
- - [Using Brevit.js in LLM Prompts](#using-brevitjs-in-llm-prompts)
16
+ - [Using brevit in LLM Prompts](#using-brevit-in-llm-prompts)
17
17
  - [Syntax Cheatsheet](#syntax-cheatsheet)
18
18
  - [Other Implementations](#other-implementations)
19
19
  - [Full Specification](#full-specification)
20
20
 
21
- ## Why Brevit.js?
21
+ ## Why brevit?
22
22
 
23
23
  ### JavaScript-Specific Advantages
24
24
 
@@ -53,7 +53,7 @@ const explicit = await brevit.optimize(complexOrder);
53
53
 
54
54
  ### Automatic Strategy Selection
55
55
 
56
- Brevit.js now includes the `.brevity()` method that automatically analyzes your data and selects the optimal optimization strategy:
56
+ brevit now includes the `.brevity()` method that automatically analyzes your data and selects the optimal optimization strategy:
57
57
 
58
58
  ```javascript
59
59
  const data = {
@@ -110,7 +110,7 @@ pnpm add brevit
110
110
 
111
111
  ### TypeScript Support
112
112
 
113
- Brevit.js includes full TypeScript definitions. Simply import and use with full type safety:
113
+ brevit includes full TypeScript definitions. Simply import and use with full type safety:
114
114
 
115
115
  ```typescript
116
116
  import {
@@ -130,7 +130,7 @@ const client = new BrevitClient(new BrevitConfig(config));
130
130
 
131
131
  ## Complete Usage Examples
132
132
 
133
- Brevit.js supports three main data types: **JSON objects/strings**, **text files/strings**, and **images**. Here's how to use each:
133
+ brevit supports three main data types: **JSON objects/strings**, **text files/strings**, and **images**. Here's how to use each:
134
134
 
135
135
  ### 1. JSON Optimization Examples
136
136
 
@@ -219,20 +219,6 @@ const optimized = await brevit.brevity(jsonString);
219
219
  // @o.status:SHIPPED
220
220
  ```
221
221
 
222
- #### Example 1.2a: Abbreviations Disabled
223
-
224
- ```javascript
225
- const brevitNoAbbr = new BrevitClient(new BrevitConfig({
226
- jsonMode: JsonOptimizationMode.Flatten,
227
- enableAbbreviations: false // Disable abbreviations
228
- }));
229
-
230
- const jsonString = '{"order": {"id": "o-456", "status": "SHIPPED"}}';
231
- const optimized = await brevitNoAbbr.brevity(jsonString);
232
- // Output (without abbreviations):
233
- // order.id:o-456
234
- // order.status:SHIPPED
235
- ```
236
222
 
237
223
  #### Example 1.3: Complex Nested JSON with Arrays
238
224
 
@@ -276,51 +262,6 @@ const optimized = await brevit.brevity(complexData);
276
262
  // luis,9.2,540,2,Ridge Overlook,false
277
263
  ```
278
264
 
279
- #### Example 1.3a: Complex Data with Abbreviations Disabled
280
-
281
- ```javascript
282
- const brevitNoAbbr = new BrevitClient(new BrevitConfig({
283
- jsonMode: JsonOptimizationMode.Flatten,
284
- enableAbbreviations: false // Disable abbreviations
285
- }));
286
-
287
- const complexData = {
288
- context: {
289
- task: "Our favorite hikes together",
290
- location: "Boulder",
291
- season: "spring_2025"
292
- },
293
- friends: ["ana", "luis", "sam"],
294
- hikes: [
295
- {
296
- id: 1,
297
- name: "Blue Lake Trail",
298
- distanceKm: 7.5,
299
- elevationGain: 320,
300
- companion: "ana",
301
- wasSunny: true
302
- },
303
- {
304
- id: 2,
305
- name: "Ridge Overlook",
306
- distanceKm: 9.2,
307
- elevationGain: 540,
308
- companion: "luis",
309
- wasSunny: false
310
- }
311
- ]
312
- };
313
-
314
- const optimized = await brevitNoAbbr.brevity(complexData);
315
- // Output (without abbreviations):
316
- // context.task:Our favorite hikes together
317
- // context.location:Boulder
318
- // context.season:spring_2025
319
- // friends[3]:ana,luis,sam
320
- // hikes[2]{companion,distanceKm,elevationGain,id,name,wasSunny}:
321
- // ana,7.5,320,1,Blue Lake Trail,true
322
- // luis,9.2,540,2,Ridge Overlook,false
323
- ```
324
265
 
325
266
  #### Example 1.4: Different JSON Optimization Modes
326
267
 
@@ -643,7 +584,7 @@ processOrder(order).then(console.log);
643
584
  <!DOCTYPE html>
644
585
  <html>
645
586
  <head>
646
- <title>Brevit.js Example</title>
587
+ <title>brevit Example</title>
647
588
  </head>
648
589
  <body>
649
590
  <script type="module">
@@ -880,14 +821,16 @@ const user = {
880
821
  };
881
822
 
882
823
  const optimized = await brevit.optimize(user);
883
- // Output:
884
- // id: u-123
885
- // name: Javian
886
- // isActive: true
887
- // contact.email: support@javianpicardo.com
888
- // contact.phone: null
889
- // orders[0].orderId: o-456
890
- // orders[0].status: SHIPPED
824
+ // Output (with abbreviations enabled by default):
825
+ // @c=contact
826
+ // @o=orders
827
+ // id:u-123
828
+ // name:Javian
829
+ // isActive:true
830
+ // @c.email:support@javianpicardo.com
831
+ // @c.phone:null
832
+ // @o[0].orderId:o-456
833
+ // @o[0].status:SHIPPED
891
834
  ```
892
835
 
893
836
  ### Example 2: Optimize JSON String
@@ -925,7 +868,7 @@ const optimized = await brevit.optimize(imageData);
925
868
  // Will trigger image optimization
926
869
  ```
927
870
 
928
- ## When Not to Use Brevit.js
871
+ ## When Not to Use brevit
929
872
 
930
873
  Consider alternatives when:
931
874
 
@@ -1199,7 +1142,7 @@ class BrevitConfig {
1199
1142
  - `Ocr` - Extract text via OCR
1200
1143
  - `Metadata` - Extract metadata only
1201
1144
 
1202
- ## Using Brevit.js in LLM Prompts
1145
+ ## Using brevit in LLM Prompts
1203
1146
 
1204
1147
  ### Best Practices
1205
1148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brevit",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "A high-performance JavaScript library for semantically compressing and optimizing data before sending it to a Large Language Model (LLM).",
5
5
  "main": "src/brevit.js",
6
6
  "types": "src/brevit.d.ts",