Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@molecule/app-utilities

Latest version: v1.1.0

Overview

Last scanned
29 Nov 2026
Published
29 Nov 2026
npm package Publisher: vialoh
45 Stars
4 Forks
6 Versions
25.7K Downloads
TypeScript Repo language

Scan summary

@molecule/app-utilities was last scanned on 29 Nov 2026 at version 1.1.0. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 6 versions; the latest was published on 29 Nov 2026.
  • Findings: No rules fired in version 1.1.0.
  • Downloads: 25,726 downloads.

Versions

6 versions published
Versions and the rules that fired in each
VersionPublishedStatus
1.1.0 LATEST 29 Nov 2026 No rules fired
1.0.7 16 Nov 2026 No rules fired
1.0.6 26 Oct 2026 No rules fired
1.0.5 24 Oct 2026 Not shown
1.0.4 4 Oct 2026 Not shown

No rules fired in 1.1.0

Findings

Findings for v1.1.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 1.1.0; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@molecule/app-utilities

Common utilities for molecule.dev frontend applications.

Framework-agnostic helpers for async control (debounce/throttle/retry/sleep), strings, dates, Intl-based formatting (currency/number/percent/file size), validation, clipboard, URLs/query strings, URL-safe base64, and user-friendly error messages. Prefer these over hand-rolling the same helpers in app code — they are dependency-free and already tested.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { debounce, formatCurrency, getErrorMessage } from '@molecule/app-utilities'
import { t } from '@molecule/app-i18n'

const onSearch = debounce((q: unknown) => runSearch(q as string), 300)
const price = formatCurrency(1234.56, 'EUR', 'de-DE')

try {
  await saveThing()
} catch (error) {
  // Pass the app's `t` so the message is localized — defaults are English-only.
  showToast(getErrorMessage(error, undefined, t))
}

Type

core

Installation

npm install @molecule/app-utilities

API

Interfaces
PromiseState

State of an async operation.

interface PromiseState<T> {
  /**
   * Current status.
   */
  status: PromiseStatus

  /**
   * Resolved value.
   */
  value: T | null

  /**
   * Rejection error.
   */
  error: Error | null
}
AlphanumericOptions

Alphanumeric validation options.

interface AlphanumericOptions {
  /**
   * Allow spaces.
   */
  allowSpaces?: boolean

  /**
   * Allow dashes.
   */
  allowDashes?: boolean

  /**
   * Allow underscores.
   */
  allowUnderscores?: boolean

  /**
   * Minimum length.
   */
  minLength?: number

  /**
   * Maximum length.
   */
  maxLength?: number
}
WebVttCue

A WebVTT cue with a time interval in seconds.

interface WebVttCue {
  /** Inclusive start time. */
  start: number
  /** Exclusive end time. */
  end: number
  /** The cue text. */
  text: string
}
Types
PromiseStatus

Status of an async operation.

type PromiseStatus = 'idle' | 'pending' | 'resolved' | 'rejected'
Functions
sleep(ms)

Returns a promise that resolves after the specified number of milliseconds.

function sleep(ms: number): Promise<void>
  • ms — The delay duration in milliseconds.

Returns: A promise that resolves after the delay.

debounce(fn, delay)

Wraps a function so that it is only invoked after it stops being called for the specified delay. Useful for search inputs and resize handlers.

function debounce<T extends (...args: unknown[]) => unknown>(
  fn: T,
  delay: number,
): (...args: Parameters<T>) => void
  • fn — The function to debounce.
  • delay — The quiet period in milliseconds before the function fires.

Returns: A debounced version of fn that resets its timer on each call.

throttle(fn, limit)

Wraps a function so that it fires at most once per limit milliseconds. Unlike debounce, the first call executes immediately.

function throttle<T extends (...args: unknown[]) => unknown>(
  fn: T,
  limit: number,
): (...args: Parameters<T>) => void
  • fn — The function to throttle.
  • limit — The minimum interval in milliseconds between invocations.

Returns: A throttled version of fn that drops calls within the limit window.

retry(fn, options)

Retries an async function with exponential backoff. Each failed attempt waits initialDelay * backoffFactor^(attempt-1) ms, capped at maxDelay.

function retry<T>(
  fn: () => Promise<T>,
  options?: {
    maxAttempts?: number
    initialDelay?: number
    maxDelay?: number
    backoffFactor?: number
  },
): Promise<T>
  • fn — The async function to retry.
  • options — Retry configuration.
  • options.maxAttempts — Maximum number of attempts (default: 3).
  • options.initialDelay — Delay in ms before the first retry (default: 1000).
  • options.maxDelay — Maximum delay cap in ms (default: 30000).
  • options.backoffFactor — Multiplier applied to the delay after each attempt (default: 2).

Returns: The resolved value from the first successful attempt.

copyToClipboard(text) (deprecated)

Deprecated: Use copyTextWithFallback() from @molecule/app-clipboard, which copies through the bonded clipboard provider.

Copies text to the system clipboard. Uses the Clipboard API when it is available, and the legacy copy command where it is missing (a plain-HTTP page) or refuses the write (an iframe without the clipboard-write permission, a document without focus).

function copyToClipboard(text: string): Promise<boolean>
  • text — The text to copy to the clipboard.

Returns: true if the copy succeeded, false when no copy was possible.

readFromClipboard() (deprecated)

Deprecated: Use readText() from @molecule/app-clipboard, which reads through the bonded clipboard provider.

Reads text from the system clipboard using the Clipboard API.

function readFromClipboard(): Promise<string | null>

Returns: The clipboard text content, or null if reading is not supported or fails.

timeAgo(time, abbreviate)

Formats the elapsed time since a given timestamp as a human-readable relative string (e.g. "3 hours ago" or "3h ago" when abbreviated).

function timeAgo(time: number | string | Date, abbreviate?: boolean): string
  • time — The timestamp as a Unix ms number, ISO date string, or Date object.
  • abbreviate — When true, uses short suffixes (m, h, d, w, y) instead of full words.

Returns: A relative time string like "just now", "5 minutes ago", or "2d ago".

urlBase64ToUint8Array(base64String)

Converts a URL-safe base64 string to a Uint8Array. Commonly used for decoding VAPID public keys for push notification subscriptions.

function urlBase64ToUint8Array(base64String: string): Uint8Array
  • base64String — The URL-safe base64-encoded string (uses - and _ instead of + and /).

Returns: The decoded byte array.

uint8ArrayToUrlBase64(array)

Converts a Uint8Array to a URL-safe base64 string. The inverse of urlBase64ToUint8Array.

function uint8ArrayToUrlBase64(array: Uint8Array): string
  • array — The byte array to encode.

Returns: The URL-safe base64-encoded string (trailing = padding removed).

getErrorMessage(error, customMessages, t)

Extracts a user-friendly error message from an unknown error value. Handles strings, Error instances, and objects with code/message/error properties. Recognizes TypeError (fetch failures) as network errors and AbortError as timeouts.

When a translation function t is provided, error messages are passed through it for i18n support.

function getErrorMessage(
  error: unknown,
  customMessages?: Record<string, string>,
  t?: TranslateFn,
): string
  • error — The error value (string, Error, or object with code/message).
  • customMessages — Optional map of error codes to custom message strings that override defaults.
  • t — Optional i18n translation function for localizing error messages.

Returns: A user-friendly error message string.

getHumanFileSize(bytes, decimals)

Formats a byte count as a human-readable file size string (e.g. "1.5 MB", "0 B", "-3.2 GB").

function getHumanFileSize(bytes: number, decimals?: number): string
  • bytes — The number of bytes to format (supports negative values).
  • decimals — The number of decimal places (default: 2).

Returns: A formatted file size string with the appropriate unit.

formatNumber(value, locale)

Formats a number with locale-appropriate thousand separators using Intl.NumberFormat.

function formatNumber(value: number, locale?: string): string
  • value — The number to format.
  • locale — The BCP 47 locale string (default: 'en-US').

Returns: The formatted number string (e.g. "1,234,567").

formatCurrency(value, currency, locale)

Formats a number as a currency string using Intl.NumberFormat.

function formatCurrency(value: number, currency?: string, locale?: string): string
  • value — The monetary amount.
  • currency — The ISO 4217 currency code (default: 'USD').
  • locale — The BCP 47 locale string (default: 'en-US').

Returns: The formatted currency string (e.g. "$1,234.56").

formatPercent(value, decimals, locale)

Formats a number as a percentage string using Intl.NumberFormat. The input value should be a decimal (e.g. 0.75 for 75%).

function formatPercent(value: number, decimals?: number, locale?: string): string
  • value — The decimal value to format as a percentage.
  • decimals — The number of decimal places (default: 0).
  • locale — The BCP 47 locale string (default: 'en-US').

Returns: The formatted percentage string (e.g. "75%").

randomString(length, charset)

Generates a random string by picking characters from the given charset. Uses Math.random() — not suitable for cryptographic purposes.

function randomString(length?: number, charset?: string): string
  • length — The desired string length (default: 16).
  • charset — The character set to sample from (default: alphanumeric A-Z, a-z, 0-9).

Returns: A random string of the specified length.

uuid()

Generates a UUID v4 string. Uses crypto.randomUUID() when available, with a Math.random() fallback for environments that lack it.

function uuid(): string

Returns: A UUID v4 string (e.g. "550e8400-e29b-41d4-a716-446655440000").

isAlphanumeric(value, options)

Tests whether a string contains only alphanumeric characters (and optionally spaces, dashes, or underscores). Supports length constraints via minLength and maxLength options.

function isAlphanumeric(value: string, options?: AlphanumericOptions): boolean
  • value — The string to test.
  • options — Optional flags to allow spaces, dashes, underscores, and length constraints.

Returns: true if the string matches the alphanumeric pattern.

alphanumeric(value, options)

Strips non-alphanumeric characters from a string, keeping only letters and digits (plus optionally spaces, dashes, or underscores).

function alphanumeric(value: string, options?: AlphanumericOptions): string
  • value — The string to clean.
  • options — Optional flags to preserve spaces, dashes, or underscores.

Returns: The cleaned string with disallowed characters removed.

truncate(value, maxLength, suffix)

Truncates a string to a maximum length, appending a suffix (default "...") when the string exceeds the limit.

function truncate(value: string, maxLength: number, suffix?: string): string
  • value — The string to truncate.
  • maxLength — The maximum total length including the suffix.
  • suffix — The truncation indicator appended when the string is shortened (default: "...").

Returns: The original string if within limits, or the truncated string with suffix.

toTitleCase(value)

Converts a string to Title Case (capitalizes the first letter of each word).

function toTitleCase(value: string): string
  • value — The string to convert.

Returns: The title-cased string, or an empty string if the input is falsy.

toKebabCase(value)

Converts a camelCase, PascalCase, snake_case, or space-separated string to kebab-case (e.g. "myVariable" becomes "my-variable").

function toKebabCase(value: string): string
  • value — The string to convert.

Returns: The kebab-cased string, or an empty string if the input is falsy.

toCamelCase(value)

Converts a kebab-case, snake_case, or space-separated string to camelCase (e.g. "my-variable" becomes "myVariable").

function toCamelCase(value: string): string
  • value — The string to convert.

Returns: The camelCased string, or an empty string if the input is falsy.

toQueryString(params)

Converts a key-value object into a URL query string. Array values are appended as multiple entries for the same key. null and undefined values are skipped.

function toQueryString(params: Record<string, unknown>): string
  • params — The key-value pairs to serialize.

Returns: The query string including the leading ?, or an empty string if no params.

parseQueryString(queryString)

Parses a URL query string into a key-value object. Keys that appear multiple times are returned as arrays.

function parseQueryString(queryString: string): Record<string, string | string[]>
  • queryString — The query string to parse (with or without leading ?).

Returns: An object where each key maps to a single string or an array of strings.

isInternalUrl(url)

Checks whether a URL points to the same origin as the current page. Relative URLs (not starting with http:// or https://) are considered internal.

function isInternalUrl(url: string): boolean
  • url — The URL to check (absolute or relative).

Returns: true if the URL is same-origin or relative.

openUrl(url, options)

Opens a URL by navigating in the current tab or opening a new window/tab with noopener,noreferrer for security. Only http:, https: and relative targets are allowed — anything else (a model-authored or user-supplied javascript:/data: URL, say) is refused with a console.warn and no navigation.

function openUrl(url: string, options?: { newWindow?: boolean; target?: string }): void
  • url — The URL to open.
  • options — Navigation options.
  • options.newWindow — When true, opens in a new window/tab instead of navigating.
  • options.target — The window target name (default: '_blank' when newWindow is true).
handleAnchorClick(event, navigate)

Intercepts an anchor element click for SPA client-side navigation. Skips interception when modifier keys are held, when target="_blank", or when the link points to an external URL.

function handleAnchorClick(event: MouseEvent, navigate: (url: string) => void): boolean
  • event — The mouse click event from a click listener.
  • navigate — The SPA router's navigation function to call with the href.

Returns: true if the click was intercepted and handled, false if it should proceed normally.

isEmail(value)

Validates an email address against a simplified RFC 5322 pattern.

function isEmail(value: string): boolean
  • value — The string to validate as an email address.

Returns: true if the string matches the email pattern.

isUrl(value)

Validates whether a string is a well-formed URL using the URL constructor.

function isUrl(value: string): boolean
  • value — The string to validate as a URL.

Returns: true if the string can be parsed as a valid URL.

parseWebVtt(file)

Reads timed text from a WebVTT file in playback order.

function parseWebVtt(file: string): WebVttCue[]
  • file — WebVTT file contents.

Returns: Valid cues sorted by start time.

activeWebVttText(cues, time)

Reads the joined text of the cues active at a playback position.

function activeWebVttText(cues: readonly WebVttCue[], time: number): string
  • cues — Parsed WebVTT cues.
  • time — Playback position in seconds.

Returns: Active cue text, or an empty string between cues.

loadWebVtt(url, signal)

Loads a WebVTT track, with optional cancellation when its source changes.

function loadWebVtt(url: string, signal?: AbortSignal): Promise<WebVttCue[]>
  • url — Caption track URL.
  • signal — Cancellation for the request.

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @molecule/app-utilities

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Ethersphere Hijacked With Crypto Stealing Malware (1)
npm

Ethersphere Hijacked With Crypto Stealing Malware Via Github & npm

Vulnerability Insights

OpenSSH Password Authentication Bypass on Alpine Linux (*sshole) – CVE-2026-123158

PolinRider Returns
Research

PolinRider Returns: Hijacked npm Packages Use Ethereum Blockchain to Conceal Malware Infrastructure

Frame 2085668439 (1)
Group 1261154229