How to use printf - 10 common examples

To help you get started, we’ve selected a few printf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github voloko / uki / tests / runner.js View on Github external
QUnit.done = function(failures, total) {
        lastMessage = ("  " + p.sprintf("%8d", total) + " expectations complete with " + failures + " failures");
    };
github azukiapp / azk / lib / azk / utils / i18n.js View on Github external
($traceurRuntime.createClass)(i18n, {translate: function(key) {
    for (var args = [],
        $__2 = 1; $__2 < arguments.length; $__2++)
      args[$__2 - 1] = arguments[$__2];
    var keys = (typeof(key) == "string") ? key.split('.') : key;
    var buffer = this.dict || {};
    for (var i = 0; i < keys.length; i++) {
      buffer = buffer[keys[i]];
      if (!buffer)
        break;
    }
    if (buffer) {
      return typeof(buffer) == "string" ? printf.apply(null, $traceurRuntime.spread([buffer], args)) : buffer;
    } else {
      return (typeof(key) == "string" ? key : key.join("."));
    }
  }}, {});
module.exports = {
github clibs / clib / index.js View on Github external
function printf() {
  console.log(sprintf.apply(null, arguments));
}
github hacksalot / HackMyResume / src / cli / out.js View on Github external
log: function( msg ) {
      msg = msg || '';
      var printf = require('printf');
      var finished = printf.apply( printf, arguments );
      this.opts.silent || console.log( finished );
    },
github telemmo / telemmo / src / game / core / combatView.js View on Github external
}/${
        turn.defenderHp.init
      }*`
    ).join('\n\n')
  )

  const exp = prizes
    .find(prize => prize.exp)
  const item = prizes
    .find(prize => prize.item)
  const equip = prizes
    .find(prize => prize.equip)

  const prizesView = _(
    'Experience: %s\nItens: %s\nEquips: %s\n',
    exp ? exp.exp : _('none :('),
    item ? item.item : _('none :('),
    equip ? equip.equip : _('none :('),
  )

  const view = header + initiativeView + turnsView + prizesView
  return view
}
github telemmo / telemmo / src / game / core / combatView.js View on Github external
const initiative = head(c.turns)
  const turns = tail(c.turns)
  const prizes = c.prizes.filter(prize => prize.owner === id)

  const header = _(`%s vs. %s\n\n`, c.teams[0].overall.name, c.teams[1].overall.name)

  const initiativeView = _(
    '*%s* won the initiative!\n%s\n',
    initiative.winner,
    map(
      pair => `${pair[0]}: ${pair[1]}\n`,
      toPairs(initiative.rolls),
    ).join(''),
  )

  const turnsView = _(
    '%s\n\n',
    turns.map(turn =>
      `*${
        turn.attacker
      }* | aim ${
        turn.rolls.aAim
      } | hit ${
        turn.rolls.aHit
      } | skill ${
        turn.rolls.aSkill
      } |${
        turn.casts
          ? turn.casts.map(cast =>
            `\n! casted ${
              cast.skill
            } for ${
github telemmo / telemmo / src / game / core / combatView.js View on Github external
}*`
    ).join('\n\n')
  )

  const exp = prizes
    .find(prize => prize.exp)
  const item = prizes
    .find(prize => prize.item)
  const equip = prizes
    .find(prize => prize.equip)

  const prizesView = _(
    'Experience: %s\nItens: %s\nEquips: %s\n',
    exp ? exp.exp : _('none :('),
    item ? item.item : _('none :('),
    equip ? equip.equip : _('none :('),
  )

  const view = header + initiativeView + turnsView + prizesView
  return view
}
github telemmo / telemmo / src / game / core / combatView.js View on Github external
}'s hp: ${
        turn.defenderHp.current
      }/${
        turn.defenderHp.init
      }*`
    ).join('\n\n')
  )

  const exp = prizes
    .find(prize => prize.exp)
  const item = prizes
    .find(prize => prize.item)
  const equip = prizes
    .find(prize => prize.equip)

  const prizesView = _(
    'Experience: %s\nItens: %s\nEquips: %s\n',
    exp ? exp.exp : _('none :('),
    item ? item.item : _('none :('),
    equip ? equip.equip : _('none :('),
  )

  const view = header + initiativeView + turnsView + prizesView
  return view
}
github zeit / now / src / util / output / table.js View on Github external
  data.reduce((line, col, i) => line + printf(`%-${sizes[i]}s`, col), '');
github telemmo / telemmo / src / game / core / combatView.js View on Github external
turn.defenderHp.init
      }*`
    ).join('\n\n')
  )

  const exp = prizes
    .find(prize => prize.exp)
  const item = prizes
    .find(prize => prize.item)
  const equip = prizes
    .find(prize => prize.equip)

  const prizesView = _(
    'Experience: %s\nItens: %s\nEquips: %s\n',
    exp ? exp.exp : _('none :('),
    item ? item.item : _('none :('),
    equip ? equip.equip : _('none :('),
  )

  const view = header + initiativeView + turnsView + prizesView
  return view
}

printf

Full implementation of the `printf` family in pure JS.

MIT
Latest version published 4 years ago

Package Health Score

56 / 100
Full package analysis