Changelog:
- Added `getGroupByName() getGroupByGid() getUserByName getUserByUid()` methods to the `Bash` class. - Fixed a bug inside the `localStorage` caching logic that saved only 32 characters out of 36 in the signature UUID. - Added support for reverse order sorting in the quick sort implementation. **Commands:** - ls -l -a -A -U -g -G -h -f -n -N -r -Q -p -o - cd
This commit is contained in:
@@ -161,4 +161,36 @@ export class Bash {
|
||||
|
||||
return `${(bytes / Math.pow(k, i)).toFixed(dp)}${units[i]}`;
|
||||
}
|
||||
|
||||
getGroupByName(name: string): Group {
|
||||
const out: Group | undefined = this._group.find((group) => group.groupname === name);
|
||||
console.log(out);
|
||||
|
||||
if (out) return out;
|
||||
else throw new Error(`Cannot find a user group named ${name}`);
|
||||
}
|
||||
|
||||
getUserByName(name: string): User {
|
||||
const out: User | undefined = this._passwd.find((user) => user.username === name);
|
||||
console.log(out);
|
||||
|
||||
if (out) return out;
|
||||
else throw new Error(`Cannot find a user named ${name}`);
|
||||
}
|
||||
|
||||
getGroupByGid(gid: number): Group {
|
||||
const out: Group | undefined = this._group.find((group) => group.gid === gid);
|
||||
console.log(out);
|
||||
|
||||
if (out) return out;
|
||||
else throw new Error(`Cannot find a user group named ${name}`);
|
||||
}
|
||||
|
||||
getUserByUid(uid: number): User {
|
||||
const out: User | undefined = this._passwd.find((user) => user.uid === uid);
|
||||
console.log(out);
|
||||
|
||||
if (out) return out;
|
||||
else throw new Error(`Cannot find a user group named ${name}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user