Home Reference Source

src/debug/log.js

  1. /**
  2. * You can use this emit particles.
  3. *
  4. * This method will console.log the fixed number of your info in updata or requestAnimationFrame
  5. *
  6. * use like this log('+12',mc); log 12 times
  7. *
  8. * @return void
  9. */
  10. export default function() {
  11. let once = 0;
  12.  
  13. if (window.console && window.console.trace) {
  14. var arg = Array.prototype.slice.call(arguments);
  15. var s1 = arguments[0] + '';
  16.  
  17. if (s1.indexOf('+') == 0) {
  18. var n = parseInt(arguments[0]);
  19.  
  20. if (once < n) {
  21. arg.shift();
  22. console.trace.apply(console, arg);
  23. once++;
  24. }
  25. } else {
  26. arg.unshift('+15');
  27. this.apply(console, arg);
  28. }
  29. }
  30. }