New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

smath

Package Overview
Dependencies
Maintainers
0
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smath - npm Package Compare versions

Comparing version 1.8.5 to 1.8.6

4

dist/index.js

@@ -6,5 +6,3 @@ "use strict";

* @packageDocumentation
* Small math function library
*
* Exports the public-facing API for `smath`
* ![NPM Downloads](https://img.shields.io/npm/d18m/smath) Small math function library
*/

@@ -11,0 +9,0 @@ /**

{
"name": "smath",
"version": "1.8.5",
"version": "1.8.6",
"description": "Small math function library",
"homepage": "https://npm.nicfv.com/smath",
"homepage": "https://npm.nicfv.com/",
"bin": "dist/bin.js",

@@ -14,7 +14,6 @@ "main": "dist/index.js",

"scripts": {
"build": "npm run postpack && typedoc --options ../typedoc.json src && node dist/test.js && rm dist/test.js types/test.d.ts",
"test": "tsc -v && tsc --noEmit",
"clean": "rm -rf node_modules package-lock.json && npm run postpack",
"build": "npm run postpack && tsc && node dist/test.js && rm dist/test.js types/test.d.ts",
"test": "tsc --noEmit",
"prepack": "npm run build",
"postpack": "rm -rf dist types docs"
"postpack": "rm -rf dist types"
},

@@ -61,5 +60,4 @@ "keywords": [

"@types/node": "20.12.7",
"exray": "1.1.1",
"typedoc": "0.25.13"
"t6": "1.1.4"
}
}

@@ -1,26 +0,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/@n1cfv) | Small math function library
![NPM Downloads](https://img.shields.io/npm/dt/smath)
![NPM Version](https://img.shields.io/npm/v/smath)
![Relative date](https://img.shields.io/date/1713369829)
![GitHub watchers](https://img.shields.io/github/watchers/nicfv/npm)
![GitHub forks](https://img.shields.io/github/forks/nicfv/npm)
![GitHub Repo stars](https://img.shields.io/github/stars/nicfv/npm)
[![Static Badge](https://img.shields.io/badge/donate-PayPal-blue)](https://paypal.me/nicfv)
## Installation
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.
```shell
npm i smath@1.8.5
```
## Bugs and Requests
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>.
## Contribute
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!
## Getting Started

@@ -49,80 +24,1 @@

```
## Examples
Here are a few quickstart examples written in JavaScript that showcase some out-of-box features of the `smath` package.
### JavaScript Math Oddities
Sometimes, JavaScript does weird math! Try adding `0.1 + 0.2` in your NodeJS terminal. What did you get?
> Hint: It's not 0.3!
The function `SMath.approx()` is an attempt to mitigate some of the issues that arise when doing arithmetic with non-whole numbers.
#### Instructions
1. Copy the source code
1. Paste into a new file
1. Save as `JavaScript-Math-Oddities.mjs`
1. Run this command in your terminal
```shell
node JavaScript-Math-Oddities.mjs
```
#### Source
```js
import { SMath } from 'smath';
// Determine the value of 0.1 + 0.2 using vanilla JavaScript and SMath
console.log('0.1 + 0.2 == 0.3 is ' + (0.1 + 0.2 == 0.3));
console.log('SMath.approx(0.1 + 0.2, 0.3) is ' + SMath.approx(0.1 + 0.2, 0.3));
```
#### Output
```text
0.1 + 0.2 == 0.3 is false
SMath.approx(0.1 + 0.2, 0.3) is true
```
### Temperature Conversion
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.
#### Instructions
1. Copy the source code
1. Paste into a new file
1. Save as `Temperature-Conversion.mjs`
1. Run this command in your terminal
```shell
node Temperature-Conversion.mjs
```
#### Source
```js
import { SMath } from 'smath';
// Water always freezes at the
// same temperature, but the
// units might be different.
// Define some constants to
// create two number ranges.
const C_Freeze = 0,
C_Boil = 100,
F_Freeze = 32,
F_Boil = 212;
// Use the `SMath` class to
// generate an array of five
// linearly spaced temperature
// values from 0 to 20.
const C = SMath.linspace(0, 20, 5);
// Use the `SMath` class to linearly
// interpolate the temperature in the
// C number range to a temperature
// in the F number range.
const F = C.map(c => SMath.translate(c, C_Freeze, C_Boil, F_Freeze, F_Boil));
// Print out each temperature
// in both units of C and F.
for (let i = 0; i < C.length; i++) {
console.log(C[i].toFixed() + 'C is ' + F[i].toFixed() + 'F')
}
```
#### Output
```text
0C is 32F
5C is 41F
10C is 50F
15C is 59F
20C is 68F
```
/**
* @packageDocumentation
* Small math function library
*
* Exports the public-facing API for `smath`
* ![NPM Downloads](https://img.shields.io/npm/d18m/smath) Small math function library
*/

@@ -7,0 +5,0 @@ /**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc