scriptref:params

smudgy:params

Generated from smudgy v0.3.5 (smudgy-params.d.ts @ 36bdd47232ed). Index: scriptref.

Per-package configuration: read the option values chosen when a package was installed (the options block of its smudgy.package.json). Import from smudgy:params.

export function get(key: string): ParamValue | null | undefined;

Read one of your package's configured options by key (a params[].key from its smudgy.package.json). Returns the value configured at install time, or undefined/null when the option is unset (or when the caller isn't a package). Secret options come back as plain strings; a dropdown returns the chosen option's value.

import { get } from "smudgy:params";
const url = get("pg.url");       // ParamValue | null | undefined
if (typeof url === "string") connect(url);
 
const routes = get("routes");    // a `table` param -> array of row objects
if (Array.isArray(routes)) {
  for (const row of routes) console.log(row.from, row.via);
}

This describes a type returned from a function on this page. Typically you'll never construct it directly.

type ParamValue = ParamScalar | ParamScalar[] | Record<string, ParamScalar>[];

A configured option value. Simple params store one ParamScalar; a list param stores an array of its element values; a table param stores an array of row objects keyed by column.

This describes a type returned from a function on this page. Typically you'll never construct it directly.

type ParamScalar = string | number | boolean;

A single option value: what a string/number/boolean/dropdown param stores.

The module's default export (params).

const params: { get: typeof get };

The default export bundles the same get accessor.


Script API reference · smudgy:core — Sessions & output · smudgy:core — Lines & buffer · smudgy:core — Events · smudgy:core — Automations · smudgy:core — Saved automations · smudgy:core — Panes · smudgy:widgets · Mapper