index.js 379 B

12345678910111213141516171819
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = addLeadingZeros;
  6. function addLeadingZeros(number, targetLength) {
  7. var sign = number < 0 ? '-' : '';
  8. var output = Math.abs(number).toString();
  9. while (output.length < targetLength) {
  10. output = '0' + output;
  11. }
  12. return sign + output;
  13. }
  14. module.exports = exports.default;