Skip to content

Commit dbdc383

Browse files
committed
Use arrow functions
1 parent 27c4a89 commit dbdc383

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/tsserver/server.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace ts.server {
1919
connect(options: { port: number }, onConnect?: () => void): NodeSocket
2020
} = require("net");
2121

22-
const getGlobalTypingsCacheLocation = function () {
22+
const getGlobalTypingsCacheLocation = () => {
2323
switch (process.platform) {
2424
case "win32": {
2525
const basePath = process.env.LOCALAPPDATA ||
@@ -42,9 +42,9 @@ namespace ts.server {
4242
default:
4343
return Debug.fail(`unsupported platform '${process.platform}'`);
4444
}
45-
}
45+
};
4646

47-
const getNonWindowsCacheLocation = function (platformIsDarwin: boolean) {
47+
const getNonWindowsCacheLocation = (platformIsDarwin: boolean) => {
4848
if (process.env.XDG_CACHE_HOME) {
4949
return process.env.XDG_CACHE_HOME;
5050
}
@@ -57,7 +57,7 @@ namespace ts.server {
5757
? "Library/Caches"
5858
: ".cache";
5959
return combinePaths(normalizeSlashes(homePath), cacheFolder);
60-
}
60+
};
6161

6262
interface NodeChildProcess {
6363
send(message: any, sendHandle?: any): void;
@@ -591,7 +591,7 @@ namespace ts.server {
591591
logToFile?: boolean;
592592
}
593593

594-
const parseLoggingEnvironmentString = function (logEnvStr: string | undefined): LogOptions {
594+
const parseLoggingEnvironmentString = (logEnvStr: string | undefined): LogOptions => {
595595
if (!logEnvStr) {
596596
return {};
597597
}
@@ -636,9 +636,9 @@ namespace ts.server {
636636
}
637637
return { value: stripQuotes(pathStart), extraPartCounter };
638638
}
639-
}
639+
};
640640

641-
const getLogLevel = function (level: string | undefined) {
641+
const getLogLevel = (level: string | undefined) => {
642642
if (level) {
643643
const l = level.toLowerCase();
644644
for (const name in LogLevel) {
@@ -648,10 +648,10 @@ namespace ts.server {
648648
}
649649
}
650650
return undefined;
651-
}
651+
};
652652

653653
// TSS_LOG "{ level: "normal | verbose | terse", file?: string}"
654-
const createLogger = function () {
654+
const createLogger = () => {
655655
const cmdLineLogFileName = findArgument("--logFile");
656656
const cmdLineVerbosity = getLogLevel(findArgument("--logVerbosity"));
657657
const envLogOptions = parseLoggingEnvironmentString(process.env.TSS_LOG);
@@ -668,13 +668,13 @@ namespace ts.server {
668668

669669
const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel;
670670
return new Logger(substitutedLogFileName!, envLogOptions.traceToConsole!, logVerbosity!); // TODO: GH#18217
671-
}
671+
};
672672
// This places log file in the directory containing editorServices.js
673673
// TODO: check that this location is writable
674674

675675
// average async stat takes about 30 microseconds
676676
// set chunk size to do 30 files in < 1 millisecond
677-
const createPollingWatchedFileSet = function (interval = 2500, chunkSize = 30) {
677+
const createPollingWatchedFileSet = (interval = 2500, chunkSize = 30) => {
678678
const watchedFiles: WatchedFile[] = [];
679679
let nextFileToCheck = 0;
680680
return { getModifiedTime, poll, startWatchTimer, addFile, removeFile };
@@ -750,7 +750,7 @@ namespace ts.server {
750750
function removeFile(file: WatchedFile) {
751751
unorderedRemoveItem(watchedFiles, file);
752752
}
753-
}
753+
};
754754

755755
// REVIEW: for now this implementation uses polling.
756756
// The advantage of polling is that it works reliably
@@ -770,24 +770,24 @@ namespace ts.server {
770770
const pending: Buffer[] = [];
771771
let canWrite = true;
772772

773-
const writeMessage = function (buf: Buffer) {
773+
const writeMessage = (buf: Buffer) => {
774774
if (!canWrite) {
775775
pending.push(buf);
776776
}
777777
else {
778778
canWrite = false;
779779
process.stdout.write(buf, setCanWriteFlagAndWriteMessageIfNecessary);
780780
}
781-
}
781+
};
782782

783-
const setCanWriteFlagAndWriteMessageIfNecessary = function () {
783+
const setCanWriteFlagAndWriteMessageIfNecessary = () => {
784784
canWrite = true;
785785
if (pending.length) {
786786
writeMessage(pending.shift()!);
787787
}
788-
}
788+
};
789789

790-
const extractWatchDirectoryCacheKey = function (path: string, currentDriveKey: string | undefined) {
790+
const extractWatchDirectoryCacheKey = (path: string, currentDriveKey: string | undefined) => {
791791
path = normalizeSlashes(path);
792792
if (isUNCPath(path)) {
793793
// UNC path: extract server name
@@ -811,11 +811,11 @@ namespace ts.server {
811811
}
812812
// do not cache any other cases
813813
return undefined;
814-
}
814+
};
815815

816-
const isUNCPath = function (s: string): boolean {
816+
const isUNCPath = (s: string): boolean => {
817817
return s.length > 2 && s.charCodeAt(0) === CharacterCodes.slash && s.charCodeAt(1) === CharacterCodes.slash;
818-
}
818+
};
819819

820820
const logger = createLogger();
821821

@@ -827,15 +827,15 @@ namespace ts.server {
827827
const noopWatcher: FileWatcher = { close: noop };
828828
// This is the function that catches the exceptions when watching directory, and yet lets project service continue to function
829829
// Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point
830-
const watchDirectorySwallowingException = function (path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher {
830+
const watchDirectorySwallowingException = (path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher => {
831831
try {
832832
return originalWatchDirectory(path, callback, recursive, options);
833833
}
834834
catch (e) {
835835
logger.info(`Exception when creating directory watcher: ${e.message}`);
836836
return noopWatcher;
837837
}
838-
}
838+
};
839839

840840
if (useWatchGuard) {
841841
const currentDrive = extractWatchDirectoryCacheKey(sys.resolvePath(sys.getCurrentDirectory()), /*currentDriveKey*/ undefined);
@@ -923,10 +923,10 @@ namespace ts.server {
923923
cancellationToken = nullCancellationToken;
924924
}
925925

926-
const parseEventPort = function (eventPortStr: string | undefined) {
926+
const parseEventPort = (eventPortStr: string | undefined) => {
927927
const eventPort = eventPortStr === undefined ? undefined : parseInt(eventPortStr);
928928
return eventPort !== undefined && !isNaN(eventPort) ? eventPort : undefined;
929-
}
929+
};
930930
const eventPort: number | undefined = parseEventPort(findArgument("--eventPort"));
931931

932932
const localeStr = findArgument("--locale");
@@ -941,13 +941,13 @@ namespace ts.server {
941941
const npmLocation = findArgument(Arguments.NpmLocation);
942942
const validateDefaultNpmLocation = hasArgument(Arguments.ValidateDefaultNpmLocation);
943943

944-
const parseStringArray = function (argName: string): readonly string[] {
944+
const parseStringArray = (argName: string): readonly string[] => {
945945
const arg = findArgument(argName);
946946
if (arg === undefined) {
947947
return emptyArray;
948948
}
949949
return arg.split(",").filter(name => name !== "");
950-
}
950+
};
951951

952952
const globalPlugins = parseStringArray("--globalPlugins");
953953
const pluginProbeLocations = parseStringArray("--pluginProbeLocations");

0 commit comments

Comments
 (0)