github.com/jfrog/frogbot@v1.1.1-0.20231221090046-821a26f50338/action/node_modules/deprecation/README.md (about)

     1  # deprecation
     2  
     3  > Log a deprecation message with stack
     4  
     5  ![build](https://action-badges.now.sh/gr2m/deprecation)
     6  
     7  ## Usage
     8  
     9  <table>
    10  <tbody valign=top align=left>
    11  <tr><th>
    12  Browsers
    13  </th><td width=100%>
    14  
    15  Load `deprecation` directly from [cdn.pika.dev](https://cdn.pika.dev)
    16  
    17  ```html
    18  <script type="module">
    19    import { Deprecation } from "https://cdn.pika.dev/deprecation/v2";
    20  </script>
    21  ```
    22  
    23  </td></tr>
    24  <tr><th>
    25  Node
    26  </th><td>
    27  
    28  Install with `npm install deprecation`
    29  
    30  ```js
    31  const { Deprecation } = require("deprecation");
    32  // or: import { Deprecation } from "deprecation";
    33  ```
    34  
    35  </td></tr>
    36  </tbody>
    37  </table>
    38  
    39  ```js
    40  function foo() {
    41    bar();
    42  }
    43  
    44  function bar() {
    45    baz();
    46  }
    47  
    48  function baz() {
    49    console.warn(new Deprecation("[my-lib] foo() is deprecated, use bar()"));
    50  }
    51  
    52  foo();
    53  // { Deprecation: [my-lib] foo() is deprecated, use bar()
    54  //     at baz (/path/to/file.js:12:15)
    55  //     at bar (/path/to/file.js:8:3)
    56  //     at foo (/path/to/file.js:4:3)
    57  ```
    58  
    59  To log a deprecation message only once, you can use the [once](https://www.npmjs.com/package/once) module.
    60  
    61  ```js
    62  const Deprecation = require("deprecation");
    63  const once = require("once");
    64  
    65  const deprecateFoo = once(console.warn);
    66  
    67  function foo() {
    68    deprecateFoo(new Deprecation("[my-lib] foo() is deprecated, use bar()"));
    69  }
    70  
    71  foo();
    72  foo(); // logs nothing
    73  ```
    74  
    75  ## License
    76  
    77  [ISC](LICENSE)