Initial commit
[yaffs-website] / node_modules / lodash.isstring / index.js
1 /**
2  * lodash 4.0.1 (Custom Build) <https://lodash.com/>
3  * Build: `lodash modularize exports="npm" -o ./`
4  * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
5  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
6  * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
7  * Available under MIT license <https://lodash.com/license>
8  */
9
10 /** `Object#toString` result references. */
11 var stringTag = '[object String]';
12
13 /** Used for built-in method references. */
14 var objectProto = Object.prototype;
15
16 /**
17  * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
18  * of values.
19  */
20 var objectToString = objectProto.toString;
21
22 /**
23  * Checks if `value` is classified as an `Array` object.
24  *
25  * @static
26  * @memberOf _
27  * @type Function
28  * @category Lang
29  * @param {*} value The value to check.
30  * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
31  * @example
32  *
33  * _.isArray([1, 2, 3]);
34  * // => true
35  *
36  * _.isArray(document.body.children);
37  * // => false
38  *
39  * _.isArray('abc');
40  * // => false
41  *
42  * _.isArray(_.noop);
43  * // => false
44  */
45 var isArray = Array.isArray;
46
47 /**
48  * Checks if `value` is object-like. A value is object-like if it's not `null`
49  * and has a `typeof` result of "object".
50  *
51  * @static
52  * @memberOf _
53  * @category Lang
54  * @param {*} value The value to check.
55  * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
56  * @example
57  *
58  * _.isObjectLike({});
59  * // => true
60  *
61  * _.isObjectLike([1, 2, 3]);
62  * // => true
63  *
64  * _.isObjectLike(_.noop);
65  * // => false
66  *
67  * _.isObjectLike(null);
68  * // => false
69  */
70 function isObjectLike(value) {
71   return !!value && typeof value == 'object';
72 }
73
74 /**
75  * Checks if `value` is classified as a `String` primitive or object.
76  *
77  * @static
78  * @memberOf _
79  * @category Lang
80  * @param {*} value The value to check.
81  * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
82  * @example
83  *
84  * _.isString('abc');
85  * // => true
86  *
87  * _.isString(1);
88  * // => false
89  */
90 function isString(value) {
91   return typeof value == 'string' ||
92     (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
93 }
94
95 module.exports = isString;