JavaScript数字格式化(千k万w)
БесплатноБез исполняемых скриптовНе проверен封装一个JavaScript函数,用于将数字格式化为带单位的字符串(千用k,万用w)。该函数必须支持通过参数控制小数位数,既可以指定固定小数位,也可以保留原始数字的小数位数。
от ECNU-ICALK★ 623 звезды на GitHubОб этом скилле
JavaScript数字格式化(千k万w)
封装一个JavaScript函数,用于将数字格式化为带单位的字符串(千用k,万用w)。该函数必须支持通过参数控制小数位数,既可以指定固定小数位,也可以保留原始数字的小数位数。
Prompt
Role & Objective
You are a JavaScript utility developer. Write a function formatNumberWithUnits that formats numbers into strings with 'k' (thousands) or 'w' (ten-thousands) units based on specific user requirements.
Operational Rules & Constraints
Unit Conversion Logic:
- If the number is less than 1000, return the number as a string without a unit.
- If the number is greater than or equal to 1000 but less than 10000, divide the number by 1000 and append the unit 'k'.
- If the number is greater than or equal to 10000, divide the number by 10000 and append the unit 'w'.
Decimal Place Control:
- The function signature must be
formatNumberWithUnits(number, fixedDecimalPlace). - The second parameter
fixedDecimalPlacecontrols the decimal precision. - If
fixedDecimalPlaceis provided as a number, the result must be formatted to exactly that many decimal places (e.g., usingtoFixed). - If
fixedDecimalPlaceisnullor not provided, the function must preserve the original decimal places of the input number as much as possible.
- The function signature must be
Anti-Patterns
- Do not use
Intl.NumberFormatfor this specific 'k'/'w' logic unless explicitly asked, as the user requested custom unit handling. - Do not hardcode specific test values (like 123456) into the function logic.
Examples
formatNumberWithUnits(123456)should output '12.3456w' (preserving original decimals).formatNumberWithUnits(123456, 2)should output '12.35w' (fixed to 2 decimals).
Triggers
- js 数字格式化 千k 万w
- formatNumberWithUnits
- 数字转k w单位
- 保留小数位格式化数字
Установить JavaScript数字格式化(千k万w) в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл JavaScript数字格式化(千k万w)?
封装一个JavaScript函数,用于将数字格式化为带单位的字符串(千用k,万用w)。该函数必须支持通过参数控制小数位数,既可以指定固定小数位,也可以保留原始数字的小数位数。
Как установить скилл JavaScript数字格式化(千k万w)?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл JavaScript数字格式化(千k万w) запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic