This is a simple string calculator application written in TypeScript. It provides a function to add numbers in a string format, supporting custom delimiters and handling various edge cases.
To install the dependencies, run:
npm install
To use the add function, import it and pass a string of numbers:
import { add } from './src/string-calculator';
const result = add('1,2,3');
console.log(result); // Output: 6
- Supports custom delimiters
- Handles new lines between numbers
- Throws an error for negative numbers
- Validates input for invalid numbers
build
: Compiles the TypeScript codetest
: Runs the tests using Jestformat
: Formats the code using Prettier
To build, use:
tsc
To run the tests, use:
npm test
To format the code, use:
npm run format
