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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@small-web/kitten

v3.1.1

Published

Type-safe Kitten namespace.

Downloads

75

Readme

Type-safe Kitten globals

Kitten has a global kitten namespace that make it easy to get started with building Small Web sites and apps with it.

If you’re building something quick, that might be all you need.

However, if you use JSDoc to implement type checking for your larger projects and include @ts-check in your files, the untyped global kitten object will be a source of false negatives for the type checker and litter your code with type errors. (And you won’t be able to take advantage of code hints while authoring.)

That’s what this simple package is for.

Simply install the module and import the default export and it will behave exactly like the default global kitten namespace but with type safety.

Install

npm install @small-web/kitten

Use

For example, in a Kitten page:

index.page.js

@ts-check

import kitten from '@small-web/kitten'

export default () => {
  return {
    markup: kitten.html`
      <!-- The Alpine.js example from https://alpinejs.dev/ -->
      <div x-data='{ open: false }'>
          <button @click='open = true'>Expand</button>
 
          <span x-show='open'>
              Content…
          </span>
      </div>
    `,
    libraries: [kitten.libraries.alpineJs]
  }

You can also pick and choose which elements you import instead of using the default export.

The following example is equivalent to the one above:

@ts-check

import { html, libraries } from '@small-web/kitten'

export default () => {
  return {
    markup: html`
      <!-- The Alpine.js example from https://alpinejs.dev/ -->
      <div x-data='{ open: false }'>
          <button @click='open = true'>Expand</button>
 
          <span x-show='open'>
              Content…
          </span>
      </div>
    `,
    libraries: [libraries.alpineJs]
  }

Database type safety

Kitten by default has at least two databases per project:

An internal database called _db and a custom one for you to use in your project called db.

This package provides a type-safe _db export for the internal database as the structure is well known. It also provides exports of the global Session and Upload classes and, due to an unfortunate limitation of JSDoc, instances of these classes in the internal database have the types SessionInstance and UploadInstance.

If you want type safety for your custom project database, please create and use a type-safe database app module.

Like this? Fund us!

Small Technology Foundation is a tiny, independent not-for-profit.

We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.

License

Copyright © 2023-present Aral Balkan, Small Technology Foundation Released under AGPL 3.0.