You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_utils.js 985B

12345678910111213141516171819202122232425262728
  1. // @flow
  2. /**
  3. * Utility class with no dependencies. Used in components that are stripped in separate bundles
  4. * and requires as less dependencies as possible.
  5. */
  6. /**
  7. * Formats the conference pin in readable way for UI to display it.
  8. * Formats the pin in 3 groups of digits:
  9. * XXXX XXXX XX or XXXXX XXXXX XXX.
  10. * The length of first and second group is Math.ceil(pin.length / 3).
  11. *
  12. * @param {Object} conferenceID - The conference id to format, string or number.
  13. * @returns {string} - The formatted conference pin.
  14. * @private
  15. */
  16. export function _formatConferenceIDPin(conferenceID: Object) {
  17. const conferenceIDStr = conferenceID.toString();
  18. // let's split the conferenceID in 3 parts, to be easier to read
  19. const partLen = Math.ceil(conferenceIDStr.length / 3);
  20. return `${
  21. conferenceIDStr.substring(0, partLen)} ${
  22. conferenceIDStr.substring(partLen, 2 * partLen)} ${
  23. conferenceIDStr.substring(2 * partLen, conferenceIDStr.length)}`;
  24. }