πŸ“BJSON

The module that provides the service to encode and decode objects.

Imports

import { BjsonService } 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 { BjsonService } from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

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

Importing the service inside the module.

Method of Use with classes

You should add the class constructor to the service before using the methods.

If you are going to perform encoding of an object with inheritance, you should follow this method of use.

Test results

Without dependencies

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

Properties

Property
Scope
Description

CONSTRUCTORS

static

The object that contains the constructors.

MAXDEPTH

static

The maximum depth of the object.

Methods

Method
Scope
Description

_encode

private

Encode an object to string.

_decode

private

Decode an object from string.

addConstructors

public

It adds the constructors to the _constructors object.

removeConstructors

public

It removes the constructors from the _constructors object.

setMaxDepth

public

Sets the maximum depth of the object.

getMaxDepth

public

Gets the maximum depth of the object.

makeDeepCopy

public

It takes an object of type custom, makes a deep copy of it, and returns it.

stringify

public

It takes an object of type custom, encodes it, stringifies it, and returns it.

parse

public

It takes a string, parses it, decodes it, and returns it.

Last updated