UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

18 lines (17 loc) 561 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.lcfirst = lcfirst; function lcfirst(str) { // discuss at: https://locutus.io/perl/lcfirst/ // parity verified: Perl 5.40 // original by: Kevin van Zonneveld (https://kvz.io) // example 1: lcfirst('HELLO') // returns 1: 'hELLO' // example 2: lcfirst('Hello') // returns 2: 'hello' const value = String(str); if (!value) { return ''; } return value.charAt(0).toLowerCase() + value.slice(1); }