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 🙏

© 2024 – Pkg Stats / Ryan Hefner

placa-mercosul

v0.1.7

Published

Auxilia na validação da placa do mercosul e na conversão da placa antiga pra placa nova

Downloads

72

Readme

Build Status codecov Known Vulnerabilities Maintainability devDependencies Status Inline docs contributions welcome HitCount

https://nodei.co/npm/placa-mercosul.png?downloads=true&downloadRank=true&stars=true

node-placa-mercosul

Pacote para validar e converter as placas para o novo formato

Getting Started

import { validate, convert } from "placa-mercosul";
// ou const placaMercosul = require("placa-mercosul")

const isValid = validate("BR ABC 1C34"); //true

const isValid = validate("BRABC1C34"); //true

const isValid = validate("ABC 1C34"); //true

const isValid = validate("ABC 1234"); //false

const isValid = validate("ABC 1234", true); //true

// NO SAFE convert
// P.S.: essa regra ainda pode mudar para outros tipos de veiculo
// para moto: o 3 numero vira letra
// para carro: o 2 numero vira letra

const placa = convert("ABC 1234"); //BR ABC 1C34

const placa = convert("ABC 1234", {}, "moto"); //BR ABC 12D4

const placa = convert("ABC 1234", { suffix: "PR" }); //PR ABC 1C34

const placa = convert("ABC 1234", { spaceChar: "" }); //PRABC1C34

const placa = convert("ABC 1234", { spaceChar: "_" }); //PR_ABC_1C34

const placa = convert("ABC 1234", { letterIndex: 0 }); //PR_ABC_B234
const placa = convert("ABC 1234", { letterIndex: 1 }); //PR_ABC_1C34
const placa = convert("ABC 1234", { letterIndex: 2 }); //PR_ABC_12D4
const placa = convert("ABC 1234", { letterIndex: 3 }); //PR_ABC_123E

const placa = convert("INVALID!"); // INVALID!

const placa = convert("INVALID!", { throwsInvalid: true }); // will throw Error!!

function validate

validate(placa: string, incluirFormatoAntigo: bool = false)

  • placa: string: Placa a ser validada
  • incluirFormatoAntigo: bool: Se true ira confirmar válido formato antigo (ex. ABC1234), senão, se falso somente o formato mercosul.

function convert

convert(placa: string, options: ConvertOptions , tipo: "carro"|"moto" = "carro")

  • placa: string: Placa a ser convertida, caso inválida, sera retornada intacta.

  • options: ConvertOptions:

    • suffix: string (default: "BR"): sufixo da placa, geralmente indica o país;
    • spaceChar: string (default: " "): indica o separador dos blocos da placa;
    • throwsInvalid: bool (default: false): se true caso não seja possivel converter ele lança um erro, caso contrario somente retorna a entrada sem impacto.
  • tipo: "carro"|"moto" (default: "carro"): Indica através do tipo do veículo

Problemas ?

Duvidas ou dificuldades, abra uma ISSUE ou contribua com um PR!