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

ts-barcode-generator

v0.0.3

Published

Simple Barcode Generator created in TypeScript

Downloads

8

Readme

SVG Barcode Generator written in TypeScript

Simple barcode generator for frameworks like React, Preact, Qwik, Svelte, etc.
Created to be lightweight and easy to use.

Generated 1D barcodes can be resized freely horizontally and vertically. By default, they will take on the size of the parent element. QR codes will be scalable, preserve aspect ratio and their size also depends on width of parent element.

Why to use this library

  • Creates responsive SVG graphics.
  • Is TailwindCSS friendly (you can easily apply colors).
  • Is Dependency-free

Why you shouldn't use this library

Whether the project will be developed further depends on my willingness to work. EAN13 might be the only supported format.

Idea

There was no browser API that I could use for generating 1D/2D barcodes in my projects. Among the libraries available on NPM, I found only one decent library that is written in pure JavaScript - bwip-js, which unfortunately does not have tree shaking. Bundled in my Vite project it takes about 230 kilobytes Gzipped.

So, as part of my TypeScript learning journey (and programming in general), I decided to see if I could create such a generator with the help of ChatGPT and GitHub Copilot. At the beginning, I will focus on the most important types of codes for me: EAN13 and QR.

Usage

Common

import TsBarcodeGenerator from 'ts-barcode-generator';

const barcode = TsBarcodeGenerator.generate('7423522549551', 'EAN13');

console.log(barcode);

React/Preact + TailwindCSS

import TsBarcodeGenerator from 'ts-barcode-generator';

export const YourComponent = () => {
  const barcode = TsBarcodeGenerator.generate('7423522549551', 'EAN13');
  return (
    <div className='p-6 bg-white fill-current text-black'>
      <div dangerouslySetInnerHTML={{ __html: barcode }} />
    </div>
  );
};

Supported code formats

  • EAN13
  • UPC

Planned code formats

  • Simple 1D barcodes like Code 128, Code 39, etc.
  • QR Code (I already tried to implement it without success, it's challenging)

Materials you can check before use

Support the project

If you see potential in this project and want to help - feel free to contribute. Any help is welcome.

You can contact me on Discord: avaray_
You can find me on servers like: Astro Lounge, Anthony's, Programowanko TSH.io.