{"_id":"@ai-path/tb-formula","_rev":"2-ca5761c0cc40b810575dac8f9f73f884","name":"@ai-path/tb-formula","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@ai-path/tb-formula","version":"0.2.0","license":"MIT","_id":"@ai-path/tb-formula@0.2.0","maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"homepage":"https://github.com/aipathjp/lattica#readme","bugs":{"url":"https://github.com/aipathjp/lattica/issues"},"dist":{"shasum":"8adb40d71124573702e20d3c4c667fe0c2e775e5","tarball":"https://registry.npmjs.org/@ai-path/tb-formula/-/tb-formula-0.2.0.tgz","fileCount":9,"integrity":"sha512-E0e9Pjcy9Ltsjq0jtRE9fPjovZ6ePNnGmXpze/KK7OQANtyzna7+7yqyRNNBdMAXFuKy4B5AtMm1z5GmyGb6hA==","signatures":[{"sig":"MEYCIQCrIDmfX/HcN9/I9q/6mIbTpDtdi7lZDSZ/+MJG+K7EfQIhAIXUCZP0Wk+BgFt6wjb42nkNl6omscZuTEh7IqVRr7OE","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":749758},"main":"./dist/index.cjs","type":"module","_from":"file:ai-path-tb-formula-0.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"fsakurai","email":"f-sakurai@ai-path.jp"},"_resolved":"/private/var/folders/tf/0c43660d4k1dg4ssxq0n63ww0000gn/T/b958cfffed3f2598e5e0690ee123661c/ai-path-tb-formula-0.2.0.tgz","_integrity":"sha512-E0e9Pjcy9Ltsjq0jtRE9fPjovZ6ePNnGmXpze/KK7OQANtyzna7+7yqyRNNBdMAXFuKy4B5AtMm1z5GmyGb6hA==","repository":{"url":"git+https://github.com/aipathjp/lattica.git","type":"git","directory":"packages/formula"},"_npmVersion":"10.9.3","description":"Clean-room, dependency-free Excel-compatible formula engine for Taible: lexer, Pratt parser, evaluator, and an incremental dependency graph.","directories":{},"sideEffects":false,"_nodeVersion":"22.18.0","dependencies":{"@ai-path/tb-core":"0.2.0"},"publishConfig":{"access":"public","provenance":false},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tb-formula_0.2.0_1783181301575_0.43551738042282206","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@ai-path/tb-formula","version":"0.3.0","description":"Clean-room, dependency-free Excel-compatible formula engine for Taible: lexer, Pratt parser, evaluator, and an incremental dependency graph.","license":"MIT","type":"module","sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"dependencies":{"@ai-path/tb-core":"0.3.0"},"repository":{"type":"git","url":"git+https://github.com/aipathjp/lattica.git","directory":"packages/formula"},"homepage":"https://github.com/aipathjp/lattica#readme","bugs":{"url":"https://github.com/aipathjp/lattica/issues"},"publishConfig":{"access":"public","provenance":false},"scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_id":"@ai-path/tb-formula@0.3.0","_integrity":"sha512-4uCLHRMR1tI+uEXEL5+XtJ15itpSZmGlYUMWfRiCp2caKSg4tiu3Nt0CSPAcOcb3z4+Aq1lPauDuc+/AO2jHvw==","_resolved":"/private/var/folders/tf/0c43660d4k1dg4ssxq0n63ww0000gn/T/cf0822d2f6d69ea1e8c73a87fba69198/ai-path-tb-formula-0.3.0.tgz","_from":"file:ai-path-tb-formula-0.3.0.tgz","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-4uCLHRMR1tI+uEXEL5+XtJ15itpSZmGlYUMWfRiCp2caKSg4tiu3Nt0CSPAcOcb3z4+Aq1lPauDuc+/AO2jHvw==","shasum":"d3cd148a7d05ec5d5d6ba0177e091494cb13480d","tarball":"https://registry.npmjs.org/@ai-path/tb-formula/-/tb-formula-0.3.0.tgz","fileCount":9,"unpackedSize":749758,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDUWquo0ZzsgBu5Qpo+Yn4aj+3qtzHpSdg2Vi3dqJjOBQIhAP0lzfKVIXhj7HOfEm7tjLY206MIAXAF4D/0yRwZ5v64"}]},"_npmUser":{"name":"fsakurai","email":"f-sakurai@ai-path.jp"},"directories":{},"maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tb-formula_0.3.0_1783188079107_0.4394547833060036"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-04T16:08:21.455Z","modified":"2026-07-04T18:01:19.427Z","0.2.0":"2026-07-04T16:08:21.736Z","0.3.0":"2026-07-04T18:01:19.280Z"},"bugs":{"url":"https://github.com/aipathjp/lattica/issues"},"license":"MIT","homepage":"https://github.com/aipathjp/lattica#readme","repository":{"type":"git","url":"git+https://github.com/aipathjp/lattica.git","directory":"packages/formula"},"description":"Clean-room, dependency-free Excel-compatible formula engine for Taible: lexer, Pratt parser, evaluator, and an incremental dependency graph.","maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"readme":"# @ai-path/tb-formula\n\nA clean-room, Excel-compatible formula engine for Taible. It is a complete\npipeline — lexer, parser, value coercion, an evaluator with a pluggable function\nregistry, reference extraction, a dependency graph with topological\nrecalculation, and a high-level `SheetEngine` that ties it all together — with\nno runtime dependencies. R1C1 ↔ A1 conversion and a typed error model round out\nthe package.\n\n## Install\n\n```sh\npnpm add @ai-path/tb-formula\n```\n\n## API overview\n\n### SheetEngine\n\nThe main entry point: set literal or formula content into cells, read back\ncomputed values, and define named ranges. `setContent` returns the set of cell\nkeys that recalculated.\n\n```ts\nimport { SheetEngine } from '@ai-path/tb-formula';\n\nconst engine = new SheetEngine();\nengine.setContent({ row: 0, col: 0 }, 10);\nengine.setContent({ row: 1, col: 0 }, 20);\nengine.setContent({ row: 2, col: 0 }, '=SUM(A1:A2)');\n\nengine.getValue({ row: 2, col: 0 });   // 30\nengine.getContent({ row: 2, col: 0 }); // '=SUM(A1:A2)'\n```\n\n### Named ranges & ad-hoc evaluation\n\n```ts\nimport { SheetEngine } from '@ai-path/tb-formula';\n\nconst engine = new SheetEngine();\nengine.defineName('TAX', '0.1');\nengine.getNames();                      // ['TAX']\nengine.evaluateFormula('100 * (1 + TAX)'); // 110\n```\n\n### Parsing & references\n\n`parseFormula` (and the `Parser`) turn formula text into an AST; `tokenize`\nexposes the lexer; `extractReferences` lists the cell/range references a formula\ndepends on.\n\n```ts\nimport { parseFormula, extractReferences, tokenize } from '@ai-path/tb-formula';\n\nconst ast = parseFormula('A1 + SUM(B1:B3)');\nconst refs = extractReferences('A1 + SUM(B1:B3)'); // referenced cells/ranges\nconst tokens = tokenize('A1+1');\n```\n\n### Errors, functions, and R1C1\n\n- `FormulaError` plus the standard tokens `DIV0`, `VALUE`, `REF`, `NAME`, `NA`, `NUM`, `CYCLE` (and `errorFromText`). Use `FormulaError.is(value)` to test a computed value.\n- `createDefaultFunctions()` builds the built-in `FunctionRegistry`; `builtinFunctionNames` lists them. Pass a custom registry to `new SheetEngine({ functions })`.\n- `DependencyGraph` / `topoSort` drive recalculation order.\n- Value coercion helpers: `toNumber`, `toText`, `toBoolean`, `compareScalars`, `isNumeric`.\n- R1C1 interop: `a1ToR1C1`, `r1c1ToA1`, `isR1C1`.\n\n```ts\nimport { a1ToR1C1, FormulaError } from '@ai-path/tb-formula';\n\na1ToR1C1('B3'); // 'R3C2'\nFormulaError.is(engine.getValue({ row: 0, col: 0 }));\n```\n","readmeFilename":"README.md"}