模极社社区 - 制造业全产业链交流平台

    • 登录
    • 版块
    • 最新
    • 话题
    • 热门
    • 用户
    • 群组

    Prototypes——模具行业从业者必备知识手册

    社区公告
    1
    1
    0
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • S
      system 2 最后由 编辑

      <h2>Prototypes</h2>

      <p>The functions in this folder are to be use for keeping cached references to the built-in prototypes, so that people can't inadvertently break the library by making mistakes in userland.</p>

      <p>See https://github.com/sinonjs/sinon/pull/1523</p>

      <h3>Without cached references</h3>

      <pre><code>
      // in userland, the library user needs to replace the filter method on
      // Array.prototype
      var array = [1, 2, 3];
      sinon.replace(array, "filter", sinon.fake.returns(2));

      // in a sinon module, the library author needs to use the filter method
      var someArray = ["a", "b", 42, "c"];
      var answer = filter(someArray, function (v) {
      return v === 42;
      });

      console.log(answer);
      // => 2
      </code></pre>

      <h3>With cached references</h3>

      <pre><code>
      // in userland, the library user needs to replace the filter method on
      // Array.prototype
      var array = [1, 2, 3];
      sinon.replace(array, "filter", sinon.fake.returns(2));

      // in a sinon module, the library author needs to use the filter method
      // get a reference to the original Array.prototype.filter
      var filter = require("@sinonjs/commons").prototypes.array.filter;
      var someArray = ["a", "b", 42, "c"];
      var answer = filter(someArray, function (v) {
      return v === 42;
      });

      console.log(answer);
      // => 42
      </code></pre>

      <hr>

      <p>本文由模极社发布</p>

      <h4>📋 内容概览</h4>

      <table>
      <tr><td>分类</td><td>要点</td><td>建议/说明</td></tr>
      <tr><td>核心概念</td><td>Prototypes</td><td>详见正文</td></tr>
      <tr><td>操作步骤</td><td>Prototypes</td><td>详见正文</td></tr>
      <tr><td>注意事项</td><td>Prototypes</td><td>详见正文</td></tr>
      <tr><td>适用场景</td><td>Prototypes</td><td>详见正文</td></tr>
      <tr><td>常见问题</td><td>Prototypes</td><td>详见正文</td></tr>
      </table>

      <hr>
      <h4>🔗 你可能还感兴趣</h4>
      <ul>
      <li><a href="/t/3478/3478">VDMA 德国机械制造商联合会工模具分会</a></li>
      <li><a href="/t/4375/4375">jest-docblock</a></li>
      <li><a href="/t/4507/4507">@vue/compiler-vapor</a></li>
      </ul>

      <hr>
      <p><strong>相关推荐:</strong></p>
      <ul>
      <li><a href="https://www.mj7.cn/t/4836-4836">北京模具产业 — 科技研发驱动型模具基地</a></li>
      <li><a href="https://www.mj7.cn/t/4835-4835">上海模具产业 — 高端精密模具研发中心</a></li>
      <li><a href="https://www.mj7.cn/t/4834-4834">产业集群与模具产业发展的关系</a></li>
      </ul>

      <hr>
      <p>这个参数你们一般设多少?评论区说说。</p>

      1 条回复 最后回复 回复 引用 0
      • First post
        Last post
      Powered by NodeBB | Contributors