Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ean13-lib

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ean13-lib

Provides common EAN 13 barcode related features.

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

EAN 13 lib

Typescript library for EAN 13 numbers basic features.

Installation

$ npm i ean13-lib --save

Usage

Number Validation

Returns if the input (13 length digits string) is an EAN 13 number or not.

import { Ean13Utils } from 'ean13-lib';

const result = Ean13Utils.validate('2621922006400');
expect(result).toBeFalsy();
                    
const result = Ean13Utils.validate('2621922006390');
expect(result).toBeTruthy();

Check digit calculation

Calculates the input (12 digits string) check digit.

const result = Ean13Utils.calculateCheckDigit('262192200517');
expect(result).toBe(1);

Number Generation

Returns the input with the calculated check digit as the 13th digit.

const generatedBarcode = Ean13Utils.generate('262192200517');
expect(generatedBarcode).toBe(2621922005171);

Keywords

FAQs

Package last updated on 09 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc