@pertype/decimal.js
v0.6.0
Published
pertype support for decimal.js
Downloads
104
Maintainers
Readme
@pertype/decimal.js
pertype - [/type] - add-on for decimal.js
pertype is still in alpha. Expect bugs and api changes!
Installation
npm install @pertype/decimal.js # npm
yarn add @pertype/decimal.js # yarn
bun add @pertype/decimal.js # bun
pnpm add @pertype/decimal.js # pnpmBasic Usage
import { decimal } from '@pertype/decimal.js'
// create decimal schema
const schema = decimal()
// type guard
if (schema.is(value)) {
// ... value is inferred as `Decimal`
}
// decode value (coercion) to `Decimal`
schema.decode(value)
// encode value to Json compatible type
schema.encode(value)Schema
pertype come with built-in schema you can immediately use
| Name | Typescript | Factory |
| ------- | ---------- | ----------- |
| decimal | Decimal | decimal() |
