deprecatejs
Advanced tools
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); | ||
}; | ||
}; |
{ | ||
"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. | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
1943
10
53