npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

math-practice

v1.0.1

Published

数学算术脱式计算模块 - 提供多种计算策略和步骤分解

Readme

数学练习解析

提供数学算术问题解析服务,对输入的数学问题提供不同的答题提示。

解题方法类型

  • 口算 oral:直接提供算术结果
  • 脱式计算 working:展示算术计算的逐步算术过程
  • 竖式计算 vertical: 使用竖式计算展现计算过程

技术标准

  • 使用TS开发,类型定义清晰
  • 模块化、模块关系清晰

模块结构

  • working/src/types.ts:核心类型定义(Step、CalculationResult、StrategyModule 等)
  • working/src/parser.ts:表达式标准化与词法解析工具
  • working/src/addition.ts|subtraction.ts|multiplication.ts|division.ts:整数四则运算策略实现
  • working/src/decimal.ts|fraction.ts:小数与分数专用策略
  • working/src/mixed.ts:混合运算(先乘除后加减)流程
  • working/src/engine.ts:策略编排与统一对外接口
  • working/src/index.ts:导出入口

核心算法

  • 策略优先级:分数 → 小数 → 除法 → 乘法 → 加法 → 减法 → 混合运算
  • 加法策略涵盖颠倒数求和、基准数加法、拆补凑整、分组凑整、连续自然数求和等
  • 减法策略包含退位检测、分段减法与减整补差法
  • 乘法策略支持平移乘法、凑整配对、近百数乘法、乘以 11 等速算技巧
  • 除法策略覆盖除数拆分、拆整相除,以及除以 5/25/125 的换算
  • 分数策略保持分数形式输出,并在每步过程中化简
  • 混合策略根据“先乘除后加减”生成中间步骤

使用方式

  1. 安装依赖并构建
    pnpm install
    pnpm build
  2. 在代码中引入并使用默认计算引擎
    import { defaultEngine } from './working/src';
    
    const result = defaultEngine.generate('36 + 63');
    console.log(result.steps);

测试

  • 在 packages/math-practice/test 目录下编写 Jest 测试用例
  • 运行 pnpm test 执行全部测试