_stringSize.js 432 B

12345678910111213141516171819
  1. var asciiSize = require('./_asciiSize'),
  2. hasUnicode = require('./_hasUnicode'),
  3. unicodeSize = require('./_unicodeSize');
  4. /**
  5. * Gets the number of symbols in `string`.
  6. *
  7. * @private
  8. * @param {string} string The string to inspect.
  9. * @returns {number} Returns the string size.
  10. */
  11. function stringSize(string) {
  12. return hasUnicode(string)
  13. ? unicodeSize(string)
  14. : asciiSize(string);
  15. }
  16. module.exports = stringSize;