Skip to content

Installation

rut.ts is a single, zero-dependency package. It ships both ESM and CommonJS builds and is fully tree-shakeable (sideEffects: false), so you only pay for the functions you import.

Requirements#

  • Node.js 16+, Bun, Deno, or any modern browser / edge runtime
  • A package manager: npm, pnpm, bun, or yarn
  • TypeScript is optional — types are bundled, but the library works in plain JavaScript too

Add the package#

Shell
npm install rut.ts

Verify the installation#

1

Import a function

Pull in only what you need. Imports are named and tree-shakeable.

TypeScript
import { validate } from 'rut.ts'
2

Run it

Validation checks both the shape and the Modulo 11 verifier digit.

TypeScript
console.log(validate('12.345.678-5')) // true
console.log(validate('12.345.678-0')) // false
3

You're set

If both lines log as above, the package is wired correctly. Continue with the Quick Start.

Module formats#

rut.ts works with both module systems without configuration:

TypeScript
// ESM / TypeScript
import { validate, format } from 'rut.ts'
JavaScript
// CommonJS
const { validate, format } = require('rut.ts')

Runtime support#

The same code runs on Node, Deno, Bun, the Edge, and the browser. RUT generation uses the Web Crypto API when available and falls back gracefully when it is not — no configuration needed.

EnvironmentSupportedNotes
Node.js 16+ESM and CommonJS
BunNative ESM
DenoImport via npm specifier
BrowsersBundle with any tool; tree-shakeable
Edge / Vercel FunctionsNo Node-only APIs in the hot path

CDN / no build step#

For quick prototypes you can import straight from a CDN in the browser:

HTML
<script type="module">
  import { validate, format } from 'https://esm.sh/rut.ts'
 
  console.log(validate('12.345.678-5')) // true
</script>

Next steps#