ts-object-formatter
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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.

Package Sidebar

Install

npm i ts-object-formatter

Weekly Downloads

26

Version

1.0.3

License

MIT

Unpacked Size

28.7 kB

Total Files

14

Last publish

Collaborators

  • evandrolg