refactor(): use const and let instead of var
This commit is contained in:

committed by
Victor Berchet

parent
73593d4bf3
commit
77ee27c59e
@ -18,7 +18,7 @@
|
||||
|
||||
function benchmarksBootstrap() {
|
||||
// check query param
|
||||
var useBundles = location.search.indexOf('bundles=false') == -1;
|
||||
const useBundles = location.search.indexOf('bundles=false') == -1;
|
||||
if (useBundles) {
|
||||
System.config({
|
||||
defaultJSExtensions: true,
|
||||
|
@ -69,14 +69,14 @@ export class AppComponent {
|
||||
copies: number[] = [];
|
||||
values: string[] = [];
|
||||
constructor() {
|
||||
for (var i = 0; i < 50; i++) {
|
||||
for (let i = 0; i < 50; i++) {
|
||||
this.values[i] = `someValue${i}`;
|
||||
}
|
||||
}
|
||||
|
||||
setCopies(count: number) {
|
||||
this.copies = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
this.copies.push(i);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import {bindAction, profile} from '../../util';
|
||||
import {buildTable, emptyTable} from '../util';
|
||||
import {TableComponent} from './table';
|
||||
|
||||
var table: TableComponent;
|
||||
let table: TableComponent;
|
||||
|
||||
function destroyDom() {
|
||||
table.data = emptyTable;
|
||||
|
@ -11,7 +11,7 @@ import {buildTable, emptyTable} from '../util';
|
||||
import {TableComponent} from './table';
|
||||
|
||||
export function main() {
|
||||
var table: TableComponent;
|
||||
let table: TableComponent;
|
||||
|
||||
function destroyDom() { table.data = emptyTable; }
|
||||
|
||||
|
@ -21,7 +21,7 @@ import {CompilerConfig, DirectiveResolver} from '@angular/compiler';
|
||||
import {getIntParameter, bindAction} from '@angular/testing/src/benchmark_util';
|
||||
|
||||
function _createBindings(): any[] {
|
||||
var multiplyTemplatesBy = getIntParameter('elements');
|
||||
const multiplyTemplatesBy = getIntParameter('elements');
|
||||
return [
|
||||
{
|
||||
provide: DirectiveResolver,
|
||||
@ -42,7 +42,7 @@ function _createBindings(): any[] {
|
||||
export function main() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
bootstrap(CompilerAppComponent, _createBindings()).then((ref) => {
|
||||
var app = ref.instance;
|
||||
const app = ref.instance;
|
||||
bindAction('#compileNoBindings', measureWrapper(() => app.compileNoBindings(), 'No Bindings'));
|
||||
bindAction(
|
||||
'#compileWithBindings', measureWrapper(() => app.compileWithBindings(), 'With Bindings'));
|
||||
@ -51,13 +51,13 @@ export function main() {
|
||||
|
||||
function measureWrapper(func, desc) {
|
||||
return function() {
|
||||
var begin = new Date();
|
||||
const begin = new Date();
|
||||
print(`[${desc}] Begin...`);
|
||||
var onSuccess = function(_) {
|
||||
var elapsedMs = new Date().getTime() - begin.getTime();
|
||||
const onSuccess = function(_) {
|
||||
const elapsedMs = new Date().getTime() - begin.getTime();
|
||||
print(`[${desc}] ...done, took ${elapsedMs} ms`);
|
||||
};
|
||||
var onError = function(e) { DOM.logError(e); };
|
||||
const onError = function(e) { DOM.logError(e); };
|
||||
PromiseWrapper.then(func(), onSuccess, onError);
|
||||
};
|
||||
}
|
||||
@ -74,9 +74,9 @@ class MultiplyDirectiveResolver extends DirectiveResolver {
|
||||
}
|
||||
|
||||
private _fillCache(component: Type) {
|
||||
var view = super.resolve(component);
|
||||
var multipliedTemplates = new Array(this._multiplyBy);
|
||||
for (var i = 0; i < this._multiplyBy; ++i) {
|
||||
const view = super.resolve(component);
|
||||
const multipliedTemplates = new Array(this._multiplyBy);
|
||||
for (let i = 0; i < this._multiplyBy; ++i) {
|
||||
multipliedTemplates[i] = view.template;
|
||||
}
|
||||
this._cache.set(
|
||||
|
@ -13,41 +13,41 @@ import {bindAction, getIntParameter} from '@angular/testing/src/benchmark_util';
|
||||
|
||||
export function main() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
var count = getIntParameter('selectors');
|
||||
const count = getIntParameter('selectors');
|
||||
|
||||
var fixedMatcher;
|
||||
var fixedSelectorStrings = [];
|
||||
var fixedSelectors = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
let fixedMatcher;
|
||||
const fixedSelectorStrings = [];
|
||||
const fixedSelectors = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
fixedSelectorStrings.push(randomSelector());
|
||||
}
|
||||
for (var i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
fixedSelectors.push(CssSelector.parse(fixedSelectorStrings[i]));
|
||||
}
|
||||
fixedMatcher = new SelectorMatcher();
|
||||
for (var i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
fixedMatcher.addSelectables(fixedSelectors[i], i);
|
||||
}
|
||||
|
||||
function parse() {
|
||||
var result = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
const result = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
result.push(CssSelector.parse(fixedSelectorStrings[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function addSelectable() {
|
||||
var matcher = new SelectorMatcher();
|
||||
for (var i = 0; i < count; i++) {
|
||||
const matcher = new SelectorMatcher();
|
||||
for (let i = 0; i < count; i++) {
|
||||
matcher.addSelectables(fixedSelectors[i], i);
|
||||
}
|
||||
return matcher;
|
||||
}
|
||||
|
||||
function match() {
|
||||
var matchCount = 0;
|
||||
for (var i = 0; i < count; i++) {
|
||||
let matchCount = 0;
|
||||
for (let i = 0; i < count; i++) {
|
||||
fixedMatcher.match(fixedSelectors[i][0], (selector, selected) => { matchCount += selected; });
|
||||
}
|
||||
return matchCount;
|
||||
@ -59,18 +59,18 @@ export function main() {
|
||||
}
|
||||
|
||||
function randomSelector() {
|
||||
var res = randomStr(5);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
let res = randomStr(5);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
res += '.' + randomStr(5);
|
||||
}
|
||||
for (var i = 0; i < 3; i++) {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
res += '[' + randomStr(3) + '=' + randomStr(6) + ']';
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function randomStr(len) {
|
||||
var s = '';
|
||||
let s = '';
|
||||
while (s.length < len) {
|
||||
s += randomChar();
|
||||
}
|
||||
@ -78,7 +78,7 @@ function randomStr(len) {
|
||||
}
|
||||
|
||||
function randomChar() {
|
||||
var n = randomNum(62);
|
||||
const n = randomNum(62);
|
||||
if (n < 10) return n.toString(); // 1-10
|
||||
if (n < 36) return StringWrapper.fromCharCode(n + 55); // A-Z
|
||||
return StringWrapper.fromCharCode(n + 61); // a-z
|
||||
|
@ -14,16 +14,16 @@ import {BrowserModule, bootstrap} from '@angular/platform-browser';
|
||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||
import {bindAction, getIntParameter} from '@angular/testing/src/benchmark_util';
|
||||
|
||||
var testList = null;
|
||||
let testList = null;
|
||||
|
||||
export function main() {
|
||||
var size = getIntParameter('size');
|
||||
const size = getIntParameter('size');
|
||||
testList = new Array(size);
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => {
|
||||
var injector = ref.injector;
|
||||
var app: AppComponent = ref.instance;
|
||||
var appRef = injector.get(ApplicationRef);
|
||||
const injector = ref.injector;
|
||||
const app: AppComponent = ref.instance;
|
||||
const appRef = injector.get(ApplicationRef);
|
||||
|
||||
bindAction('#reset', function() {
|
||||
app.reset();
|
||||
|
@ -12,7 +12,7 @@ import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_ca
|
||||
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
|
||||
import {bindAction, getIntParameter, microBenchmark} from '@angular/testing/src/benchmark_util';
|
||||
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
|
||||
function setupReflector() {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
@ -20,48 +20,48 @@ function setupReflector() {
|
||||
|
||||
export function main() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
var iterations = getIntParameter('iterations');
|
||||
const iterations = getIntParameter('iterations');
|
||||
|
||||
// This benchmark does not use bootstrap and needs to create a reflector
|
||||
setupReflector();
|
||||
var bindings = [A, B, C, D, E];
|
||||
var injector = ReflectiveInjector.resolveAndCreate(bindings);
|
||||
const bindings = [A, B, C, D, E];
|
||||
const injector = ReflectiveInjector.resolveAndCreate(bindings);
|
||||
|
||||
var D_KEY = ReflectiveKey.get(D);
|
||||
var E_KEY = ReflectiveKey.get(E);
|
||||
var childInjector = injector.resolveAndCreateChild([])
|
||||
.resolveAndCreateChild([])
|
||||
.resolveAndCreateChild([])
|
||||
.resolveAndCreateChild([])
|
||||
.resolveAndCreateChild([]);
|
||||
const D_KEY = ReflectiveKey.get(D);
|
||||
const E_KEY = ReflectiveKey.get(E);
|
||||
const childInjector = injector.resolveAndCreateChild([])
|
||||
.resolveAndCreateChild([])
|
||||
.resolveAndCreateChild([])
|
||||
.resolveAndCreateChild([])
|
||||
.resolveAndCreateChild([]);
|
||||
|
||||
var variousProviders = [A, {provide: B, useClass: C}, [D, [E]], {provide: F, useValue: 6}];
|
||||
const variousProviders = [A, {provide: B, useClass: C}, [D, [E]], {provide: F, useValue: 6}];
|
||||
|
||||
var variousProvidersResolved = ReflectiveInjector.resolve(variousProviders);
|
||||
const variousProvidersResolved = ReflectiveInjector.resolve(variousProviders);
|
||||
|
||||
function getByToken() {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
for (let i = 0; i < iterations; ++i) {
|
||||
injector.get(D);
|
||||
injector.get(E);
|
||||
}
|
||||
}
|
||||
function getByKey() {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
for (let i = 0; i < iterations; ++i) {
|
||||
injector.get(D_KEY);
|
||||
injector.get(E_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
function getChild() {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
for (let i = 0; i < iterations; ++i) {
|
||||
childInjector.get(D);
|
||||
childInjector.get(E);
|
||||
}
|
||||
}
|
||||
|
||||
function instantiate() {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
var child = injector.resolveAndCreateChild([E]);
|
||||
for (let i = 0; i < iterations; ++i) {
|
||||
const child = injector.resolveAndCreateChild([E]);
|
||||
child.get(E);
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ export function main() {
|
||||
* Creates an injector with a variety of provider types.
|
||||
*/
|
||||
function createVariety() {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
for (let i = 0; i < iterations; ++i) {
|
||||
ReflectiveInjector.resolveAndCreate(variousProviders);
|
||||
}
|
||||
}
|
||||
@ -79,7 +79,7 @@ export function main() {
|
||||
* Same as [createVariety] but resolves providers ahead of time.
|
||||
*/
|
||||
function createVarietyResolved() {
|
||||
for (var i = 0; i < iterations; ++i) {
|
||||
for (let i = 0; i < iterations; ++i) {
|
||||
ReflectiveInjector.fromResolvedProviders(variousProvidersResolved);
|
||||
}
|
||||
}
|
||||
|
@ -37,18 +37,18 @@ export class App {
|
||||
scrollIncrement: number;
|
||||
|
||||
constructor() {
|
||||
var appSize = getIntParameter('appSize');
|
||||
let appSize = getIntParameter('appSize');
|
||||
this.iterationCount = getIntParameter('iterationCount');
|
||||
this.scrollIncrement = getIntParameter('scrollIncrement');
|
||||
appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table
|
||||
this.scrollAreas = [];
|
||||
for (var i = 0; i < appSize; i++) {
|
||||
for (let i = 0; i < appSize; i++) {
|
||||
this.scrollAreas.push(i);
|
||||
}
|
||||
bindAction('#run-btn', () => { this.runBenchmark(); });
|
||||
bindAction('#reset-btn', () => {
|
||||
this._getScrollDiv().scrollTop = 0;
|
||||
var existingMarker = this._locateFinishedMarker();
|
||||
const existingMarker = this._locateFinishedMarker();
|
||||
if (isPresent(existingMarker)) {
|
||||
DOM.removeChild(document.body, existingMarker);
|
||||
}
|
||||
@ -56,9 +56,9 @@ export class App {
|
||||
}
|
||||
|
||||
runBenchmark() {
|
||||
var scrollDiv = this._getScrollDiv();
|
||||
var n: number = this.iterationCount;
|
||||
var scheduleScroll;
|
||||
const scrollDiv = this._getScrollDiv();
|
||||
let n: number = this.iterationCount;
|
||||
let scheduleScroll;
|
||||
scheduleScroll = () => {
|
||||
TimerWrapper.setTimeout(() => {
|
||||
scrollDiv.scrollTop += this.scrollIncrement;
|
||||
@ -75,13 +75,13 @@ export class App {
|
||||
|
||||
// Puts a marker indicating that the test is finished.
|
||||
private _scheduleFinishedMarker() {
|
||||
var existingMarker = this._locateFinishedMarker();
|
||||
const existingMarker = this._locateFinishedMarker();
|
||||
if (isPresent(existingMarker)) {
|
||||
// Nothing to do, the marker is already there
|
||||
return;
|
||||
}
|
||||
TimerWrapper.setTimeout(() => {
|
||||
var finishedDiv = DOM.createElement('div');
|
||||
const finishedDiv = DOM.createElement('div');
|
||||
finishedDiv.id = 'done';
|
||||
DOM.setInnerHTML(finishedDiv, 'Finished');
|
||||
DOM.appendChild(document.body, finishedDiv);
|
||||
|
@ -87,7 +87,7 @@ export class StageButtonsComponent extends HasStyle {
|
||||
}
|
||||
|
||||
private _computeStageButtons() {
|
||||
var disabled = true;
|
||||
let disabled = true;
|
||||
this.stages = STATUS_LIST
|
||||
.map((status) => {
|
||||
const isCurrent = this._offering.status == status;
|
||||
|
@ -49,10 +49,10 @@ export class CustomDate {
|
||||
}
|
||||
|
||||
addDays(days: number): CustomDate {
|
||||
var newDay = this.day + days;
|
||||
var newMonth = this.month + Math.floor(newDay / 30);
|
||||
let newDay = this.day + days;
|
||||
const newMonth = this.month + Math.floor(newDay / 30);
|
||||
newDay = newDay % 30;
|
||||
var newYear = this.year + Math.floor(newMonth / 12);
|
||||
const newYear = this.year + Math.floor(newMonth / 12);
|
||||
return new CustomDate(newYear, newMonth, newDay);
|
||||
}
|
||||
|
||||
@ -68,10 +68,10 @@ export class RawEntity {
|
||||
if (key.indexOf('.') == -1) {
|
||||
return this._data[key];
|
||||
}
|
||||
var pieces = key.split('.');
|
||||
var last = pieces[pieces.length - 1];
|
||||
const pieces = key.split('.');
|
||||
const last = pieces[pieces.length - 1];
|
||||
pieces.length = pieces.length - 1;
|
||||
var target = this._resolve(pieces, this);
|
||||
const target = this._resolve(pieces, this);
|
||||
if (target == null) {
|
||||
return null;
|
||||
}
|
||||
@ -83,10 +83,10 @@ export class RawEntity {
|
||||
this._data[key] = value;
|
||||
return;
|
||||
}
|
||||
var pieces = key.split('.');
|
||||
var last = pieces[pieces.length - 1];
|
||||
const pieces = key.split('.');
|
||||
const last = pieces[pieces.length - 1];
|
||||
pieces.length = pieces.length - 1;
|
||||
var target = this._resolve(pieces, this);
|
||||
const target = this._resolve(pieces, this);
|
||||
target[last] = value;
|
||||
}
|
||||
|
||||
@ -94,16 +94,16 @@ export class RawEntity {
|
||||
if (!StringWrapper.contains(key, '.')) {
|
||||
return this._data.delete(key);
|
||||
}
|
||||
var pieces = key.split('.');
|
||||
var last = pieces[pieces.length - 1];
|
||||
const pieces = key.split('.');
|
||||
const last = pieces[pieces.length - 1];
|
||||
pieces.length = pieces.length - 1;
|
||||
var target = this._resolve(pieces, this);
|
||||
const target = this._resolve(pieces, this);
|
||||
return target.remove(last);
|
||||
}
|
||||
|
||||
private _resolve(pieces, start) {
|
||||
var cur = start;
|
||||
for (var i = 0; i < pieces.length; i++) {
|
||||
let cur = start;
|
||||
for (let i = 0; i < pieces.length; i++) {
|
||||
cur = cur[pieces[i]];
|
||||
if (cur == null) {
|
||||
return null;
|
||||
|
@ -9,15 +9,15 @@
|
||||
import {AAT_STATUS_LIST, Account, Company, CustomDate, Offering, Opportunity, STATUS_LIST} from './common';
|
||||
|
||||
export function generateOfferings(count: number): Offering[] {
|
||||
var res = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
const res = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
res.push(generateOffering(i));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
export function generateOffering(seed: number): Offering {
|
||||
var res = new Offering();
|
||||
const res = new Offering();
|
||||
res.name = generateName(seed++);
|
||||
res.company = generateCompany(seed++);
|
||||
res.opportunity = generateOpportunity(seed++);
|
||||
@ -33,24 +33,24 @@ export function generateOffering(seed: number): Offering {
|
||||
}
|
||||
|
||||
export function generateCompany(seed: number): Company {
|
||||
var res = new Company();
|
||||
const res = new Company();
|
||||
res.name = generateName(seed);
|
||||
return res;
|
||||
}
|
||||
|
||||
export function generateOpportunity(seed: number): Opportunity {
|
||||
var res = new Opportunity();
|
||||
const res = new Opportunity();
|
||||
res.name = generateName(seed);
|
||||
return res;
|
||||
}
|
||||
|
||||
export function generateAccount(seed: number): Account {
|
||||
var res = new Account();
|
||||
const res = new Account();
|
||||
res.accountId = seed;
|
||||
return res;
|
||||
}
|
||||
|
||||
var names = [
|
||||
const names = [
|
||||
'Foo', 'Bar', 'Baz', 'Qux', 'Quux', 'Garply', 'Waldo', 'Fred', 'Plugh', 'Xyzzy', 'Thud', 'Cruft',
|
||||
'Stuff'
|
||||
];
|
||||
@ -59,7 +59,7 @@ function generateName(seed: number): string {
|
||||
return names[seed % names.length];
|
||||
}
|
||||
|
||||
var offsets = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
const offsets = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
function randomDate(seed: number, minDate: CustomDate = null): CustomDate {
|
||||
if (minDate == null) {
|
||||
@ -69,13 +69,13 @@ function randomDate(seed: number, minDate: CustomDate = null): CustomDate {
|
||||
return minDate.addDays(offsets[seed % offsets.length]);
|
||||
}
|
||||
|
||||
var stringLengths = [5, 7, 9, 11, 13];
|
||||
var charCodeOffsets = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||
const stringLengths = [5, 7, 9, 11, 13];
|
||||
const charCodeOffsets = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||
|
||||
function randomString(seed: number): string {
|
||||
var len = stringLengths[seed % 5];
|
||||
var str = '';
|
||||
for (var i = 0; i < len; i++) {
|
||||
const len = stringLengths[seed % 5];
|
||||
let str = '';
|
||||
for (let i = 0; i < len; i++) {
|
||||
str += StringWrapper.fromCharCode(97 + charCodeOffsets[seed % 9] + i);
|
||||
}
|
||||
return str;
|
||||
|
@ -48,9 +48,9 @@ export class ScrollAreaComponent {
|
||||
}
|
||||
|
||||
onScroll(evt) {
|
||||
var scrollTop = 0;
|
||||
let scrollTop = 0;
|
||||
if (evt != null) {
|
||||
var scrollDiv = evt.target;
|
||||
const scrollDiv = evt.target;
|
||||
if (this.paddingDiv == null) {
|
||||
this.paddingDiv = scrollDiv.querySelector('#padding');
|
||||
}
|
||||
@ -60,9 +60,9 @@ export class ScrollAreaComponent {
|
||||
}
|
||||
scrollTop = scrollDiv.scrollTop;
|
||||
}
|
||||
var iStart = Math.floor(scrollTop / ITEM_HEIGHT);
|
||||
var iEnd = Math.min(iStart + VISIBLE_ITEMS + 1, this._fullList.length);
|
||||
var padding = iStart * ITEM_HEIGHT;
|
||||
const iStart = Math.floor(scrollTop / ITEM_HEIGHT);
|
||||
const iEnd = Math.min(iStart + VISIBLE_ITEMS + 1, this._fullList.length);
|
||||
const padding = iStart * ITEM_HEIGHT;
|
||||
if (this.innerDiv != null) {
|
||||
this.innerDiv.style.setProperty('height', `${HEIGHT - padding}px`);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import {bindAction, profile} from '../../util';
|
||||
import {buildTree, emptyTree} from '../util';
|
||||
import {TreeComponent} from './tree';
|
||||
|
||||
var tree: TreeComponent;
|
||||
let tree: TreeComponent;
|
||||
|
||||
function destroyDom() {
|
||||
tree.data = emptyTree;
|
||||
|
@ -12,7 +12,7 @@ import {TreeComponent} from './tree';
|
||||
const {patch} = require('incremental-dom');
|
||||
|
||||
export function main() {
|
||||
var tree: TreeComponent;
|
||||
let tree: TreeComponent;
|
||||
|
||||
function destroyDom() { tree.data = emptyTree; }
|
||||
|
||||
|
@ -92,7 +92,7 @@ export class FtlViewContainerRef implements ViewContainerRef {
|
||||
}
|
||||
|
||||
get(index: number): any {
|
||||
var result = this._firstView;
|
||||
let result = this._firstView;
|
||||
while (index > 0 && result) {
|
||||
result = result.next;
|
||||
index--;
|
||||
@ -166,7 +166,7 @@ export class FtlViewContainerRef implements ViewContainerRef {
|
||||
}
|
||||
|
||||
remove(index?: number): void {
|
||||
var view: FtlView<any> = <any>this.detach(index);
|
||||
const view: FtlView<any> = <any>this.detach(index);
|
||||
view.destroyInternal();
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ import {buildTree, emptyTree} from '../util';
|
||||
import {AppModule, RootTreeComponent} from './tree';
|
||||
|
||||
export function main() {
|
||||
var tree: RootTreeComponent;
|
||||
var appRef: ApplicationRef;
|
||||
let tree: RootTreeComponent;
|
||||
let appRef: ApplicationRef;
|
||||
|
||||
function destroyDom() {
|
||||
tree.data = emptyTree;
|
||||
|
@ -37,7 +37,7 @@ export class RootTreeComponent {
|
||||
|
||||
function createModule(): any {
|
||||
const components: any[] = [RootTreeComponent];
|
||||
for (var i = 0; i <= maxDepth; i++) {
|
||||
for (let i = 0; i <= maxDepth; i++) {
|
||||
components.push(createTreeComponent(i, i === maxDepth));
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,8 @@ import {buildTree, emptyTree} from '../util';
|
||||
import {AppModule, TreeComponent} from './tree';
|
||||
|
||||
export function init(moduleRef: NgModuleRef<AppModule>) {
|
||||
var tree: TreeComponent;
|
||||
var appRef: ApplicationRef;
|
||||
let tree: TreeComponent;
|
||||
let appRef: ApplicationRef;
|
||||
|
||||
function destroyDom() {
|
||||
tree.data = emptyTree;
|
||||
|
@ -20,7 +20,7 @@ export function main() {
|
||||
|
||||
function createDom() {
|
||||
const flatTree = flattenTree(buildTree(), []);
|
||||
for (var i = 0; i < flatTree.length; i++) {
|
||||
for (let i = 0; i < flatTree.length; i++) {
|
||||
const el: any = document.createElement('tree-leaf');
|
||||
el.data = flatTree[i];
|
||||
rootEl.appendChild(el);
|
||||
|
@ -13,13 +13,13 @@ export function getIntParameter(name: string) {
|
||||
}
|
||||
|
||||
export function getStringParameter(name: string) {
|
||||
var els = document.querySelectorAll(`input[name="${name}"]`);
|
||||
var value: any;
|
||||
var el: any;
|
||||
const els = document.querySelectorAll(`input[name="${name}"]`);
|
||||
let value: any;
|
||||
let el: any;
|
||||
|
||||
for (var i = 0; i < els.length; i++) {
|
||||
for (let i = 0; i < els.length; i++) {
|
||||
el = els[i];
|
||||
var type = el.type;
|
||||
const type = el.type;
|
||||
if ((type != 'radio' && type != 'checkbox') || el.checked) {
|
||||
value = el.value;
|
||||
break;
|
||||
@ -41,11 +41,11 @@ export function bindAction(selector: string, callback: () => void) {
|
||||
export function profile(create: () => void, destroy: () => void, name: string) {
|
||||
return function() {
|
||||
window.console.profile(name + ' w GC');
|
||||
var duration = 0;
|
||||
var count = 0;
|
||||
let duration = 0;
|
||||
let count = 0;
|
||||
while (count++ < 150) {
|
||||
(<any>window)['gc']();
|
||||
var start = window.performance.now();
|
||||
const start = window.performance.now();
|
||||
create();
|
||||
duration += window.performance.now() - start;
|
||||
destroy();
|
||||
@ -57,7 +57,7 @@ export function profile(create: () => void, destroy: () => void, name: string) {
|
||||
duration = 0;
|
||||
count = 0;
|
||||
while (count++ < 150) {
|
||||
var start = window.performance.now();
|
||||
const start = window.performance.now();
|
||||
create();
|
||||
duration += window.performance.now() - start;
|
||||
destroy();
|
||||
@ -70,15 +70,15 @@ export function profile(create: () => void, destroy: () => void, name: string) {
|
||||
// helper script that will read out the url parameters
|
||||
// and store them in appropriate form fields on the page
|
||||
function urlParamsToForm() {
|
||||
var regex = /(\w+)=(\w+)/g;
|
||||
var search = decodeURIComponent(location.search);
|
||||
var match: any[];
|
||||
const regex = /(\w+)=(\w+)/g;
|
||||
const search = decodeURIComponent(location.search);
|
||||
let match: any[];
|
||||
while (match = regex.exec(search)) {
|
||||
var name = match[1];
|
||||
var value = match[2];
|
||||
var els = document.querySelectorAll('input[name="' + name + '"]');
|
||||
var el: any;
|
||||
for (var i = 0; i < els.length; i++) {
|
||||
const name = match[1];
|
||||
const value = match[2];
|
||||
const els = document.querySelectorAll('input[name="' + name + '"]');
|
||||
let el: any;
|
||||
for (let i = 0; i < els.length; i++) {
|
||||
el = els[i];
|
||||
if (el.type === 'radio' || el.type === 'checkbox') {
|
||||
el.checked = el.value === value;
|
||||
|
Reference in New Issue
Block a user