UNPKG

reakit-utils

Version:

Reakit utils

32 lines (26 loc) 686 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var isObject = require('./isObject.js'); /** * Checks whether `arg` is empty or not. * * @example * import { isEmpty } from "reakit-utils"; * * isEmpty([]); // true * isEmpty(["a"]); // false * isEmpty({}); // true * isEmpty({ a: "a" }); // false * isEmpty(); // true * isEmpty(null); // true * isEmpty(undefined); // true * isEmpty(""); // true */ function isEmpty(arg) { if (Array.isArray(arg)) return !arg.length; if (isObject.isObject(arg)) return !Object.keys(arg).length; if (arg == null) return true; if (arg === "") return true; return false; } exports.isEmpty = isEmpty;