MCPcopy Index your code
hub / github.com/react/create-react-app / parse

Function parse

packages/react-error-overlay/fixtures/bundle.mjs:19666–19715  ·  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

19664 */
19665
19666function parse(str) {
19667 str = String(str)
19668 if (str.length > 10000) {
19669 return
19670 }
19671 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str)
19672 if (!match) {
19673 return
19674 }
19675 var n = parseFloat(match[1])
19676 var type = (match[2] || 'ms').toLowerCase()
19677 switch (type) {
19678 case 'years':
19679 case 'year':
19680 case 'yrs':
19681 case 'yr':
19682 case 'y':
19683 return n * y
19684 case 'days':
19685 case 'day':
19686 case 'd':
19687 return n * d
19688 case 'hours':
19689 case 'hour':
19690 case 'hrs':
19691 case 'hr':
19692 case 'h':
19693 return n * h
19694 case 'minutes':
19695 case 'minute':
19696 case 'mins':
19697 case 'min':
19698 case 'm':
19699 return n * m
19700 case 'seconds':
19701 case 'second':
19702 case 'secs':
19703 case 'sec':
19704 case 's':
19705 return n * s
19706 case 'milliseconds':
19707 case 'millisecond':
19708 case 'msecs':
19709 case 'msec':
19710 case 'ms':
19711 return n
19712 default:
19713 return undefined
19714 }
19715}
19716
19717/**
19718 * Short format for `ms`.

Callers 10

hasFunction · 0.70
bundle.mjsFile · 0.70
getStackFramesFunction · 0.50
unmapper.jsFile · 0.50
mapper.jsFile · 0.50
chrome.jsFile · 0.50
generic.jsFile · 0.50
react.jsFile · 0.50
safari.jsFile · 0.50
firefox.jsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected