lib/logRotator.js
function timeInMs(time) {
	var HOUR_IN_MS = 3.6e+6,
		DAY_IN_MS = HOUR_IN_MS * 24,
		WK_IN_MS = DAY_IN_MS * 7,
		MS_DICTIONARY = {
			'weeks': WK_IN_MS,
			'week': WK_IN_MS,
			'w': WK_IN_MS,
			'days': DAY_IN_MS,
			'day': DAY_IN_MS,
			'd': DAY_IN_MS,
			'hours': HOUR_IN_MS,
			'hour': HOUR_IN_MS,
			'h': HOUR_IN_MS
		};

	var duration = parseInt(time, 10);
	var interval = time.replace(/\d*[\d]/, '').trim();

	if (Object.keys(MS_DICTIONARY).indexOf(interval) < 0) {
		throw new Error('Interval is invalid. The ttl must be of weeks, days, or hours');
	}

	return MS_DICTIONARY[interval] * duration;
}
function timeInMs(time) {
	var HOUR_IN_MS = 3.6e+6,
		DAY_IN_MS = HOUR_IN_MS * 24,
		WK_IN_MS = DAY_IN_MS * 7,
		MS_DICTIONARY = {
			'weeks': WK_IN_MS,
			'week': WK_IN_MS,
			'w': WK_IN_MS,
			'days': DAY_IN_MS,
			'day': DAY_IN_MS,
			'd': DAY_IN_MS,
			'hours': HOUR_IN_MS,
			'hour': HOUR_IN_MS,
			'h': HOUR_IN_MS
		};

	var duration = parseInt(time, 10);
	var interval = time.replace(/\d*[\d]/, '').trim();

	if (Object.keys(MS_DICTIONARY).indexOf(interval) < 0) {
		throw new Error('Interval is invalid. The ttl must be of weeks, days, or hours');
	}

	return MS_DICTIONARY[interval] * duration;
}
function timeInMs ( time ) { var HOUR_IN_MS = 3.6e+6 , DAY_IN_MS = HOUR_IN_MS * 24 , WK_IN_MS = DAY_IN_MS * 7 , MS_DICTIONARY = { 'weeks' : WK_IN_MS , 'week' : WK_IN_MS , 'w' : WK_IN_MS , 'days' : DAY_IN_MS , 'day' : DAY_IN_MS , 'd' : DAY_IN_MS , 'hours' : HOUR_IN_MS , 'hour' : HOUR_IN_MS , 'h' : HOUR_IN_MS } ; var duration = parseInt ( time , 10 ) ; var interval = time . replace ( / \d*[\d] / , '' ) . trim ( ) ; if ( Object . keys ( MS_DICTIONARY ) . indexOf ( interval ) < 0 ) { throw new Error ( 'Interval is invalid. The ttl must be of weeks, days, or hours' ) ; } return MS_DICTIONARY [ interval ] * duration ; }
Get the time in ms
@param {String} time - The time as a string.
@example timeInMs('24h'); // => 8.64e+7
@return {Number}
Get the time in ms