CSlawyer1985/legal-skillhub / skills/awlm2026472
awlm2026472
Verified用 fraction.js 做份额/股权比例精算。当用户要分数运算、股权比例、fraction.js 时使用。轻量接入:new Fraction + add/div;输出约分后的比与百分比;不做完整股权系统。
股权份额精算
灵感:能力工具箱 fraction-js(fraction.js 做份额/股权比例精算)。
小四原创:份数 →
Fraction→ 约分占比。
避免0.1+0.2式浮点比例误差。
何时使用
- 合伙人份额占比
- 按份数分摊金额
- Demo 股权比例展示
硬约束
- 依赖:
fraction.js。 - 入参用整数份数或可解析分数串。
- 实现要点注释标 小四原创。
- 不做完整股权登记/协议生成。
推荐实现
import Fraction from 'fraction.js'
// 小四原创:股权份额精算
export function shareRatio(parts: number[]): { labels: string[]; pct: string[] } {
const total = parts.reduce((a, b) => a + b, 0)
if (!total) return { labels: [], pct: [] }
const labels = parts.map((p) => new Fraction(p, total).toFraction(true))
const pct = parts.map((p) =>
new Fraction(p, total).mul(100).valueOf().toFixed(2) + '%'
)
return { labels, pct }
}
export function splitByShares(amount: string, parts: number[]): string[] {
const total = parts.reduce((a, b) => a + b, 0)
if (!total) return parts.map(() => '0')
return parts.map((p) =>
new Fraction(amount).mul(p).div(total).valueOf().toFixed(2)
)
}
Agent 步骤
npm i fraction.js。- 输入各方份数;展示
toFraction与百分比。 - 自测:
[1,1,2]得1/4,1/4,1/2。
不要做
- 用浮点直接除算出比例当最终结果。
- 做成完整股权台账。
附加
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |