MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / number2permission

Function number2permission

frontend/src/tools/permission.ts:12–35  ·  view source on GitHub ↗
(permission: number)

Source from the content-addressed store, hash-verified

10};
11
12export const number2permission = (permission: number) => {
13 const calculate = (num: number): string[] => {
14 const arr: string[] = [];
15 if (num - 4 >= 0) {
16 arr.push("4");
17 num -= 4;
18 }
19 if (num - 2 >= 0) {
20 arr.push("2");
21 num -= 2;
22 }
23 if (num - 1 >= 0) {
24 arr.push("1");
25 num -= 1;
26 }
27 return arr;
28 };
29 const str = permission.toString().padStart(3, "0");
30 return {
31 owner: calculate(parseInt(str[0])),
32 usergroup: calculate(parseInt(str[1])),
33 everyone: calculate(parseInt(str[2]))
34 };
35};

Callers 1

changePermissionFunction · 0.90

Calls 1

calculateFunction · 0.85

Tested by

no test coverage detected