@shushed/helpers 0.0.217 → 0.0.218
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.
|
@@ -338,26 +338,17 @@ function onResponse(config, options, requiredFlag) {
|
|
|
338
338
|
cacheMaxAge: 0,
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
|
-
function parsePrices(priceData, timeZone = 'UTC'
|
|
341
|
+
function parsePrices(priceData, timeZone = 'UTC') {
|
|
342
342
|
const result = [];
|
|
343
343
|
const defaultStartDate = convertDateToDatetimeTZ(new Date(0).toISOString(), timeZone);
|
|
344
344
|
const defaultEndDate = convertDateToDatetimeTZ(new Date('2099-01-01T00:00:00Z').toISOString(), timeZone);
|
|
345
345
|
for (let i = 0; i < priceData.length; i += 1) {
|
|
346
|
-
const priceChanges = (priceData[i].price_changes || []).map(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return {
|
|
353
|
-
effective_from: x.effective_from ? (!isNaN(new Date(x.effective_from).getTime()) ? convertDateToDatetimeTZ(x.effective_from, timeZone) : null) : defaultStartDate,
|
|
354
|
-
effective_until: x.effective_until ? (!isNaN(new Date(x.effective_until).getTime()) ? convertDateToDatetimeTZ(x.effective_until, timeZone) : null) : defaultEndDate,
|
|
355
|
-
price: x.price,
|
|
356
|
-
price_type: x.price_type,
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
return null;
|
|
360
|
-
}).filter((x) => x !== null);
|
|
346
|
+
const priceChanges = (priceData[i].price_changes || []).map(x => ({
|
|
347
|
+
effective_from: x.effective_from ? (!isNaN(new Date(x.effective_from).getTime()) ? convertDateToDatetimeTZ(x.effective_from, timeZone) : null) : defaultStartDate,
|
|
348
|
+
effective_until: x.effective_until ? (!isNaN(new Date(x.effective_until).getTime()) ? convertDateToDatetimeTZ(x.effective_until, timeZone) : null) : defaultEndDate,
|
|
349
|
+
price: x.price,
|
|
350
|
+
price_type: x.price_type,
|
|
351
|
+
}));
|
|
361
352
|
const rrpPriceTypes = parsePriceType(priceChanges.filter((x) => x.price_type === 'rrp'));
|
|
362
353
|
const permPriceTypes = parsePriceType(priceChanges.filter((x) => x.price_type === 'perm'));
|
|
363
354
|
const posPriceTypes = parsePriceType(priceChanges.filter((x) => x.price_type === 'pos'));
|
|
@@ -377,7 +368,6 @@ function parsePrices(priceData, timeZone = 'UTC', options) {
|
|
|
377
368
|
}
|
|
378
369
|
result.push({
|
|
379
370
|
...priceData[i],
|
|
380
|
-
...(options?.overrideCurrency ? { currency: options.overrideCurrency } : {}),
|
|
381
371
|
current_price: currentPrice,
|
|
382
372
|
current_price_type: currentPriceType,
|
|
383
373
|
rrp: rrpPriceTypes,
|
|
@@ -79,10 +79,7 @@ type NormPrice = {
|
|
|
79
79
|
price: number;
|
|
80
80
|
price_type: 'rrp' | 'perm' | 'pos';
|
|
81
81
|
};
|
|
82
|
-
export declare function parsePrices<T extends Price>(priceData: T[], timeZone?: string
|
|
83
|
-
overrideCurrency?: string;
|
|
84
|
-
overridePrices?: (priceData: Exclude<T['price_changes'], undefined>[number]) => Exclude<Exclude<T['price_changes'], undefined>[number], undefined> | null;
|
|
85
|
-
}): (T & {
|
|
82
|
+
export declare function parsePrices<T extends Price>(priceData: T[], timeZone?: string): (T & {
|
|
86
83
|
rrp: {
|
|
87
84
|
current: NormPrice | undefined;
|
|
88
85
|
future: NormPrice[];
|