数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

24 lines
471 B

'use strict';
function toBoolean(name, value, defaultValue) {
switch (typeof value) {
case "boolean":
return value;
case "number":
return !!value;
case "string":
switch (value.toLowerCase()) {
case "1":
case "true":
case name.toLowerCase():
return true;
case "0":
case "false":
case "":
return false;
}
}
return defaultValue;
}
exports.toBoolean = toBoolean;