smath 1.8.2 → 1.8.4

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.
Files changed (2) hide show
  1. package/README.md +0 -103
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,27 +1,3 @@
1
- [Home](https://npm.nicfv.com/) | [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
-
3
- ![NPM Downloads](https://img.shields.io/npm/dt/smath)
4
- ![NPM Version](https://img.shields.io/npm/v/smath)
5
- ![Relative date](https://img.shields.io/date/1712869981)
6
- ![GitHub watchers](https://img.shields.io/github/watchers/nicfv/npm)
7
- ![GitHub forks](https://img.shields.io/github/forks/nicfv/npm)
8
- ![GitHub Repo stars](https://img.shields.io/github/stars/nicfv/npm)
9
-
10
- ## Installation
11
-
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
-
14
- ```shell
15
- npm i smath@1.8.2
16
- ```
17
-
18
- ## Bugs and Requests
19
-
20
- Is there a way we can make smath better? Please report all bugs, issues, and new feature requests to the [issues](https://github.com/nicfv/npm/issues) page in the [official repository](https://github.com/nicfv/npm). For critical security issues, please send an email to <smath@nicfv.com>.
21
-
22
- ## Contribute
23
-
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
1
  ## Getting Started
26
2
 
27
3
  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!
@@ -45,82 +21,3 @@ This example command returns the value 0.4.
45
21
  ```shell
46
22
  npx smath normalize 4 0 10
47
23
  ```
48
- ## Examples
49
- Here are a few quickstart examples written in JavaScript that showcase some out-of-box features of the `smath` package.
50
- ### JavaScript Math Oddities
51
- Sometimes, JavaScript does weird math! Try adding `0.1 + 0.2` in your NodeJS terminal. What did you get?
52
-
53
- > Hint: It's not 0.3!
54
-
55
- The function `SMath.approx()` is an attempt to mitigate some of the issues that arise when doing arithmetic with non-whole numbers.
56
- #### Instructions
57
- 1. Copy the source code
58
- 1. Paste into a new file
59
- 1. Save as `JavaScript-Math-Oddities.mjs`
60
- 1. Run this command in your terminal
61
- ```shell
62
- node JavaScript-Math-Oddities.mjs
63
- ```
64
- #### Source
65
- ```js
66
- import { SMath } from 'smath';
67
-
68
- // Determine the value of 0.1 + 0.2 using vanilla JavaScript and SMath
69
- console.log('0.1 + 0.2 == 0.3 is ' + (0.1 + 0.2 == 0.3));
70
- console.log('SMath.approx(0.1 + 0.2, 0.3) is ' + SMath.approx(0.1 + 0.2, 0.3));
71
- ```
72
- #### Output
73
- ```text
74
- 0.1 + 0.2 == 0.3 is false
75
- SMath.approx(0.1 + 0.2, 0.3) is true
76
- ```
77
- ### Temperature Conversion
78
- 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.
79
- #### Instructions
80
- 1. Copy the source code
81
- 1. Paste into a new file
82
- 1. Save as `Temperature-Conversion.mjs`
83
- 1. Run this command in your terminal
84
- ```shell
85
- node Temperature-Conversion.mjs
86
- ```
87
- #### Source
88
- ```js
89
- import { SMath } from 'smath';
90
-
91
- // Water always freezes at the
92
- // same temperature, but the
93
- // units might be different.
94
- // Define some constants to
95
- // create two number ranges.
96
- const C_Freeze = 0,
97
- C_Boil = 100,
98
- F_Freeze = 32,
99
- F_Boil = 212;
100
-
101
- // Use the `SMath` class to
102
- // generate an array of five
103
- // linearly spaced temperature
104
- // values from 0 to 20.
105
- const C = SMath.linspace(0, 20, 5);
106
-
107
- // Use the `SMath` class to linearly
108
- // interpolate the temperature in the
109
- // C number range to a temperature
110
- // in the F number range.
111
- const F = C.map(c => SMath.translate(c, C_Freeze, C_Boil, F_Freeze, F_Boil));
112
-
113
- // Print out each temperature
114
- // in both units of C and F.
115
- for (let i = 0; i < C.length; i++) {
116
- console.log(C[i].toFixed() + 'C is ' + F[i].toFixed() + 'F')
117
- }
118
- ```
119
- #### Output
120
- ```text
121
- 0C is 32F
122
- 5C is 41F
123
- 10C is 50F
124
- 15C is 59F
125
- 20C is 68F
126
- ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smath",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "Small math function library",
5
5
  "homepage": "https://npm.nicfv.com/smath",
6
6
  "bin": "dist/bin.js",
@@ -11,11 +11,11 @@
11
11
  "types"
12
12
  ],
13
13
  "scripts": {
14
- "build": "rm -rf dist types docs && typedoc --options ../typedoc.json src && node dist/test.js && rm dist/test.js types/test.d.ts",
14
+ "build": "npm run postpack && typedoc --options ../typedoc.json src && node dist/test.js && rm dist/test.js types/test.d.ts",
15
15
  "test": "tsc -v && tsc --noEmit",
16
- "clean": "rm -rf node_modules package-lock.json dist types docs",
16
+ "clean": "rm -rf node_modules package-lock.json && npm run postpack",
17
17
  "prepack": "npm run build",
18
- "postpack": "rm -rf dist types"
18
+ "postpack": "rm -rf dist types docs"
19
19
  },
20
20
  "keywords": [
21
21
  "small",
@@ -51,13 +51,13 @@
51
51
  },
52
52
  "funding": {
53
53
  "type": "paypal",
54
- "url": "https://www.paypal.com/donate/?business=UM6EEKPW8GXA2&no_recurring=0&item_name=Open+source+development&currency_code=USD"
54
+ "url": "https://paypal.me/nicfv"
55
55
  },
56
56
  "repository": "github:nicfv/npm",
57
57
  "license": "MIT",
58
58
  "devDependencies": {
59
59
  "@types/node": "20.12.7",
60
- "exray": "1.0.3",
60
+ "exray": "1.1.1",
61
61
  "typedoc": "0.25.13"
62
62
  }
63
63
  }