Example #1
0
File: Node.js Project: airware/vili
 get memory() {
   const match = /(\d+)Ki/g.exec(this.getIn(["status", "capacity", "memory"]))
   if (match) {
     return humanSize(parseInt(match[1]) * 1024, 1)
   }
   return this.getIn(["status", "capacity", "memory"])
 }
Example #2
0
 get memory () {
   const match = /(\d+)Ki/g.exec(this.getIn(['status', 'capacity', 'memory']))
   if (match) {
     return humanSize(parseInt(match[1]) * 1024, 1)
   }
   return this.getIn(['status', 'capacity', 'memory'])
 }
Example #3
0
function fmtBytes(byteCount) {
  if (byteCount <= 0) {
    return "0 B";
  } else {
    return humanSize(byteCount, 1);
  }
}
Example #4
0
// @formatter:on


/**
 * Log a message with size
 * Log a message with size
 * options:
 *  - sender {string}       sender of the message
 *  - message {string}      message
 *  - size {number}         gulpSizeObject
 *  - sizeAfter {number=}   gulpSizeObject to compare
 *  - wrap {boolean=}       wrap the log into a handler function
 *  - check {boolean=}      perform a boolean check before logging
 *
 * @param options {{sender: {string}, message: {string}, size: {object}, sizeAfter:{object} check: {boolean=}, wrap: {boolean=}}}
 */
function logSize ( options ) {

    if( options.wrap ) {

        options.wrap = false;
        return function () { logSize.call( this, options ) }

    } else {

        var sizeLog = humanSize( options.size.size, true );

        if( options.sizeAfter ) {
            var difference = options.size.size - options.sizeAfter.size;
            if( difference > 0 ) sizeLog = 'saved ' + humanSize( difference, true );
            else sizeLog = 'gained ' + humanSize( difference );
        }

        if( typeof options.check !== 'undefined' && !options.check ) return;
        console.log( gulpUtil.colors.blue( '[' + options.sender + '] size: ' + options.message ) + gulpUtil.colors.cyan( sizeLog ) );

    }

}