Community写作与编辑github.com

shuangying0001-beep/unit-converter

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

unit-converter 是什么?

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

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add shuangying0001-beep/unit-converter

Installed? Explore more 写作与编辑 skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

unit-converter —— Unit Conversion / Specification Structuring

Parse text values with units into standardized unit values. Pure functions (Node ESM, zero dependencies), directly importable. Extracted from caijiqi-kaifa/electron/collector/content-parser.ts's parseWeightToKg / parseDimensionsToCm, and extended with voltage/power/color temperature/lumen.

Use Cases

  • Amazon / e-commerce platform scraped weight and dimension values in pounds / inches / oz, need to unify to kg / cm
  • Product spec text (e.g., Weight: 2.5 kg, Dimensions: 10 x 8 x 2 inches, Voltage: 120V) needs to be structured for database storage
  • Logistics pricing based on weight, supply chain dimension database normalization before storing

Usage

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'); // auto extract key parameters

Core API

  • parseWeightToKg(value) → number | null: Supports kg / pounds(lbs) / ounces(oz) / grams(g) → kg (rounded to 3 decimal places)
  • parseDimensionsToCm(value) → { length?, width?, height? } | null: Supports L x W x H (inches|in|cm|mm) → cm (rounded to 2 decimal places, defaults to inches if unit missing)
  • 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) → Batch extract all recognizable parameters from a text string (returns object)

Notes

  • Returns null on parsing failure (no throwing), caller decides default values.
  • Fully local parsing, no network calls, no data upload.

相关技能