RienNeVaPlus / gtin-manager

🏷️ Generates a list of EANs / GTINs for a given Global Company Prefix (GPC / Basisnummer)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

β•‘β–ˆβ•‘β–Œβ•‘β–ˆβ•‘β–Œβ”‚β•‘β–Œβ•‘β–Œβ–ˆβ•‘

🏷️ GTIN Manager

Generates Global Trade Item Numbers (formerly known as EANs) for a given Global Company Prefix.

license last-commit version version

β•‘β–Œβ•‘β–ˆβ•‘β•‘β–Œβ–Œβ”‚β•‘β–Œβ•‘β•‘β–Œβ–Œβ•‘

Setup

npm install gtin-manager
// or
yarn add gtin-manager
β•‘β–Œβ•‘β–ˆβ•‘β•‘β–Œβ–Œβ•‘β–Œβ•‘β–ˆβ•‘β–Œβ•‘

Usage

Create a generator instance using a GCP (Global Company Prefix) provided by GS1.

import Manager from 'gtin-manager'

const manager = new Manager('12345678')

manager.contingent

Returns the amount of possible GTINs that can be created from the current GCP.

manager.contingent === 10000 // true

manager.index(number)

Returns GTIN / EAN for an index (which has to be inside the bounds of manager.contingent)

manager.index(0) === '1234567800004'    // true
manager.index(9999) === '1234567899992' // true
manager.index(10000)                    // Error: Index out of bounds
manager.index(-1)                       // Error: Index out of bounds

manager.all

Returns an array of all possible GTINs / EANs for the GCP.

manager.all === ['1234567800011', '1234567800028', ... 9998 more items] // true
β–Œβ•‘β•‘β–ˆβ•‘β•‘β–Œβ–ˆβ•‘β–Œβ•‘β•‘β–Œβ•‘β–Œ

🌻 Thanks to xbpf/gtin for providing functions used in this repository.

About

🏷️ Generates a list of EANs / GTINs for a given Global Company Prefix (GPC / Basisnummer)

License:MIT License


Languages

Language:JavaScript 63.6%Language:TypeScript 36.4%