@rzl-zone/utils-js
Version:
A modern, lightweight set of JavaScript utility functions with TypeScript support for everyday development, crafted to enhance code readability and maintainability.
39 lines (34 loc) • 1.41 kB
JavaScript
/*!
* ====================================================
* Rzl Utils-JS.
* ----------------------------------------------------
* Version: 3.11.0.
* Author: Rizalvin Dwiky.
* Repository: https://github.com/rzl-zone/utils-js.
* ====================================================
*/
;
var chunkSYHPSOUU_cjs = require('./chunk-SYHPSOUU.cjs');
var isEmptyArray = (value) => {
if (!chunkSYHPSOUU_cjs.isArray(value)) return true;
return value.length === 0;
};
function isEmptyObject(value, options = {}) {
if (!chunkSYHPSOUU_cjs.isObject(value)) {
return true;
}
chunkSYHPSOUU_cjs.assertIsPlainObject(options, {
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
});
const checkSymbols = chunkSYHPSOUU_cjs.hasOwnProp(options, "checkSymbols") ? options.checkSymbols : false;
chunkSYHPSOUU_cjs.assertIsBoolean(checkSymbols, {
message: ({ currentType, validType }) => `Parameter \`checkSymbols\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
});
const hasNoKeys = Object.keys(value).length === 0;
if (checkSymbols) {
return hasNoKeys && Object.getOwnPropertySymbols(value).length === 0;
}
return hasNoKeys;
}
exports.isEmptyArray = isEmptyArray;
exports.isEmptyObject = isEmptyObject;