@polkadot/util
Version:
A collection of useful utilities for @polkadot
38 lines (35 loc) • 895 B
JavaScript
// Copyright 2017-2022 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
function converter(fn) {
return value => value ? fn(value[0]) + value.slice(1) : '';
}
/**
* @name stringLowerFirst
* @summary Lowercase the first letter of a string
* @description
* Lowercase the first letter of a string
* @example
* <BR>
*
* ```javascript
* import { stringLowerFirst } from '@polkadot/util';
*
* stringLowerFirst('ABC'); // => 'aBC'
* ```
*/
export const stringLowerFirst = converter(s => s.toLowerCase());
/**
* @name stringUpperFirst
* @summary Uppercase the first letter of a string
* @description
* Lowercase the first letter of a string
* @example
* <BR>
*
* ```javascript
* import { stringUpperFirst } from '@polkadot/util';
*
* stringUpperFirst('abc'); // => 'Abc'
* ```
*/
export const stringUpperFirst = converter(s => s.toUpperCase());