deprecatejs
Advanced tools
Comparing version 1.0.7 to 1.0.8
'use strict'; | ||
var deprecate = function(callback, message) { | ||
if (deprecate.production) { | ||
return callback; | ||
} | ||
return function deprecateFn() { | ||
console.error('- Deprecation Warning! ' + ( message || '')); | ||
if (!deprecate.production) { | ||
console.log('- Deprecation Warning! ' + ( message || '')); | ||
} | ||
return callback.apply(null, arguments); | ||
@@ -11,0 +9,0 @@ }; |
{ | ||
"name": "deprecatejs", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"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", |
@@ -11,3 +11,3 @@ 'use strict'; | ||
describe('Deprecation warnings', function() { | ||
describe('Warnings', function() { | ||
function func1(value) { | ||
@@ -18,3 +18,3 @@ return value; | ||
beforeEach(function() { | ||
sinon.spy(console, 'error'); | ||
sinon.spy(console, 'log'); | ||
deprecate.production = false; | ||
@@ -24,6 +24,6 @@ }); | ||
afterEach(function() { | ||
console.error.restore(); | ||
console.log.restore(); | ||
}); | ||
it('should work deprecate a function', function() { | ||
it('should deprecate a function', function() { | ||
var depFunc, result; | ||
@@ -34,3 +34,3 @@ | ||
result.should.equal('str1'); | ||
expect(console.error).to.not.be.called; | ||
expect(console.log).to.not.be.called; | ||
@@ -41,4 +41,4 @@ depFunc = deprecate(func1); | ||
result.should.equal('str2'); | ||
expect(console.error).to.be.called; | ||
expect(console.log).to.be.called; | ||
}); | ||
}); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
describe('Deprecation warnings', function() { | ||
describe('Warnings', function() { | ||
function func1(value) { | ||
@@ -18,3 +18,3 @@ return value; | ||
beforeEach(function() { | ||
sinon.spy(console, 'error'); | ||
sinon.spy(console, 'log'); | ||
deprecate.inProduction(); | ||
@@ -24,3 +24,3 @@ }); | ||
afterEach(function() { | ||
console.error.restore(); | ||
console.log.restore(); | ||
}); | ||
@@ -34,3 +34,3 @@ | ||
result.should.equal('str1'); | ||
expect(console.error).to.not.be.called; | ||
expect(console.log).to.not.be.called; | ||
@@ -41,4 +41,4 @@ depFunc = deprecate(func1); | ||
result.should.equal('str2'); | ||
expect(console.error).to.not.be.called; | ||
expect(console.log).to.not.be.called; | ||
}); | ||
}); |
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
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
13602
78