palin.js
function getTimestampString(date) {
    // all this nasty code is faster (~30k ops/sec) than doing "moment(date).format('HH:mm:ss:SSS')" and means 0 dependencies
    var hour = '0' + date.getHours();
    hour = hour.slice(hour.length - 2);
    var minute = '0' + date.getMinutes();
    minute = minute.slice(minute.length - 2);
    var second = '0' + date.getSeconds();
    second = second.slice(second.length - 2);
    var ms = '' + date.getMilliseconds();

    // https://github.com/MarkHerhold/palin/issues/6
    // this is faster than using an actual left-pad algorithm
    if (ms.length === 1) {
        ms = '00' + ms;
    } else if (ms.length === 2) {
        ms = '0' + ms;
    } // no modifications for 3 or more digits

    return chalk.dim(`${hour}:${minute}:${second}:${ms}`);
}
function getTimestampString(date) {
    // all this nasty code is faster (~30k ops/sec) than doing "moment(date).format('HH:mm:ss:SSS')" and means 0 dependencies
    var hour = '0' + date.getHours();
    hour = hour.slice(hour.length - 2);
    var minute = '0' + date.getMinutes();
    minute = minute.slice(minute.length - 2);
    var second = '0' + date.getSeconds();
    second = second.slice(second.length - 2);
    var ms = '' + date.getMilliseconds();

    // https://github.com/MarkHerhold/palin/issues/6
    // this is faster than using an actual left-pad algorithm
    if (ms.length === 1) {
        ms = '00' + ms;
    } else if (ms.length === 2) {
        ms = '0' + ms;
    } // no modifications for 3 or more digits

    return chalk.dim(`${hour}:${minute}:${second}:${ms}`);
}
function getTimestampString ( date ) { // all this nasty code is faster (~30k ops/sec) than doing "moment(date).format('HH:mm:ss:SSS')" and means 0 dependencies var hour = '0' + date . getHours ( ) ; hour = hour . slice ( hour . length - 2 ) ; var minute = '0' + date . getMinutes ( ) ; minute = minute . slice ( minute . length - 2 ) ; var second = '0' + date . getSeconds ( ) ; second = second . slice ( second . length - 2 ) ; var ms = '' + date . getMilliseconds ( ) ; // https://github.com/MarkHerhold/palin/issues/6 // this is faster than using an actual left-pad algorithm if ( ms . length === 1 ) { ms = '00' + ms ; } else if ( ms . length === 2 ) { ms = '0' + ms ; } // no modifications for 3 or more digits return chalk . dim ( ` ${ hour } ${ minute } ${ second } ${ ms } ` ) ; }
retruns the colorized timestamp string
retruns the colorized timestamp string