CommunityEscrita e Ediçãogithub.com

shuangying0001-beep/unit-converter

电商/物流规格单位换算(kg·cm·V·W):把5kg 30cm这类带单位文本解析换算成标准单位。适合电商运营、物流报价、BOM 整理。

O que é unit-converter?

unit-converter is a Claude Code agent skill that 电商/物流规格单位换算(kg·cm·V·W):把5kg 30cm这类带单位文本解析换算成标准单位。适合电商运营、物流报价、BOM 整理。.

Funciona com~Claude Code~Codex CLI~Cursor
npx skills add shuangying0001-beep/unit-converter

Installed? Explore more Escrita e Edição skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

unit-converter —— 单位换算 / 规格参数结构化

把带单位的文本数值解析成统一标准单位的数值。纯函数(Node ESM,零依赖),可直接 import。 抽取自 caijiqi-kaifa/electron/collector/content-parser.ts 中的 parseWeightToKg / parseDimensionsToCm,并扩展电压/功率/色温/流明。

适用场景

  • 亚马逊 / 电商平台抓到的重量、尺寸是 pounds / inches / oz,要统一成 kg / cm
  • 商品规格文本(如 Weight: 2.5 kg、Dimensions: 10 x 8 x 2 inches、Voltage: 120V)要结构化落库
  • 物流按重量计费、供应链按尺寸建库前的单位归一

用法

import { parseWeightToKg, parseDimensionsToCm, parseVoltageToV, parseSpec } from './scripts/unit-converter.mjs';

parseWeightToKg('15.4 pounds');          // 6.984 (kg)
parseWeightToKg('500 g');                // 0.5
parseDimensionsToCm('10 x 8 x 2 inches');// { length: 25.4, width: 20.32, height: 5.08 }
parseDimensionsToCm('300x200x100 mm');   // { length: 30, width: 20, height: 10 }
parseVoltageToV('120 volts');            // 120
parseSpec('Weight: 1.2kg, Dimensions: 10x8x2in, Voltage 120V 60W'); // 自动挑关键参数

核心 API

  • parseWeightToKg(value) → number | null:支持 kg / pounds(lbs) / ounces(oz) / grams(g) → kg(保留 3 位)
  • parseDimensionsToCm(value) → { length?, width?, height? } | null:支持 L x W x H (inches|in|cm|mm) → cm(保留 2 位,缺省按 inches 算)
  • parseVoltageToV(value) → number | null:V / volts
  • parseWattageToW(value) → number | null:W / watts
  • parseColorTempToK(value) → number | null:K / kelvin
  • parseLumens(value) → number | null:lm / lumens
  • parseSpec(text) → 批量从一段文本里提取所有可识别参数(返回对象)

注意

  • 解析失败返回 null(不会抛错),调用方自行决定默认值。
  • 纯本地解析,不联网、不上传。

Habilidades Relacionadas