不要怂,就是干,撸起袖子干!

Commit 9717f90c by Felix Becker Committed by Mick Hansen

ES6 refactor of parameter-validator.js (#6079)

let, const, template strings, export default
1 parent 37c176a3
Showing with 7 additions and 5 deletions
'use strict';
var _ = require('lodash');
var util = require('util');
const _ = require('lodash');
const util = require('util');
function validateDeprecation (value, expectation, options) {
if (!options.deprecated) {
return;
}
var valid = value instanceof options.deprecated || Object.prototype.toString.call(value) === Object.prototype.toString.call(options.deprecated.call());
const valid = value instanceof options.deprecated || Object.prototype.toString.call(value) === Object.prototype.toString.call(options.deprecated.call());
if (valid) {
var message = util.format('%s should not be of type "%s"', util.inspect(value), options.deprecated.name);
const message = `${util.inspect(value)} should not be of type "${options.deprecated.name}"`;
console.log('DEPRECATION WARNING:', options.deprecationWarning || message);
}
......@@ -26,7 +26,7 @@ function validate (value, expectation) {
return true;
}
throw new Error(util.format('The parameter (value: %s) is no %s.', value, expectation.name));
throw new Error(`The parameter (value: ${value}) is no ${expectation.name}`);
}
function check (value, expectation, options) {
......@@ -55,3 +55,5 @@ function check (value, expectation, options) {
}
module.exports = check;
module.exports.check = check;
module.exports.default = check;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!