25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
723 B

4 년 전
  1. var baseGetTag = require('./_baseGetTag'),
  2. isArray = require('./isArray'),
  3. isObjectLike = require('./isObjectLike');
  4. /** `Object#toString` result references. */
  5. var stringTag = '[object String]';
  6. /**
  7. * Checks if `value` is classified as a `String` primitive or object.
  8. *
  9. * @static
  10. * @since 0.1.0
  11. * @memberOf _
  12. * @category Lang
  13. * @param {*} value The value to check.
  14. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  15. * @example
  16. *
  17. * _.isString('abc');
  18. * // => true
  19. *
  20. * _.isString(1);
  21. * // => false
  22. */
  23. function isString(value) {
  24. return typeof value == 'string' ||
  25. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  26. }
  27. module.exports = isString;