kibana-riya
Version:
Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic
19 lines (15 loc) • 482 B
JavaScript
import _ from 'lodash';
// adopted from http://stackoverflow.com/questions/3109978/php-display-number-with-ordinal-suffix
export default function addOrdinalSuffix(num) {
return num + '' + suffix(num);
};
function suffix(num) {
let int = Math.floor(parseFloat(num));
let hunth = int % 100;
if (hunth >= 11 && hunth <= 13) return 'th';
let tenth = int % 10;
if (tenth === 1) return 'st';
if (tenth === 2) return 'nd';
if (tenth === 3) return 'rd';
return 'th';
}