Coder Social home page Coder Social logo

jeroenvisser101 / barcode_generator Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 11 KB

Barcode generator for Elixir, generating large amounts of GTIN barcodes efficiently

Home Page: https://hexdocs.pm/barcode_generator

License: MIT License

Elixir 100.00%
elixir gtin barcode ean generator

barcode_generator's Introduction

BarcodeGenerator

Online documentation | Hex.pm

BarcodeGenerator generates a list of barcodes from a given start and end barcode.

This library allows you to generate GTIN barcodes by passing it the first and last barcode of a range.

Examples

Validating

BarcodeGenerator allows simple check-digit validation for GTIN barcodes, both in binary and numeric format:

BarcodeGenerator.valid?("6291041500206")
# true

BarcodeGenerator.valid?(6291041500206)
# true

BarcodeGenerator.valid?("6291041500200")
# false

BarcodeGenerator.valid?(6291041500200)
# false

Generating

BarcodeGenerator can generate barcodes in three different ways:

Plain list

BarcodeGenerator.generate/2 generates barcodes in a simple list format.

BarcodeGenerator.generate(6_291_041_500_200, 6_291_041_500_299)

Stream

BarcodeGenerator.generate_stream/2 returns a Stream that can be enumerated. Barcodes are generated as the stream is consumed, reducing memory footprint.

stream = BarcodeGenerator.generate_stream(6_291_041_500_200, 6_291_041_500_299)
barcodes = Enum.to_list(stream)

Flow (optional dependency)

BarcodeGenerator.generate_flow/3 returns a Flow, but requires that flow is present as dependency. Generating barcodes using Flow is heavily optimized to use all available resources to generate as quickly as possible.

BarcodeGenerator.generate_flow/3 accepts an optional third argument, opts, which is passed to Flow.from_enumerable/2, and defaults to max_demand: 1000.

# Assuming `{:flow, "~> 1.0"}` is in mix.exs
flow = BarcodeGenerator.generate_flow(6_291_041_500_200, 6_291_041_500_299)
barcodes = Enum.to_list(flow)

Installation

Add barcode_generator to your list of dependencies in mix.exs:

def deps do
  [{:barcode_generator, "~> 1.1.0"}]
end

License

This library is MIT licensed. See the LICENSE file in this repository for details.

barcode_generator's People

Contributors

jeroenvisser101 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.