datocms-plugin-sdk
Version:
32 lines • 990 B
JavaScript
import emojiRegex from 'emoji-regex-xs';
export function isNullish(value) {
return value === null || value === undefined;
}
export function isBoolean(value) {
return typeof value === 'boolean';
}
export function isString(value) {
return typeof value === 'string';
}
export function isEmoji(value) {
if (!isString(value))
return false;
var regex = emojiRegex();
var match = value.match(regex);
return match !== null && match.length === 1 && match[0] === value;
}
export function isNumber(value) {
return typeof value === 'number';
}
export function isRecord(value) {
return typeof value === 'object' && value !== null && !Array.isArray(value);
}
export function isArray(value, checkItem) {
return Array.isArray(value) && value.every(checkItem);
}
export function isPlacement(value) {
return (isArray(value, isString) &&
value.length === 2 &&
['before', 'after'].includes(value[0]));
}
//# sourceMappingURL=guardUtils.js.map