npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ideas-digitales/rut-input

v0.1.3

Published

Format Chilean RUT input while typing (formatting only, no modulo 11 validation)

Readme

@ideas-digitales/rut-input

Formato progresivo de RUT chileno para inputs de texto mientras el usuario escribe.

Este paquete sí hace: limpieza de caracteres + formateo visual (. y -).

Este paquete NO hace: validación semántica de RUT (sin módulo 11).

Instalación

npm install @ideas-digitales/rut-input

Uso rápido (manual)

import { formatRutInput } from '@ideas-digitales/rut-input';

formatRutInput('12345678k'); // "12.345.678-K"

API

  • cleanRut(value: string): string

    • Deja solo dígitos y K.
    • Convierte k a K.
    • K solo puede quedar al final.
    • Largo máximo lógico: 9 (8 cuerpo + 1 verificador).
  • formatRut(value: string): string

    • Limpia con cleanRut y aplica formato progresivo de RUT.
  • formatRutInput(value: string): string

    • Alias semántico de formatRut.
  • attachRutFormatter(input: HTMLInputElement, options?)

    • Aplica formato en cada input event.
    • Devuelve función de cleanup para desadjuntar listener.

Ejemplos de formateo

  • 1 -> 1
  • 12 -> 12
  • 123 -> 123
  • 1234 -> 1.234
  • 12345 -> 12.345
  • 123456 -> 123.456
  • 1234567 -> 1.234.567
  • 77204288 -> 7.720.428-8
  • 12345678 -> 1.234.567-8
  • 123456789 -> 12.345.678-9
  • 12345678k -> 12.345.678-K

CDN (ES module)

<script type="module">
  import { formatRutInput } from 'https://cdn.jsdelivr.net/npm/@ideas-digitales/[email protected]/dist/index.js';

  console.log(formatRutInput('12345678k')); // 12.345.678-K
</script>

También podés usar unpkg:

<script type="module">
  import { formatRutInput } from 'https://unpkg.com/@ideas-digitales/[email protected]/dist/index.js';
</script>

CDN (global script)

<script src="https://cdn.jsdelivr.net/npm/@ideas-digitales/[email protected]/dist/rut-input.global.js"></script>
<script>
  console.log(window.RutInput.formatRutInput('12345678k')); // 12.345.678-K
</script>

Vanilla JS con attachRutFormatter

<input id="rut" type="text" />
<script type="module">
  import { attachRutFormatter } from 'https://cdn.jsdelivr.net/npm/@ideas-digitales/[email protected]/dist/index.js';

  const input = document.getElementById('rut');
  const detach = attachRutFormatter(input);

  // Cuando no lo necesites:
  // detach();
</script>

React

import { formatRutInput } from '@ideas-digitales/rut-input';
import { useState } from 'react';

export function RutField() {
  const [rut, setRut] = useState('');

  return (
    <input
      value={rut}
      onChange={(e) => setRut(formatRutInput(e.target.value))}
      placeholder="12.345.678-K"
    />
  );
}

WordPress (theme/plugin simple)

<?php
// Enqueue desde CDN
wp_enqueue_script(
  'rut-input',
  'https://unpkg.com/@ideas-digitales/[email protected]/dist/rut-input.global.js',
  array(),
  null,
  true
);
<input id="rut" type="text" />
<script>
  document.addEventListener('DOMContentLoaded', function () {
    var input = document.getElementById('rut');
    if (input && window.RutInput) {
      window.RutInput.attachRutFormatter(input);
    }
  });
</script>

License

MIT