
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
@okiba/math
Advanced tools
Collection of math functions
__
npm i --save @okiba/math
Or import it directly in the browser
<script type="module" src="https://unpkg.com/@okiba/math/index.js"></script>
import math from '@okiba/math'
Okiba Core packages are not transpiled, so don't forget to transpile them with your favourite bundler. For example, using Babel with Webpack, you should prevent imports from okiba to be excluded from transpilation, like follows:
{
test: /\.js$/,
exclude: /node_modules\/(?!(@okiba)\/).*/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
Linear interpolation between a two values
import {lerp} from '@okiba/math'
const xPosition = lerp(0, 100, 0.5)
console.log(xPosition) // 50
min: NumberMinimum possible value
max: NumberMaximum possible value
fraction: NumberCurrent position
Number The interpolated value
Maps a value between two ranges
import {map} from '@okiba/math'
const x = map(0.5, 0, 1, 0, 1000)
console.log(x) // 500
const y = map(0, -1, 1, -1000, 1000)
console.log(y) // 0
n: NumberValue to map
min1: NumberSource range minimum
max1: NumberSource range maximum
min2: NumberTarget range minimum
max2: NumberTarget range maximum
Number Mapped value
Limit a value between a min and a max (inclusive)
import {cap} from '@okiba/math'
let progress = 1.1
progress = cap(0, 1, progress)
console.log(progress) // 1
n: NumberValue to cap
min: NumberMinimum possible value
max: NumberMaximum possible value
Number Capped value
Distance between two numbers
import {distance} from '@okiba/math'
const x1 = -100, x2 = 100
const d = distance(x1, x2)
console.log(d) // 200
x1: NumberFirst number
x2: NumberSecond number
Number Distance between the values
Round a number with given precision, with memoized powers
import {round} from '@okiba/math'
const rounded = distance(1.111111, 3)
console.log(rounded) // 1.111
n: NumberNumber to round
p: Number | optional - default: 3Precision of digits to leave
Number Rounded number
FAQs
Math functions used in okiba.js
We found that @okiba/math demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.