yoastseo
Version:
Yoast client-side content analysis
37 lines (35 loc) • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isSameType = exports.getType = exports.default = void 0;
/**
* Gets the parsed type name of subjects.
*
* @param {array|object|string|number} subject The subject to get the parsed type from.
* @returns {string} The parsed type name.
*/
var getType = function (subject) {
if (Array.isArray(subject)) {
return "array";
}
return typeof subject;
};
/**
* Validates the type of subjects. Throws an error if the type is invalid.
*
* @param {object} subject The object containing all subjects.
* @param {string} expectedType The expected type.
* @returns {boolean} Returns true if types matches expected type. Otherwise returns false.
*/
exports.getType = getType;
var isSameType = function (subject, expectedType) {
var passedType = getType(subject);
return passedType === expectedType;
};
exports.isSameType = isSameType;
var _default = exports.default = {
getType: getType,
isSameType: isSameType
};
//# sourceMappingURL=types.js.map