For AI agents: the complete documentation index is available at /tc39-atlas/llms.txt, the full documentation bundle is available at /tc39-atlas/llms-full.txt, and this page is available as Markdown at /tc39-atlas/proposals/proposal-math-extensions.md.
  • 简体中文
  • Math Extensions ?

    中文标题:数学扩展

    提案概览
    提案速览

    该提案旨在将常见的数学函数(如度/弧度转换、缩放、钳位)作为内置的 Math 方法添加,因为这些函数在许多 JS 库中经常以不一致的方式实现。它参考了 Java、Python、Racket 和 Rust 中的实现。map 与 Math.scale)的开放问题,并且已有 polyfill 可用。

    Note

    以下 README 来自上游仓库,其中的阶段或状态标注可能滞后;当前信息以提案概览为准。

    Math 扩展提案

    Champion

    Rick Waldron

    状态

    该提案目前处于 TC39 流程 的 stage 1。

    动机

    这些函数存在于许多、许多 JavaScript 库中,无论是手写的还是通过 npm 上的许多模块。将它们作为内置函数提供有助于铺设牛道。实现和命名不一致。其他几种语言将这些作为内置函数提供。

    Java

    Python

    Racket

    Rust

    问题

    • Math.map
      • 它是...
        • Math.scale <-- 这个
        • Math.map
        • Math.remap
      • 是否应该有一个对应的 Math.fmap?(即 https://tc39.github.io/ecma262/#sec-math.fround, 第 3 和 4 步将结果转换为 IEEE 754-2008 binary32(使用 roundTiesToEven),然后转换为 IEEE 754-2008 binary64).
    • Math.constrain
      • 它是...
        • Math.constrain
        • Math.clamp

    Polyfill