dustjs-linkedin
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -14,11 +14,12 @@ var dust = {}; | ||
} | ||
var ERROR = 'ERROR', | ||
var NONE = 'NONE', | ||
ERROR = 'ERROR', | ||
WARN = 'WARN', | ||
INFO = 'INFO', | ||
DEBUG = 'DEBUG', | ||
levels = [DEBUG, INFO, WARN, ERROR], | ||
loggingLevels = [DEBUG, INFO, WARN, ERROR, NONE], | ||
logger = function() {}; | ||
dust.isDebug = false; | ||
dust.debugLevel = INFO; | ||
dust.debugLevel = NONE; | ||
dust.silenceErrors = false; | ||
@@ -35,3 +36,3 @@ // Try to find the console logger in window scope (browsers) or top level scope (node.js) | ||
* This default implementation will print to the console if it exists. | ||
* @param {String} message the message to print | ||
* @param {String|Error} message the message to print/throw | ||
* @param {String} type the severity of the message(ERROR, WARN, INFO, or DEBUG) | ||
@@ -41,4 +42,10 @@ * @public | ||
dust.log = function(message, type) { | ||
var type = type || INFO; | ||
if(dust.isDebug && levels.indexOf(type) >= levels.indexOf(dust.debugLevel)) { | ||
// dust.isDebug is deprecated, so this conditional will default the debugLevel to INFO if it's set to maintain backcompat. | ||
if (dust.isDebug && dust.debugLevel === NONE) { | ||
logger.call(console || window.console, '[!!!DEPRECATION WARNING!!!]: dust.isDebug is deprecated. Set dust.debugLevel instead to the level of logging you want ["debug","info","warn","error","none"]'); | ||
dust.debugLevel = INFO; | ||
} | ||
type = type || INFO; | ||
if (loggingLevels.indexOf(type) >= loggingLevels.indexOf(dust.debugLevel)) { | ||
if(!dust.logQueue) { | ||
@@ -50,2 +57,10 @@ dust.logQueue = []; | ||
} | ||
if (!dust.silenceErrors && type === ERROR) { | ||
if (typeof message === 'string') { | ||
throw new Error(message); | ||
} else { | ||
throw message; | ||
} | ||
} | ||
}; | ||
@@ -61,4 +76,5 @@ | ||
dust.onError = function(error, chunk) { | ||
logger.call(console || window.console, '[!!!DEPRECATION WARNING!!!]: dust.onError will no longer return a chunk object.'); | ||
dust.log(error.message || error, ERROR); | ||
if(dust.isDebug) { | ||
if(!dust.silenceErrors) { | ||
throw error; | ||
@@ -84,3 +100,3 @@ } else { | ||
} catch (err) { | ||
dust.onError(err, chunk); | ||
dust.log(err, ERROR); | ||
} | ||
@@ -95,3 +111,3 @@ }; | ||
} catch (err) { | ||
dust.onError(err, stream.head); | ||
dust.log(err, ERROR); | ||
} | ||
@@ -115,3 +131,3 @@ }); | ||
else { | ||
dust.onError(new Error('Template [' + name + '] cannot be resolved to a Dust function')); | ||
dust.log(new Error('Template [' + name + '] cannot be resolved to a Dust function'), ERROR); | ||
} | ||
@@ -182,3 +198,3 @@ }); | ||
else { | ||
dust.onError(new Error('Invalid filter [' + name + ']')); | ||
dust.log(new Error('Invalid filter [' + name + ']'), ERROR); | ||
} | ||
@@ -287,4 +303,9 @@ } | ||
//wrap to preserve context 'this' see #174 | ||
return function(){ | ||
return ctx.apply(ctxThis,arguments); | ||
return function() { | ||
try { | ||
return ctx.apply(ctxThis, arguments); | ||
} catch (err) { | ||
dust.log(err, ERROR); | ||
return ctx.head; | ||
} | ||
}; | ||
@@ -365,3 +386,3 @@ } | ||
this.callback(chunk.error); | ||
dust.onError(new Error('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.')); | ||
dust.log(new Error('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.'), ERROR); | ||
this.flush = function() {}; | ||
@@ -390,3 +411,3 @@ return; | ||
this.emit('error', chunk.error); | ||
dust.onError(new Error('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.')); | ||
dust.log(new Error('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.'), ERROR); | ||
this.flush = function() {}; | ||
@@ -421,3 +442,3 @@ return; | ||
} else { | ||
dust.onError(new Error('Event Handler [' + handler + '] is not of a type that is handled by emit')); | ||
dust.log(new Error('Event Handler [' + handler + '] is not of a type that is handled by emit'), ERROR); | ||
} | ||
@@ -450,3 +471,3 @@ }; | ||
} catch (err) { | ||
dust.onError(err, stream.head); | ||
dust.log(err, ERROR); | ||
} | ||
@@ -457,3 +478,3 @@ }).on("end", function() { | ||
} catch (err) { | ||
dust.onError(err, stream.head); | ||
dust.log(err, ERROR); | ||
} | ||
@@ -693,6 +714,7 @@ }).on("error", function(err) { | ||
} else { | ||
return dust.onError(new Error('Invalid helper [' + name + ']'), chunk); | ||
dust.log(new Error('Invalid helper [' + name + ']'), ERROR); | ||
return chunk; | ||
} | ||
} catch (err) { | ||
return dust.onError(err, chunk); | ||
return dust.log(err, ERROR); | ||
} | ||
@@ -699,0 +721,0 @@ }; |
{ | ||
"name": "dustjs-linkedin", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"author": "Aleksander Williams", | ||
@@ -5,0 +5,0 @@ "description": "Asynchronous templates for the browser and node.js ( LinkedIn fork )", |
Sorry, the diff of this file is too big to display
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2581933
98
69219
9
37