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

@simpill/adapters.utils

v1.0.0

Published

Adapter helpers, logger and cache adapter interfaces (Node and Edge).

Readme

Features: Type-safe · Node & Edge · Lightweight


Installation

From npm

npm install @simpill/adapters.utils

From GitHub

To use this package from the monorepo source:

git clone https://github.com/SkinnnyJay/simpill.git
cd simpill/utils/@simpill-adapters.utils
npm install && npm run build

In your project you can then install from the local path: npm install /path/to/simpill/utils/@simpill-adapters.utils or use npm link from the package directory.


Quick Start

import {
  createAdapter,
  memoryCacheAdapter,
  consoleLoggerAdapter,
} from "@simpill/adapters.utils";

const cache = memoryCacheAdapter<string, number>();
cache.set("x", 1);
const logger = consoleLoggerAdapter(console);
logger.info("Hello");
const wrapped = createAdapter(myImpl);

Features

| Feature | Description | |---------|-------------| | CacheAdapter | get, set, delete, has — sync or async; no getMany/deleteMany; memoryCacheAdapter has no TTL/eviction | | LoggerAdapter | debug, info, warn, error — minimal; use with logger.utils setLoggerAdapter | | memoryCacheAdapter | Sync Map-based cache; for TTL/LRU use cache.utils | | consoleLoggerAdapter | Wraps console-like (log/info/warn/error) into LoggerAdapter | | createAdapter | Identity: use to type a superset implementation as interface T (e.g. for DI) |


API Reference

  • CacheAdapter<K, V> — get, set, delete, has. Methods may be sync or async (return type is union); consumers should await when using an async implementation. No getMany/deleteMany; implement batch ops on top of get/set/delete if needed.
  • LoggerAdapter — debug, info, warn, error (message + ...args). Minimal interface; for structured log types use your logger (e.g. @simpill/logger.utils) and wrap with an adapter that implements this shape.
  • memoryCacheAdapter<K, V>() → CacheAdapter<K, V> — sync, Map-based; no TTL or eviction. For TTL/LRU use @simpill/cache.utils and wrap with an adapter if needed.
  • consoleLoggerAdapter(consoleLike) → LoggerAdapter — uses log for debug/info when debug/info are missing.
  • createAdapter<T>(impl: T) → T — identity: returns impl unchanged. Use when your implementation has a superset of interface T and you want a typed view (e.g. for DI or testing) so callers only see T.

createAdapter value

Use createAdapter when you have a concrete implementation that does more than the interface (e.g. a Redis client with get/set/del plus connect/disconnect). Passing it through createAdapter<CacheAdapter>(redisImpl) gives you a value typed as CacheAdapter so dependents don’t depend on the concrete type. No runtime behavior change.

Sync vs async

CacheAdapter allows each method to be sync or async (return type is V | undefined | Promise<V | undefined>, etc.). memoryCacheAdapter is sync. If you implement an async cache (e.g. Redis), return Promises and document that callers must await.

Error handling

Adapters do not catch or transform errors. If get/set/delete or logger methods throw, the caller sees the error. Implementations (e.g. Redis) should document failure behavior; wrap in try/catch or use Result at the call site if you need consistent error handling.

logger.utils usage

Use LoggerAdapter as the contract for @simpill/logger.utils: pass consoleLoggerAdapter(console) or a custom object implementing debug/info/warn/error. The logger factory can then use setLoggerAdapter(myAdapter). No built-in pino/winston adapters; implement an object that forwards to pino/winston with the same four methods.

What we don’t provide

  • Pino / Winston adapters — No pre-built adapters for pino or winston. Implement an object with debug, info, warn, error that forwards to your logger (e.g. pino.info(msg) or winston.info(msg)).
  • Structured log typesLoggerAdapter is message + ...args only. For structured fields (ECS, log levels, correlation IDs), use @simpill/logger.utils and pass an adapter that implements this interface; the logger layer handles structure.

Examples

npx ts-node examples/01-basic-usage.ts

| Example | Description | |---------|-------------| | 01-basic-usage.ts | createAdapter, memoryCacheAdapter, consoleLoggerAdapter |


Development

npm install
npm test
npm run build
npm run verify

Documentation


License

ISC