Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
typings: define types for os binding
  • Loading branch information
targos committed Sep 26, 2021
commit c2460eb5b8a944dcad30b199f61fe5fb55ab697c
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"./typings/internalBinding/http_parser.d.ts",
"./typings/internalBinding/messaging.d.ts",
"./typings/internalBinding/options.d.ts",
"./typings/internalBinding/os.d.ts",
"./typings/internalBinding/serdes.d.ts",
"./typings/internalBinding/timers.d.ts",
"./typings/internalBinding/util.d.ts",
Expand Down
21 changes: 21 additions & 0 deletions typings/internalBinding/os.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
declare function InternalBinding(binding: 'os'): {
getHostname(ctx: object): string | undefined;
Comment thread
targos marked this conversation as resolved.
Outdated
getLoadAvg(array: Float64Array): void;
getUptime(): number;
getTotalMem(): number;
getFreeMem(): number;
getCPUs(): Array<string | number>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getCPUs(): Array<string | number>;
getCPUs(): (string | number)[];

for consistency with other dts

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a preference to use type[] for simple types and Array<types> for more complex ones

getInterfaceAddresses(ctx: object): Array<string | number | boolean> | undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getInterfaceAddresses(ctx: object): Array<string | number | boolean> | undefined;
getInterfaceAddresses(ctx: object): (string | number | boolean)[] | undefined;

getHomeDirectory(ctx: object): string | undefined;
getUserInfo(options: {encoding?: string} | undefined, ctx: object): {
Comment thread
targos marked this conversation as resolved.
Outdated
uid: number;
gid: number;
username: string;
homedir: string;
shell: string | null;
} | undefined;
setPriority(pid: number, priority: number, ctx: object): number;
getPriority(pid: number, ctx: object): number | undefined;
getOSInformation(ctx: object): [sysname: string, version: string, release: string];
isBigEndian: boolean;
};