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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sporttotal/utils

v1.6.6

Published

Saulx utils package, hashes are non cryptographic 32 bit hashes

Downloads

10

Readme

utils

Saulx utils package, hashes are non cryptographic 32 bit hashes

hash

Create a hash for any data type

import { hash } from '@saulx/utils'
console.log(hash({ x: true }))
import { hash } from '@saulx/utils'

// pads extra zeroes
console.log(hash({ x: true }, 15))

hashCompact

Create a hash for any data type, returns a base 62 string

import { hashCompact } from '@saulx/utils'
console.log(hashCompact({ x: true })) // -> CCoj0h

Passing an array and specifying more chars makes a hash that uses all avaible space to make it more unique (becomes more then 32 bits)

import { hashCompact } from '@saulx/utils'
console.log(hashCompact([{ x: true }, 'bla', 'blurp', 'snurf'], 20)) // -> CCoj0hNFgt8MovDmLkmh

hashObject

Create a hash from objects or arrays

import { hashObject } from '@saulx/utils'
console.log(hashObject({ x: true }))

hashObjectIgnoreKeyOrder

Only works for objects, creates the same hash independent from object key order

import { hashObject } from '@saulx/utils'
console.log(
  hashObjectIgnoreKeyOrder({ x: true, y: true }) ===
    hashObjectIgnoreKeyOrder({ y: true, x: true })
)

stringHash

Creates a hash for strings

import { stringHash } from '@saulx/utils'
console.log(stringHash('bla bla bla'))

deepEqual

Compare objects

import { stringHash } from '@saulx/utils'
console.log(deepEqual({ a: { b: true } }, { a: { b: true } })) // true

deepCopy

Create a deepcopy of objects

import { deepCopy } from '@saulx/utils'
console.log(deepCopy({ x: true }))

deepMerge

Merge an object into another object, arrays are treated as new values

import { deepMerge } from '@saulx/utils'

const a = { x: { a: { c: true, x: [1, 2] } } }
const b = { y: true }
const c = { x: { a: { b: true, x: ['bla'] } } }

console.log(deepMerge(a, b))

console.log(deepMerge(a, b, c))

/*
 Logs
 {
   x: { a: { b: true, c: true, x: ['bla']}},
   y: true
 }
*/

deepMergeArrays

Merge an object into another object, arrays are treated as objects

import { deepMergeArrays } from '@saulx/utils'
const a = { x: { a: { c: true, x: [1, 2, 3] } } }
const b = { y: true }
const c = { x: { a: { b: true, x: ['bla'] } } }

console.log(deepMergeArrays(a, b))

console.log(deepMergeArrays(a, b, c))

/*
 Logs
 {
   x: { a: { b: true, c: true, x: ['bla', 2, 3]}},
   y: true
 }
*/

isObject

Checks if a variable is an object and not an array

import { isObject } from '@saulx/utils'
console.log(isObject({ x: true })) // true
console.log(isObject([1, 2, 3])) // false

wait

Timeout in a promise, default is 100ms

import { wait } from '@saulx/utils'

const somethingAsync = async () => {
  await wait() // 100ms
  console.log('after 100ms')
  await wait(1000)
  console.log('after 1100ms')
}

somethingAsync()

readStream

Sink a read stream into a promise

import { readStream } from '@saulx/utils'
import fs from 'fs'

const aReadStream = fs.createReadStream('somefile')
const myResult = await readStream(aReadStream)

toEnvVar

Convert a string to a env variable safe name

import { toEnvVar } from '@saulx/utils'
const x = toEnvVar('@based/bla-bla-bla$_!')
console.log(x) // prints BASED_BLA_BLA_BLA

queued

Pass any async function and queue it based on the arguments, also shares the function execution for the same args

Accepts 5 arguments maximum!

import { queued, wait } from '@saulx/utils'

const myFn = queued(async (a: string) => {
  await wait(1000)
  return a + '!'
})

// will execute bla first then x
await Promise.all([
  myFn('bla'),
  myFn('x')
  myFn('bla') // bla will be shared
])
import { queued, wait } from '@saulx/utils'

const myFn = queued(async (a: string) => {
  await wait(1000)
  return a + '!'
}, {
  dedup: (a) => {
    // choose the value to use for dedup (to share results)
    return a
  },
  concurrency: 10 // max concurrency of 10
})

// will execute all at the same time (scince concurrency is 10)
// will only execute 'bla' once since it has the same arguments used in id
await Promise.all([
  myFn('bla'),
  myFn('x')
  myFn('bla') // bla will be shared
])