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

@webgogol/core-share

v0.13.0

Published

Core utilities shared across @webgogol packages.

Readme

@webgogol/core-share

Core utilities shared across @webgogol packages.

This package provides a collection of utility functions and types designed to be used across multiple projects within the @webgogol ecosystem. It includes modules for handling Base64 conversions, managing contracts, data manipulation, event handling, file operations, and more.

Installation

pnpm add @webgogol/core-share

Usage

import { uuid, shortenPath, truncateString } from "@webgogol/core-share";

const id = uuid();
const short = shortenPath("c:/very/long/path/to/file.txt");
const preview = truncateString("Some very long text...", 80);

API Reference

Base64 Utilities (base64.ts)

  • arrayBufferToBase64(buffer: ArrayBuffer): string: Converts an ArrayBuffer to a Base64 string.
  • base64ToArrayBuffer(base64: string): ArrayBuffer: Converts a Base64 string to an ArrayBuffer.
  • uint8ArrayToBase64(a: Uint8Array): string: Converts a Uint8Array to a Base64 string.

Contract Utilities (contract.ts)

  • Types: Contract, BriefContract, FlowContract, ProcessorContract, StatusFlowContract, StepStatusProcessorContract, VaultId.
  • brief(contract: Contract): BriefContract: Creates a brief version of a contract.
  • checkContract(contract: Contract): Contract: Validates a contract.
  • emptyContract(): Returns an empty contract object.
  • emptyBriefContract(): Returns an empty brief contract object.
  • emptyVaultId(): Returns an empty vault ID object.

Data Handling (data.ts)

  • Types: ContentType, Data, Format.
  • data(source: string, contentType: ContentType, format: Format = "base64"): Data: Creates a data URL.

Event Handling (event.ts)

  • AppErrorEvent: Custom error event class.
  • emit(event: Event): Dispatches an event.
  • handleEvent(event: Event, handler: HandlerEvent): Handles a specific event.
  • rwl(message: string, level: "log" | "warn" | "error" = "log"): A simple event logger.
  • Type: HandlerEvent.

File Utilities (file.ts)

  • replaceExt(path: string, ext: string): string: Replaces the extension of a file path.
  • replaceName(path: string, name: string): string: Replaces the name of a file in a path.

Fingerprinting (fingerprint.ts)

  • fingerprint(): Promise<string>: Generates a browser fingerprint.

Key Utilities (key.ts)

  • akey(parts: string[]): string: Assembles a key from parts.
  • removeFirstKey(key: string): string: Removes the first segment of a key.
  • removePagination(key: string): string: Removes pagination from a key.
  • rkey(key: string): string[]: Splits a key into its component parts.

Path Utilities (path.ts)

  • shortenPath(path: string, maxLength = 50): string: Shortens a file path to a maximum length.

Object Utilities (object.ts)

  • truncate(value: unknown, maxLength = 100): unknown: Truncates strings in primitives, arrays, and objects to a max length.
  • truncateObject<T extends object>(obj: T, maxLength = 100): T: Safely truncates all string fields within an object.
  • truncateString(text: string, maxLength = 100): string: Truncates a string to a max length with an ellipsis.

Prefix Utilities (prefix.ts)

  • Type: Prefix.
  • getPrefix(text: string): Prefix | undefined: Extracts a prefix from a string.
  • hasAnyPrefix(text: string): boolean: Checks if a string has any known prefix.
  • hasPrefix(text: string, prefix: Prefix): boolean: Checks if a string has a specific prefix.
  • noPrefix(text: string): string: Removes any known prefix from a string.
  • prefix(text: string, prefix: Prefix): string: Adds a prefix to a string.

SQLite Utilities (sqlite.ts)

  • fromSqliteValue(value: any, type: string): any: Converts a value from its SQLite representation.
  • getSqliteType(value: any): string: Determines the SQLite type of a value.
  • toSqliteValue(value: any): any: Converts a value to its SQLite representation.
  • SQLITE_TYPE_MAP: A map of JavaScript types to SQLite types.

General Tools (tool.ts)

  • contractId(id: string): string: Formats a contract ID.
  • objectId(): string: Generates a new object ID.
  • parsedJsonOrSame(json: string): any: Safely parses a JSON string.
  • uuid(): string: Generates a UUID.