UNPKG

angular-ordinal

Version:
51 lines (43 loc) 1.44 kB
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 'use strict'; var ordinal = require('ordinal-number-suffix'); angular .module('ordinal', []) // Take a number and returns its ordinal value // i.e. 1 -> 1st, 2 -> 2nd, etc. .filter('ordinal', function() { return function(input) { var num = parseInt(input, 10); return isNaN(num) ? input : ordinal(num); }; }); },{"ordinal-number-suffix":2}],2:[function(require,module,exports){ /** * Get the ordinal number with suffix from `n` * * @api public * @param {Number} n * @return {String} */ exports = module.exports = function (n) { return n + exports.suffix(+n); }; /** * Get the suffix for the given `n` * * @api private * @param {Number} n * @return {String} */ exports.suffix = function (n) { return Math.floor(n / 10) === 1 ? 'th' : (n % 10 === 1 ? 'st' : (n % 10 === 2 ? 'nd' : (n % 10 === 3 ? 'rd' : 'th'))); }; },{}]},{},[1]);