您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.ts 829B

12345678910111213141516171819202122232425
  1. import { IStateful } from '../base/app/types';
  2. import { toState } from '../base/redux/functions';
  3. /**
  4. * A short string to represent the number of visitors.
  5. * Over 100 we show numbers like 0.2 K or 9.5 K.
  6. *
  7. * @param {number} visitorsCount - The number of visitors to shorten.
  8. *
  9. * @returns {string} Short string representing the number of visitors.
  10. */
  11. export function getVisitorsShortText(visitorsCount: number) {
  12. return visitorsCount > 100 ? `${Math.round(visitorsCount / 100) / 10} K` : String(visitorsCount);
  13. }
  14. /**
  15. * Whether current UI is in visitor mode.
  16. *
  17. * @param {Function|Object} stateful - The redux store or {@code getState}
  18. * function.
  19. * @returns {boolean} Whether iAmVisitor is set.
  20. */
  21. export function iAmVisitor(stateful: IStateful) {
  22. return toState(stateful)['features/visitors'].iAmVisitor;
  23. }