@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.
32 lines (29 loc) • 1.39 kB
JavaScript
/*!
* ====================================================
* Rzl Utils-JS.
* ----------------------------------------------------
* Version: 3.11.0.
* Author: Rizalvin Dwiky.
* Repository: https://github.com/rzl-zone/utils-js.
* ====================================================
*/
import { isEmptyString } from './chunk-ULQPCIA2.js';
import { isEmptyArray, isEmptyObject } from './chunk-GOFINGT6.js';
import { assertIsPlainObject, hasOwnProp, assertIsBoolean, isNil, isNaN, isString, isArray, isObject } from './chunk-MSUW5VHZ.js';
var isEmptyValue = (value, options = {}) => {
assertIsPlainObject(options, {
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
});
const checkSymbols = hasOwnProp(options, "checkSymbols") ? options.checkSymbols : false;
assertIsBoolean(checkSymbols, {
message: ({ currentType, validType }) => `Parameter \`checkSymbols\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
});
if (isNil(value) || value === false || isNaN(value)) return true;
if (isString(value)) return isEmptyString(value);
if (isArray(value)) return isEmptyArray(value);
if (isObject(value)) {
return isEmptyObject(value, { checkSymbols });
}
return false;
};
export { isEmptyValue };