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

@atom-forge/svelte-helpers

v0.0.2

Published

Svelte helper utilities, types and components

Readme

@atom-forge/svelte-helpers

Svelte helper utilities, types, and components for building type-safe Svelte 5 applications.

Installation

bun add @atom-forge/svelte-helpers

Types

ClassProp

Standard type for components that accept external CSS classes.

let { class: classes }: ClassProp = $props();
const cls = $derived(twMerge('base-styles', classes));

AnyProp

For extra HTML attributes to be spread onto elements (...props). Always place at the end of the intersection.

let { class: classes, ...props }: ClassProp & AnyProp = $props();
// ...
<input {...props} class={cls} />

ChildrenProp / ChildrenPropOptional

Consistent naming for snippet props.

// Required children snippet
let { children }: ChildrenProp = $props();

// Optional children snippet
let { children }: ChildrenPropOptional = $props();

// Parameterized snippet
let { children }: ChildrenProp<[Item]> = $props();

XOR

Enforce mutually exclusive props instead of string unions for better type safety.

// small OR compact, but not both
type Props = XOR<{ small: true }, { compact: true }, {}>;

// 3+ exclusive variants
type ButtonProps = XOR<{ primary: true }, { secondary: true }, { ghost: true }, {}>;

AtLeastOne

Ensures that at least one of the properties in an object is provided.

type LabelOrIcon = AtLeastOne<{ label: string; icon: IconDefinition }>;

Utilities

variantMap

Boolean props are simpler in templates; variantMap returns the string value for internal logic. Works best when combined with XOR or AtLeastOne prop types.

const { small, compact, ...props } = $props();
const size = untrack(() => variantMap({ small, compact }, 'normal'));
// Returns 'small' | 'compact' | 'normal'

debounce / debounceAsync

Standard utilities to limit function execution rate.

const handleInput = debounce((val) => {
    console.log(val);
}, 300);

const search = debounceAsync(async (query) => {
    return await api.fetch(query);
}, 500);

as

TypeCast helper for Svelte templates and snippets. The TypeScript as keyword is not allowed inside Svelte template expressions — use this helper to restore type safety inline.

Primitive shorthands — for inline use in templates:

{@const on = as.boolean(td[k])}
{@const label = as.string(item.value)}
{@render list(as.array<string>(items))}

Available shorthands: as.string, as.number, as.boolean, as.array, as.object, as.function, as.any, as.unknown.

Generic usage — for custom interfaces inline:

const user = as<{ name: string; age: number }>(userData);

Script-side casters — recommended for complex or frequently reused types:

import { as } from '@atom-forge/svelte-helpers';

const toTask = as<{ title: string; done: boolean }>;
const toKey  = as<keyof TableData>;
{@const task = toTask(_task)}
{@const on   = as.boolean(td[toKey(k)])}

Snippet parameter typing — use a script-side caster instead of inline type annotations in snippet params:

<script lang="ts">
  import { as } from '@atom-forge/svelte-helpers';
  const itemArgType = as<{ title: string }>;
</script>

{#snippet item(_task)}
  {@const task = itemArgType(_task)}
  {task.title}
{/snippet}

Components

RenderSnippet

A helper component to safely render snippets dynamically. Especially useful when an API expects a Component — you can pass RenderSnippet wrapping your snippet.

<RenderSnippet {snippet} args={{ item, index }} />