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

@christianpasinrey/vue-code-parser

v1.0.2

Published

Composable para Vue 3 que permite detectar, validar y parsear códigos de barras EAN, DataMatrix y QR (GS1).

Readme

🎯 vue-code-parser

🧩 Composable para Vue 3 para detectar, validar y parsear códigos de barras (EAN-13, EAN-14), QR y DataMatrix (GS1).

Este paquete te permite trabajar con inputs escaneados o digitados que contienen información estructurada como GTIN, LOTE, FECHA, SERIAL, etc., incluyendo parsing avanzado de códigos GS1.


🚀 Instalación

npm install vue-code-parser

🧠 ¿Qué hace?

Detecta el tipo de código escaneado (EAN, QR, DataMatrix) y lo convierte en un objeto legible:

  • ✅ Validación EAN-13 y EAN-14 con cálculo de dígito de control
  • ✅ Parsing de DataMatrix (con soporte GS1 y AI como 01, 10, 17, etc.)
  • ✅ Detección de QR y extracción del payload
  • ✅ Buffer con debounce para evitar repeticiones en escáneres
  • ✅ Manejo de caracteres invisibles (como charCode === 29)

🧰 Uso básico

import { useCodeParser } from "vue-code-parser";

const {
  handleInput,
  parsedResult,
  isParsedResultArray,
  detectType,
  isQr,
  checkInvisibleChars
} = useCodeParser();

// En algún método:
handleInput(']d20112345678901234101725010110ABC123+')
  .then(() => {
    console.log(parsedResult.value);
  });

🧾 Resultado esperado (DataMatrix GS1)

[
  { code: "01", value: "12345678901234", name: "Global Trade Item Number", description: "GTIN" },
  { code: "17", value: "250101", name: "Expiration date (YYMMDD)", description: "FECHA DE CACUCIDAD" },
  { code: "10", value: "ABC123", name: "Batch or lot number", description: "LOTE" }
]

📦 API completa


🧩 Tipos

interface CodePart {
  code: string;
  value: string;
  name: string;
  description: string;
}

🏷️ Códigos soportados (GS1 AIs)

| Código | Descripción | Longitud fija | |--------|------------------------------|---------------| | 01 | GTIN | ✅ 16 | | 10 | Lote | ❌ variable | | 11 | Fecha de producción (YYMMDD) | ✅ 8 | | 17 | Fecha de caducidad (YYMMDD) | ✅ 8 | | 21 | Número de serie | ❌ variable | | 712 | Código nacional (NPC) | ❌ variable |


🧪 Ejemplo de integración con input de escáner

<template>
  <input
    @keypress="(e) => inputBuffer += checkInvisibleChars(e)"
    @keydown.enter.prevent="handleInput(inputBuffer)"
    v-model="inputBuffer"
  />
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useCodeParser } from "vue-code-parser";

const inputBuffer = ref("");
const { handleInput, checkInvisibleChars, parsedResult } = useCodeParser();
</script>

📃 Licencia

MIT © Christian


🤝 Contribuir

¡Pull requests y feedback son bienvenidos! Si encuentras un código no compatible, puedes abrir un issue o PR con los nuevos GS1 AI.