UNPKG

@sap/cds

Version:

SAP Cloud Application Programming Model - CDS for Node.js

20 lines (18 loc) 407 B
module.exports.time2ms = timeout => { const match = timeout.match(/^([0-9]+)(w|d|h|hrs|min)$/) if (!match) return const [, val, t] = match switch (t) { case 'w': return val * 1000 * 3600 * 24 * 7 case 'd': return val * 1000 * 3600 * 24 case 'h': case 'hrs': return val * 1000 * 3600 case 'min': return val * 1000 * 60 default: return val } }