UNPKG

react-rut

Version:
19 lines 685 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const unformat_1 = __importDefault(require("./unformat")); function format(value) { const unformatted = unformat_1.default(value); if (unformatted.length < 2) { return unformatted; } const length = unformatted.length - 1; const rut = unformatted .substring(0, length) .replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.'); return `${rut}-${unformatted.charAt(length)}`; } exports.default = format; //# sourceMappingURL=format.js.map