edyt

Developerprompt

Document It

Add a docstring or doc comment to code.

Example input

function formatPrice(cents, currency = "USD", locale = "en-US") {
  if (!Number.isInteger(cents)) throw new TypeError("cents must be an integer");
  return new Intl.NumberFormat(locale, { style: "currency", currency }).format(cents / 100);
}

Edyt's result

/**
 * Formats a price in cents to a currency string based on the specified locale.
 *
 * @param {number} cents - The amount in cents, which must be an integer.
 * @param {string} [currency="USD"] - The currency code (e.g., "USD", "EUR").
 * @param {string} [locale="en-US"] - The locale to format the currency string.
 * @returns {string} The formatted currency string.
 * @throws {TypeError} If cents is not an integer.
 */
function formatPrice(cents, currency = "USD", locale = "en-US") {
  if (!Number.isInteger(cents)) throw new TypeError("cents must be an integer");
  return new Intl.NumberFormat(locale, { style: "currency", currency }).format(cents / 100);
}

Run this on any text, in any app

Select text, hit your shortcut, and pick this recipe. The result appears in place. No copy-paste, no browser tab.

Document It | Edyt Prompt | Edyt