USD (src/money.ts)

opencode · packages/schema/src/money.ts · typescript · MIT
payments, tag:knn-classified

Defines branded USD and USDPerMillionTokens schemas for type-safe monetary values.

// Source: https://github.com/anomalyco/opencode | License: MIT | Copyright 2025 opencode
// Provided via justclaw.it.com; keep this notice with the code.
export * as Money from "./money.js"

import { Schema } from "effect"
import { statics } from "./schema.js"

export const USD = Schema.Finite.pipe(
  Schema.brand("Money.USD"),
  Schema.annotate({ identifier: "Money.USD" }),
  statics((schema) => ({ zero: schema.make(0) })),
)
export type USD = typeof USD.Type

export const USDPerMillionTokens = Schema.Finite.pipe(
  Schema.brand("Money.USDPerMillionTokens"),
  Schema.annotate({ identifier: "Money.USDPerMillionTokens" }),
  statics((schema) => ({ zero: schema.make(0) })),
)
export type USDPerMillionTokens = typeof USDPerMillionTokens.Type

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key