提交 c0cfb1a6 编写于 作者: B Benjamin Pasero

💄

上级 cafc25cc
......@@ -18,7 +18,7 @@ export function equals<T>(one: T[], other: T[], itemEquals: (a: T, b: T) => bool
return false;
}
for (var i = 0, len = one.length; i < len; i++) {
for (let i = 0, len = one.length; i < len; i++) {
if (!itemEquals(one[i], other[i])) {
return false;
}
......@@ -177,7 +177,7 @@ export function first<T>(array: T[], fn: (item: T) => boolean, notFoundValue: T
export function commonPrefixLength<T>(one: T[], other: T[], equals: (a: T, b: T) => boolean = (a, b) => a === b): number {
let result = 0;
for (var i = 0, len = Math.min(one.length, other.length); i < len && equals(one[i], other[i]); i++) {
for (let i = 0, len = Math.min(one.length, other.length); i < len && equals(one[i], other[i]); i++) {
result++;
}
......
......@@ -71,8 +71,8 @@ export interface ITask<T> {
* The throttler implements this via the queue() method, by providing it a task
* factory. Following the example:
*
* var throttler = new Throttler();
* var letters = [];
* const throttler = new Throttler();
* const letters = [];
*
* function deliver() {
* const lettersToDeliver = letters;
......@@ -166,8 +166,8 @@ export class SimpleThrottler {
* to be executed and the waiting period (delay) must be passed in as arguments. Following
* the example:
*
* var delayer = new Delayer(WAITING_PERIOD);
* var letters = [];
* const delayer = new Delayer(WAITING_PERIOD);
* const letters = [];
*
* function letterReceived(l) {
* letters.push(l);
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import nls = require('vs/nls');
export function since(date: Date): string {
var seconds = (new Date().getTime() - date.getTime()) / 1000;
if (seconds < 60) {
return nls.localize('diff.seconds.verbose', "just now");
}
var minutes = seconds / 60;
if (minutes < 60) {
return Math.floor(minutes) === 1 ? nls.localize('diff.minute.verbose', "1 minute ago") : nls.localize('diff.minutes.verbose', "{0} minutes ago", Math.floor(minutes));
}
var hours = minutes / 60;
if (hours < 24) {
return Math.floor(hours) === 1 ? nls.localize('diff.hour.verbose', "1 hour ago") : nls.localize('diff.hours.verbose', "{0} hours ago", Math.floor(hours));
}
var days = hours / 24;
if (Math.floor(days) === 1) {
return nls.localize('diff.days.yesterday', "yesterday");
}
if (days > 6 && days < 8) {
return nls.localize('diff.days.week', "a week ago");
}
if (days > 30 && days < 40) {
return nls.localize('diff.days.month', "a month ago");
}
return nls.localize('diff.days.verbose', "{0} days ago", Math.floor(days));
}
\ No newline at end of file
......@@ -52,7 +52,7 @@ export class LinkedMap<K extends Key, T> {
}
public keys(): K[] {
var keys: K[] = [];
const keys: K[] = [];
for (let key in this.map) {
keys.push(this.map[key].key);
}
......@@ -60,7 +60,7 @@ export class LinkedMap<K extends Key, T> {
}
public values(): T[] {
var values: T[] = [];
const values: T[] = [];
for (let key in this.map) {
values.push(this.map[key].value);
}
......@@ -68,7 +68,7 @@ export class LinkedMap<K extends Key, T> {
}
public entries(): Entry<K, T>[] {
var entries: Entry<K, T>[] = [];
const entries: Entry<K, T>[] = [];
for (let key in this.map) {
entries.push(this.map[key]);
}
......
......@@ -143,7 +143,7 @@ function guessMimeTypeByPath(path: string, filename: string, associations: IText
let patternMatch: ITextMimeAssociationItem;
let extensionMatch: ITextMimeAssociationItem;
for (var i = 0; i < associations.length; i++) {
for (let i = 0; i < associations.length; i++) {
let association = associations[i];
// First exact name match
......@@ -243,7 +243,7 @@ export function isUnspecific(mime: string[] | string): boolean {
}
export function suggestFilename(langId: string, prefix: string): string {
for (var i = 0; i < registeredAssociations.length; i++) {
for (let i = 0; i < registeredAssociations.length; i++) {
let association = registeredAssociations[i];
if (association.userConfigured) {
continue; // only support registered ones
......
......@@ -12,23 +12,23 @@ export namespace Schemas {
* A schema that is used for models that exist in memory
* only and that have no correspondence on a server or such.
*/
export var inMemory: string = 'inmemory';
export const inMemory: string = 'inmemory';
/**
* A schema that is used for setting files
*/
export var vscode: string = 'vscode';
export const vscode: string = 'vscode';
/**
* A schema that is used for internal private files
*/
export var internal: string = 'private';
export const internal: string = 'private';
export var http: string = 'http';
export const http: string = 'http';
export var https: string = 'https';
export const https: string = 'https';
export var file: string = 'file';
export const file: string = 'file';
}
export interface IXHROptions {
......
......@@ -11,12 +11,12 @@ import { CharCode } from 'vs/base/common/charCode';
/**
* The forward slash path separator.
*/
export var sep = '/';
export const sep = '/';
/**
* The native path separator depending on the OS.
*/
export var nativeSep = isWindows ? '\\' : '/';
export const nativeSep = isWindows ? '\\' : '/';
export function relative(from: string, to: string): string {
const originalNormalizedFrom = normalize(from);
......@@ -50,7 +50,7 @@ export function relative(from: string, to: string): string {
* @returns the directory name of a path.
*/
export function dirname(path: string): string {
var idx = ~path.lastIndexOf('/') || ~path.lastIndexOf('\\');
const idx = ~path.lastIndexOf('/') || ~path.lastIndexOf('\\');
if (idx === 0) {
return '.';
} else if (~idx === 0) {
......@@ -64,7 +64,7 @@ export function dirname(path: string): string {
* @returns the base name of a path.
*/
export function basename(path: string): string {
var idx = ~path.lastIndexOf('/') || ~path.lastIndexOf('\\');
const idx = ~path.lastIndexOf('/') || ~path.lastIndexOf('\\');
if (idx === 0) {
return path;
} else if (~idx === path.length - 1) {
......@@ -79,7 +79,7 @@ export function basename(path: string): string {
*/
export function extname(path: string): string {
path = basename(path);
var idx = ~path.lastIndexOf('.');
const idx = ~path.lastIndexOf('.');
return idx ? path.substring(~idx) : '';
}
......
......@@ -6,7 +6,7 @@
import { globals } from 'vs/base/common/platform';
var hasPerformanceNow = (globals.performance && typeof globals.performance.now === 'function');
const hasPerformanceNow = (globals.performance && typeof globals.performance.now === 'function');
export class StopWatch {
......
......@@ -607,8 +607,8 @@ export function safeBtoa(str: string): string {
}
export function repeat(s: string, count: number): string {
var result = '';
for (var i = 0; i < count; i++) {
let result = '';
for (let i = 0; i < count; i++) {
result += s;
}
return result;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册