360 Secure SkillHub
360 安全技能中心

string-utils

该 Skill 是一个 JavaScript 字符串工具模块,提供大小写转换、修剪与填充、截断、slug 生成、HTML 转义/反转义、URL 编解码、模板插值和字符串相似度等函数;文档给出调用示例,未说明网络或外部服务依赖。

jpengcheng523-netizen
jpengcheng523-netizen
热度 42.20
最近更新 2026-05-11 17:37:03
分类:效率依赖:代码执行应用场景:数据处理 / 模板

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add jpeng-string-utils
Metadata
name
string-utils
description
Provides string manipulation and transformation operations for working with text. Use when you need to transform, format, or manipulate strings.

String Utils

Provides string manipulation and transformation operations.

Usage

const str = require('./skills/string-utils');

// Case conversion
const camel = str.toCamelCase('hello world'); // helloWorld
const snake = str.toSnakeCase('helloWorld'); // hello_world
const kebab = str.toKebabCase('helloWorld'); // hello-world

// Trimming and padding
const trimmed = str.trim('  hello  '); // 'hello'
const padded = str.padLeft('5', 3, '0'); // '005'

// Truncation
const short = str.truncate('hello world', 8); // 'hello...'

// Slug generation
const slug = str.slugify('Hello World!'); // 'hello-world'

// Escape/unescape
const escaped = str.escapeHtml('<div>'); // '&lt;div&gt;'

Features

  • Case conversion (camelCase, snake_case, kebab-case, PascalCase, etc.)
  • Trimming and padding
  • Truncation with ellipsis
  • Slug generation
  • HTML escape/unescape
  • URL encoding/decoding
  • Template interpolation
  • String similarity