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

@bigmistqke/solid-whenever

v0.1.1

Published

reactive utilities to ease working with nullable signals

Readme

solid-whenever

pnpm

Working with nullable values in solid can cause awkward patterns with intermediary variables:

// Without solid-whenever
const [user, setUser] = createSignal(null)
const [settings, setSettings] = createSignal(null)

createEffect(() => {
  const _user = user()
  const _settings = settings()
  if (_user && _settings) {
    console.log(_user.name, _settings.theme)
  }
})

With solid-whenever, you can keep your variable names and have cleaner code:

// With solid-whenever
createEffect(
  when(every(user, settings), ([user, settings]) => {
    // Same names, no confusion!
    console.log(user.name, settings.theme)
  }),
)

API

The library provides 3 core utilities:

  • check - Conditionally execute code when a value is truthy
  • when - A callback wrapper around check
  • every - Compose multiple conditions together

Plus convenience wrappers around Solid's reactive primitives:

  • whenEffect
  • whenRenderEffect
  • whenComputed
  • whenMemo

check

Immediately checks if a value is truthy and executes a callback with that value. Returns the callback result or undefined/fallback.

import { check } from 'solid-whenever'

// Basic usage
const result = check(user(), u => u.name) // returns name if user exists

// With fallback
const name = check(
  user(),
  u => u.name,
  () => 'Anonymous',
)

when

Returns a function that conditionally executes based on truthiness, for composition with solid's reactive primitives.

import { when, createSignal, createMemo } from 'solid-js'

const [user, setUser] = createSignal(null)

// In reactive computations
const greeting = createMemo(when(user, u => `Welcome, ${u.name}!`))

// With accessors
const userName = createMemo(
  when(
    () => user()?.profile,
    profile => profile.displayName,
  ),
)

// With fallback
const status = createMemo(
  when(
    user,
    u => u.status,
    () => 'offline',
  ),
)

every

Returns a function that checks if all provided values are truthy and returns them as a tuple. Designed to be composed with when.

import { when, every } from 'solid-whenever'
import { createSignal, createMemo } from 'solid-js'

const [user] = createSignal(null)
const [settings] = createSignal(null)
const [permissions] = createSignal(null)

// Compose with when
const displayName = createMemo(
  when(every(user, settings), ([user, settings]) =>
    settings.useNickname ? user.nickname : user.name
  )
)

// Multiple conditions
createEffect(
  when(every(user, settings, permissions), ([user, settings, permissions]) => {
    console.log(`${user.name} has ${permissions.role} role with ${settings.theme} theme`)
  })
)

### Solid wrappers

#### `whenEffect`

Creates an effect that runs when the value is truthy. Useful for side effects.

```tsx
import { whenEffect } from 'solid-whenever'

const [user, setUser] = createSignal(null)

// Runs effect only when user exists
whenEffect(user, u => {
  console.log(`User ${u.name} logged in`)
  // Setup user-specific listeners, etc.
})

whenRenderEffect

Like whenEffect but uses createRenderEffect internally. Useful for DOM manipulations.

import { whenRenderEffect } from 'solid-whenever'

whenRenderEffect(videoElement, element => {
  element.play()
})

whenComputed

Creates a computed that runs when the value is truthy. Useful for dependent computations.

import { whenComputed } from 'solid-whenever'

const [count, setCount] = createSignal(0)

// Only computes when count > 0
whenComputed(
  () => count() > 0,
  value => {
    console.log(`Positive count: ${value}`)
  },
)

whenMemo

Creates a memoized value that updates only when the condition is truthy.

import { whenMemo } from 'solid-whenever'

const [user] = createSignal(null)

// Memoizes expensive computation only when user exists
const userStats = whenMemo(user, user => {
  return expensiveStatsCalculation(user)
})