Nodejs Number Convert toChar()

Here you can find the source of toChar()

Method Source Code

// Number extensions

Number.prototype.toChar = function() {
  return String.fromCharCode(this);
};

Related

  1. toAbbr(precision)
    Number.prototype.toAbbr = function(precision) {
      if(this < 1000)
        return Math.round(this);
      else {
        var mag = Math.floor(Math.log(this) / Math.LN10 / 3);
        return (this / Math.pow(1000, mag)).toPrecision(precision || 3) + " KMBTP"[mag];
    };
    
  2. toApproximateTime()
    Number.prototype.toApproximateTime = function () {
        sec_numb    = parseInt(this);
        var approximateHours = (sec_numb / 3600).toFixedDown(1);
        var hours   = Math.floor(sec_numb / 3600);
        var minutes = Math.floor((sec_numb - (hours * 3600)) / 60);
        var seconds = sec_numb - (hours * 3600) - (minutes * 60);
      var time = '';
        if( approximateHours >= 1 ) {
          time = approximateHours + ' hours';
    ...
    
  3. toBytes()
    Number.prototype.toBytes = function () {
      if (this === 0) { return '0 bytes' }
      var i = parseInt(Math.floor(Math.log(this) / Math.log(1024)))
      var r = Math.round(this / Math.pow(1024, i) * 10) / 10
      return [r, ['bytes', 'KB', 'MB', 'GB', 'TB'][i]].join(' ')
    
  4. toCents()
    Number.prototype.toCents = function(){
      return this * 100;
    };
    
  5. toCounter()
    Number.prototype.toCounter = function () {
        var d = this;
        d = Number(d);
        var h = Math.floor(d / 1000 / 3600 );
        var m = Math.floor(d / 1000 % 3600 / 60);
        var s = Math.floor(d / 1000 % 3600 % 60);
        var ms = (d % 3600000 % 60000 % 1000);
        var tenths = Math.floor(ms / 100);
        return ((h > 0 ? h + ":" + (m < 10 ? "0" : "") : "") + m + ":" + (s < 10 ? "0" : "") + s + "." + tenths);
    ...
    
  6. toDigits()
    Number.prototype.toDigits = Number.prototype.toDigits || function () {
      let number = this;
      let digits = [];
      while (number > 0) {
        digits[digits.length] = number % 10;
        number = Math.floor(number / 10);
      return digits.reverse();
    };
    ...
    
  7. toDollars(c, printSign)
    Number.prototype.toDollars = function(c, printSign){
      var n = this,
        c = isNaN(c = Math.abs(c)) ? 2 : c,
        d = ".",
        t = ",",
        s = n < 0 ? "-" : "",
        i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
        j = (j = i.length) > 3 ? j % 3 : 0,
        sign = printSign ? '$': '';
    ...
    
  8. toMinutes()
    Number.prototype.toMinutes = function(){
      return (Math.floor(parseInt(this)/60)).addTrailingZero()+":"+(parseInt(this)%60).addTrailingZero();
    };