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

@vistta/utils

v1.2.0

Published

Vistta Utils Package Bundle

Readme

VISTTA Utils

Utility library/package bundle

Getting Started

Install

npm install @vistta/utils

Usage

import { sleep, clone } from "@vistta/utils";

await sleep(5000);

const obj = { key: "value" };
const newObj = clone(obj);

console.log(capitalize("hello world!"));

API

fs

The filesystem facade forwards the default and named exports from @vistta/fs:

import fs, { readFile } from "@vistta/utils/fs";
// Alternatively: import { fs } from "@vistta/utils";

await fs.writeFile("hello.txt", "Hello");
console.log(await readFile("hello.txt", "utf8"));

Node uses the native filesystem; browser-aware bundlers select the OPFS implementation automatically. Browser-only restrictions and unsupported-operation errors are unchanged. See the filesystem documentation for the supported API. Filesystem functions are not individually exported from the utils root, avoiding collisions with other utilities. @vistta/fs remains independently usable.

database

@vistta/utils/database exposes the same asynchronous Database API in Node (built-in node:sqlite, Node 22.13+ or newer) and browser-aware bundlers (IndexedDB). It exports both Database and a default export. @vistta/utils/node/database and the Database export of @vistta/utils/node also use this asynchronous API, replacing the previous synchronous SQLite API. The separate @vistta/utils/browser/indexedDB key/value utility is unchanged.

import Database from "@vistta/utils/database";

const users = new Database("app.db", "users", {
  name: "TEXT",
  age: "INTEGER",
  active: "BOOLEAN",
  settings: "OBJECT",
  created: "DATE",
});

try {
  const id = await users.insert({
    name: "Alice",
    age: 25,
    active: true,
    settings: { theme: "dark" },
    created: new Date(),
  });
  await users.update({ id, age: 26 });
  const rows = await users
    .select(["id", "name"])
    .where({ active: true })
    .where("age", ">=", 18)
    .orderBy("age", "desc")
    .limit(10)
    .all();
  console.log(rows);
} finally {
  await users.close();
}

The constructor takes (fileOrDatabaseName, tableName, fields). Node uses a SQLite file (:memory: is supported); browsers use origin-scoped IndexedDB storage named @vistta/utils/database: followed by the supplied name, not an OS file. Browser data is subject to quotas and eviction and is not synchronized with Node data. Multiple tables can share one database. Table names are case-insensitive identifiers; field names are case-sensitive identifiers, must not differ only by case, and must not be id. The __vistta_ table prefix is reserved. Connections open lazily on the first operation.

Supported schema types:

  • TEXT: strings.
  • INTEGER: safe integer numbers.
  • REAL: finite numbers.
  • BOOLEAN: booleans.
  • DATE: valid Date objects, restored as dates.
  • OBJECT: JSON-compatible objects/arrays, restored as independent values. Cycles, undefined values, functions, symbols and non-JSON values are rejected.
  • BLOB: Uint8Array, restored as independent byte arrays.
  • NULL: only null.

Every field accepts null; omitted insert fields become null. Explicit undefined is rejected. Schemas are persisted and checked when reopening; incompatible schemas throw instead of silently changing tables. Automatic schema migrations and adopting tables created by the legacy SQLite API are not supported.

Methods and return values:

  • await insert(fields): generates and returns an ID starting at 1.
  • await update({ id, ...fields }): patches an existing record and returns its ID; missing records throw. Unspecified fields are preserved.
  • await upsert({ id, ...fields }): atomically patches an existing record or inserts a missing one with that ID. Without id, it behaves like insert.
  • await delete(id): returns true when a record was removed, otherwise false.
  • select(fields = "*"): creates a synchronous query builder.
  • await close(): closes this connection; repeated calls are safe, and later operations reject. Other connections are unaffected.

IDs are non-negative safe integers, including explicit ID 0. Generated IDs are not reused after deletion. Explicit high IDs advance the sequence. Inserts and upserts are atomic; IndexedDB writes resolve only after transaction commit. Inserting Number.MAX_SAFE_INTEGER rejects because advancing the ID sequence would overflow; the failed write is rolled back.

Query methods:

  • where({ field: value, ... }) adds equality filters.
  • where(field, operator, value) supports =, !=, <, <=, >, >=. Repeated filters are combined with AND. Values are validated against the schema; raw SQL expressions are not accepted.
  • orderBy(field, direction = "asc") supports asc or desc; repeated calls add secondary sort keys. Ties and queries without ordering use ascending IDs.
  • limit(count) sets one non-negative limit, including zero.
  • await all() returns projected records; await get() returns the first matching record or undefined.

Only = and != can compare to null; ordered comparisons exclude null records. Null sorts first ascending and last descending. Text uses JavaScript code-unit ordering, dates compare chronologically, and OBJECT/BLOB fields cannot be filtered or sorted. The shared query layer scans the table and filters/sorts in memory to keep behavior identical across backends; SQL expressions, indexes, joins and cross-table transactions are not exposed.

Invalid query/schema arguments throw synchronously. Execution, validation and storage failures reject promises; no fallback records are returned. Native storage errors propagate. Calls using the previous Node database API must await execution methods and replace raw SQL filters with structured filters.

From the workspace root, run the shared contract tests against both backends:

node packages\cli\bin.js test "packages/utils/tests/database.test.js" --environment=node
node packages\cli\bin.js test "packages/utils/tests/database.browser.test.js" --environment=browser

array

/**
 * Ensure that the given value is an array. If it is not an array, it will be wrapped in an array.
 *
 * @param {any} value - The value to ensure is an array.
 * @returns {Array} - The value as an array.
 */
function ensureArray(value);

/**
 * Add the given value to the array if it is not already present.
 *
 * @param {Array} array - The array to add the value to.
 * @param {any} value - The value to add to the array.
 */
function addUnique(array, value);

/**
 * Insert anything into the array sorted.
 * @param {Array} array - The array to insert into.
 * @param {any} value - The value to insert.
 * @param {Function} [compare] - The comparison function to use. It should return a negative number if a is less than b, a positive number if a is greater than b, and 0 if they are equal.
 * @returns {number} - The index at which the value was inserted.
 */
function insertSorted(array, value, compare);

color

/**
 * Convert color from one format to another.
 * @param {string} color Input color string
 * @param {"hex" | "rgb" | "rgba" | "hsl" | "hsla"} format Output format: "hex", "rgb", "rgba", "hsl", "hsla"
 * @returns {string} Converted color string
 */
function convertColor(color, format);

/**
 * Mix two colors by a given ratio.
 * @param {string} aStr First color string
 * @param {string} bStr Second color string
 * @param {"hex" | "rgb" | "rgba" | "hsl" | "hsla"} [format="hex"] Output format: "hex", "rgb", "rgba", "hsl", "hsla"
 * @param {number|string} [t=0.5] Mix ratio (0 to 1 or percentage string)
 * @returns {string} Mixed color string
 */
function mixColors(aStr, bStr, format = "hex", t = 0.5);

/**
 * Get a contrasting color (black or white) for the given color.
 * @param {string} color Input color string
 * @param {"hex" | "rgb" | "rgba" | "hsl" | "hsla"} [format="hex"] Output format: "hex", "rgb", "rgba", "hsl", "hsla"
 * @returns {string} Contrasting color string
 */
function contrastColor(color, format = "hex");

datetime

/**
 * Creates a new date and time object with default date format.
 *
 * @param {Date|number|string|DateTime} [value] - The date and time value.
 * @param {Intl.DateTimeFormatOptions} [options] - The options for the date and time.
 * @returns {DateTime} A new date and time object.
 */
function date(value, options);

/**
 * Creates a new date and time object with default time format.
 *
 * @param {Date|number|string|DateTime} [value] - The date and time value.
 * @param {Intl.DateTimeFormatOptions} [options] - The options for the date and time.
 * @returns {DateTime} A new date and time object.
 */
function time(value, options);

/**
 * A class representing a date and time.
 */
class DateTime {
  /**
   * Returns the earlier of two date and time objects.
   *
   * @param {DateTime} a The first date and time object.
   * @param {DateTime} b The second date and time object.
   * @returns {DateTime | null} The date and time with the earliest time value.
   */
  static min(a, b);

  /**
   * Returns the later of two date and time objects.
   *
   * @param {DateTime} a The first date and time object.
   * @param {DateTime} b The second date and time object.
   * @returns {DateTime | null} The date and time with the latest time value.
   */
  static max(a, b);

  /**
   * Checks if two date and time objects are equal.
   *
   * @param {DateTime} a The first date and time object.
   * @param {DateTime} b The second date and time object.
   * @returns {boolean} Whether both date and time objects are equal.
   */
  static equals(a, b);

  /**
   * Gets the current time in in milliseconds since the Unix epoch.
   *
   * @returns {number} The time in in milliseconds since the Unix epoch.
   */
  static now();

  /**
   * Creates a new DateTime instance.
   *
   * @param {Date|number|string|DateTime} [value] - The date and time value.
   * @param {Intl.DateTimeFormatOptions} [options] - The options for the date and time.
   */
  constructor(value, options);

  /**
   * @returns {number} The year of the date and time.
   */
  get year();

  /**
   * @param {number} value - The new year of the date and time.
   */
  set year(value);

  /**
   * @returns {number} The month of the date and time.
   */
  get month();

  /**
   * @param {number} value - The new month of the date and time.
   */
  set month(value);

  /**
   * @returns {number} The day of the month of the date and time.
   */
  get day();

  /**
   * @param {number} value - The new day of the month of the date and time.
   */
  set day(value);

  /**
   * @returns {number} The hour of the date and time.
   */
  get hours();

  /**
   * @param {number} value - The new hour of the date and time.
   */
  set hours(value);

  /**
   * @returns {number} The minute of the date and time.
   */
  get minutes();

  /**
   * @param {number} value - The new minute of the date and time.
   */
  set minutes(value);

  /**
   * @returns {Date} A Date object representing the current date and time.
   */
  get date();

  /**
   * @returns {Intl.DateTimeFormatOptions} The date and time format options.
   */
  get options();

  /**
   * @returns {number} The time in in milliseconds since the Unix epoch.
   */
  get time();

  /**
   * Gets the ISO 8601 formatted date and time.
   *
   * @returns {string} The ISO 8601 formatted date and time.
   */
  toISOString();

  /**
   * Formats the date according to the default or the specified locales.
   *
   * @param {string} [locales] - The locale to use for formatting.
   * @returns {string} The formatted date and time.
   */
  toString(locales);

  /**
   * Formats the date according to the default or the specified options.
   *
   * @param {LocaleOptions & Intl.DateTimeFormatOptions} [options] - The Intl.DateTimeFormat options object.
   * @returns {string} The formatted date and time.
   */
  format(options);

  /**
   * Checks whether the date and time is equal to the target date and time.
   *
   * @param {DateTime} target - Comparison target.
   * @returns {boolean} Whether the date and time is equal to the target date and time.
   */
  equals(target);

  /**
   * Creates a deep copy of the current DateTime object.
   *
   * @returns {DateTime} A new date and time object that is a clone of the current object.
   */
  clone();

  /**
   * Calculates the difference between two date and times (e.g., years, months, days, hours, minutes, seconds).
   *
   * @param {DateTime} target - The target date and time.
   * @param {string} output - The output format.
   * @param {boolean} [float] - Whether to use floating-point numbers.
   * @returns {number | null} The difference between the two date and times.
   */
  diff(target, output, float);

  /**
   * Gets the relative time from the reference date (e.g., "just now", "in an hour", etc.).
   *
   * @param {RelativeOptions & Intl.RelativeTimeFormatOptions} options - The options for relative time calculations.
   * @returns {string} The relative time from the reference date.
   */
  relative(options);

  /**
   * Adds the specified value in the specified unit to the date and time (e.g., year, month, day, hour, minute, second).
   * @param {"year"|"month"|"week"|"day"|"hour"|"minute"|"second"|"millisecond"} unit The unit to add the value in.
   * @param {number} value The value to add.
   * @returns {DateTime} The updated date and time object.
   */
  add(unit, value = 1);

  /**
   * Subtracts the specified value in the specified unit from the date and time (e.g., year, month, day, hour, minute, second).
   * @param {number} value The value to subtract.
   * @param {"year"|"month"|"week"|"day"|"hour"|"minute"|"second"|"millisecond"} unit The unit to subtract the value in.
   * @returns {DateTime} The updated date and time object.
   */
  subtract(unit, value = 1);

  /**
   * Sets the date and time to the start of the specified unit (e.g., year, month, day, hour, minute, second).
   * @param {"year"|"month"|"week"|"day"|"hour"|"minute"|"second"} unit The unit to set the date and time to the start of.
   * @returns {DateTime} The updated date and time object.
   */
  startOf(unit);

  /**
   * Sets the date and time to the end of the specified unit (e.g., year, month, day, hour, minute, second).
   * @param {"year"|"month"|"week"|"day"|"hour"|"minute"|"second"} unit The unit to set the date and time to the end of.
   * @returns {DateTime} The updated date and time object.
   */
  endOf(unit);

  /**
   * Moves the date and time forward by the specified step in the specified unit (e.g., year, month, day, hour, minute, second).
   * @param {"year"|"month"|"week"|"day"|"hour"|"minute"|"second"} unit The unit to move the date and time by.
   * @param {number} step The number of units to move the date and time by (positive or negative).
   * @returns {DateTime} The updated date and time object.
   */
  next(unit, step = 1);

  /**
   * Moves the date and time backward by the specified step in the specified unit (e.g., year, month, day, hour, minute, second).
   * @param {"year"|"month"|"week"|"day"|"hour"|"minute"|"second"} unit The unit to move the date and time by.
   * @param {number} step The number of units to move the date and time by (positive or negative).
   * @returns {DateTime} The updated date and time object.
   */
  previous(unit, step = 1);
}

generic

/**
 * Checks if two values are equal.
 *
 * @param {any} arg1 - The first value.
 * @param {any} arg2 - The second value.
 * @returns {boolean} Whether the two values are equal.
 */
function equals(arg1, arg2);

/**
 * Sets an immediate timeout.
 *
 * @param {() => any} callback - The callback function to execute.
 * @returns {Promise<any>} A promise that resolves when the callback is executed.
 */
function setImmediate(callback);

/**
 * Delays execution for a specified amount of milliseconds.
 *
 * @param {number} milliseconds - The number of milliseconds to delay execution.
 * @returns {Promise} A promise that resolves after the specified time.
 */
function sleep(milliseconds);

/**
 * Creates a debounced version of a function.
 *
 * @param {function} callback - The function to debounce.
 * @param {number} [delay] - The delay in milliseconds, default 200ms.
 * @returns {function} A debounced version of the function.
 */
function debounce(callback, delay);

/**
 * Creates a throttled version of a function.
 *
 * @param {function} callback - The function to throttle.
 * @param {number} [limit] - The time limit in milliseconds, default 200ms.
 * @returns {function} A throttled version of the function.
 */
function throttle(callback, limit);

/**
 * Formats a byte count into a human-readable string using the smallest
 * appropriate unit (B, KB, MB, GB, TB, PB).
 *
 * @param {number} bytes - The number of bytes.
 * @param {number} [decimals] - The number of decimal places, default 2.
 * @returns {string} The formatted size string.
 */
function formatSize(bytes, decimals);

/**
 * Schedules a callback to run at a fixed interval aligned to the wall clock.
 *
 * Unlike `setInterval`, which drifts over time and can cause gaps between
 * consecutive windows, this function computes the delay until the next
 * boundary and re-arms a fresh `setTimeout` after every invocation.
 * This guarantees the callback always fires as close as possible to the
 * boundary, preventing missed ticks. In Node.js, the timer does not keep the
 * process alive by itself.
 *
 * @param {() => any} callback - The callback function to execute.
 * @param {string|number} [unit] - The interval unit. Accepts a unit name
 *   ("second", "minute", "hour", "day") optionally prefixed with a count
 *   (e.g. "2 minutes", "1 day", "3 seconds"). Defaults to "minute".
 * @returns {() => void} A cancel function that stops further invocations.
 */
function runEvery(callback, unit);

/**
 * A base class that automatically binds all methods to the instance.
 *
 * This class iterates over all the methods of the instance and binds them
 * to the instance itself, ensuring that the `this` context is always correct
 * when the methods are called.
 */
class BoundClass {
  /**
   * Creates an instance of BoundClass.
   *
   * The constructor retrieves all the method names from the prototype of the instance,
   * and binds each method to the instance, except for the constructor.
   */
  constructor();
}

object

/**
 * Checks if a value is an object.
 *
 * @param {any} object - The value to check.
 * @returns {boolean} Whether the value is an object.
 */
function isObject(object);

/**
 * Checks if an object is empty.
 *
 * @param {Object} object - The object to check.
 * @returns {boolean} Whether the object is empty.
 */
function isObjectEmpty(object);

/**
 * Stringifies an object.
 *
 * @param {Object} object - The object to stringify.
 * @param {boolean} [formatted] - Whether to format the output.
 * @returns {string} The stringified object.
 */
function stringify(object, formatted = false);

/**
 * Parses a stringified object.
 *
 * @param {string} object - The stringified object.
 * @param {boolean} [secure] - Whether to use secure parsing.
 * @returns {Object} The parsed object.
 */
function parse(object, secure = false);

/**
 * Clones an object.
 *
 * @param {Object} object - The object to clone.
 * @param {boolean} [json] - Whether to use JSON parsing.
 * @returns {Object} The cloned object.
 */
function clone(object, json);

/**
 * Copies the property descriptor of one object to another.
 *
 * @param {Object} object - The object to copy property to.
 * @param {Object} target - The object to copy property from.
 * @param {string} propertyName - The property name.
 * @returns {Object} The object with the copied property.
 */
function copyPropertyDescriptor(object, target, propertyName);

/**
 * Flattens an object.
 *
 * @param {Object} object - The object to flatten.
 * @param {string} [separator] - The separator to use for nested keys.
 * @param {function} [transformer] - A function to transform keys.
 * @returns {Object} The flattened object.
 */
function flatten(object, separator, transformer);

/**
 * Recursively assigns properties of object `b` to object `a`.
 *
 * @param {Object} a - The target object to which properties will be assigned.
 * @param {Object} b - The source object from which properties will be assigned.
 * @returns {Object} - The modified target object `a`.
 */
function assign(a, b);

/**
 * Extracts the specified keys from the given object and deletes them from the object.
 *
 * @param {Object} object - The object from which to extract and delete keys.
 * @param {...string} keys - The keys to extract and delete from the object.
 * @returns {Array} - An array containing the values of the extracted keys.
 */
function extract(object, ...keys);

/**
 * Traverses an object and applies a callback function to each non-object property.
 *
 * @param {Object} object - The object to traverse.
 * @param {function} callback - The function to call for each non-object property.
 * @returns {void}
 */
function traverse(object, callback);

/**
 * Removes the specified keys from the given object.
 *
 * @param {Object} object - The object from which to remove keys.
 * @param {...string} keys - The keys to remove from the object.
 */
function remove(object, ...keys);

/**
 * Creates a proxy for an object that intercepts get and set operations.
 * @param {Object} obj - The object to proxy.
 * @param {Object} options - Options for the proxy.
 * @param {function} [options.apply] - A trap for a function call.
 * @param {function} [options.construct] - A trap for the new operator.
 * @param {function} [options.defineProperty] - A trap for Object.defineProperty.
 * @param {function} [options.deleteProperty] - A trap for the delete operator.
 * @param {function} [options.get] - A trap for getting property values.
 * @param {function} [options.getOwnPropertyDescriptor] - A trap for Object.getOwnPropertyDescriptor.
 * @param {function} [options.getPrototypeOf] - A trap for Object.getPrototypeOf.
 * @param {function} [options.has] - A trap for the in operator.
 * @param {function} [options.isExtensible] - A trap for Object.isExtensible.
 * @param {function} [options.ownKeys] - A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.
 * @param {function} [options.preventExtensions] - A trap for Object.preventExtensions.
 * @param {function} [options.set] - A trap for setting property values.
 * @param {function} [options.setPrototypeOf] - A trap for Object.setPrototypeOf.
 * @param {boolean} [options.recursive=true] - Whether to wrap nested objects in proxies.
 * @param {boolean} [options.readonly] - If true, the proxy will not allow setting properties.
 * @returns {Proxy} A proxy for the object.
 */
function proxy(target, options = {});

promise

/**
 * Checks if a value is a Promise.
 *
 * @param {any} f - The value to check.
 * @returns {boolean} Whether the value is a Promise.
 */
function isPromise(f);

/**
 * Checks if a value is an async function.
 *
 * @param {function} f - The value to check.
 * @returns {boolean} Whether the value is an async function.
 */
function isAsync(f);

/**
 * Converts any function or value into Async
 *
 * @param {any} value - Value to convert into a Async.
 * @returns {Promise<any>} Promise.
 */
function async(value);

request

/**
 * Sends an HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response.
 */
function request(url, options);

/**
 * Sends a GET HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response data.
 */
function request.get(url, options);

/**
 * Sends a POST HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response data.
 */
function request.post(url, options);

/**
 * Sends a HEAD HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response data.
 */
function request.head(url, options);

/**
 * Sends a PUT HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response data.
 */
function request.put(url, options);

/**
 * Sends a DELETE HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response data.
 */
function request.delete(url, options);

/**
 * Sends a CONNECT HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response data.
 */
function request.connect(url, options);

/**
 * Sends an OPTIONS HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response data.
 */
function request.options(url, options);

/**
 * Sends a TRACE HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response data.
 */
function request.trace(url, options);

/**
 * Sends a PATCH HTTP request and returns a Promise that resolves to the response.
 *
 * @param {string} url - The URL for the request.
 * @param {Options} [options] Options for the request.
 * @returns {Promise<Response>} A promise that resolves to the response data.
 */
function request.patch(url, options);

/**
 * Sets the bearer token for all requests.
 *
 * @param {string} token - The bearer token to set.
 */
function request.setAuthorization(token);

string

/**
 * Encodes a string using a specified encoding.
 *
 * @param {string} string - The string to encode.
 * @param {"base64" | "hex" | "ascii" | "binary"} [encoding] - The encoding to use. Defaults to "base64".
 * @returns {string} The encoded string.
 */
function encode(string, encoding = "base64");

/**
 * Decodes a string using a specified encoding.
 *
 * @param {string} data - The string to decode.
 * @param {"base64" | "hex" | "ascii" | "binary"} [encoding] - The encoding to use. Defaults to "base64".
 * @returns {string} The decoded string.
 */
function decode(data, encoding = "base64");

/**
 * Capitalizes the first letter of a string.
 *
 * @param {string} string - The string to capitalize.
 * @returns {string} The capitalized string.
 */
function capitalize(string);

/**
 * Abbreviates a number or string.
 *
 * @param {string | number} input - The number or string to abbreviate.
 * @returns {string} The abbreviated string.
 */
function abbreviate(input);

/**
 * Checks if a string is a valid IP address.
 *
 * @param {string} string - The string to check.
 * @returns {boolean} Whether the string is a valid IP address.
 */
function isIPAddress(string);

/**
 * Checks if a string is a valid URL.
 *
 * @param {string} string - The string to check.
 * @returns {boolean} Whether the string is a valid URL.
 */
function isValidUrl(string);

/**
 * Checks if a string is a valid URL pathname.
 *
 * @param {string} string - The string to check.
 * @returns {boolean} Whether the string is a valid URL pathname.
 */
function isValidUrlPathname(string);

/**
 * Ensures that a given string ends with a specified pattern.
 *
 * @param {string} str - The string to be checked.
 * @param {string} pattern - The pattern that the string should end with.
 * @returns {string} - The original string with the pattern appended if it wasn't already present.
 */
function ensureEndsWith(str, pattern);

/**
 * Checks if a string is numeric.
 *
 * @param {string} str - The string to check.
 * @returns {boolean} Whether the string is numeric.
 */
function isNumeric(str);

License

Licensed under the GNU General Public License version 3 only (GPL-3.0-only). See LICENSE for the full terms.

Contributing

Thank you for your interest in contributing to this project! Please ensure that any contributions respect the licensing terms specified. If you encounter any issues or have suggestions, feel free to report them. All issues will be well received and addressed to the best of our ability. We appreciate your support and contributions!

Authors