Skip to content

Commit

Permalink
Add .editorConfig, fix doc comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacingBat3 committed May 4, 2024
1 parent 5e8c11c commit dedd298
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.{ts,json}]
indent_size = 2
indent_style = space
charset = utf-8
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = true
36 changes: 18 additions & 18 deletions sources/common/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export abstract class Protocol<S extends GenericServer,T extends string=string>
}
/**
* Whenever this class has been *destroyed*.
*
*
* @see {@link destroy} for more details about this state.
*/
public isDestroyed() {
Expand All @@ -117,17 +117,17 @@ export abstract class Protocol<S extends GenericServer,T extends string=string>
* values with a reference to the function that throws an error (for methods
* and some required properties using getters) or sets them to a nullish value
* (for optional properties).
*
*
* As it is hard to guarantee the Garbage Collector will ever deallocate
* memory after dereferencing all of the objects, the goal is to prevent API
* consumers from using class method that no longer make sense than implement
* any kind of the memory cleanup logic.
*
*
* **Note: This operation is designed to be irreversible!** You will have to
* initialize the new class instance if you want to use given transport again.
*
*
* @throws {@link Error} in case object has been already destroyed.
*
*
* @since v1.1.0
*/
public destroy() {
Expand Down Expand Up @@ -167,10 +167,10 @@ export abstract class Protocol<S extends GenericServer,T extends string=string>
}
/**
* Adds a hook to the given hook list if it doesn't exist in it.
*
*
* @param {T extends HookName} name - A name of hook list.
* @param value - A function that will be added to hook list.
*
*
* @returns number of hooks of given key or `false` if value were added before
* @throws {@link TypeError} on invalid function parameter types.
* @since v1.0.0
Expand All @@ -183,10 +183,10 @@ export abstract class Protocol<S extends GenericServer,T extends string=string>
return wereAddedBefore ? false : [...this.#hooks[name].list].length;
}
/**
* Removes given hook function from give the hook list.
*
* Removes given hook function from the given hook list.
*
* @param name - A name of hook list.
*
*
* @returns whenever hook has been deleted
* @throws {@link TypeError} on invalid function parameter types.
* @since v1.0.0
Expand All @@ -198,9 +198,9 @@ export abstract class Protocol<S extends GenericServer,T extends string=string>
}
/**
* Removes **all** hooks from the given hook list.
*
*
* @param name - A name of hook list.
*
*
* @returns if hook list wasn't empty before removing — values from it
* @throws {@link TypeError} on invalid hook list name.
* @since v1.0.0
Expand All @@ -214,9 +214,9 @@ export abstract class Protocol<S extends GenericServer,T extends string=string>
}
/**
* Lists all hooks from the given hook list.
*
*
* @param name - A name of hook list.
*
*
* @returns `Array` of hooks
* @throws {@link TypeError} on invalid hook list name.
* @since v1.0.0
Expand All @@ -228,9 +228,9 @@ export abstract class Protocol<S extends GenericServer,T extends string=string>
}
/**
* Whenever any of hooks will execute by server.
*
*
* @param name - A name of hook list.
*
*
* @returns whenever hooks are *active*
* @throws {@link TypeError} on invalid hook list name.
* @since v1.0.0
Expand All @@ -244,10 +244,10 @@ export abstract class Protocol<S extends GenericServer,T extends string=string>
}
/**
* Switches state of a given hook list, which can either disable it or not.
*
*
* @param name - A name of hook list.
* @param active - New state of hooks. Defaults to negation of previous state.
*
*
* @returns current state of given hook (i.e if it is active or not)
* @throws {@link TypeError} on invalid function parameter types.
* @since v1.0.0
Expand Down
12 changes: 6 additions & 6 deletions sources/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ interface GetServerEvt {

/**
* Reserves a server at given port range. Used by constructor of
* {@link WebSocketProtocol}.
*
* {@link Protocol}.
*
* @summary
*
*
* If first element of range is greater than last, port lookup will be done
* downwards (e.g. `6472` → `6471`), else it will lookup ports upwards (e.g.
* `6463` → `6464`).
*
*
* @param start - first element of port range
* @param end - last element of port range
* @param getter - method to get the server somehow
*
*
* @returns
*
*
* A {@link Promise} that resolves to object with the negotiated port number and the {@link Server} reference.
*/
export async function getServer<S extends GenericServer>(start:number,end:number,getter:(port:number) => S,events?:GetServerEvt,...rest:[]) {
Expand Down
8 changes: 4 additions & 4 deletions sources/transport/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {
* A list of standard status codes used within WebSocket communication at
* connection close. Currently, not all are documented there, although all were
* listed, with some additional ones took from MDN.
*
*
* Reference: [MDN], [RFC 6455].
*
*
* [MDN]: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code "CloseEvent.close – Web APIs | MDN"
* [RFC 6455]: https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1 "RFC 6455: The WebSocket protocol."
*/
Expand Down Expand Up @@ -106,10 +106,10 @@ export class WebSocketProtocol extends Protocol<Server,"WebSocket"> {
});
}
/** Creates new instance of {@link WebSocketProtocol} class.
*
*
* @param validOrigins - Whitelist of client origins as {@link RegExp} patterns or strings.
* @param console - [`Console`](https://nodejs.org/api/console.html#console) instance used within class (defaults to {@link global.console}).
*
*
* @throws - {@link Error} if server couldn't be created within a given port range.
*/
constructor(validOrigins:(RegExp|string)[], console?:Console|null, color: fgColor = "magenta") {
Expand Down

0 comments on commit dedd298

Please sign in to comment.