repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add and use array helper.
[e-mobility-charging-stations-simulator.git]
/
src
/
utils
/
Utils.js
diff --git
a/src/utils/Utils.js
b/src/utils/Utils.js
index a06d57ead326e3dc052417fe902b54a9036b04fa..15ee30711ec2c3645626b0e6af071abd212c71aa 100644
(file)
--- a/
src/utils/Utils.js
+++ b/
src/utils/Utils.js
@@
-1,7
+1,7
@@
const {v4: uuid} = require('uuid');
class Utils {
const {v4: uuid} = require('uuid');
class Utils {
- static generate
G
UID() {
+ static generate
U
UID() {
return uuid();
}
return uuid();
}
@@
-74,30
+74,33
@@
class Utils {
return changedID;
}
return changedID;
}
- static convertToInt(
id
) {
- let changed
ID = id
;
- if (!
id
) {
+ static convertToInt(
value
) {
+ let changed
Value = value
;
+ if (!
value
) {
return 0;
}
return 0;
}
+ if (Number.isSafeInteger(value)) {
+ return value;
+ }
// Check
// Check
- if (typeof
id
=== 'string') {
+ if (typeof
value
=== 'string') {
// Create Object
// Create Object
- changed
ID = parseInt(id
);
+ changed
Value = parseInt(value
);
}
}
- return changed
ID
;
+ return changed
Value
;
}
}
- static convertToFloat(
id
) {
- let changed
ID = id
;
- if (!
id
) {
+ static convertToFloat(
value
) {
+ let changed
Value = value
;
+ if (!
value
) {
return 0;
}
// Check
return 0;
}
// Check
- if (typeof
id
=== 'string') {
+ if (typeof
value
=== 'string') {
// Create Object
// Create Object
- changed
ID = parseFloat(id
);
+ changed
Value = parseFloat(value
);
}
}
- return changed
ID
;
+ return changed
Value
;
}
static convertToBoolean(value) {
}
static convertToBoolean(value) {
@@
-125,7
+128,7
@@
class Utils {
static basicFormatLog(prefixString = '') {
const date = new Date();
static basicFormatLog(prefixString = '') {
const date = new Date();
- return date.to
ISOString().substr(0, 19
) + prefixString;
+ return date.to
LocaleString(
) + prefixString;
}
static objectHasOwnProperty(object, property) {
}
static objectHasOwnProperty(object, property) {
@@
-135,6
+138,20
@@
class Utils {
static cloneJSonDocument(jsonDocument) {
return JSON.parse(JSON.stringify(jsonDocument));
}
static cloneJSonDocument(jsonDocument) {
return JSON.parse(JSON.stringify(jsonDocument));
}
+
+ static isUndefined(value) {
+ if (typeof value === 'undefined') {
+ return true;
+ }
+ return false;
+ }
+
+ static isEmptyArray(object) {
+ if (Array.isArray(object) && object.length > 0) {
+ return false;
+ }
+ return true;
+ }
}
module.exports = Utils;
}
module.exports = Utils;