utils.module.ts 506 B

123456789101112131415161718
  1. import { Module } from '@nestjs/common';
  2. import { UtilsService } from './utils.service';
  3. @Module({
  4. providers: [UtilsService],
  5. exports: [UtilsService],
  6. })
  7. export class UtilsModule {
  8. initPadleft(): void {
  9. // function padLeft(nr, n, str) {
  10. // return Array(n - String(nr).length + 1).join(str || '0') + nr;
  11. // };
  12. //or as a Number prototype method:
  13. Number.prototype.padLeft = function (n, str) {
  14. return Array(n - String(this).length + 1).join(str || '0') + this;
  15. };
  16. }
  17. }