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

@jolly-pixel/asset-source

v2.1.0

Published

Physical asset storage

Readme

💡 About

An AssetSource stores bytes under root-relative POSIX paths. Its four common operations read, write, delete and list assets. Both built-in sources normalize path separators and reject paths that escape their root.

flowchart TB
    Caller["Asset backend or other caller"]
    Contract["AssetSource<br/>byte storage contract"]
    FS["FilesystemAssetSource"]
    Memory["MemoryAssetSource"]
    IDB["IndexedDbAssetSource"]

    Caller --> Contract
    Contract --> FS
    Contract --> Memory
    Contract --> IDB

💃 Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @jolly-pixel/asset-source
# or
$ yarn add @jolly-pixel/asset-source

👀 Usage example

import {
  FilesystemAssetSource
} from "@jolly-pixel/asset-source";

const source = new FilesystemAssetSource("./assets");

const bytes = new TextEncoder().encode("grass texture");
await source.write(
  "textures/grass.png",
  bytes
);

📚 API

AssetSource

All persistence sources implement this contract:

interface AssetSource {
  // Rejects when the asset is missing.
  read(path: string): Promise<Uint8Array>;
  // Reports the current state; use writeIfAbsent for concurrent creation.
  exists(path: string): Promise<boolean>;
  write(path: string, data: Uint8Array): Promise<void>;
  // Creates atomically; returns true if created, false if occupied.
  writeIfAbsent(path: string, data: Uint8Array): Promise<boolean>;
  delete(path: string): Promise<void>;
  // Returns sorted paths, excluding .jollypixel/ state files.
  list(): Promise<string[]>;
  // Optional: reports whether a path is hidden from listing and watching.
  isIgnored?(path: string): boolean;
  // Optional: reports changed paths and returns a function to stop watching.
  watch?(onChange: (path: string) => void): () => void;
}

[!IMPORTANT]

Paths are normalized to root-relative POSIX form. Empty, absolute and root-escaping paths are rejected. State files remain available to direct storage operations.

📦 Persistence

[!NOTE]

The filesystem source provides both optional methods. The memory and IndexedDB sources provide neither. The browser-safe core entry exports the contract, memory source and utilities without loading Node.js builtins.

✂️ Utilities

Path, state-directory and JSON helpers

🌍 HTTP serving

createAssetStaticHandler serves any AssetSource over HTTP as connect-style middleware.

✨ Contributors guide

If you are a developer looking to contribute to the project, you must first read the CONTRIBUTING guide.

Run these commands from the monorepo root:

$ pnpm --filter @jolly-pixel/asset-source test
$ pnpm run lint

[!CAUTION] In case you introduce a new feature or fix a bug, make sure to include tests for it as well.

📃 License

MIT