MCPcopy Create free account
hub / github.com/ReactJSResources/react-webpack-babel / parse

Function parse

public/bundle.js:6402–6431  ·  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

6400 */
6401
6402 function parse(str) {
6403 var match = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(str);
6404 if (!match) return;
6405 var n = parseFloat(match[1]);
6406 var type = (match[2] || 'ms').toLowerCase();
6407 switch (type) {
6408 case 'years':
6409 case 'year':
6410 case 'y':
6411 return n * y;
6412 case 'days':
6413 case 'day':
6414 case 'd':
6415 return n * d;
6416 case 'hours':
6417 case 'hour':
6418 case 'h':
6419 return n * h;
6420 case 'minutes':
6421 case 'minute':
6422 case 'm':
6423 return n * m;
6424 case 'seconds':
6425 case 'second':
6426 case 's':
6427 return n * s;
6428 case 'ms':
6429 return n;
6430 }
6431 }
6432
6433 /**
6434 * Short format for `ms`.

Callers 2

hasFunction · 0.85
bundle.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected