1.0.3 • Published 5 months ago

ts-object-formatter v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

ts-object-formatter · license

A tiny library for formatting object fields in snake case or camel case.

Installation

To install ts-object-formatter, execute:

npm install ts-object-formatter

Quickstart

Below is an example of how to use the library:

import objectFormatter from 'ts-object-formatter';

const map = {
  user_nickname: 'evandrolg',
  last_post: '2023-01-01',
  career: {
    last_companies: ['spotify', 'dazn', 'joyn'],
  },
};

objectFormatter(map, 'lowerCamelCase');
/*
{
  userNickname: 'evandrolg',
  lastPost: '2023-01-01',
  career: {
    lastCompanies: ['spotify', 'dazn', 'joyn'],
  },
}
*/

API

objectFormatter(object, filter)

Converts the object keys to camel or snake case.

object

Type: object Object that will be formatted.

filter

Type: lowerCamelCase | upperCamelCase | lowerSnakeCase | upperSnakeCase Filter that will be applied to convert the object key.

1.0.2

5 months ago

1.0.3

5 months ago

1.0.1

8 months ago

1.0.0

8 months ago