mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-30 06:57:49 +00:00
28 lines
672 B
JavaScript
28 lines
672 B
JavaScript
import baseGetTag from './.internal/baseGetTag.js';
|
|
import isObjectLike from './isObjectLike.js';
|
|
|
|
/** `Object#toString` result references. */
|
|
const stringTag = '[object String]';
|
|
|
|
/**
|
|
* Checks if `value` is classified as a `String` primitive or object.
|
|
*
|
|
* @since 0.1.0
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
|
|
* @example
|
|
*
|
|
* isString('abc');
|
|
* // => true
|
|
*
|
|
* isString(1);
|
|
* // => false
|
|
*/
|
|
function isString(value) {
|
|
return typeof value == 'string' ||
|
|
(!Array.isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
|
|
}
|
|
|
|
export default isString;
|