or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

core-resolution.mdindex.mdmodule-registry.mdstring-utilities.md
tile.json

string-utilities.mddocs/

String Utilities

High-performance cached string transformation utilities for converting between different naming conventions used throughout Ember applications.

Capabilities

String Transformation Functions

Cached string transformation utilities that convert between various naming conventions with performance optimization.

/**
 * Converts camelCase to underscore_case
 * @param str - String to decamelize
 * @returns Decamelized string
 */
function decamelize(str: string): string;

/**
 * Replaces underscores, spaces, or camelCase with dashes
 * @param str - String to dasherize
 * @returns Dasherized string
 */
function dasherize(str: string): string;

/**
 * Returns the UpperCamelCase form of a string
 * @param str - String to classify
 * @returns Classified string
 */
function classify(str: string): string;

/**
 * Returns the lower_case_and_underscored form of a string
 * @param str - String to underscore
 * @returns Underscored string
 */
function underscore(str: string): string;

Usage Examples:

import { dasherize, classify, underscore, decamelize } from "ember-resolver/string";

// Decamelize: camelCase to underscore_case
console.log(decamelize('innerHTML')); // 'inner_html'
console.log(decamelize('actionName')); // 'action_name'
console.log(decamelize('css-class-name')); // 'css-class-name' (unchanged)

// Dasherize: various formats to dash-case
console.log(dasherize('innerHTML')); // 'inner-html'
console.log(dasherize('action_name')); // 'action-name'
console.log(dasherize('css-class-name')); // 'css-class-name' (unchanged)
console.log(dasherize('my favorite items')); // 'my-favorite-items'
console.log(dasherize('privateDocs/ownerInvoice')); // 'private-docs/owner-invoice'

// Classify: various formats to UpperCamelCase
console.log(classify('innerHTML')); // 'InnerHTML'
console.log(classify('action_name')); // 'ActionName'
console.log(classify('css-class-name')); // 'CssClassName'
console.log(classify('my favorite items')); // 'MyFavoriteItems'
console.log(classify('private-docs/owner-invoice')); // 'PrivateDocs/OwnerInvoice'

// Underscore: various formats to lower_case_with_underscores
console.log(underscore('innerHTML')); // 'inner_html'
console.log(underscore('action_name')); // 'action_name' (unchanged)
console.log(underscore('css-class-name')); // 'css_class_name'
console.log(underscore('my favorite items')); // 'my_favorite_items'
console.log(underscore('privateDocs/ownerInvoice')); // 'private_docs/owner_invoice'

String Configuration

Global string configuration system for customizing string utilities behavior.

/**
 * Sets string configuration object
 * @param strings - Configuration object for string utilities
 */
function setStrings(strings: object): void;

/**
 * Gets current string configuration
 * @returns Current string configuration object
 */
function getStrings(): object;

/**
 * Gets specific string from configuration
 * @param name - Name of string to retrieve
 * @returns String value from configuration
 */
function getString(name: string): any;

Usage Examples:

import { setStrings, getStrings, getString } from "ember-resolver/string";

// Set custom string configuration
setStrings({
  customPrefix: "my-app",
  defaultSuffix: "-component",
  specialNames: {
    user: "person",
    admin: "administrator"
  }
});

// Get all string configuration
const config = getStrings();
console.log(config.customPrefix); // "my-app"

// Get specific string
const prefix = getString("customPrefix"); // "my-app"

Performance Optimization

The string utilities use an internal caching system for optimal performance. Each function uses a dedicated LRU-like cache with a 1000-item limit to avoid recomputing transformations for commonly used strings.

Performance Characteristics

The string utilities use specialized caches for optimal performance:

  • DECAMELIZE_CACHE: 1000-item cache for decamelize operations
  • STRING_DASHERIZE_CACHE: 1000-item cache for dasherize operations
  • CLASSIFY_CACHE: 1000-item cache for classify operations
  • UNDERSCORE_CACHE: 1000-item cache for underscore operations

Each cache uses efficient regular expressions and avoids repeated computations for commonly transformed strings, making the utilities suitable for high-frequency usage in Ember applications.