📝StringEx

The module provides several methods for manipulating strings.

Imports

import { StringExService } from 'niro-health';

Method of Use

To use this module, you need to inject it into the desired service.

import { Module } from '@nestjs/common';
import {
  StringExService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IStringExService',
      useClass: StringExService,
    },
  ],
})
export class AppModule {}

Injecting the module into our service.

import { Inject, Injectable } from '@nestjs/common';
import type { IStringExService } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IStringExService')
    private readonly stringExService: IStringExService,
  ) {}

  public async hashPassword(password: string) {
    return await this.stringExService.hashPassword(password);
  }
}

Without dependencies

You won't need to connect the pieces with any other module.

Methods

Method
Scope
Description

LZStringCompressToEncodedURIComponent

public

Compresses a string to EncodedURIComponent.

LZStringDecompressFromEncodedURIComponent

public

Decompresses a string from EncodedURIComponent to string.

compress

public

Compresses a {string | Uint8Array | Buffer} to base64.

decompress

public

Decompresses a string from base64 to {Type | string | Uint8Array | Buffer}.

hashPassword

public

Return hash from password.

compareHashPassword

public

Compare hash from password.

hash

public

Return hash from string.

bytesToString

public

Return bytes to string.

getFilename

public

Get name of file.

getFileExtension

public

Get extension of file.

extractNumbers

public

Extract numbers from string.

maskMoney

public

Convert a string to money format.

maskPhone

public

Convert a string to phone pretty.

maskZipCode

public

Convert a string to zip code pretty.

maskCNPJ

public

Convert a string to CNPJ pretty.

maskCPF

public

Convert a string to CPF pretty.

maskRG

public

Convert a string to RG pretty.

Last updated