@ancon/wildcat-utils 1.40.35 → 1.40.37

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.
@@ -0,0 +1,2 @@
1
+ import { EAN13WeightPriceEmbeddedDecodeResult } from './types';
2
+ export default function decodeWeightPriceEmbeddedEAN13Barcode(barcode: string, skuLength?: number, weightLength?: number): EAN13WeightPriceEmbeddedDecodeResult;
@@ -0,0 +1 @@
1
+ "use strict";require("./validEAN13BarcodeCheckDigit.js");const P=require("./isWeightPriceEmbeddedEAN13Barcode.js"),i=require("./types.js");function E(t,d=5,h=4){if(!P(t))throw new Error("Invalid weight/price embedded EAN-13 barcode.");const c=2,m=t.slice(0,c),r=t.slice(-h-1,-1),s=t.slice(-1),b=t.slice(c,c+d),e={prefix:i.EAN13WeightPriceEmbeddedPrefix.WeightWithOneDecimal,productCode:b,checkDigit:s};switch(m){case i.EAN13WeightPriceEmbeddedPrefix.PriceWithTwoDecimals:e.prefix=i.EAN13WeightPriceEmbeddedPrefix.PriceWithTwoDecimals,e.price=Number((Number(r)/100).toFixed(2));break;case i.EAN13WeightPriceEmbeddedPrefix.PriceWithOneDecimal:e.prefix=i.EAN13WeightPriceEmbeddedPrefix.PriceWithOneDecimal,e.price=Number((Number(r)/10).toFixed(2));break;case i.EAN13WeightPriceEmbeddedPrefix.PriceAsInteger:e.prefix=i.EAN13WeightPriceEmbeddedPrefix.PriceAsInteger,e.price=Number(r);break;case i.EAN13WeightPriceEmbeddedPrefix.WeightWithThreeDecimals:e.prefix=i.EAN13WeightPriceEmbeddedPrefix.WeightWithThreeDecimals,e.weight=Number((Number(r)/1e3).toFixed(2));break;case i.EAN13WeightPriceEmbeddedPrefix.WeightWithTwoDecimals:e.prefix=i.EAN13WeightPriceEmbeddedPrefix.WeightWithTwoDecimals,e.weight=Number((Number(r)/100).toFixed(2));break;default:e.weight=Number((Number(r)/10).toFixed(2));break}return e}module.exports=E;
@@ -0,0 +1,36 @@
1
+ import "./validEAN13BarcodeCheckDigit.mjs";
2
+ import d from "./isWeightPriceEmbeddedEAN13Barcode.mjs";
3
+ import { EAN13WeightPriceEmbeddedPrefix as i } from "./types.mjs";
4
+ function p(t, m = 5, s = 4) {
5
+ if (!d(t))
6
+ throw new Error("Invalid weight/price embedded EAN-13 barcode.");
7
+ const c = 2, h = t.slice(0, c), r = t.slice(-s - 1, -1), o = t.slice(-1), a = t.slice(c, c + m), e = {
8
+ prefix: i.WeightWithOneDecimal,
9
+ productCode: a,
10
+ checkDigit: o
11
+ };
12
+ switch (h) {
13
+ case i.PriceWithTwoDecimals:
14
+ e.prefix = i.PriceWithTwoDecimals, e.price = Number((Number(r) / 100).toFixed(2));
15
+ break;
16
+ case i.PriceWithOneDecimal:
17
+ e.prefix = i.PriceWithOneDecimal, e.price = Number((Number(r) / 10).toFixed(2));
18
+ break;
19
+ case i.PriceAsInteger:
20
+ e.prefix = i.PriceAsInteger, e.price = Number(r);
21
+ break;
22
+ case i.WeightWithThreeDecimals:
23
+ e.prefix = i.WeightWithThreeDecimals, e.weight = Number((Number(r) / 1e3).toFixed(2));
24
+ break;
25
+ case i.WeightWithTwoDecimals:
26
+ e.prefix = i.WeightWithTwoDecimals, e.weight = Number((Number(r) / 100).toFixed(2));
27
+ break;
28
+ default:
29
+ e.weight = Number((Number(r) / 10).toFixed(2));
30
+ break;
31
+ }
32
+ return e;
33
+ }
34
+ export {
35
+ p as default
36
+ };
@@ -0,0 +1,4 @@
1
+ import validEAN13BarcodeCheckDigit from './validEAN13BarcodeCheckDigit';
2
+ import isWeightPriceEmbeddedEAN13Barcode from './isWeightPriceEmbeddedEAN13Barcode';
3
+ import decodeWeightPriceEmbeddedEAN13Barcode from './decodeWeightPriceEmbeddedEAN13Barcode';
4
+ export { validEAN13BarcodeCheckDigit, isWeightPriceEmbeddedEAN13Barcode, decodeWeightPriceEmbeddedEAN13Barcode, };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./validEAN13BarcodeCheckDigit.js"),d=require("./isWeightPriceEmbeddedEAN13Barcode.js"),r=require("./decodeWeightPriceEmbeddedEAN13Barcode.js");require("./types.js");exports.validEAN13BarcodeCheckDigit=e;exports.isWeightPriceEmbeddedEAN13Barcode=d;exports.decodeWeightPriceEmbeddedEAN13Barcode=r;
@@ -0,0 +1,9 @@
1
+ import { default as o } from "./validEAN13BarcodeCheckDigit.mjs";
2
+ import { default as t } from "./isWeightPriceEmbeddedEAN13Barcode.mjs";
3
+ import { default as c } from "./decodeWeightPriceEmbeddedEAN13Barcode.mjs";
4
+ import "./types.mjs";
5
+ export {
6
+ c as decodeWeightPriceEmbeddedEAN13Barcode,
7
+ t as isWeightPriceEmbeddedEAN13Barcode,
8
+ o as validEAN13BarcodeCheckDigit
9
+ };
@@ -0,0 +1 @@
1
+ export default function isWeighOrPriceEmbeddedBarcode(barcode: string): boolean;
@@ -0,0 +1 @@
1
+ "use strict";const i=require("./types.js"),t=require("./validEAN13BarcodeCheckDigit.js");function r(e){if(!t(e))throw new Error("Invalid EAN-13 barcode");return e.startsWith(i.EAN13WeightPriceEmbeddedPrefix.PriceWithTwoDecimals)||e.startsWith(i.EAN13WeightPriceEmbeddedPrefix.PriceWithOneDecimal)||e.startsWith(i.EAN13WeightPriceEmbeddedPrefix.PriceAsInteger)||e.startsWith(i.EAN13WeightPriceEmbeddedPrefix.WeightWithThreeDecimals)||e.startsWith(i.EAN13WeightPriceEmbeddedPrefix.WeightWithTwoDecimals)||e.startsWith(i.EAN13WeightPriceEmbeddedPrefix.WeightWithOneDecimal)}module.exports=r;
@@ -0,0 +1,12 @@
1
+ import { EAN13WeightPriceEmbeddedPrefix as i } from "./types.mjs";
2
+ import e from "./validEAN13BarcodeCheckDigit.mjs";
3
+ function s(t) {
4
+ if (!e(t))
5
+ throw new Error("Invalid EAN-13 barcode");
6
+ return t.startsWith(i.PriceWithTwoDecimals) || t.startsWith(i.PriceWithOneDecimal) || t.startsWith(i.PriceAsInteger) || t.startsWith(
7
+ i.WeightWithThreeDecimals
8
+ ) || t.startsWith(i.WeightWithTwoDecimals) || t.startsWith(i.WeightWithOneDecimal);
9
+ }
10
+ export {
11
+ s as default
12
+ };
@@ -0,0 +1,15 @@
1
+ export declare enum EAN13WeightPriceEmbeddedPrefix {
2
+ PriceWithTwoDecimals = "20",
3
+ PriceWithOneDecimal = "21",
4
+ PriceAsInteger = "22",
5
+ WeightWithThreeDecimals = "23",
6
+ WeightWithTwoDecimals = "24",
7
+ WeightWithOneDecimal = "25"
8
+ }
9
+ export declare type EAN13WeightPriceEmbeddedDecodeResult = {
10
+ prefix: EAN13WeightPriceEmbeddedPrefix;
11
+ productCode: string;
12
+ checkDigit: string;
13
+ weight?: number;
14
+ price?: number;
15
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var a=(t=>(t.PriceWithTwoDecimals="20",t.PriceWithOneDecimal="21",t.PriceAsInteger="22",t.WeightWithThreeDecimals="23",t.WeightWithTwoDecimals="24",t.WeightWithOneDecimal="25",t))(a||{});exports.EAN13WeightPriceEmbeddedPrefix=a;
@@ -0,0 +1,4 @@
1
+ var t = /* @__PURE__ */ ((a) => (a.PriceWithTwoDecimals = "20", a.PriceWithOneDecimal = "21", a.PriceAsInteger = "22", a.WeightWithThreeDecimals = "23", a.WeightWithTwoDecimals = "24", a.WeightWithOneDecimal = "25", a))(t || {});
2
+ export {
3
+ t as EAN13WeightPriceEmbeddedPrefix
4
+ };
@@ -0,0 +1 @@
1
+ export default function validEAN13BarcodeChecksum(barCode: string): boolean;
@@ -0,0 +1 @@
1
+ "use strict";function l(s){if(s.length!==13||!/^\d+$/.test(s))return!1;const t=s.split("").map(Number),c=t.pop(),u=(10-t.reduce((n,e,r)=>n+(r%2===0?e:e*3),0)%10)%10;return c===u}module.exports=l;
@@ -0,0 +1,12 @@
1
+ function a(e) {
2
+ if (e.length !== 13 || !/^\d+$/.test(e))
3
+ return !1;
4
+ const s = e.split("").map(Number), c = s.pop(), u = (10 - s.reduce(
5
+ (n, t, l) => n + (l % 2 === 0 ? t : t * 3),
6
+ 0
7
+ ) % 10) % 10;
8
+ return c === u;
9
+ }
10
+ export {
11
+ a as default
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.40.35",
3
+ "version": "1.40.37",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -36,6 +36,31 @@
36
36
  "require": "./api/isNoContentResponse.js",
37
37
  "types": "./api/isNoContentResponse.d.ts"
38
38
  },
39
+ "./barcode/decodeWeightPriceEmbeddedEAN13Barcode": {
40
+ "import": "./barcode/decodeWeightPriceEmbeddedEAN13Barcode.mjs",
41
+ "require": "./barcode/decodeWeightPriceEmbeddedEAN13Barcode.js",
42
+ "types": "./barcode/decodeWeightPriceEmbeddedEAN13Barcode.d.ts"
43
+ },
44
+ "./barcode": {
45
+ "import": "./barcode/index.mjs",
46
+ "require": "./barcode/index.js",
47
+ "types": "./barcode/index.d.ts"
48
+ },
49
+ "./barcode/isWeightPriceEmbeddedEAN13Barcode": {
50
+ "import": "./barcode/isWeightPriceEmbeddedEAN13Barcode.mjs",
51
+ "require": "./barcode/isWeightPriceEmbeddedEAN13Barcode.js",
52
+ "types": "./barcode/isWeightPriceEmbeddedEAN13Barcode.d.ts"
53
+ },
54
+ "./barcode/types": {
55
+ "import": "./barcode/types.mjs",
56
+ "require": "./barcode/types.js",
57
+ "types": "./barcode/types.d.ts"
58
+ },
59
+ "./barcode/validEAN13BarcodeCheckDigit": {
60
+ "import": "./barcode/validEAN13BarcodeCheckDigit.mjs",
61
+ "require": "./barcode/validEAN13BarcodeCheckDigit.js",
62
+ "types": "./barcode/validEAN13BarcodeCheckDigit.d.ts"
63
+ },
39
64
  "./card/getGiftCardStatus": {
40
65
  "import": "./card/getGiftCardStatus.mjs",
41
66
  "require": "./card/getGiftCardStatus.js",