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

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

    depd依赖模块 - 编程技术参考——模具行业从业者必备知识手册

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

      <h2>depd</h2>

      <p>[![NPM Version][npm-version-image]][npm-url]</p>
      <p>[![NPM Downloads][npm-downloads-image]][npm-url]</p>
      <p>[![Node.js Version][node-image]][node-url]</p>
      <p>[![Linux Build][travis-image]][travis-url]</p>
      <p>[![Windows Build][appveyor-image]][appveyor-url]</p>
      <p>[![Coverage Status][coveralls-image]][coveralls-url]</p>

      <p>Deprecate all the things</p>

      <blockquote>
      <p>With great modules comes great responsibility; mark things deprecated!</p>
      </blockquote>

      <h3>Install</h3>

      <p>This module is installed directly using <code>npm</code>:</p>

      <pre><code>
      $ npm install depd
      </code></pre>

      <p>This module can also be bundled with systems like</p>
      <p><a href="http://browserify.org/">Browserify</a> or <a href="https://webpack.github.io/">webpack</a>,</p>
      <p>though by default this module will alter it's API to no longer display or</p>
      <p>track deprecations.</p>

      <h3>API</h3>

      <p><!-- eslint-disable no-unused-vars --></p>

      <pre><code>
      var deprecate = require('depd')('my-module')
      </code></pre>

      <p>This library allows you to display deprecation messages to your users.</p>
      <p>This library goes above and beyond with deprecation warnings by</p>
      <p>introspection of the call stack (but only the bits that it is interested</p>
      <p>in).</p>

      <p>Instead of just warning on the first invocation of a deprecated</p>
      <p>function and never again, this module will warn on the first invocation</p>
      <p>of a deprecated function per unique call site, making it ideal to alert</p>
      <p>users of all deprecated uses across the code base, rather than just</p>
      <p>whatever happens to execute first.</p>

      <p>The deprecation warnings from this module also include the file and line</p>
      <p>information for the call into the module that the deprecated function was</p>
      <p>in.</p>

      <p><strong>NOTE</strong> this library has a similar interface to the <code>debug</code> module, and</p>
      <p>this module uses the calling file to get the boundary for the call stacks,</p>
      <p>so you should always create a new <code>deprecate</code> object in each file and not</p>
      <p>within some central file.</p>

      <h4>depd(namespace)</h4>

      <p>Create a new deprecate function that uses the given namespace name in the</p>
      <p>messages and will display the call site prior to the stack entering the</p>
      <p>file this function was called from. It is highly suggested you use the</p>
      <p>name of your module as the namespace.</p>

      <h4>deprecate(message)</h4>

      <p>Call this function from deprecated code to display a deprecation message.</p>
      <p>This message will appear once per unique caller site. Caller site is the</p>
      <p>first call site in the stack in a different file from the caller of this</p>
      <p>function.</p>

      <p>If the message is omitted, a message is generated for you based on the site</p>
      <p>of the <code>deprecate()</code> call and will display the name of the function called,</p>
      <p>similar to the name displayed in a stack trace.</p>

      <h4>deprecate.function(fn, message)</h4>

      <p>Call this function to wrap a given function in a deprecation message on any</p>
      <p>call to the function. An optional message can be supplied to provide a custom</p>
      <p>message.</p>

      <h4>deprecate.property(obj, prop, message)</h4>

      <p>Call this function to wrap a given property on object in a deprecation message</p>
      <p>on any accessing or setting of the property. An optional message can be supplied</p>
      <p>to provide a custom message.</p>

      <p>The method must be called on the object where the property belongs (not</p>
      <p>inherited from the prototype).</p>

      <p>If the property is a data descriptor, it will be converted to an accessor</p>
      <p>descriptor in order to display the deprecation message.</p>

      <h4>process.on('deprecation', fn)</h4>

      <p>This module will allow easy capturing of deprecation errors by emitting the</p>
      <p>errors as the type "deprecation" on the global <code>process</code>. If there are no</p>
      <p>listeners for this type, the errors are written to STDERR as normal, but if</p>
      <p>there are any listeners, nothing will be written to STDERR and instead only</p>
      <p>emitted. From there, you</p>

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

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