MCPcopy Index your code
hub / github.com/prototypejs/prototype / parse

Function parse

test/unit/static/js/mocha.js:1642–1671  ·  view source on GitHub ↗

* Parse the given `str` and return milliseconds. * * @param {String} str * @return {Number} * @api private

(str)

Source from the content-addressed store, hash-verified

1640 */
1641
1642function parse(str) {
1643 var m = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(str);
1644 if (!m) return;
1645 var n = parseFloat(m[1]);
1646 var type = (m[2] || 'ms').toLowerCase();
1647 switch (type) {
1648 case 'years':
1649 case 'year':
1650 case 'y':
1651 return n * 31557600000;
1652 case 'days':
1653 case 'day':
1654 case 'd':
1655 return n * 86400000;
1656 case 'hours':
1657 case 'hour':
1658 case 'h':
1659 return n * 3600000;
1660 case 'minutes':
1661 case 'minute':
1662 case 'm':
1663 return n * 60000;
1664 case 'seconds':
1665 case 'second':
1666 case 's':
1667 return n * 1000;
1668 case 'ms':
1669 return n;
1670 }
1671}
1672
1673/**
1674 * Format the given `ms`.

Callers 1

mocha.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected