1 | import isArray from './isArray';
|
2 | import isObjectLike from './isObjectLike';
|
3 |
|
4 | /** `Object#toString` result references. */
|
5 | var stringTag = '[object String]';
|
6 |
|
7 | /** Used for built-in method references. */
|
8 | var objectProto = Object.prototype;
|
9 |
|
10 | /**
|
11 | * Used to resolve the
|
12 | * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
13 | * of values.
|
14 | */
|
15 | var objectToString = objectProto.toString;
|
16 |
|
17 | /**
|
18 | * Checks if `value` is classified as a `String` primitive or object.
|
19 | *
|
20 | * @static
|
21 | * @since 0.1.0
|
22 | * @memberOf _
|
23 | * @category Lang
|
24 | * @param {*} value The value to check.
|
25 | * @returns {boolean} Returns `true` if `value` is correctly classified,
|
26 | * else `false`.
|
27 | * @example
|
28 | *
|
29 | * _.isString('abc');
|
30 | * // => true
|
31 | *
|
32 | * _.isString(1);
|
33 | * // => false
|
34 | */
|
35 | function isString(value) {
|
36 | return typeof value == 'string' ||
|
37 | (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
|
38 | }
|
39 |
|
40 | export default isString;
|