Add stringLowerFirst, stringUpperFirst, stringCamelCase (#219)
* Add stringLowerFirst * Add stringUpperFirst * Change test description * Add camelcase * Add header
This commit is contained in:
committed by
Jaco Greeff
parent
a634fe380c
commit
9a6a02ce46
@@ -0,0 +1,25 @@
|
||||
// Copyright 2017-2018 @polkadot/util authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import isNull from '../is/null';
|
||||
import isUndefined from '../is/undefined';
|
||||
|
||||
/**
|
||||
* @name stringLowerFirst
|
||||
* @signature stringLowerFirst (_value: string): string
|
||||
* @summary Lowercase the first letter of a string
|
||||
* @description
|
||||
* Lowercase the first letter of a string
|
||||
* @example
|
||||
* import { stringLowerFirst } from '@polkadot/util';
|
||||
*
|
||||
* stringLowerFirst('ABC'); // => 'aBC'
|
||||
*/
|
||||
export default function stringLowerFirst (_value: string): string {
|
||||
if (isNull(_value) || isUndefined(_value)) {
|
||||
return _value;
|
||||
}
|
||||
|
||||
return _value.charAt(0).toLowerCase() + _value.slice(1);
|
||||
}
|
||||
Reference in New Issue
Block a user