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/strmap

v0.1.0

Published

Small collection of FP utilities for working with plain objects as maps.

Downloads

39

Readme

@algosail/strmap

Plain JS objects used as string-keyed maps (StrMap). Keys are always iterated in sorted order. Value comparisons take an explicit comparator.

Contents


equals

equals :: ((v, v) -> Boolean) -> StrMap v -> StrMap v -> Boolean

Element-wise equality over sorted keys.

equals((a, b) => a === b)({ a: 1, b: 2 })({ b: 2, a: 1 }) // => true  (key order doesn't matter)
equals((a, b) => a === b)({ a: 1 })({ a: 2 }) // => false
equals((a, b) => a === b)({ a: 1 })({ a: 1, b: 2 }) // => false

lte

lte :: ((v, v) -> Boolean) -> StrMap v -> StrMap v -> Boolean

Lexicographic ordering over sorted keys; values are compared on key ties.

lte((a, b) => a <= b)({ a: 1 })({ a: 2 }) // => true
lte((a, b) => a <= b)({ a: 2 })({ a: 1 }) // => false
lte((a, b) => a <= b)({ a: 1 })({ a: 1, b: 1 }) // => true  (prefix)

concat

concat :: StrMap v -> StrMap v -> StrMap v

Right-biased merge — keys in b overwrite keys in a.

concat({ a: 1, b: 2 })({ b: 99, c: 3 }) // => { a: 1, b: 99, c: 3 }
concat({ a: 1 })({}) // => { a: 1 }

empty / zero

empty :: () -> StrMap v
zero  :: () -> StrMap v

Both return a new empty object. zero is the monoid identity.

empty() // => {}
zero() // => {}

size

size :: StrMap v -> Integer

Returns the number of own enumerable keys.

size({ a: 1, b: 2, c: 3 }) // => 3
size({}) // => 0

value

value :: String -> StrMap a -> Maybe a

Returns Just(m[k]) if k is an own enumerable property; Nothing otherwise.

value('a')({ a: 1 }) // => just(1)
value('missing')({ a: 1 }) // => nothing()
value('toString')({ a: 1 }) // => nothing()  — prototype keys excluded

singleton

singleton :: String -> a -> StrMap a

Creates a single-entry map.

singleton('key')(42) // => { key: 42 }
singleton('x')([1, 2]) // => { x: [1, 2] }

filter / reject

filter :: (v -> Boolean) -> StrMap v -> StrMap v
reject :: (v -> Boolean) -> StrMap v -> StrMap v

Keep or remove entries by value predicate.

filter((v) => v > 1)({ a: 1, b: 2, c: 3 }) // => { b: 2, c: 3 }
reject((v) => v > 1)({ a: 1, b: 2, c: 3 }) // => { a: 1 }

map

map :: (a -> b) -> StrMap a -> StrMap b

Applies f to every value.

map((v) => v * 2)({ a: 1, b: 2, c: 3 }) // => { a: 2, b: 4, c: 6 }
map(String)({ x: 1, y: 2 }) // => { x: '1', y: '2' }

ap

ap :: StrMap (a -> b) -> StrMap a -> StrMap b

Applies functions to matching keys; only shared keys appear in the result.

ap({ a: (x) => x + 1, b: (x) => x * 2 })({ a: 10, b: 5, c: 99 })
// => { a: 11, b: 10 }  — 'c' has no function

alt

alt :: StrMap v -> StrMap v -> StrMap v

Left-biased merge — keys from a overwrite keys from b.

alt({ a: 1 })({ a: 99, b: 2 }) // => { a: 1, b: 2 }

all / any / none

all  :: (v -> Boolean) -> StrMap v -> Boolean
any  :: (v -> Boolean) -> StrMap v -> Boolean
none :: (v -> Boolean) -> StrMap v -> Boolean
all((v) => v > 0)({ a: 1, b: 2 }) // => true
all((v) => v > 1)({ a: 1, b: 2 }) // => false

any((v) => v > 1)({ a: 1, b: 2 }) // => true
any((v) => v > 5)({ a: 1, b: 2 }) // => false

none((v) => v > 5)({ a: 1, b: 2 }) // => true
none((v) => v > 1)({ a: 1, b: 2 }) // => false

elem

elem :: ((v, v) -> Boolean) -> v -> StrMap v -> Boolean

True when x is found among the values using the comparator.

elem((a, b) => a === b)(2)({ a: 1, b: 2, c: 3 }) // => true
elem((a, b) => a === b)(9)({ a: 1, b: 2, c: 3 }) // => false

reduce

reduce :: ((b, v) -> b) -> b -> StrMap v -> b

Left fold over values in sorted key order.

reduce((acc, v) => acc + v)(0)({ b: 2, a: 1, c: 3 }) // => 6  (visits a, b, c)
reduce((acc, v) => [...acc, v])([])({ b: 2, a: 1 }) // => [1, 2]  (sorted)

traverse

traverse :: (b -> f b) -> (f (a->b) -> f a -> f b) -> ((a->b) -> f a -> f b) -> (v -> f b) -> StrMap v -> f (StrMap b)

Applicative traversal — passes explicit apOf, apAp, apMap to work with any applicative.

// Traverse with Maybe — short-circuits on Nothing
const safeDouble = (v) => (v < 0 ? nothing() : just(v * 2))

traverse(just)((mf) => (ma) => ap(mf)(ma))((f) => (ma) => map(f)(ma))(
  safeDouble,
)({ a: 1, b: 2 }) // => just({ a: 2, b: 4 })

traverse(just)((mf) => (ma) => ap(mf)(ma))((f) => (ma) => map(f)(ma))(
  safeDouble,
)({ a: 1, b: -1 }) // => nothing()