string.js 353 B

12345678910111213141516171819
  1. var camelizeRE = /-(\w)/g;
  2. export function camelize(str) {
  3. return str.replace(camelizeRE, function (_, c) {
  4. return c.toUpperCase();
  5. });
  6. }
  7. export function padZero(num, targetLength) {
  8. if (targetLength === void 0) {
  9. targetLength = 2;
  10. }
  11. var str = num + '';
  12. while (str.length < targetLength) {
  13. str = '0' + str;
  14. }
  15. return str;
  16. }