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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@certes/common

v0.1.2

Published

A set of common baseline functions in JavaScript.

Readme

@certes/common

Common utility functions for functional programming patterns in TypeScript.

[!CAUTION]

⚠️ Active Development & Alpha Status

This repository is currently undergoing active development.

Until 1.0.0 release:

  • Stability: APIs are subject to breaking changes without prior notice.
  • Releases: Current releases (tags/npm packages) are strictly for testing and integration feedback.
  • Production: Do not use this software in production environments where data integrity or high availability is required.

Installation

npm install @certes/common

API Reference

lookup

Creates a curried lookup function with optional default handling for missing keys.

Type Signature

// Without default function
function lookup(
  obj: T
): (prop: PropertyKey) => T[keyof T] | undefined;

// With default function
function lookup(
  obj: T,
  def: (value: T[keyof T] | undefined) => R
): (prop: PropertyKey) => T[keyof T] | R;

Parameters

  • obj - The lookup table record
  • def - Optional function to handle missing or undefined values

Returns

A function that accepts a property key and returns the value or default.

Example

import { lookup } from '@certes/common';

const statusCodes = {
  200: 'OK',
  404: 'Not Found',
  500: 'Internal Server Error',
} as const;
type Statuses = typeof statusCodes[keyof typeof statusCodes];

const getStatus = lookup(statusCodes, (x: Statuses | undefined) => x ?? 'Unknown');

getStatus(200); // 'OK'
getStatus(999); // Statuses | 'Unknown'

noop

A no-operation function that accepts any argument and returns undefined.

Type Signature

const noop: (x?: unknown) => void;

Example

import { noop } from '@certes/common';

const handler = isDevelopment ? console.log : noop;
handler('Debug message'); // Only logs in development

once

Ensures a function is only called once, caching and returning the result for all subsequent calls.

Type Signature

function once<T extends (...args: any[]) => any>(fn: T): T;

Parameters

  • fn - The function to call once

Returns

A wrapped function that executes once and caches the result.

Example

import { once } from '@certes/common';

const initializeDatabase = once(async () => {
  console.log('Connecting to database...');
  return await connectDB();
});

await initializeDatabase(); // Logs and connects
await initializeDatabase(); // Returns cached connection
await initializeDatabase(); // Returns cached connection

tap

Executes a function for its side effects and returns the input value unchanged. Useful for debugging and logging in functional pipelines.

Type Signature

function tap(fn: (v: T) => R): (val: T) => T;

Parameters

  • fn - The function to call for side effects

Returns

A function that passes through its input value.

Example

import { tap } from '@certes/common';
import { pipe } from '@certes/composition';

const processData = pipe(
  (x: string) => x.trim(),
  tap(x => console.log('After trim:', x)),
  (x: string) => x.toLowerCase(),
  tap(x => console.log('After lowercase:', x)),
  (x: string) => x.split(' ')
);

processData('  HELLO WORLD  ');
// Logs:
// After trim: HELLO WORLD
// After lowercase: hello world
// Returns: ['hello', 'world']

License

MIT

Contributing

Part of the @certes monorepo. See main repository for contribution guidelines.