An open API service indexing awesome lists of open source software.

https://github.com/riennevaplus/gtin-manager

🏷️ Generates a list of EANs / GTINs for a given Global Company Prefix (GPC / Basisnummer)
https://github.com/riennevaplus/gtin-manager

ean ean-code ean-list ean13 generator gtin gtin-codes gtin-generator gtin-list gtin-toolkit node-js

Last synced: over 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

║█║▌║█║▌│║▌║▌█║

🏷️ GTIN Manager


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


license
last-commit
version
version

║▌║█║║▌▌│║▌║║▌▌║

### Setup

```ts
npm install gtin-manager
// or
yarn add gtin-manager
```

║▌║█║║▌▌║▌║█║▌║

### Usage
Create a generator instance using a GCP ([Global Company Prefix](https://www.gs1ie.org/standards/identification/global-company-prefix-gcp/)) provided by [GS1](https://www.gs1-germany.de/).

```ts
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.

```ts
manager.contingent === 10000 // true
```


`manager.index(number)`
---

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

```ts
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.

```ts
manager.all === ['1234567800011', '1234567800028', ... 9998 more items] // true
```

▌║║█║║▌█║▌║║▌║▌

---

*🌻 Thanks to [xbpf/gtin](https://github.com/xbpf/gtin) for providing functions used in this repository.*