A multi-language library for handling lexicographic position calculations, providing consistent implementations across TypeScript, Go, C#, Java, and Rust. Perfect for implementing fractional indexing in ordered lists and trees.
midpoint(a, b)- Return lexicographic midpoint betweenaandb, enforcinga< pos <bvalidate(pos)- Ensure position string is lowercase a–z and ≤ max lengthneedsRebalance(a, b)- True if midpoint would exceed length or conflictrebalance3(a, b, c)- Return 3 evenly spaced values between "a" and "z"compare(a, b)- Lexicographic sort logic (safe in all langs)
test-vectors/- Shared golden test cases for consistency across all implementationsts/- TypeScript implementationgo/- Go implementationcsharp/- C# (.NET) implementationjava/- Java implementationrust/- Rust implementationscripts/- Build and test automation scripts.github/workflows/- CI/CD workflows for all languages
All implementations use the same test vectors from test-vectors/positions.json to ensure mathematical consistency across languages.
Each language implementation has its own README with specific setup instructions:
Please ensure all implementations pass the shared test vectors before submitting changes.