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-6/

Filename Sanitizer with Performance Optimization

A utility that generates safe filenames from user-provided strings with performance optimizations for ASCII content.

Problem Description

Build a filename sanitizer that converts user input into filesystem-safe filenames. The system should handle both ASCII and non-ASCII content, optimizing performance when working with ASCII-only strings.

Requirements:

  • Convert strings into safe filenames with underscores as separators
  • For ASCII content: skip character conversion for better performance
  • For Unicode content: either preserve Unicode characters or convert them to ASCII equivalents

Requirements

Filename Sanitization with Performance Options

  • Converts "hello world 2024" to "hello_world_2024" using performance-optimized processing @test
  • Converts "文档 2024" to "文档_2024" when preserving Unicode characters @test
  • Converts "Über München" to "ueber_muenchen" when converting to ASCII @test

Implementation

@generates

API

/**
 * Generates a safe filename from user input with ASCII performance optimization
 *
 * @param {string} input - The user-provided string to convert
 * @param {Object} options - Configuration options
 * @param {boolean} options.preserveUnicode - If true, preserves non-ASCII characters instead of converting them
 * @returns {string} A filesystem-safe filename
 */
function generateFilename(input, options = {}) {
  // IMPLEMENTATION HERE
}

module.exports = { generateFilename };

Dependencies { .dependencies }

@sindresorhus/slugify { .dependency }

Provides string slugification with Unicode support and performance optimizations.

Install with Tessl CLI

npx tessl i tessl/npm-sindresorhus--slugify

tile.json