Socket
Socket
Sign inDemoInstall

util-deprecate

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

util-deprecate

The Node.js `util.deprecate()` function with browser support


Version published
Maintainers
1
Weekly downloads
38,662,613
decreased by-9.85%

Weekly downloads

Package description

What is util-deprecate?

The util-deprecate package is a utility for node and the browser that allows developers to mark functions or methods as deprecated. This helps in signaling to users of the library that a particular function or method will be removed or changed in future releases. It provides a straightforward way to display deprecation warnings to developers, encouraging them to update their code to use newer or preferred APIs.

What are util-deprecate's main functionalities?

Deprecating a function

This feature allows you to wrap a function with a deprecation warning. When the deprecated function is called, it will execute normally, but it will also print a warning message to the console indicating that the function is deprecated.

const deprecate = require('util-deprecate');
const deprecatedFunction = deprecate(function() {}, 'deprecatedFunction is deprecated and will be removed in the next major release.');

Custom warning message

This demonstrates how to provide a custom warning message for the deprecated function. This is useful for guiding users towards an alternative function or method.

const deprecate = require('util-deprecate');
const customWarningFunction = deprecate(function() {}, 'customWarningFunction is deprecated. Please use alternativeFunction instead.');

Other packages similar to util-deprecate

Readme

Source

util-deprecate

The Node.js util.deprecate() function with browser support

In Node.js, this module simply re-exports the util.deprecate() function.

In the web browser (i.e. via browserify), a browser-specific implementation of the util.deprecate() function is used.

API

A deprecate() function is the only thing exposed by this module.

// setup:
exports.foo = deprecate(foo, 'foo() is deprecated, use bar() instead');


// users see:
foo();
// foo() is deprecated, use bar() instead
foo();
foo();

License

(The MIT License)

Copyright (c) 2014 Nathan Rajlich nathan@tootallnate.net

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Last updated on 07 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc