|
|
@ -13,7 +13,10 @@ module.exports.swapStrings = (string, start, length, swap) => { |
|
|
|
|
|
|
|
|
// removes null and undefined
|
|
|
// removes null and undefined
|
|
|
module.exports.removeNull = obj => { |
|
|
module.exports.removeNull = obj => { |
|
|
obj = _(obj).omitBy(_.isUndefined).omitBy(_.isNull).value() |
|
|
obj = _(obj) |
|
|
|
|
|
.omitBy(_.isUndefined) |
|
|
|
|
|
.omitBy(_.isNull) |
|
|
|
|
|
.value() |
|
|
for (let [key, value] of Object.entries(obj)) { |
|
|
for (let [key, value] of Object.entries(obj)) { |
|
|
// only objects
|
|
|
// only objects
|
|
|
if (typeof value === "object" && !Array.isArray(value)) { |
|
|
if (typeof value === "object" && !Array.isArray(value)) { |
|
|
@ -25,7 +28,7 @@ module.exports.removeNull = obj => { |
|
|
|
|
|
|
|
|
module.exports.addConstants = obj => { |
|
|
module.exports.addConstants = obj => { |
|
|
if (obj.now == null) { |
|
|
if (obj.now == null) { |
|
|
obj.now = (new Date()).toISOString() |
|
|
obj.now = new Date().toISOString() |
|
|
} |
|
|
} |
|
|
return obj |
|
|
return obj |
|
|
} |
|
|
} |
|
|
|