5ed392e4060e17f197893fb36cea168d9d5423f3
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / isString.js
1 var isArray = require('./isArray'),
2     isObjectLike = require('./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 [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
12  * of values.
13  */
14 var objectToString = objectProto.toString;
15
16 /**
17  * Checks if `value` is classified as a `String` primitive or object.
18  *
19  * @static
20  * @memberOf _
21  * @category Lang
22  * @param {*} value The value to check.
23  * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
24  * @example
25  *
26  * _.isString('abc');
27  * // => true
28  *
29  * _.isString(1);
30  * // => false
31  */
32 function isString(value) {
33   return typeof value == 'string' ||
34     (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
35 }
36
37 module.exports = isString;