@softwear/latestcollectioncore 1.0.60 → 1.0.62
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/dist/buildPropertyMappingFn.js +4 -2
- package/dist/consts.d.ts +1 -1
- package/dist/consts.js +1 -1
- package/dist/hasOnlyDigits.d.ts +0 -1
- package/dist/hasOnlyDigits.js +0 -1
- package/package.json +1 -1
- package/src/buildPropertyMappingFn.ts +4 -1
- package/src/consts.ts +1 -1
- package/src/hasOnlyDigits.ts +0 -1
- package/test/hasOnlyDigits.js +11 -0
|
@@ -62,9 +62,11 @@ function default_1(brands, strategy) {
|
|
|
62
62
|
const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
|
|
63
63
|
const mapping = indexedByBrandPropertyMapping[brand];
|
|
64
64
|
mappingPairs.forEach((pair) => {
|
|
65
|
-
var _a;
|
|
65
|
+
var _a, _b, _c, _d, _e;
|
|
66
66
|
const from = sku[pair.from] || '';
|
|
67
|
-
const
|
|
67
|
+
const redirectedMappingSource = (_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a['~~'];
|
|
68
|
+
const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {};
|
|
69
|
+
const to = ((_b = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _b === void 0 ? void 0 : _b[from]) || ((_c = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _c === void 0 ? void 0 : _c['']) || ((_d = redirectedMapping === null || redirectedMapping === void 0 ? void 0 : redirectedMapping[pair.category]) === null || _d === void 0 ? void 0 : _d[from]) || ((_e = redirectedMapping === null || redirectedMapping === void 0 ? void 0 : redirectedMapping[pair.category]) === null || _e === void 0 ? void 0 : _e['']);
|
|
68
70
|
if (to == undefined)
|
|
69
71
|
sku[pair.to] = '***';
|
|
70
72
|
});
|
package/dist/consts.d.ts
CHANGED
package/dist/consts.js
CHANGED
package/dist/hasOnlyDigits.d.ts
CHANGED
package/dist/hasOnlyDigits.js
CHANGED
package/package.json
CHANGED
|
@@ -57,7 +57,10 @@ export default function (brands: Array<BrandSettingI>, strategy: mappingStrategy
|
|
|
57
57
|
const mapping = indexedByBrandPropertyMapping[brand]
|
|
58
58
|
mappingPairs.forEach((pair) => {
|
|
59
59
|
const from = sku[pair.from] || ''
|
|
60
|
-
const
|
|
60
|
+
const redirectedMappingSource = mapping?.[pair.category]?.['~~']
|
|
61
|
+
const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {}
|
|
62
|
+
|
|
63
|
+
const to = mapping?.[pair.category]?.[from] || mapping?.[pair.category]?.[''] || redirectedMapping?.[pair.category]?.[from] || redirectedMapping?.[pair.category]?.['']
|
|
61
64
|
if (to == undefined) sku[pair.to] = '***'
|
|
62
65
|
})
|
|
63
66
|
return sku
|
package/src/consts.ts
CHANGED
package/src/hasOnlyDigits.ts
CHANGED
package/test/hasOnlyDigits.js
CHANGED
|
@@ -27,4 +27,15 @@ describe('hasOnlyDigits function', function () {
|
|
|
27
27
|
expect(hasOnlyDigits({ key: 'value' })).to.equal(false)
|
|
28
28
|
expect(hasOnlyDigits(new Date())).to.equal(false)
|
|
29
29
|
})
|
|
30
|
+
|
|
31
|
+
it('should be fast', function () {
|
|
32
|
+
// This function will be called many times on large datasets
|
|
33
|
+
// We expect 1 million operations to take no more than 1 second on our test infrastructure
|
|
34
|
+
const start = parseInt(process.hrtime.bigint())
|
|
35
|
+
for (let i = 0; i < 1_000_000; i++) {
|
|
36
|
+
const result = hasOnlyDigits('' + 1234567890123 + i)
|
|
37
|
+
}
|
|
38
|
+
const end = parseInt(process.hrtime.bigint())
|
|
39
|
+
expect(end - start).to.be.below(1_000_000_000)
|
|
40
|
+
})
|
|
30
41
|
})
|