burdy-web-utils
Version:
Utility library for web
27 lines (26 loc) • 775 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEmptyString = exports.forEach = void 0;
/**
* Utility function to execute callback for eack key->value pair.
*/
const forEach = (obj, callback) => {
if (obj) {
for (const key in obj) { // eslint-disable-line no-restricted-syntax
if ({}.hasOwnProperty.call(obj, key)) {
callback(key, obj[key]);
}
}
}
};
exports.forEach = forEach;
/**
* The function returns true if the string passed to it has no content.
*/
const isEmptyString = (str) => {
if (str === undefined || str === null || str.length === 0 || str.trim().length === 0) {
return true;
}
return false;
};
exports.isEmptyString = isEmptyString;