2.0.4 • Published 1 year ago

mapping-keys v2.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago
let comment = {
  comment_id: 42,
  user_id: 1024,
  user_name: 'Mufasa',
  content: 'You deliberately disobeyed me.',
  viewed_by: [
    { user_id: 3820, user_name: 'Rafiki' },
    { user_id: 8391, user_name: 'Zazu' }
  ]
};

function snakeToCamel(key) {
  return key.replace(/_(\w)/g, (match, char) => char.toUpperCase());
}

let result = mappingKeys(comment, snakeToCamel);

And the result will look like this:

{
  commentId: 42,
  userId: 1024,
  userName: 'Mufasa',
  content: 'You deliberately disobeyed me.',
  viewedBy: [
    { userId: 3820, userName: 'Rafiki' },
    { userId: 8391, userName: 'Zazu' }
  ]
}
2.0.4

1 year ago

1.3.8

1 year ago

1.3.7

1 year ago

1.3.5

1 year ago

1.3.3

1 year ago

1.3.1

1 year ago

1.1.11

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago