CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-sindresorhus--slugify

Slugify a string with comprehensive Unicode transliteration and extensive customization options

94

1.34x
Overview
Eval results
Files

task.mdevals/scenario-1/

Identifier Slug Converter

Build a utility that converts programming identifiers (variable names, class names, function names) into URL-friendly slugs for use in documentation sites.

Requirements

Your solution should handle the following conversions:

Convert various identifier formats to slugs

  • Convert simple camelCase identifiers like fooBar to foo-bar @test
  • Convert PascalCase identifiers like UserProfile to user-profile @test
  • Convert identifiers with numbers like FOO360BAR to foo-360-bar @test
  • Convert acronym-based identifiers like APISection to api-section @test
  • Convert mixed-case identifiers like XMLHttpRequest to xml-http-request @test

Handle edge cases

  • Convert single-word identifiers like foo to foo @test
  • Convert all-uppercase identifiers like API to api @test

Implementation

Create a function convertIdentifierToSlug that takes a string (programming identifier) and returns a URL-friendly slug string.

@generates

API

/**
 * Converts a programming identifier to a URL-friendly slug
 *
 * @param {string} identifier - The programming identifier to convert
 * @returns {string} The URL-friendly slug
 */
function convertIdentifierToSlug(identifier) {
  // IMPLEMENTATION HERE
}

module.exports = { convertIdentifierToSlug };

Dependencies { .dependencies }

@sindresorhus/slugify { .dependency }

Provides string slugification support.

Install with Tessl CLI

npx tessl i tessl/npm-sindresorhus--slugify

tile.json