Skip to content

Commit 1b02da5

Browse files
thonatosJacksonTian
authored andcommitted
refactor: use es6 & use sync func
1 parent 48453a7 commit 1b02da5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

app/common/tools.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const moment = require('moment');
66
moment.locale('zh-cn'); // 使用中文
77

88
// 格式化时间
9-
exports.formatDate = function(date, friendly) {
9+
exports.formatDate = (date, friendly) => {
1010
date = moment(date);
1111

1212
if (friendly) {
@@ -16,14 +16,14 @@ exports.formatDate = function(date, friendly) {
1616
return date.format('YYYY-MM-DD HH:mm');
1717
};
1818

19-
exports.validateId = function(str) {
19+
exports.validateId = str => {
2020
return /^[a-zA-Z0-9\-_]+$/i.test(str);
2121
};
2222

23-
exports.bhash = function(str, callback) {
24-
bcrypt.hash(str, 10, callback);
23+
exports.bhash = str => {
24+
return bcrypt.hashSync(str, 10);
2525
};
2626

27-
exports.bcompare = function(str, hash, callback) {
28-
bcrypt.compare(str, hash, callback);
27+
exports.bcompare = (str, hash) => {
28+
return bcrypt.compareSync(str, hash);
2929
};

0 commit comments

Comments
 (0)