_Scanner.prototype.scanNumber = function (start) { assert(isDigit(this.peek)); var simple = (this.index === start); this.advance(); // Skip initial digit. while (true) { if (isDigit(this.peek)) { } else if (this.peek == exports.$PERIOD) { simple = false; } else if (isExponentStart(this.peek)) { this.advance(); if (isExponentSign(this.peek)) this.advance(); if (!isDigit(this.peek)) this.error('Invalid exponent', -1); simple = false; } else { break; } this.advance(); } var str = this.input.substring(start, this.index); // TODO var value = simple ? lang_1.NumberWrapper.parseIntAutoRadix(str) : lang_1.NumberWrapper.parseFloat(str); return newNumberToken(start, value); };
/** * Exercises change detection in a loop and then prints the average amount of * time in milliseconds how long a single round of change detection takes for * the current state of the UI. It runs a minimum of 5 rounds for a minimum * of 500 milliseconds. * * Optionally, a user may pass a `config` parameter containing a map of * options. Supported options are: * * `record` (boolean) - causes the profiler to record a CPU profile while * it exercises the change detector. Example: * * ``` * ng.profiler.timeChangeDetection({record: true}) * ``` */ timeChangeDetection(config) { var record = isPresent(config) && config['record']; var profileName = 'Change Detection'; // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened var isProfilerAvailable = isPresent(window.console.profile); if (record && isProfilerAvailable) { window.console.profile(profileName); } var start = DOM.performanceNow(); var numTicks = 0; while (numTicks < 5 || (DOM.performanceNow() - start) < 500) { this.lifeCycle.tick(); numTicks++; } var end = DOM.performanceNow(); if (record && isProfilerAvailable) { // need to cast to <any> because type checker thinks there's no argument // while in fact there is: // // https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd window.console.profileEnd(profileName); } var msPerTick = (end - start) / numTicks; window.console.log(`ran ${numTicks} change detection cycles`); window.console.log(`${NumberWrapper.toFixed(msPerTick, 2)} ms per check`); }
AngularProfiler.prototype.timeChangeDetection = function (config) { var record = lang_1.isPresent(config) && config['record']; var profileName = 'Change Detection'; // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened var isProfilerAvailable = lang_1.isPresent(browser_1.window.console.profile); if (record && isProfilerAvailable) { browser_1.window.console.profile(profileName); } var start = dom_adapter_1.DOM.performanceNow(); var numTicks = 0; while (numTicks < 5 || (dom_adapter_1.DOM.performanceNow() - start) < 500) { this.lifeCycle.tick(); numTicks++; } var end = dom_adapter_1.DOM.performanceNow(); if (record && isProfilerAvailable) { // need to cast to <any> because type checker thinks there's no argument // while in fact there is: // // https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd browser_1.window.console.profileEnd(profileName); } var msPerTick = (end - start) / numTicks; browser_1.window.console.log("ran " + numTicks + " change detection cycles"); browser_1.window.console.log(lang_1.NumberWrapper.toFixed(msPerTick, 2) + " ms per check"); };
Animation.prototype.parseDurationString = function (duration) { var maxValue = 0; // duration must have at least 2 characters to be valid. (number + type) if (duration == null || duration.length < 2) { return maxValue; } else if (duration.substring(duration.length - 2) == 'ms') { var value = lang_1.NumberWrapper.parseInt(this.stripLetters(duration), 10); if (value > maxValue) maxValue = value; } else if (duration.substring(duration.length - 1) == 's') { var ms = lang_1.NumberWrapper.parseFloat(this.stripLetters(duration)) * 1000; var value = math_1.Math.floor(ms); if (value > maxValue) maxValue = value; } return maxValue; };
_Scanner.prototype.scanString = function () { assert(this.peek == exports.$SQ || this.peek == exports.$DQ); var start = this.index; var quote = this.peek; this.advance(); // Skip initial quote. var buffer; var marker = this.index; var input = this.input; while (this.peek != quote) { if (this.peek == exports.$BACKSLASH) { if (buffer == null) buffer = new lang_1.StringJoiner(); buffer.add(input.substring(marker, this.index)); this.advance(); var unescapedCode; if (this.peek == $u) { // 4 character hex code for unicode character. var hex = input.substring(this.index + 1, this.index + 5); try { unescapedCode = lang_1.NumberWrapper.parseInt(hex, 16); } catch (e) { this.error("Invalid unicode escape [\\u" + hex + "]", 0); } for (var i = 0; i < 5; i++) { this.advance(); } } else { unescapedCode = unescape(this.peek); this.advance(); } buffer.add(lang_1.StringWrapper.fromCharCode(unescapedCode)); marker = this.index; } else if (this.peek == exports.$EOF) { this.error('Unterminated quote', 0); } else { this.advance(); } } var last = input.substring(marker, this.index); this.advance(); // Skip terminating quote. // Compute the unescaped string value. var unescaped = last; if (buffer != null) { buffer.add(last); unescaped = buffer.toString(); } return newStringToken(start, unescaped); };
export function getIntParameter(name) { return NumberWrapper.parseInt(getStringParameter(name), 10); }
return elId.split(NG_ID_SEPARATOR).map(function (partStr) { return lang_1.NumberWrapper.parseInt(partStr, 10); });
function MaxLengthValidator(maxLength) { this.maxLength = lang_2.NumberWrapper.parseInt(maxLength, 10); }