@sohqureshi/tokenwise 1.0.0

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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +260 -0
  3. package/dist/chunk-2IQAGI7Q.js +54 -0
  4. package/dist/chunk-33GBS5YN.js +288 -0
  5. package/dist/chunk-33RRCCAT.js +287 -0
  6. package/dist/chunk-3ECVBELU.js +49 -0
  7. package/dist/chunk-D4CFTFM3.js +105 -0
  8. package/dist/chunk-EUFLW42L.js +13 -0
  9. package/dist/chunk-GQ62V6ZK.js +61 -0
  10. package/dist/chunk-HKCPRPJL.js +294 -0
  11. package/dist/chunk-IAV75SZA.js +36 -0
  12. package/dist/chunk-JBKETSTK.js +270 -0
  13. package/dist/chunk-SURFMVNH.js +285 -0
  14. package/dist/chunk-TM6L7YF2.js +9 -0
  15. package/dist/chunk-YMOSWQGE.js +22 -0
  16. package/dist/cli.cjs +352 -0
  17. package/dist/cli.d.cts +1 -0
  18. package/dist/cli.d.ts +1 -0
  19. package/dist/cli.js +51 -0
  20. package/dist/core/analyze.cjs +181 -0
  21. package/dist/core/analyze.d.cts +13 -0
  22. package/dist/core/analyze.d.ts +13 -0
  23. package/dist/core/analyze.js +11 -0
  24. package/dist/core/compact.cjs +68 -0
  25. package/dist/core/compact.d.cts +3 -0
  26. package/dist/core/compact.d.ts +3 -0
  27. package/dist/core/compact.js +7 -0
  28. package/dist/core/flatten.cjs +46 -0
  29. package/dist/core/flatten.d.cts +18 -0
  30. package/dist/core/flatten.d.ts +18 -0
  31. package/dist/core/flatten.js +6 -0
  32. package/dist/core/natural.cjs +129 -0
  33. package/dist/core/natural.d.cts +28 -0
  34. package/dist/core/natural.d.ts +28 -0
  35. package/dist/core/natural.js +6 -0
  36. package/dist/core/prune.cjs +60 -0
  37. package/dist/core/prune.d.cts +11 -0
  38. package/dist/core/prune.d.ts +11 -0
  39. package/dist/core/prune.js +6 -0
  40. package/dist/core/token.cjs +33 -0
  41. package/dist/core/token.d.cts +12 -0
  42. package/dist/core/token.d.ts +12 -0
  43. package/dist/core/token.js +6 -0
  44. package/dist/core/toon.cjs +73 -0
  45. package/dist/core/toon.d.cts +25 -0
  46. package/dist/core/toon.d.ts +25 -0
  47. package/dist/core/toon.js +6 -0
  48. package/dist/index.cjs +344 -0
  49. package/dist/index.d.cts +40 -0
  50. package/dist/index.d.ts +40 -0
  51. package/dist/index.js +49 -0
  52. package/package.json +78 -0
@@ -0,0 +1,40 @@
1
+ import { estimateTokens } from './core/token.js';
2
+ import { toNatural } from './core/natural.js';
3
+ import { analyze } from './core/analyze.js';
4
+ import { toTOON } from './core/toon.js';
5
+ import { flatten } from './core/flatten.js';
6
+ import { compact } from './core/compact.js';
7
+ import { prune } from './core/prune.js';
8
+
9
+ declare class AIChain {
10
+ private data;
11
+ constructor(data: any);
12
+ prune(options?: any): this;
13
+ compact(): this;
14
+ flatten(): this;
15
+ toTOON(): this;
16
+ toNatural(): string;
17
+ analyze(): {
18
+ originalTokens: number;
19
+ optimizedTokens: number;
20
+ savings: number;
21
+ savingsPercent: number;
22
+ optimizedData: any;
23
+ reductionRatio: number;
24
+ };
25
+ value(): any;
26
+ }
27
+
28
+ declare function ai(data: any): AIChain;
29
+ declare namespace ai {
30
+ var prune: typeof prune;
31
+ var compact: typeof compact;
32
+ var flatten: typeof flatten;
33
+ var toTOON: typeof toTOON;
34
+ var analyze: typeof analyze;
35
+ var toNatural: typeof toNatural;
36
+ var estimateTokens: typeof estimateTokens;
37
+ var AIChain: typeof AIChain;
38
+ }
39
+
40
+ export { AIChain, analyze, compact, ai as default, estimateTokens, flatten, prune, toNatural, toTOON };
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ import {
2
+ AIChain
3
+ } from "./chunk-2IQAGI7Q.js";
4
+ import {
5
+ analyze
6
+ } from "./chunk-GQ62V6ZK.js";
7
+ import {
8
+ toTOON
9
+ } from "./chunk-3ECVBELU.js";
10
+ import {
11
+ compact
12
+ } from "./chunk-EUFLW42L.js";
13
+ import {
14
+ flatten
15
+ } from "./chunk-YMOSWQGE.js";
16
+ import {
17
+ toNatural
18
+ } from "./chunk-D4CFTFM3.js";
19
+ import {
20
+ prune
21
+ } from "./chunk-IAV75SZA.js";
22
+ import {
23
+ estimateTokens
24
+ } from "./chunk-TM6L7YF2.js";
25
+
26
+ // src/index.ts
27
+ function ai(data) {
28
+ return new AIChain(data);
29
+ }
30
+ ai.prune = prune;
31
+ ai.compact = compact;
32
+ ai.flatten = flatten;
33
+ ai.toTOON = toTOON;
34
+ ai.analyze = analyze;
35
+ ai.toNatural = toNatural;
36
+ ai.estimateTokens = estimateTokens;
37
+ ai.AIChain = AIChain;
38
+ var index_default = ai;
39
+ export {
40
+ AIChain,
41
+ analyze,
42
+ compact,
43
+ index_default as default,
44
+ estimateTokens,
45
+ flatten,
46
+ prune,
47
+ toNatural,
48
+ toTOON
49
+ };
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@sohqureshi/tokenwise",
3
+ "version": "1.0.0",
4
+ "description": "Optimize JSON data for AI by reducing token usage",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./core/analyze": {
15
+ "types": "./dist/core/analyze.d.ts",
16
+ "import": "./dist/core/analyze.js",
17
+ "require": "./dist/core/analyze.cjs"
18
+ },
19
+ "./core/compact": {
20
+ "types": "./dist/core/compact.d.ts",
21
+ "import": "./dist/core/compact.js",
22
+ "require": "./dist/core/compact.cjs"
23
+ },
24
+ "./core/flatten": {
25
+ "types": "./dist/core/flatten.d.ts",
26
+ "import": "./dist/core/flatten.js",
27
+ "require": "./dist/core/flatten.cjs"
28
+ },
29
+ "./core/natural": {
30
+ "types": "./dist/core/natural.d.ts",
31
+ "import": "./dist/core/natural.js",
32
+ "require": "./dist/core/natural.cjs"
33
+ },
34
+ "./core/prune": {
35
+ "types": "./dist/core/prune.d.ts",
36
+ "import": "./dist/core/prune.js",
37
+ "require": "./dist/core/prune.cjs"
38
+ },
39
+ "./core/token": {
40
+ "types": "./dist/core/token.d.ts",
41
+ "import": "./dist/core/token.js",
42
+ "require": "./dist/core/token.cjs"
43
+ },
44
+ "./core/toon": {
45
+ "types": "./dist/core/toon.d.ts",
46
+ "import": "./dist/core/toon.js",
47
+ "require": "./dist/core/toon.cjs"
48
+ }
49
+ },
50
+ "bin": {
51
+ "tokenwise": "./dist/cli.js"
52
+ },
53
+ "files": [
54
+ "dist"
55
+ ],
56
+ "scripts": {
57
+ "build": "tsup src/index.ts src/cli.ts src/core/analyze.ts src/core/compact.ts src/core/flatten.ts src/core/natural.ts src/core/prune.ts src/core/token.ts src/core/toon.ts --format esm,cjs --dts",
58
+ "test": "vitest",
59
+ "prepare": "npm run build"
60
+ },
61
+ "keywords": [
62
+ "ai",
63
+ "llm",
64
+ "token",
65
+ "json",
66
+ "optimization",
67
+ "toon",
68
+ "data-processing"
69
+ ],
70
+ "author": "Mohammad Sohail",
71
+ "license": "MIT",
72
+ "devDependencies": {
73
+ "@types/node": "^25.6.0",
74
+ "tsup": "^8.0.0",
75
+ "typescript": "^5.0.0",
76
+ "vitest": "^1.0.0"
77
+ }
78
+ }