rerobe-js-orm 2.7.29 → 2.7.30
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.
|
@@ -3,6 +3,7 @@ export default class ReRobeProductHelpers {
|
|
|
3
3
|
static calculateFulfillmentFee(commission: number): number;
|
|
4
4
|
static calculateSalePrice(productObj: CompleteProduct): string;
|
|
5
5
|
static isValidCommission(commission: any): boolean;
|
|
6
|
+
static isValidVendorName(name: string): boolean;
|
|
6
7
|
static commissionFixer(commisssion: any): string;
|
|
7
8
|
static isValidSalePrice(productObj: CompleteProduct): boolean;
|
|
8
9
|
static buildReRobeEarnings(arrayLike: CompleteProduct | CompleteProduct[]): number[];
|
|
@@ -47,6 +47,12 @@ class ReRobeProductHelpers {
|
|
|
47
47
|
}
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
|
+
static isValidVendorName(name) {
|
|
51
|
+
if (name && typeof name === 'string') {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
50
56
|
static commissionFixer(commisssion) {
|
|
51
57
|
let fix = String(commisssion);
|
|
52
58
|
if (fix.includes(',')) {
|
package/lib/helpers/Utilities.js
CHANGED
|
@@ -88,5 +88,45 @@ class Utilities {
|
|
|
88
88
|
}
|
|
89
89
|
return 0;
|
|
90
90
|
}
|
|
91
|
+
isProperString(name) {
|
|
92
|
+
// Check if the name is a string
|
|
93
|
+
if (typeof name !== 'string') {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
// Check if the name has more than one word (i.e. contains a space)
|
|
97
|
+
if (/\s/.test(name)) {
|
|
98
|
+
// Split the name into an array of words
|
|
99
|
+
const words = name.split(' ');
|
|
100
|
+
// Check if each word is a proper string (i.e. not empty and doesn't contain any whitespace)
|
|
101
|
+
for (const word of words) {
|
|
102
|
+
if (!word || /\s/.test(word)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// If the name is a single word, check if it is a proper string
|
|
109
|
+
if (!name || /\s/.test(name)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// If the name is a string and doesn't have any whitespace, it is a proper string
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
toProperString(name) {
|
|
117
|
+
// Check if the name is a string
|
|
118
|
+
if (typeof name !== 'string') {
|
|
119
|
+
// If the name is not a string, return an empty string
|
|
120
|
+
return '';
|
|
121
|
+
}
|
|
122
|
+
// Remove any consecutive whitespace characters from the name
|
|
123
|
+
name = name.replace(/\s+/g, ' ');
|
|
124
|
+
// Remove any leading or trailing whitespace from the name
|
|
125
|
+
name = name.trim();
|
|
126
|
+
// Split the name into an array of words
|
|
127
|
+
const words = name.split(' ');
|
|
128
|
+
// Capitalize each word and join the words together
|
|
129
|
+
return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
|
130
|
+
}
|
|
91
131
|
}
|
|
92
132
|
exports.default = Utilities;
|