MCPcopy Create free account
hub / github.com/denoland/std / modeToString

Function modeToString

http/file_server.ts:85–102  ·  view source on GitHub ↗
(isDir: boolean, maybeMode: number | null)

Source from the content-addressed store, hash-verified

83 : undefined;
84
85function modeToString(isDir: boolean, maybeMode: number | null): string {
86 const modeMap = ["---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"];
87
88 if (maybeMode === null) {
89 return "(unknown mode)";
90 }
91 const mode = maybeMode.toString(8).padStart(3, "0");
92 let output = "";
93 mode
94 .split("")
95 .reverse()
96 .slice(0, 3)
97 .forEach((v) => {
98 output = `${modeMap[+v]} ${output}`;
99 });
100 output = `${isDir ? "d" : "-"} ${output}`;
101 return output;
102}
103
104function createStandardResponse(status: StatusCode, init?: ResponseInit) {
105 const statusText = STATUS_TEXT[status];

Callers 1

serveDirIndexFunction · 0.85

Calls 3

forEachMethod · 0.80
toStringMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected