mirror of
https://github.com/frappe/books.git
synced 2024-11-14 01:14:03 +00:00
26 lines
626 B
JavaScript
26 lines
626 B
JavaScript
let utils = {};
|
|
|
|
Object.assign(utils, require('./number_format'));
|
|
|
|
Object.assign(utils, {
|
|
slug(text) {
|
|
return text.toLowerCase().replace(/ /g, '_');
|
|
},
|
|
|
|
async_handler(fn) {
|
|
return (req, res, next) => Promise.resolve(fn(req, res, next))
|
|
.catch((err) => {
|
|
console.log(err);
|
|
// handle error
|
|
res.status(err.status_code || 500).send({error: err.message});
|
|
});
|
|
},
|
|
|
|
async sleep(seconds) {
|
|
return new Promise(resolve => {
|
|
setTimeout(resolve, seconds * 1000);
|
|
});
|
|
}
|
|
});
|
|
|
|
module.exports = utils; |