mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
30 lines
711 B
JavaScript
30 lines
711 B
JavaScript
let utils = {};
|
|
|
|
Object.assign(utils, require('./number_format'));
|
|
|
|
Object.assign(utils, {
|
|
slug(text) {
|
|
return text.toLowerCase().replace(/ /g, '_');
|
|
},
|
|
|
|
get_random_name() {
|
|
return Math.random().toString(36).substr(3);
|
|
},
|
|
|
|
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; |