MCPcopy Create free account
hub / github.com/ampproject/amphtml / formatPinCount

Method formatPinCount

extensions/amp-pinterest/0.1/save-button.js:90–103  ·  view source on GitHub ↗

* Pretty print the Pin count with english suffixes * @param {number|string} count The Pin count for the source URL * @return {string}

(count)

Source from the content-addressed store, hash-verified

88 * @return {string}
89 */
90 formatPinCount(count) {
91 if (count > 999) {
92 if (count < 1000000) {
93 count = parseInt(count / 1000, 10) + 'K+';
94 } else {
95 if (count < 1000000000) {
96 count = parseInt(count / 1000000, 10) + 'M+';
97 } else {
98 count = '++';
99 }
100 }
101 }
102 return String(count);
103 }
104
105 /**
106 * Render helper for the optional count bubble

Callers 1

renderCountMethod · 0.95

Calls 1

StringFunction · 0.50

Tested by

no test coverage detected