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

v0.1.0

Published

Small collection of FP utilities for working with strings.

Readme

@algosail/string

String comparison, concatenation, and utility functions. All functions are curried. Operations on non-string inputs return safe defaults (false, '', []).

Contents


equals

equals :: String -> String -> Boolean

True when both values are strings with identical content.

equals('hello')('hello') // => true
equals('hello')('world') // => false
equals('1')(1) // => false  — type matters

lte / lt / gte / gt

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

Lexicographic comparisons (native JS string ordering).

lte('a')('b') // => true
lte('b')('a') // => false
lte('abc')('abd') // => true

lt('a')('b') // => true
lt('b')('b') // => false

gte('b')('a') // => true
gt('b')('a') // => true

min / max / clamp

min   :: String -> String -> String
max   :: String -> String -> String
clamp :: String -> String -> String -> String
min('apple')('banana') // => 'apple'
max('apple')('banana') // => 'banana'

clamp('b')('d')('a') // => 'b'   (below lo)
clamp('b')('d')('c') // => 'c'   (in range)
clamp('b')('d')('e') // => 'd'   (above hi)

concat

concat :: String -> String -> String

Concatenates two strings. Returns '' if either argument is not a string.

concat('foo')('bar') // => 'foobar'
concat('hello')(' world') // => 'hello world'

empty

empty :: String

The empty string constant.

empty // => ''

toUpper / toLower / trim

toUpper :: String -> String
toLower :: String -> String
trim    :: String -> String
toUpper('hello') // => 'HELLO'
toLower('HELLO') // => 'hello'
trim('  hi  ') // => 'hi'
trim('\n text \t') // => 'text'

stripPrefix

stripPrefix :: String -> String -> Maybe String

Returns Just the remainder after stripping the prefix, or Nothing if the string does not start with the prefix.

stripPrefix('foo')('foobar') // => just('bar')
stripPrefix('foo')('foo') // => just('')
stripPrefix('foo')('bar') // => nothing()
stripPrefix('')('abc') // => just('abc')

stripSuffix

stripSuffix :: String -> String -> Maybe String

Returns Just the string with the suffix removed, or Nothing if it does not end with the suffix.

stripSuffix('bar')('foobar') // => just('foo')
stripSuffix('.js')('index.js') // => just('index')
stripSuffix('.ts')('index.js') // => nothing()

words / unwords

words   :: String -> Array String
unwords :: Array String -> String

Split on whitespace / join with a single space. Leading and trailing whitespace is ignored.

words('  foo bar  baz  ') // => ['foo', 'bar', 'baz']
words('') // => []
words('single') // => ['single']

unwords(['foo', 'bar', 'baz']) // => 'foo bar baz'
unwords([]) // => ''

lines / unlines

lines   :: String -> Array String
unlines :: Array String -> String

Split on \n, \r\n, or \r. unlines appends a terminating \n to each line.

lines('a\nb\nc') // => ['a', 'b', 'c']
lines('a\r\nb') // => ['a', 'b']
lines('') // => []

unlines(['a', 'b', 'c']) // => 'a\nb\nc\n'

splitOn

splitOn :: String -> String -> Array String

Splits a string on a separator substring.

splitOn(',')('a,b,c') // => ['a', 'b', 'c']
splitOn(', ')('a, b, c') // => ['a', 'b', 'c']
splitOn('::')('a::b::c') // => ['a', 'b', 'c']
splitOn(',')('no-separator') // => ['no-separator']

splitOnRegex

splitOnRegex :: RegExp -> String -> Array String

Splits on a regex pattern. The regex must have the g flag.

splitOnRegex(/\s+/g)('  foo  bar  baz  ') // => ['  ', 'foo', '  ', 'bar', '  ', 'baz', '  ']
splitOnRegex(/,\s*/g)('a, b,c , d') // => ['a', 'b', 'c', 'd']

joinWith

joinWith :: String -> Array String -> String

Joins an array of strings with the given separator.

joinWith('-')(['a', 'b', 'c']) // => 'a-b-c'
joinWith(', ')(['foo', 'bar']) // => 'foo, bar'
joinWith('')(['h', 'e', 'l', 'l', 'o']) // => 'hello'