smath 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[Home](
|
|
1
|
+
[Home](../) | [Docs](https://npm.nicfv.com/smath/) | [GitHub](https://github.com/nicfv/npm/tree/main/smath/) | [npm](https://www.npmjs.com/package/smath) | [Changelog](https://github.com/nicfv/npm/blob/main/smath//CHANGELOG.md) | [YouTube](https://www.youtube.com/@nciv) | Small math function library
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|

|
|
5
|
-

|
|
6
6
|

|
|
7
7
|

|
|
8
8
|

|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
smath can be installed from the official [npm package repository](https://www.npmjs.com/package/smath). It is highly recommended to install the latest version, which is installed by default with the following command.
|
|
13
13
|
|
|
14
14
|
```shell
|
|
15
|
-
npm i smath@1.3.
|
|
15
|
+
npm i smath@1.3.2
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Bugs and Requests
|
|
@@ -24,14 +24,24 @@ Is there a way we can make smath better? Please report all bugs, issues, and new
|
|
|
24
24
|
Thank you for your interest in contributing to smath! smath is an open source software package maintained by Nicolas Ventura ([@nicfv](https://github.com/nicfv)) and built by users like you! You are allowed to fork the repository as permitted by the [MIT License](https://raw.githubusercontent.com/nicfv/npm/main/LICENSE) terms. Contributions are welcome by submitting a [pull request](https://github.com/nicfv/npm/pulls). Please follow the existing code styling if submitting a pull request. Thank you for your consideration!
|
|
25
25
|
## Getting Started
|
|
26
26
|
|
|
27
|
-
Similar to JavaScript's builtin [`Math`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math) object, `SMath` exports one global object with several math-related helper functions. There is no need to instantiate the class, just call functions directly. See the examples below to get started using SMath!
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Here are a few examples written in JavaScript for a quick start into `SMath`.
|
|
32
|
-
|
|
27
|
+
Small math? Simple math? Or supplemental math? Canonically, "SMath" is pronounced "smath" and stands for "small math (library.)" Similar to JavaScript's builtin [`Math`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math) object, `SMath` exports one global object with several math-related helper functions. There is no need to instantiate the class, just call functions directly. See the examples below to get started using SMath!
|
|
28
|
+
## Examples
|
|
29
|
+
Here are a few quickstart examples written in JavaScript that showcase some out-of-box features of the `smath` package.
|
|
33
30
|
### JavaScript Math Oddities
|
|
34
|
-
|
|
31
|
+
Sometimes, JavaScript does weird math! Try adding `0.1 + 0.2` in your NodeJS terminal. What did you get?
|
|
32
|
+
|
|
33
|
+
> Hint: It's not 0.3!
|
|
34
|
+
|
|
35
|
+
The function `SMath.approx()` is an attempt to mitigate some of the issues that arise when doing arithmetic with non-whole numbers.
|
|
36
|
+
#### Instructions
|
|
37
|
+
1. Copy the source code
|
|
38
|
+
1. Paste into a new file
|
|
39
|
+
1. Save as `JavaScript-Math-Oddities.mjs`
|
|
40
|
+
1. Run this command in your terminal
|
|
41
|
+
```shell
|
|
42
|
+
node JavaScript-Math-Oddities.mjs
|
|
43
|
+
```
|
|
44
|
+
#### Source
|
|
35
45
|
```js
|
|
36
46
|
import { SMath } from 'smath';
|
|
37
47
|
|
|
@@ -39,16 +49,22 @@ import { SMath } from 'smath';
|
|
|
39
49
|
console.log('0.1 + 0.2 == 0.3 is ' + (0.1 + 0.2 == 0.3));
|
|
40
50
|
console.log('SMath.approx(0.1 + 0.2, 0.3) is ' + SMath.approx(0.1 + 0.2, 0.3));
|
|
41
51
|
```
|
|
42
|
-
|
|
52
|
+
#### Output
|
|
43
53
|
```text
|
|
44
54
|
0.1 + 0.2 == 0.3 is false
|
|
45
55
|
SMath.approx(0.1 + 0.2, 0.3) is true
|
|
46
56
|
```
|
|
47
|
-
|
|
48
57
|
### Temperature Conversion
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
This example demonstrates a simple temperature converter from Celsius to Fahrenheit, using `SMath.translate()` to linearly interpolate between unit systems. The translation uses freezing and boiling points to fix the bounds of the linear interpolation.
|
|
59
|
+
#### Instructions
|
|
60
|
+
1. Copy the source code
|
|
61
|
+
1. Paste into a new file
|
|
62
|
+
1. Save as `Temperature-Conversion.mjs`
|
|
63
|
+
1. Run this command in your terminal
|
|
64
|
+
```shell
|
|
65
|
+
node Temperature-Conversion.mjs
|
|
66
|
+
```
|
|
67
|
+
#### Source
|
|
52
68
|
```js
|
|
53
69
|
import { SMath } from 'smath';
|
|
54
70
|
|
|
@@ -80,7 +96,7 @@ for (let i = 0; i < C.length; i++) {
|
|
|
80
96
|
console.log(C[i].toFixed() + 'C is ' + F[i].toFixed() + 'F')
|
|
81
97
|
}
|
|
82
98
|
```
|
|
83
|
-
|
|
99
|
+
#### Output
|
|
84
100
|
```text
|
|
85
101
|
0C is 32F
|
|
86
102
|
5C is 41F
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smath",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Small math function library",
|
|
5
5
|
"homepage": "https://npm.nicfv.com/smath",
|
|
6
|
-
"bin": "dist/
|
|
7
|
-
"main": "dist/
|
|
8
|
-
"types": "types/
|
|
6
|
+
"bin": "dist/bin.js",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist
|
|
11
|
-
"types
|
|
10
|
+
"dist",
|
|
11
|
+
"types"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "rm -rf dist && tsc",
|
|
15
|
-
"test": "
|
|
15
|
+
"test": "tsc --noEmit # tsc --outDir tmp test/index.ts && { node tmp/test/index.js ; rm -r tmp ; }",
|
|
16
16
|
"clean": "rm -rf node_modules package-lock.json dist types docs",
|
|
17
17
|
"docs": "rm -rf docs && typedoc --includeVersion --disableSources --hideGenerator src",
|
|
18
18
|
"prepack": "npm run build",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "20.11.30",
|
|
51
51
|
"typedoc": "0.25.12",
|
|
52
|
-
"typescript": "5.4.3"
|
|
53
|
-
"xpt": "0.2.0"
|
|
52
|
+
"typescript": "5.4.3"
|
|
54
53
|
}
|
|
55
54
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|