const { toString } = Object.prototype; /** * Gets the `toStringTag` of `value`. * * @private * @param {*} value The value to query. * @returns {string} Returns the `toStringTag`. */ function getTag(value: any) { if (value == null) { return value === undefined ? '[object Undefined]' : '[object Null]'; } return toString.call(value); } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types const isString = (value: any): value is string => { const type = typeof value; return ( type === 'string' || (type === 'object' && value != null && !Array.isArray(value) && getTag(value) === '[object String]') ); }; export default isString;