Skip to content

Commit 0051b5b

Browse files
hypermath init
0 parents  commit 0051b5b

13 files changed

+9699
-0
lines changed

.eslintrc.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
tsconfigRootDir: __dirname,
6+
sourceType: 'module',
7+
},
8+
plugins: ['@typescript-eslint/eslint-plugin'],
9+
extends: [
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
jest: true,
17+
},
18+
ignorePatterns: ['.eslintrc.js'],
19+
rules: {
20+
'@typescript-eslint/interface-name-prefix': 'off',
21+
'@typescript-eslint/explicit-function-return-type': 'off',
22+
'@typescript-eslint/explicit-module-boundary-types': 'off',
23+
'@typescript-eslint/no-explicit-any': 'off',
24+
},
25+
};

.gitignore

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
pnpm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
lerna-debug.log*
13+
14+
# OS
15+
.DS_Store
16+
17+
# Tests
18+
/coverage
19+
/.nyc_output
20+
21+
# IDEs and editors
22+
/.idea
23+
.project
24+
.classpath
25+
.c9/
26+
*.launch
27+
.settings/
28+
*.sublime-workspace
29+
30+
# IDE - VSCode
31+
.vscode/*
32+
!.vscode/settings.json
33+
!.vscode/tasks.json
34+
!.vscode/launch.json
35+
!.vscode/extensions.json

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Hypertek Solutions LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# HyperMath
2+
3+
HyperMath is a simple JavaScript/TypeScript library designed to address common pitfalls in JavaScript math operations. It provides a set of static methods for basic arithmetic operations with improved precision and input handling.
4+
5+
## Installation
6+
7+
```bash
8+
npm install hypermath
9+
```
10+
11+
## Usage
12+
13+
```typescript
14+
import { HyperMath } from 'hypermath';
15+
16+
// Multiplication
17+
console.log(HyperMath.multiply(0.1, 0.2)); // 0.02 (instead of 0.020000000000000004)
18+
19+
// Addition
20+
console.log(HyperMath.add(0.1, 0.2)); // 0.3 (instead of 0.30000000000000004)
21+
22+
// Division
23+
console.log(HyperMath.divide(0.3, 0.1)); // 3 (instead of 2.9999999999999996)
24+
```
25+
26+
## Features
27+
28+
- Handles both number and string inputs
29+
- Attempts to maintain precision up to 2 significant digits
30+
- Provides static methods for multiplication, addition, and division
31+
- Throws an error for invalid string inputs
32+
33+
## API
34+
35+
### `HyperMath.multiply(firstValue: number | string, secondValue: number | string): number`
36+
37+
Multiplies two numbers with improved precision.
38+
39+
### `HyperMath.add(firstValue: number | string, secondValue: number | string): number`
40+
41+
Adds two numbers with improved precision.
42+
43+
### `HyperMath.divide(firstValue: number | string, secondValue: number | string): number`
44+
45+
Divides two numbers with improved precision.
46+
47+
## Notes
48+
49+
- This library uses `toPrecision(2)` internally, which may lead to rounding in some cases. Be aware of this limitation when using the library for calculations requiring high precision.
50+
- Input strings are parsed to numbers. Invalid string inputs will throw an error.
51+
52+
## Contributing
53+
54+
Contributions are welcome! Please feel free to submit a Pull Request.
55+
56+
## License
57+
58+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

nest-cli.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://json.schemastore.org/nest-cli",
3+
"collection": "@nestjs/schematics",
4+
"sourceRoot": "src",
5+
"compilerOptions": {
6+
"deleteOutDir": true
7+
}
8+
}

0 commit comments

Comments
 (0)