@valentynb/gs1-parser 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +31 -0
- package/.github/workflows/publish.yml +45 -0
- package/LICENSE +21 -21
- package/README.md +246 -247
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +1 -1
- package/package.json +49 -42
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: CI (Tests + Dry Publish Check)
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test-build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v5
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-node@v5
|
|
19
|
+
with:
|
|
20
|
+
node-version: 24
|
|
21
|
+
registry-url: https://registry.npmjs.org/
|
|
22
|
+
|
|
23
|
+
- run: npm ci
|
|
24
|
+
|
|
25
|
+
- run: npm test
|
|
26
|
+
|
|
27
|
+
- run: npm run build
|
|
28
|
+
|
|
29
|
+
- name: Verify npm packaging (dry run)
|
|
30
|
+
run: npm publish --dry-run
|
|
31
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
id-token: write
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
publish:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout code
|
|
17
|
+
uses: actions/checkout@v5
|
|
18
|
+
|
|
19
|
+
- name: Set up Node
|
|
20
|
+
uses: actions/setup-node@v5
|
|
21
|
+
with:
|
|
22
|
+
node-version: '24'
|
|
23
|
+
registry-url: 'https://registry.npmjs.org/'
|
|
24
|
+
|
|
25
|
+
- name: Authenticate with npm
|
|
26
|
+
run: echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
|
|
27
|
+
env:
|
|
28
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
29
|
+
|
|
30
|
+
- name: Update npm
|
|
31
|
+
run: npm install -g npm@latest
|
|
32
|
+
|
|
33
|
+
- name: Install dependencies
|
|
34
|
+
run: npm ci
|
|
35
|
+
|
|
36
|
+
- name: Test
|
|
37
|
+
run: npm test
|
|
38
|
+
|
|
39
|
+
- name: Build
|
|
40
|
+
run: npm run build
|
|
41
|
+
|
|
42
|
+
- name: Publish
|
|
43
|
+
run: npm publish --provenance
|
|
44
|
+
env:
|
|
45
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Valentyn Blaha
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Valentyn Blaha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,247 +1,246 @@
|
|
|
1
|
-
# GS1 Barcode Parser
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/gs1-
|
|
4
|
-
[](https://www.npmjs.com/package/gs1-
|
|
5
|
-
[](LICENSE)
|
|
7
|
-
[](#)
|
|
8
|
-
|
|
9
|
-
A modern TypeScript library for parsing GS1 barcodes, supporting both ESModule and CommonJS formats.
|
|
10
|
-
|
|
11
|
-
### Based on work from: https://github.com/PeterBrockfeld/BarcodeParser
|
|
12
|
-
|
|
13
|
-
## Table of Contents
|
|
14
|
-
|
|
15
|
-
* [Purpose](#purpose)
|
|
16
|
-
* [Installation](#installation)
|
|
17
|
-
* [Disclaimer](#disclaimer)
|
|
18
|
-
* [The Specification](#the-specification)
|
|
19
|
-
* [About GS1 Barcodes](#about-gs1-barcodes)
|
|
20
|
-
* [About the Structure of GS1 Barcodes](#about-the-structure-of-gs1-barcodes)
|
|
21
|
-
* [Use Case](#use-case)
|
|
22
|
-
* [How to Use It](#how-to-use-it)
|
|
23
|
-
* [ESModule Usage](#esmodule-usage)
|
|
24
|
-
* [CommonJS Usage](#commonjs-usage)
|
|
25
|
-
* [TypeScript Usage](#typescript-usage)
|
|
26
|
-
* [Limitations](#limitations)
|
|
27
|
-
* [API Reference](#api-reference)
|
|
28
|
-
* [About Barcode Scanning Devices](#about-barcode-scanning-devices)
|
|
29
|
-
* [The FNC1 Character](#the-fnc1-character)
|
|
30
|
-
* [Key Press Detecting](#key-press-detecting)
|
|
31
|
-
* [Examples](#examples)
|
|
32
|
-
* [What's New](#whats-new)
|
|
33
|
-
* [License](#license)
|
|
34
|
-
|
|
35
|
-
## Purpose
|
|
36
|
-
|
|
37
|
-
The barcode parser is a TypeScript library for handling the contents of GS1 barcodes. GS1 barcodes are used for various purposes, from simple product barcodes to complex codes describing the contents of an entire pallet. Two-dimensional barcodes can hold a significant amount of information, and this library makes it easier to access and process that data.
|
|
38
|
-
|
|
39
|
-
The barcode parser contains functions for parsing GS1 barcodes, yielding individual elements in a format easily processable by JavaScript and TypeScript applications.
|
|
40
|
-
|
|
41
|
-
The barcode parser is meant to be used in applications which:
|
|
42
|
-
|
|
43
|
-
* Take data from a barcode scanning device or barcode reading application
|
|
44
|
-
* Process the data
|
|
45
|
-
* Perform actions based on the barcode contents
|
|
46
|
-
|
|
47
|
-
## Installation
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
npm install @valentynb/gs1-parser
|
|
51
|
-
# or
|
|
52
|
-
yarn add @valentynb/gs1-parser
|
|
53
|
-
# or
|
|
54
|
-
pnpm add @valentynb/gs1-parser
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Disclaimer
|
|
58
|
-
|
|
59
|
-
This library is an independent interpretation of the GS1 specification. It is neither endorsed, supported, approved, nor recommended by GS1, and there are no affiliations with GS1.
|
|
60
|
-
|
|
61
|
-
## The Specification
|
|
62
|
-
|
|
63
|
-
The full "GS1 General Specifications" can be found at [http://www.gs1.org/standards/genspecs](https://ref.gs1.org/standards/genspecs/). This library has been updated to comply with the **2025 version** of the GS1 specification.
|
|
64
|
-
|
|
65
|
-
## About GS1 Barcodes
|
|
66
|
-
|
|
67
|
-
GS1 barcodes can contain comprehensive product information including:
|
|
68
|
-
|
|
69
|
-
* GTIN (Global Trade Item Number, formerly UPC or EAN)
|
|
70
|
-
* Weight or dimensions
|
|
71
|
-
* Price
|
|
72
|
-
* Lot/batch code
|
|
73
|
-
* Manufacturing date
|
|
74
|
-
* Expiration date
|
|
75
|
-
* And much more
|
|
76
|
-
|
|
77
|
-
### About the Structure of GS1 Barcodes
|
|
78
|
-
|
|
79
|
-
A GS1 barcode is a concatenation of *data elements*. Each element starts with an *application identifier* (AI), a two to four digit number, followed by the actual information.
|
|
80
|
-
|
|
81
|
-
A *data element* is delimited by:
|
|
82
|
-
|
|
83
|
-
* The end of the barcode
|
|
84
|
-
* A fixed character count specification
|
|
85
|
-
* A special FNC1 character
|
|
86
|
-
|
|
87
|
-
The *application identifiers* and their properties are described in the third chapter of the GS1 General Specifications.
|
|
88
|
-
|
|
89
|
-
The GS1 barcode begins with a *symbology identifier* (a three-character sequence denoting the barcode type), followed by an arbitrary number of *data elements*. The parser decomposes this string into its individual elements.
|
|
90
|
-
|
|
91
|
-
## Use Case
|
|
92
|
-
|
|
93
|
-
Your application receives a GS1 barcode as a string from a scanning device:
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
]C101040123456789011715012910ABC1233932978471131030005253922471142127649716
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
The library extracts and parses the data into structured elements:
|
|
100
|
-
|
|
101
|
-
| AI | Title | Contents | Unit/Currency |
|
|
102
|
-
|:---|:------|:---------|:--------------|
|
|
103
|
-
| 01 | GTIN | 04012345678901 | |
|
|
104
|
-
| 17 | USE BY OR EXPIRY | 2015-01-29 | |
|
|
105
|
-
| 10 | BATCH/LOT | ABC123 | |
|
|
106
|
-
| 3932 | PRICE | 47.11 | 978 |
|
|
107
|
-
| 3103 | NET WEIGHT (kg) | 0.525 | KGM |
|
|
108
|
-
| 3922 | PRICE | 47.11 | |
|
|
109
|
-
| 421 | SHIP TO POST | 49716 | 276 |
|
|
110
|
-
|
|
111
|
-
## How to Use It
|
|
112
|
-
|
|
113
|
-
### ESModule Usage
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
import { GS1Parser } from '@valentynb/gs1-parser';
|
|
117
|
-
|
|
118
|
-
const gs1Parser = new GS1Parser(
|
|
119
|
-
{
|
|
120
|
-
lotMaxLength: 20 // If not specified, no limit is applied, except the one in the GS1 specs
|
|
121
|
-
fncChar: String.fromCodePoint(29); // If not specified, the GS char is used
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
try {
|
|
126
|
-
const barcodeString = document.getElementById("barcode").value;
|
|
127
|
-
// returns a DecodeResult object or throws an Error in case of parsing errors
|
|
128
|
-
const result = gs1Parser.decode(barcodeString);
|
|
129
|
-
|
|
130
|
-
console.log(result.codeName); // e.g., "GS1-128"
|
|
131
|
-
console.log(result.denormalized); // Full barcode with parentheses
|
|
132
|
-
console.log(result.data); // Dictionary of parsed elements
|
|
133
|
-
} catch (error) {
|
|
134
|
-
console.error('Barcode parsing failed:', error);
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### CommonJS Usage
|
|
139
|
-
|
|
140
|
-
```javascript
|
|
141
|
-
const { parseBarcode } = require('@valentynb/gs1-parser');
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
const result = parseBarcode(barcodeString);
|
|
145
|
-
// Process result...
|
|
146
|
-
} catch (error) {
|
|
147
|
-
console.error('Barcode parsing failed:', error);
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### TypeScript Usage
|
|
152
|
-
|
|
153
|
-
The library is written in TypeScript and includes full type definitions:
|
|
154
|
-
|
|
155
|
-
```typescript
|
|
156
|
-
import { GS1Parser, BarcodeResult, ParsedElement } from '@valentynb/gs1-parser';
|
|
157
|
-
|
|
158
|
-
const gs1Parser = new GS1Parser(
|
|
159
|
-
{
|
|
160
|
-
lotMaxLength: 20 // If not specified, no limit is applied, except the one in the GS1 specs
|
|
161
|
-
fncChar: String.fromCodePoint(29); // If not specified, the GS char is used
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
const result: BarcodeResult = gs1Parser.decode(barcodeString);
|
|
167
|
-
|
|
168
|
-
result.data.values().forEach((item: ParsedElement) => {
|
|
169
|
-
console.log(`AI: ${item.ai}`);
|
|
170
|
-
console.log(`Title: ${item.dataTitle}`);
|
|
171
|
-
console.log(`Data: ${item.data}`);
|
|
172
|
-
console.log(`Unit: ${item.unit || 'N/A'}`);
|
|
173
|
-
});
|
|
174
|
-
} catch (error) {
|
|
175
|
-
console.error('Error:', error);
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Limitations
|
|
180
|
-
|
|
181
|
-
The `decode()` method does not perform plausibility checks (as of now). If the barcode contains invalid data (e.g., an invalid GTIN or ISO code), the function will return this invalid content without validation.
|
|
182
|
-
|
|
183
|
-
## API Reference
|
|
184
|
-
|
|
185
|
-
### `GS1Parser.decode(barcode: string): BarcodeResult`
|
|
186
|
-
|
|
187
|
-
Parses a GS1 barcode string and returns structured data.
|
|
188
|
-
|
|
189
|
-
**
|
|
190
|
-
- `
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
- `
|
|
198
|
-
- `
|
|
199
|
-
- `
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
* **
|
|
237
|
-
* **
|
|
238
|
-
* **
|
|
239
|
-
* **
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
Copyright
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
See the LICENSE.md file for license rights and limitations (MIT).
|
|
1
|
+
# GS1 Barcode Parser
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@valentynb/gs1-parser)
|
|
4
|
+
[](https://www.npmjs.com/package/@valentynb/gs1-parser)
|
|
5
|
+
[](https://github.com/valentynblaha/gs1-parser/actions)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](#)
|
|
8
|
+
|
|
9
|
+
A modern TypeScript library for parsing GS1 barcodes, supporting both ESModule and CommonJS formats.
|
|
10
|
+
|
|
11
|
+
### Based on work from: https://github.com/PeterBrockfeld/BarcodeParser
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
* [Purpose](#purpose)
|
|
16
|
+
* [Installation](#installation)
|
|
17
|
+
* [Disclaimer](#disclaimer)
|
|
18
|
+
* [The Specification](#the-specification)
|
|
19
|
+
* [About GS1 Barcodes](#about-gs1-barcodes)
|
|
20
|
+
* [About the Structure of GS1 Barcodes](#about-the-structure-of-gs1-barcodes)
|
|
21
|
+
* [Use Case](#use-case)
|
|
22
|
+
* [How to Use It](#how-to-use-it)
|
|
23
|
+
* [ESModule Usage](#esmodule-usage)
|
|
24
|
+
* [CommonJS Usage](#commonjs-usage)
|
|
25
|
+
* [TypeScript Usage](#typescript-usage)
|
|
26
|
+
* [Limitations](#limitations)
|
|
27
|
+
* [API Reference](#api-reference)
|
|
28
|
+
* [About Barcode Scanning Devices](#about-barcode-scanning-devices)
|
|
29
|
+
* [The FNC1 Character](#the-fnc1-character)
|
|
30
|
+
* [Key Press Detecting](#key-press-detecting)
|
|
31
|
+
* [Examples](#examples)
|
|
32
|
+
* [What's New](#whats-new)
|
|
33
|
+
* [License](#license)
|
|
34
|
+
|
|
35
|
+
## Purpose
|
|
36
|
+
|
|
37
|
+
The barcode parser is a TypeScript library for handling the contents of GS1 barcodes. GS1 barcodes are used for various purposes, from simple product barcodes to complex codes describing the contents of an entire pallet. Two-dimensional barcodes can hold a significant amount of information, and this library makes it easier to access and process that data.
|
|
38
|
+
|
|
39
|
+
The barcode parser contains functions for parsing GS1 barcodes, yielding individual elements in a format easily processable by JavaScript and TypeScript applications.
|
|
40
|
+
|
|
41
|
+
The barcode parser is meant to be used in applications which:
|
|
42
|
+
|
|
43
|
+
* Take data from a barcode scanning device or barcode reading application
|
|
44
|
+
* Process the data
|
|
45
|
+
* Perform actions based on the barcode contents
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install @valentynb/gs1-parser
|
|
51
|
+
# or
|
|
52
|
+
yarn add @valentynb/gs1-parser
|
|
53
|
+
# or
|
|
54
|
+
pnpm add @valentynb/gs1-parser
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Disclaimer
|
|
58
|
+
|
|
59
|
+
This library is an independent interpretation of the GS1 specification. It is neither endorsed, supported, approved, nor recommended by GS1, and there are no affiliations with GS1.
|
|
60
|
+
|
|
61
|
+
## The Specification
|
|
62
|
+
|
|
63
|
+
The full "GS1 General Specifications" can be found at [http://www.gs1.org/standards/genspecs](https://ref.gs1.org/standards/genspecs/). This library has been updated to comply with the **2025 version** of the GS1 specification.
|
|
64
|
+
|
|
65
|
+
## About GS1 Barcodes
|
|
66
|
+
|
|
67
|
+
GS1 barcodes can contain comprehensive product information including:
|
|
68
|
+
|
|
69
|
+
* GTIN (Global Trade Item Number, formerly UPC or EAN)
|
|
70
|
+
* Weight or dimensions
|
|
71
|
+
* Price
|
|
72
|
+
* Lot/batch code
|
|
73
|
+
* Manufacturing date
|
|
74
|
+
* Expiration date
|
|
75
|
+
* And much more
|
|
76
|
+
|
|
77
|
+
### About the Structure of GS1 Barcodes
|
|
78
|
+
|
|
79
|
+
A GS1 barcode is a concatenation of *data elements*. Each element starts with an *application identifier* (AI), a two to four digit number, followed by the actual information.
|
|
80
|
+
|
|
81
|
+
A *data element* is delimited by:
|
|
82
|
+
|
|
83
|
+
* The end of the barcode
|
|
84
|
+
* A fixed character count specification
|
|
85
|
+
* A special FNC1 character
|
|
86
|
+
|
|
87
|
+
The *application identifiers* and their properties are described in the third chapter of the GS1 General Specifications.
|
|
88
|
+
|
|
89
|
+
The GS1 barcode begins with a *symbology identifier* (a three-character sequence denoting the barcode type), followed by an arbitrary number of *data elements*. The parser decomposes this string into its individual elements.
|
|
90
|
+
|
|
91
|
+
## Use Case
|
|
92
|
+
|
|
93
|
+
Your application receives a GS1 barcode as a string from a scanning device:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
]C101040123456789011715012910ABC1233932978471131030005253922471142127649716
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The library extracts and parses the data into structured elements:
|
|
100
|
+
|
|
101
|
+
| AI | Title | Contents | Unit/Currency |
|
|
102
|
+
|:---|:------|:---------|:--------------|
|
|
103
|
+
| 01 | GTIN | 04012345678901 | |
|
|
104
|
+
| 17 | USE BY OR EXPIRY | 2015-01-29 | |
|
|
105
|
+
| 10 | BATCH/LOT | ABC123 | |
|
|
106
|
+
| 3932 | PRICE | 47.11 | 978 |
|
|
107
|
+
| 3103 | NET WEIGHT (kg) | 0.525 | KGM |
|
|
108
|
+
| 3922 | PRICE | 47.11 | |
|
|
109
|
+
| 421 | SHIP TO POST | 49716 | 276 |
|
|
110
|
+
|
|
111
|
+
## How to Use It
|
|
112
|
+
|
|
113
|
+
### ESModule Usage
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { GS1Parser } from '@valentynb/gs1-parser';
|
|
117
|
+
|
|
118
|
+
const gs1Parser = new GS1Parser(
|
|
119
|
+
{
|
|
120
|
+
lotMaxLength: 20 // If not specified, no limit is applied, except the one in the GS1 specs
|
|
121
|
+
fncChar: String.fromCodePoint(29); // If not specified, the GS char is used
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
const barcodeString = document.getElementById("barcode").value;
|
|
127
|
+
// returns a DecodeResult object or throws an Error in case of parsing errors
|
|
128
|
+
const result = gs1Parser.decode(barcodeString);
|
|
129
|
+
|
|
130
|
+
console.log(result.codeName); // e.g., "GS1-128"
|
|
131
|
+
console.log(result.denormalized); // Full barcode with parentheses
|
|
132
|
+
console.log(result.data); // Dictionary of parsed elements
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error('Barcode parsing failed:', error);
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### CommonJS Usage
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
const { parseBarcode } = require('@valentynb/gs1-parser');
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
const result = parseBarcode(barcodeString);
|
|
145
|
+
// Process result...
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error('Barcode parsing failed:', error);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### TypeScript Usage
|
|
152
|
+
|
|
153
|
+
The library is written in TypeScript and includes full type definitions:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { GS1Parser, BarcodeResult, ParsedElement } from '@valentynb/gs1-parser';
|
|
157
|
+
|
|
158
|
+
const gs1Parser = new GS1Parser(
|
|
159
|
+
{
|
|
160
|
+
lotMaxLength: 20 // If not specified, no limit is applied, except the one in the GS1 specs
|
|
161
|
+
fncChar: String.fromCodePoint(29); // If not specified, the GS char is used
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
const result: BarcodeResult = gs1Parser.decode(barcodeString);
|
|
167
|
+
|
|
168
|
+
result.data.values().forEach((item: ParsedElement) => {
|
|
169
|
+
console.log(`AI: ${item.ai}`);
|
|
170
|
+
console.log(`Title: ${item.dataTitle}`);
|
|
171
|
+
console.log(`Data: ${item.data}`);
|
|
172
|
+
console.log(`Unit: ${item.unit || 'N/A'}`);
|
|
173
|
+
});
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.error('Error:', error);
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Limitations
|
|
180
|
+
|
|
181
|
+
The `decode()` method does not perform plausibility checks (as of now). If the barcode contains invalid data (e.g., an invalid GTIN or ISO code), the function will return this invalid content without validation.
|
|
182
|
+
|
|
183
|
+
## API Reference
|
|
184
|
+
|
|
185
|
+
### `GS1Parser.decode(barcode: string): BarcodeResult`
|
|
186
|
+
|
|
187
|
+
Parses a GS1 barcode string and returns structured data.
|
|
188
|
+
|
|
189
|
+
**Returns:** `BarcodeResult` object containing:
|
|
190
|
+
- `codeName` (string): Barcode type identifier (e.g., "GS1-128", "GS1-DataMatrix")
|
|
191
|
+
- `data` (Partial<Record<GS1Field, ParsedElement>>): Dictionary of parsed data elements
|
|
192
|
+
- `denormalized` (string): The original barcode in human readable form, with parentheses surrounding each AI
|
|
193
|
+
|
|
194
|
+
**ParsedCodeItem structure:**
|
|
195
|
+
- `ai` (string): Application identifier
|
|
196
|
+
- `data` (string | number | Date): The actual content
|
|
197
|
+
- `dataTitle` (string): Description of the data element
|
|
198
|
+
- `dataString` (string): The substring that is being parsed
|
|
199
|
+
- `unit` (string | undefined): Unit of measurement, country code, or currency (ISO codes)
|
|
200
|
+
|
|
201
|
+
## About Barcode Scanning Devices
|
|
202
|
+
|
|
203
|
+
GS1 barcodes are typically scanned using hardware barcode scanners configured as HID (Human Interface Device) keyboards. This works well for most characters but presents challenges with the FNC1 character.
|
|
204
|
+
|
|
205
|
+
### The FNC1 Character
|
|
206
|
+
|
|
207
|
+
The FNC1 is a non-printable control character used to delimit GS1 Element Strings of variable length.
|
|
208
|
+
|
|
209
|
+
GS1 DataMatrix and GS1 QR Code use ASCII Group Separator (GS, ASCII 29, 0x1D, Unicode U+001D) as FNC1.
|
|
210
|
+
|
|
211
|
+
Since this character isn't on standard keyboards, scanners send control sequences as replacements. The canonical sequence is `Ctrl + ]`.
|
|
212
|
+
|
|
213
|
+
**Important:** Keyboard layout matters! A scanner emulating a German keyboard may send `Ctrl + +` instead of `Ctrl + ]`, which can trigger browser zoom. You'll need to:
|
|
214
|
+
|
|
215
|
+
1. Identify the sequence your scanner sends
|
|
216
|
+
2. Catch and transform these keyboard events into proper group separators
|
|
217
|
+
|
|
218
|
+
### Key Press Detecting
|
|
219
|
+
|
|
220
|
+
To determine what control sequence your scanner sends, create a simple test page that logs keyboard events (`keyCode`, `charCode`, `which`) to the console when scanning test barcodes containing the GS character.
|
|
221
|
+
|
|
222
|
+
## Examples
|
|
223
|
+
|
|
224
|
+
Example usage and test barcodes are included in the repository, demonstrating:
|
|
225
|
+
|
|
226
|
+
* Basic parsing operations
|
|
227
|
+
* Handling different barcode formats (GS1-128, DataMatrix, QR Code)
|
|
228
|
+
* Working with FNC1 characters
|
|
229
|
+
* Building scanning applications
|
|
230
|
+
|
|
231
|
+
## What's New
|
|
232
|
+
|
|
233
|
+
This modernized version includes:
|
|
234
|
+
|
|
235
|
+
* **TypeScript**: Full TypeScript rewrite with complete type definitions
|
|
236
|
+
* **Dual Module Support**: Works with both ESModule (`import`) and CommonJS (`require`)
|
|
237
|
+
* **Updated Specification**: Complies with 2025 GS1 General Specifications
|
|
238
|
+
* **Reorganized Code**: Improved code structure and maintainability
|
|
239
|
+
* **Modern Build System**: Compatible with current JavaScript tooling
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
Copyright © 2014-2015 Peter Brockfeld (original version)
|
|
244
|
+
Copyright © 2025 Valentyn Blaha (This version)
|
|
245
|
+
|
|
246
|
+
See the LICENSE.md file for license rights and limitations (MIT).
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var r=(_,S)=>l(_,"name",{value:S,configurable:!0});var p=(_,S)=>{for(var E in S)l(_,E,{get:S[E],enumerable:!0})},b=(_,S,E,I)=>{if(S&&typeof S=="object"||typeof S=="function")for(let T of w(S))!B.call(_,T)&&T!==E&&l(_,T,{get:()=>S[T],enumerable:!(I=W(S,T))||I.enumerable});return _};var Q=_=>b(l({},"__esModule",{value:!0}),_);var y={};p(y,{GS1Parser:()=>h});module.exports=Q(y);var g={ai00:"sscc",ai01:"gtin",ai02:"content",ai10:"batch",ai11:"prodDate",ai12:"dueDate",ai13:"packDate",ai15:"bestBefore",ai16:"sellBy",ai17:"expDate",ai20:"variant",ai21:"serial",ai22:"hibcc",ai235:"tpx",ai240:"additionalProductID",ai241:"customerPartNumber",ai242:"madeToOrder",ai243:"packaging",ai250:"secondarySerialNumber",ai251:"refSource",ai253:"gdti",ai254:"glnExtension",ai255:"gcn",ai30:"variableCount",ai310:"netWeightKg0",ai3100:"netWeightKg0",ai3101:"netWeightKg1",ai3102:"netWeightKg2",ai3103:"netWeightKg3",ai3104:"netWeightKg4",ai3105:"netWeightKg5",ai3110:"lengthMeters0",ai3111:"lengthMeters1",ai3112:"lengthMeters2",ai3113:"lengthMeters3",ai3114:"lengthMeters4",ai3115:"lengthMeters5",ai3120:"widthMeters0",ai3121:"widthMeters1",ai3122:"widthMeters2",ai3123:"widthMeters3",ai3124:"widthMeters4",ai3125:"widthMeters5",ai3130:"heightMeters0",ai3131:"heightMeters1",ai3132:"heightMeters2",ai3133:"heightMeters3",ai3134:"heightMeters4",ai3135:"heightMeters5",ai3140:"areaSquareMeters0",ai3141:"areaSquareMeters1",ai3142:"areaSquareMeters2",ai3143:"areaSquareMeters3",ai3144:"areaSquareMeters4",ai3145:"areaSquareMeters5",ai3150:"netVolumeLiters0",ai3151:"netVolumeLiters1",ai3152:"netVolumeLiters2",ai3153:"netVolumeLiters3",ai3154:"netVolumeLiters4",ai3155:"netVolumeLiters5",ai3160:"netVolumeCubicMeters0",ai3161:"netVolumeCubicMeters1",ai3162:"netVolumeCubicMeters2",ai3163:"netVolumeCubicMeters3",ai3164:"netVolumeCubicMeters4",ai3165:"netVolumeCubicMeters5",ai3200:"netWeightLb0",ai3201:"netWeightLb1",ai3202:"netWeightLb2",ai3203:"netWeightLb3",ai3204:"netWeightLb4",ai3205:"netWeightLb5",ai3210:"lengthInches0",ai3211:"lengthInches1",ai3212:"lengthInches2",ai3213:"lengthInches3",ai3214:"lengthInches4",ai3215:"lengthInches5",ai3220:"lengthFeet0",ai3221:"lengthFeet1",ai3222:"lengthFeet2",ai3223:"lengthFeet3",ai3224:"lengthFeet4",ai3225:"lengthFeet5",ai3230:"lengthYards0",ai3231:"lengthYards1",ai3232:"lengthYards2",ai3233:"lengthYards3",ai3234:"lengthYards4",ai3235:"lengthYards5",ai3240:"widthInches0",ai3241:"widthInches1",ai3242:"widthInches2",ai3243:"widthInches3",ai3244:"widthInches4",ai3245:"widthInches5",ai3250:"widthFeet0",ai3251:"widthFeet1",ai3252:"widthFeet2",ai3253:"widthFeet3",ai3254:"widthFeet4",ai3255:"widthFeet5",ai3260:"widthYards0",ai3261:"widthYards1",ai3262:"widthYards2",ai3263:"widthYards3",ai3264:"widthYards4",ai3265:"widthYards5",ai3270:"heightInches0",ai3271:"heightInches1",ai3272:"heightInches2",ai3273:"heightInches3",ai3274:"heightInches4",ai3275:"heightInches5",ai3280:"heightFeet0",ai3281:"heightFeet1",ai3282:"heightFeet2",ai3283:"heightFeet3",ai3284:"heightFeet4",ai3285:"heightFeet5",ai3290:"heightYards0",ai3291:"heightYards1",ai3292:"heightYards2",ai3293:"heightYards3",ai3294:"heightYards4",ai3295:"heightYards5",ai3300:"grossWeightKg0",ai3301:"grossWeightKg1",ai3302:"grossWeightKg2",ai3303:"grossWeightKg3",ai3304:"grossWeightKg4",ai3305:"grossWeightKg5",ai3310:"lengthMetersLog0",ai3311:"lengthMetersLog1",ai3312:"lengthMetersLog2",ai3313:"lengthMetersLog3",ai3314:"lengthMetersLog4",ai3315:"lengthMetersLog5",ai3320:"widthMetersLog0",ai3321:"widthMetersLog1",ai3322:"widthMetersLog2",ai3323:"widthMetersLog3",ai3324:"widthMetersLog4",ai3325:"widthMetersLog5",ai3330:"heightMetersLog0",ai3331:"heightMetersLog1",ai3332:"heightMetersLog2",ai3333:"heightMetersLog3",ai3334:"heightMetersLog4",ai3335:"heightMetersLog5",ai3340:"areaSquareInches0",ai3341:"areaSquareInches1",ai3342:"areaSquareInches2",ai3343:"areaSquareInches3",ai3344:"areaSquareInches4",ai3345:"areaSquareInches5",ai3350:"areaSquareFeet0",ai3351:"areaSquareFeet1",ai3352:"areaSquareFeet2",ai3353:"areaSquareFeet3",ai3354:"areaSquareFeet4",ai3355:"areaSquareFeet5",ai3360:"areaSquareYards0",ai3361:"areaSquareYards1",ai3362:"areaSquareYards2",ai3363:"areaSquareYards3",ai3364:"areaSquareYards4",ai3365:"areaSquareYards5",ai3370:"areaSquareMetersLog0",ai3371:"areaSquareMetersLog1",ai3372:"areaSquareMetersLog2",ai3373:"areaSquareMetersLog3",ai3374:"areaSquareMetersLog4",ai3375:"areaSquareMetersLog5",ai3400:"netWeightOunces0",ai3401:"netWeightOunces1",ai3402:"netWeightOunces2",ai3403:"netWeightOunces3",ai3404:"netWeightOunces4",ai3405:"netWeightOunces5",ai3410:"netVolumeQuarts0",ai3411:"netVolumeQuarts1",ai3412:"netVolumeQuarts2",ai3413:"netVolumeQuarts3",ai3414:"netVolumeQuarts4",ai3415:"netVolumeQuarts5",ai3420:"netVolumeGallons0",ai3421:"netVolumeGallons1",ai3422:"netVolumeGallons2",ai3423:"netVolumeGallons3",ai3424:"netVolumeGallons4",ai3425:"netVolumeGallons5",ai3430:"volumeCubicInches0",ai3431:"volumeCubicInches1",ai3432:"volumeCubicInches2",ai3433:"volumeCubicInches3",ai3434:"volumeCubicInches4",ai3435:"volumeCubicInches5",ai3440:"volumeCubicFeet0",ai3441:"volumeCubicFeet1",ai3442:"volumeCubicFeet2",ai3443:"volumeCubicFeet3",ai3444:"volumeCubicFeet4",ai3445:"volumeCubicFeet5",ai3450:"volumeCubicYards0",ai3451:"volumeCubicYards1",ai3452:"volumeCubicYards2",ai3453:"volumeCubicYards3",ai3454:"volumeCubicYards4",ai3455:"volumeCubicYards5",ai3460:"volumeCubicMetersLog0",ai3461:"volumeCubicMetersLog1",ai3462:"volumeCubicMetersLog2",ai3463:"volumeCubicMetersLog3",ai3464:"volumeCubicMetersLog4",ai3465:"volumeCubicMetersLog5",ai3500:"grossWeightLb0",ai3501:"grossWeightLb1",ai3502:"grossWeightLb2",ai3503:"grossWeightLb3",ai3504:"grossWeightLb4",ai3505:"grossWeightLb5",ai3510:"lengthInchesLog0",ai3511:"lengthInchesLog1",ai3512:"lengthInchesLog2",ai3513:"lengthInchesLog3",ai3514:"lengthInchesLog4",ai3515:"lengthInchesLog5",ai3520:"lengthFeetLog0",ai3521:"lengthFeetLog1",ai3522:"lengthFeetLog2",ai3523:"lengthFeetLog3",ai3524:"lengthFeetLog4",ai3525:"lengthFeetLog5",ai3530:"lengthYardsLog0",ai3531:"lengthYardsLog1",ai3532:"lengthYardsLog2",ai3533:"lengthYardsLog3",ai3534:"lengthYardsLog4",ai3535:"lengthYardsLog5",ai3540:"widthInchesLog0",ai3541:"widthInchesLog1",ai3542:"widthInchesLog2",ai3543:"widthInchesLog3",ai3544:"widthInchesLog4",ai3545:"widthInchesLog5",ai3550:"widthFeetLog0",ai3551:"widthFeetLog1",ai3552:"widthFeetLog2",ai3553:"widthFeetLog3",ai3554:"widthFeetLog4",ai3555:"widthFeetLog5",ai3560:"widthYardsLog0",ai3561:"widthYardsLog1",ai3562:"widthYardsLog2",ai3563:"widthYardsLog3",ai3564:"widthYardsLog4",ai3565:"widthYardsLog5",ai3570:"heightInchesLog0",ai3571:"heightInchesLog1",ai3572:"heightInchesLog2",ai3573:"heightInchesLog3",ai3574:"heightInchesLog4",ai3575:"heightInchesLog5",ai3580:"heightFeetLog0",ai3581:"heightFeetLog1",ai3582:"heightFeetLog2",ai3583:"heightFeetLog3",ai3584:"heightFeetLog4",ai3585:"heightFeetLog5",ai3590:"heightYardsLog0",ai3591:"heightYardsLog1",ai3592:"heightYardsLog2",ai3593:"heightYardsLog3",ai3594:"heightYardsLog4",ai3595:"heightYardsLog5",ai3600:"grossWeightOunces0",ai3601:"grossWeightOunces1",ai3602:"grossWeightOunces2",ai3603:"grossWeightOunces3",ai3604:"grossWeightOunces4",ai3605:"grossWeightOunces5",ai3610:"netVolumeFluidOunces0",ai3611:"netVolumeFluidOunces1",ai3612:"netVolumeFluidOunces2",ai3613:"netVolumeFluidOunces3",ai3614:"netVolumeFluidOunces4",ai3615:"netVolumeFluidOunces5",ai3620:"grossVolumeQuarts0",ai3621:"grossVolumeQuarts1",ai3622:"grossVolumeQuarts2",ai3623:"grossVolumeQuarts3",ai3624:"grossVolumeQuarts4",ai3625:"grossVolumeQuarts5",ai3630:"grossVolumeGallons0",ai3631:"grossVolumeGallons1",ai3632:"grossVolumeGallons2",ai3633:"grossVolumeGallons3",ai3634:"grossVolumeGallons4",ai3635:"grossVolumeGallons5",ai3640:"volumeCubicInchesLog0",ai3641:"volumeCubicInchesLog1",ai3642:"volumeCubicInchesLog2",ai3643:"volumeCubicInchesLog3",ai3644:"volumeCubicInchesLog4",ai3645:"volumeCubicInchesLog5",ai3650:"volumeCubicFeetLog0",ai3651:"volumeCubicFeetLog1",ai3652:"volumeCubicFeetLog2",ai3653:"volumeCubicFeetLog3",ai3654:"volumeCubicFeetLog4",ai3655:"volumeCubicFeetLog5",ai3660:"volumeCubicYardsLog0",ai3661:"volumeCubicYardsLog1",ai3662:"volumeCubicYardsLog2",ai3663:"volumeCubicYardsLog3",ai3664:"volumeCubicYardsLog4",ai3665:"volumeCubicYardsLog5",ai37:"count",ai3900:"amountPayable0",ai3901:"amountPayable1",ai3902:"amountPayable2",ai3903:"amountPayable3",ai3904:"amountPayable4",ai3905:"amountPayable5",ai3910:"amountPayableISO0",ai3911:"amountPayableISO1",ai3912:"amountPayableISO2",ai3913:"amountPayableISO3",ai3914:"amountPayableISO4",ai3915:"amountPayableISO5",ai3920:"price0",ai3921:"price1",ai3922:"price2",ai3923:"price3",ai3930:"priceISO0",ai3931:"priceISO1",ai3932:"priceISO2",ai3933:"priceISO3",ai3940:"percentDiscount0",ai3941:"percentDiscount1",ai3942:"percentDiscount2",ai3943:"percentDiscount3",ai3950:"pricePerUnitMeasure0",ai3951:"pricePerUnitMeasure1",ai3952:"pricePerUnitMeasure2",ai3953:"pricePerUnitMeasure3",ai3954:"pricePerUnitMeasure4",ai3955:"pricePerUnitMeasure5",ai400:"orderNumber",ai401:"ginc",ai402:"gsin",ai403:"route",ai410:"shipTo",ai411:"billTo",ai412:"purchaseFrom",ai413:"shipFor",ai414:"locNo",ai415:"payTo",ai416:"prodServLoc",ai417:"party",ai420:"shipToPost",ai421:"shipToPostISO",ai422:"origin",ai423:"countryInitialProcess",ai424:"countryProcess",ai425:"countryDisassembly",ai426:"countryFullProcess",ai427:"originSubdivision",ai7001:"nsn",ai7002:"meatCut",ai7003:"expirationDateTime",ai7004:"activePotency",ai7005:"catchArea",ai7006:"firstFreezeDate",ai7007:"harvestDate",ai7008:"aquaticSpecies",ai7009:"fishingGearType",ai7010:"prodMethod",ai7020:"refurbLot",ai7021:"funcStat",ai7022:"revStat",ai7023:"giaiAssembly",ai7030:"processor",ai7031:"processor2",ai7032:"processor3",ai7033:"processor4",ai7034:"processor5",ai7035:"processor6",ai7036:"processor7",ai7037:"processor8",ai7038:"processor9",ai7039:"processor10",ai7040:"uicExt",ai8001:"rollProducts",ai8002:"cmtNo",ai8003:"grai",ai8004:"giai",ai8005:"pricePerUnit",ai8006:"itip",ai8007:"iban",ai8008:"prodTime",ai8009:"opticalSensor",ai8010:"cpid",ai8011:"cpidSerial",ai8012:"version",ai8013:"gmn",ai8017:"gsrnProvider",ai8018:"gsrnRecipient",ai8019:"srin",ai8020:"refNo",ai8026:"itipContent",ai8030:"coupon",ai8110:"couponExtended",ai8111:"couponExtended2",ai8112:"couponExtended3",ai8200:"productURL",ai90:"internal1",ai91:"internal2",ai92:"internal3",ai93:"internal4",ai94:"internal5",ai95:"internal6",ai96:"internal7",ai97:"internal8",ai98:"internal9",ai99:"internal10"};var M=String.fromCodePoint(29),o=/^\d+$/;var A=class extends Error{static{r(this,"InternalError")}constructor(S,E){super(S),this.name="InternalError",this.code=S,this.ex=E}ex;code},O=class extends Error{static{r(this,"InvalidAiError")}constructor(S,E){let I;S?I=`Invalid AI identifier "${E}" after "${S}"`:I=`Invalid first AI identifier "${E}"`,super(I),this.name="InvalidAiError"}},G=class extends Error{static{r(this,"BarcodeError")}constructor(S,E,I){super(I),this.name="BarcodeError",this.num=S,this.code=E,this.des=I}num;code;des},H=class{static{r(this,"ParsedElementClass")}ai;dataTitle;data;dataString;unit;constructor(S,E,I){switch(this.ai=S,this.dataTitle=E,this.unit="",this.dataString="",I){case"S":this.data="";break;case"N":this.data=0;break;case"D":this.data=new Date,this.data.setHours(0,0,0,0);break;default:this.data="";break}}},C=class{constructor(S,E,I={}){this.codeName=S;this.denormalized=E;this.data=I}static{r(this,"DecodeResult")}};function m(_,S){let E=_,I=E.slice(0,1);for(;I===S;)E=E.slice(1),I=E.slice(0,1);return E}r(m,"cleanCodestring");function F(_,S,E){if(S<0||S>11)return!1;let I=S;E===0&&I++;let T=new Date(_,I,E);return T.getFullYear()===_&&T.getMonth()===S&&(T.getDate()===E||E===0)}r(F,"checkValidDate");function D(_,S){let E=_.length-S,I=_.slice(0,E)+"."+_.slice(E);try{return Number.parseFloat(I)}catch(T){throw new A("36",T)}}r(D,"parseFloatingPoint");function u(_,S,E){let I=new H(_,S,"D"),T=_.length,a=E.slice(T,T+6),e=0,L=0,R=0;try{e=Number.parseInt(a.slice(0,2),10)}catch(N){throw new A("33",N)}try{L=Number.parseInt(a.slice(2,4),10)-1}catch(N){throw new A("34",N)}try{R=Number.parseInt(a.slice(4,6),10)}catch(N){throw new A("35",N)}if(e>50?e=e+1900:e=e+2e3,!F(e,L,R))throw new G(7,"36",`Invalid date "${a}" for AI "${_}".`);return R===0&&L++,I.data.setFullYear(e,L,R),I.dataString=a,{element:I,codestring:E.slice(T+6,E.length)}}r(u,"parseDate");function s(_,S,E,I,T=!1){let a=new H(_,S,"S"),e=_.length,L=I.slice(e,E+e);if(L.length<E)throw new G(9,"37",`Data length ${L.length} is less than expected length ${E} for AI "${_}".`);if(T&&!o.test(L))throw new G(11,"39",`Numeric data expected for AI "${_}", but got "${L}".`);a.data=L,a.dataString=L;let R=I.slice(E+e,I.length);return{element:a,codestring:R}}r(s,"parseFixedLength");function t(_,S,E,I,T,a=!1){let e=new H(_,S,"S"),L=_.length,R=E.indexOf(I),N="";if(R===-1?T&&T>0?(e.data=E.slice(L,T+L),N=E.replace(_+e.data,"")):e.data=E.slice(L,E.length):(e.data=E.slice(L,R),N=E.slice(R+1,E.length)),e.data==="")throw new G(10,"38",`Variable length data for AI "${_}" is empty.`);if(a&&!o.test(e.data))throw new G(11,"39",`Numeric data expected for AI "${_}", but got "${e.data}".`);return e.dataString=e.data,{element:e,codestring:N}}r(t,"parseVariableLength");function c(_,S,E,I,T,a){let e=new H(_+S,E,"N"),L=_.length+1,R=T.indexOf(a),N=Number.parseInt(S,10),n="",U="";return R===-1?n=T.slice(L,T.length):(n=T.slice(L,R),U=T.slice(R+1,T.length)),e.data=D(n,N),e.dataString=n,e.unit=I,{element:e,codestring:U}}r(c,"parseVariableLengthMeasure");function i(_,S,E,I,T){let a=new H(_+S,E,"N"),e=_.length+1,L=Number.parseInt(S,10),R=T.slice(e,e+6);a.data=D(R,L),a.dataString=R,a.unit=I;let N=T.slice(e+6,T.length);return{element:a,codestring:N}}r(i,"parseFixedLengthMeasure");function P(_,S,E,I,T){let a=new H(_+S,E,"N"),e=_.length+1,L=I.indexOf(T),R=Number.parseInt(S,10),N="",n="",U="";return L===-1?N=I.slice(e,I.length):(N=I.slice(e,L),U=I.slice(L+1,I.length)),n=N.slice(3,N.length),a.data=D(n,R),a.dataString=n,a.unit=N.slice(0,3),{element:a,codestring:U}}r(P,"parseVariableLengthWithISONumbers");function V(_,S,E,I){let T=new H(_,S,"S"),a=_.length,e=E.indexOf(I),L="",R="";return e===-1?L=E.slice(a,E.length):(L=E.slice(a,e),R=E.slice(e+1,E.length)),T.data=L.slice(3,L.length),T.unit=L.slice(0,3),T.dataString=L,{element:T,codestring:R}}r(V,"parseVariableLengthWithISOChars");function f(_,S,E){E||(E=M);let I=_.slice(0,1),T=_.slice(1,2),a="",e="";switch(I){case"0":switch(T){case"0":return s("00","SSCC",18,_,!0);case"1":return s("01","GTIN",14,_,!0);case"2":return s("02","CONTENT",14,_);case"3":return s("03","MTO GTIN",14,_);default:throw new O("0",T)}case"1":switch(T){case"0":return t("10","BATCH/LOT",_,E,S??20);case"1":return u("11","PROD DATE",_);case"2":return u("12","DUE DATE",_);case"3":return u("13","PACK DATE",_);case"5":return u("15","BEST BEFORE or BEST BY",_);case"6":return u("16","SELL BY",_);case"7":return u("17","USE BY OR EXPIRY",_);default:throw new O("1",T)}case"2":switch(T){case"0":return s("20","VARIANT",2,_);case"1":return t("21","SERIAL",_,E,S??20);case"2":return t("22","CPV",_,E,20);case"3":switch(a=_.slice(2,3),a){case"5":return t("235","TPX",_,E,28);default:throw new O("23",a)}case"4":switch(a=_.slice(2,3),a){case"0":return t("240","ADDITIONAL ID",_,E,30);case"1":return t("241","CUST. PART NO.",_,E,30);case"2":return t("242","MTO VARIANT",_,E,6);case"3":return t("243","PCN",_,E,20);default:throw new O("24",a)}case"5":switch(a=_.slice(2,3),a){case"0":return t("250","SECONDARY SERIAL",_,E,30);case"1":return t("251","REF. TO SOURCE",_,E,30);case"3":return t("253","GDTI",_,E,42);case"4":return t("254","GLN EXTENSION COMPONENT",_,E,20);case"5":return t("255","GCN",_,E,37);default:throw new O("25",a)}default:throw new O("2",T)}case"3":switch(T){case"0":return t("30","VAR. COUNT",_,E,8);case"1":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("310",e,"NET WEIGHT (kg)","KGM",_);case"1":return i("311",e,"LENGTH (m)","MTR",_);case"2":return i("312",e,"WIDTH (m)","MTR",_);case"3":return i("313",e,"HEIGHT (m)","MTR",_);case"4":return i("314",e,"AREA (m2)","MTK",_);case"5":return i("315",e,"NET VOLUME (l)","LTR",_);case"6":return i("316",e,"NET VOLUME (m3)","MTQ",_);default:throw new O("31",a)}case"2":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("320",e,"NET WEIGHT (lb)","LBR",_);case"1":return i("321",e,"LENGTH (i)","INH",_);case"2":return i("322",e,"LENGTH (f)","FOT",_);case"3":return i("323",e,"LENGTH (y)","YRD",_);case"4":return i("324",e,"WIDTH (i)","INH",_);case"5":return i("325",e,"WIDTH (f)","FOT",_);case"6":return i("326",e,"WIDTH (y)","YRD",_);case"7":return i("327",e,"HEIGHT (i)","INH",_);case"8":return i("328",e,"HEIGHT (f)","FOT",_);case"9":return i("329",e,"HEIGHT (y)","YRD",_);default:throw new O("32",a)}case"3":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("330",e,"GROSS WEIGHT (kg)","KGM",_);case"1":return i("331",e,"LENGTH (m), log","MTR",_);case"2":return i("332",e,"WIDTH (m), log","MTR",_);case"3":return i("333",e,"HEIGHT (m), log","MTR",_);case"4":return i("334",e,"AREA (m2), log","MTK",_);case"5":return i("335",e,"VOLUME (l), log","LTR",_);case"6":return i("336",e,"VOLUME (m3), log","MTQ",_);case"7":return i("337",e,"KG PER m\xB2","28",_);default:throw new O("33",a)}case"4":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("340",e,"GROSS WEIGHT (lb)","LBR",_);case"1":return i("341",e,"LENGTH (i), log","INH",_);case"2":return i("342",e,"LENGTH (f), log","FOT",_);case"3":return i("343",e,"LENGTH (y), log","YRD",_);case"4":return i("344",e,"WIDTH (i), log","INH",_);case"5":return i("345",e,"WIDTH (f), log","FOT",_);case"6":return i("346",e,"WIDTH (y), log","YRD",_);case"7":return i("347",e,"HEIGHT (i), log","INH",_);case"8":return i("348",e,"HEIGHT (f), log","FOT",_);case"9":return i("349",e,"HEIGHT (y), log","YRD",_);default:throw new O("33",a)}case"5":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("350",e,"AREA (i2)","INK",_);case"1":return i("351",e,"AREA (f2)","FTK",_);case"2":return i("352",e,"AREA (y2)","YDK",_);case"3":return i("353",e,"AREA (i2), log","INK",_);case"4":return i("354",e,"AREA (f2), log","FTK",_);case"5":return i("355",e,"AREA (y2), log","YDK",_);case"6":return i("356",e,"NET WEIGHT (t)","APZ",_);case"7":return i("357",e,"NET VOLUME (oz)","ONZ",_);default:throw new O("35",a)}case"6":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("360",e,"NET VOLUME (q)","QT",_);case"1":return i("361",e,"NET VOLUME (g)","GLL",_);case"2":return i("362",e,"VOLUME (q), log","QT",_);case"3":return i("363",e,"VOLUME (g), log","GLL",_);case"4":return i("364",e,"VOLUME (i3)","INQ",_);case"5":return i("365",e,"VOLUME (f3)","FTQ",_);case"6":return i("366",e,"VOLUME (y3)","YDQ",_);case"7":return i("367",e,"VOLUME (i3), log","INQ",_);case"8":return i("368",e,"VOLUME (f3), log","FTQ",_);case"9":return i("369",e,"VOLUME (y3), log","YDQ",_);default:throw new O("36",a)}case"7":return t("37","COUNT",_,E,8);case"9":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return c("390",e,"AMOUNT","",_,E);case"1":return P("391",e,"AMOUNT",_,E);case"2":return c("392",e,"PRICE","",_,E);case"3":return P("393",e,"PRICE",_,E);default:throw new O("39",a)}default:throw new O("3",T)}case"4":switch(T){case"0":switch(a=_.slice(2,3),a){case"0":return t("400","ORDER NUMBER",_,E,30);case"1":return t("401","GINC",_,E);case"2":return t("402","GSIN",_,E,17);case"3":return t("403","ROUTE",_,E,30);default:throw new O("40",a)}case"1":switch(a=_.slice(2,3),a){case"0":return s("410","SHIP TO LOC",13,_);case"1":return s("411","BILL TO",13,_);case"2":return s("412","PURCHASE FROM",13,_);case"3":return s("413","SHIP FOR LOC",13,_);case"4":return s("414","LOC NO",13,_);case"5":return s("415","PAY TO",13,_);case"6":return s("416","PROD/SERV LOC",13,_);case"7":return s("417","PARTY",13,_);default:throw new O("41",a)}case"2":switch(a=_.slice(2,3),a){case"0":return t("420","SHIP TO POST",_,E,20);case"1":return V("421","SHIP TO POST",_,E);case"2":return s("422","ORIGIN",3,_);case"3":return t("423","COUNTRY - INITIAL PROCESS.",_,E,15);case"4":return s("424","COUNTRY - PROCESS.",3,_);case"5":return s("425","COUNTRY - DISASSEMBLY",3,_);case"6":return s("426","COUNTRY - FULL PROCESS",3,_);case"7":return t("427","ORIGIN SUBDIVISION",_,E,3);default:throw new O("42",a)}default:throw new O("4",T)}case"7":switch(T){case"0":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"1":return t("7001","NSN",_,E,13);case"2":return t("7002","MEAT CUT",_,E);case"3":return t("7003","EXPIRY TIME",_,E,10);case"4":return t("7004","ACTIVE POTENCY",_,E,6);default:throw new O("70",a)}case"3":return V("703"+e,"PROCESSOR # "+e,_,E);default:throw new O("70",a)}case"1":switch(a=_.slice(2,3),a){case"0":return t("710","NHRN PZN",_,E);case"1":return t("711","NHRN CIP",_,E);case"2":return t("712","NHRN CN",_,E);case"3":return t("713","NHRN DRN",_,E);default:throw new O("71",a)}default:throw new O("7",T)}case"8":switch(T){case"0":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"1":return t("8001","DIMENSIONS",_,E,14);case"2":return t("8002","CMT No",_,E);case"3":return t("8003","GRAI",_,E);case"4":return t("8004","GIAI",_,E);case"5":return t("8005","PRICE PER UNIT",_,E,6);case"6":return t("8006","GCTIN",_,E,18);case"7":return t("8007","IBAN",_,E);case"8":return t("8008","PROD TIME",_,E,12);default:throw new O("800",e)}case"1":switch(e){case"0":return t("8010","CPID",_,E);case"1":return t("8011","CPID SERIAL",_,E);case"7":return t("8017","GSRN - PROVIDER",_,E,18);case"8":return t("8018","GSRN - RECIPIENT",_,E,18,!0);case"9":return t("8019","SRIN",_,E,void 0,!0);default:throw new O("801",e)}case"2":switch(e){case"0":return t("8020","REF No",_,E);default:throw new O("802",e)}default:throw new O("80",a)}case"1":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"0":return t("8100","-",_,E,6);case"1":return t("8101","-",_,E,10);case"2":return t("8102","-",_,E,2);default:throw new O("810",e)}case"1":switch(e){case"0":return t("8110","-",_,E);default:throw new O("811",e)}default:throw new O("81",a)}case"2":switch(a=_.slice(2,3),a){case"0":return t("8200","PRODUCT URL",_,E);default:throw new O("82",a)}default:throw new O("8",T)}case"9":switch(T){case"0":return t("90","INTERNAL",_,E);case"1":return t("91","INTERNAL",_,E);case"2":return t("92","INTERNAL",_,E);case"3":return t("93","INTERNAL",_,E);case"4":return t("94","INTERNAL",_,E);case"5":return t("95","INTERNAL",_,E);case"6":return t("96","INTERNAL",_,E);case"7":return t("97","INTERNAL",_,E);case"8":return t("98","INTERNAL",_,E);case"9":return t("99","INTERNAL",_,E);default:throw new O("9",T)}default:throw new O("",I)}}r(f,"identifyAI");function Y(_,S,E){if(!_||typeof _!="string")throw new G(2,"31","The barcode is empty or not a string.");let I=_.length,T={codeName:"",denormalized:"",parsedCodeItems:[]},a="",e=_.slice(0,3),L;switch(e){case"]C1":T.codeName="GS1-128",a=_.slice(3,I);break;case"]e0":T.codeName="GS1 DataBar",a=_.slice(3,I);break;case"]e1":case"]e2":T.codeName="GS1 Composite",a=_.slice(3,I);break;case"]d2":T.codeName="GS1 DataMatrix",a=_.slice(3,I);break;case"]Q3":T.codeName="GS1 QR Code",a=_.slice(3,I);break;default:T.codeName="",a=_;break}for(T.parsedCodeItems=[];a.length>0;)try{L=f(a,E),a=m(L.codestring,S),T.parsedCodeItems.push(L.element),T.denormalized+="("+L.element.ai+")"+L.element.dataString}catch(R){if(R instanceof A)v(R);else throw R}return T}r(Y,"parseBarcode");function v(_){switch(_.code){case"32":throw new G(6,32,"Invalid normal AI.");case"33":throw new G(7,33,"L'anno nella data non \xE8 valido.");case"34":throw new G(7,34,"Il mese nella data non \xE8 valido.");case"36":throw new G(8,36,"Numeri non validi");default:throw _}}r(v,"handleInternalError");var h=class{static{r(this,"GS1Parser")}fncChar;lotLen;constructor(S){this.fncChar=S?.fncChar||M,this.lotLen=S?.lotMaxLength}decode(S){let E=S.replaceAll("(",this.fncChar).replaceAll(")","");E.startsWith(this.fncChar)&&(E=E.slice(1));let I=Y(E,this.fncChar,this.lotLen),T={};for(let a of I.parsedCodeItems){let e=g["ai"+a.ai];e&&(T[e]=a)}return new C(I.codeName,I.denormalized,T)}};0&&(module.exports={GS1Parser});
|
|
1
|
+
"use strict";var C=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var r=(_,I)=>C(_,"name",{value:I,configurable:!0});var p=(_,I)=>{for(var E in I)C(_,E,{get:I[E],enumerable:!0})},b=(_,I,E,S)=>{if(I&&typeof I=="object"||typeof I=="function")for(let t of w(I))!B.call(_,t)&&t!==E&&C(_,t,{get:()=>I[t],enumerable:!(S=W(I,t))||S.enumerable});return _};var Q=_=>b(C({},"__esModule",{value:!0}),_);var y={};p(y,{GS1Parser:()=>D});module.exports=Q(y);var m={ai00:"sscc",ai01:"gtin",ai02:"content",ai10:"batch",ai11:"prodDate",ai12:"dueDate",ai13:"packDate",ai15:"bestBefore",ai16:"sellBy",ai17:"expDate",ai20:"variant",ai21:"serial",ai22:"hibcc",ai235:"tpx",ai240:"additionalProductID",ai241:"customerPartNumber",ai242:"madeToOrder",ai243:"packaging",ai250:"secondarySerialNumber",ai251:"refSource",ai253:"gdti",ai254:"glnExtension",ai255:"gcn",ai30:"variableCount",ai310:"netWeightKg0",ai3100:"netWeightKg0",ai3101:"netWeightKg1",ai3102:"netWeightKg2",ai3103:"netWeightKg3",ai3104:"netWeightKg4",ai3105:"netWeightKg5",ai3110:"lengthMeters0",ai3111:"lengthMeters1",ai3112:"lengthMeters2",ai3113:"lengthMeters3",ai3114:"lengthMeters4",ai3115:"lengthMeters5",ai3120:"widthMeters0",ai3121:"widthMeters1",ai3122:"widthMeters2",ai3123:"widthMeters3",ai3124:"widthMeters4",ai3125:"widthMeters5",ai3130:"heightMeters0",ai3131:"heightMeters1",ai3132:"heightMeters2",ai3133:"heightMeters3",ai3134:"heightMeters4",ai3135:"heightMeters5",ai3140:"areaSquareMeters0",ai3141:"areaSquareMeters1",ai3142:"areaSquareMeters2",ai3143:"areaSquareMeters3",ai3144:"areaSquareMeters4",ai3145:"areaSquareMeters5",ai3150:"netVolumeLiters0",ai3151:"netVolumeLiters1",ai3152:"netVolumeLiters2",ai3153:"netVolumeLiters3",ai3154:"netVolumeLiters4",ai3155:"netVolumeLiters5",ai3160:"netVolumeCubicMeters0",ai3161:"netVolumeCubicMeters1",ai3162:"netVolumeCubicMeters2",ai3163:"netVolumeCubicMeters3",ai3164:"netVolumeCubicMeters4",ai3165:"netVolumeCubicMeters5",ai3200:"netWeightLb0",ai3201:"netWeightLb1",ai3202:"netWeightLb2",ai3203:"netWeightLb3",ai3204:"netWeightLb4",ai3205:"netWeightLb5",ai3210:"lengthInches0",ai3211:"lengthInches1",ai3212:"lengthInches2",ai3213:"lengthInches3",ai3214:"lengthInches4",ai3215:"lengthInches5",ai3220:"lengthFeet0",ai3221:"lengthFeet1",ai3222:"lengthFeet2",ai3223:"lengthFeet3",ai3224:"lengthFeet4",ai3225:"lengthFeet5",ai3230:"lengthYards0",ai3231:"lengthYards1",ai3232:"lengthYards2",ai3233:"lengthYards3",ai3234:"lengthYards4",ai3235:"lengthYards5",ai3240:"widthInches0",ai3241:"widthInches1",ai3242:"widthInches2",ai3243:"widthInches3",ai3244:"widthInches4",ai3245:"widthInches5",ai3250:"widthFeet0",ai3251:"widthFeet1",ai3252:"widthFeet2",ai3253:"widthFeet3",ai3254:"widthFeet4",ai3255:"widthFeet5",ai3260:"widthYards0",ai3261:"widthYards1",ai3262:"widthYards2",ai3263:"widthYards3",ai3264:"widthYards4",ai3265:"widthYards5",ai3270:"heightInches0",ai3271:"heightInches1",ai3272:"heightInches2",ai3273:"heightInches3",ai3274:"heightInches4",ai3275:"heightInches5",ai3280:"heightFeet0",ai3281:"heightFeet1",ai3282:"heightFeet2",ai3283:"heightFeet3",ai3284:"heightFeet4",ai3285:"heightFeet5",ai3290:"heightYards0",ai3291:"heightYards1",ai3292:"heightYards2",ai3293:"heightYards3",ai3294:"heightYards4",ai3295:"heightYards5",ai3300:"grossWeightKg0",ai3301:"grossWeightKg1",ai3302:"grossWeightKg2",ai3303:"grossWeightKg3",ai3304:"grossWeightKg4",ai3305:"grossWeightKg5",ai3310:"lengthMetersLog0",ai3311:"lengthMetersLog1",ai3312:"lengthMetersLog2",ai3313:"lengthMetersLog3",ai3314:"lengthMetersLog4",ai3315:"lengthMetersLog5",ai3320:"widthMetersLog0",ai3321:"widthMetersLog1",ai3322:"widthMetersLog2",ai3323:"widthMetersLog3",ai3324:"widthMetersLog4",ai3325:"widthMetersLog5",ai3330:"heightMetersLog0",ai3331:"heightMetersLog1",ai3332:"heightMetersLog2",ai3333:"heightMetersLog3",ai3334:"heightMetersLog4",ai3335:"heightMetersLog5",ai3340:"areaSquareInches0",ai3341:"areaSquareInches1",ai3342:"areaSquareInches2",ai3343:"areaSquareInches3",ai3344:"areaSquareInches4",ai3345:"areaSquareInches5",ai3350:"areaSquareFeet0",ai3351:"areaSquareFeet1",ai3352:"areaSquareFeet2",ai3353:"areaSquareFeet3",ai3354:"areaSquareFeet4",ai3355:"areaSquareFeet5",ai3360:"areaSquareYards0",ai3361:"areaSquareYards1",ai3362:"areaSquareYards2",ai3363:"areaSquareYards3",ai3364:"areaSquareYards4",ai3365:"areaSquareYards5",ai3370:"areaSquareMetersLog0",ai3371:"areaSquareMetersLog1",ai3372:"areaSquareMetersLog2",ai3373:"areaSquareMetersLog3",ai3374:"areaSquareMetersLog4",ai3375:"areaSquareMetersLog5",ai3400:"netWeightOunces0",ai3401:"netWeightOunces1",ai3402:"netWeightOunces2",ai3403:"netWeightOunces3",ai3404:"netWeightOunces4",ai3405:"netWeightOunces5",ai3410:"netVolumeQuarts0",ai3411:"netVolumeQuarts1",ai3412:"netVolumeQuarts2",ai3413:"netVolumeQuarts3",ai3414:"netVolumeQuarts4",ai3415:"netVolumeQuarts5",ai3420:"netVolumeGallons0",ai3421:"netVolumeGallons1",ai3422:"netVolumeGallons2",ai3423:"netVolumeGallons3",ai3424:"netVolumeGallons4",ai3425:"netVolumeGallons5",ai3430:"volumeCubicInches0",ai3431:"volumeCubicInches1",ai3432:"volumeCubicInches2",ai3433:"volumeCubicInches3",ai3434:"volumeCubicInches4",ai3435:"volumeCubicInches5",ai3440:"volumeCubicFeet0",ai3441:"volumeCubicFeet1",ai3442:"volumeCubicFeet2",ai3443:"volumeCubicFeet3",ai3444:"volumeCubicFeet4",ai3445:"volumeCubicFeet5",ai3450:"volumeCubicYards0",ai3451:"volumeCubicYards1",ai3452:"volumeCubicYards2",ai3453:"volumeCubicYards3",ai3454:"volumeCubicYards4",ai3455:"volumeCubicYards5",ai3460:"volumeCubicMetersLog0",ai3461:"volumeCubicMetersLog1",ai3462:"volumeCubicMetersLog2",ai3463:"volumeCubicMetersLog3",ai3464:"volumeCubicMetersLog4",ai3465:"volumeCubicMetersLog5",ai3500:"grossWeightLb0",ai3501:"grossWeightLb1",ai3502:"grossWeightLb2",ai3503:"grossWeightLb3",ai3504:"grossWeightLb4",ai3505:"grossWeightLb5",ai3510:"lengthInchesLog0",ai3511:"lengthInchesLog1",ai3512:"lengthInchesLog2",ai3513:"lengthInchesLog3",ai3514:"lengthInchesLog4",ai3515:"lengthInchesLog5",ai3520:"lengthFeetLog0",ai3521:"lengthFeetLog1",ai3522:"lengthFeetLog2",ai3523:"lengthFeetLog3",ai3524:"lengthFeetLog4",ai3525:"lengthFeetLog5",ai3530:"lengthYardsLog0",ai3531:"lengthYardsLog1",ai3532:"lengthYardsLog2",ai3533:"lengthYardsLog3",ai3534:"lengthYardsLog4",ai3535:"lengthYardsLog5",ai3540:"widthInchesLog0",ai3541:"widthInchesLog1",ai3542:"widthInchesLog2",ai3543:"widthInchesLog3",ai3544:"widthInchesLog4",ai3545:"widthInchesLog5",ai3550:"widthFeetLog0",ai3551:"widthFeetLog1",ai3552:"widthFeetLog2",ai3553:"widthFeetLog3",ai3554:"widthFeetLog4",ai3555:"widthFeetLog5",ai3560:"widthYardsLog0",ai3561:"widthYardsLog1",ai3562:"widthYardsLog2",ai3563:"widthYardsLog3",ai3564:"widthYardsLog4",ai3565:"widthYardsLog5",ai3570:"heightInchesLog0",ai3571:"heightInchesLog1",ai3572:"heightInchesLog2",ai3573:"heightInchesLog3",ai3574:"heightInchesLog4",ai3575:"heightInchesLog5",ai3580:"heightFeetLog0",ai3581:"heightFeetLog1",ai3582:"heightFeetLog2",ai3583:"heightFeetLog3",ai3584:"heightFeetLog4",ai3585:"heightFeetLog5",ai3590:"heightYardsLog0",ai3591:"heightYardsLog1",ai3592:"heightYardsLog2",ai3593:"heightYardsLog3",ai3594:"heightYardsLog4",ai3595:"heightYardsLog5",ai3600:"grossWeightOunces0",ai3601:"grossWeightOunces1",ai3602:"grossWeightOunces2",ai3603:"grossWeightOunces3",ai3604:"grossWeightOunces4",ai3605:"grossWeightOunces5",ai3610:"netVolumeFluidOunces0",ai3611:"netVolumeFluidOunces1",ai3612:"netVolumeFluidOunces2",ai3613:"netVolumeFluidOunces3",ai3614:"netVolumeFluidOunces4",ai3615:"netVolumeFluidOunces5",ai3620:"grossVolumeQuarts0",ai3621:"grossVolumeQuarts1",ai3622:"grossVolumeQuarts2",ai3623:"grossVolumeQuarts3",ai3624:"grossVolumeQuarts4",ai3625:"grossVolumeQuarts5",ai3630:"grossVolumeGallons0",ai3631:"grossVolumeGallons1",ai3632:"grossVolumeGallons2",ai3633:"grossVolumeGallons3",ai3634:"grossVolumeGallons4",ai3635:"grossVolumeGallons5",ai3640:"volumeCubicInchesLog0",ai3641:"volumeCubicInchesLog1",ai3642:"volumeCubicInchesLog2",ai3643:"volumeCubicInchesLog3",ai3644:"volumeCubicInchesLog4",ai3645:"volumeCubicInchesLog5",ai3650:"volumeCubicFeetLog0",ai3651:"volumeCubicFeetLog1",ai3652:"volumeCubicFeetLog2",ai3653:"volumeCubicFeetLog3",ai3654:"volumeCubicFeetLog4",ai3655:"volumeCubicFeetLog5",ai3660:"volumeCubicYardsLog0",ai3661:"volumeCubicYardsLog1",ai3662:"volumeCubicYardsLog2",ai3663:"volumeCubicYardsLog3",ai3664:"volumeCubicYardsLog4",ai3665:"volumeCubicYardsLog5",ai37:"count",ai3900:"amountPayable0",ai3901:"amountPayable1",ai3902:"amountPayable2",ai3903:"amountPayable3",ai3904:"amountPayable4",ai3905:"amountPayable5",ai3910:"amountPayableISO0",ai3911:"amountPayableISO1",ai3912:"amountPayableISO2",ai3913:"amountPayableISO3",ai3914:"amountPayableISO4",ai3915:"amountPayableISO5",ai3920:"price0",ai3921:"price1",ai3922:"price2",ai3923:"price3",ai3930:"priceISO0",ai3931:"priceISO1",ai3932:"priceISO2",ai3933:"priceISO3",ai3940:"percentDiscount0",ai3941:"percentDiscount1",ai3942:"percentDiscount2",ai3943:"percentDiscount3",ai3950:"pricePerUnitMeasure0",ai3951:"pricePerUnitMeasure1",ai3952:"pricePerUnitMeasure2",ai3953:"pricePerUnitMeasure3",ai3954:"pricePerUnitMeasure4",ai3955:"pricePerUnitMeasure5",ai400:"orderNumber",ai401:"ginc",ai402:"gsin",ai403:"route",ai410:"shipTo",ai411:"billTo",ai412:"purchaseFrom",ai413:"shipFor",ai414:"locNo",ai415:"payTo",ai416:"prodServLoc",ai417:"party",ai420:"shipToPost",ai421:"shipToPostISO",ai422:"origin",ai423:"countryInitialProcess",ai424:"countryProcess",ai425:"countryDisassembly",ai426:"countryFullProcess",ai427:"originSubdivision",ai7001:"nsn",ai7002:"meatCut",ai7003:"expirationDateTime",ai7004:"activePotency",ai7005:"catchArea",ai7006:"firstFreezeDate",ai7007:"harvestDate",ai7008:"aquaticSpecies",ai7009:"fishingGearType",ai7010:"prodMethod",ai7020:"refurbLot",ai7021:"funcStat",ai7022:"revStat",ai7023:"giaiAssembly",ai7030:"processor",ai7031:"processor2",ai7032:"processor3",ai7033:"processor4",ai7034:"processor5",ai7035:"processor6",ai7036:"processor7",ai7037:"processor8",ai7038:"processor9",ai7039:"processor10",ai7040:"uicExt",ai7041:"ufrgtUnitType",ai710:"nhrnPzn",ai711:"nhrnCip",ai712:"nhrnCn",ai713:"nhrnDrn",ai714:"nhrnAim",ai715:"nhrnDnc",ai716:"nhrnAic",ai8001:"rollProducts",ai8002:"cmtNo",ai8003:"grai",ai8004:"giai",ai8005:"pricePerUnit",ai8006:"itip",ai8007:"iban",ai8008:"prodTime",ai8009:"opticalSensor",ai8010:"cpid",ai8011:"cpidSerial",ai8012:"version",ai8013:"gmn",ai8017:"gsrnProvider",ai8018:"gsrnRecipient",ai8019:"srin",ai8020:"refNo",ai8026:"itipContent",ai8030:"digSig",ai8110:"coupon",ai8111:"points",ai8112:"couponExtended",ai8200:"productURL",ai90:"internal1",ai91:"internal2",ai92:"internal3",ai93:"internal4",ai94:"internal5",ai95:"internal6",ai96:"internal7",ai97:"internal8",ai98:"internal9",ai99:"internal10"};var h=String.fromCodePoint(29),l=/^\d+$/;var A=class extends Error{static{r(this,"InternalError")}constructor(I,E){super(I),this.name="InternalError",this.code=I,this.ex=E}ex;code},R=class extends Error{static{r(this,"InvalidAiError")}constructor(I,E){let S;I?S=`Invalid AI identifier "${E}" after "${I}"`:S=`Invalid first AI identifier "${E}"`,super(S),this.name="InvalidAiError"}},G=class extends Error{static{r(this,"BarcodeError")}constructor(I,E,S){super(S),this.name="BarcodeError",this.num=I,this.code=E,this.des=S}num;code;des},H=class{static{r(this,"ParsedElementClass")}ai;dataTitle;data;dataString;unit;constructor(I,E,S){switch(this.ai=I,this.dataTitle=E,this.unit="",this.dataString="",S){case"S":this.data="";break;case"N":this.data=0;break;case"D":this.data=new Date,this.data.setHours(0,0,0,0);break;default:this.data="";break}}},M=class{constructor(I,E,S={}){this.codeName=I;this.denormalized=E;this.data=S}static{r(this,"DecodeResult")}};function F(_,I){let E=_,S=E.slice(0,1);for(;S===I;)E=E.slice(1),S=E.slice(0,1);return E}r(F,"cleanCodestring");function g(_,I,E){if(I<0||I>11)return!1;let S=I;E===0&&S++;let t=new Date(_,S,E);return t.getFullYear()===_&&t.getMonth()===I&&(t.getDate()===E||E===0)}r(g,"checkValidDate");function o(_,I){let E=_.length-I,S=_.slice(0,E)+"."+_.slice(E);try{return Number.parseFloat(S)}catch(t){throw new A("36",t)}}r(o,"parseFloatingPoint");function n(_,I,E){let S=new H(_,I,"D"),t=_.length,a=E.slice(t,t+6),e=0,L=0,O=0;try{e=Number.parseInt(a.slice(0,2),10)}catch(N){throw new A("33",N)}try{L=Number.parseInt(a.slice(2,4),10)-1}catch(N){throw new A("34",N)}try{O=Number.parseInt(a.slice(4,6),10)}catch(N){throw new A("35",N)}if(e>50?e=e+1900:e=e+2e3,!g(e,L,O))throw new G(7,"36",`Invalid date "${a}" for AI "${_}".`);return O===0&&L++,S.data.setFullYear(e,L,O),S.dataString=a,{element:S,codestring:E.slice(t+6,E.length)}}r(n,"parseDate");function s(_,I,E,S,t=!1){let a=new H(_,I,"S"),e=_.length,L=S.slice(e,E+e);if(L.length<E)throw new G(9,"37",`Data length ${L.length} is less than expected length ${E} for AI "${_}".`);if(t&&!l.test(L))throw new G(11,"39",`Numeric data expected for AI "${_}", but got "${L}".`);a.data=L,a.dataString=L;let O=S.slice(E+e,S.length);return{element:a,codestring:O}}r(s,"parseFixedLength");function T(_,I,E,S,t,a=!1){let e=new H(_,I,"S"),L=_.length,O=E.indexOf(S),N="";if(O===-1?t&&t>0?(e.data=E.slice(L,t+L),N=E.replace(_+e.data,"")):e.data=E.slice(L,E.length):(e.data=E.slice(L,O),N=E.slice(O+1,E.length)),e.data==="")throw new G(10,"38",`Variable length data for AI "${_}" is empty.`);if(a&&!l.test(e.data))throw new G(11,"39",`Numeric data expected for AI "${_}", but got "${e.data}".`);return e.dataString=e.data,{element:e,codestring:N}}r(T,"parseVariableLength");function c(_,I,E,S,t,a){let e=new H(_+I,E,"N"),L=_.length+1,O=t.indexOf(a),N=Number.parseInt(I,10),u="",U="";return O===-1?u=t.slice(L,t.length):(u=t.slice(L,O),U=t.slice(O+1,t.length)),e.data=o(u,N),e.dataString=u,e.unit=S,{element:e,codestring:U}}r(c,"parseVariableLengthMeasure");function i(_,I,E,S,t){let a=new H(_+I,E,"N"),e=_.length+1;if(!l.test(I))throw new R(_,I);let L=Number.parseInt(I,10),O=t.slice(e,e+6);if(!l.test(O))throw new G(11,"39",`Numeric data expected for AI "${_+I}", but got "${O}".`);a.data=o(O,L),a.dataString=O,a.unit=S;let N=t.slice(e+6,t.length);return{element:a,codestring:N}}r(i,"parseFixedLengthMeasure");function P(_,I,E,S,t){let a=new H(_+I,E,"N"),e=_.length+1,L=S.indexOf(t),O=Number.parseInt(I,10),N="",u="",U="";return L===-1?N=S.slice(e,S.length):(N=S.slice(e,L),U=S.slice(L+1,S.length)),u=N.slice(3,N.length),a.data=o(u,O),a.dataString=u,a.unit=N.slice(0,3),{element:a,codestring:U}}r(P,"parseVariableLengthWithISONumbers");function V(_,I,E,S){let t=new H(_,I,"S"),a=_.length,e=E.indexOf(S),L="",O="";return e===-1?L=E.slice(a,E.length):(L=E.slice(a,e),O=E.slice(e+1,E.length)),t.data=L.slice(3,L.length),t.unit=L.slice(0,3),t.dataString=L,{element:t,codestring:O}}r(V,"parseVariableLengthWithISOChars");function f(_,I,E){E||(E=h);let S=_.slice(0,1),t=_.slice(1,2),a="",e="";switch(S){case"0":switch(t){case"0":return s("00","SSCC",18,_,!0);case"1":return s("01","GTIN",14,_,!0);case"2":return s("02","CONTENT",14,_);case"3":return s("03","MTO GTIN",14,_);default:throw new R("0",t)}case"1":switch(t){case"0":return T("10","BATCH/LOT",_,E,I??20);case"1":return n("11","PROD DATE",_);case"2":return n("12","DUE DATE",_);case"3":return n("13","PACK DATE",_);case"5":return n("15","BEST BEFORE or BEST BY",_);case"6":return n("16","SELL BY",_);case"7":return n("17","USE BY OR EXPIRY",_);default:throw new R("1",t)}case"2":switch(t){case"0":return s("20","VARIANT",2,_);case"1":return T("21","SERIAL",_,E,I??20);case"2":return T("22","CPV",_,E,20);case"3":switch(a=_.slice(2,3),a){case"5":return T("235","TPX",_,E,28);default:throw new R("23",a)}case"4":switch(a=_.slice(2,3),a){case"0":return T("240","ADDITIONAL ID",_,E,30);case"1":return T("241","CUST. PART NO.",_,E,30);case"2":return T("242","MTO VARIANT",_,E,6,!0);case"3":return T("243","PCN",_,E,20);default:throw new R("24",a)}case"5":switch(a=_.slice(2,3),a){case"0":return T("250","SECONDARY SERIAL",_,E,30);case"1":return T("251","REF. TO SOURCE",_,E,30);case"3":return T("253","GDTI",_,E,42);case"4":return T("254","GLN EXTENSION COMPONENT",_,E,20);case"5":return T("255","GCN",_,E,25,!0);default:throw new R("25",a)}default:throw new R("2",t)}case"3":switch(t){case"0":return T("30","VAR. COUNT",_,E,8,!0);case"1":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("310",e,"NET WEIGHT (kg)","KGM",_);case"1":return i("311",e,"LENGTH (m)","MTR",_);case"2":return i("312",e,"WIDTH (m)","MTR",_);case"3":return i("313",e,"HEIGHT (m)","MTR",_);case"4":return i("314",e,"AREA (m2)","MTK",_);case"5":return i("315",e,"NET VOLUME (l)","LTR",_);case"6":return i("316",e,"NET VOLUME (m3)","MTQ",_);default:throw new R("31",a)}case"2":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("320",e,"NET WEIGHT (lb)","LBR",_);case"1":return i("321",e,"LENGTH (i)","INH",_);case"2":return i("322",e,"LENGTH (f)","FOT",_);case"3":return i("323",e,"LENGTH (y)","YRD",_);case"4":return i("324",e,"WIDTH (i)","INH",_);case"5":return i("325",e,"WIDTH (f)","FOT",_);case"6":return i("326",e,"WIDTH (y)","YRD",_);case"7":return i("327",e,"HEIGHT (i)","INH",_);case"8":return i("328",e,"HEIGHT (f)","FOT",_);case"9":return i("329",e,"HEIGHT (y)","YRD",_);default:throw new R("32",a)}case"3":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("330",e,"GROSS WEIGHT (kg)","KGM",_);case"1":return i("331",e,"LENGTH (m), log","MTR",_);case"2":return i("332",e,"WIDTH (m), log","MTR",_);case"3":return i("333",e,"HEIGHT (m), log","MTR",_);case"4":return i("334",e,"AREA (m2), log","MTK",_);case"5":return i("335",e,"VOLUME (l), log","LTR",_);case"6":return i("336",e,"VOLUME (m3), log","MTQ",_);case"7":return i("337",e,"KG PER m\xB2","28",_);default:throw new R("33",a)}case"4":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("340",e,"GROSS WEIGHT (lb)","LBR",_);case"1":return i("341",e,"LENGTH (i), log","INH",_);case"2":return i("342",e,"LENGTH (f), log","FOT",_);case"3":return i("343",e,"LENGTH (y), log","YRD",_);case"4":return i("344",e,"WIDTH (i), log","INH",_);case"5":return i("345",e,"WIDTH (f), log","FOT",_);case"6":return i("346",e,"WIDTH (y), log","YRD",_);case"7":return i("347",e,"HEIGHT (i), log","INH",_);case"8":return i("348",e,"HEIGHT (f), log","FOT",_);case"9":return i("349",e,"HEIGHT (y), log","YRD",_);default:throw new R("33",a)}case"5":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("350",e,"AREA (i2)","INK",_);case"1":return i("351",e,"AREA (f2)","FTK",_);case"2":return i("352",e,"AREA (y2)","YDK",_);case"3":return i("353",e,"AREA (i2), log","INK",_);case"4":return i("354",e,"AREA (f2), log","FTK",_);case"5":return i("355",e,"AREA (y2), log","YDK",_);case"6":return i("356",e,"NET WEIGHT (t)","APZ",_);case"7":return i("357",e,"NET VOLUME (oz)","ONZ",_);default:throw new R("35",a)}case"6":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return i("360",e,"NET VOLUME (q)","QT",_);case"1":return i("361",e,"NET VOLUME (g)","GLL",_);case"2":return i("362",e,"VOLUME (q), log","QT",_);case"3":return i("363",e,"VOLUME (g), log","GLL",_);case"4":return i("364",e,"VOLUME (i3)","INQ",_);case"5":return i("365",e,"VOLUME (f3)","FTQ",_);case"6":return i("366",e,"VOLUME (y3)","YDQ",_);case"7":return i("367",e,"VOLUME (i3), log","INQ",_);case"8":return i("368",e,"VOLUME (f3), log","FTQ",_);case"9":return i("369",e,"VOLUME (y3), log","YDQ",_);default:throw new R("36",a)}case"7":return T("37","COUNT",_,E,8);case"9":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return c("390",e,"AMOUNT","",_,E);case"1":return P("391",e,"AMOUNT",_,E);case"2":return c("392",e,"PRICE","",_,E);case"3":return P("393",e,"PRICE",_,E);default:throw new R("39",a)}default:throw new R("3",t)}case"4":switch(t){case"0":switch(a=_.slice(2,3),a){case"0":return T("400","ORDER NUMBER",_,E,30);case"1":return T("401","GINC",_,E);case"2":return T("402","GSIN",_,E,17,!0);case"3":return T("403","ROUTE",_,E,30);default:throw new R("40",a)}case"1":switch(a=_.slice(2,3),a){case"0":return s("410","SHIP TO LOC",13,_,!0);case"1":return s("411","BILL TO",13,_,!0);case"2":return s("412","PURCHASE FROM",13,_,!0);case"3":return s("413","SHIP FOR LOC",13,_,!0);case"4":return s("414","LOC NO",13,_,!0);case"5":return s("415","PAY TO",13,_,!0);case"6":return s("416","PROD/SERV LOC",13,_,!0);case"7":return s("417","PARTY",13,_,!0);default:throw new R("41",a)}case"2":switch(a=_.slice(2,3),a){case"0":return T("420","SHIP TO POST",_,E,20);case"1":return V("421","SHIP TO POST",_,E);case"2":return s("422","ORIGIN",3,_,!0);case"3":return T("423","COUNTRY - INITIAL PROCESS.",_,E,15);case"4":return s("424","COUNTRY - PROCESS.",3,_,!0);case"5":return s("425","COUNTRY - DISASSEMBLY",3,_,!0);case"6":return s("426","COUNTRY - FULL PROCESS",3,_,!0);case"7":return T("427","ORIGIN SUBDIVISION",_,E,3);default:throw new R("42",a)}default:throw new R("4",t)}case"7":switch(t){case"0":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"1":return T("7001","NSN",_,E,13,!0);case"2":return T("7002","MEAT CUT",_,E);case"3":return T("7003","EXPIRY TIME",_,E,10,!0);case"4":return T("7004","ACTIVE POTENCY",_,E,4,!0);case"5":return T("7005","CATCH AREA",_,E,12);case"6":return n("7006","FIRST FREEZE DATE",_);case"7":return T("7007","HARVEST DATE",_,E,12,!0);case"8":return T("7008","AQUATIC SPECIES",_,E,3);case"9":return T("7009","FISHING GEAR TYPE",_,E,10);default:throw new R("700",e)}case"1":switch(e){case"0":return T("7010","PROD METHOD",_,E,2);case"1":return T("7011","TEST BY DATE",_,E,10,!0);default:throw new R("701",e)}case"2":switch(e){case"0":return T("7020","REFURB LOT",_,E,20);case"1":return T("7021","FUNC STAT",_,E,20);case"2":return T("7022","REV STAT",_,E,20);case"3":return T("7023","GIAI - ASSEMBLY",_,E,30);default:throw new R("702",e)}case"3":return V("703"+e,"PROCESSOR # "+e,_,E);default:throw new R("70",a)}case"1":switch(a=_.slice(2,3),a){case"0":return T("710","NHRN PZN",_,E);case"1":return T("711","NHRN CIP",_,E);case"2":return T("712","NHRN CN",_,E);case"3":return T("713","NHRN DRN",_,E);case"4":return T("714","NHRN AIM",_,E);case"5":return T("715","NHRN NDC",_,E);case"6":return T("716","NHRN AIC",_,E);default:throw new R("71",a)}default:throw new R("7",t)}case"8":switch(t){case"0":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"1":return T("8001","DIMENSIONS",_,E,14);case"2":return T("8002","CMT No",_,E);case"3":return T("8003","GRAI",_,E);case"4":return T("8004","GIAI",_,E);case"5":return T("8005","PRICE PER UNIT",_,E,6);case"6":return T("8006","GCTIN",_,E,18);case"7":return T("8007","IBAN",_,E);case"8":return T("8008","PROD TIME",_,E,12);default:throw new R("800",e)}case"1":switch(e){case"0":return T("8010","CPID",_,E);case"1":return T("8011","CPID SERIAL",_,E);case"7":return T("8017","GSRN - PROVIDER",_,E,18);case"8":return T("8018","GSRN - RECIPIENT",_,E,18,!0);case"9":return T("8019","SRIN",_,E,void 0,!0);default:throw new R("801",e)}case"2":switch(e){case"0":return T("8020","REF No",_,E);case"6":return T("8026","ITIP CONTENT",_,E,18,!0);default:throw new R("802",e)}case"3":switch(e){case"0":return T("8030","DIGSIG",_,E);default:throw new R("803",e)}default:throw new R("80",a)}case"1":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"1":switch(e){case"0":return T("8110","-",_,E);case"1":return T("8111","POINTS",_,E,4,!0);case"2":return T("8112","-",_,E);default:throw new R("811",e)}default:throw new R("81",a)}case"2":switch(a=_.slice(2,3),a){case"0":return T("8200","PRODUCT URL",_,E);default:throw new R("82",a)}default:throw new R("8",t)}case"9":switch(t){case"0":return T("90","INTERNAL",_,E,30);case"1":return T("91","INTERNAL",_,E);case"2":return T("92","INTERNAL",_,E);case"3":return T("93","INTERNAL",_,E);case"4":return T("94","INTERNAL",_,E);case"5":return T("95","INTERNAL",_,E);case"6":return T("96","INTERNAL",_,E);case"7":return T("97","INTERNAL",_,E);case"8":return T("98","INTERNAL",_,E);case"9":return T("99","INTERNAL",_,E);default:throw new R("9",t)}default:throw new R("",S)}}r(f,"identifyAI");function Y(_,I,E){if(!_||typeof _!="string")throw new G(2,"31","The barcode is empty or not a string.");let S=_.length,t={codeName:"",denormalized:"",parsedCodeItems:[]},a="",e=_.slice(0,3),L;switch(e){case"]C1":t.codeName="GS1-128",a=_.slice(3,S);break;case"]e0":t.codeName="GS1 DataBar",a=_.slice(3,S);break;case"]e1":case"]e2":t.codeName="GS1 Composite",a=_.slice(3,S);break;case"]d2":t.codeName="GS1 DataMatrix",a=_.slice(3,S);break;case"]Q3":t.codeName="GS1 QR Code",a=_.slice(3,S);break;default:t.codeName="",a=_;break}for(t.parsedCodeItems=[];a.length>0;)try{L=f(a,E),a=F(L.codestring,I),t.parsedCodeItems.push(L.element),t.denormalized+="("+L.element.ai+")"+L.element.dataString}catch(O){if(O instanceof A)v(O);else throw O}return t}r(Y,"parseBarcode");function v(_){switch(_.code){case"32":throw new G(6,32,"Invalid normal AI.");case"33":throw new G(7,33,"The year of the date is not valid.");case"34":throw new G(7,34,"The month of the date is not valid.");case"36":throw new G(8,36,"Invalid numbers");default:throw _}}r(v,"handleInternalError");var D=class{static{r(this,"GS1Parser")}fncChar;lotLen;constructor(I){this.fncChar=I?.fncChar||h,this.lotLen=I?.lotMaxLength}decode(I){let E=I.replaceAll("(",this.fncChar).replaceAll(")","");E.startsWith(this.fncChar)&&(E=E.slice(1));let S=Y(E,this.fncChar,this.lotLen),t={};for(let a of S.parsedCodeItems){let e=m["ai"+a.ai];e&&(t[e]=a)}return new M(S.codeName,S.denormalized,t)}};0&&(module.exports={GS1Parser});
|
package/dist/index.d.cts
CHANGED
|
@@ -406,6 +406,14 @@ declare enum GS1Field {
|
|
|
406
406
|
PROCESSOR_9 = "processor9",
|
|
407
407
|
PROCESSOR_10 = "processor10",
|
|
408
408
|
UIC_EXT = "uicExt",
|
|
409
|
+
UFRGT_UNIT_TYPE = "ufrgtUnitType",
|
|
410
|
+
NHRN_PZN = "nhrnPzn",
|
|
411
|
+
NHRN_CIP = "nhrnCip",
|
|
412
|
+
NHRN_CN = "nhrnCn",
|
|
413
|
+
NHRN_DRN = "nhrnDrn",
|
|
414
|
+
NHRN_AIM = "nhrnAim",
|
|
415
|
+
NHRN_DNC = "nhrnDnc",
|
|
416
|
+
NHRN_AIC = "nhrnAic",
|
|
409
417
|
ROLL_PRODUCTS = "rollProducts",
|
|
410
418
|
CMT_NO = "cmtNo",
|
|
411
419
|
GRAI = "grai",
|
|
@@ -424,10 +432,10 @@ declare enum GS1Field {
|
|
|
424
432
|
SRIN = "srin",
|
|
425
433
|
REF_NO = "refNo",
|
|
426
434
|
ITIP_CONTENT = "itipContent",
|
|
435
|
+
DIG_SIG = "digSig",
|
|
427
436
|
COUPON = "coupon",
|
|
437
|
+
POINTS = "points",
|
|
428
438
|
COUPON_EXTENDED = "couponExtended",
|
|
429
|
-
COUPON_EXTENDED_2 = "couponExtended2",
|
|
430
|
-
COUPON_EXTENDED_3 = "couponExtended3",
|
|
431
439
|
PRODUCT_URL = "productURL",
|
|
432
440
|
INTERNAL_1 = "internal1",
|
|
433
441
|
INTERNAL_2 = "internal2",
|
package/dist/index.d.ts
CHANGED
|
@@ -406,6 +406,14 @@ declare enum GS1Field {
|
|
|
406
406
|
PROCESSOR_9 = "processor9",
|
|
407
407
|
PROCESSOR_10 = "processor10",
|
|
408
408
|
UIC_EXT = "uicExt",
|
|
409
|
+
UFRGT_UNIT_TYPE = "ufrgtUnitType",
|
|
410
|
+
NHRN_PZN = "nhrnPzn",
|
|
411
|
+
NHRN_CIP = "nhrnCip",
|
|
412
|
+
NHRN_CN = "nhrnCn",
|
|
413
|
+
NHRN_DRN = "nhrnDrn",
|
|
414
|
+
NHRN_AIM = "nhrnAim",
|
|
415
|
+
NHRN_DNC = "nhrnDnc",
|
|
416
|
+
NHRN_AIC = "nhrnAic",
|
|
409
417
|
ROLL_PRODUCTS = "rollProducts",
|
|
410
418
|
CMT_NO = "cmtNo",
|
|
411
419
|
GRAI = "grai",
|
|
@@ -424,10 +432,10 @@ declare enum GS1Field {
|
|
|
424
432
|
SRIN = "srin",
|
|
425
433
|
REF_NO = "refNo",
|
|
426
434
|
ITIP_CONTENT = "itipContent",
|
|
435
|
+
DIG_SIG = "digSig",
|
|
427
436
|
COUPON = "coupon",
|
|
437
|
+
POINTS = "points",
|
|
428
438
|
COUPON_EXTENDED = "couponExtended",
|
|
429
|
-
COUPON_EXTENDED_2 = "couponExtended2",
|
|
430
|
-
COUPON_EXTENDED_3 = "couponExtended3",
|
|
431
439
|
PRODUCT_URL = "productURL",
|
|
432
440
|
INTERNAL_1 = "internal1",
|
|
433
441
|
INTERNAL_2 = "internal2",
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Y=Object.defineProperty;var r=(_,i)=>Y(_,"name",{value:i,configurable:!0});var V={ai00:"sscc",ai01:"gtin",ai02:"content",ai10:"batch",ai11:"prodDate",ai12:"dueDate",ai13:"packDate",ai15:"bestBefore",ai16:"sellBy",ai17:"expDate",ai20:"variant",ai21:"serial",ai22:"hibcc",ai235:"tpx",ai240:"additionalProductID",ai241:"customerPartNumber",ai242:"madeToOrder",ai243:"packaging",ai250:"secondarySerialNumber",ai251:"refSource",ai253:"gdti",ai254:"glnExtension",ai255:"gcn",ai30:"variableCount",ai310:"netWeightKg0",ai3100:"netWeightKg0",ai3101:"netWeightKg1",ai3102:"netWeightKg2",ai3103:"netWeightKg3",ai3104:"netWeightKg4",ai3105:"netWeightKg5",ai3110:"lengthMeters0",ai3111:"lengthMeters1",ai3112:"lengthMeters2",ai3113:"lengthMeters3",ai3114:"lengthMeters4",ai3115:"lengthMeters5",ai3120:"widthMeters0",ai3121:"widthMeters1",ai3122:"widthMeters2",ai3123:"widthMeters3",ai3124:"widthMeters4",ai3125:"widthMeters5",ai3130:"heightMeters0",ai3131:"heightMeters1",ai3132:"heightMeters2",ai3133:"heightMeters3",ai3134:"heightMeters4",ai3135:"heightMeters5",ai3140:"areaSquareMeters0",ai3141:"areaSquareMeters1",ai3142:"areaSquareMeters2",ai3143:"areaSquareMeters3",ai3144:"areaSquareMeters4",ai3145:"areaSquareMeters5",ai3150:"netVolumeLiters0",ai3151:"netVolumeLiters1",ai3152:"netVolumeLiters2",ai3153:"netVolumeLiters3",ai3154:"netVolumeLiters4",ai3155:"netVolumeLiters5",ai3160:"netVolumeCubicMeters0",ai3161:"netVolumeCubicMeters1",ai3162:"netVolumeCubicMeters2",ai3163:"netVolumeCubicMeters3",ai3164:"netVolumeCubicMeters4",ai3165:"netVolumeCubicMeters5",ai3200:"netWeightLb0",ai3201:"netWeightLb1",ai3202:"netWeightLb2",ai3203:"netWeightLb3",ai3204:"netWeightLb4",ai3205:"netWeightLb5",ai3210:"lengthInches0",ai3211:"lengthInches1",ai3212:"lengthInches2",ai3213:"lengthInches3",ai3214:"lengthInches4",ai3215:"lengthInches5",ai3220:"lengthFeet0",ai3221:"lengthFeet1",ai3222:"lengthFeet2",ai3223:"lengthFeet3",ai3224:"lengthFeet4",ai3225:"lengthFeet5",ai3230:"lengthYards0",ai3231:"lengthYards1",ai3232:"lengthYards2",ai3233:"lengthYards3",ai3234:"lengthYards4",ai3235:"lengthYards5",ai3240:"widthInches0",ai3241:"widthInches1",ai3242:"widthInches2",ai3243:"widthInches3",ai3244:"widthInches4",ai3245:"widthInches5",ai3250:"widthFeet0",ai3251:"widthFeet1",ai3252:"widthFeet2",ai3253:"widthFeet3",ai3254:"widthFeet4",ai3255:"widthFeet5",ai3260:"widthYards0",ai3261:"widthYards1",ai3262:"widthYards2",ai3263:"widthYards3",ai3264:"widthYards4",ai3265:"widthYards5",ai3270:"heightInches0",ai3271:"heightInches1",ai3272:"heightInches2",ai3273:"heightInches3",ai3274:"heightInches4",ai3275:"heightInches5",ai3280:"heightFeet0",ai3281:"heightFeet1",ai3282:"heightFeet2",ai3283:"heightFeet3",ai3284:"heightFeet4",ai3285:"heightFeet5",ai3290:"heightYards0",ai3291:"heightYards1",ai3292:"heightYards2",ai3293:"heightYards3",ai3294:"heightYards4",ai3295:"heightYards5",ai3300:"grossWeightKg0",ai3301:"grossWeightKg1",ai3302:"grossWeightKg2",ai3303:"grossWeightKg3",ai3304:"grossWeightKg4",ai3305:"grossWeightKg5",ai3310:"lengthMetersLog0",ai3311:"lengthMetersLog1",ai3312:"lengthMetersLog2",ai3313:"lengthMetersLog3",ai3314:"lengthMetersLog4",ai3315:"lengthMetersLog5",ai3320:"widthMetersLog0",ai3321:"widthMetersLog1",ai3322:"widthMetersLog2",ai3323:"widthMetersLog3",ai3324:"widthMetersLog4",ai3325:"widthMetersLog5",ai3330:"heightMetersLog0",ai3331:"heightMetersLog1",ai3332:"heightMetersLog2",ai3333:"heightMetersLog3",ai3334:"heightMetersLog4",ai3335:"heightMetersLog5",ai3340:"areaSquareInches0",ai3341:"areaSquareInches1",ai3342:"areaSquareInches2",ai3343:"areaSquareInches3",ai3344:"areaSquareInches4",ai3345:"areaSquareInches5",ai3350:"areaSquareFeet0",ai3351:"areaSquareFeet1",ai3352:"areaSquareFeet2",ai3353:"areaSquareFeet3",ai3354:"areaSquareFeet4",ai3355:"areaSquareFeet5",ai3360:"areaSquareYards0",ai3361:"areaSquareYards1",ai3362:"areaSquareYards2",ai3363:"areaSquareYards3",ai3364:"areaSquareYards4",ai3365:"areaSquareYards5",ai3370:"areaSquareMetersLog0",ai3371:"areaSquareMetersLog1",ai3372:"areaSquareMetersLog2",ai3373:"areaSquareMetersLog3",ai3374:"areaSquareMetersLog4",ai3375:"areaSquareMetersLog5",ai3400:"netWeightOunces0",ai3401:"netWeightOunces1",ai3402:"netWeightOunces2",ai3403:"netWeightOunces3",ai3404:"netWeightOunces4",ai3405:"netWeightOunces5",ai3410:"netVolumeQuarts0",ai3411:"netVolumeQuarts1",ai3412:"netVolumeQuarts2",ai3413:"netVolumeQuarts3",ai3414:"netVolumeQuarts4",ai3415:"netVolumeQuarts5",ai3420:"netVolumeGallons0",ai3421:"netVolumeGallons1",ai3422:"netVolumeGallons2",ai3423:"netVolumeGallons3",ai3424:"netVolumeGallons4",ai3425:"netVolumeGallons5",ai3430:"volumeCubicInches0",ai3431:"volumeCubicInches1",ai3432:"volumeCubicInches2",ai3433:"volumeCubicInches3",ai3434:"volumeCubicInches4",ai3435:"volumeCubicInches5",ai3440:"volumeCubicFeet0",ai3441:"volumeCubicFeet1",ai3442:"volumeCubicFeet2",ai3443:"volumeCubicFeet3",ai3444:"volumeCubicFeet4",ai3445:"volumeCubicFeet5",ai3450:"volumeCubicYards0",ai3451:"volumeCubicYards1",ai3452:"volumeCubicYards2",ai3453:"volumeCubicYards3",ai3454:"volumeCubicYards4",ai3455:"volumeCubicYards5",ai3460:"volumeCubicMetersLog0",ai3461:"volumeCubicMetersLog1",ai3462:"volumeCubicMetersLog2",ai3463:"volumeCubicMetersLog3",ai3464:"volumeCubicMetersLog4",ai3465:"volumeCubicMetersLog5",ai3500:"grossWeightLb0",ai3501:"grossWeightLb1",ai3502:"grossWeightLb2",ai3503:"grossWeightLb3",ai3504:"grossWeightLb4",ai3505:"grossWeightLb5",ai3510:"lengthInchesLog0",ai3511:"lengthInchesLog1",ai3512:"lengthInchesLog2",ai3513:"lengthInchesLog3",ai3514:"lengthInchesLog4",ai3515:"lengthInchesLog5",ai3520:"lengthFeetLog0",ai3521:"lengthFeetLog1",ai3522:"lengthFeetLog2",ai3523:"lengthFeetLog3",ai3524:"lengthFeetLog4",ai3525:"lengthFeetLog5",ai3530:"lengthYardsLog0",ai3531:"lengthYardsLog1",ai3532:"lengthYardsLog2",ai3533:"lengthYardsLog3",ai3534:"lengthYardsLog4",ai3535:"lengthYardsLog5",ai3540:"widthInchesLog0",ai3541:"widthInchesLog1",ai3542:"widthInchesLog2",ai3543:"widthInchesLog3",ai3544:"widthInchesLog4",ai3545:"widthInchesLog5",ai3550:"widthFeetLog0",ai3551:"widthFeetLog1",ai3552:"widthFeetLog2",ai3553:"widthFeetLog3",ai3554:"widthFeetLog4",ai3555:"widthFeetLog5",ai3560:"widthYardsLog0",ai3561:"widthYardsLog1",ai3562:"widthYardsLog2",ai3563:"widthYardsLog3",ai3564:"widthYardsLog4",ai3565:"widthYardsLog5",ai3570:"heightInchesLog0",ai3571:"heightInchesLog1",ai3572:"heightInchesLog2",ai3573:"heightInchesLog3",ai3574:"heightInchesLog4",ai3575:"heightInchesLog5",ai3580:"heightFeetLog0",ai3581:"heightFeetLog1",ai3582:"heightFeetLog2",ai3583:"heightFeetLog3",ai3584:"heightFeetLog4",ai3585:"heightFeetLog5",ai3590:"heightYardsLog0",ai3591:"heightYardsLog1",ai3592:"heightYardsLog2",ai3593:"heightYardsLog3",ai3594:"heightYardsLog4",ai3595:"heightYardsLog5",ai3600:"grossWeightOunces0",ai3601:"grossWeightOunces1",ai3602:"grossWeightOunces2",ai3603:"grossWeightOunces3",ai3604:"grossWeightOunces4",ai3605:"grossWeightOunces5",ai3610:"netVolumeFluidOunces0",ai3611:"netVolumeFluidOunces1",ai3612:"netVolumeFluidOunces2",ai3613:"netVolumeFluidOunces3",ai3614:"netVolumeFluidOunces4",ai3615:"netVolumeFluidOunces5",ai3620:"grossVolumeQuarts0",ai3621:"grossVolumeQuarts1",ai3622:"grossVolumeQuarts2",ai3623:"grossVolumeQuarts3",ai3624:"grossVolumeQuarts4",ai3625:"grossVolumeQuarts5",ai3630:"grossVolumeGallons0",ai3631:"grossVolumeGallons1",ai3632:"grossVolumeGallons2",ai3633:"grossVolumeGallons3",ai3634:"grossVolumeGallons4",ai3635:"grossVolumeGallons5",ai3640:"volumeCubicInchesLog0",ai3641:"volumeCubicInchesLog1",ai3642:"volumeCubicInchesLog2",ai3643:"volumeCubicInchesLog3",ai3644:"volumeCubicInchesLog4",ai3645:"volumeCubicInchesLog5",ai3650:"volumeCubicFeetLog0",ai3651:"volumeCubicFeetLog1",ai3652:"volumeCubicFeetLog2",ai3653:"volumeCubicFeetLog3",ai3654:"volumeCubicFeetLog4",ai3655:"volumeCubicFeetLog5",ai3660:"volumeCubicYardsLog0",ai3661:"volumeCubicYardsLog1",ai3662:"volumeCubicYardsLog2",ai3663:"volumeCubicYardsLog3",ai3664:"volumeCubicYardsLog4",ai3665:"volumeCubicYardsLog5",ai37:"count",ai3900:"amountPayable0",ai3901:"amountPayable1",ai3902:"amountPayable2",ai3903:"amountPayable3",ai3904:"amountPayable4",ai3905:"amountPayable5",ai3910:"amountPayableISO0",ai3911:"amountPayableISO1",ai3912:"amountPayableISO2",ai3913:"amountPayableISO3",ai3914:"amountPayableISO4",ai3915:"amountPayableISO5",ai3920:"price0",ai3921:"price1",ai3922:"price2",ai3923:"price3",ai3930:"priceISO0",ai3931:"priceISO1",ai3932:"priceISO2",ai3933:"priceISO3",ai3940:"percentDiscount0",ai3941:"percentDiscount1",ai3942:"percentDiscount2",ai3943:"percentDiscount3",ai3950:"pricePerUnitMeasure0",ai3951:"pricePerUnitMeasure1",ai3952:"pricePerUnitMeasure2",ai3953:"pricePerUnitMeasure3",ai3954:"pricePerUnitMeasure4",ai3955:"pricePerUnitMeasure5",ai400:"orderNumber",ai401:"ginc",ai402:"gsin",ai403:"route",ai410:"shipTo",ai411:"billTo",ai412:"purchaseFrom",ai413:"shipFor",ai414:"locNo",ai415:"payTo",ai416:"prodServLoc",ai417:"party",ai420:"shipToPost",ai421:"shipToPostISO",ai422:"origin",ai423:"countryInitialProcess",ai424:"countryProcess",ai425:"countryDisassembly",ai426:"countryFullProcess",ai427:"originSubdivision",ai7001:"nsn",ai7002:"meatCut",ai7003:"expirationDateTime",ai7004:"activePotency",ai7005:"catchArea",ai7006:"firstFreezeDate",ai7007:"harvestDate",ai7008:"aquaticSpecies",ai7009:"fishingGearType",ai7010:"prodMethod",ai7020:"refurbLot",ai7021:"funcStat",ai7022:"revStat",ai7023:"giaiAssembly",ai7030:"processor",ai7031:"processor2",ai7032:"processor3",ai7033:"processor4",ai7034:"processor5",ai7035:"processor6",ai7036:"processor7",ai7037:"processor8",ai7038:"processor9",ai7039:"processor10",ai7040:"uicExt",ai8001:"rollProducts",ai8002:"cmtNo",ai8003:"grai",ai8004:"giai",ai8005:"pricePerUnit",ai8006:"itip",ai8007:"iban",ai8008:"prodTime",ai8009:"opticalSensor",ai8010:"cpid",ai8011:"cpidSerial",ai8012:"version",ai8013:"gmn",ai8017:"gsrnProvider",ai8018:"gsrnRecipient",ai8019:"srin",ai8020:"refNo",ai8026:"itipContent",ai8030:"coupon",ai8110:"couponExtended",ai8111:"couponExtended2",ai8112:"couponExtended3",ai8200:"productURL",ai90:"internal1",ai91:"internal2",ai92:"internal3",ai93:"internal4",ai94:"internal5",ai95:"internal6",ai96:"internal7",ai97:"internal8",ai98:"internal9",ai99:"internal10"};var C=String.fromCodePoint(29),M=/^\d+$/;var A=class extends Error{static{r(this,"InternalError")}constructor(i,E){super(i),this.name="InternalError",this.code=i,this.ex=E}ex;code},O=class extends Error{static{r(this,"InvalidAiError")}constructor(i,E){let I;i?I=`Invalid AI identifier "${E}" after "${i}"`:I=`Invalid first AI identifier "${E}"`,super(I),this.name="InvalidAiError"}},G=class extends Error{static{r(this,"BarcodeError")}constructor(i,E,I){super(I),this.name="BarcodeError",this.num=i,this.code=E,this.des=I}num;code;des},H=class{static{r(this,"ParsedElementClass")}ai;dataTitle;data;dataString;unit;constructor(i,E,I){switch(this.ai=i,this.dataTitle=E,this.unit="",this.dataString="",I){case"S":this.data="";break;case"N":this.data=0;break;case"D":this.data=new Date,this.data.setHours(0,0,0,0);break;default:this.data="";break}}},l=class{constructor(i,E,I={}){this.codeName=i;this.denormalized=E;this.data=I}static{r(this,"DecodeResult")}};function g(_,i){let E=_,I=E.slice(0,1);for(;I===i;)E=E.slice(1),I=E.slice(0,1);return E}r(g,"cleanCodestring");function m(_,i,E){if(i<0||i>11)return!1;let I=i;E===0&&I++;let T=new Date(_,I,E);return T.getFullYear()===_&&T.getMonth()===i&&(T.getDate()===E||E===0)}r(m,"checkValidDate");function h(_,i){let E=_.length-i,I=_.slice(0,E)+"."+_.slice(E);try{return Number.parseFloat(I)}catch(T){throw new A("36",T)}}r(h,"parseFloatingPoint");function u(_,i,E){let I=new H(_,i,"D"),T=_.length,a=E.slice(T,T+6),e=0,L=0,R=0;try{e=Number.parseInt(a.slice(0,2),10)}catch(N){throw new A("33",N)}try{L=Number.parseInt(a.slice(2,4),10)-1}catch(N){throw new A("34",N)}try{R=Number.parseInt(a.slice(4,6),10)}catch(N){throw new A("35",N)}if(e>50?e=e+1900:e=e+2e3,!m(e,L,R))throw new G(7,"36",`Invalid date "${a}" for AI "${_}".`);return R===0&&L++,I.data.setFullYear(e,L,R),I.dataString=a,{element:I,codestring:E.slice(T+6,E.length)}}r(u,"parseDate");function s(_,i,E,I,T=!1){let a=new H(_,i,"S"),e=_.length,L=I.slice(e,E+e);if(L.length<E)throw new G(9,"37",`Data length ${L.length} is less than expected length ${E} for AI "${_}".`);if(T&&!M.test(L))throw new G(11,"39",`Numeric data expected for AI "${_}", but got "${L}".`);a.data=L,a.dataString=L;let R=I.slice(E+e,I.length);return{element:a,codestring:R}}r(s,"parseFixedLength");function t(_,i,E,I,T,a=!1){let e=new H(_,i,"S"),L=_.length,R=E.indexOf(I),N="";if(R===-1?T&&T>0?(e.data=E.slice(L,T+L),N=E.replace(_+e.data,"")):e.data=E.slice(L,E.length):(e.data=E.slice(L,R),N=E.slice(R+1,E.length)),e.data==="")throw new G(10,"38",`Variable length data for AI "${_}" is empty.`);if(a&&!M.test(e.data))throw new G(11,"39",`Numeric data expected for AI "${_}", but got "${e.data}".`);return e.dataString=e.data,{element:e,codestring:N}}r(t,"parseVariableLength");function o(_,i,E,I,T,a){let e=new H(_+i,E,"N"),L=_.length+1,R=T.indexOf(a),N=Number.parseInt(i,10),n="",U="";return R===-1?n=T.slice(L,T.length):(n=T.slice(L,R),U=T.slice(R+1,T.length)),e.data=h(n,N),e.dataString=n,e.unit=I,{element:e,codestring:U}}r(o,"parseVariableLengthMeasure");function S(_,i,E,I,T){let a=new H(_+i,E,"N"),e=_.length+1,L=Number.parseInt(i,10),R=T.slice(e,e+6);a.data=h(R,L),a.dataString=R,a.unit=I;let N=T.slice(e+6,T.length);return{element:a,codestring:N}}r(S,"parseFixedLengthMeasure");function D(_,i,E,I,T){let a=new H(_+i,E,"N"),e=_.length+1,L=I.indexOf(T),R=Number.parseInt(i,10),N="",n="",U="";return L===-1?N=I.slice(e,I.length):(N=I.slice(e,L),U=I.slice(L+1,I.length)),n=N.slice(3,N.length),a.data=h(n,R),a.dataString=n,a.unit=N.slice(0,3),{element:a,codestring:U}}r(D,"parseVariableLengthWithISONumbers");function c(_,i,E,I){let T=new H(_,i,"S"),a=_.length,e=E.indexOf(I),L="",R="";return e===-1?L=E.slice(a,E.length):(L=E.slice(a,e),R=E.slice(e+1,E.length)),T.data=L.slice(3,L.length),T.unit=L.slice(0,3),T.dataString=L,{element:T,codestring:R}}r(c,"parseVariableLengthWithISOChars");function w(_,i,E){E||(E=C);let I=_.slice(0,1),T=_.slice(1,2),a="",e="";switch(I){case"0":switch(T){case"0":return s("00","SSCC",18,_,!0);case"1":return s("01","GTIN",14,_,!0);case"2":return s("02","CONTENT",14,_);case"3":return s("03","MTO GTIN",14,_);default:throw new O("0",T)}case"1":switch(T){case"0":return t("10","BATCH/LOT",_,E,i??20);case"1":return u("11","PROD DATE",_);case"2":return u("12","DUE DATE",_);case"3":return u("13","PACK DATE",_);case"5":return u("15","BEST BEFORE or BEST BY",_);case"6":return u("16","SELL BY",_);case"7":return u("17","USE BY OR EXPIRY",_);default:throw new O("1",T)}case"2":switch(T){case"0":return s("20","VARIANT",2,_);case"1":return t("21","SERIAL",_,E,i??20);case"2":return t("22","CPV",_,E,20);case"3":switch(a=_.slice(2,3),a){case"5":return t("235","TPX",_,E,28);default:throw new O("23",a)}case"4":switch(a=_.slice(2,3),a){case"0":return t("240","ADDITIONAL ID",_,E,30);case"1":return t("241","CUST. PART NO.",_,E,30);case"2":return t("242","MTO VARIANT",_,E,6);case"3":return t("243","PCN",_,E,20);default:throw new O("24",a)}case"5":switch(a=_.slice(2,3),a){case"0":return t("250","SECONDARY SERIAL",_,E,30);case"1":return t("251","REF. TO SOURCE",_,E,30);case"3":return t("253","GDTI",_,E,42);case"4":return t("254","GLN EXTENSION COMPONENT",_,E,20);case"5":return t("255","GCN",_,E,37);default:throw new O("25",a)}default:throw new O("2",T)}case"3":switch(T){case"0":return t("30","VAR. COUNT",_,E,8);case"1":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return S("310",e,"NET WEIGHT (kg)","KGM",_);case"1":return S("311",e,"LENGTH (m)","MTR",_);case"2":return S("312",e,"WIDTH (m)","MTR",_);case"3":return S("313",e,"HEIGHT (m)","MTR",_);case"4":return S("314",e,"AREA (m2)","MTK",_);case"5":return S("315",e,"NET VOLUME (l)","LTR",_);case"6":return S("316",e,"NET VOLUME (m3)","MTQ",_);default:throw new O("31",a)}case"2":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return S("320",e,"NET WEIGHT (lb)","LBR",_);case"1":return S("321",e,"LENGTH (i)","INH",_);case"2":return S("322",e,"LENGTH (f)","FOT",_);case"3":return S("323",e,"LENGTH (y)","YRD",_);case"4":return S("324",e,"WIDTH (i)","INH",_);case"5":return S("325",e,"WIDTH (f)","FOT",_);case"6":return S("326",e,"WIDTH (y)","YRD",_);case"7":return S("327",e,"HEIGHT (i)","INH",_);case"8":return S("328",e,"HEIGHT (f)","FOT",_);case"9":return S("329",e,"HEIGHT (y)","YRD",_);default:throw new O("32",a)}case"3":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return S("330",e,"GROSS WEIGHT (kg)","KGM",_);case"1":return S("331",e,"LENGTH (m), log","MTR",_);case"2":return S("332",e,"WIDTH (m), log","MTR",_);case"3":return S("333",e,"HEIGHT (m), log","MTR",_);case"4":return S("334",e,"AREA (m2), log","MTK",_);case"5":return S("335",e,"VOLUME (l), log","LTR",_);case"6":return S("336",e,"VOLUME (m3), log","MTQ",_);case"7":return S("337",e,"KG PER m\xB2","28",_);default:throw new O("33",a)}case"4":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return S("340",e,"GROSS WEIGHT (lb)","LBR",_);case"1":return S("341",e,"LENGTH (i), log","INH",_);case"2":return S("342",e,"LENGTH (f), log","FOT",_);case"3":return S("343",e,"LENGTH (y), log","YRD",_);case"4":return S("344",e,"WIDTH (i), log","INH",_);case"5":return S("345",e,"WIDTH (f), log","FOT",_);case"6":return S("346",e,"WIDTH (y), log","YRD",_);case"7":return S("347",e,"HEIGHT (i), log","INH",_);case"8":return S("348",e,"HEIGHT (f), log","FOT",_);case"9":return S("349",e,"HEIGHT (y), log","YRD",_);default:throw new O("33",a)}case"5":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return S("350",e,"AREA (i2)","INK",_);case"1":return S("351",e,"AREA (f2)","FTK",_);case"2":return S("352",e,"AREA (y2)","YDK",_);case"3":return S("353",e,"AREA (i2), log","INK",_);case"4":return S("354",e,"AREA (f2), log","FTK",_);case"5":return S("355",e,"AREA (y2), log","YDK",_);case"6":return S("356",e,"NET WEIGHT (t)","APZ",_);case"7":return S("357",e,"NET VOLUME (oz)","ONZ",_);default:throw new O("35",a)}case"6":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return S("360",e,"NET VOLUME (q)","QT",_);case"1":return S("361",e,"NET VOLUME (g)","GLL",_);case"2":return S("362",e,"VOLUME (q), log","QT",_);case"3":return S("363",e,"VOLUME (g), log","GLL",_);case"4":return S("364",e,"VOLUME (i3)","INQ",_);case"5":return S("365",e,"VOLUME (f3)","FTQ",_);case"6":return S("366",e,"VOLUME (y3)","YDQ",_);case"7":return S("367",e,"VOLUME (i3), log","INQ",_);case"8":return S("368",e,"VOLUME (f3), log","FTQ",_);case"9":return S("369",e,"VOLUME (y3), log","YDQ",_);default:throw new O("36",a)}case"7":return t("37","COUNT",_,E,8);case"9":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return o("390",e,"AMOUNT","",_,E);case"1":return D("391",e,"AMOUNT",_,E);case"2":return o("392",e,"PRICE","",_,E);case"3":return D("393",e,"PRICE",_,E);default:throw new O("39",a)}default:throw new O("3",T)}case"4":switch(T){case"0":switch(a=_.slice(2,3),a){case"0":return t("400","ORDER NUMBER",_,E,30);case"1":return t("401","GINC",_,E);case"2":return t("402","GSIN",_,E,17);case"3":return t("403","ROUTE",_,E,30);default:throw new O("40",a)}case"1":switch(a=_.slice(2,3),a){case"0":return s("410","SHIP TO LOC",13,_);case"1":return s("411","BILL TO",13,_);case"2":return s("412","PURCHASE FROM",13,_);case"3":return s("413","SHIP FOR LOC",13,_);case"4":return s("414","LOC NO",13,_);case"5":return s("415","PAY TO",13,_);case"6":return s("416","PROD/SERV LOC",13,_);case"7":return s("417","PARTY",13,_);default:throw new O("41",a)}case"2":switch(a=_.slice(2,3),a){case"0":return t("420","SHIP TO POST",_,E,20);case"1":return c("421","SHIP TO POST",_,E);case"2":return s("422","ORIGIN",3,_);case"3":return t("423","COUNTRY - INITIAL PROCESS.",_,E,15);case"4":return s("424","COUNTRY - PROCESS.",3,_);case"5":return s("425","COUNTRY - DISASSEMBLY",3,_);case"6":return s("426","COUNTRY - FULL PROCESS",3,_);case"7":return t("427","ORIGIN SUBDIVISION",_,E,3);default:throw new O("42",a)}default:throw new O("4",T)}case"7":switch(T){case"0":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"1":return t("7001","NSN",_,E,13);case"2":return t("7002","MEAT CUT",_,E);case"3":return t("7003","EXPIRY TIME",_,E,10);case"4":return t("7004","ACTIVE POTENCY",_,E,6);default:throw new O("70",a)}case"3":return c("703"+e,"PROCESSOR # "+e,_,E);default:throw new O("70",a)}case"1":switch(a=_.slice(2,3),a){case"0":return t("710","NHRN PZN",_,E);case"1":return t("711","NHRN CIP",_,E);case"2":return t("712","NHRN CN",_,E);case"3":return t("713","NHRN DRN",_,E);default:throw new O("71",a)}default:throw new O("7",T)}case"8":switch(T){case"0":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"1":return t("8001","DIMENSIONS",_,E,14);case"2":return t("8002","CMT No",_,E);case"3":return t("8003","GRAI",_,E);case"4":return t("8004","GIAI",_,E);case"5":return t("8005","PRICE PER UNIT",_,E,6);case"6":return t("8006","GCTIN",_,E,18);case"7":return t("8007","IBAN",_,E);case"8":return t("8008","PROD TIME",_,E,12);default:throw new O("800",e)}case"1":switch(e){case"0":return t("8010","CPID",_,E);case"1":return t("8011","CPID SERIAL",_,E);case"7":return t("8017","GSRN - PROVIDER",_,E,18);case"8":return t("8018","GSRN - RECIPIENT",_,E,18,!0);case"9":return t("8019","SRIN",_,E,void 0,!0);default:throw new O("801",e)}case"2":switch(e){case"0":return t("8020","REF No",_,E);default:throw new O("802",e)}default:throw new O("80",a)}case"1":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"0":return t("8100","-",_,E,6);case"1":return t("8101","-",_,E,10);case"2":return t("8102","-",_,E,2);default:throw new O("810",e)}case"1":switch(e){case"0":return t("8110","-",_,E);default:throw new O("811",e)}default:throw new O("81",a)}case"2":switch(a=_.slice(2,3),a){case"0":return t("8200","PRODUCT URL",_,E);default:throw new O("82",a)}default:throw new O("8",T)}case"9":switch(T){case"0":return t("90","INTERNAL",_,E);case"1":return t("91","INTERNAL",_,E);case"2":return t("92","INTERNAL",_,E);case"3":return t("93","INTERNAL",_,E);case"4":return t("94","INTERNAL",_,E);case"5":return t("95","INTERNAL",_,E);case"6":return t("96","INTERNAL",_,E);case"7":return t("97","INTERNAL",_,E);case"8":return t("98","INTERNAL",_,E);case"9":return t("99","INTERNAL",_,E);default:throw new O("9",T)}default:throw new O("",I)}}r(w,"identifyAI");function F(_,i,E){if(!_||typeof _!="string")throw new G(2,"31","The barcode is empty or not a string.");let I=_.length,T={codeName:"",denormalized:"",parsedCodeItems:[]},a="",e=_.slice(0,3),L;switch(e){case"]C1":T.codeName="GS1-128",a=_.slice(3,I);break;case"]e0":T.codeName="GS1 DataBar",a=_.slice(3,I);break;case"]e1":case"]e2":T.codeName="GS1 Composite",a=_.slice(3,I);break;case"]d2":T.codeName="GS1 DataMatrix",a=_.slice(3,I);break;case"]Q3":T.codeName="GS1 QR Code",a=_.slice(3,I);break;default:T.codeName="",a=_;break}for(T.parsedCodeItems=[];a.length>0;)try{L=w(a,E),a=g(L.codestring,i),T.parsedCodeItems.push(L.element),T.denormalized+="("+L.element.ai+")"+L.element.dataString}catch(R){if(R instanceof A)B(R);else throw R}return T}r(F,"parseBarcode");function B(_){switch(_.code){case"32":throw new G(6,32,"Invalid normal AI.");case"33":throw new G(7,33,"L'anno nella data non \xE8 valido.");case"34":throw new G(7,34,"Il mese nella data non \xE8 valido.");case"36":throw new G(8,36,"Numeri non validi");default:throw _}}r(B,"handleInternalError");var P=class{static{r(this,"GS1Parser")}fncChar;lotLen;constructor(i){this.fncChar=i?.fncChar||C,this.lotLen=i?.lotMaxLength}decode(i){let E=i.replaceAll("(",this.fncChar).replaceAll(")","");E.startsWith(this.fncChar)&&(E=E.slice(1));let I=F(E,this.fncChar,this.lotLen),T={};for(let a of I.parsedCodeItems){let e=V["ai"+a.ai];e&&(T[e]=a)}return new l(I.codeName,I.denormalized,T)}};export{P as GS1Parser};
|
|
1
|
+
var Y=Object.defineProperty;var r=(_,i)=>Y(_,"name",{value:i,configurable:!0});var V={ai00:"sscc",ai01:"gtin",ai02:"content",ai10:"batch",ai11:"prodDate",ai12:"dueDate",ai13:"packDate",ai15:"bestBefore",ai16:"sellBy",ai17:"expDate",ai20:"variant",ai21:"serial",ai22:"hibcc",ai235:"tpx",ai240:"additionalProductID",ai241:"customerPartNumber",ai242:"madeToOrder",ai243:"packaging",ai250:"secondarySerialNumber",ai251:"refSource",ai253:"gdti",ai254:"glnExtension",ai255:"gcn",ai30:"variableCount",ai310:"netWeightKg0",ai3100:"netWeightKg0",ai3101:"netWeightKg1",ai3102:"netWeightKg2",ai3103:"netWeightKg3",ai3104:"netWeightKg4",ai3105:"netWeightKg5",ai3110:"lengthMeters0",ai3111:"lengthMeters1",ai3112:"lengthMeters2",ai3113:"lengthMeters3",ai3114:"lengthMeters4",ai3115:"lengthMeters5",ai3120:"widthMeters0",ai3121:"widthMeters1",ai3122:"widthMeters2",ai3123:"widthMeters3",ai3124:"widthMeters4",ai3125:"widthMeters5",ai3130:"heightMeters0",ai3131:"heightMeters1",ai3132:"heightMeters2",ai3133:"heightMeters3",ai3134:"heightMeters4",ai3135:"heightMeters5",ai3140:"areaSquareMeters0",ai3141:"areaSquareMeters1",ai3142:"areaSquareMeters2",ai3143:"areaSquareMeters3",ai3144:"areaSquareMeters4",ai3145:"areaSquareMeters5",ai3150:"netVolumeLiters0",ai3151:"netVolumeLiters1",ai3152:"netVolumeLiters2",ai3153:"netVolumeLiters3",ai3154:"netVolumeLiters4",ai3155:"netVolumeLiters5",ai3160:"netVolumeCubicMeters0",ai3161:"netVolumeCubicMeters1",ai3162:"netVolumeCubicMeters2",ai3163:"netVolumeCubicMeters3",ai3164:"netVolumeCubicMeters4",ai3165:"netVolumeCubicMeters5",ai3200:"netWeightLb0",ai3201:"netWeightLb1",ai3202:"netWeightLb2",ai3203:"netWeightLb3",ai3204:"netWeightLb4",ai3205:"netWeightLb5",ai3210:"lengthInches0",ai3211:"lengthInches1",ai3212:"lengthInches2",ai3213:"lengthInches3",ai3214:"lengthInches4",ai3215:"lengthInches5",ai3220:"lengthFeet0",ai3221:"lengthFeet1",ai3222:"lengthFeet2",ai3223:"lengthFeet3",ai3224:"lengthFeet4",ai3225:"lengthFeet5",ai3230:"lengthYards0",ai3231:"lengthYards1",ai3232:"lengthYards2",ai3233:"lengthYards3",ai3234:"lengthYards4",ai3235:"lengthYards5",ai3240:"widthInches0",ai3241:"widthInches1",ai3242:"widthInches2",ai3243:"widthInches3",ai3244:"widthInches4",ai3245:"widthInches5",ai3250:"widthFeet0",ai3251:"widthFeet1",ai3252:"widthFeet2",ai3253:"widthFeet3",ai3254:"widthFeet4",ai3255:"widthFeet5",ai3260:"widthYards0",ai3261:"widthYards1",ai3262:"widthYards2",ai3263:"widthYards3",ai3264:"widthYards4",ai3265:"widthYards5",ai3270:"heightInches0",ai3271:"heightInches1",ai3272:"heightInches2",ai3273:"heightInches3",ai3274:"heightInches4",ai3275:"heightInches5",ai3280:"heightFeet0",ai3281:"heightFeet1",ai3282:"heightFeet2",ai3283:"heightFeet3",ai3284:"heightFeet4",ai3285:"heightFeet5",ai3290:"heightYards0",ai3291:"heightYards1",ai3292:"heightYards2",ai3293:"heightYards3",ai3294:"heightYards4",ai3295:"heightYards5",ai3300:"grossWeightKg0",ai3301:"grossWeightKg1",ai3302:"grossWeightKg2",ai3303:"grossWeightKg3",ai3304:"grossWeightKg4",ai3305:"grossWeightKg5",ai3310:"lengthMetersLog0",ai3311:"lengthMetersLog1",ai3312:"lengthMetersLog2",ai3313:"lengthMetersLog3",ai3314:"lengthMetersLog4",ai3315:"lengthMetersLog5",ai3320:"widthMetersLog0",ai3321:"widthMetersLog1",ai3322:"widthMetersLog2",ai3323:"widthMetersLog3",ai3324:"widthMetersLog4",ai3325:"widthMetersLog5",ai3330:"heightMetersLog0",ai3331:"heightMetersLog1",ai3332:"heightMetersLog2",ai3333:"heightMetersLog3",ai3334:"heightMetersLog4",ai3335:"heightMetersLog5",ai3340:"areaSquareInches0",ai3341:"areaSquareInches1",ai3342:"areaSquareInches2",ai3343:"areaSquareInches3",ai3344:"areaSquareInches4",ai3345:"areaSquareInches5",ai3350:"areaSquareFeet0",ai3351:"areaSquareFeet1",ai3352:"areaSquareFeet2",ai3353:"areaSquareFeet3",ai3354:"areaSquareFeet4",ai3355:"areaSquareFeet5",ai3360:"areaSquareYards0",ai3361:"areaSquareYards1",ai3362:"areaSquareYards2",ai3363:"areaSquareYards3",ai3364:"areaSquareYards4",ai3365:"areaSquareYards5",ai3370:"areaSquareMetersLog0",ai3371:"areaSquareMetersLog1",ai3372:"areaSquareMetersLog2",ai3373:"areaSquareMetersLog3",ai3374:"areaSquareMetersLog4",ai3375:"areaSquareMetersLog5",ai3400:"netWeightOunces0",ai3401:"netWeightOunces1",ai3402:"netWeightOunces2",ai3403:"netWeightOunces3",ai3404:"netWeightOunces4",ai3405:"netWeightOunces5",ai3410:"netVolumeQuarts0",ai3411:"netVolumeQuarts1",ai3412:"netVolumeQuarts2",ai3413:"netVolumeQuarts3",ai3414:"netVolumeQuarts4",ai3415:"netVolumeQuarts5",ai3420:"netVolumeGallons0",ai3421:"netVolumeGallons1",ai3422:"netVolumeGallons2",ai3423:"netVolumeGallons3",ai3424:"netVolumeGallons4",ai3425:"netVolumeGallons5",ai3430:"volumeCubicInches0",ai3431:"volumeCubicInches1",ai3432:"volumeCubicInches2",ai3433:"volumeCubicInches3",ai3434:"volumeCubicInches4",ai3435:"volumeCubicInches5",ai3440:"volumeCubicFeet0",ai3441:"volumeCubicFeet1",ai3442:"volumeCubicFeet2",ai3443:"volumeCubicFeet3",ai3444:"volumeCubicFeet4",ai3445:"volumeCubicFeet5",ai3450:"volumeCubicYards0",ai3451:"volumeCubicYards1",ai3452:"volumeCubicYards2",ai3453:"volumeCubicYards3",ai3454:"volumeCubicYards4",ai3455:"volumeCubicYards5",ai3460:"volumeCubicMetersLog0",ai3461:"volumeCubicMetersLog1",ai3462:"volumeCubicMetersLog2",ai3463:"volumeCubicMetersLog3",ai3464:"volumeCubicMetersLog4",ai3465:"volumeCubicMetersLog5",ai3500:"grossWeightLb0",ai3501:"grossWeightLb1",ai3502:"grossWeightLb2",ai3503:"grossWeightLb3",ai3504:"grossWeightLb4",ai3505:"grossWeightLb5",ai3510:"lengthInchesLog0",ai3511:"lengthInchesLog1",ai3512:"lengthInchesLog2",ai3513:"lengthInchesLog3",ai3514:"lengthInchesLog4",ai3515:"lengthInchesLog5",ai3520:"lengthFeetLog0",ai3521:"lengthFeetLog1",ai3522:"lengthFeetLog2",ai3523:"lengthFeetLog3",ai3524:"lengthFeetLog4",ai3525:"lengthFeetLog5",ai3530:"lengthYardsLog0",ai3531:"lengthYardsLog1",ai3532:"lengthYardsLog2",ai3533:"lengthYardsLog3",ai3534:"lengthYardsLog4",ai3535:"lengthYardsLog5",ai3540:"widthInchesLog0",ai3541:"widthInchesLog1",ai3542:"widthInchesLog2",ai3543:"widthInchesLog3",ai3544:"widthInchesLog4",ai3545:"widthInchesLog5",ai3550:"widthFeetLog0",ai3551:"widthFeetLog1",ai3552:"widthFeetLog2",ai3553:"widthFeetLog3",ai3554:"widthFeetLog4",ai3555:"widthFeetLog5",ai3560:"widthYardsLog0",ai3561:"widthYardsLog1",ai3562:"widthYardsLog2",ai3563:"widthYardsLog3",ai3564:"widthYardsLog4",ai3565:"widthYardsLog5",ai3570:"heightInchesLog0",ai3571:"heightInchesLog1",ai3572:"heightInchesLog2",ai3573:"heightInchesLog3",ai3574:"heightInchesLog4",ai3575:"heightInchesLog5",ai3580:"heightFeetLog0",ai3581:"heightFeetLog1",ai3582:"heightFeetLog2",ai3583:"heightFeetLog3",ai3584:"heightFeetLog4",ai3585:"heightFeetLog5",ai3590:"heightYardsLog0",ai3591:"heightYardsLog1",ai3592:"heightYardsLog2",ai3593:"heightYardsLog3",ai3594:"heightYardsLog4",ai3595:"heightYardsLog5",ai3600:"grossWeightOunces0",ai3601:"grossWeightOunces1",ai3602:"grossWeightOunces2",ai3603:"grossWeightOunces3",ai3604:"grossWeightOunces4",ai3605:"grossWeightOunces5",ai3610:"netVolumeFluidOunces0",ai3611:"netVolumeFluidOunces1",ai3612:"netVolumeFluidOunces2",ai3613:"netVolumeFluidOunces3",ai3614:"netVolumeFluidOunces4",ai3615:"netVolumeFluidOunces5",ai3620:"grossVolumeQuarts0",ai3621:"grossVolumeQuarts1",ai3622:"grossVolumeQuarts2",ai3623:"grossVolumeQuarts3",ai3624:"grossVolumeQuarts4",ai3625:"grossVolumeQuarts5",ai3630:"grossVolumeGallons0",ai3631:"grossVolumeGallons1",ai3632:"grossVolumeGallons2",ai3633:"grossVolumeGallons3",ai3634:"grossVolumeGallons4",ai3635:"grossVolumeGallons5",ai3640:"volumeCubicInchesLog0",ai3641:"volumeCubicInchesLog1",ai3642:"volumeCubicInchesLog2",ai3643:"volumeCubicInchesLog3",ai3644:"volumeCubicInchesLog4",ai3645:"volumeCubicInchesLog5",ai3650:"volumeCubicFeetLog0",ai3651:"volumeCubicFeetLog1",ai3652:"volumeCubicFeetLog2",ai3653:"volumeCubicFeetLog3",ai3654:"volumeCubicFeetLog4",ai3655:"volumeCubicFeetLog5",ai3660:"volumeCubicYardsLog0",ai3661:"volumeCubicYardsLog1",ai3662:"volumeCubicYardsLog2",ai3663:"volumeCubicYardsLog3",ai3664:"volumeCubicYardsLog4",ai3665:"volumeCubicYardsLog5",ai37:"count",ai3900:"amountPayable0",ai3901:"amountPayable1",ai3902:"amountPayable2",ai3903:"amountPayable3",ai3904:"amountPayable4",ai3905:"amountPayable5",ai3910:"amountPayableISO0",ai3911:"amountPayableISO1",ai3912:"amountPayableISO2",ai3913:"amountPayableISO3",ai3914:"amountPayableISO4",ai3915:"amountPayableISO5",ai3920:"price0",ai3921:"price1",ai3922:"price2",ai3923:"price3",ai3930:"priceISO0",ai3931:"priceISO1",ai3932:"priceISO2",ai3933:"priceISO3",ai3940:"percentDiscount0",ai3941:"percentDiscount1",ai3942:"percentDiscount2",ai3943:"percentDiscount3",ai3950:"pricePerUnitMeasure0",ai3951:"pricePerUnitMeasure1",ai3952:"pricePerUnitMeasure2",ai3953:"pricePerUnitMeasure3",ai3954:"pricePerUnitMeasure4",ai3955:"pricePerUnitMeasure5",ai400:"orderNumber",ai401:"ginc",ai402:"gsin",ai403:"route",ai410:"shipTo",ai411:"billTo",ai412:"purchaseFrom",ai413:"shipFor",ai414:"locNo",ai415:"payTo",ai416:"prodServLoc",ai417:"party",ai420:"shipToPost",ai421:"shipToPostISO",ai422:"origin",ai423:"countryInitialProcess",ai424:"countryProcess",ai425:"countryDisassembly",ai426:"countryFullProcess",ai427:"originSubdivision",ai7001:"nsn",ai7002:"meatCut",ai7003:"expirationDateTime",ai7004:"activePotency",ai7005:"catchArea",ai7006:"firstFreezeDate",ai7007:"harvestDate",ai7008:"aquaticSpecies",ai7009:"fishingGearType",ai7010:"prodMethod",ai7020:"refurbLot",ai7021:"funcStat",ai7022:"revStat",ai7023:"giaiAssembly",ai7030:"processor",ai7031:"processor2",ai7032:"processor3",ai7033:"processor4",ai7034:"processor5",ai7035:"processor6",ai7036:"processor7",ai7037:"processor8",ai7038:"processor9",ai7039:"processor10",ai7040:"uicExt",ai7041:"ufrgtUnitType",ai710:"nhrnPzn",ai711:"nhrnCip",ai712:"nhrnCn",ai713:"nhrnDrn",ai714:"nhrnAim",ai715:"nhrnDnc",ai716:"nhrnAic",ai8001:"rollProducts",ai8002:"cmtNo",ai8003:"grai",ai8004:"giai",ai8005:"pricePerUnit",ai8006:"itip",ai8007:"iban",ai8008:"prodTime",ai8009:"opticalSensor",ai8010:"cpid",ai8011:"cpidSerial",ai8012:"version",ai8013:"gmn",ai8017:"gsrnProvider",ai8018:"gsrnRecipient",ai8019:"srin",ai8020:"refNo",ai8026:"itipContent",ai8030:"digSig",ai8110:"coupon",ai8111:"points",ai8112:"couponExtended",ai8200:"productURL",ai90:"internal1",ai91:"internal2",ai92:"internal3",ai93:"internal4",ai94:"internal5",ai95:"internal6",ai96:"internal7",ai97:"internal8",ai98:"internal9",ai99:"internal10"};var M=String.fromCodePoint(29),l=/^\d+$/;var A=class extends Error{static{r(this,"InternalError")}constructor(i,E){super(i),this.name="InternalError",this.code=i,this.ex=E}ex;code},R=class extends Error{static{r(this,"InvalidAiError")}constructor(i,E){let S;i?S=`Invalid AI identifier "${E}" after "${i}"`:S=`Invalid first AI identifier "${E}"`,super(S),this.name="InvalidAiError"}},G=class extends Error{static{r(this,"BarcodeError")}constructor(i,E,S){super(S),this.name="BarcodeError",this.num=i,this.code=E,this.des=S}num;code;des},H=class{static{r(this,"ParsedElementClass")}ai;dataTitle;data;dataString;unit;constructor(i,E,S){switch(this.ai=i,this.dataTitle=E,this.unit="",this.dataString="",S){case"S":this.data="";break;case"N":this.data=0;break;case"D":this.data=new Date,this.data.setHours(0,0,0,0);break;default:this.data="";break}}},C=class{constructor(i,E,S={}){this.codeName=i;this.denormalized=E;this.data=S}static{r(this,"DecodeResult")}};function m(_,i){let E=_,S=E.slice(0,1);for(;S===i;)E=E.slice(1),S=E.slice(0,1);return E}r(m,"cleanCodestring");function F(_,i,E){if(i<0||i>11)return!1;let S=i;E===0&&S++;let t=new Date(_,S,E);return t.getFullYear()===_&&t.getMonth()===i&&(t.getDate()===E||E===0)}r(F,"checkValidDate");function h(_,i){let E=_.length-i,S=_.slice(0,E)+"."+_.slice(E);try{return Number.parseFloat(S)}catch(t){throw new A("36",t)}}r(h,"parseFloatingPoint");function n(_,i,E){let S=new H(_,i,"D"),t=_.length,a=E.slice(t,t+6),e=0,L=0,O=0;try{e=Number.parseInt(a.slice(0,2),10)}catch(N){throw new A("33",N)}try{L=Number.parseInt(a.slice(2,4),10)-1}catch(N){throw new A("34",N)}try{O=Number.parseInt(a.slice(4,6),10)}catch(N){throw new A("35",N)}if(e>50?e=e+1900:e=e+2e3,!F(e,L,O))throw new G(7,"36",`Invalid date "${a}" for AI "${_}".`);return O===0&&L++,S.data.setFullYear(e,L,O),S.dataString=a,{element:S,codestring:E.slice(t+6,E.length)}}r(n,"parseDate");function s(_,i,E,S,t=!1){let a=new H(_,i,"S"),e=_.length,L=S.slice(e,E+e);if(L.length<E)throw new G(9,"37",`Data length ${L.length} is less than expected length ${E} for AI "${_}".`);if(t&&!l.test(L))throw new G(11,"39",`Numeric data expected for AI "${_}", but got "${L}".`);a.data=L,a.dataString=L;let O=S.slice(E+e,S.length);return{element:a,codestring:O}}r(s,"parseFixedLength");function T(_,i,E,S,t,a=!1){let e=new H(_,i,"S"),L=_.length,O=E.indexOf(S),N="";if(O===-1?t&&t>0?(e.data=E.slice(L,t+L),N=E.replace(_+e.data,"")):e.data=E.slice(L,E.length):(e.data=E.slice(L,O),N=E.slice(O+1,E.length)),e.data==="")throw new G(10,"38",`Variable length data for AI "${_}" is empty.`);if(a&&!l.test(e.data))throw new G(11,"39",`Numeric data expected for AI "${_}", but got "${e.data}".`);return e.dataString=e.data,{element:e,codestring:N}}r(T,"parseVariableLength");function D(_,i,E,S,t,a){let e=new H(_+i,E,"N"),L=_.length+1,O=t.indexOf(a),N=Number.parseInt(i,10),u="",U="";return O===-1?u=t.slice(L,t.length):(u=t.slice(L,O),U=t.slice(O+1,t.length)),e.data=h(u,N),e.dataString=u,e.unit=S,{element:e,codestring:U}}r(D,"parseVariableLengthMeasure");function I(_,i,E,S,t){let a=new H(_+i,E,"N"),e=_.length+1;if(!l.test(i))throw new R(_,i);let L=Number.parseInt(i,10),O=t.slice(e,e+6);if(!l.test(O))throw new G(11,"39",`Numeric data expected for AI "${_+i}", but got "${O}".`);a.data=h(O,L),a.dataString=O,a.unit=S;let N=t.slice(e+6,t.length);return{element:a,codestring:N}}r(I,"parseFixedLengthMeasure");function o(_,i,E,S,t){let a=new H(_+i,E,"N"),e=_.length+1,L=S.indexOf(t),O=Number.parseInt(i,10),N="",u="",U="";return L===-1?N=S.slice(e,S.length):(N=S.slice(e,L),U=S.slice(L+1,S.length)),u=N.slice(3,N.length),a.data=h(u,O),a.dataString=u,a.unit=N.slice(0,3),{element:a,codestring:U}}r(o,"parseVariableLengthWithISONumbers");function c(_,i,E,S){let t=new H(_,i,"S"),a=_.length,e=E.indexOf(S),L="",O="";return e===-1?L=E.slice(a,E.length):(L=E.slice(a,e),O=E.slice(e+1,E.length)),t.data=L.slice(3,L.length),t.unit=L.slice(0,3),t.dataString=L,{element:t,codestring:O}}r(c,"parseVariableLengthWithISOChars");function w(_,i,E){E||(E=M);let S=_.slice(0,1),t=_.slice(1,2),a="",e="";switch(S){case"0":switch(t){case"0":return s("00","SSCC",18,_,!0);case"1":return s("01","GTIN",14,_,!0);case"2":return s("02","CONTENT",14,_);case"3":return s("03","MTO GTIN",14,_);default:throw new R("0",t)}case"1":switch(t){case"0":return T("10","BATCH/LOT",_,E,i??20);case"1":return n("11","PROD DATE",_);case"2":return n("12","DUE DATE",_);case"3":return n("13","PACK DATE",_);case"5":return n("15","BEST BEFORE or BEST BY",_);case"6":return n("16","SELL BY",_);case"7":return n("17","USE BY OR EXPIRY",_);default:throw new R("1",t)}case"2":switch(t){case"0":return s("20","VARIANT",2,_);case"1":return T("21","SERIAL",_,E,i??20);case"2":return T("22","CPV",_,E,20);case"3":switch(a=_.slice(2,3),a){case"5":return T("235","TPX",_,E,28);default:throw new R("23",a)}case"4":switch(a=_.slice(2,3),a){case"0":return T("240","ADDITIONAL ID",_,E,30);case"1":return T("241","CUST. PART NO.",_,E,30);case"2":return T("242","MTO VARIANT",_,E,6,!0);case"3":return T("243","PCN",_,E,20);default:throw new R("24",a)}case"5":switch(a=_.slice(2,3),a){case"0":return T("250","SECONDARY SERIAL",_,E,30);case"1":return T("251","REF. TO SOURCE",_,E,30);case"3":return T("253","GDTI",_,E,42);case"4":return T("254","GLN EXTENSION COMPONENT",_,E,20);case"5":return T("255","GCN",_,E,25,!0);default:throw new R("25",a)}default:throw new R("2",t)}case"3":switch(t){case"0":return T("30","VAR. COUNT",_,E,8,!0);case"1":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return I("310",e,"NET WEIGHT (kg)","KGM",_);case"1":return I("311",e,"LENGTH (m)","MTR",_);case"2":return I("312",e,"WIDTH (m)","MTR",_);case"3":return I("313",e,"HEIGHT (m)","MTR",_);case"4":return I("314",e,"AREA (m2)","MTK",_);case"5":return I("315",e,"NET VOLUME (l)","LTR",_);case"6":return I("316",e,"NET VOLUME (m3)","MTQ",_);default:throw new R("31",a)}case"2":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return I("320",e,"NET WEIGHT (lb)","LBR",_);case"1":return I("321",e,"LENGTH (i)","INH",_);case"2":return I("322",e,"LENGTH (f)","FOT",_);case"3":return I("323",e,"LENGTH (y)","YRD",_);case"4":return I("324",e,"WIDTH (i)","INH",_);case"5":return I("325",e,"WIDTH (f)","FOT",_);case"6":return I("326",e,"WIDTH (y)","YRD",_);case"7":return I("327",e,"HEIGHT (i)","INH",_);case"8":return I("328",e,"HEIGHT (f)","FOT",_);case"9":return I("329",e,"HEIGHT (y)","YRD",_);default:throw new R("32",a)}case"3":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return I("330",e,"GROSS WEIGHT (kg)","KGM",_);case"1":return I("331",e,"LENGTH (m), log","MTR",_);case"2":return I("332",e,"WIDTH (m), log","MTR",_);case"3":return I("333",e,"HEIGHT (m), log","MTR",_);case"4":return I("334",e,"AREA (m2), log","MTK",_);case"5":return I("335",e,"VOLUME (l), log","LTR",_);case"6":return I("336",e,"VOLUME (m3), log","MTQ",_);case"7":return I("337",e,"KG PER m\xB2","28",_);default:throw new R("33",a)}case"4":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return I("340",e,"GROSS WEIGHT (lb)","LBR",_);case"1":return I("341",e,"LENGTH (i), log","INH",_);case"2":return I("342",e,"LENGTH (f), log","FOT",_);case"3":return I("343",e,"LENGTH (y), log","YRD",_);case"4":return I("344",e,"WIDTH (i), log","INH",_);case"5":return I("345",e,"WIDTH (f), log","FOT",_);case"6":return I("346",e,"WIDTH (y), log","YRD",_);case"7":return I("347",e,"HEIGHT (i), log","INH",_);case"8":return I("348",e,"HEIGHT (f), log","FOT",_);case"9":return I("349",e,"HEIGHT (y), log","YRD",_);default:throw new R("33",a)}case"5":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return I("350",e,"AREA (i2)","INK",_);case"1":return I("351",e,"AREA (f2)","FTK",_);case"2":return I("352",e,"AREA (y2)","YDK",_);case"3":return I("353",e,"AREA (i2), log","INK",_);case"4":return I("354",e,"AREA (f2), log","FTK",_);case"5":return I("355",e,"AREA (y2), log","YDK",_);case"6":return I("356",e,"NET WEIGHT (t)","APZ",_);case"7":return I("357",e,"NET VOLUME (oz)","ONZ",_);default:throw new R("35",a)}case"6":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return I("360",e,"NET VOLUME (q)","QT",_);case"1":return I("361",e,"NET VOLUME (g)","GLL",_);case"2":return I("362",e,"VOLUME (q), log","QT",_);case"3":return I("363",e,"VOLUME (g), log","GLL",_);case"4":return I("364",e,"VOLUME (i3)","INQ",_);case"5":return I("365",e,"VOLUME (f3)","FTQ",_);case"6":return I("366",e,"VOLUME (y3)","YDQ",_);case"7":return I("367",e,"VOLUME (i3), log","INQ",_);case"8":return I("368",e,"VOLUME (f3), log","FTQ",_);case"9":return I("369",e,"VOLUME (y3), log","YDQ",_);default:throw new R("36",a)}case"7":return T("37","COUNT",_,E,8);case"9":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":return D("390",e,"AMOUNT","",_,E);case"1":return o("391",e,"AMOUNT",_,E);case"2":return D("392",e,"PRICE","",_,E);case"3":return o("393",e,"PRICE",_,E);default:throw new R("39",a)}default:throw new R("3",t)}case"4":switch(t){case"0":switch(a=_.slice(2,3),a){case"0":return T("400","ORDER NUMBER",_,E,30);case"1":return T("401","GINC",_,E);case"2":return T("402","GSIN",_,E,17,!0);case"3":return T("403","ROUTE",_,E,30);default:throw new R("40",a)}case"1":switch(a=_.slice(2,3),a){case"0":return s("410","SHIP TO LOC",13,_,!0);case"1":return s("411","BILL TO",13,_,!0);case"2":return s("412","PURCHASE FROM",13,_,!0);case"3":return s("413","SHIP FOR LOC",13,_,!0);case"4":return s("414","LOC NO",13,_,!0);case"5":return s("415","PAY TO",13,_,!0);case"6":return s("416","PROD/SERV LOC",13,_,!0);case"7":return s("417","PARTY",13,_,!0);default:throw new R("41",a)}case"2":switch(a=_.slice(2,3),a){case"0":return T("420","SHIP TO POST",_,E,20);case"1":return c("421","SHIP TO POST",_,E);case"2":return s("422","ORIGIN",3,_,!0);case"3":return T("423","COUNTRY - INITIAL PROCESS.",_,E,15);case"4":return s("424","COUNTRY - PROCESS.",3,_,!0);case"5":return s("425","COUNTRY - DISASSEMBLY",3,_,!0);case"6":return s("426","COUNTRY - FULL PROCESS",3,_,!0);case"7":return T("427","ORIGIN SUBDIVISION",_,E,3);default:throw new R("42",a)}default:throw new R("4",t)}case"7":switch(t){case"0":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"1":return T("7001","NSN",_,E,13,!0);case"2":return T("7002","MEAT CUT",_,E);case"3":return T("7003","EXPIRY TIME",_,E,10,!0);case"4":return T("7004","ACTIVE POTENCY",_,E,4,!0);case"5":return T("7005","CATCH AREA",_,E,12);case"6":return n("7006","FIRST FREEZE DATE",_);case"7":return T("7007","HARVEST DATE",_,E,12,!0);case"8":return T("7008","AQUATIC SPECIES",_,E,3);case"9":return T("7009","FISHING GEAR TYPE",_,E,10);default:throw new R("700",e)}case"1":switch(e){case"0":return T("7010","PROD METHOD",_,E,2);case"1":return T("7011","TEST BY DATE",_,E,10,!0);default:throw new R("701",e)}case"2":switch(e){case"0":return T("7020","REFURB LOT",_,E,20);case"1":return T("7021","FUNC STAT",_,E,20);case"2":return T("7022","REV STAT",_,E,20);case"3":return T("7023","GIAI - ASSEMBLY",_,E,30);default:throw new R("702",e)}case"3":return c("703"+e,"PROCESSOR # "+e,_,E);default:throw new R("70",a)}case"1":switch(a=_.slice(2,3),a){case"0":return T("710","NHRN PZN",_,E);case"1":return T("711","NHRN CIP",_,E);case"2":return T("712","NHRN CN",_,E);case"3":return T("713","NHRN DRN",_,E);case"4":return T("714","NHRN AIM",_,E);case"5":return T("715","NHRN NDC",_,E);case"6":return T("716","NHRN AIC",_,E);default:throw new R("71",a)}default:throw new R("7",t)}case"8":switch(t){case"0":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"0":switch(e){case"1":return T("8001","DIMENSIONS",_,E,14);case"2":return T("8002","CMT No",_,E);case"3":return T("8003","GRAI",_,E);case"4":return T("8004","GIAI",_,E);case"5":return T("8005","PRICE PER UNIT",_,E,6);case"6":return T("8006","GCTIN",_,E,18);case"7":return T("8007","IBAN",_,E);case"8":return T("8008","PROD TIME",_,E,12);default:throw new R("800",e)}case"1":switch(e){case"0":return T("8010","CPID",_,E);case"1":return T("8011","CPID SERIAL",_,E);case"7":return T("8017","GSRN - PROVIDER",_,E,18);case"8":return T("8018","GSRN - RECIPIENT",_,E,18,!0);case"9":return T("8019","SRIN",_,E,void 0,!0);default:throw new R("801",e)}case"2":switch(e){case"0":return T("8020","REF No",_,E);case"6":return T("8026","ITIP CONTENT",_,E,18,!0);default:throw new R("802",e)}case"3":switch(e){case"0":return T("8030","DIGSIG",_,E);default:throw new R("803",e)}default:throw new R("80",a)}case"1":switch(a=_.slice(2,3),e=_.slice(3,4),a){case"1":switch(e){case"0":return T("8110","-",_,E);case"1":return T("8111","POINTS",_,E,4,!0);case"2":return T("8112","-",_,E);default:throw new R("811",e)}default:throw new R("81",a)}case"2":switch(a=_.slice(2,3),a){case"0":return T("8200","PRODUCT URL",_,E);default:throw new R("82",a)}default:throw new R("8",t)}case"9":switch(t){case"0":return T("90","INTERNAL",_,E,30);case"1":return T("91","INTERNAL",_,E);case"2":return T("92","INTERNAL",_,E);case"3":return T("93","INTERNAL",_,E);case"4":return T("94","INTERNAL",_,E);case"5":return T("95","INTERNAL",_,E);case"6":return T("96","INTERNAL",_,E);case"7":return T("97","INTERNAL",_,E);case"8":return T("98","INTERNAL",_,E);case"9":return T("99","INTERNAL",_,E);default:throw new R("9",t)}default:throw new R("",S)}}r(w,"identifyAI");function g(_,i,E){if(!_||typeof _!="string")throw new G(2,"31","The barcode is empty or not a string.");let S=_.length,t={codeName:"",denormalized:"",parsedCodeItems:[]},a="",e=_.slice(0,3),L;switch(e){case"]C1":t.codeName="GS1-128",a=_.slice(3,S);break;case"]e0":t.codeName="GS1 DataBar",a=_.slice(3,S);break;case"]e1":case"]e2":t.codeName="GS1 Composite",a=_.slice(3,S);break;case"]d2":t.codeName="GS1 DataMatrix",a=_.slice(3,S);break;case"]Q3":t.codeName="GS1 QR Code",a=_.slice(3,S);break;default:t.codeName="",a=_;break}for(t.parsedCodeItems=[];a.length>0;)try{L=w(a,E),a=m(L.codestring,i),t.parsedCodeItems.push(L.element),t.denormalized+="("+L.element.ai+")"+L.element.dataString}catch(O){if(O instanceof A)B(O);else throw O}return t}r(g,"parseBarcode");function B(_){switch(_.code){case"32":throw new G(6,32,"Invalid normal AI.");case"33":throw new G(7,33,"The year of the date is not valid.");case"34":throw new G(7,34,"The month of the date is not valid.");case"36":throw new G(8,36,"Invalid numbers");default:throw _}}r(B,"handleInternalError");var P=class{static{r(this,"GS1Parser")}fncChar;lotLen;constructor(i){this.fncChar=i?.fncChar||M,this.lotLen=i?.lotMaxLength}decode(i){let E=i.replaceAll("(",this.fncChar).replaceAll(")","");E.startsWith(this.fncChar)&&(E=E.slice(1));let S=g(E,this.fncChar,this.lotLen),t={};for(let a of S.parsedCodeItems){let e=V["ai"+a.ai];e&&(t[e]=a)}return new C(S.codeName,S.denormalized,t)}};export{P as GS1Parser};
|
package/package.json
CHANGED
|
@@ -1,42 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@valentynb/gs1-parser",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A typescript gs1-barcode parser. Based on code from https://github.com/
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"dev": "vite",
|
|
10
|
-
"build": "tsup src/index.ts --dts --format esm,cjs --clean --minify --keep-names",
|
|
11
|
-
"test": "vitest"
|
|
12
|
-
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@valentynb/gs1-parser",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "A typescript gs1-barcode parser. Based on code from https://github.com/PeterBrockfeld/BarcodeParser",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "vite",
|
|
10
|
+
"build": "tsup src/index.ts --dts --format esm,cjs --clean --minify --keep-names",
|
|
11
|
+
"test": "vitest"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"gs1",
|
|
24
|
+
"barcode",
|
|
25
|
+
"parsing",
|
|
26
|
+
"logistics"
|
|
27
|
+
],
|
|
28
|
+
"author": "Valentyn Blaha",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/valentynblaha/gs1-parser#readme",
|
|
31
|
+
"repository": {
|
|
32
|
+
"url": "git+https://github.com/valentynblaha/gs1-parser.git",
|
|
33
|
+
"type": "git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/valentynblaha/gs1-parser/issues"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@eslint/js": "^9.39.1",
|
|
40
|
+
"eslint": "^9.39.1",
|
|
41
|
+
"globals": "^16.5.0",
|
|
42
|
+
"jiti": "^2.6.1",
|
|
43
|
+
"tsup": "^8.5.1",
|
|
44
|
+
"typescript": "~5.9.3",
|
|
45
|
+
"typescript-eslint": "~8.46.4",
|
|
46
|
+
"vite": "^7.2.2",
|
|
47
|
+
"vitest": "^4.0.9"
|
|
48
|
+
}
|
|
49
|
+
}
|