UNPKG

895 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3function converter(fn) {
4 return value => value ? fn(value[0]) + value.slice(1) : '';
5}
6/**
7 * @name stringLowerFirst
8 * @summary Lowercase the first letter of a string
9 * @description
10 * Lowercase the first letter of a string
11 * @example
12 * <BR>
13 *
14 * ```javascript
15 * import { stringLowerFirst } from '@polkadot/util';
16 *
17 * stringLowerFirst('ABC'); // => 'aBC'
18 * ```
19 */
20
21
22export const stringLowerFirst = converter(s => s.toLowerCase());
23/**
24 * @name stringUpperFirst
25 * @summary Uppercase the first letter of a string
26 * @description
27 * Lowercase the first letter of a string
28 * @example
29 * <BR>
30 *
31 * ```javascript
32 * import { stringUpperFirst } from '@polkadot/util';
33 *
34 * stringUpperFirst('abc'); // => 'Abc'
35 * ```
36 */
37
38export const stringUpperFirst = converter(s => s.toUpperCase());
\No newline at end of file