{"_id":"@ai-path/lattica-formula","_rev":"3-ee17aaa35d5ae45f47020353841ed4a2","name":"@ai-path/lattica-formula","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@ai-path/lattica-formula","version":"0.1.0","license":"MIT","_id":"@ai-path/lattica-formula@0.1.0","maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"dist":{"shasum":"7c4a02486f19c22379adfa32487c74671530fdb2","tarball":"https://registry.npmjs.org/@ai-path/lattica-formula/-/lattica-formula-0.1.0.tgz","fileCount":8,"integrity":"sha512-rZcZDTti0qKG5VbLWibA1OTLgxvRXt6WIvQ/8NZBbgjJZoLlqTARMMg6HoXgXj7hWdTVGJfBeBkAjhtIBfjRpg==","signatures":[{"sig":"MEQCIBiJScupK+3R7tN+hXfB5spjduLknvXuhcDpF97Bp5BOAiBte0U5upJ8x/BKd1MZTi72rG3jPhtwREEmKnhwMlTj8A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":748573},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"2e14dee9aa41d49bc8899cc2091f182e6f3dd349","scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"fsakurai","email":"f-sakurai@ai-path.jp"},"_npmVersion":"10.9.3","description":"Clean-room, dependency-free Excel-compatible formula engine for Lattica: lexer, Pratt parser, evaluator, and an incremental dependency graph.","directories":{},"sideEffects":false,"_nodeVersion":"22.18.0","dependencies":{"@ai-path/lattica-core":"workspace:*"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/lattica-formula_0.1.0_1783152244858_0.7541745220179781","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Renamed to @ai-path/tb-formula (product: Taible). Install @ai-path/tb-formula instead."},"0.1.1":{"name":"@ai-path/lattica-formula","version":"0.1.1","license":"MIT","_id":"@ai-path/lattica-formula@0.1.1","maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"dist":{"shasum":"0d33de6bfc6b6c815253b528707c4e5fc3701cae","tarball":"https://registry.npmjs.org/@ai-path/lattica-formula/-/lattica-formula-0.1.1.tgz","fileCount":9,"integrity":"sha512-E+DVSxfMok5GEA//2MjYwhOEbEs9/8NyT8VcfeS+WpP/8WzaT5wFl3TNHdbDLiC7adP7PGxLZ6i+9lJFxga7xw==","signatures":[{"sig":"MEUCIBlrl04l1WQkb7jrn9+WO1M5VmvvhhVMLDxwoHR35GQkAiEApnreSw0hIirB0cqpgj/y0ErirXNgyEDA86lDRVjtXEo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":749655},"main":"./dist/index.cjs","type":"module","_from":"file:/tmp/lattica-publish/ai-path-lattica-formula-0.1.1.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":"/tmp/lattica-publish/ai-path-lattica-formula-0.1.1.tgz","_integrity":"sha512-E+DVSxfMok5GEA//2MjYwhOEbEs9/8NyT8VcfeS+WpP/8WzaT5wFl3TNHdbDLiC7adP7PGxLZ6i+9lJFxga7xw==","_npmVersion":"10.9.3","description":"Clean-room, dependency-free Excel-compatible formula engine for Lattica: lexer, Pratt parser, evaluator, and an incremental dependency graph.","directories":{},"sideEffects":false,"_nodeVersion":"22.18.0","dependencies":{"@ai-path/lattica-core":"0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/lattica-formula_0.1.1_1783159894718_0.8529898796649484","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Renamed to @ai-path/tb-formula (product: Taible). Install @ai-path/tb-formula instead."}},"time":{"created":"2026-07-04T08:04:04.634Z","modified":"2026-07-04T16:08:45.990Z","0.1.0":"2026-07-04T08:04:05.045Z","0.1.1":"2026-07-04T10:11:34.879Z"},"license":"MIT","description":"Clean-room, dependency-free Excel-compatible formula engine for Lattica: lexer, Pratt parser, evaluator, and an incremental dependency graph.","maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"readme":"# @ai-path/lattica-formula\n\nA clean-room, Excel-compatible formula engine for Lattica. 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/lattica-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/lattica-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/lattica-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/lattica-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/lattica-formula';\n\na1ToR1C1('B3'); // 'R3C2'\nFormulaError.is(engine.getValue({ row: 0, col: 0 }));\n```\n","readmeFilename":"README.md"}