appium-uiautomator2-driver
Version:
UiAutomator2 integration for Appium
37 lines • 1.16 kB
JavaScript
;
// TODO(appium server 3.4.1+): Replace local `isEmpty` / `escapeRegExp` with imports from `appium/support`
// once this driver declares that minimum server version.
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEmpty = isEmpty;
exports.escapeRegExp = escapeRegExp;
/**
* Returns true when the value has no elements/properties.
*
* @param value - Value to check
* @returns `true` if the value is empty
*/
function isEmpty(value) {
if (value == null) {
return true;
}
if (typeof value === 'string' || Array.isArray(value) || Buffer.isBuffer(value)) {
return value.length === 0;
}
if (value instanceof Map || value instanceof Set) {
return value.size === 0;
}
if (typeof value === 'object' || typeof value === 'function') {
return Object.keys(value).length === 0;
}
return true;
}
/**
* Escapes RegExp special characters in a string.
*
* @param value - Input string
* @returns Escaped string safe for RegExp source
*/
function escapeRegExp(value) {
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
//# sourceMappingURL=lang.js.map