optis
v0.3.0
Published
minimalistic library for building composable options processors
Readme
optis
minimalistic library for building composable options processors
minimal example
import optis from 'optis'
const schema = optis({
defaults: {
target: 'world',
},
})
export default (options: optis.Parameter<typeof schema>) => {
const processedOptions = schema.process(options)
return `Hello, ${processedOptions.target}!`
}installation
npm install --save optisusage
The default export also carries the public type helpers, so optis.Parameter<typeof schema>, optis.Processed<typeof schema> and optis.Schema<...> work without a second import type.
If you prefer direct named type imports, the same helpers are also exported as OptisParameter, OptisProcessed, OptisProcessedMap, OptisSchema, OptisSetup and related aliases.
import optis, {type OptisParameter} from 'optis'
const schema = optis({
defaults: {
target: 'world',
},
})
export default (options: OptisParameter<typeof schema>) => {
const processedOptions = schema.process(options)
return `Hello, ${processedOptions.target}!`
}Type-only and runtime features can be composed by chaining .extend() and .extendTyped().
import optis from 'optis'
const schema = optis({
defaults: {
cwd: process.cwd(),
},
}).extendTyped<{
optional: {
user: string
}
}>()
export default (options: optis.Parameter<typeof schema>) => {
const processedOptions = schema.process(options)
if (processedOptions.user) {
console.log(`USER=${processedOptions.user}`)
}
}development
Maintain README content in docs/tldw. Do not edit readme.md directly.
bun run readme regenerates it. bun run build regenerates the README before building the package.
setting up
git clone [email protected]:Jaid/optis.git
cd optis
bun installtesting
bun run testlicense
MIT License Copyright © 2026, Jaid <[email protected]> (https://github.com/jaid)
