or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-lodash.startcase

The lodash method _.startCase exported as a module for converting strings to start case format

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash.startcase@3.1.x

To install, run

npx @tessl/cli install tessl/npm-lodash.startcase@3.1.0

index.mddocs/

Lodash StartCase

Lodash StartCase provides the startCase method from the Lodash utility library as a standalone module. The startCase function converts strings to start case format, where each word is capitalized and separated by spaces. It handles various input formats including camelCase, snake_case, kebab-case, and other delimited strings, transforming them into properly formatted title case text.

Package Information

  • Package Name: lodash.startcase
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash.startcase

Core Imports

var startCase = require('lodash.startcase');

For ES modules (if supported):

import startCase from 'lodash.startcase';

Basic Usage

var startCase = require('lodash.startcase');

// Convert camelCase
var result1 = startCase('fooBar');
// => 'Foo Bar'

// Convert kebab-case  
var result2 = startCase('--foo-bar');
// => 'Foo Bar'

// Convert snake_case
var result3 = startCase('__foo_bar__');
// => 'Foo Bar'

// Convert space-separated
var result4 = startCase('foo bar');
// => 'Foo Bar'

// Handle all caps (converted to proper case)
var result5 = startCase('FOO BAR');
// => 'Foo Bar'

Capabilities

Start Case Conversion

Converts strings to start case format where each word is capitalized and separated by spaces.

/**
 * Converts string to start case.
 * @param {string} [string=''] - The string to convert
 * @returns {string} Returns the start cased string
 */
function startCase(string)

Usage Examples:

var startCase = require('lodash.startcase');

// Basic conversions
startCase('fooBar');
// => 'Foo Bar'

startCase('foo-bar');  
// => 'Foo Bar'

startCase('foo_bar');
// => 'Foo Bar'

startCase('foo bar');
// => 'Foo Bar'

// Handles various delimiters
startCase('--foo-bar--');
// => 'Foo Bar'

startCase('__foo_bar__');
// => 'Foo Bar'

// All caps (converted to proper case)
startCase('FOO BAR');
// => 'Foo Bar'

startCase('fOoBaR');
// => 'F Oo Ba R'

// Empty and null handling
startCase('');
// => ''

startCase();
// => ''

// Accented characters
startCase('café-münü');
// => 'Cafe Menu'

// Numbers and special characters
startCase('foo2bar');
// => 'Foo 2 Bar'

startCase('foo-bar-123');
// => 'Foo Bar 123'

Implementation Details

The startCase function:

  1. Input Processing: Accepts any input and converts it to a string
  2. Deburring: Removes diacritical marks from Latin characters (café → cafe)
  3. Word Extraction: Uses pattern matching to identify word boundaries across various formats:
    • Camel case boundaries (fooBar → foo, Bar)
    • Underscore delimiters (foo_bar → foo, bar)
    • Hyphen delimiters (foo-bar → foo, bar)
    • Space delimiters (foo bar → foo, bar)
    • Mixed delimiters (foo-bar → foo, bar)
  4. Capitalization: Capitalizes the first character of each extracted word
  5. Joining: Combines words with single spaces

Error Handling

  • Null/Undefined Input: Returns empty string
  • Non-String Input: Automatically converted to string representation
  • Empty String: Returns empty string
  • No Exceptions: Function does not throw errors for any input type

Performance Characteristics

  • Algorithm: Single-pass processing with regex-based word extraction
  • Memory: Minimal allocation, processes input once
  • Compatibility: Works in all JavaScript environments (Node.js, browsers)
  • Dependencies: Standalone module with no external dependencies