mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
269fa37bb8
Summary: This moves the `indent` function into a `Utils` module so it can be also used to properly indent the abstract methods declarations in a C++ TurboModule spec. Changelog: Internal Reviewed By: nlutsenko Differential Revision: D34704456 fbshipit-source-id: 88a3a672e4860927b5dd1f5107f40da7b5a83e51
34 lines
700 B
JavaScript
34 lines
700 B
JavaScript
/**
|
|
* 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.
|
|
*
|
|
* @flow strict
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
function capitalize(string: string): string {
|
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
}
|
|
|
|
function indent(nice: string, spaces: number): string {
|
|
return nice
|
|
.split('\n')
|
|
.map((line, index) => {
|
|
if (line.length === 0 || index === 0) {
|
|
return line;
|
|
}
|
|
const emptySpaces = new Array(spaces + 1).join(' ');
|
|
return emptySpaces + line;
|
|
})
|
|
.join('\n');
|
|
}
|
|
|
|
module.exports = {
|
|
capitalize,
|
|
indent,
|
|
};
|