Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

25 lignes
596 B

  1. 'use strict';
  2. var strValue = String.prototype.valueOf;
  3. var tryStringObject = function tryStringObject(value) {
  4. try {
  5. strValue.call(value);
  6. return true;
  7. } catch (e) {
  8. return false;
  9. }
  10. };
  11. var toStr = Object.prototype.toString;
  12. var strClass = '[object String]';
  13. var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
  14. module.exports = function isString(value) {
  15. if (typeof value === 'string') {
  16. return true;
  17. }
  18. if (typeof value !== 'object') {
  19. return false;
  20. }
  21. return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass;
  22. };