npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@algosail/number

v0.1.0

Published

Small collection of FP utilities for working with numbers.

Readme

@algosail/number

Number comparison, ordering, and arithmetic utilities. All comparison functions are curried.

Notable semantics: NaN equals NaN, -0 equals +0, NaN is treated as the minimum in ordering.

Contents


isNum

isNum :: a -> Boolean

Returns true only for numeric values that are not NaN.

isNum(42) // => true
isNum(-Infinity) // => true
isNum(NaN) // => false
isNum('42') // => false
isNum(null) // => false

equals

equals :: Number -> Number -> Boolean

Structural equality: NaN equals NaN, +0 equals -0.

equals(1)(1) // => true
equals(NaN)(NaN) // => true   — unlike ===
equals(0)(-0) // => true
equals(1)(2) // => false

lte / lt / gte / gt

lte :: Number -> Number -> Boolean
lt  :: Number -> Number -> Boolean
gte :: Number -> Number -> Boolean
gt  :: Number -> Number -> Boolean

Total ordering — NaN is treated as the minimum (less than everything).

lte(1)(2) // => true
lte(2)(2) // => true
lt(1)(2) // => true
lt(2)(2) // => false

gte(2)(1) // => true
gt(2)(1) // => true

// NaN semantics
lte(NaN)(NaN) // => true  (NaN ≤ NaN)
lte(NaN)(-999) // => true  (NaN is minimum)
lte(-999)(NaN) // => false

min / max / clamp

min   :: Number -> Number -> Number
max   :: Number -> Number -> Number
clamp :: Number -> Number -> Number -> Number
min(3)(7) // => 3
max(3)(7) // => 7
clamp(0)(10)(5) // => 5
clamp(0)(10)(15) // => 10
clamp(0)(10)(-2) // => 0

negate

negate :: Number -> Number
negate(3) // => -3
negate(-5) // => 5
negate(0) // => 0

add / sub / mult / div / pow

add  :: Number -> Number -> Number   — add(x)(y) = x + y
sub  :: Number -> Number -> Number   — sub(n)(x) = x - n
mult :: Number -> Number -> Number   — mult(x)(y) = x * y
div  :: Number -> Number -> Number   — div(n)(x) = x / n
pow  :: Number -> Number -> Number   — pow(exp)(base) = base ** exp

Note: sub and div take the operand first, so they flip naturally in pipelines.

add(1)(2) // => 3
sub(1)(3) // => 2   (3 - 1)
mult(2)(3) // => 6
div(2)(10) // => 5   (10 / 2)
pow(2)(3) // => 9   (3 ** 2)

// Pipeline example: (x - 1) / 2
pipe([sub(1), div(2)])(9) // => 4

sum / product

sum     :: Array Number -> Number
product :: Array Number -> Number
sum([1, 2, 3, 4]) // => 10
sum([]) // => 0

product([2, 3, 4]) // => 24
product([]) // => 1

even / odd

even :: Integer -> Boolean
odd  :: Integer -> Boolean
even(4) // => true
even(3) // => false
odd(3) // => true
odd(4) // => false
even(0) // => true

parseFloat_

parseFloat_ :: String -> Maybe Number

Parses a float string strictly — rejects strings with garbage characters that native parseFloat would accept.

parseFloat_('3.14') // => just(3.14)
parseFloat_('-1e5') // => just(-100000)
parseFloat_('Infinity') // => just(Infinity)
parseFloat_('3px') // => nothing()   — native parseFloat would return 3
parseFloat_('') // => nothing()
parseFloat_('abc') // => nothing()

parseInt_

parseInt_ :: Integer -> String -> Maybe Integer

Parses an integer string in radix 2–36, stricter than the built-in parseInt.

parseInt_(10)('42') // => just(42)
parseInt_(16)('ff') // => just(255)
parseInt_(2)('1010') // => just(10)
parseInt_(10)('42px') // => nothing()  — native parseInt would return 42
parseInt_(10)('') // => nothing()
parseInt_(1)('1') // => nothing()  — radix must be 2–36