@ancon/wildcat-utils 1.18.6 → 1.18.8
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const u=require("@ancon/wildcat-types"),s=require("../currency/getFormattedCurrency.js");require("../currency/getFormattedCurrencyPostfix.js");function y(e,t){return t?e-t>0?e-t:0:e}function M(e,t,i,r){const n=`${t}x ${e}`,o=y(t,i);if(o){const c=`(${o}x ${s(r.amount,r.currency)})`;return`${n} ${c}`}return n}function $(e){return e.reduce((i,r)=>{const{modification:n,name:o,freeAmount:c,quantity:f,cost:p,replacementName:m,totalCost:a}=r;switch(n){case u.ModificationType.Remove:i.removed.push(o);break;case u.ModificationType.Replace:{const d=`${o} → ${m} (${s(a.amount,a.currency)})`;i.replaced.push(d);break}default:{const d=M(o,f,c,p);i.added.push(d)}}return i},{added:[],removed:[],replaced:[]})}module.exports=$;
|
|
@@ -1,39 +1,52 @@
|
|
|
1
|
-
import { ModificationType as
|
|
2
|
-
import
|
|
1
|
+
import { ModificationType as u } from "@ancon/wildcat-types";
|
|
2
|
+
import f from "../currency/getFormattedCurrency.mjs";
|
|
3
3
|
import "../currency/getFormattedCurrencyPostfix.mjs";
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function $(t, e) {
|
|
5
|
+
return e ? t - e > 0 ? t - e : 0 : t;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
function l(t, e, o, r) {
|
|
8
|
+
const n = `${e}x ${t}`, i = $(e, o);
|
|
9
|
+
if (i) {
|
|
10
|
+
const d = `(${i}x ${f(
|
|
11
|
+
r.amount,
|
|
12
|
+
r.currency
|
|
13
|
+
)})`;
|
|
14
|
+
return `${n} ${d}`;
|
|
15
|
+
}
|
|
16
|
+
return n;
|
|
17
|
+
}
|
|
18
|
+
function x(t) {
|
|
19
|
+
return t.reduce(
|
|
20
|
+
(o, r) => {
|
|
10
21
|
const {
|
|
11
|
-
modification:
|
|
22
|
+
modification: n,
|
|
12
23
|
name: i,
|
|
13
|
-
freeAmount:
|
|
14
|
-
quantity:
|
|
15
|
-
cost:
|
|
16
|
-
replacementName:
|
|
17
|
-
totalCost:
|
|
18
|
-
} =
|
|
19
|
-
switch (
|
|
20
|
-
case
|
|
24
|
+
freeAmount: d,
|
|
25
|
+
quantity: s,
|
|
26
|
+
cost: m,
|
|
27
|
+
replacementName: p,
|
|
28
|
+
totalCost: c
|
|
29
|
+
} = r;
|
|
30
|
+
switch (n) {
|
|
31
|
+
case u.Remove:
|
|
21
32
|
o.removed.push(i);
|
|
22
33
|
break;
|
|
23
|
-
case
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
case u.Replace: {
|
|
35
|
+
const a = `${i} → ${p} (${f(
|
|
36
|
+
c.amount,
|
|
37
|
+
c.currency
|
|
27
38
|
)})`;
|
|
28
|
-
o.replaced.push(
|
|
39
|
+
o.replaced.push(a);
|
|
29
40
|
break;
|
|
30
41
|
}
|
|
31
42
|
default: {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
const a = l(
|
|
44
|
+
i,
|
|
45
|
+
s,
|
|
46
|
+
d,
|
|
47
|
+
m
|
|
48
|
+
);
|
|
49
|
+
o.added.push(a);
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
52
|
return o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function
|
|
1
|
+
"use strict";function m(t=0){if(t>1e3){const e=t/1e3;return Number.isInteger(e)?`${e} km`:`${e.toFixed(2)} km`}return Number.isInteger(t)?`${t} m`:`${t.toFixed(2)} m`}module.exports=m;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
2
|
-
if (
|
|
3
|
-
const
|
|
4
|
-
return Number.isInteger(
|
|
1
|
+
function m(t = 0) {
|
|
2
|
+
if (t > 1e3) {
|
|
3
|
+
const e = t / 1e3;
|
|
4
|
+
return Number.isInteger(e) ? `${e} km` : `${e.toFixed(2)} km`;
|
|
5
5
|
}
|
|
6
|
-
return Number.isInteger(
|
|
6
|
+
return Number.isInteger(t) ? `${t} m` : `${t.toFixed(2)} m`;
|
|
7
7
|
}
|
|
8
8
|
export {
|
|
9
|
-
|
|
9
|
+
m as default
|
|
10
10
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OrderFormat,
|
|
1
|
+
import { OrderFormat, OutletListItem } from '@ancon/wildcat-types';
|
|
2
2
|
/**
|
|
3
3
|
* Get outlet's available order formats - included pre-order formats
|
|
4
4
|
* @param outlet Outlet list item
|
|
5
5
|
* @returns Array of OrderFormat
|
|
6
6
|
*/
|
|
7
|
-
export default function getOutletOrderFormats(outlet:
|
|
7
|
+
export default function getOutletOrderFormats(outlet: OutletListItem): OrderFormat[];
|