dev:scriptref:params

smudgy:params

Generated from smudgy v0.4.2-dev (smudgy-params.d.ts @ b7a128a7ff9c). 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.

get

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") console.log(`Configured URL: ${url}`);
 
const routes = get("routes");    // a `table` param -> array of row objects
if (Array.isArray(routes)) {
  for (const row of routes) {
    if (typeof row === "object" && row !== null) console.log(row.from, row.via);
  }
}

ParamValue

Support type used by signatures on this page.

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.

ParamScalar

Support type used by signatures on this page.

type ParamScalar = string | number | boolean;

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

Default export

The module's default export (params).

const params: { get: typeof get };

The default export bundles the same get accessor.


Script API reference · ← Mapper · Scripting manual