Skip to content

Converts Object with snake_case propty to camelCase proprty

Notifications You must be signed in to change notification settings

rzkhosroshahi/sanitizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanitizer

Converts Object with snake_case propty to camelCase proprty

Usage

import { sanitizer } from 'sanitizer';
const data = { 'one_key': 'foo', 'two_key': 'foo' };
sanitizer(data); // { oneKey: 'foo', twoKey: 'foo', }

Deep

Set manually how far getting deep to convert keys with deep option Default deep option is zero

import { sanitizer } from 'sanitizer';
const data = {
    'third_key': { 'one_key': 'foo', 'two_key': 'foo' },
};
sanitizer(data, { deep: 2 }); // { thirdKey: { oneKey: 'foo', twoKey: 'foo' }, }

convertsArray

Set convertsArray option that tells to sanitizer do you want to convert array objects key or not Default convertsArray option is true

import { sanitizer } from 'sanitizer';
const data = {
    'third_key': [{ 'one_key': 'foo', 'two_key': 'foo' }],
};
sanitizer(data, { deep: 0, convertsArray: false } ); // { thirdKey: [{ 'one_key': 'foo', 'two_key': 'foo' }], }

infinite

Set infinite to prevent check how far getting deep Default infinite option is false

About

Converts Object with snake_case propty to camelCase proprty

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published