Skip to content

question44/auto-camel-case-with-rules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auto-camel-case-with-rules

This utils allows to change object props to camelcase with optional custom property names. The returned object has correct type.

Example

import autoCamelCaseWithRules from 'auto-camel-case-with-rules';

const mapUser = autoCamelCaseWithRules({
  id: 'userId',
} as const);

const result = mapUser({
  id: 1,
  ['do you.like__candy']: true,
  created_at: new Date()
});

// result === { userId: 1, doYouLikeCandy: true, createdAt: '2021-05-15T21:57:00.524Z' };

type TResult = typeof result;

// TResult === { userId: number, doYouLikeCandy: boolean, createdAt: Date }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published