Displayable name for attributes utility function
Summary: Utility function that transforms lower camel case attribute names to a more readable name. e.g. sizeToFit -> Size To Fit Reviewed By: antonk52 Differential Revision: D40344715 fbshipit-source-id: f0745b892a78cc262133197a4d4b7624a7e2141d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1ee89d0e64
commit
9721993576
@@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function displayableName(attribute: string): string {
|
||||||
|
if (attribute.length > 0) {
|
||||||
|
const displayable = attribute[0].toUpperCase() + attribute.substring(1);
|
||||||
|
return displayable.replace(/([a-z](?=[A-Z]))/g, '$1 ');
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user