Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deprecatejs

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deprecatejs - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

10

index.js
'use strict';
module.exports = function (callback, message) {
module.exports = function (callback, message, isProduction) {
if(isProduction) {
return callback;
}
return function deprecateFn () {
console.warn('- Deprecation Warning! ' + ( message || ''));
console.error('- Deprecation Warning! ' + ( message || ''));
return callback.apply(null, arguments);
};
};

2

package.json
{
"name": "deprecatejs",
"version": "1.0.3",
"version": "1.0.4",
"description": "Wrapper to deprecate JavaScript functions. Displays a custom error message if consumers call a function you've marked as deprecated",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,3 +13,3 @@ # DeprecateJS

console.log(str);
}, "Please use newFunc instead"),
}, 'Please use newFunc instead'),

@@ -29,1 +29,27 @@ newFunc: function (str) {

```
In Production: (if we dont want to console error in prod we can pass in a boolean indicating if our env isProduction)
```js
// someModule
var deprecate = require('deprecatejs');
var environment = process.env.NODE_ENV;
module.exports = {
oldFunc: deprecate(function (str) {
console.log(str);
}, 'Please use newFunc instead', environment === 'production'),
newFunc: function (str) {
...
}
};
```
```js
var someModule = require('someModule ');
someModule.oldFunc('foo.'); //in prod the error is skipped
// foo.
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc