index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. /** `Object#toString` result references. */
  10. var stringTag = '[object String]';
  11. /** Used for built-in method references. */
  12. var objectProto = Object.prototype;
  13. /**
  14. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  15. * of values.
  16. */
  17. var objectToString = objectProto.toString;
  18. /**
  19. * Checks if `value` is classified as an `Array` object.
  20. *
  21. * @static
  22. * @memberOf _
  23. * @type Function
  24. * @category Lang
  25. * @param {*} value The value to check.
  26. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  27. * @example
  28. *
  29. * _.isArray([1, 2, 3]);
  30. * // => true
  31. *
  32. * _.isArray(document.body.children);
  33. * // => false
  34. *
  35. * _.isArray('abc');
  36. * // => false
  37. *
  38. * _.isArray(_.noop);
  39. * // => false
  40. */
  41. var isArray = Array.isArray;
  42. /**
  43. * Checks if `value` is object-like. A value is object-like if it's not `null`
  44. * and has a `typeof` result of "object".
  45. *
  46. * @static
  47. * @memberOf _
  48. * @category Lang
  49. * @param {*} value The value to check.
  50. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  51. * @example
  52. *
  53. * _.isObjectLike({});
  54. * // => true
  55. *
  56. * _.isObjectLike([1, 2, 3]);
  57. * // => true
  58. *
  59. * _.isObjectLike(_.noop);
  60. * // => false
  61. *
  62. * _.isObjectLike(null);
  63. * // => false
  64. */
  65. function isObjectLike(value) {
  66. return !!value && typeof value == 'object';
  67. }
  68. /**
  69. * Checks if `value` is classified as a `String` primitive or object.
  70. *
  71. * @static
  72. * @memberOf _
  73. * @category Lang
  74. * @param {*} value The value to check.
  75. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  76. * @example
  77. *
  78. * _.isString('abc');
  79. * // => true
  80. *
  81. * _.isString(1);
  82. * // => false
  83. */
  84. function isString(value) {
  85. return typeof value == 'string' ||
  86. (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
  87. }
  88. module.exports = isString;